diff options
author | sky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-16 15:22:48 +0000 |
---|---|---|
committer | sky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-16 15:22:48 +0000 |
commit | ad59ef3d47e885120966b07ebaef96440ef1ec3d (patch) | |
tree | 46ff8f94d73cfb4c46b33a602f25fec3543a7b4f /chrome/browser/download/save_package.cc | |
parent | bc1e07c777d31055c22cc4a498a0267097063a97 (diff) | |
download | chromium_src-ad59ef3d47e885120966b07ebaef96440ef1ec3d.zip chromium_src-ad59ef3d47e885120966b07ebaef96440ef1ec3d.tar.gz chromium_src-ad59ef3d47e885120966b07ebaef96440ef1ec3d.tar.bz2 |
Fixes two crashers in saving page:
1. GetTabID was being called AFTER the process was destroyed, which
means we could try and deref NULL. By caching the value we don't
have to worry about whether the web contents goes away or not.
2. A PostTask was done, then we assumed the SaveItem still
exists. That isn't the case if the user canceled the save.
BUG=2206
TEST=none, just make sure save page as still works correctly.
Review URL: http://codereview.chromium.org/3034
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2261 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/download/save_package.cc')
-rw-r--r-- | chrome/browser/download/save_package.cc | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/chrome/browser/download/save_package.cc b/chrome/browser/download/save_package.cc index 5410d31..ec350ea 100644 --- a/chrome/browser/download/save_package.cc +++ b/chrome/browser/download/save_package.cc @@ -68,7 +68,8 @@ SavePackage::SavePackage(WebContents* web_content, user_canceled_(false), download_(NULL), finished_(false), - wait_state_(INITIALIZE) { + wait_state_(INITIALIZE), + tab_id_(web_content->process()->host_id()) { DCHECK(web_content); const GURL& current_page_url = web_contents_->GetURL(); DCHECK(current_page_url.is_valid()); @@ -91,7 +92,8 @@ SavePackage::SavePackage(const wchar_t* file_full_path, finished_(true), download_(NULL), user_canceled_(false), - disk_error_occurred_(false) { + disk_error_occurred_(false), + tab_id_(0) { DCHECK(!saved_main_file_path_.empty() && saved_main_file_path_.length() <= kMaxFilePathLength); DCHECK(!saved_main_directory_path_.empty() && @@ -366,7 +368,7 @@ void SavePackage::StartSave(const SaveFileCreateInfo* info) { &SaveFileManager::SaveLocalFile, save_item->url(), save_item->save_id(), - GetTabId())); + tab_id())); return; } @@ -709,11 +711,6 @@ void SavePackage::DoSavingProcess() { } } -int SavePackage::GetTabId() { - DCHECK(web_contents_); - return web_contents_->process()->host_id(); -} - // After finishing all SaveItems which need to get data from net. // We collect all URLs which have local storage and send the // map:(originalURL:currentLocalPath) to render process (backend). @@ -776,7 +773,7 @@ void SavePackage::ProcessSerializedHtmlData(const GURL& frame_url, if (wait_state_ != HTML_DATA) return; - int tab_id = GetTabId(); + int id = tab_id(); // If the all frames are finished saving, we need to close the // remaining SaveItems. if (flag == webkit_glue::DomSerializerDelegate::ALL_FRAMES_ARE_FINISHED) { @@ -787,7 +784,7 @@ void SavePackage::ProcessSerializedHtmlData(const GURL& frame_url, &SaveFileManager::SaveFinished, it->second->save_id(), it->second->url(), - tab_id, + id, true)); } return; @@ -821,7 +818,7 @@ void SavePackage::ProcessSerializedHtmlData(const GURL& frame_url, &SaveFileManager::SaveFinished, save_item->save_id(), save_item->url(), - tab_id, + id, true)); } } |