Download service: Rename DownloadService to BackgroundDownloadService.
Based on some discussion and to avoid class name conflicts, this CL
renames download::DownloadService to
download::BackgroundDownloadService.
Service factories and implementation classes are also renamed.
Trace event and histogram strings are not renamed.
Bug: 1215315
Change-Id: Ia65f680bc6a20e7ada37e3858f33eca16dc545f7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2970207
Reviewed-by: Sophie Chang <sophiechang@chromium.org>
Reviewed-by: Carlos Knippschild <carlosk@chromium.org>
Reviewed-by: Bo <boliu@chromium.org>
Reviewed-by: Alexander Alekseev <alemate@chromium.org>
Reviewed-by: Sylvain Defresne <sdefresne@chromium.org>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Reviewed-by: David Trainor <dtrainor@chromium.org>
Commit-Queue: Xing Liu <xingliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#894342}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
c69dc63df9
commit
276df674fb
chrome/browser
BUILD.gn
ash
plugin_vm
background_fetch
background_fetch_browsertest.ccbackground_fetch_delegate_factory.ccbackground_fetch_delegate_impl.ccbackground_fetch_delegate_impl.h
download
offline_pages
optimization_guide
prediction
profiles
ui
webui
components
background_fetch
download
content
internal
background_service
public
offline_pages
content/web_test/browser
ios/chrome/browser
browser_state
download
weblayer
@ -398,6 +398,8 @@ static_library("browser") {
|
||||
"dom_distiller/tab_utils.h",
|
||||
"domain_reliability/service_factory.cc",
|
||||
"domain_reliability/service_factory.h",
|
||||
"download/background_download_service_factory.cc",
|
||||
"download/background_download_service_factory.h",
|
||||
"download/chrome_download_manager_delegate.cc",
|
||||
"download/chrome_download_manager_delegate.h",
|
||||
"download/deferred_client_wrapper.cc",
|
||||
@ -434,8 +436,6 @@ static_library("browser") {
|
||||
"download/download_query.h",
|
||||
"download/download_request_limiter.cc",
|
||||
"download/download_request_limiter.h",
|
||||
"download/download_service_factory.cc",
|
||||
"download/download_service_factory.h",
|
||||
"download/download_started_animation.h",
|
||||
"download/download_stats.cc",
|
||||
"download/download_stats.h",
|
||||
|
@ -8,11 +8,11 @@
|
||||
#include "base/threading/sequenced_task_runner_handle.h"
|
||||
#include "chrome/browser/ash/plugin_vm/plugin_vm_installer.h"
|
||||
#include "chrome/browser/ash/plugin_vm/plugin_vm_installer_factory.h"
|
||||
#include "chrome/browser/download/download_service_factory.h"
|
||||
#include "chrome/browser/download/background_download_service_factory.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/browser/profiles/profile_key.h"
|
||||
#include "components/download/public/background_service/background_download_service.h"
|
||||
#include "components/download/public/background_service/download_metadata.h"
|
||||
#include "components/download/public/background_service/download_service.h"
|
||||
#include "services/network/public/cpp/resource_request_body.h"
|
||||
|
||||
namespace plugin_vm {
|
||||
@ -35,8 +35,9 @@ void PluginVmImageDownloadClient::OnServiceInitialized(
|
||||
// TODO(timloh): It appears that only completed downloads (aka previous
|
||||
// successful installations) surface here, so this logic might not be needed.
|
||||
for (const auto& download : downloads) {
|
||||
VLOG(1) << "Download tracked by DownloadService: " << download.guid;
|
||||
DownloadServiceFactory::GetForKey(profile_->GetProfileKey())
|
||||
VLOG(1) << "Download tracked by BackgroundDownloadService: "
|
||||
<< download.guid;
|
||||
BackgroundDownloadServiceFactory::GetForKey(profile_->GetProfileKey())
|
||||
->CancelDownload(download.guid);
|
||||
}
|
||||
}
|
||||
@ -51,7 +52,7 @@ void PluginVmImageDownloadClient::OnDownloadStarted(
|
||||
// We do not want downloads that are tracked by download service from its
|
||||
// initialization to proceed.
|
||||
if (!IsCurrentDownload(guid)) {
|
||||
DownloadServiceFactory::GetForKey(profile_->GetProfileKey())
|
||||
BackgroundDownloadServiceFactory::GetForKey(profile_->GetProfileKey())
|
||||
->CancelDownload(guid);
|
||||
return;
|
||||
}
|
||||
|
@ -25,12 +25,12 @@
|
||||
#include "chrome/browser/ash/plugin_vm/plugin_vm_pref_names.h"
|
||||
#include "chrome/browser/ash/plugin_vm/plugin_vm_util.h"
|
||||
#include "chrome/browser/ash/profiles/profile_helper.h"
|
||||
#include "chrome/browser/download/download_service_factory.h"
|
||||
#include "chrome/browser/download/background_download_service_factory.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/browser/profiles/profile_key.h"
|
||||
#include "chromeos/dbus/debug_daemon/debug_daemon_client.h"
|
||||
#include "components/download/public/background_service/background_download_service.h"
|
||||
#include "components/download/public/background_service/download_metadata.h"
|
||||
#include "components/download/public/background_service/download_service.h"
|
||||
#include "components/prefs/pref_service.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
@ -107,8 +107,8 @@ PluginVmSetupResult BucketForCancelledInstall(
|
||||
|
||||
PluginVmInstaller::PluginVmInstaller(Profile* profile)
|
||||
: profile_(profile),
|
||||
download_service_(
|
||||
DownloadServiceFactory::GetForKey(profile->GetProfileKey())) {}
|
||||
download_service_(BackgroundDownloadServiceFactory::GetForKey(
|
||||
profile->GetProfileKey())) {}
|
||||
|
||||
absl::optional<PluginVmInstaller::FailureReason> PluginVmInstaller::Start() {
|
||||
LOG_FUNCTION_CALL();
|
||||
@ -312,7 +312,7 @@ int64_t PluginVmInstaller::RequiredFreeDiskSpace() {
|
||||
}
|
||||
|
||||
void PluginVmInstaller::SetDownloadServiceForTesting(
|
||||
download::DownloadService* download_service) {
|
||||
download::BackgroundDownloadService* download_service) {
|
||||
download_service_ = download_service;
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "services/device/public/mojom/wake_lock.mojom.h"
|
||||
|
||||
namespace download {
|
||||
class DownloadService;
|
||||
class BackgroundDownloadService;
|
||||
struct CompletionInfo;
|
||||
} // namespace download
|
||||
|
||||
@ -159,7 +159,7 @@ class PluginVmInstaller : public KeyedService,
|
||||
free_disk_space_for_testing_ = bytes;
|
||||
}
|
||||
void SetDownloadServiceForTesting(
|
||||
download::DownloadService* download_service);
|
||||
download::BackgroundDownloadService* download_service);
|
||||
void SetDownloadedImageForTesting(const base::FilePath& downloaded_image);
|
||||
void SetDriveDownloadServiceForTesting(
|
||||
std::unique_ptr<PluginVmDriveImageDownloadService>
|
||||
@ -264,7 +264,7 @@ class PluginVmInstaller : public KeyedService,
|
||||
|
||||
Profile* profile_ = nullptr;
|
||||
Observer* observer_ = nullptr;
|
||||
download::DownloadService* download_service_ = nullptr;
|
||||
download::BackgroundDownloadService* download_service_ = nullptr;
|
||||
State state_ = State::kIdle;
|
||||
InstallingState installing_state_ = InstallingState::kInactive;
|
||||
base::TimeTicks setup_start_tick_;
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "chrome/browser/ash/plugin_vm/plugin_vm_installer_factory.h"
|
||||
|
||||
#include "chrome/browser/ash/plugin_vm/plugin_vm_installer.h"
|
||||
#include "chrome/browser/download/download_service_factory.h"
|
||||
#include "chrome/browser/download/background_download_service_factory.h"
|
||||
#include "chrome/browser/profiles/incognito_helpers.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "components/keyed_service/content/browser_context_dependency_manager.h"
|
||||
@ -27,7 +27,7 @@ PluginVmInstallerFactory::PluginVmInstallerFactory()
|
||||
: BrowserContextKeyedServiceFactory(
|
||||
"PluginVmInstaller",
|
||||
BrowserContextDependencyManager::GetInstance()) {
|
||||
DependsOn(DownloadServiceFactory::GetInstance());
|
||||
DependsOn(BackgroundDownloadServiceFactory::GetInstance());
|
||||
}
|
||||
|
||||
PluginVmInstallerFactory::~PluginVmInstallerFactory() = default;
|
||||
|
@ -13,8 +13,8 @@
|
||||
#include "chrome/browser/background_fetch/background_fetch_delegate_impl.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
|
||||
#include "chrome/browser/download/background_download_service_factory.h"
|
||||
#include "chrome/browser/download/download_request_limiter.h"
|
||||
#include "chrome/browser/download/download_service_factory.h"
|
||||
#include "chrome/browser/offline_items_collection/offline_content_aggregator_factory.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/browser/profiles/profile_key.h"
|
||||
@ -25,7 +25,7 @@
|
||||
#include "components/background_fetch/job_details.h"
|
||||
#include "components/content_settings/core/browser/host_content_settings_map.h"
|
||||
#include "components/content_settings/core/common/content_settings_types.h"
|
||||
#include "components/download/public/background_service/download_service.h"
|
||||
#include "components/download/public/background_service/background_download_service.h"
|
||||
#include "components/download/public/background_service/logger.h"
|
||||
#include "components/offline_items_collection/core/offline_content_aggregator.h"
|
||||
#include "components/offline_items_collection/core/offline_content_provider.h"
|
||||
@ -250,7 +250,7 @@ class BackgroundFetchBrowserTest : public InProcessBrowserTest {
|
||||
download_observer_ = std::make_unique<WaitableDownloadLoggerObserver>();
|
||||
|
||||
download_service_ =
|
||||
DownloadServiceFactory::GetForKey(profile->GetProfileKey());
|
||||
BackgroundDownloadServiceFactory::GetForKey(profile->GetProfileKey());
|
||||
download_service_->GetLogger()->AddObserver(download_observer_.get());
|
||||
|
||||
// Register our observer for the offline items collection.
|
||||
@ -449,7 +449,7 @@ class BackgroundFetchBrowserTest : public InProcessBrowserTest {
|
||||
|
||||
protected:
|
||||
BackgroundFetchDelegateImpl* delegate_ = nullptr;
|
||||
download::DownloadService* download_service_ = nullptr;
|
||||
download::BackgroundDownloadService* download_service_ = nullptr;
|
||||
base::OnceClosure click_event_closure_;
|
||||
|
||||
std::unique_ptr<WaitableDownloadLoggerObserver> download_observer_;
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "chrome/browser/background_fetch/background_fetch_delegate_impl.h"
|
||||
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
|
||||
#include "chrome/browser/download/download_service_factory.h"
|
||||
#include "chrome/browser/download/background_download_service_factory.h"
|
||||
#include "chrome/browser/metrics/ukm_background_recorder_service.h"
|
||||
#include "chrome/browser/offline_items_collection/offline_content_aggregator_factory.h"
|
||||
#include "chrome/browser/profiles/incognito_helpers.h"
|
||||
@ -31,7 +31,7 @@ BackgroundFetchDelegateFactory::BackgroundFetchDelegateFactory()
|
||||
: BrowserContextKeyedServiceFactory(
|
||||
"BackgroundFetchService",
|
||||
BrowserContextDependencyManager::GetInstance()) {
|
||||
DependsOn(DownloadServiceFactory::GetInstance());
|
||||
DependsOn(BackgroundDownloadServiceFactory::GetInstance());
|
||||
DependsOn(HostContentSettingsMapFactory::GetInstance());
|
||||
DependsOn(OfflineContentAggregatorFactory::GetInstance());
|
||||
DependsOn(ukm::UkmBackgroundRecorderFactory::GetInstance());
|
||||
|
@ -14,13 +14,13 @@
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "build/build_config.h"
|
||||
#include "chrome/browser/download/download_service_factory.h"
|
||||
#include "chrome/browser/download/background_download_service_factory.h"
|
||||
#include "chrome/browser/metrics/ukm_background_recorder_service.h"
|
||||
#include "chrome/browser/offline_items_collection/offline_content_aggregator_factory.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/browser/profiles/profile_key.h"
|
||||
#include "components/background_fetch/job_details.h"
|
||||
#include "components/download/public/background_service/download_service.h"
|
||||
#include "components/download/public/background_service/background_download_service.h"
|
||||
#include "components/download/public/common/download_features.h"
|
||||
#include "components/offline_items_collection/core/offline_content_aggregator.h"
|
||||
#include "components/offline_items_collection/core/offline_item.h"
|
||||
@ -214,8 +214,9 @@ void BackgroundFetchDelegateImpl::ChangeSchedule(
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
download::DownloadService* BackgroundFetchDelegateImpl::GetDownloadService() {
|
||||
return DownloadServiceFactory::GetInstance()->GetForKey(
|
||||
download::BackgroundDownloadService*
|
||||
BackgroundFetchDelegateImpl::GetDownloadService() {
|
||||
return BackgroundDownloadServiceFactory::GetInstance()->GetForKey(
|
||||
profile_->GetProfileKey());
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ class BackgroundFetchDelegateImpl
|
||||
|
||||
protected:
|
||||
// BackgroundFetchDelegateBase:
|
||||
download::DownloadService* GetDownloadService() override;
|
||||
download::BackgroundDownloadService* GetDownloadService() override;
|
||||
void OnJobDetailsCreated(const std::string& job_id) override;
|
||||
void DoShowUi(const std::string& job_id) override;
|
||||
void DoUpdateUi(const std::string& job_id) override;
|
||||
|
@ -6,10 +6,10 @@
|
||||
#include "base/bind.h"
|
||||
#include "chrome/android/chrome_jni_headers/DownloadBackgroundTask_jni.h"
|
||||
#include "chrome/browser/download/android/download_manager_service.h"
|
||||
#include "chrome/browser/download/download_service_factory.h"
|
||||
#include "chrome/browser/download/background_download_service_factory.h"
|
||||
#include "chrome/browser/profiles/profile_key.h"
|
||||
#include "chrome/browser/profiles/profile_key_android.h"
|
||||
#include "components/download/public/background_service/download_service.h"
|
||||
#include "components/download/public/background_service/background_download_service.h"
|
||||
#include "components/download/public/common/auto_resumption_handler.h"
|
||||
#include "content/public/browser/browser_context.h"
|
||||
|
||||
@ -18,10 +18,11 @@ using base::android::JavaParamRef;
|
||||
namespace download {
|
||||
namespace android {
|
||||
|
||||
DownloadService* GetDownloadService(const JavaParamRef<jobject>& jkey) {
|
||||
BackgroundDownloadService* GetDownloadService(
|
||||
const JavaParamRef<jobject>& jkey) {
|
||||
ProfileKey* key = ProfileKeyAndroid::FromProfileKeyAndroid(jkey);
|
||||
DCHECK(key);
|
||||
return DownloadServiceFactory::GetForKey(key);
|
||||
return BackgroundDownloadServiceFactory::GetForKey(key);
|
||||
}
|
||||
|
||||
AutoResumptionHandler* GetAutoResumptionHandler() {
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "chrome/browser/download/download_service_factory.h"
|
||||
#include "chrome/browser/download/background_download_service_factory.h"
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
@ -14,6 +14,7 @@
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/task/task_traits.h"
|
||||
#include "base/task/thread_pool.h"
|
||||
#include "build/build_config.h"
|
||||
#include "build/chromeos_buildflags.h"
|
||||
#include "chrome/browser/ash/plugin_vm/plugin_vm_image_download_client.h"
|
||||
#include "chrome/browser/download/deferred_client_wrapper.h"
|
||||
@ -29,10 +30,10 @@
|
||||
#include "components/background_fetch/download_client.h"
|
||||
#include "components/download/content/factory/download_service_factory_helper.h"
|
||||
#include "components/download/content/factory/navigation_monitor_factory.h"
|
||||
#include "components/download/public/background_service/background_download_service.h"
|
||||
#include "components/download/public/background_service/basic_task_scheduler.h"
|
||||
#include "components/download/public/background_service/blob_context_getter_factory.h"
|
||||
#include "components/download/public/background_service/clients.h"
|
||||
#include "components/download/public/background_service/download_service.h"
|
||||
#include "components/download/public/background_service/features.h"
|
||||
#include "components/download/public/common/simple_download_manager_coordinator.h"
|
||||
#include "components/keyed_service/core/simple_dependency_manager.h"
|
||||
@ -106,27 +107,29 @@ class DownloadBlobContextGetterFactory
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
DownloadServiceFactory* DownloadServiceFactory::GetInstance() {
|
||||
return base::Singleton<DownloadServiceFactory>::get();
|
||||
BackgroundDownloadServiceFactory*
|
||||
BackgroundDownloadServiceFactory::GetInstance() {
|
||||
return base::Singleton<BackgroundDownloadServiceFactory>::get();
|
||||
}
|
||||
|
||||
// static
|
||||
download::DownloadService* DownloadServiceFactory::GetForKey(
|
||||
SimpleFactoryKey* key) {
|
||||
return static_cast<download::DownloadService*>(
|
||||
download::BackgroundDownloadService*
|
||||
BackgroundDownloadServiceFactory::GetForKey(SimpleFactoryKey* key) {
|
||||
return static_cast<download::BackgroundDownloadService*>(
|
||||
GetInstance()->GetServiceForKey(key, true));
|
||||
}
|
||||
|
||||
DownloadServiceFactory::DownloadServiceFactory()
|
||||
: SimpleKeyedServiceFactory("download::DownloadService",
|
||||
BackgroundDownloadServiceFactory::BackgroundDownloadServiceFactory()
|
||||
: SimpleKeyedServiceFactory("download::BackgroundDownloadService",
|
||||
SimpleDependencyManager::GetInstance()) {
|
||||
DependsOn(SimpleDownloadManagerCoordinatorFactory::GetInstance());
|
||||
DependsOn(download::NavigationMonitorFactory::GetInstance());
|
||||
}
|
||||
|
||||
DownloadServiceFactory::~DownloadServiceFactory() = default;
|
||||
BackgroundDownloadServiceFactory::~BackgroundDownloadServiceFactory() = default;
|
||||
|
||||
std::unique_ptr<KeyedService> DownloadServiceFactory::BuildServiceInstanceFor(
|
||||
std::unique_ptr<KeyedService>
|
||||
BackgroundDownloadServiceFactory::BuildServiceInstanceFor(
|
||||
SimpleFactoryKey* key) const {
|
||||
auto clients = std::make_unique<download::DownloadClientMap>();
|
||||
ProfileKey* profile_key = ProfileKey::FromSimpleFactoryKey(key);
|
||||
@ -196,7 +199,7 @@ std::unique_ptr<KeyedService> DownloadServiceFactory::BuildServiceInstanceFor(
|
||||
task_scheduler =
|
||||
std::make_unique<download::BasicTaskScheduler>(base::BindRepeating(
|
||||
[](SimpleFactoryKey* key) {
|
||||
return DownloadServiceFactory::GetForKey(key);
|
||||
return BackgroundDownloadServiceFactory::GetForKey(key);
|
||||
},
|
||||
key));
|
||||
#endif
|
||||
@ -214,7 +217,7 @@ std::unique_ptr<KeyedService> DownloadServiceFactory::BuildServiceInstanceFor(
|
||||
}
|
||||
}
|
||||
|
||||
SimpleFactoryKey* DownloadServiceFactory::GetKeyToUse(
|
||||
SimpleFactoryKey* BackgroundDownloadServiceFactory::GetKeyToUse(
|
||||
SimpleFactoryKey* key) const {
|
||||
return key;
|
||||
}
|
@ -2,8 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_FACTORY_H_
|
||||
#define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_FACTORY_H_
|
||||
#ifndef CHROME_BROWSER_DOWNLOAD_BACKGROUND_DOWNLOAD_SERVICE_FACTORY_H_
|
||||
#define CHROME_BROWSER_DOWNLOAD_BACKGROUND_DOWNLOAD_SERVICE_FACTORY_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
@ -18,31 +18,31 @@ struct DefaultSingletonTraits;
|
||||
} // namespace base
|
||||
|
||||
namespace download {
|
||||
class DownloadService;
|
||||
class BackgroundDownloadService;
|
||||
} // namespace download
|
||||
|
||||
// DownloadServiceFactory is the main client class for interaction with the
|
||||
// download component.
|
||||
class DownloadServiceFactory : public SimpleKeyedServiceFactory {
|
||||
// BackgroundDownloadServiceFactory is the main client class for interaction
|
||||
// with the download component.
|
||||
class BackgroundDownloadServiceFactory : public SimpleKeyedServiceFactory {
|
||||
public:
|
||||
// Returns singleton instance of DownloadServiceFactory.
|
||||
static DownloadServiceFactory* GetInstance();
|
||||
static BackgroundDownloadServiceFactory* GetInstance();
|
||||
|
||||
// Returns the DownloadService associated with |key|.
|
||||
static download::DownloadService* GetForKey(SimpleFactoryKey* key);
|
||||
static download::BackgroundDownloadService* GetForKey(SimpleFactoryKey* key);
|
||||
|
||||
private:
|
||||
friend struct base::DefaultSingletonTraits<DownloadServiceFactory>;
|
||||
friend struct base::DefaultSingletonTraits<BackgroundDownloadServiceFactory>;
|
||||
|
||||
DownloadServiceFactory();
|
||||
~DownloadServiceFactory() override;
|
||||
BackgroundDownloadServiceFactory();
|
||||
~BackgroundDownloadServiceFactory() override;
|
||||
|
||||
// SimpleKeyedServiceFactory overrides:
|
||||
std::unique_ptr<KeyedService> BuildServiceInstanceFor(
|
||||
SimpleFactoryKey* key) const override;
|
||||
SimpleFactoryKey* GetKeyToUse(SimpleFactoryKey* key) const override;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(DownloadServiceFactory);
|
||||
DISALLOW_COPY_AND_ASSIGN(BackgroundDownloadServiceFactory);
|
||||
};
|
||||
|
||||
#endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_FACTORY_H_
|
||||
#endif // CHROME_BROWSER_DOWNLOAD_BACKGROUND_DOWNLOAD_SERVICE_FACTORY_H_
|
@ -11,7 +11,7 @@
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/threading/sequenced_task_runner_handle.h"
|
||||
#include "chrome/browser/download/download_service_factory.h"
|
||||
#include "chrome/browser/download/background_download_service_factory.h"
|
||||
#include "chrome/browser/offline_pages/prefetch/prefetch_service_factory.h"
|
||||
#include "components/download/public/background_service/download_metadata.h"
|
||||
#include "components/offline_pages/core/prefetch/prefetch_downloader.h"
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include "base/task/task_traits.h"
|
||||
#include "base/task/thread_pool.h"
|
||||
#include "base/threading/sequenced_task_runner_handle.h"
|
||||
#include "chrome/browser/download/download_service_factory.h"
|
||||
#include "chrome/browser/download/background_download_service_factory.h"
|
||||
#include "chrome/browser/image_fetcher/image_fetcher_service_factory.h"
|
||||
#include "chrome/browser/net/system_network_context_manager.h"
|
||||
#include "chrome/browser/offline_pages/offline_page_model_factory.h"
|
||||
@ -91,7 +91,7 @@ void OnProfileCreated(PrefetchServiceImpl* prefetch_service, Profile* profile) {
|
||||
PrefetchServiceFactory::PrefetchServiceFactory()
|
||||
: SimpleKeyedServiceFactory("OfflinePagePrefetchService",
|
||||
SimpleDependencyManager::GetInstance()) {
|
||||
DependsOn(DownloadServiceFactory::GetInstance());
|
||||
DependsOn(BackgroundDownloadServiceFactory::GetInstance());
|
||||
DependsOn(OfflinePageModelFactory::GetInstance());
|
||||
DependsOn(ImageFetcherServiceFactory::GetInstance());
|
||||
}
|
||||
@ -149,8 +149,8 @@ std::unique_ptr<KeyedService> PrefetchServiceFactory::BuildServiceInstanceFor(
|
||||
profile_key, image_fetcher::ImageFetcherConfig::kReducedMode);
|
||||
|
||||
auto prefetch_downloader = std::make_unique<PrefetchDownloaderImpl>(
|
||||
DownloadServiceFactory::GetForKey(profile_key), chrome::GetChannel(),
|
||||
profile_key->GetPrefs());
|
||||
BackgroundDownloadServiceFactory::GetForKey(profile_key),
|
||||
chrome::GetChannel(), profile_key->GetPrefs());
|
||||
|
||||
auto prefetch_importer = std::make_unique<PrefetchImporterImpl>(
|
||||
prefetch_dispatcher.get(), offline_page_model, background_task_runner);
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "base/task/thread_pool.h"
|
||||
#include "base/time/default_clock.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "chrome/browser/download/download_service_factory.h"
|
||||
#include "chrome/browser/download/background_download_service_factory.h"
|
||||
#include "chrome/browser/optimization_guide/prediction/prediction_model_download_manager.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/browser/profiles/profile_key.h"
|
||||
@ -739,7 +739,8 @@ void PredictionManager::OnStoreInitialized() {
|
||||
!prediction_model_download_manager_) {
|
||||
prediction_model_download_manager_ =
|
||||
std::make_unique<PredictionModelDownloadManager>(
|
||||
DownloadServiceFactory::GetForKey(profile_->GetProfileKey()),
|
||||
BackgroundDownloadServiceFactory::GetForKey(
|
||||
profile_->GetProfileKey()),
|
||||
base::ThreadPool::CreateSequencedTaskRunner(
|
||||
{base::MayBlock(), base::TaskPriority::BEST_EFFORT}));
|
||||
prediction_model_download_manager_->AddObserver(this);
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include "chrome/browser/optimization_guide/prediction/prediction_model_download_observer.h"
|
||||
#include "chrome/common/chrome_paths.h"
|
||||
#include "components/crx_file/crx_verifier.h"
|
||||
#include "components/download/public/background_service/download_service.h"
|
||||
#include "components/download/public/background_service/background_download_service.h"
|
||||
#include "components/optimization_guide/core/optimization_guide_enums.h"
|
||||
#include "components/optimization_guide/core/optimization_guide_features.h"
|
||||
#include "components/optimization_guide/core/optimization_guide_switches.h"
|
||||
@ -97,7 +97,7 @@ void RecordPredictionModelDownloadStatus(PredictionModelDownloadStatus status) {
|
||||
} // namespace
|
||||
|
||||
PredictionModelDownloadManager::PredictionModelDownloadManager(
|
||||
download::DownloadService* download_service,
|
||||
download::BackgroundDownloadService* download_service,
|
||||
scoped_refptr<base::SequencedTaskRunner> background_task_runner)
|
||||
: download_service_(download_service),
|
||||
is_available_for_downloads_(true),
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "third_party/abseil-cpp/absl/types/optional.h"
|
||||
|
||||
namespace download {
|
||||
class DownloadService;
|
||||
class BackgroundDownloadService;
|
||||
} // namespace download
|
||||
|
||||
namespace optimization_guide {
|
||||
@ -32,7 +32,7 @@ class PredictionModel;
|
||||
class PredictionModelDownloadManager {
|
||||
public:
|
||||
PredictionModelDownloadManager(
|
||||
download::DownloadService* download_service,
|
||||
download::BackgroundDownloadService* download_service,
|
||||
scoped_refptr<base::SequencedTaskRunner> background_task_runner);
|
||||
virtual ~PredictionModelDownloadManager();
|
||||
PredictionModelDownloadManager(const PredictionModelDownloadManager&) =
|
||||
@ -74,7 +74,7 @@ class PredictionModelDownloadManager {
|
||||
void OnDownloadServiceUnavailable();
|
||||
|
||||
// Invoked when the download has been accepted and persisted by the
|
||||
// DownloadService.
|
||||
// BackgroundDownloadService.
|
||||
void OnDownloadStarted(const std::string& guid,
|
||||
download::DownloadParams::StartResult start_result);
|
||||
|
||||
@ -122,7 +122,7 @@ class PredictionModelDownloadManager {
|
||||
// The Download Service to schedule model downloads with.
|
||||
//
|
||||
// Guaranteed to outlive |this|.
|
||||
download::DownloadService* download_service_;
|
||||
download::BackgroundDownloadService* download_service_;
|
||||
|
||||
// The directory to store verified models in.
|
||||
absl::optional<base::FilePath> models_dir_;
|
||||
|
@ -28,8 +28,8 @@
|
||||
#include "chrome/browser/device_api/managed_configuration_api_factory.h"
|
||||
#include "chrome/browser/dom_distiller/dom_distiller_service_factory.h"
|
||||
#include "chrome/browser/domain_reliability/service_factory.h"
|
||||
#include "chrome/browser/download/background_download_service_factory.h"
|
||||
#include "chrome/browser/download/download_core_service_factory.h"
|
||||
#include "chrome/browser/download/download_service_factory.h"
|
||||
#include "chrome/browser/engagement/site_engagement_service_factory.h"
|
||||
#include "chrome/browser/favicon/favicon_service_factory.h"
|
||||
#include "chrome/browser/favicon/history_ui_favicon_request_handler_factory.h"
|
||||
@ -304,7 +304,7 @@ void ChromeBrowserMainExtraPartsProfiles::
|
||||
DomainDiversityReporterFactory::GetInstance();
|
||||
dom_distiller::DomDistillerServiceFactory::GetInstance();
|
||||
DownloadCoreServiceFactory::GetInstance();
|
||||
DownloadServiceFactory::GetInstance();
|
||||
BackgroundDownloadServiceFactory::GetInstance();
|
||||
#if defined(OS_ANDROID)
|
||||
explore_sites::ExploreSitesServiceFactory::GetInstance();
|
||||
#endif
|
||||
|
@ -7,11 +7,11 @@
|
||||
#include "base/bind.h"
|
||||
#include "base/guid.h"
|
||||
#include "base/values.h"
|
||||
#include "chrome/browser/download/download_service_factory.h"
|
||||
#include "chrome/browser/download/background_download_service_factory.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/browser/profiles/profile_key.h"
|
||||
#include "components/download/public/background_service/background_download_service.h"
|
||||
#include "components/download/public/background_service/download_params.h"
|
||||
#include "components/download/public/background_service/download_service.h"
|
||||
#include "content/public/browser/web_ui.h"
|
||||
#include "net/traffic_annotation/network_traffic_annotation.h"
|
||||
|
||||
@ -44,7 +44,7 @@ void DownloadInternalsUIMessageHandler::RegisterMessages() {
|
||||
|
||||
Profile* profile = Profile::FromWebUI(web_ui());
|
||||
download_service_ =
|
||||
DownloadServiceFactory::GetForKey(profile->GetProfileKey());
|
||||
BackgroundDownloadServiceFactory::GetForKey(profile->GetProfileKey());
|
||||
download_service_->GetLogger()->AddObserver(this);
|
||||
}
|
||||
|
||||
|
@ -11,8 +11,8 @@
|
||||
#include "content/public/browser/web_ui_message_handler.h"
|
||||
|
||||
namespace download {
|
||||
class DownloadService;
|
||||
}
|
||||
class BackgroundDownloadService;
|
||||
} // namespace download
|
||||
|
||||
namespace download_internals {
|
||||
|
||||
@ -42,7 +42,7 @@ class DownloadInternalsUIMessageHandler : public content::WebUIMessageHandler,
|
||||
// Starts a background download.
|
||||
void HandleStartDownload(const base::ListValue* args);
|
||||
|
||||
download::DownloadService* download_service_;
|
||||
download::BackgroundDownloadService* download_service_;
|
||||
|
||||
base::WeakPtrFactory<DownloadInternalsUIMessageHandler> weak_ptr_factory_{
|
||||
this};
|
||||
|
@ -14,9 +14,9 @@
|
||||
#include "build/build_config.h"
|
||||
#include "components/background_fetch/job_details.h"
|
||||
#include "components/content_settings/core/common/content_settings_types.h"
|
||||
#include "components/download/public/background_service/background_download_service.h"
|
||||
#include "components/download/public/background_service/blob_context_getter_factory.h"
|
||||
#include "components/download/public/background_service/download_params.h"
|
||||
#include "components/download/public/background_service/download_service.h"
|
||||
#include "content/public/browser/background_fetch_description.h"
|
||||
#include "content/public/browser/background_fetch_response.h"
|
||||
#include "content/public/browser/browser_context.h"
|
||||
|
@ -22,16 +22,16 @@ class BrowserContext;
|
||||
}
|
||||
|
||||
namespace download {
|
||||
class DownloadService;
|
||||
class BackgroundDownloadService;
|
||||
} // namespace download
|
||||
|
||||
namespace background_fetch {
|
||||
|
||||
struct JobDetails;
|
||||
|
||||
// Implementation of BackgroundFetchDelegate using the DownloadService. This
|
||||
// base class is shared by multiple embedders, with specializations providing
|
||||
// their own UI.
|
||||
// Implementation of BackgroundFetchDelegate using the
|
||||
// BackgroundDownloadService. This base class is shared by multiple embedders,
|
||||
// with specializations providing their own UI.
|
||||
class BackgroundFetchDelegateBase : public content::BackgroundFetchDelegate {
|
||||
public:
|
||||
explicit BackgroundFetchDelegateBase(content::BrowserContext* context);
|
||||
@ -106,7 +106,7 @@ class BackgroundFetchDelegateBase : public content::BackgroundFetchDelegate {
|
||||
|
||||
protected:
|
||||
// Return the download service for `context_`.
|
||||
virtual download::DownloadService* GetDownloadService() = 0;
|
||||
virtual download::BackgroundDownloadService* GetDownloadService() = 0;
|
||||
|
||||
// Called when a new JobDetails object has been created and inserted in
|
||||
// |job_details_map_|.
|
||||
|
@ -13,8 +13,8 @@
|
||||
#include "base/bind.h"
|
||||
#include "base/threading/sequenced_task_runner_handle.h"
|
||||
#include "components/background_fetch/background_fetch_delegate_base.h"
|
||||
#include "components/download/public/background_service/background_download_service.h"
|
||||
#include "components/download/public/background_service/download_metadata.h"
|
||||
#include "components/download/public/background_service/download_service.h"
|
||||
#include "content/public/browser/background_fetch_response.h"
|
||||
#include "content/public/browser/browser_context.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
|
@ -10,10 +10,10 @@
|
||||
#include "build/build_config.h"
|
||||
#include "components/download/content/factory/navigation_monitor_factory.h"
|
||||
#include "components/download/content/internal/download_driver_impl.h"
|
||||
#include "components/download/internal/background_service/background_download_service_impl.h"
|
||||
#include "components/download/internal/background_service/client_set.h"
|
||||
#include "components/download/internal/background_service/config.h"
|
||||
#include "components/download/internal/background_service/controller_impl.h"
|
||||
#include "components/download/internal/background_service/download_service_impl.h"
|
||||
#include "components/download/internal/background_service/download_store.h"
|
||||
#include "components/download/internal/background_service/empty_file_monitor.h"
|
||||
#include "components/download/internal/background_service/file_monitor_impl.h"
|
||||
@ -48,7 +48,7 @@ const base::FilePath::CharType kFilesStorageDir[] = FILE_PATH_LITERAL("Files");
|
||||
|
||||
// Helper function to create download service with different implementation
|
||||
// details.
|
||||
std::unique_ptr<DownloadService> CreateDownloadServiceInternal(
|
||||
std::unique_ptr<BackgroundDownloadService> CreateDownloadServiceInternal(
|
||||
SimpleFactoryKey* simple_factory_key,
|
||||
std::unique_ptr<DownloadClientMap> clients,
|
||||
std::unique_ptr<Configuration> config,
|
||||
@ -91,12 +91,12 @@ std::unique_ptr<DownloadService> CreateDownloadServiceInternal(
|
||||
files_storage_dir);
|
||||
logger->SetLogSource(controller.get());
|
||||
|
||||
return std::make_unique<DownloadServiceImpl>(
|
||||
return std::make_unique<BackgroundDownloadServiceImpl>(
|
||||
std::move(config), std::move(logger), std::move(controller));
|
||||
}
|
||||
|
||||
// Create download service for normal profile.
|
||||
std::unique_ptr<DownloadService> BuildDownloadService(
|
||||
std::unique_ptr<BackgroundDownloadService> BuildDownloadService(
|
||||
SimpleFactoryKey* simple_factory_key,
|
||||
std::unique_ptr<DownloadClientMap> clients,
|
||||
network::NetworkConnectionTracker* network_connection_tracker,
|
||||
@ -128,7 +128,7 @@ std::unique_ptr<DownloadService> BuildDownloadService(
|
||||
}
|
||||
|
||||
// Create download service for incognito mode without any database or file IO.
|
||||
std::unique_ptr<DownloadService> BuildInMemoryDownloadService(
|
||||
std::unique_ptr<BackgroundDownloadService> BuildInMemoryDownloadService(
|
||||
SimpleFactoryKey* simple_factory_key,
|
||||
std::unique_ptr<DownloadClientMap> clients,
|
||||
network::NetworkConnectionTracker* network_connection_tracker,
|
||||
|
@ -27,7 +27,7 @@ class ProtoDatabaseProvider;
|
||||
|
||||
namespace download {
|
||||
|
||||
class DownloadService;
|
||||
class BackgroundDownloadService;
|
||||
class SimpleDownloadManagerCoordinator;
|
||||
class TaskScheduler;
|
||||
|
||||
@ -41,7 +41,7 @@ class TaskScheduler;
|
||||
// will act as an in-memory only service (this means no auto-retries after
|
||||
// restarts, no files written on completion, etc.).
|
||||
// |background_task_runner| will be used for all disk reads and writes.
|
||||
std::unique_ptr<DownloadService> BuildDownloadService(
|
||||
std::unique_ptr<BackgroundDownloadService> BuildDownloadService(
|
||||
SimpleFactoryKey* simple_factory_key,
|
||||
std::unique_ptr<DownloadClientMap> clients,
|
||||
network::NetworkConnectionTracker* network_connection_tracker,
|
||||
@ -53,7 +53,7 @@ std::unique_ptr<DownloadService> BuildDownloadService(
|
||||
|
||||
// Create download service used in incognito mode, without any database or
|
||||
// download file IO.
|
||||
std::unique_ptr<DownloadService> BuildInMemoryDownloadService(
|
||||
std::unique_ptr<BackgroundDownloadService> BuildInMemoryDownloadService(
|
||||
SimpleFactoryKey* simple_factory_key,
|
||||
std::unique_ptr<DownloadClientMap> clients,
|
||||
network::NetworkConnectionTracker* network_connection_tracker,
|
||||
|
@ -17,6 +17,8 @@ if (!is_ios) {
|
||||
]
|
||||
|
||||
sources = [
|
||||
"background_download_service_impl.cc",
|
||||
"background_download_service_impl.h",
|
||||
"blob_task_proxy.cc",
|
||||
"blob_task_proxy.h",
|
||||
"client_set.cc",
|
||||
@ -29,8 +31,6 @@ if (!is_ios) {
|
||||
"download_blockage_status.cc",
|
||||
"download_blockage_status.h",
|
||||
"download_driver.h",
|
||||
"download_service_impl.cc",
|
||||
"download_service_impl.h",
|
||||
"download_store.cc",
|
||||
"download_store.h",
|
||||
"driver_entry.cc",
|
||||
@ -151,9 +151,9 @@ source_set("unit_tests") {
|
||||
|
||||
if (!is_ios) {
|
||||
sources += [
|
||||
"background_download_service_impl_unittest.cc",
|
||||
"client_set_unittest.cc",
|
||||
"controller_impl_unittest.cc",
|
||||
"download_service_impl_unittest.cc",
|
||||
"download_store_unittest.cc",
|
||||
"entry_utils_unittest.cc",
|
||||
"file_monitor_unittest.cc",
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "components/download/internal/background_service/download_service_impl.h"
|
||||
#include "components/download/internal/background_service/background_download_service_impl.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
@ -15,27 +15,29 @@
|
||||
|
||||
namespace download {
|
||||
|
||||
DownloadServiceImpl::DownloadServiceImpl(std::unique_ptr<Configuration> config,
|
||||
std::unique_ptr<Logger> logger,
|
||||
std::unique_ptr<Controller> controller)
|
||||
BackgroundDownloadServiceImpl::BackgroundDownloadServiceImpl(
|
||||
std::unique_ptr<Configuration> config,
|
||||
std::unique_ptr<Logger> logger,
|
||||
std::unique_ptr<Controller> controller)
|
||||
: config_(std::move(config)),
|
||||
logger_(std::move(logger)),
|
||||
controller_(std::move(controller)),
|
||||
service_config_(config_.get()),
|
||||
startup_completed_(false) {
|
||||
controller_->Initialize(
|
||||
base::BindOnce(&DownloadServiceImpl::OnControllerInitialized,
|
||||
base::BindOnce(&BackgroundDownloadServiceImpl::OnControllerInitialized,
|
||||
weak_ptr_factory_.GetWeakPtr()));
|
||||
}
|
||||
|
||||
DownloadServiceImpl::~DownloadServiceImpl() = default;
|
||||
BackgroundDownloadServiceImpl::~BackgroundDownloadServiceImpl() = default;
|
||||
|
||||
const ServiceConfig& DownloadServiceImpl::GetConfig() {
|
||||
const ServiceConfig& BackgroundDownloadServiceImpl::GetConfig() {
|
||||
return service_config_;
|
||||
}
|
||||
|
||||
void DownloadServiceImpl::OnStartScheduledTask(DownloadTaskType task_type,
|
||||
TaskFinishedCallback callback) {
|
||||
void BackgroundDownloadServiceImpl::OnStartScheduledTask(
|
||||
DownloadTaskType task_type,
|
||||
TaskFinishedCallback callback) {
|
||||
if (startup_completed_) {
|
||||
controller_->OnStartScheduledTask(task_type, std::move(callback));
|
||||
return;
|
||||
@ -46,7 +48,8 @@ void DownloadServiceImpl::OnStartScheduledTask(DownloadTaskType task_type,
|
||||
task_type, std::move(callback));
|
||||
}
|
||||
|
||||
bool DownloadServiceImpl::OnStopScheduledTask(DownloadTaskType task_type) {
|
||||
bool BackgroundDownloadServiceImpl::OnStopScheduledTask(
|
||||
DownloadTaskType task_type) {
|
||||
if (startup_completed_) {
|
||||
return controller_->OnStopScheduledTask(task_type);
|
||||
}
|
||||
@ -62,21 +65,23 @@ bool DownloadServiceImpl::OnStopScheduledTask(DownloadTaskType task_type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
DownloadService::ServiceStatus DownloadServiceImpl::GetStatus() {
|
||||
BackgroundDownloadService::ServiceStatus
|
||||
BackgroundDownloadServiceImpl::GetStatus() {
|
||||
switch (controller_->GetState()) {
|
||||
case Controller::State::CREATED: // Intentional fallthrough.
|
||||
case Controller::State::INITIALIZING: // Intentional fallthrough.
|
||||
case Controller::State::RECOVERING:
|
||||
return DownloadService::ServiceStatus::STARTING_UP;
|
||||
return BackgroundDownloadService::ServiceStatus::STARTING_UP;
|
||||
case Controller::State::READY:
|
||||
return DownloadService::ServiceStatus::READY;
|
||||
return BackgroundDownloadService::ServiceStatus::READY;
|
||||
case Controller::State::UNAVAILABLE: // Intentional fallthrough.
|
||||
default:
|
||||
return DownloadService::ServiceStatus::UNAVAILABLE;
|
||||
return BackgroundDownloadService::ServiceStatus::UNAVAILABLE;
|
||||
}
|
||||
}
|
||||
|
||||
void DownloadServiceImpl::StartDownload(DownloadParams download_params) {
|
||||
void BackgroundDownloadServiceImpl::StartDownload(
|
||||
DownloadParams download_params) {
|
||||
stats::LogServiceApiAction(download_params.client,
|
||||
stats::ServiceApiAction::START_DOWNLOAD);
|
||||
if (startup_completed_) {
|
||||
@ -88,7 +93,7 @@ void DownloadServiceImpl::StartDownload(DownloadParams download_params) {
|
||||
}
|
||||
}
|
||||
|
||||
void DownloadServiceImpl::PauseDownload(const std::string& guid) {
|
||||
void BackgroundDownloadServiceImpl::PauseDownload(const std::string& guid) {
|
||||
if (startup_completed_) {
|
||||
controller_->PauseDownload(guid);
|
||||
} else {
|
||||
@ -97,7 +102,7 @@ void DownloadServiceImpl::PauseDownload(const std::string& guid) {
|
||||
}
|
||||
}
|
||||
|
||||
void DownloadServiceImpl::ResumeDownload(const std::string& guid) {
|
||||
void BackgroundDownloadServiceImpl::ResumeDownload(const std::string& guid) {
|
||||
if (startup_completed_) {
|
||||
controller_->ResumeDownload(guid);
|
||||
} else {
|
||||
@ -107,7 +112,7 @@ void DownloadServiceImpl::ResumeDownload(const std::string& guid) {
|
||||
}
|
||||
}
|
||||
|
||||
void DownloadServiceImpl::CancelDownload(const std::string& guid) {
|
||||
void BackgroundDownloadServiceImpl::CancelDownload(const std::string& guid) {
|
||||
if (startup_completed_) {
|
||||
controller_->CancelDownload(guid);
|
||||
} else {
|
||||
@ -117,7 +122,7 @@ void DownloadServiceImpl::CancelDownload(const std::string& guid) {
|
||||
}
|
||||
}
|
||||
|
||||
void DownloadServiceImpl::ChangeDownloadCriteria(
|
||||
void BackgroundDownloadServiceImpl::ChangeDownloadCriteria(
|
||||
const std::string& guid,
|
||||
const SchedulingParams& params) {
|
||||
if (startup_completed_) {
|
||||
@ -129,11 +134,11 @@ void DownloadServiceImpl::ChangeDownloadCriteria(
|
||||
}
|
||||
}
|
||||
|
||||
Logger* DownloadServiceImpl::GetLogger() {
|
||||
Logger* BackgroundDownloadServiceImpl::GetLogger() {
|
||||
return logger_.get();
|
||||
}
|
||||
|
||||
void DownloadServiceImpl::OnControllerInitialized() {
|
||||
void BackgroundDownloadServiceImpl::OnControllerInitialized() {
|
||||
while (!pending_actions_.empty()) {
|
||||
auto callback = std::move(pending_actions_.front());
|
||||
pending_actions_.pop_front();
|
@ -2,8 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef COMPONENTS_DOWNLOAD_INTERNAL_BACKGROUND_SERVICE_DOWNLOAD_SERVICE_IMPL_H_
|
||||
#define COMPONENTS_DOWNLOAD_INTERNAL_BACKGROUND_SERVICE_DOWNLOAD_SERVICE_IMPL_H_
|
||||
#ifndef COMPONENTS_DOWNLOAD_INTERNAL_BACKGROUND_SERVICE_BACKGROUND_DOWNLOAD_SERVICE_IMPL_H_
|
||||
#define COMPONENTS_DOWNLOAD_INTERNAL_BACKGROUND_SERVICE_BACKGROUND_DOWNLOAD_SERVICE_IMPL_H_
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
@ -14,7 +14,7 @@
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "components/download/internal/background_service/config.h"
|
||||
#include "components/download/internal/background_service/service_config_impl.h"
|
||||
#include "components/download/public/background_service/download_service.h"
|
||||
#include "components/download/public/background_service/background_download_service.h"
|
||||
|
||||
namespace download {
|
||||
|
||||
@ -24,15 +24,15 @@ class Logger;
|
||||
struct DownloadParams;
|
||||
struct SchedulingParams;
|
||||
|
||||
// The internal implementation of the DownloadService.
|
||||
class DownloadServiceImpl : public DownloadService {
|
||||
// The internal implementation of the BackgroundDownloadService.
|
||||
class BackgroundDownloadServiceImpl : public BackgroundDownloadService {
|
||||
public:
|
||||
DownloadServiceImpl(std::unique_ptr<Configuration> config,
|
||||
std::unique_ptr<Logger> logger,
|
||||
std::unique_ptr<Controller> controller);
|
||||
~DownloadServiceImpl() override;
|
||||
BackgroundDownloadServiceImpl(std::unique_ptr<Configuration> config,
|
||||
std::unique_ptr<Logger> logger,
|
||||
std::unique_ptr<Controller> controller);
|
||||
~BackgroundDownloadServiceImpl() override;
|
||||
|
||||
// DownloadService implementation.
|
||||
// BackgroundDownloadService implementation.
|
||||
const ServiceConfig& GetConfig() override;
|
||||
void OnStartScheduledTask(DownloadTaskType task_type,
|
||||
TaskFinishedCallback callback) override;
|
||||
@ -61,11 +61,11 @@ class DownloadServiceImpl : public DownloadService {
|
||||
std::map<DownloadTaskType, base::OnceClosure> pending_tasks_;
|
||||
bool startup_completed_;
|
||||
|
||||
base::WeakPtrFactory<DownloadServiceImpl> weak_ptr_factory_{this};
|
||||
base::WeakPtrFactory<BackgroundDownloadServiceImpl> weak_ptr_factory_{this};
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(DownloadServiceImpl);
|
||||
DISALLOW_COPY_AND_ASSIGN(BackgroundDownloadServiceImpl);
|
||||
};
|
||||
|
||||
} // namespace download
|
||||
|
||||
#endif // COMPONENTS_DOWNLOAD_INTERNAL_BACKGROUND_SERVICE_DOWNLOAD_SERVICE_IMPL_H_
|
||||
#endif // COMPONENTS_DOWNLOAD_INTERNAL_BACKGROUND_SERVICE_BACKGROUND_DOWNLOAD_SERVICE_IMPL_H_
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "components/download/internal/background_service/download_service_impl.h"
|
||||
#include "components/download/internal/background_service/background_download_service_impl.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
@ -25,47 +25,50 @@ using testing::Return;
|
||||
namespace download {
|
||||
namespace {
|
||||
|
||||
class DownloadServiceImplTest : public testing::Test {
|
||||
class BackgroundDownloadServiceImplTest : public testing::Test {
|
||||
public:
|
||||
DownloadServiceImplTest()
|
||||
BackgroundDownloadServiceImplTest()
|
||||
: controller_(nullptr),
|
||||
task_runner_(new base::TestSimpleTaskRunner),
|
||||
handle_(task_runner_) {}
|
||||
~DownloadServiceImplTest() override = default;
|
||||
~BackgroundDownloadServiceImplTest() override = default;
|
||||
|
||||
void SetUp() override {
|
||||
auto config = std::make_unique<Configuration>();
|
||||
auto logger = std::make_unique<test::EmptyLogger>();
|
||||
auto controller = std::make_unique<test::MockController>();
|
||||
controller_ = controller.get();
|
||||
service_ = std::make_unique<DownloadServiceImpl>(
|
||||
service_ = std::make_unique<BackgroundDownloadServiceImpl>(
|
||||
std::move(config), std::move(logger), std::move(controller));
|
||||
}
|
||||
|
||||
protected:
|
||||
test::MockController* controller_;
|
||||
std::unique_ptr<DownloadServiceImpl> service_;
|
||||
std::unique_ptr<BackgroundDownloadServiceImpl> service_;
|
||||
scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
|
||||
base::ThreadTaskRunnerHandle handle_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(DownloadServiceImplTest);
|
||||
DISALLOW_COPY_AND_ASSIGN(BackgroundDownloadServiceImplTest);
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST_F(DownloadServiceImplTest, TestGetStatus) {
|
||||
TEST_F(BackgroundDownloadServiceImplTest, TestGetStatus) {
|
||||
StartupStatus startup_status;
|
||||
EXPECT_CALL(*controller_, GetState())
|
||||
.WillOnce(Return(Controller::State::INITIALIZING))
|
||||
.WillOnce(Return(Controller::State::READY))
|
||||
.WillOnce(Return(Controller::State::UNAVAILABLE));
|
||||
|
||||
EXPECT_EQ(DownloadService::ServiceStatus::STARTING_UP, service_->GetStatus());
|
||||
EXPECT_EQ(DownloadService::ServiceStatus::READY, service_->GetStatus());
|
||||
EXPECT_EQ(DownloadService::ServiceStatus::UNAVAILABLE, service_->GetStatus());
|
||||
EXPECT_EQ(BackgroundDownloadService::ServiceStatus::STARTING_UP,
|
||||
service_->GetStatus());
|
||||
EXPECT_EQ(BackgroundDownloadService::ServiceStatus::READY,
|
||||
service_->GetStatus());
|
||||
EXPECT_EQ(BackgroundDownloadService::ServiceStatus::UNAVAILABLE,
|
||||
service_->GetStatus());
|
||||
}
|
||||
|
||||
TEST_F(DownloadServiceImplTest, TestApiPassThrough) {
|
||||
TEST_F(BackgroundDownloadServiceImplTest, TestApiPassThrough) {
|
||||
DownloadParams params = test::BuildBasicDownloadParams();
|
||||
auto guid = params.guid;
|
||||
SchedulingParams scheduling_params;
|
@ -8,8 +8,8 @@
|
||||
#include <string>
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "components/download/public/background_service/background_download_service.h"
|
||||
#include "components/download/public/background_service/clients.h"
|
||||
#include "components/download/public/background_service/download_service.h"
|
||||
#include "components/download/public/task/download_task_types.h"
|
||||
|
||||
namespace download {
|
||||
@ -42,8 +42,8 @@ enum class CompletionType {
|
||||
COUNT = 9,
|
||||
};
|
||||
|
||||
// The core Controller responsible for gluing various DownloadService components
|
||||
// together to manage the active downloads.
|
||||
// The core Controller responsible for gluing various BackgroundDownloadService
|
||||
// components together to manage the active downloads.
|
||||
class Controller {
|
||||
public:
|
||||
enum class State {
|
||||
@ -100,11 +100,11 @@ class Controller {
|
||||
// Otherwise returns DownloadClient::INVALID for an unowned entry.
|
||||
virtual DownloadClient GetOwnerOfDownload(const std::string& guid) = 0;
|
||||
|
||||
// See DownloadService::OnStartScheduledTask.
|
||||
// See BackgroundDownloadService::OnStartScheduledTask.
|
||||
virtual void OnStartScheduledTask(DownloadTaskType task_type,
|
||||
TaskFinishedCallback callback) = 0;
|
||||
|
||||
// See DownloadService::OnStopScheduledTask.
|
||||
// See BackgroundDownloadService::OnStopScheduledTask.
|
||||
virtual bool OnStopScheduledTask(DownloadTaskType task_type) = 0;
|
||||
|
||||
private:
|
||||
|
@ -45,7 +45,7 @@ struct DownloadMetaData;
|
||||
struct SchedulingParams;
|
||||
|
||||
// The internal Controller implementation. This class does all of the heavy
|
||||
// lifting for the DownloadService.
|
||||
// lifting for the BackgroundDownloadService.
|
||||
class ControllerImpl : public Controller,
|
||||
public DownloadDriver::Client,
|
||||
public Model::Client,
|
||||
|
@ -5,8 +5,8 @@
|
||||
source_set("background_service") {
|
||||
assert(is_ios)
|
||||
sources = [
|
||||
"download_service_impl.cc",
|
||||
"download_service_impl.h",
|
||||
"background_download_service_impl.cc",
|
||||
"background_download_service_impl.h",
|
||||
]
|
||||
|
||||
visibility = [
|
||||
|
68
components/download/internal/background_service/ios/background_download_service_impl.cc
Normal file
68
components/download/internal/background_service/ios/background_download_service_impl.cc
Normal file
@ -0,0 +1,68 @@
|
||||
// Copyright 2021 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "components/download/internal/background_service/ios/background_download_service_impl.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "base/notreached.h"
|
||||
#include "components/download/internal/background_service/config.h"
|
||||
#include "components/download/public/background_service/download_params.h"
|
||||
|
||||
namespace download {
|
||||
|
||||
BackgroundDownloadServiceImpl::BackgroundDownloadServiceImpl()
|
||||
: config_(std::make_unique<Configuration>()),
|
||||
service_config_(config_.get()) {}
|
||||
|
||||
BackgroundDownloadServiceImpl::~BackgroundDownloadServiceImpl() = default;
|
||||
|
||||
const ServiceConfig& BackgroundDownloadServiceImpl::GetConfig() {
|
||||
NOTREACHED() << " This function is not supported on iOS.";
|
||||
return service_config_;
|
||||
}
|
||||
void BackgroundDownloadServiceImpl::OnStartScheduledTask(
|
||||
DownloadTaskType task_type,
|
||||
TaskFinishedCallback callback) {
|
||||
NOTREACHED() << " This function is not supported on iOS.";
|
||||
}
|
||||
|
||||
bool BackgroundDownloadServiceImpl::OnStopScheduledTask(
|
||||
DownloadTaskType task_type) {
|
||||
NOTREACHED() << " This function is not supported on iOS.";
|
||||
return true;
|
||||
}
|
||||
|
||||
BackgroundDownloadService::ServiceStatus
|
||||
BackgroundDownloadServiceImpl::GetStatus() {
|
||||
NOTIMPLEMENTED();
|
||||
return BackgroundDownloadService::ServiceStatus::UNAVAILABLE;
|
||||
}
|
||||
|
||||
void BackgroundDownloadServiceImpl::StartDownload(
|
||||
DownloadParams download_params) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void BackgroundDownloadServiceImpl::PauseDownload(const std::string& guid) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
void BackgroundDownloadServiceImpl::ResumeDownload(const std::string& guid) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
void BackgroundDownloadServiceImpl::CancelDownload(const std::string& guid) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
void BackgroundDownloadServiceImpl::ChangeDownloadCriteria(
|
||||
const std::string& guid,
|
||||
const SchedulingParams& params) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
Logger* BackgroundDownloadServiceImpl::GetLogger() {
|
||||
NOTIMPLEMENTED();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace download
|
@ -2,14 +2,14 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef COMPONENTS_DOWNLOAD_INTERNAL_BACKGROUND_SERVICE_IOS_DOWNLOAD_SERVICE_IMPL_H_
|
||||
#define COMPONENTS_DOWNLOAD_INTERNAL_BACKGROUND_SERVICE_IOS_DOWNLOAD_SERVICE_IMPL_H_
|
||||
#ifndef COMPONENTS_DOWNLOAD_INTERNAL_BACKGROUND_SERVICE_IOS_BACKGROUND_DOWNLOAD_SERVICE_IMPL_H_
|
||||
#define COMPONENTS_DOWNLOAD_INTERNAL_BACKGROUND_SERVICE_IOS_BACKGROUND_DOWNLOAD_SERVICE_IMPL_H_
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "components/download/internal/background_service/service_config_impl.h"
|
||||
#include "components/download/public/background_service/download_service.h"
|
||||
#include "components/download/public/background_service/background_download_service.h"
|
||||
#include "components/download/public/task/download_task_types.h"
|
||||
|
||||
namespace download {
|
||||
@ -18,10 +18,10 @@ struct Configuration;
|
||||
struct DownloadParams;
|
||||
struct SchedulingParams;
|
||||
|
||||
class DownloadServiceImpl : public DownloadService {
|
||||
class BackgroundDownloadServiceImpl : public BackgroundDownloadService {
|
||||
public:
|
||||
DownloadServiceImpl();
|
||||
~DownloadServiceImpl() override;
|
||||
BackgroundDownloadServiceImpl();
|
||||
~BackgroundDownloadServiceImpl() override;
|
||||
|
||||
private:
|
||||
// DownloadService implementation.
|
||||
@ -44,4 +44,4 @@ class DownloadServiceImpl : public DownloadService {
|
||||
|
||||
} // namespace download
|
||||
|
||||
#endif // COMPONENTS_DOWNLOAD_INTERNAL_BACKGROUND_SERVICE_IOS_DOWNLOAD_SERVICE_IMPL_H_
|
||||
#endif // COMPONENTS_DOWNLOAD_INTERNAL_BACKGROUND_SERVICE_IOS_BACKGROUND_DOWNLOAD_SERVICE_IMPL_H_
|
@ -1,64 +0,0 @@
|
||||
// Copyright 2021 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "components/download/internal/background_service/ios/download_service_impl.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "base/notreached.h"
|
||||
#include "components/download/internal/background_service/config.h"
|
||||
#include "components/download/public/background_service/download_params.h"
|
||||
|
||||
namespace download {
|
||||
|
||||
DownloadServiceImpl::DownloadServiceImpl()
|
||||
: config_(std::make_unique<Configuration>()),
|
||||
service_config_(config_.get()) {}
|
||||
|
||||
DownloadServiceImpl::~DownloadServiceImpl() = default;
|
||||
|
||||
const ServiceConfig& DownloadServiceImpl::GetConfig() {
|
||||
NOTREACHED() << " This function is not supported on iOS.";
|
||||
return service_config_;
|
||||
}
|
||||
void DownloadServiceImpl::OnStartScheduledTask(DownloadTaskType task_type,
|
||||
TaskFinishedCallback callback) {
|
||||
NOTREACHED() << " This function is not supported on iOS.";
|
||||
}
|
||||
|
||||
bool DownloadServiceImpl::OnStopScheduledTask(DownloadTaskType task_type) {
|
||||
NOTREACHED() << " This function is not supported on iOS.";
|
||||
return true;
|
||||
}
|
||||
|
||||
DownloadService::ServiceStatus DownloadServiceImpl::GetStatus() {
|
||||
NOTIMPLEMENTED();
|
||||
return DownloadService::ServiceStatus::UNAVAILABLE;
|
||||
}
|
||||
|
||||
void DownloadServiceImpl::StartDownload(DownloadParams download_params) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void DownloadServiceImpl::PauseDownload(const std::string& guid) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
void DownloadServiceImpl::ResumeDownload(const std::string& guid) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
void DownloadServiceImpl::CancelDownload(const std::string& guid) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
void DownloadServiceImpl::ChangeDownloadCriteria(
|
||||
const std::string& guid,
|
||||
const SchedulingParams& params) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
Logger* DownloadServiceImpl::GetLogger() {
|
||||
NOTIMPLEMENTED();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace download
|
@ -9,6 +9,7 @@ if (is_android) {
|
||||
|
||||
source_set("public") {
|
||||
sources = [
|
||||
"background_download_service.h",
|
||||
"client.cc",
|
||||
"client.h",
|
||||
"clients.h",
|
||||
@ -16,7 +17,6 @@ source_set("public") {
|
||||
"download_metadata.h",
|
||||
"download_params.cc",
|
||||
"download_params.h",
|
||||
"download_service.h",
|
||||
"features.cc",
|
||||
"features.h",
|
||||
"service_config.h",
|
||||
|
@ -2,8 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef COMPONENTS_DOWNLOAD_PUBLIC_BACKGROUND_SERVICE_DOWNLOAD_SERVICE_H_
|
||||
#define COMPONENTS_DOWNLOAD_PUBLIC_BACKGROUND_SERVICE_DOWNLOAD_SERVICE_H_
|
||||
#ifndef COMPONENTS_DOWNLOAD_PUBLIC_BACKGROUND_SERVICE_BACKGROUND_DOWNLOAD_SERVICE_H_
|
||||
#define COMPONENTS_DOWNLOAD_PUBLIC_BACKGROUND_SERVICE_BACKGROUND_DOWNLOAD_SERVICE_H_
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@ -29,13 +29,13 @@ using TaskFinishedCallback = base::OnceCallback<void(bool)>;
|
||||
// A service responsible for helping facilitate the scheduling and downloading
|
||||
// of file content from the web. See |DownloadParams| for more details on the
|
||||
// types of scheduling that can be achieved and the required input parameters
|
||||
// for starting a download. Note that DownloadServices with a valid storage
|
||||
// directory will persist the requests across restarts. This means that any
|
||||
// feature requesting a download will have to implement a download::Client
|
||||
// for starting a download. Note that BackgroundDownloadService with a valid
|
||||
// storage directory will persist the requests across restarts. This means that
|
||||
// any feature requesting a download will have to implement a download::Client
|
||||
// interface so this class knows who to contact when a download completes after
|
||||
// a process restart.
|
||||
// See the embedder specific factories for creation options.
|
||||
class DownloadService : public KeyedService {
|
||||
class BackgroundDownloadService : public KeyedService {
|
||||
public:
|
||||
// The current status of the Service.
|
||||
enum class ServiceStatus {
|
||||
@ -69,8 +69,8 @@ class DownloadService : public KeyedService {
|
||||
// method directly.
|
||||
virtual bool OnStopScheduledTask(DownloadTaskType task_type) = 0;
|
||||
|
||||
// Whether or not the DownloadService is currently available, initialized
|
||||
// successfully, and ready to be used.
|
||||
// Whether or not the BackgroundDownloadService is currently available,
|
||||
// initialized successfully, and ready to be used.
|
||||
virtual ServiceStatus GetStatus() = 0;
|
||||
|
||||
// Sends the download to the service. A callback to
|
||||
@ -98,15 +98,15 @@ class DownloadService : public KeyedService {
|
||||
// components in the larger system.
|
||||
virtual Logger* GetLogger() = 0;
|
||||
|
||||
~DownloadService() override = default;
|
||||
~BackgroundDownloadService() override = default;
|
||||
|
||||
protected:
|
||||
DownloadService() = default;
|
||||
BackgroundDownloadService() = default;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(DownloadService);
|
||||
DISALLOW_COPY_AND_ASSIGN(BackgroundDownloadService);
|
||||
};
|
||||
|
||||
} // namespace download
|
||||
|
||||
#endif // COMPONENTS_DOWNLOAD_PUBLIC_BACKGROUND_SERVICE_DOWNLOAD_SERVICE_H_
|
||||
#endif // COMPONENTS_DOWNLOAD_PUBLIC_BACKGROUND_SERVICE_BACKGROUND_DOWNLOAD_SERVICE_H_
|
@ -10,12 +10,13 @@
|
||||
#include "base/task/task_traits.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "base/time/time.h"
|
||||
#include "components/download/public/background_service/download_service.h"
|
||||
#include "components/download/public/background_service/background_download_service.h"
|
||||
|
||||
namespace download {
|
||||
|
||||
BasicTaskScheduler::BasicTaskScheduler(
|
||||
const base::RepeatingCallback<DownloadService*()>& get_download_service)
|
||||
const base::RepeatingCallback<BackgroundDownloadService*()>&
|
||||
get_download_service)
|
||||
: get_download_service_(get_download_service) {}
|
||||
|
||||
BasicTaskScheduler::~BasicTaskScheduler() = default;
|
||||
|
@ -15,14 +15,15 @@
|
||||
|
||||
namespace download {
|
||||
|
||||
class DownloadService;
|
||||
class BackgroundDownloadService;
|
||||
|
||||
// A TaskScheduler implementation that doesn't do anything but posts the task
|
||||
// after the specified delay.
|
||||
class BasicTaskScheduler : public download::TaskScheduler {
|
||||
public:
|
||||
explicit BasicTaskScheduler(
|
||||
const base::RepeatingCallback<DownloadService*()>& get_download_service);
|
||||
const base::RepeatingCallback<BackgroundDownloadService*()>&
|
||||
get_download_service);
|
||||
BasicTaskScheduler(const BasicTaskScheduler& other) = delete;
|
||||
BasicTaskScheduler& operator=(const BasicTaskScheduler& other) = delete;
|
||||
~BasicTaskScheduler() override;
|
||||
@ -44,7 +45,7 @@ class BasicTaskScheduler : public download::TaskScheduler {
|
||||
std::map<download::DownloadTaskType, base::CancelableOnceClosure>
|
||||
scheduled_tasks_;
|
||||
|
||||
base::RepeatingCallback<DownloadService*()> get_download_service_;
|
||||
base::RepeatingCallback<BackgroundDownloadService*()> get_download_service_;
|
||||
|
||||
base::WeakPtrFactory<BasicTaskScheduler> weak_factory_{this};
|
||||
};
|
||||
|
@ -8,20 +8,20 @@
|
||||
#include <string>
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "components/download/public/background_service/background_download_service.h"
|
||||
#include "components/download/public/background_service/download_params.h"
|
||||
#include "components/download/public/background_service/download_service.h"
|
||||
#include "components/download/public/background_service/service_config.h"
|
||||
#include "testing/gmock/include/gmock/gmock.h"
|
||||
|
||||
namespace download {
|
||||
namespace test {
|
||||
|
||||
class MockDownloadService : public DownloadService {
|
||||
class MockDownloadService : public BackgroundDownloadService {
|
||||
public:
|
||||
MockDownloadService();
|
||||
~MockDownloadService() override;
|
||||
|
||||
// DownloadService implementation.
|
||||
// BackgroundDownloadService implementation.
|
||||
MOCK_METHOD0(GetConfig, const ServiceConfig&());
|
||||
MOCK_METHOD2(OnStartScheduledTask,
|
||||
void(DownloadTaskType task_type, TaskFinishedCallback callback));
|
||||
|
@ -7,10 +7,10 @@
|
||||
#include "base/bind.h"
|
||||
#include "base/no_destructor.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "components/download/public/background_service/background_download_service.h"
|
||||
#include "components/download/public/background_service/client.h"
|
||||
#include "components/download/public/background_service/download_metadata.h"
|
||||
#include "components/download/public/background_service/download_params.h"
|
||||
#include "components/download/public/background_service/download_service.h"
|
||||
#include "components/download/public/background_service/service_config.h"
|
||||
#include "components/download/public/background_service/test/empty_logger.h"
|
||||
|
||||
@ -61,9 +61,9 @@ bool TestDownloadService::OnStopScheduledTask(DownloadTaskType task_type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
DownloadService::ServiceStatus TestDownloadService::GetStatus() {
|
||||
return is_ready_ ? DownloadService::ServiceStatus::READY
|
||||
: DownloadService::ServiceStatus::STARTING_UP;
|
||||
BackgroundDownloadService::ServiceStatus TestDownloadService::GetStatus() {
|
||||
return is_ready_ ? BackgroundDownloadService::ServiceStatus::READY
|
||||
: BackgroundDownloadService::ServiceStatus::STARTING_UP;
|
||||
}
|
||||
|
||||
void TestDownloadService::StartDownload(DownloadParams params) {
|
||||
|
@ -9,9 +9,9 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "components/download/public/background_service/background_download_service.h"
|
||||
#include "components/download/public/background_service/client.h"
|
||||
#include "components/download/public/background_service/download_params.h"
|
||||
#include "components/download/public/background_service/download_service.h"
|
||||
#include "third_party/abseil-cpp/absl/types/optional.h"
|
||||
|
||||
namespace download {
|
||||
@ -20,8 +20,8 @@ struct CompletionInfo;
|
||||
|
||||
namespace test {
|
||||
|
||||
// Implementation of DownloadService used for testing.
|
||||
class TestDownloadService : public DownloadService {
|
||||
// Implementation of BackgroundDownloadService used for testing.
|
||||
class TestDownloadService : public BackgroundDownloadService {
|
||||
public:
|
||||
TestDownloadService();
|
||||
~TestDownloadService() override;
|
||||
@ -31,7 +31,7 @@ class TestDownloadService : public DownloadService {
|
||||
void OnStartScheduledTask(DownloadTaskType task_type,
|
||||
TaskFinishedCallback callback) override;
|
||||
bool OnStopScheduledTask(DownloadTaskType task_type) override;
|
||||
DownloadService::ServiceStatus GetStatus() override;
|
||||
BackgroundDownloadService::ServiceStatus GetStatus() override;
|
||||
void StartDownload(DownloadParams download_params) override;
|
||||
void PauseDownload(const std::string& guid) override;
|
||||
void ResumeDownload(const std::string& guid) override;
|
||||
|
@ -10,8 +10,8 @@
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/time/time.h"
|
||||
#include "base/trace_event/trace_event.h"
|
||||
#include "components/download/public/background_service/background_download_service.h"
|
||||
#include "components/download/public/background_service/download_params.h"
|
||||
#include "components/download/public/background_service/download_service.h"
|
||||
#include "components/download/public/background_service/service_config.h"
|
||||
#include "components/offline_pages/core/offline_clock.h"
|
||||
#include "components/offline_pages/core/offline_event_logger.h"
|
||||
@ -37,7 +37,7 @@ void NotifyDispatcher(PrefetchService* service, PrefetchDownloadResult result) {
|
||||
} // namespace
|
||||
|
||||
PrefetchDownloaderImpl::PrefetchDownloaderImpl(
|
||||
download::DownloadService* download_service,
|
||||
download::BackgroundDownloadService* download_service,
|
||||
version_info::Channel channel,
|
||||
PrefService* prefs)
|
||||
: download_service_(download_service), channel_(channel), prefs_(prefs) {
|
||||
|
@ -21,7 +21,7 @@
|
||||
class PrefService;
|
||||
|
||||
namespace download {
|
||||
class DownloadService;
|
||||
class BackgroundDownloadService;
|
||||
} // namespace download
|
||||
|
||||
namespace offline_pages {
|
||||
@ -31,7 +31,7 @@ class PrefetchService;
|
||||
// Asynchronously downloads the archive.
|
||||
class PrefetchDownloaderImpl : public PrefetchDownloader {
|
||||
public:
|
||||
PrefetchDownloaderImpl(download::DownloadService* download_service,
|
||||
PrefetchDownloaderImpl(download::BackgroundDownloadService* download_service,
|
||||
version_info::Channel channel,
|
||||
PrefService* prefs);
|
||||
~PrefetchDownloaderImpl() override;
|
||||
@ -75,7 +75,7 @@ class PrefetchDownloaderImpl : public PrefetchDownloader {
|
||||
success_downloads);
|
||||
|
||||
// Unowned. It is valid until |this| instance is disposed.
|
||||
download::DownloadService* download_service_;
|
||||
download::BackgroundDownloadService* download_service_;
|
||||
|
||||
// Unowned, owns |this|.
|
||||
PrefetchService* prefetch_service_ = nullptr;
|
||||
|
@ -87,9 +87,10 @@ bool TestDownloadService::OnStopScheduledTask(
|
||||
NOTIMPLEMENTED();
|
||||
return false;
|
||||
}
|
||||
download::DownloadService::ServiceStatus TestDownloadService::GetStatus() {
|
||||
download::BackgroundDownloadService::ServiceStatus
|
||||
TestDownloadService::GetStatus() {
|
||||
NOTIMPLEMENTED();
|
||||
return DownloadService::ServiceStatus();
|
||||
return BackgroundDownloadService::ServiceStatus();
|
||||
}
|
||||
void TestDownloadService::PauseDownload(const std::string& guid) {
|
||||
NOTIMPLEMENTED();
|
||||
|
@ -9,26 +9,26 @@
|
||||
#include <string>
|
||||
|
||||
#include "base/files/scoped_temp_dir.h"
|
||||
#include "components/download/public/background_service/background_download_service.h"
|
||||
#include "components/download/public/background_service/client.h"
|
||||
#include "components/download/public/background_service/download_params.h"
|
||||
#include "components/download/public/background_service/download_service.h"
|
||||
#include "components/offline_pages/core/prefetch/test_download_client.h"
|
||||
#include "third_party/abseil-cpp/absl/types/optional.h"
|
||||
|
||||
namespace offline_pages {
|
||||
|
||||
// Implementation of DownloadService used for testing.
|
||||
class TestDownloadService : public download::DownloadService {
|
||||
// Implementation of BackgroundDownloadService used for testing.
|
||||
class TestDownloadService : public download::BackgroundDownloadService {
|
||||
public:
|
||||
TestDownloadService();
|
||||
~TestDownloadService() override;
|
||||
|
||||
// DownloadService implementation.
|
||||
// BackgroundDownloadService implementation.
|
||||
const download::ServiceConfig& GetConfig() override;
|
||||
void OnStartScheduledTask(download::DownloadTaskType task_type,
|
||||
download::TaskFinishedCallback callback) override;
|
||||
bool OnStopScheduledTask(download::DownloadTaskType task_type) override;
|
||||
DownloadService::ServiceStatus GetStatus() override;
|
||||
BackgroundDownloadService::ServiceStatus GetStatus() override;
|
||||
void StartDownload(download::DownloadParams download_params) override;
|
||||
void PauseDownload(const std::string& guid) override;
|
||||
void ResumeDownload(const std::string& guid) override;
|
||||
|
@ -14,11 +14,11 @@
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "base/test/scoped_feature_list.h"
|
||||
#include "components/download/content/factory/download_service_factory_helper.h"
|
||||
#include "components/download/public/background_service/background_download_service.h"
|
||||
#include "components/download/public/background_service/blob_context_getter_factory.h"
|
||||
#include "components/download/public/background_service/clients.h"
|
||||
#include "components/download/public/background_service/download_metadata.h"
|
||||
#include "components/download/public/background_service/download_params.h"
|
||||
#include "components/download/public/background_service/download_service.h"
|
||||
#include "components/download/public/background_service/features.h"
|
||||
#include "components/keyed_service/core/simple_factory_key.h"
|
||||
#include "components/keyed_service/core/simple_key_map.h"
|
||||
|
@ -15,7 +15,7 @@
|
||||
class SimpleFactoryKey;
|
||||
|
||||
namespace download {
|
||||
class DownloadService;
|
||||
class BackgroundDownloadService;
|
||||
} // namespace download
|
||||
|
||||
namespace content {
|
||||
@ -52,7 +52,7 @@ class WebTestBackgroundFetchDelegate : public BackgroundFetchDelegate {
|
||||
std::unique_ptr<SimpleFactoryKey> simple_factory_key_;
|
||||
|
||||
// In-memory instance of the Download Service lazily created by the delegate.
|
||||
std::unique_ptr<download::DownloadService> download_service_;
|
||||
std::unique_ptr<download::BackgroundDownloadService> download_service_;
|
||||
|
||||
// Weak reference to an instance of our download client.
|
||||
WebTestBackgroundFetchDownloadClient* background_fetch_client_;
|
||||
|
@ -18,7 +18,7 @@
|
||||
#import "ios/chrome/browser/device_sharing/device_sharing_manager_factory.h"
|
||||
#include "ios/chrome/browser/discover_feed/discover_feed_service_factory.h"
|
||||
#include "ios/chrome/browser/dom_distiller/dom_distiller_service_factory.h"
|
||||
#include "ios/chrome/browser/download/background_service/download_service_factory.h"
|
||||
#include "ios/chrome/browser/download/background_service/background_download_service_factory.h"
|
||||
#include "ios/chrome/browser/download/browser_download_service_factory.h"
|
||||
#include "ios/chrome/browser/favicon/favicon_service_factory.h"
|
||||
#include "ios/chrome/browser/favicon/ios_chrome_favicon_loader_factory.h"
|
||||
@ -122,7 +122,7 @@ void EnsureBrowserStateKeyedServiceFactoriesBuilt() {
|
||||
DeviceSharingManagerFactory::GetInstance();
|
||||
DiscoverFeedServiceFactory::GetInstance();
|
||||
DomainDiversityReporterFactory::GetInstance();
|
||||
DownloadServiceFactory::GetInstance();
|
||||
BackgroundDownloadServiceFactory::GetInstance();
|
||||
GoogleLogoServiceFactory::GetInstance();
|
||||
IdentityManagerFactory::GetInstance();
|
||||
IOSChromeContentSuggestionsServiceFactory::GetInstance();
|
||||
|
@ -4,8 +4,8 @@
|
||||
|
||||
source_set("background_service") {
|
||||
sources = [
|
||||
"download_service_factory.cc",
|
||||
"download_service_factory.h",
|
||||
"background_download_service_factory.cc",
|
||||
"background_download_service_factory.h",
|
||||
]
|
||||
|
||||
deps = [
|
||||
|
40
ios/chrome/browser/download/background_service/background_download_service_factory.cc
Normal file
40
ios/chrome/browser/download/background_service/background_download_service_factory.cc
Normal file
@ -0,0 +1,40 @@
|
||||
// Copyright 2021 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "ios/chrome/browser/download/background_service/background_download_service_factory.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "components/download/internal/background_service/ios/background_download_service_impl.h"
|
||||
#include "components/download/public/background_service/background_download_service.h"
|
||||
#include "components/keyed_service/ios/browser_state_dependency_manager.h"
|
||||
#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
|
||||
|
||||
// static
|
||||
download::BackgroundDownloadService*
|
||||
BackgroundDownloadServiceFactory::GetForBrowserState(
|
||||
ChromeBrowserState* browser_state) {
|
||||
return static_cast<download::BackgroundDownloadService*>(
|
||||
GetInstance()->GetServiceForBrowserState(browser_state, true));
|
||||
}
|
||||
|
||||
// static
|
||||
BackgroundDownloadServiceFactory*
|
||||
BackgroundDownloadServiceFactory::GetInstance() {
|
||||
static base::NoDestructor<BackgroundDownloadServiceFactory> instance;
|
||||
return instance.get();
|
||||
}
|
||||
|
||||
BackgroundDownloadServiceFactory::BackgroundDownloadServiceFactory()
|
||||
: BrowserStateKeyedServiceFactory(
|
||||
"BackgroundDownloadService",
|
||||
BrowserStateDependencyManager::GetInstance()) {}
|
||||
|
||||
BackgroundDownloadServiceFactory::~BackgroundDownloadServiceFactory() = default;
|
||||
|
||||
std::unique_ptr<KeyedService>
|
||||
BackgroundDownloadServiceFactory::BuildServiceInstanceFor(
|
||||
web::BrowserState* context) const {
|
||||
return std::make_unique<download::BackgroundDownloadServiceImpl>();
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
// Copyright 2021 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef IOS_CHROME_BROWSER_DOWNLOAD_BACKGROUND_SERVICE_BACKGROUND_DOWNLOAD_SERVICE_FACTORY_H_
|
||||
#define IOS_CHROME_BROWSER_DOWNLOAD_BACKGROUND_SERVICE_BACKGROUND_DOWNLOAD_SERVICE_FACTORY_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "base/no_destructor.h"
|
||||
#include "components/keyed_service/ios/browser_state_keyed_service_factory.h"
|
||||
|
||||
class ChromeBrowserState;
|
||||
|
||||
namespace download {
|
||||
class BackgroundDownloadService;
|
||||
}
|
||||
|
||||
// Singleton that owns all BackgroundDownloadServiceFactory and associates them
|
||||
// with ChromeBrowserState.
|
||||
class BackgroundDownloadServiceFactory
|
||||
: public BrowserStateKeyedServiceFactory {
|
||||
public:
|
||||
static download::BackgroundDownloadService* GetForBrowserState(
|
||||
ChromeBrowserState* browser_state);
|
||||
static BackgroundDownloadServiceFactory* GetInstance();
|
||||
|
||||
private:
|
||||
friend class base::NoDestructor<BackgroundDownloadServiceFactory>;
|
||||
|
||||
BackgroundDownloadServiceFactory();
|
||||
~BackgroundDownloadServiceFactory() override;
|
||||
BackgroundDownloadServiceFactory(const BackgroundDownloadServiceFactory&) =
|
||||
delete;
|
||||
BackgroundDownloadServiceFactory& operator=(
|
||||
const BackgroundDownloadServiceFactory&) = delete;
|
||||
|
||||
// BrowserStateKeyedServiceFactory implementation.
|
||||
std::unique_ptr<KeyedService> BuildServiceInstanceFor(
|
||||
web::BrowserState* context) const override;
|
||||
};
|
||||
|
||||
#endif // IOS_CHROME_BROWSER_DOWNLOAD_BACKGROUND_SERVICE_BACKGROUND_DOWNLOAD_SERVICE_FACTORY_H_
|
@ -1,37 +0,0 @@
|
||||
// Copyright 2021 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "ios/chrome/browser/download/background_service/download_service_factory.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "components/download/internal/background_service/ios/download_service_impl.h"
|
||||
#include "components/download/public/background_service/download_service.h"
|
||||
#include "components/keyed_service/ios/browser_state_dependency_manager.h"
|
||||
#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
|
||||
|
||||
// static
|
||||
download::DownloadService* DownloadServiceFactory::GetForBrowserState(
|
||||
ChromeBrowserState* browser_state) {
|
||||
return static_cast<download::DownloadService*>(
|
||||
GetInstance()->GetServiceForBrowserState(browser_state, true));
|
||||
}
|
||||
|
||||
// static
|
||||
DownloadServiceFactory* DownloadServiceFactory::GetInstance() {
|
||||
static base::NoDestructor<DownloadServiceFactory> instance;
|
||||
return instance.get();
|
||||
}
|
||||
|
||||
DownloadServiceFactory::DownloadServiceFactory()
|
||||
: BrowserStateKeyedServiceFactory(
|
||||
"DownloadService",
|
||||
BrowserStateDependencyManager::GetInstance()) {}
|
||||
|
||||
DownloadServiceFactory::~DownloadServiceFactory() = default;
|
||||
|
||||
std::unique_ptr<KeyedService> DownloadServiceFactory::BuildServiceInstanceFor(
|
||||
web::BrowserState* context) const {
|
||||
return std::make_unique<download::DownloadServiceImpl>();
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
// Copyright 2021 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef IOS_CHROME_BROWSER_DOWNLOAD_BACKGROUND_SERVICE_DOWNLOAD_SERVICE_FACTORY_H_
|
||||
#define IOS_CHROME_BROWSER_DOWNLOAD_BACKGROUND_SERVICE_DOWNLOAD_SERVICE_FACTORY_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "base/no_destructor.h"
|
||||
#include "components/keyed_service/ios/browser_state_keyed_service_factory.h"
|
||||
|
||||
class ChromeBrowserState;
|
||||
|
||||
namespace download {
|
||||
class DownloadService;
|
||||
}
|
||||
|
||||
// Singleton that owns all DownloadServiceFactory and associates them with
|
||||
// ChromeBrowserState.
|
||||
class DownloadServiceFactory : public BrowserStateKeyedServiceFactory {
|
||||
public:
|
||||
static download::DownloadService* GetForBrowserState(
|
||||
ChromeBrowserState* browser_state);
|
||||
static DownloadServiceFactory* GetInstance();
|
||||
|
||||
private:
|
||||
friend class base::NoDestructor<DownloadServiceFactory>;
|
||||
|
||||
DownloadServiceFactory();
|
||||
~DownloadServiceFactory() override;
|
||||
DownloadServiceFactory(const DownloadServiceFactory&) = delete;
|
||||
DownloadServiceFactory& operator=(const DownloadServiceFactory&) = delete;
|
||||
|
||||
// BrowserStateKeyedServiceFactory implementation.
|
||||
std::unique_ptr<KeyedService> BuildServiceInstanceFor(
|
||||
web::BrowserState* context) const override;
|
||||
};
|
||||
|
||||
#endif // IOS_CHROME_BROWSER_DOWNLOAD_BACKGROUND_SERVICE_DOWNLOAD_SERVICE_FACTORY_H_
|
@ -139,6 +139,8 @@ source_set("weblayer_lib_base") {
|
||||
"app/main.cc",
|
||||
"browser/autofill_client_impl.cc",
|
||||
"browser/autofill_client_impl.h",
|
||||
"browser/background_download_service_factory.cc",
|
||||
"browser/background_download_service_factory.h",
|
||||
"browser/background_fetch/background_fetch_delegate_factory.cc",
|
||||
"browser/background_fetch/background_fetch_delegate_factory.h",
|
||||
"browser/background_fetch/background_fetch_delegate_impl.cc",
|
||||
@ -184,8 +186,6 @@ source_set("weblayer_lib_base") {
|
||||
"browser/download_impl.h",
|
||||
"browser/download_manager_delegate_impl.cc",
|
||||
"browser/download_manager_delegate_impl.h",
|
||||
"browser/download_service_factory.cc",
|
||||
"browser/download_service_factory.h",
|
||||
"browser/favicon/favicon_backend_wrapper.cc",
|
||||
"browser/favicon/favicon_backend_wrapper.h",
|
||||
"browser/favicon/favicon_fetcher_impl.cc",
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "weblayer/browser/download_service_factory.h"
|
||||
#include "weblayer/browser/background_download_service_factory.h"
|
||||
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/sequenced_task_runner.h"
|
||||
@ -12,10 +12,10 @@
|
||||
#include "components/background_fetch/download_client.h"
|
||||
#include "components/download/content/factory/download_service_factory_helper.h"
|
||||
#include "components/download/content/factory/navigation_monitor_factory.h"
|
||||
#include "components/download/public/background_service/background_download_service.h"
|
||||
#include "components/download/public/background_service/basic_task_scheduler.h"
|
||||
#include "components/download/public/background_service/blob_context_getter_factory.h"
|
||||
#include "components/download/public/background_service/clients.h"
|
||||
#include "components/download/public/background_service/download_service.h"
|
||||
#include "components/download/public/common/simple_download_manager_coordinator.h"
|
||||
#include "components/keyed_service/content/browser_context_dependency_manager.h"
|
||||
#include "components/leveldb_proto/public/proto_database_provider.h"
|
||||
@ -33,8 +33,9 @@ namespace weblayer {
|
||||
|
||||
namespace {
|
||||
|
||||
// Like DownloadServiceFactory, this is a BrowserContextKeyedServiceFactory
|
||||
// although the Chrome version is a SimpleKeyedServiceFactory.
|
||||
// Like BackgroundDownloadServiceFactory, this is a
|
||||
// BrowserContextKeyedServiceFactory although the Chrome version is a
|
||||
// SimpleKeyedServiceFactory.
|
||||
class SimpleDownloadManagerCoordinatorFactory
|
||||
: public BrowserContextKeyedServiceFactory {
|
||||
public:
|
||||
@ -108,28 +109,30 @@ class DownloadBlobContextGetterFactory
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
download::DownloadService* DownloadServiceFactory::GetForBrowserContext(
|
||||
download::BackgroundDownloadService*
|
||||
BackgroundDownloadServiceFactory::GetForBrowserContext(
|
||||
content::BrowserContext* browser_context) {
|
||||
return static_cast<download::DownloadService*>(
|
||||
return static_cast<download::BackgroundDownloadService*>(
|
||||
GetInstance()->GetServiceForBrowserContext(browser_context,
|
||||
/*create=*/true));
|
||||
}
|
||||
|
||||
// static
|
||||
DownloadServiceFactory* DownloadServiceFactory::GetInstance() {
|
||||
static base::NoDestructor<DownloadServiceFactory> factory;
|
||||
BackgroundDownloadServiceFactory*
|
||||
BackgroundDownloadServiceFactory::GetInstance() {
|
||||
static base::NoDestructor<BackgroundDownloadServiceFactory> factory;
|
||||
return factory.get();
|
||||
}
|
||||
|
||||
DownloadServiceFactory::DownloadServiceFactory()
|
||||
BackgroundDownloadServiceFactory::BackgroundDownloadServiceFactory()
|
||||
: BrowserContextKeyedServiceFactory(
|
||||
"DownloadServiceFactory",
|
||||
"BackgroundDownloadServiceFactory",
|
||||
BrowserContextDependencyManager::GetInstance()) {
|
||||
DependsOn(SimpleDownloadManagerCoordinatorFactory::GetInstance());
|
||||
DependsOn(download::NavigationMonitorFactory::GetInstance());
|
||||
}
|
||||
|
||||
KeyedService* DownloadServiceFactory::BuildServiceInstanceFor(
|
||||
KeyedService* BackgroundDownloadServiceFactory::BuildServiceInstanceFor(
|
||||
content::BrowserContext* context) const {
|
||||
SimpleFactoryKey* key = ProfileImpl::FromBrowserContext(context)
|
||||
->GetBrowserContext()
|
||||
@ -176,13 +179,15 @@ KeyedService* DownloadServiceFactory::BuildServiceInstanceFor(
|
||||
proto_db_provider, background_task_runner,
|
||||
std::make_unique<download::BasicTaskScheduler>(base::BindRepeating(
|
||||
[](content::BrowserContext* context) {
|
||||
return DownloadServiceFactory::GetForBrowserContext(context);
|
||||
return BackgroundDownloadServiceFactory::
|
||||
GetForBrowserContext(context);
|
||||
},
|
||||
context)))
|
||||
.release();
|
||||
}
|
||||
|
||||
content::BrowserContext* DownloadServiceFactory::GetBrowserContextToUse(
|
||||
content::BrowserContext*
|
||||
BackgroundDownloadServiceFactory::GetBrowserContextToUse(
|
||||
content::BrowserContext* context) const {
|
||||
return context;
|
||||
}
|
30
weblayer/browser/download_service_factory.h → weblayer/browser/background_download_service_factory.h
30
weblayer/browser/download_service_factory.h → weblayer/browser/background_download_service_factory.h
@ -2,37 +2,39 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef WEBLAYER_BROWSER_DOWNLOAD_SERVICE_FACTORY_H_
|
||||
#define WEBLAYER_BROWSER_DOWNLOAD_SERVICE_FACTORY_H_
|
||||
#ifndef WEBLAYER_BROWSER_BACKGROUND_DOWNLOAD_SERVICE_FACTORY_H_
|
||||
#define WEBLAYER_BROWSER_BACKGROUND_DOWNLOAD_SERVICE_FACTORY_H_
|
||||
|
||||
#include "base/no_destructor.h"
|
||||
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
|
||||
|
||||
namespace download {
|
||||
class DownloadService;
|
||||
}
|
||||
class BackgroundDownloadService;
|
||||
} // namespace download
|
||||
|
||||
namespace weblayer {
|
||||
|
||||
// Unlike Chrome, which can operate outside of full browser mode, WebLayer can
|
||||
// assume the full BrowserContext is available. For that reason this class is a
|
||||
// BrowserContextKeyedService rather than a SimpleKeyedServiceFactory.
|
||||
class DownloadServiceFactory : public BrowserContextKeyedServiceFactory {
|
||||
class BackgroundDownloadServiceFactory
|
||||
: public BrowserContextKeyedServiceFactory {
|
||||
public:
|
||||
static DownloadServiceFactory* GetInstance();
|
||||
static BackgroundDownloadServiceFactory* GetInstance();
|
||||
|
||||
static download::DownloadService* GetForBrowserContext(
|
||||
static download::BackgroundDownloadService* GetForBrowserContext(
|
||||
content::BrowserContext* context);
|
||||
|
||||
DownloadServiceFactory(const DownloadServiceFactory& other) = delete;
|
||||
DownloadServiceFactory& operator=(const DownloadServiceFactory& other) =
|
||||
delete;
|
||||
BackgroundDownloadServiceFactory(
|
||||
const BackgroundDownloadServiceFactory& other) = delete;
|
||||
BackgroundDownloadServiceFactory& operator=(
|
||||
const BackgroundDownloadServiceFactory& other) = delete;
|
||||
|
||||
private:
|
||||
friend class base::NoDestructor<DownloadServiceFactory>;
|
||||
friend class base::NoDestructor<BackgroundDownloadServiceFactory>;
|
||||
|
||||
DownloadServiceFactory();
|
||||
~DownloadServiceFactory() override = default;
|
||||
BackgroundDownloadServiceFactory();
|
||||
~BackgroundDownloadServiceFactory() override = default;
|
||||
|
||||
// BrowserContextKeyedService:
|
||||
KeyedService* BuildServiceInstanceFor(
|
||||
@ -43,4 +45,4 @@ class DownloadServiceFactory : public BrowserContextKeyedServiceFactory {
|
||||
|
||||
} // namespace weblayer
|
||||
|
||||
#endif // WEBLAYER_BROWSER_DOWNLOAD_SERVICE_FACTORY_H_
|
||||
#endif // WEBLAYER_BROWSER_BACKGROUND_DOWNLOAD_SERVICE_FACTORY_H_
|
@ -8,8 +8,8 @@
|
||||
#include "build/build_config.h"
|
||||
#include "components/keyed_service/content/browser_context_dependency_manager.h"
|
||||
#include "content/public/browser/background_fetch_delegate.h"
|
||||
#include "weblayer/browser/background_download_service_factory.h"
|
||||
#include "weblayer/browser/background_fetch/background_fetch_delegate_impl.h"
|
||||
#include "weblayer/browser/download_service_factory.h"
|
||||
#include "weblayer/browser/host_content_settings_map_factory.h"
|
||||
|
||||
#if defined(OS_ANDROID)
|
||||
@ -47,7 +47,7 @@ BackgroundFetchDelegateFactory::BackgroundFetchDelegateFactory()
|
||||
: BrowserContextKeyedServiceFactory(
|
||||
"BackgroundFetchService",
|
||||
BrowserContextDependencyManager::GetInstance()) {
|
||||
DependsOn(DownloadServiceFactory::GetInstance());
|
||||
DependsOn(BackgroundDownloadServiceFactory::GetInstance());
|
||||
DependsOn(HostContentSettingsMapFactory::GetInstance());
|
||||
}
|
||||
|
||||
|
@ -15,8 +15,8 @@
|
||||
#include "content/public/browser/browser_context.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "weblayer/browser/background_download_service_factory.h"
|
||||
#include "weblayer/browser/browser_context_impl.h"
|
||||
#include "weblayer/browser/download_service_factory.h"
|
||||
#include "weblayer/browser/profile_impl.h"
|
||||
#include "weblayer/browser/system_network_context_manager.h"
|
||||
#include "weblayer/public/download_delegate.h"
|
||||
@ -77,8 +77,9 @@ void BackgroundFetchDelegateImpl::UpdateUI(
|
||||
client->OnUIUpdated(job_id);
|
||||
}
|
||||
|
||||
download::DownloadService* BackgroundFetchDelegateImpl::GetDownloadService() {
|
||||
return DownloadServiceFactory::GetForBrowserContext(context());
|
||||
download::BackgroundDownloadService*
|
||||
BackgroundFetchDelegateImpl::GetDownloadService() {
|
||||
return BackgroundDownloadServiceFactory::GetForBrowserContext(context());
|
||||
}
|
||||
|
||||
void BackgroundFetchDelegateImpl::OnJobDetailsCreated(
|
||||
|
@ -24,7 +24,8 @@ class BrowserContext;
|
||||
|
||||
namespace weblayer {
|
||||
|
||||
// Implementation of BackgroundFetchDelegate using the DownloadService.
|
||||
// Implementation of BackgroundFetchDelegate using the
|
||||
// BackgroundDownloadService.
|
||||
class BackgroundFetchDelegateImpl
|
||||
: public background_fetch::BackgroundFetchDelegateBase,
|
||||
public KeyedService {
|
||||
@ -43,7 +44,7 @@ class BackgroundFetchDelegateImpl
|
||||
|
||||
protected:
|
||||
// BackgroundFetchDelegateBase:
|
||||
download::DownloadService* GetDownloadService() override;
|
||||
download::BackgroundDownloadService* GetDownloadService() override;
|
||||
void OnJobDetailsCreated(const std::string& job_id) override;
|
||||
void DoShowUi(const std::string& job_id) override;
|
||||
void DoUpdateUi(const std::string& job_id) override;
|
||||
|
Reference in New Issue
Block a user