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

Side by Side Diff: chrome/browser/download/save_package.cc

Issue 3398029: Merge 60439 - Fix leak of a DownloadItem in SavePackage::Init.... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/517/src/
Patch Set: '' 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/download/download_manager.h ('k') | no next file » | 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 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 // Initialize the request context and resource dispatcher. 362 // Initialize the request context and resource dispatcher.
363 Profile* profile = tab_contents_->profile(); 363 Profile* profile = tab_contents_->profile();
364 if (!profile) { 364 if (!profile) {
365 NOTREACHED(); 365 NOTREACHED();
366 return false; 366 return false;
367 } 367 }
368 368
369 request_context_getter_ = profile->GetRequestContext(); 369 request_context_getter_ = profile->GetRequestContext();
370 370
371 // Create the fake DownloadItem and display the view. 371 // Create the fake DownloadItem and display the view.
372 download_ = new DownloadItem(tab_contents_->profile()->GetDownloadManager(), 372 DownloadManager* download_manager =
373 saved_main_file_path_, page_url_, 373 tab_contents_->profile()->GetDownloadManager();
374 download_ = new DownloadItem(download_manager,
375 saved_main_file_path_,
376 page_url_,
374 profile->IsOffTheRecord()); 377 profile->IsOffTheRecord());
378
379 // Transfer the ownership to the download manager. We need the DownloadItem
380 // to be alive as long as the Profile is alive.
381 download_manager->SavePageAsDownloadStarted(download_);
382
375 tab_contents_->OnStartDownload(download_); 383 tab_contents_->OnStartDownload(download_);
376 384
377 // Check save type and process the save page job. 385 // Check save type and process the save page job.
378 if (save_type_ == SAVE_AS_COMPLETE_HTML) { 386 if (save_type_ == SAVE_AS_COMPLETE_HTML) {
379 // Get directory 387 // Get directory
380 DCHECK(!saved_main_directory_path_.empty()); 388 DCHECK(!saved_main_directory_path_.empty());
381 GetAllSavableResourceLinksForCurrentPage(); 389 GetAllSavableResourceLinksForCurrentPage();
382 } else { 390 } else {
383 wait_state_ = NET_FILES; 391 wait_state_ = NET_FILES;
384 SaveFileCreateInfo::SaveFileSource save_source = page_url_.SchemeIsFile() ? 392 SaveFileCreateInfo::SaveFileSource save_source = page_url_.SchemeIsFile() ?
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 int index, void* params) { 1378 int index, void* params) {
1371 SavePackageParam* save_params = reinterpret_cast<SavePackageParam*>(params); 1379 SavePackageParam* save_params = reinterpret_cast<SavePackageParam*>(params);
1372 ContinueSave(save_params, path, index); 1380 ContinueSave(save_params, path, index);
1373 delete save_params; 1381 delete save_params;
1374 } 1382 }
1375 1383
1376 void SavePackage::FileSelectionCanceled(void* params) { 1384 void SavePackage::FileSelectionCanceled(void* params) {
1377 SavePackageParam* save_params = reinterpret_cast<SavePackageParam*>(params); 1385 SavePackageParam* save_params = reinterpret_cast<SavePackageParam*>(params);
1378 delete save_params; 1386 delete save_params;
1379 } 1387 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698