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

Unified Diff: content/browser/loader/resource_loader.cc

Issue 2557433005: Revert of Fix a pair of ResourceLoader cancellation/error bugs. (Closed)
Patch Set: Created 4 years 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
Index: content/browser/loader/resource_loader.cc
diff --git a/content/browser/loader/resource_loader.cc b/content/browser/loader/resource_loader.cc
index d944ea9a5e59175cca7ae78646f93242eabba6b8..0b3833a655ec3c9a6f44b7826de333f460f26f68 100644
--- a/content/browser/loader/resource_loader.cc
+++ b/content/browser/loader/resource_loader.cc
@@ -350,13 +350,13 @@
CompleteResponseStarted();
- // If the handler deferred the request, it will resume the request later. If
- // the request was cancelled, the request will call back into |this| with a
- // bogus read completed error.
- if (is_deferred() || !request_->status().is_success())
- return;
-
- StartReading(false); // Read the first chunk.
+ if (is_deferred())
+ return;
+
+ if (request_->status().is_success())
+ StartReading(false); // Read the first chunk.
+ else
+ ResponseCompleted();
}
void ResourceLoader::OnReadCompleted(net::URLRequest* unused, int bytes_read) {
@@ -375,9 +375,12 @@
CompleteRead(bytes_read);
// If the handler cancelled or deferred the request, do not continue
- // processing the read. If canceled, either the request will call into |this|
- // with a bogus read error, or, if the request was completed, a task posted
- // from ResourceLoader::CancelREquestInternal will run OnResponseCompleted.
+ // processing the read. If cancelled, the URLRequest has already been
+ // cancelled and will schedule an erroring OnReadCompleted later. If deferred,
+ // do nothing until resumed.
+ //
+ // Note: if bytes_read is 0 (EOF) and the handler defers, resumption will call
+ // ResponseCompleted().
if (is_deferred() || !request_->status().is_success())
return;
@@ -559,8 +562,7 @@
ReadMore(&bytes_read);
// If IO is pending, wait for the URLRequest to call OnReadCompleted.
- // On error or cancellation, wait for notification of failure.
- if (request_->status().is_io_pending() || !request_->status().is_success())
+ if (request_->status().is_io_pending())
return;
if (!is_continuation || bytes_read <= 0) {
« no previous file with comments | « content/browser/loader/intercepting_resource_handler_unittest.cc ('k') | content/browser/loader/resource_loader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698