#include "chrome/browser/download/background_download_service_factory.h"
#include <memory>
#include <utility>
#include "base/feature_list.h"
#include "base/files/file_path.h"
#include "base/memory/raw_ptr.h"
#include "base/no_destructor.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/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/download/deferred_client_wrapper.h"
#include "chrome/browser/download/download_manager_utils.h"
#include "chrome/browser/download/simple_download_manager_coordinator_factory.h"
#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/browser/optimization_guide/prediction/prediction_model_download_client.h"
#include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_key.h"
#include "chrome/browser/transition_manager/full_browser_transition_manager.h"
#include "chrome/common/chrome_constants.h"
#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/features.h"
#include "components/download/public/common/simple_download_manager_coordinator.h"
#include "components/keyed_service/core/simple_dependency_manager.h"
#include "components/leveldb_proto/public/proto_database_provider.h"
#include "components/optimization_guide/core/optimization_guide_features.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/download_manager.h"
#include "content/public/browser/network_service_instance.h"
#include "content/public/browser/storage_partition.h"
#if BUILDFLAG(IS_ANDROID)
#include "chrome/browser/download/android/service/download_task_scheduler.h"
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/ash/plugin_vm/plugin_vm_image_download_client.h"
#endif
namespace {
std::unique_ptr<download::Client> CreateBackgroundFetchDownloadClient(
Profile* profile) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
std::unique_ptr<download::Client> CreatePluginVmImageDownloadClient(
Profile* profile) {
return std::make_unique<plugin_vm::PluginVmImageDownloadClient>(profile);
}
#endif
std::unique_ptr<download::Client>
CreateOptimizationGuidePredictionModelDownloadClient(Profile* profile) { … }
void DownloadOnProfileCreated(download::BlobContextGetterCallback callback,
Profile* profile) { … }
class DownloadBlobContextGetterFactory
: public download::BlobContextGetterFactory { … };
}
BackgroundDownloadServiceFactory*
BackgroundDownloadServiceFactory::GetInstance() { … }
download::BackgroundDownloadService*
BackgroundDownloadServiceFactory::GetForKey(SimpleFactoryKey* key) { … }
BackgroundDownloadServiceFactory::BackgroundDownloadServiceFactory()
: … { … }
BackgroundDownloadServiceFactory::~BackgroundDownloadServiceFactory() = default;
std::unique_ptr<KeyedService>
BackgroundDownloadServiceFactory::BuildServiceInstanceFor(
SimpleFactoryKey* key) const { … }
SimpleFactoryKey* BackgroundDownloadServiceFactory::GetKeyToUse(
SimpleFactoryKey* key) const { … }