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

Unified Diff: content/browser/download/save_file_manager.cc

Issue 1812693002: Fix how Save-Page-As responds to web requests blocked by extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed new test (to help with merges into Beta and Stable branches). Created 4 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 | « content/browser/download/save_file_manager.h ('k') | content/browser/download/save_package.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/download/save_file_manager.cc
diff --git a/content/browser/download/save_file_manager.cc b/content/browser/download/save_file_manager.cc
index cf2e59ce3f15c4da2c3f88020dc9051b9034181c..0c7130e51c9e7645128323d0a32d0ee937c3cf7f 100644
--- a/content/browser/download/save_file_manager.cc
+++ b/content/browser/download/save_file_manager.cc
@@ -74,6 +74,10 @@ void SaveFileManager::SaveURL(SaveItemId save_item_id,
SavePackage* save_package) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ // Insert started saving job to tracking list.
+ DCHECK(packages_.find(save_item_id) == packages_.end());
+ packages_[save_item_id] = save_package;
+
// Register a saving job.
if (save_source == SaveFileCreateInfo::SAVE_FILE_FROM_NET) {
DCHECK(url.is_valid());
@@ -201,19 +205,29 @@ void SaveFileManager::SaveFinished(SaveItemId save_item_id,
<< " save_package_id = " << save_package_id
<< " is_success = " << is_success;
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
+
+ int64_t bytes_so_far;
SaveFile* save_file = LookupSaveFile(save_item_id);
if (save_file != nullptr) {
DCHECK(save_file->InProgress());
DVLOG(20) << " " << __FUNCTION__ << "()"
<< " save_file = " << save_file->DebugString();
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(&SaveFileManager::OnSaveFinished, this, save_item_id,
- save_file->BytesSoFar(), is_success));
-
+ bytes_so_far = save_file->BytesSoFar();
save_file->Finish();
save_file->Detach();
+ } else {
+ // We got called before StartSave - this should only happen if
+ // ResourceHandler failed before it got a chance to parse headers
+ // and metadata.
+ DCHECK(!is_success);
+
+ bytes_so_far = 0;
}
+
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&SaveFileManager::OnSaveFinished, this, save_item_id,
+ bytes_so_far, is_success));
}
// Notifications sent from the file thread and run on the UI thread.
@@ -228,10 +242,6 @@ void SaveFileManager::OnStartSave(const SaveFileCreateInfo& info) {
return;
}
- // Insert started saving job to tracking list.
- DCHECK(packages_.find(info.save_item_id) == packages_.end());
- packages_[info.save_item_id] = save_package;
-
// Forward this message to SavePackage.
save_package->StartSave(&info);
}
« no previous file with comments | « content/browser/download/save_file_manager.h ('k') | content/browser/download/save_package.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698