Commit ccb33e88 authored by peter's avatar peter Committed by Commit bot

Rename the DownloadService to DownloadCoreService

The class currently named DownloadService provides access to a number of
internal details to the core of the download system in Chrome. While
it's a service in that it's a KeyedService with a factory, it's not
*the* service that services downloads.

A new project has been started to add an actual download service, that
enables different systems in Chrome to download files. That's the thing
that really should be called DownloadService.

BUG=

Review-Url: https://codereview.chromium.org/2853363002
Cr-Commit-Position: refs/heads/master@{#468729}
parent 73357e23
......@@ -327,6 +327,12 @@ split_static_library("browser") {
"download/chrome_download_manager_delegate.h",
"download/download_confirmation_reason.h",
"download/download_confirmation_result.h",
"download/download_core_service.cc",
"download/download_core_service.h",
"download/download_core_service_factory.cc",
"download/download_core_service_factory.h",
"download/download_core_service_impl.cc",
"download/download_core_service_impl.h",
"download/download_crx_util_android.cc",
"download/download_file_picker.cc",
"download/download_file_picker.h",
......@@ -344,12 +350,6 @@ split_static_library("browser") {
"download/download_request_limiter.h",
"download/download_resource_throttle.cc",
"download/download_resource_throttle.h",
"download/download_service.cc",
"download/download_service.h",
"download/download_service_factory.cc",
"download/download_service_factory.h",
"download/download_service_impl.cc",
"download/download_service_impl.h",
"download/download_started_animation.h",
"download/download_stats.cc",
"download/download_stats.h",
......
......@@ -12,8 +12,8 @@
#include "base/time/time.h"
#include "chrome/browser/android/chrome_feature_list.h"
#include "chrome/browser/android/download/download_controller.h"
#include "chrome/browser/download/download_service.h"
#include "chrome/browser/download/download_service_factory.h"
#include "chrome/browser/download/download_core_service.h"
#include "chrome/browser/download/download_core_service_factory.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/grit/generated_resources.h"
#include "components/mime_util/mime_util.h"
......@@ -130,9 +130,9 @@ static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& jobj) {
Profile* profile = ProfileManager::GetActiveUserProfile();
DownloadManagerService* service = DownloadManagerService::GetInstance();
service->Init(env, jobj);
DownloadService* download_service =
DownloadServiceFactory::GetForBrowserContext(profile);
DownloadHistory* history = download_service->GetDownloadHistory();
DownloadCoreService* download_core_service =
DownloadCoreServiceFactory::GetForBrowserContext(profile);
DownloadHistory* history = download_core_service->GetDownloadHistory();
if (history)
history->AddObserver(service);
return reinterpret_cast<intptr_t>(service);
......
......@@ -30,8 +30,8 @@
#include "chrome/browser/browser_shutdown.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/command_updater.h"
#include "chrome/browser/download/download_service.h"
#include "chrome/browser/download/download_service_factory.h"
#include "chrome/browser/download/download_core_service.h"
#include "chrome/browser/download/download_core_service_factory.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/first_run/first_run.h"
#include "chrome/browser/lifetime/application_lifetime.h"
......@@ -414,8 +414,8 @@ class AppControllerProfileObserver : public ProfileAttributesStorage::Observer {
// At this point, the user has already chosen to cancel downloads. If we
// were to shut down as usual, the downloads would be cancelled in
// DownloadService::Shutdown().
DownloadService::CancelAllDownloads();
// DownloadCoreService::Shutdown().
DownloadCoreService::CancelAllDownloads();
return NO;
}
......@@ -787,11 +787,12 @@ class AppControllerProfileObserver : public ProfileAttributesStorage::Observer {
std::vector<Profile*> profiles(profile_manager->GetLoadedProfiles());
for (size_t i = 0; i < profiles.size(); ++i) {
DownloadService* download_service =
DownloadServiceFactory::GetForBrowserContext(profiles[i]);
DownloadCoreService* download_core_service =
DownloadCoreServiceFactory::GetForBrowserContext(profiles[i]);
DownloadManager* download_manager =
(download_service->HasCreatedDownloadManager() ?
BrowserContext::GetDownloadManager(profiles[i]) : NULL);
(download_core_service->HasCreatedDownloadManager()
? BrowserContext::GetDownloadManager(profiles[i])
: NULL);
if (download_manager &&
download_manager->NonMaliciousInProgressCount() > 0) {
int downloadCount = download_manager->NonMaliciousInProgressCount();
......
......@@ -27,10 +27,10 @@
#include "chrome/browser/chrome_content_browser_client.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/download/download_core_service.h"
#include "chrome/browser/download/download_core_service_factory.h"
#include "chrome/browser/download/download_history.h"
#include "chrome/browser/download/download_prefs.h"
#include "chrome/browser/download/download_service.h"
#include "chrome/browser/download/download_service_factory.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/pdf/pdf_extension_test_util.h"
#include "chrome/browser/prerender/prerender_link_manager.h"
......@@ -2643,8 +2643,8 @@ std::unique_ptr<net::test_server::HttpResponse> HandleDownloadRequestWithCookie(
class DownloadHistoryWaiter : public DownloadHistory::Observer {
public:
explicit DownloadHistoryWaiter(content::BrowserContext* browser_context) {
DownloadService* service =
DownloadServiceFactory::GetForBrowserContext(browser_context);
DownloadCoreService* service =
DownloadCoreServiceFactory::GetForBrowserContext(browser_context);
download_history_ = service->GetDownloadHistory();
download_history_->AddObserver(this);
}
......
......@@ -10,9 +10,9 @@
#include "base/guid.h"
#include "base/run_loop.h"
#include "base/strings/string_util.h"
#include "chrome/browser/download/download_core_service.h"
#include "chrome/browser/download/download_core_service_factory.h"
#include "chrome/browser/download/download_history.h"
#include "chrome/browser/download/download_service.h"
#include "chrome/browser/download/download_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/in_process_browser_test.h"
......@@ -38,8 +38,8 @@ class DownloadsCounterTest : public InProcessBrowserTest,
manager_ =
content::BrowserContext::GetDownloadManager(browser()->profile());
history_ =
DownloadServiceFactory::GetForBrowserContext(browser()->profile())->
GetDownloadHistory();
DownloadCoreServiceFactory::GetForBrowserContext(browser()->profile())
->GetDownloadHistory();
history_->AddObserver(this);
otr_manager_ =
......
......@@ -18,9 +18,9 @@
#include "chrome/browser/chromeos/drive/drive_integration_service.h"
#include "chrome/browser/chromeos/drive/file_system_util.h"
#include "chrome/browser/chromeos/drive/write_on_cache_file.h"
#include "chrome/browser/download/download_core_service.h"
#include "chrome/browser/download/download_core_service_factory.h"
#include "chrome/browser/download/download_history.h"
#include "chrome/browser/download/download_service.h"
#include "chrome/browser/download/download_service_factory.h"
#include "components/drive/chromeos/file_system_interface.h"
#include "components/drive/drive.pb.h"
#include "content/public/browser/browser_thread.h"
......@@ -117,10 +117,11 @@ bool IsPersistedDriveDownload(const base::FilePath& drive_tmp_download_path,
if (!drive_tmp_download_path.IsParent(download->GetTargetFilePath()))
return false;
DownloadService* download_service =
DownloadServiceFactory::GetForBrowserContext(
DownloadCoreService* download_core_service =
DownloadCoreServiceFactory::GetForBrowserContext(
download->GetBrowserContext());
DownloadHistory* download_history = download_service->GetDownloadHistory();
DownloadHistory* download_history =
download_core_service->GetDownloadHistory();
return download_history && download_history->WasRestoredFromHistory(download);
}
......
......@@ -19,9 +19,8 @@
#include "chrome/browser/chromeos/drive/file_system_util.h"
#include "chrome/browser/chromeos/file_manager/path_util.h"
#include "chrome/browser/chromeos/profiles/profile_util.h"
#include "chrome/browser/download/download_core_service_factory.h"
#include "chrome/browser/download/download_prefs.h"
#include "chrome/browser/download/download_service.h"
#include "chrome/browser/download/download_service_factory.h"
#include "chrome/browser/drive/drive_notification_manager_factory.h"
#include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h"
......@@ -639,7 +638,7 @@ DriveIntegrationServiceFactory::DriveIntegrationServiceFactory()
BrowserContextDependencyManager::GetInstance()) {
DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance());
DependsOn(DriveNotificationManagerFactory::GetInstance());
DependsOn(DownloadServiceFactory::GetInstance());
DependsOn(DownloadCoreServiceFactory::GetInstance());
}
DriveIntegrationServiceFactory::~DriveIntegrationServiceFactory() {
......
......@@ -22,14 +22,14 @@
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/download/download_completion_blocker.h"
#include "chrome/browser/download/download_core_service.h"
#include "chrome/browser/download/download_core_service_factory.h"
#include "chrome/browser/download/download_crx_util.h"
#include "chrome/browser/download/download_file_picker.h"
#include "chrome/browser/download/download_history.h"
#include "chrome/browser/download/download_item_model.h"
#include "chrome/browser/download/download_path_reservation_tracker.h"
#include "chrome/browser/download/download_prefs.h"
#include "chrome/browser/download/download_service.h"
#include "chrome/browser/download/download_service_factory.h"
#include "chrome/browser/download/download_stats.h"
#include "chrome/browser/download/download_target_determiner.h"
#include "chrome/browser/download/save_package_file_picker.h"
......@@ -584,7 +584,7 @@ void ChromeDownloadManagerDelegate::NotifyExtensions(
DCHECK_CURRENTLY_ON(BrowserThread::UI);
#if BUILDFLAG(ENABLE_EXTENSIONS)
extensions::ExtensionDownloadsEventRouter* router =
DownloadServiceFactory::GetForBrowserContext(profile_)
DownloadCoreServiceFactory::GetForBrowserContext(profile_)
->GetExtensionEventRouter();
if (router) {
base::Closure original_path_callback =
......
......@@ -38,13 +38,13 @@
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/download/chrome_download_manager_delegate.h"
#include "chrome/browser/download/download_commands.h"
#include "chrome/browser/download/download_core_service.h"
#include "chrome/browser/download/download_core_service_factory.h"
#include "chrome/browser/download/download_crx_util.h"
#include "chrome/browser/download/download_history.h"
#include "chrome/browser/download/download_item_model.h"
#include "chrome/browser/download/download_prefs.h"
#include "chrome/browser/download/download_request_limiter.h"
#include "chrome/browser/download/download_service.h"
#include "chrome/browser/download/download_service_factory.h"
#include "chrome/browser/download/download_shelf.h"
#include "chrome/browser/download/download_target_determiner.h"
#include "chrome/browser/download/download_test_file_activity_observer.h"
......@@ -350,13 +350,14 @@ class HistoryObserver : public DownloadHistory::Observer {
: profile_(profile),
waiting_(false),
seen_stored_(false) {
DownloadServiceFactory::GetForBrowserContext(profile_)->
GetDownloadHistory()->AddObserver(this);
DownloadCoreServiceFactory::GetForBrowserContext(profile_)
->GetDownloadHistory()
->AddObserver(this);
}
~HistoryObserver() override {
DownloadService* service = DownloadServiceFactory::GetForBrowserContext(
profile_);
DownloadCoreService* service =
DownloadCoreServiceFactory::GetForBrowserContext(profile_);
if (service && service->GetDownloadHistory())
service->GetDownloadHistory()->RemoveObserver(this);
}
......@@ -376,8 +377,9 @@ class HistoryObserver : public DownloadHistory::Observer {
}
void OnDownloadHistoryDestroyed() override {
DownloadServiceFactory::GetForBrowserContext(profile_)->
GetDownloadHistory()->RemoveObserver(this);
DownloadCoreServiceFactory::GetForBrowserContext(profile_)
->GetDownloadHistory()
->RemoveObserver(this);
}
void WaitForStored() {
......
......@@ -2,46 +2,44 @@
// 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.h"
#include "chrome/browser/download/download_core_service.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/download/download_service_factory.h"
#include "chrome/browser/download/download_core_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
DownloadService::DownloadService() {
}
DownloadCoreService::DownloadCoreService() = default;
DownloadService::~DownloadService() {}
DownloadCoreService::~DownloadCoreService() = default;
// static
int DownloadService::NonMaliciousDownloadCountAllProfiles() {
int DownloadCoreService::NonMaliciousDownloadCountAllProfiles() {
std::vector<Profile*> profiles(
g_browser_process->profile_manager()->GetLoadedProfiles());
int count = 0;
for (std::vector<Profile*>::iterator it = profiles.begin();
it < profiles.end(); ++it) {
count += DownloadServiceFactory::GetForBrowserContext(*it)->
NonMaliciousDownloadCount();
count += DownloadCoreServiceFactory::GetForBrowserContext(*it)
->NonMaliciousDownloadCount();
if ((*it)->HasOffTheRecordProfile())
count += DownloadServiceFactory::GetForBrowserContext(
(*it)->GetOffTheRecordProfile())->NonMaliciousDownloadCount();
count += DownloadCoreServiceFactory::GetForBrowserContext(
(*it)->GetOffTheRecordProfile())
->NonMaliciousDownloadCount();
}
return count;
}
// static
void DownloadService::CancelAllDownloads() {
void DownloadCoreService::CancelAllDownloads() {
std::vector<Profile*> profiles(
g_browser_process->profile_manager()->GetLoadedProfiles());
for (std::vector<Profile*>::iterator it = profiles.begin();
it < profiles.end();
++it) {
DownloadService* service =
DownloadServiceFactory::GetForBrowserContext(*it);
it < profiles.end(); ++it) {
DownloadCoreService* service =
DownloadCoreServiceFactory::GetForBrowserContext(*it);
service->CancelDownloads();
}
}
......@@ -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_H_
#define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_
#ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_CORE_SERVICE_H_
#define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_CORE_SERVICE_H_
#include <memory>
......@@ -23,12 +23,12 @@ namespace extensions {
class ExtensionDownloadsEventRouter;
}
// Abstract base class for the download service; see DownloadServiceImpl for
// implementation.
class DownloadService : public KeyedService {
// Abstract base class for the download core service; see
// DownloadCoreServiceImpl for implementation.
class DownloadCoreService : public KeyedService {
public:
DownloadService();
~DownloadService() override;
DownloadCoreService();
~DownloadCoreService() override;
// Get the download manager delegate, creating it if it doesn't already exist.
virtual ChromeDownloadManagerDelegate* GetDownloadManagerDelegate() = 0;
......@@ -70,7 +70,7 @@ class DownloadService : public KeyedService {
virtual bool IsShelfEnabled() = 0;
private:
DISALLOW_COPY_AND_ASSIGN(DownloadService);
DISALLOW_COPY_AND_ASSIGN(DownloadCoreService);
};
#endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_
#endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_CORE_SERVICE_H_
......@@ -2,40 +2,39 @@
// 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/download_core_service_factory.h"
#include "chrome/browser/download/download_service_impl.h"
#include "chrome/browser/download/download_core_service_impl.h"
#include "chrome/browser/history/history_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"
// static
DownloadService* DownloadServiceFactory::GetForBrowserContext(
DownloadCoreService* DownloadCoreServiceFactory::GetForBrowserContext(
content::BrowserContext* context) {
return static_cast<DownloadService*>(
return static_cast<DownloadCoreService*>(
GetInstance()->GetServiceForBrowserContext(context, true));
}
// static
DownloadServiceFactory* DownloadServiceFactory::GetInstance() {
return base::Singleton<DownloadServiceFactory>::get();
DownloadCoreServiceFactory* DownloadCoreServiceFactory::GetInstance() {
return base::Singleton<DownloadCoreServiceFactory>::get();
}
DownloadServiceFactory::DownloadServiceFactory()
DownloadCoreServiceFactory::DownloadCoreServiceFactory()
: BrowserContextKeyedServiceFactory(
"DownloadService",
BrowserContextDependencyManager::GetInstance()) {
"DownloadCoreService",
BrowserContextDependencyManager::GetInstance()) {
DependsOn(HistoryServiceFactory::GetInstance());
}
DownloadServiceFactory::~DownloadServiceFactory() {
}
DownloadCoreServiceFactory::~DownloadCoreServiceFactory() {}
KeyedService* DownloadServiceFactory::BuildServiceInstanceFor(
KeyedService* DownloadCoreServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* profile) const {
DownloadService* service =
new DownloadServiceImpl(static_cast<Profile*>(profile));
DownloadCoreService* service =
new DownloadCoreServiceImpl(static_cast<Profile*>(profile));
// No need for initialization; initialization can be done on first
// use of service.
......@@ -43,7 +42,7 @@ KeyedService* DownloadServiceFactory::BuildServiceInstanceFor(
return service;
}
content::BrowserContext* DownloadServiceFactory::GetBrowserContextToUse(
content::BrowserContext* DownloadCoreServiceFactory::GetBrowserContextToUse(
content::BrowserContext* context) const {
return chrome::GetBrowserContextOwnInstanceInIncognito(context);
}
......@@ -2,25 +2,25 @@
// 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_DOWNLOAD_CORE_SERVICE_FACTORY_H_
#define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_CORE_SERVICE_FACTORY_H_
#include "base/compiler_specific.h"
#include "base/memory/singleton.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
class DownloadService;
class DownloadCoreService;
// Singleton that owns all DownloadServices and associates them with
// Singleton that owns all DownloadCoreServices and associates them with
// Profiles. Listens for the Profile's destruction notification and cleans up
// the associated DownloadService.
class DownloadServiceFactory : public BrowserContextKeyedServiceFactory {
// the associated DownloadCoreService.
class DownloadCoreServiceFactory : public BrowserContextKeyedServiceFactory {
public:
// Returns the DownloadService for |context|, creating if not yet created.
static DownloadService* GetForBrowserContext(
// Returns the DownloadCoreService for |context|, creating if not yet created.
static DownloadCoreService* GetForBrowserContext(
content::BrowserContext* context);
static DownloadServiceFactory* GetInstance();
static DownloadCoreServiceFactory* GetInstance();
protected:
// BrowserContextKeyedServiceFactory:
......@@ -30,10 +30,10 @@ class DownloadServiceFactory : public BrowserContextKeyedServiceFactory {
content::BrowserContext* context) const override;
private:
friend struct base::DefaultSingletonTraits<DownloadServiceFactory>;
friend struct base::DefaultSingletonTraits<DownloadCoreServiceFactory>;
DownloadServiceFactory();
~DownloadServiceFactory() override;
DownloadCoreServiceFactory();
~DownloadCoreServiceFactory() override;
};
#endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_FACTORY_H_
#endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_CORE_SERVICE_FACTORY_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 "chrome/browser/download/download_service_impl.h"
#include "chrome/browser/download/download_core_service_impl.h"
#include "base/callback.h"
#include "build/build_config.h"
......@@ -25,15 +25,13 @@ using content::BrowserContext;
using content::DownloadManager;
using content::DownloadManagerDelegate;
DownloadServiceImpl::DownloadServiceImpl(Profile* profile)
: download_manager_created_(false), profile_(profile) {
}
DownloadCoreServiceImpl::DownloadCoreServiceImpl(Profile* profile)
: download_manager_created_(false), profile_(profile) {}
DownloadServiceImpl::~DownloadServiceImpl() {
}
DownloadCoreServiceImpl::~DownloadCoreServiceImpl() {}
ChromeDownloadManagerDelegate*
DownloadServiceImpl::GetDownloadManagerDelegate() {
DownloadCoreServiceImpl::GetDownloadManagerDelegate() {
DownloadManager* manager = BrowserContext::GetDownloadManager(profile_);
// If we've already created the delegate, just return it.
if (download_manager_created_) {
......@@ -77,7 +75,7 @@ DownloadServiceImpl::GetDownloadManagerDelegate() {
return manager_delegate_.get();
}
DownloadHistory* DownloadServiceImpl::GetDownloadHistory() {
DownloadHistory* DownloadCoreServiceImpl::GetDownloadHistory() {
if (!download_manager_created_) {
GetDownloadManagerDelegate();
}
......@@ -87,23 +85,23 @@ DownloadHistory* DownloadServiceImpl::GetDownloadHistory() {
#if BUILDFLAG(ENABLE_EXTENSIONS)
extensions::ExtensionDownloadsEventRouter*
DownloadServiceImpl::GetExtensionEventRouter() {
DownloadCoreServiceImpl::GetExtensionEventRouter() {
return extension_event_router_.get();
}
#endif
bool DownloadServiceImpl::HasCreatedDownloadManager() {
bool DownloadCoreServiceImpl::HasCreatedDownloadManager() {
return download_manager_created_;
}
int DownloadServiceImpl::NonMaliciousDownloadCount() const {
int DownloadCoreServiceImpl::NonMaliciousDownloadCount() const {
if (!download_manager_created_)
return 0;
return BrowserContext::GetDownloadManager(profile_)
->NonMaliciousInProgressCount();
}
void DownloadServiceImpl::CancelDownloads() {
void DownloadCoreServiceImpl::CancelDownloads() {
if (!download_manager_created_)
return;
......@@ -118,7 +116,7 @@ void DownloadServiceImpl::CancelDownloads() {
}
}
void DownloadServiceImpl::SetDownloadManagerDelegateForTesting(
void DownloadCoreServiceImpl::SetDownloadManagerDelegateForTesting(
std::unique_ptr<ChromeDownloadManagerDelegate> new_delegate) {
manager_delegate_.swap(new_delegate);
DownloadManager* dm = BrowserContext::GetDownloadManager(profile_);
......@@ -128,7 +126,7 @@ void DownloadServiceImpl::SetDownloadManagerDelegateForTesting(
new_delegate->Shutdown();
}
bool DownloadServiceImpl::IsShelfEnabled() {
bool DownloadCoreServiceImpl::IsShelfEnabled() {
#if defined(OS_ANDROID)
return true;
#else
......@@ -136,7 +134,7 @@ bool DownloadServiceImpl::IsShelfEnabled() {
#endif
}
void DownloadServiceImpl::Shutdown() {
void DownloadCoreServiceImpl::Shutdown() {
if (download_manager_created_) {
// Normally the DownloadManager would be shutdown later, after the Profile
// goes away and BrowserContext's destructor runs. But that would be too
......
......@@ -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 CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_IMPL_H_
#define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_IMPL_H_
#ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_CORE_SERVICE_IMPL_H_
#define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_CORE_SERVICE_IMPL_H_
#include <memory>
#include "base/callback_forward.h"
#include "base/macros.h"
#include "chrome/browser/download/download_service.h"
#include "chrome/browser/download/download_core_service.h"
#include "components/keyed_service/core/keyed_service.h"
#include "extensions/features/features.h"
......@@ -28,12 +28,12 @@ class ExtensionDownloadsEventRouter;
}
// Owning class for ChromeDownloadManagerDelegate.
class DownloadServiceImpl : public DownloadService {
class DownloadCoreServiceImpl : public DownloadCoreService {
public:
explicit DownloadServiceImpl(Profile* profile);
~DownloadServiceImpl() override;
explicit DownloadCoreServiceImpl(Profile* profile);
~DownloadCoreServiceImpl() override;
// DownloadService
// DownloadCoreService
ChromeDownloadManagerDelegate* GetDownloadManagerDelegate() override;
DownloadHistory* GetDownloadHistory() override;
#if BUILDFLAG(ENABLE_EXTENSIONS)
......@@ -82,7 +82,7 @@ class DownloadServiceImpl : public DownloadService {
extension_event_router_;
#endif
DISALLOW_COPY_AND_ASSIGN(DownloadServiceImpl);
DISALLOW_COPY_AND_ASSIGN(DownloadCoreServiceImpl);
};
#endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_IMPL_H_
#endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_CORE_SERVICE_IMPL_H_
......@@ -14,10 +14,10 @@
#include "base/supports_user_data.h"
#include "base/time/time.h"
#include "chrome/browser/download/chrome_download_manager_delegate.h"
#include "chrome/browser/download/download_core_service.h"
#include "chrome/browser/download/download_core_service_factory.h"
#include "chrome/browser/download/download_crx_util.h"
#include "chrome/browser/download/download_history.h"
#include "chrome/browser/download/download_service.h"
#include "chrome/browser/download/download_service_factory.h"
#include "chrome/browser/download/download_stats.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/safe_browsing/download_feedback_service.h"
......@@ -615,10 +615,11 @@ void DownloadItemModel::SetShouldShowInShelf(bool should_show) {
bool DownloadItemModel::ShouldNotifyUI() const {
Profile* profile =
Profile::FromBrowserContext(download_->GetBrowserContext());
DownloadService* download_service =
DownloadServiceFactory::GetForBrowserContext(profile);
DownloadCoreService* download_core_service =
DownloadCoreServiceFactory::GetForBrowserContext(profile);
DownloadHistory* download_history =
(download_service ? download_service->GetDownloadHistory() : NULL);
(download_core_service ? download_core_service->GetDownloadHistory()
: nullptr);
// The browser is only interested in new downloads. Ones that were restored
// from history are not displayed on the shelf. The downloads page
......@@ -754,14 +755,14 @@ base::string16 DownloadItemModel::GetInProgressStatusString() const {
}
void DownloadItemModel::OpenUsingPlatformHandler() {
DownloadService* download_service =
DownloadServiceFactory::GetForBrowserContext(
DownloadCoreService* download_core_service =
DownloadCoreServiceFactory::GetForBrowserContext(
download_->GetBrowserContext());
if (!download_service)
if (!download_core_service)
return;
ChromeDownloadManagerDelegate* delegate =
download_service->GetDownloadManagerDelegate();
download_core_service->GetDownloadManagerDelegate();
if (!delegate)
return;
delegate->OpenDownloadUsingPlatformHandler(download_);
......
......@@ -22,8 +22,6 @@
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "chrome/browser/download/chrome_download_manager_delegate.h"
#include "chrome/browser/download/download_service.h"
#include "chrome/browser/download/download_service_factory.h"
#include "chrome/browser/download/download_target_determiner.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
......
......@@ -16,9 +16,9 @@
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
#include "cc/paint/paint_flags.h"
#include "chrome/browser/download/download_core_service.h"
#include "chrome/browser/download/download_core_service_factory.h"
#include "chrome/browser/download/download_item_model.h"
#include "chrome/browser/download/download_service.h"
#include "chrome/browser/download/download_service_factory.h"
#include "chrome/browser/download/download_started_animation.h"
#include "chrome/browser/platform_util.h"
#include "chrome/browser/profiles/profile.h"
......@@ -197,8 +197,9 @@ void DownloadShelf::ShowDownload(DownloadItem* download) {
if (download->GetState() == DownloadItem::COMPLETE &&
DownloadItemModel(download).ShouldRemoveFromShelfWhenComplete())
return;
if (!DownloadServiceFactory::GetForBrowserContext(
download->GetBrowserContext())->IsShelfEnabled())
if (!DownloadCoreServiceFactory::GetForBrowserContext(
download->GetBrowserContext())
->IsShelfEnabled())
return;
if (is_hidden_)
......
......@@ -7,9 +7,9 @@
#include "base/compiler_specific.h"
#include "base/run_loop.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/download/download_core_service_factory.h"
#include "chrome/browser/download/download_core_service_impl.h"
#include "chrome/browser/download/download_item_model.h"
#include "chrome/browser/download/download_service_factory.h"
#include "chrome/browser/download/download_service_impl.h"
#include "chrome/browser/download/test_download_shelf.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/browser/notification_service.h"
......
......@@ -11,8 +11,8 @@
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/download/chrome_download_manager_delegate.h"
#include "chrome/browser/download/download_service.h"
#include "chrome/browser/download/download_service_factory.h"
#include "chrome/browser/download/download_core_service.h"
#include "chrome/browser/download/download_core_service_factory.h"
#include "chrome/browser/profiles/profile.h"
namespace content {
......@@ -78,7 +78,7 @@ DownloadTestFileActivityObserver::DownloadTestFileActivityObserver(
std::unique_ptr<MockDownloadManagerDelegate> mock_delegate(
new MockDownloadManagerDelegate(profile));
test_delegate_ = mock_delegate->GetWeakPtr();
DownloadServiceFactory::GetForBrowserContext(profile)