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 {
download_observer_ = std::make_unique<WaitableDownloadLoggerObserver>();
download_service_ = DownloadServiceFactory::GetForBrowserContext(profile);
download_service_ =
DownloadServiceFactory::GetForKey(profile->GetProfileKey());
download_service_->GetLogger()->AddObserver(download_observer_.get());
// Register our observer for the offline items collection.
......
......@@ -71,8 +71,8 @@ download::DownloadService* BackgroundFetchDelegateImpl::GetDownloadService() {
if (download_service_)
return download_service_;
download_service_ =
DownloadServiceFactory::GetInstance()->GetForBrowserContext(profile_);
download_service_ = DownloadServiceFactory::GetInstance()->GetForKey(
profile_->GetProfileKey());
return download_service_;
}
......
......@@ -34,8 +34,8 @@ void PluginVmImageDownloadClient::OnServiceInitialized(
for (const auto& download : downloads) {
VLOG(1) << "Download tracked by DownloadService: " << download.guid;
old_downloads_.insert(download.guid);
DownloadServiceFactory::GetForBrowserContext(profile_)->CancelDownload(
download.guid);
DownloadServiceFactory::GetForKey(profile_->GetProfileKey())
->CancelDownload(download.guid);
}
}
......@@ -51,8 +51,8 @@ void PluginVmImageDownloadClient::OnDownloadStarted(
// We do not want downloads that are tracked by download service from its
// initialization to proceed.
if (old_downloads_.find(guid) != old_downloads_.end()) {
DownloadServiceFactory::GetForBrowserContext(profile_)->CancelDownload(
guid);
DownloadServiceFactory::GetForKey(profile_->GetProfileKey())
->CancelDownload(guid);
return;
}
......
......@@ -413,7 +413,8 @@ std::string PluginVmImageManager::GetCurrentDownloadGuidForTesting() {
PluginVmImageManager::PluginVmImageManager(Profile* profile)
: profile_(profile),
download_service_(DownloadServiceFactory::GetForBrowserContext(profile)),
download_service_(
DownloadServiceFactory::GetForKey(profile->GetProfileKey())),
weak_ptr_factory_(this) {}
GURL PluginVmImageManager::GetPluginVmImageDownloadUrl() {
......
......@@ -109,13 +109,6 @@ download::DownloadService* DownloadServiceFactory::GetForKey(
GetInstance()->GetServiceForKey(key, true));
}
// static
download::DownloadService* DownloadServiceFactory::GetForBrowserContext(
content::BrowserContext* context) {
Profile* profile = Profile::FromBrowserContext(context);
return GetForKey(profile->GetProfileKey());
}
DownloadServiceFactory::DownloadServiceFactory()
: SimpleKeyedServiceFactory("download::DownloadService",
SimpleDependencyManager::GetInstance()) {
......
......@@ -17,10 +17,6 @@ template <typename T>
struct DefaultSingletonTraits;
} // namespace base
namespace content {
class BrowserContext;
} // namespace content
namespace download {
class DownloadService;
} // namespace download
......@@ -35,12 +31,6 @@ class DownloadServiceFactory : public SimpleKeyedServiceFactory {
// Returns the DownloadService associated with |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:
friend struct base::DefaultSingletonTraits<DownloadServiceFactory>;
......
......@@ -42,7 +42,8 @@ void DownloadInternalsUIMessageHandler::RegisterMessages() {
weak_ptr_factory_.GetWeakPtr()));
Profile* profile = Profile::FromWebUI(web_ui());
download_service_ = DownloadServiceFactory::GetForBrowserContext(profile);
download_service_ =
DownloadServiceFactory::GetForKey(profile->GetProfileKey());
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