diff options
author | asanka@chromium.org <asanka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-13 20:10:41 +0000 |
---|---|---|
committer | asanka@chromium.org <asanka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-13 20:10:41 +0000 |
commit | 861b4d0a0b0cf9e5224d004eb99ce768221000ed (patch) | |
tree | e9c9b7e92a8ca67ed805e74cf6fd43a9619f9242 /chrome/browser/download/chrome_download_manager_delegate.cc | |
parent | 163a0dd59f459e0c25067b14e8e0620bb18039f8 (diff) | |
download | chromium_src-861b4d0a0b0cf9e5224d004eb99ce768221000ed.zip chromium_src-861b4d0a0b0cf9e5224d004eb99ce768221000ed.tar.gz chromium_src-861b4d0a0b0cf9e5224d004eb99ce768221000ed.tar.bz2 |
[Downloads] Make ChromeDownloadManagerDelegate owned by DownloadService.
Currently ChromeDownloadManagerDelegate is reference counted. Since it
also posts long running tasks, this causes it to outlive the associated
profile on occasion. Since there are multiple references to
Profile/BrowserContext owned objects from within CDMD, this can
introduce subtle use-after-free errors. This change is to make CDMD
owned by DownloadService so that it doesn't outlive the Profile.
BUG=317913
Review URL: https://codereview.chromium.org/69793006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@240726 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/download/chrome_download_manager_delegate.cc')
-rw-r--r-- | chrome/browser/download/chrome_download_manager_delegate.cc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/chrome/browser/download/chrome_download_manager_delegate.cc b/chrome/browser/download/chrome_download_manager_delegate.cc index 0d1c0c5..efcc701 100644 --- a/chrome/browser/download/chrome_download_manager_delegate.cc +++ b/chrome/browser/download/chrome_download_manager_delegate.cc @@ -216,6 +216,8 @@ ChromeDownloadManagerDelegate::ChromeDownloadManagerDelegate(Profile* profile) } ChromeDownloadManagerDelegate::~ChromeDownloadManagerDelegate() { + // If a DownloadManager was set for this, Shutdown() must be called. + DCHECK(!download_manager_); } void ChromeDownloadManagerDelegate::SetDownloadManager(DownloadManager* dm) { @@ -225,6 +227,13 @@ void ChromeDownloadManagerDelegate::SetDownloadManager(DownloadManager* dm) { void ChromeDownloadManagerDelegate::Shutdown() { download_prefs_.reset(); weak_ptr_factory_.InvalidateWeakPtrs(); + download_manager_ = NULL; +} + +content::DownloadIdCallback +ChromeDownloadManagerDelegate::GetDownloadIdReceiverCallback() { + return base::Bind(&ChromeDownloadManagerDelegate::SetNextId, + weak_ptr_factory_.GetWeakPtr()); } void ChromeDownloadManagerDelegate::SetNextId(uint32 next_id) { |