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

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

Issue 267563004: Avoid issuing a Read() after draining a request. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Re-upload to see if it would make bots happy. Created 6 years, 7 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/loader/resource_loader.h ('k') | content/browser/loader/resource_loader_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/loader/resource_loader.cc
diff --git a/content/browser/loader/resource_loader.cc b/content/browser/loader/resource_loader.cc
index 251fc2eb79594e3ef127f72026dda618204e9fcf..450f1934762f5fbd0b2f2c263f10a35ccca6c9b1 100644
--- a/content/browser/loader/resource_loader.cc
+++ b/content/browser/loader/resource_loader.cc
@@ -168,7 +168,12 @@ void ResourceLoader::MarkAsTransferring() {
}
void ResourceLoader::CompleteTransfer() {
- DCHECK_EQ(DEFERRED_READ, deferred_stage_);
+ // Although CrossSiteResourceHandler defers at OnResponseStarted
+ // (DEFERRED_READ), it may be seeing a replay of events via
+ // BufferedResourceHandler, and so the request itself is actually deferred at
+ // a later read stage.
+ DCHECK(DEFERRED_READ == deferred_stage_ ||
+ DEFERRED_RESPONSE_COMPLETE == deferred_stage_);
is_transferring_ = false;
GetRequestInfo()->cross_site_handler()->ResumeResponse();
@@ -363,7 +368,7 @@ void ResourceLoader::OnReadCompleted(net::URLRequest* unused, int bytes_read) {
// do nothing until resumed.
//
// Note: if bytes_read is 0 (EOF) and the handler defers, resumption will call
- // Read() on the URLRequest again and get a second EOF.
+ // ResponseCompleted().
if (is_deferred() || !request_->status().is_success())
return;
@@ -426,6 +431,12 @@ void ResourceLoader::Resume() {
base::Bind(&ResourceLoader::ResumeReading,
weak_ptr_factory_.GetWeakPtr()));
break;
+ case DEFERRED_RESPONSE_COMPLETE:
+ base::MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&ResourceLoader::ResponseCompleted,
+ weak_ptr_factory_.GetWeakPtr()));
+ break;
case DEFERRED_FINISH:
// Delay self-destruction since we don't know how we were reached.
base::MessageLoop::current()->PostTask(
@@ -622,7 +633,8 @@ void ResourceLoader::CompleteRead(int bytes_read) {
if (!handler_->OnReadCompleted(info->GetRequestID(), bytes_read, &defer)) {
Cancel();
} else if (defer) {
- deferred_stage_ = DEFERRED_READ; // Read next chunk when resumed.
+ deferred_stage_ =
+ bytes_read > 0 ? DEFERRED_READ : DEFERRED_RESPONSE_COMPLETE;
}
// Note: the request may still have been cancelled while OnReadCompleted
« no previous file with comments | « content/browser/loader/resource_loader.h ('k') | content/browser/loader/resource_loader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698