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

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

Issue 2543633004: Fix a pair of ResourceLoader cancellation/error bugs. (Closed)
Patch Set: Fix cert tests, add out-of-band cancel tests 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 f2f670a566d55ed03d811df7269c241b66a3e1bf..6c3574e2a9ff3ef743300be78f21434918a502d3 100644
--- a/content/browser/loader/resource_loader.cc
+++ b/content/browser/loader/resource_loader.cc
@@ -351,13 +351,13 @@ void ResourceLoader::OnResponseStarted(net::URLRequest* unused) {
CompleteResponseStarted();
- if (is_deferred())
+ // If the handler deferred the request, it will resume the request later. If
+ // the request was cancelled, it will call back into |this| to notify it of
+ // the cancellation.
Randy Smith (Not in Mondays) 2016/12/01 20:12:52 I'm confused by this comment. We're dealing here
mmenke 2016/12/01 20:47:43 CompleteResponseStarted() will have cancelled the
Randy Smith (Not in Mondays) 2016/12/02 20:38:55 So just to confirm I understand what's going on: *
+ if (is_deferred() || !request_->status().is_success())
return;
- if (request_->status().is_success())
- StartReading(false); // Read the first chunk.
- else
- ResponseCompleted();
+ StartReading(false); // Read the first chunk.
}
void ResourceLoader::OnReadCompleted(net::URLRequest* unused, int bytes_read) {
@@ -563,7 +563,8 @@ void ResourceLoader::StartReading(bool is_continuation) {
ReadMore(&bytes_read);
// If IO is pending, wait for the URLRequest to call OnReadCompleted.
- if (request_->status().is_io_pending())
+ // On error or cancellation, wait for notification of failure.
Randy Smith (Not in Mondays) 2016/12/01 20:12:52 I'm sure I'm missing a pathway, but ReadMore inclu
Randy Smith (Not in Mondays) 2016/12/01 20:12:52 How about "... wait for arrival of ResponseComplet
mmenke 2016/12/01 20:47:43 Note that Cancel only posts that task if the reque
mmenke 2016/12/01 20:47:43 On synchronous failure, URLRequest::Read calls bac
Randy Smith (Not in Mondays) 2016/12/02 20:38:55 Wow. I keep feeling like I've gotten to the botto
+ if (request_->status().is_io_pending() || !request_->status().is_success())
return;
if (!is_continuation || bytes_read <= 0) {

Powered by Google App Engine
This is Rietveld 408576698