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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/download/save_package.h" 5 #include "chrome/browser/download/save_package.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/i18n/file_util_icu.h" 10 #include "base/i18n/file_util_icu.h"
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 // Initialize the request context and resource dispatcher. 363 // Initialize the request context and resource dispatcher.
364 Profile* profile = tab_contents_->profile(); 364 Profile* profile = tab_contents_->profile();
365 if (!profile) { 365 if (!profile) {
366 NOTREACHED(); 366 NOTREACHED();
367 return false; 367 return false;
368 } 368 }
369 369
370 request_context_getter_ = profile->GetRequestContext(); 370 request_context_getter_ = profile->GetRequestContext();
371 371
372 // Create the fake DownloadItem and display the view. 372 // Create the fake DownloadItem and display the view.
373 download_ = new DownloadItem(tab_contents_->profile()->GetDownloadManager(), 373 DownloadManager* download_manager =
374 saved_main_file_path_, page_url_, 374 tab_contents_->profile()->GetDownloadManager();
375 download_ = new DownloadItem(download_manager,
376 saved_main_file_path_,
377 page_url_,
375 profile->IsOffTheRecord()); 378 profile->IsOffTheRecord());
379
380 // Transfer the ownership to the download manager. We need the DownloadItem
381 // to be alive as long as the Profile is alive.
382 download_manager->SavePageAsDownloadStarted(download_);
383
376 tab_contents_->OnStartDownload(download_); 384 tab_contents_->OnStartDownload(download_);
377 385
378 // Check save type and process the save page job. 386 // Check save type and process the save page job.
379 if (save_type_ == SAVE_AS_COMPLETE_HTML) { 387 if (save_type_ == SAVE_AS_COMPLETE_HTML) {
380 // Get directory 388 // Get directory
381 DCHECK(!saved_main_directory_path_.empty()); 389 DCHECK(!saved_main_directory_path_.empty());
382 GetAllSavableResourceLinksForCurrentPage(); 390 GetAllSavableResourceLinksForCurrentPage();
383 } else { 391 } else {
384 wait_state_ = NET_FILES; 392 wait_state_ = NET_FILES;
385 SaveFileCreateInfo::SaveFileSource save_source = page_url_.SchemeIsFile() ? 393 SaveFileCreateInfo::SaveFileSource save_source = page_url_.SchemeIsFile() ?
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after
1371 int index, void* params) { 1379 int index, void* params) {
1372 SavePackageParam* save_params = reinterpret_cast<SavePackageParam*>(params); 1380 SavePackageParam* save_params = reinterpret_cast<SavePackageParam*>(params);
1373 ContinueSave(save_params, path, index); 1381 ContinueSave(save_params, path, index);
1374 delete save_params; 1382 delete save_params;
1375 } 1383 }
1376 1384
1377 void SavePackage::FileSelectionCanceled(void* params) { 1385 void SavePackage::FileSelectionCanceled(void* params) {
1378 SavePackageParam* save_params = reinterpret_cast<SavePackageParam*>(params); 1386 SavePackageParam* save_params = reinterpret_cast<SavePackageParam*>(params);
1379 delete save_params; 1387 delete save_params;
1380 } 1388 }
OLDNEW
« 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