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

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

Issue 10535026: Move creation and ownership of DownloadManager from the embedder to content. This matches all the o… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix cros compile Created 8 years, 6 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/chrome_download_manager_delegate.cc
===================================================================
--- chrome/browser/download/chrome_download_manager_delegate.cc (revision 140592)
+++ chrome/browser/download/chrome_download_manager_delegate.cc (working copy)
@@ -57,6 +57,7 @@
#include "chrome/browser/download/save_package_file_picker_chromeos.h"
#endif
+using content::BrowserContext;
using content::BrowserThread;
using content::DownloadId;
using content::DownloadItem;
@@ -109,7 +110,13 @@
ChromeDownloadManagerDelegate::~ChromeDownloadManagerDelegate() {
}
+void ChromeDownloadManagerDelegate::ProfileShutdown() {
+ download_history_.reset();
+ download_prefs_.reset();
+}
+
void ChromeDownloadManagerDelegate::SetDownloadManager(DownloadManager* dm) {
+ AddRef(); // Will be balanced in Shutdown().
download_manager_ = dm;
download_history_.reset(new DownloadHistory(profile_));
download_history_->Load(
@@ -118,16 +125,15 @@
}
void ChromeDownloadManagerDelegate::Shutdown() {
- download_history_.reset();
- download_prefs_.reset();
+ Release(); // Balance the AddRef in SetDownloadManager.
}
DownloadId ChromeDownloadManagerDelegate::GetNextId() {
if (!profile_->IsOffTheRecord())
return DownloadId(this, next_download_id_++);
- return profile_->GetOriginalProfile()->GetDownloadManager()->delegate()->
- GetNextId();
+ return BrowserContext::GetDownloadManager(profile_->GetOriginalProfile())->
+ delegate()->GetNextId();
}
bool ChromeDownloadManagerDelegate::ShouldStartDownload(int32 download_id) {

Powered by Google App Engine
This is Rietveld 408576698