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_file_manager.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_file_manager.cc')
-rw-r--r-- | chrome/browser/download/save_file_manager.cc | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/chrome/browser/download/save_file_manager.cc b/chrome/browser/download/save_file_manager.cc index 2a909b72..13b2d1f 100644 --- a/chrome/browser/download/save_file_manager.cc +++ b/chrome/browser/download/save_file_manager.cc @@ -90,7 +90,7 @@ void SaveFileManager::RegisterStartingRequest(const std::wstring& save_url, SavePackage* save_package) { // Make sure it runs in the UI thread. DCHECK(MessageLoop::current() == ui_loop_); - int tab_id = save_package->GetTabId(); + int tab_id = save_package->tab_id(); // Register this starting request. StartingRequestsMap& starting_requests = tab_starting_requests_[tab_id]; @@ -201,7 +201,7 @@ void SaveFileManager::RemoveSaveFile(int save_id, const std::wstring& save_url, // so remove it if it exists. if (save_id == -1) { SavePackage* old_package = UnregisterStartingRequest(save_url, - package->GetTabId()); + package->tab_id()); DCHECK(old_package == package); } else { SavePackageMap::iterator it = packages_.find(save_id); @@ -560,7 +560,10 @@ void SaveFileManager::OnFinishSavePageJob(int render_process_id, SavePackage* save_package = GetSavePackageFromRenderIds(render_process_id, render_view_id); - save_package->Finish(); + if (save_package) { + // save_package is null if save was canceled. + save_package->Finish(); + } } void SaveFileManager::RemoveSavedFileFromFileMap( |