summaryrefslogtreecommitdiffstats
path: root/content/browser/renderer_host/throttling_resource_handler.cc
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-13 18:27:39 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-13 18:27:39 +0000
commite7d8ea75177be9eeff004599e2e7dd4bd10b4c2f (patch)
tree8c1e3740fa71fa8d3c5925b912bd97ea3030c47c /content/browser/renderer_host/throttling_resource_handler.cc
parent4916e07255398041971840eb555292b5bcffd29f (diff)
downloadchromium_src-e7d8ea75177be9eeff004599e2e7dd4bd10b4c2f.zip
chromium_src-e7d8ea75177be9eeff004599e2e7dd4bd10b4c2f.tar.gz
chromium_src-e7d8ea75177be9eeff004599e2e7dd4bd10b4c2f.tar.bz2
Replace WillReadRequest with WillProcessResponse so that the
DownloadResourceThrottle can defer ResourceHandler::OnResponseStarted. Review URL: http://codereview.chromium.org/9387001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121713 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/renderer_host/throttling_resource_handler.cc')
-rw-r--r--content/browser/renderer_host/throttling_resource_handler.cc53
1 files changed, 24 insertions, 29 deletions
diff --git a/content/browser/renderer_host/throttling_resource_handler.cc b/content/browser/renderer_host/throttling_resource_handler.cc
index 565da83..38b656f 100644
--- a/content/browser/renderer_host/throttling_resource_handler.cc
+++ b/content/browser/renderer_host/throttling_resource_handler.cc
@@ -72,20 +72,26 @@ bool ThrottlingResourceHandler::OnWillStart(int request_id,
return next_handler_->OnWillStart(request_id, url, defer);
}
-bool ThrottlingResourceHandler::OnWillRead(int request_id, net::IOBuffer** buf,
- int* buf_size, int min_size) {
+bool ThrottlingResourceHandler::OnResponseStarted(
+ int request_id,
+ content::ResourceResponse* response) {
DCHECK_EQ(request_id_, request_id);
- bool defer = false;
- WillReadRequest(&defer);
- if (defer) {
- host_->PauseRequest(child_id_, request_id_, true);
- return false; // Do not read.
+ while (index_ < throttles_.size()) {
+ bool defer = false;
+ throttles_[index_]->WillProcessResponse(&defer);
+ index_++;
+ if (defer) {
+ host_->PauseRequest(child_id_, request_id_, true);
+ deferred_stage_ = DEFERRED_RESPONSE;
+ deferred_response_ = response;
+ return true; // Do not cancel.
+ }
}
index_ = 0; // Reset for next time.
- return next_handler_->OnWillRead(request_id, buf, buf_size, min_size);
+ return next_handler_->OnResponseStarted(request_id, response);
}
void ThrottlingResourceHandler::OnRequestClosed() {
@@ -108,8 +114,8 @@ void ThrottlingResourceHandler::Resume() {
case DEFERRED_REDIRECT:
ResumeRedirect();
break;
- case DEFERRED_READ:
- ResumeRead();
+ case DEFERRED_RESPONSE:
+ ResumeResponse();
break;
}
deferred_stage_ = DEFERRED_NONE;
@@ -144,26 +150,15 @@ void ThrottlingResourceHandler::ResumeRedirect() {
}
}
-void ThrottlingResourceHandler::ResumeRead() {
- bool defer = false;
- WillReadRequest(&defer);
- if (!defer) {
- host_->PauseRequest(child_id_, request_id_, false);
- // OnWillRead will be called again, and from there we'll call the
- // next_handler_'s OnWillRead.
- }
-}
+void ThrottlingResourceHandler::ResumeResponse() {
+ scoped_refptr<ResourceResponse> response;
+ deferred_response_.swap(response);
-void ThrottlingResourceHandler::WillReadRequest(bool* defer) {
- *defer = false;
- while (index_ < throttles_.size()) {
- throttles_[index_]->WillReadRequest(defer);
- index_++;
- if (*defer) {
- deferred_stage_ = DEFERRED_READ;
- break;
- }
- }
+ // OnResponseStarted will pause again if necessary.
+ host_->PauseRequest(child_id_, request_id_, false);
+
+ if (!OnResponseStarted(request_id_, response))
+ Cancel();
}
} // namespace content