diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-24 08:30:14 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-24 08:30:14 +0000 |
commit | ecaa9a994484961d3868a3c0bf9b5ca46d989719 (patch) | |
tree | d4a3cc928ec9df003c3374a29ef69195431d8195 /chrome/browser | |
parent | 095b55f695d7a576305a06e9d8f63669d2c9baa5 (diff) | |
download | chromium_src-ecaa9a994484961d3868a3c0bf9b5ca46d989719.zip chromium_src-ecaa9a994484961d3868a3c0bf9b5ca46d989719.tar.gz chromium_src-ecaa9a994484961d3868a3c0bf9b5ca46d989719.tar.bz2 |
Fix leak of a DownloadItem in SavePackage::Init.
BUG=56495, 54149
TEST=valgrind, see bugs
Review URL: http://codereview.chromium.org/3498002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60439 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/download/download_manager.h | 3 | ||||
-rw-r--r-- | chrome/browser/download/save_package.cc | 12 |
2 files changed, 12 insertions, 3 deletions
diff --git a/chrome/browser/download/download_manager.h b/chrome/browser/download/download_manager.h index f4dc78d..4bbf49a 100644 --- a/chrome/browser/download/download_manager.h +++ b/chrome/browser/download/download_manager.h @@ -135,7 +135,8 @@ class DownloadManager // deleted is returned back to the caller. int RemoveAllDownloads(); - // Called when a Save Page As download is started. + // Called when a Save Page As download is started. Transfers ownership + // of |download_item| to the DownloadManager. void SavePageAsDownloadStarted(DownloadItem* download_item); // Download the object at the URL. Used in cases such as "Save Link As..." diff --git a/chrome/browser/download/save_package.cc b/chrome/browser/download/save_package.cc index 9fccd6e..f624e44 100644 --- a/chrome/browser/download/save_package.cc +++ b/chrome/browser/download/save_package.cc @@ -370,9 +370,17 @@ bool SavePackage::Init() { request_context_getter_ = profile->GetRequestContext(); // Create the fake DownloadItem and display the view. - download_ = new DownloadItem(tab_contents_->profile()->GetDownloadManager(), - saved_main_file_path_, page_url_, + DownloadManager* download_manager = + tab_contents_->profile()->GetDownloadManager(); + download_ = new DownloadItem(download_manager, + saved_main_file_path_, + page_url_, profile->IsOffTheRecord()); + + // Transfer the ownership to the download manager. We need the DownloadItem + // to be alive as long as the Profile is alive. + download_manager->SavePageAsDownloadStarted(download_); + tab_contents_->OnStartDownload(download_); // Check save type and process the save page job. |