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

Side by Side Diff: trunk/src/content/browser/loader/throttling_resource_handler.cc

Issue 26472004: Revert 227318 "Clean up ResourceHandler API." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 2 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
« no previous file with comments | « trunk/src/content/browser/loader/throttling_resource_handler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/loader/throttling_resource_handler.h" 5 #include "content/browser/loader/throttling_resource_handler.h"
6 6
7 #include "content/browser/loader/resource_request_info_impl.h" 7 #include "content/public/browser/resource_request_info.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
11 namespace content { 11 namespace content {
12 12
13 ThrottlingResourceHandler::ThrottlingResourceHandler( 13 ThrottlingResourceHandler::ThrottlingResourceHandler(
14 scoped_ptr<ResourceHandler> next_handler, 14 scoped_ptr<ResourceHandler> next_handler,
15 net::URLRequest* request, 15 net::URLRequest* request,
16 ScopedVector<ResourceThrottle> throttles) 16 ScopedVector<ResourceThrottle> throttles)
17 : LayeredResourceHandler(request, next_handler.Pass()), 17 : LayeredResourceHandler(next_handler.Pass()),
18 deferred_stage_(DEFERRED_NONE), 18 deferred_stage_(DEFERRED_NONE),
19 request_(request),
19 throttles_(throttles.Pass()), 20 throttles_(throttles.Pass()),
20 index_(0), 21 index_(0),
21 cancelled_by_resource_throttle_(false) { 22 cancelled_by_resource_throttle_(false) {
22 for (size_t i = 0; i < throttles_.size(); ++i) 23 for (size_t i = 0; i < throttles_.size(); ++i)
23 throttles_[i]->set_controller(this); 24 throttles_[i]->set_controller(this);
24 } 25 }
25 26
26 ThrottlingResourceHandler::~ThrottlingResourceHandler() { 27 ThrottlingResourceHandler::~ThrottlingResourceHandler() {
27 } 28 }
28 29
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 } 134 }
134 } 135 }
135 136
136 void ThrottlingResourceHandler::ResumeStart() { 137 void ThrottlingResourceHandler::ResumeStart() {
137 DCHECK(!cancelled_by_resource_throttle_); 138 DCHECK(!cancelled_by_resource_throttle_);
138 139
139 GURL url = deferred_url_; 140 GURL url = deferred_url_;
140 deferred_url_ = GURL(); 141 deferred_url_ = GURL();
141 142
142 bool defer = false; 143 bool defer = false;
143 if (!OnWillStart(GetRequestID(), url, &defer)) { 144 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request_);
145 if (!OnWillStart(info->GetRequestID(), url, &defer)) {
144 controller()->Cancel(); 146 controller()->Cancel();
145 } else if (!defer) { 147 } else if (!defer) {
146 controller()->Resume(); 148 controller()->Resume();
147 } 149 }
148 } 150 }
149 151
150 void ThrottlingResourceHandler::ResumeRedirect() { 152 void ThrottlingResourceHandler::ResumeRedirect() {
151 DCHECK(!cancelled_by_resource_throttle_); 153 DCHECK(!cancelled_by_resource_throttle_);
152 154
153 GURL new_url = deferred_url_; 155 GURL new_url = deferred_url_;
154 deferred_url_ = GURL(); 156 deferred_url_ = GURL();
155 scoped_refptr<ResourceResponse> response; 157 scoped_refptr<ResourceResponse> response;
156 deferred_response_.swap(response); 158 deferred_response_.swap(response);
157 159
158 bool defer = false; 160 bool defer = false;
159 if (!OnRequestRedirected(GetRequestID(), new_url, response.get(), &defer)) { 161 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request_);
162 if (!OnRequestRedirected(info->GetRequestID(), new_url, response.get(),
163 &defer)) {
160 controller()->Cancel(); 164 controller()->Cancel();
161 } else if (!defer) { 165 } else if (!defer) {
162 controller()->Resume(); 166 controller()->Resume();
163 } 167 }
164 } 168 }
165 169
166 void ThrottlingResourceHandler::ResumeResponse() { 170 void ThrottlingResourceHandler::ResumeResponse() {
167 DCHECK(!cancelled_by_resource_throttle_); 171 DCHECK(!cancelled_by_resource_throttle_);
168 172
169 scoped_refptr<ResourceResponse> response; 173 scoped_refptr<ResourceResponse> response;
170 deferred_response_.swap(response); 174 deferred_response_.swap(response);
171 175
172 bool defer = false; 176 bool defer = false;
173 if (!OnResponseStarted(GetRequestID(), response.get(), &defer)) { 177 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request_);
178 if (!OnResponseStarted(info->GetRequestID(), response.get(), &defer)) {
174 controller()->Cancel(); 179 controller()->Cancel();
175 } else if (!defer) { 180 } else if (!defer) {
176 controller()->Resume(); 181 controller()->Resume();
177 } 182 }
178 } 183 }
179 184
180 } // namespace content 185 } // namespace content
OLDNEW
« no previous file with comments | « trunk/src/content/browser/loader/throttling_resource_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698