Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Unified Diff: chrome/browser/download/download_service.cc

Issue 10704052: Download filename determination refactor (3/3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/download/download_service.cc
diff --git a/chrome/browser/download/download_service.cc b/chrome/browser/download/download_service.cc
index a9d401756ef0c1a6a6b3feb14428ca55e4b6f7da..378b92ae3d0d3830ad9e6e7f8cfcdda0186374c0 100644
--- a/chrome/browser/download/download_service.cc
+++ b/chrome/browser/download/download_service.cc
@@ -35,7 +35,7 @@ void DownloadService::OnManagerCreated(
}
}
-DownloadManagerDelegate* DownloadService::GetDownloadManagerDelegate() {
+ChromeDownloadManagerDelegate* DownloadService::GetDownloadManagerDelegate() {
DCHECK(!download_manager_created_);
download_manager_created_ = true;
@@ -91,11 +91,16 @@ int DownloadService::DownloadCountAllProfiles() {
void DownloadService::SetDownloadManagerDelegateForTesting(
ChromeDownloadManagerDelegate* new_delegate) {
+ // Set the new delegate first so that if BrowserContext::GetDownloadManager()
+ // causes a new download manager to be created, we won't create a redundant
+ // ChromeDownloadManagerDelegate().
+ manager_delegate_ = new_delegate;
// Guarantee everything is properly initialized.
DownloadManager* dm = BrowserContext::GetDownloadManager(profile_);
- dm->SetDelegate(new_delegate);
- new_delegate->SetDownloadManager(dm);
- manager_delegate_ = new_delegate;
+ if (dm->GetDelegate() != new_delegate) {
+ dm->SetDelegate(new_delegate);
+ new_delegate->SetDownloadManager(dm);
+ }
}
void DownloadService::Shutdown() {
@@ -107,5 +112,5 @@ void DownloadService::Shutdown() {
// manually earlier. See http://crbug.com/131692
BrowserContext::GetDownloadManager(profile_)->Shutdown();
}
- manager_delegate_.release();
+ manager_delegate_ = NULL;
asanka 2012/07/23 19:47:11 Will wait for http://codereview.chromium.org/10808
}

Powered by Google App Engine
This is Rietveld 408576698