Commit 6b8b3c76 authored by Henrique Nakashima's avatar Henrique Nakashima Committed by Commit Bot

Remove helper GetForBrowserContext() from DownloadServiceFactory.

DownloadServiceFactory is now a SimpleKeyedServiceFactory, so its
callers should provide a SimpleFactoryKey to access it.

The helper method was added as a transitional state, but is not
necessary in the long run.

Bug: 943724
Change-Id: I74ea64e6f2bb2c7f15c0cc1ea5609340bed7925c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1606247
Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Reviewed-by: default avatarMin Qin <qinmin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#665307}
parent ce55a930
...@@ -242,7 +242,8 @@ class BackgroundFetchBrowserTest : public InProcessBrowserTest { ...@@ -242,7 +242,8 @@ class BackgroundFetchBrowserTest : public InProcessBrowserTest {
download_observer_ = std::make_unique<WaitableDownloadLoggerObserver>(); download_observer_ = std::make_unique<WaitableDownloadLoggerObserver>();
download_service_ = DownloadServiceFactory::GetForBrowserContext(profile); download_service_ =
DownloadServiceFactory::GetForKey(profile->GetProfileKey());
download_service_->GetLogger()->AddObserver(download_observer_.get()); download_service_->GetLogger()->AddObserver(download_observer_.get());
// Register our observer for the offline items collection. // Register our observer for the offline items collection.
......
...@@ -71,8 +71,8 @@ download::DownloadService* BackgroundFetchDelegateImpl::GetDownloadService() { ...@@ -71,8 +71,8 @@ download::DownloadService* BackgroundFetchDelegateImpl::GetDownloadService() {
if (download_service_) if (download_service_)
return download_service_; return download_service_;
download_service_ = download_service_ = DownloadServiceFactory::GetInstance()->GetForKey(
DownloadServiceFactory::GetInstance()->GetForBrowserContext(profile_); profile_->GetProfileKey());
return download_service_; return download_service_;
} }
......
...@@ -34,8 +34,8 @@ void PluginVmImageDownloadClient::OnServiceInitialized( ...@@ -34,8 +34,8 @@ void PluginVmImageDownloadClient::OnServiceInitialized(
for (const auto& download : downloads) { for (const auto& download : downloads) {
VLOG(1) << "Download tracked by DownloadService: " << download.guid; VLOG(1) << "Download tracked by DownloadService: " << download.guid;
old_downloads_.insert(download.guid); old_downloads_.insert(download.guid);
DownloadServiceFactory::GetForBrowserContext(profile_)->CancelDownload( DownloadServiceFactory::GetForKey(profile_->GetProfileKey())
download.guid); ->CancelDownload(download.guid);
} }
} }
...@@ -51,8 +51,8 @@ void PluginVmImageDownloadClient::OnDownloadStarted( ...@@ -51,8 +51,8 @@ void PluginVmImageDownloadClient::OnDownloadStarted(
// We do not want downloads that are tracked by download service from its // We do not want downloads that are tracked by download service from its
// initialization to proceed. // initialization to proceed.
if (old_downloads_.find(guid) != old_downloads_.end()) { if (old_downloads_.find(guid) != old_downloads_.end()) {
DownloadServiceFactory::GetForBrowserContext(profile_)->CancelDownload( DownloadServiceFactory::GetForKey(profile_->GetProfileKey())
guid); ->CancelDownload(guid);
return; return;
} }
......
...@@ -413,7 +413,8 @@ std::string PluginVmImageManager::GetCurrentDownloadGuidForTesting() { ...@@ -413,7 +413,8 @@ std::string PluginVmImageManager::GetCurrentDownloadGuidForTesting() {
PluginVmImageManager::PluginVmImageManager(Profile* profile) PluginVmImageManager::PluginVmImageManager(Profile* profile)
: profile_(profile), : profile_(profile),
download_service_(DownloadServiceFactory::GetForBrowserContext(profile)), download_service_(
DownloadServiceFactory::GetForKey(profile->GetProfileKey())),
weak_ptr_factory_(this) {} weak_ptr_factory_(this) {}
GURL PluginVmImageManager::GetPluginVmImageDownloadUrl() { GURL PluginVmImageManager::GetPluginVmImageDownloadUrl() {
......
...@@ -109,13 +109,6 @@ download::DownloadService* DownloadServiceFactory::GetForKey( ...@@ -109,13 +109,6 @@ download::DownloadService* DownloadServiceFactory::GetForKey(
GetInstance()->GetServiceForKey(key, true)); GetInstance()->GetServiceForKey(key, true));
} }
// static
download::DownloadService* DownloadServiceFactory::GetForBrowserContext(
content::BrowserContext* context) {
Profile* profile = Profile::FromBrowserContext(context);
return GetForKey(profile->GetProfileKey());
}
DownloadServiceFactory::DownloadServiceFactory() DownloadServiceFactory::DownloadServiceFactory()
: SimpleKeyedServiceFactory("download::DownloadService", : SimpleKeyedServiceFactory("download::DownloadService",
SimpleDependencyManager::GetInstance()) { SimpleDependencyManager::GetInstance()) {
......
...@@ -17,10 +17,6 @@ template <typename T> ...@@ -17,10 +17,6 @@ template <typename T>
struct DefaultSingletonTraits; struct DefaultSingletonTraits;
} // namespace base } // namespace base
namespace content {
class BrowserContext;
} // namespace content
namespace download { namespace download {
class DownloadService; class DownloadService;
} // namespace download } // namespace download
...@@ -35,12 +31,6 @@ class DownloadServiceFactory : public SimpleKeyedServiceFactory { ...@@ -35,12 +31,6 @@ class DownloadServiceFactory : public SimpleKeyedServiceFactory {
// Returns the DownloadService associated with |key|. // Returns the DownloadService associated with |key|.
static download::DownloadService* GetForKey(SimpleFactoryKey* key); static download::DownloadService* GetForKey(SimpleFactoryKey* key);
// Helper method that calls GetForKey().
// Returns the DownloadService associated with the key associated with
// |context|.
static download::DownloadService* GetForBrowserContext(
content::BrowserContext* context);
private: private:
friend struct base::DefaultSingletonTraits<DownloadServiceFactory>; friend struct base::DefaultSingletonTraits<DownloadServiceFactory>;
......
...@@ -42,7 +42,8 @@ void DownloadInternalsUIMessageHandler::RegisterMessages() { ...@@ -42,7 +42,8 @@ void DownloadInternalsUIMessageHandler::RegisterMessages() {
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
Profile* profile = Profile::FromWebUI(web_ui()); Profile* profile = Profile::FromWebUI(web_ui());
download_service_ = DownloadServiceFactory::GetForBrowserContext(profile); download_service_ =
DownloadServiceFactory::GetForKey(profile->GetProfileKey());
download_service_->GetLogger()->AddObserver(this); download_service_->GetLogger()->AddObserver(this);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment