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

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

Issue 62048: Fix a crash when canceling a save page operation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/save_package.cc
===================================================================
--- chrome/browser/download/save_package.cc (revision 13138)
+++ chrome/browser/download/save_package.cc (working copy)
@@ -116,7 +116,8 @@
SavePackageType save_type,
const FilePath& file_full_path,
const FilePath& directory_full_path)
- : web_contents_(web_content),
+ : file_manager_(NULL),
+ web_contents_(web_content),
download_(NULL),
saved_main_file_path_(file_full_path),
saved_main_directory_path_(directory_full_path),
@@ -140,7 +141,8 @@
}
SavePackage::SavePackage(WebContents* web_contents)
- : web_contents_(web_contents),
+ : file_manager_(NULL),
+ web_contents_(web_contents),
download_(NULL),
finished_(false),
user_canceled_(false),
@@ -157,7 +159,8 @@
// method Cancel to be be called in destructor in test mode.
SavePackage::SavePackage(const FilePath& file_full_path,
const FilePath& directory_full_path)
- : download_(NULL),
+ : file_manager_(NULL),
+ download_(NULL),
saved_main_file_path_(file_full_path),
saved_main_directory_path_(directory_full_path),
finished_(true),
@@ -507,6 +510,11 @@
// Stop all page saving jobs that are in progress and instruct the file thread
// to delete all saved files.
void SavePackage::Stop() {
+ // If we haven't moved out of the initial state, there's nothing to cancel and
+ // there won't be valid pointers for file_manager_ or download_.
+ if (wait_state_ == INITIALIZE)
+ return;
+
// When stopping, if it still has some items in in_progress, cancel them.
DCHECK(canceled());
if (in_process_count()) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698