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

Side by Side Diff: content/browser/renderer_host/throttling_resource_handler.cc

Issue 10332130: Use defer out-params instead of ResourceDispatcherHostImpl::PauseRequest(...true) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/throttling_resource_handler.h" 5 #include "content/browser/renderer_host/throttling_resource_handler.h"
6 6
7 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" 7 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h"
8 #include "content/public/browser/resource_throttle.h" 8 #include "content/public/browser/resource_throttle.h"
9 #include "content/public/common/resource_response.h" 9 #include "content/public/common/resource_response.h"
10 10
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 } 67 }
68 } 68 }
69 69
70 index_ = 0; // Reset for next time. 70 index_ = 0; // Reset for next time.
71 71
72 return next_handler_->OnWillStart(request_id, url, defer); 72 return next_handler_->OnWillStart(request_id, url, defer);
73 } 73 }
74 74
75 bool ThrottlingResourceHandler::OnResponseStarted( 75 bool ThrottlingResourceHandler::OnResponseStarted(
76 int request_id, 76 int request_id,
77 content::ResourceResponse* response) { 77 content::ResourceResponse* response,
78 bool* defer) {
78 DCHECK_EQ(request_id_, request_id); 79 DCHECK_EQ(request_id_, request_id);
79 80
80 while (index_ < throttles_.size()) { 81 while (index_ < throttles_.size()) {
81 bool defer = false; 82 throttles_[index_]->WillProcessResponse(defer);
82 throttles_[index_]->WillProcessResponse(&defer);
83 index_++; 83 index_++;
84 if (defer) { 84 if (*defer) {
85 host_->PauseRequest(child_id_, request_id_, true);
86 deferred_stage_ = DEFERRED_RESPONSE; 85 deferred_stage_ = DEFERRED_RESPONSE;
87 deferred_response_ = response; 86 deferred_response_ = response;
88 return true; // Do not cancel. 87 return true; // Do not cancel.
89 } 88 }
90 } 89 }
91 90
92 index_ = 0; // Reset for next time. 91 index_ = 0; // Reset for next time.
Randy Smith (Not in Mondays) 2012/05/18 20:17:02 Not relevant to this CL, just for my curiosity: th
darin (slow to review) 2012/05/18 23:09:05 In this comment, "next time" refers to the next no
93 92
94 return next_handler_->OnResponseStarted(request_id, response); 93 return next_handler_->OnResponseStarted(request_id, response, defer);
95 } 94 }
96 95
97 void ThrottlingResourceHandler::OnRequestClosed() { 96 void ThrottlingResourceHandler::OnRequestClosed() {
98 throttles_.reset(); 97 throttles_.reset();
99 next_handler_->OnRequestClosed(); 98 next_handler_->OnRequestClosed();
100 } 99 }
101 100
102 void ThrottlingResourceHandler::Cancel() { 101 void ThrottlingResourceHandler::Cancel() {
103 host_->CancelRequest(child_id_, request_id_, false); 102 host_->CancelRequest(child_id_, request_id_, false);
104 } 103 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 Cancel(); 146 Cancel();
148 } else if (!defer) { 147 } else if (!defer) {
149 host_->FollowDeferredRedirect(child_id_, request_id_, false, GURL()); 148 host_->FollowDeferredRedirect(child_id_, request_id_, false, GURL());
150 } 149 }
151 } 150 }
152 151
153 void ThrottlingResourceHandler::ResumeResponse() { 152 void ThrottlingResourceHandler::ResumeResponse() {
154 scoped_refptr<ResourceResponse> response; 153 scoped_refptr<ResourceResponse> response;
155 deferred_response_.swap(response); 154 deferred_response_.swap(response);
156 155
157 // OnResponseStarted will pause again if necessary. 156 bool defer = false;
158 host_->PauseRequest(child_id_, request_id_, false); 157 if (!OnResponseStarted(request_id_, response, &defer)) {
159
160 if (!OnResponseStarted(request_id_, response))
161 Cancel(); 158 Cancel();
159 } else if (!defer) {
160 host_->ResumeDeferredRequest(child_id_, request_id_);
161 }
162 } 162 }
163 163
164 } // namespace content 164 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698