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

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

Issue 3498002: Fix leak of a DownloadItem in SavePackage::Init. (Closed)
Patch Set: rebase Created 10 years, 3 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
« no previous file with comments | « chrome/browser/download/download_manager.h ('k') | tools/valgrind/memcheck/suppressions.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/save_package.cc
diff --git a/chrome/browser/download/save_package.cc b/chrome/browser/download/save_package.cc
index 9fccd6e7684f677307527f1059fbb5fb118b6d65..f624e4458705160a76a50adb498b22cd35a5f1f1 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.
« no previous file with comments | « chrome/browser/download/download_manager.h ('k') | tools/valgrind/memcheck/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698