| OLD | NEW |
| 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 <utility> |
| 8 |
| 7 #include "content/browser/loader/resource_request_info_impl.h" | 9 #include "content/browser/loader/resource_request_info_impl.h" |
| 8 #include "content/public/browser/resource_throttle.h" | 10 #include "content/public/browser/resource_throttle.h" |
| 9 #include "content/public/common/resource_response.h" | 11 #include "content/public/common/resource_response.h" |
| 10 #include "net/url_request/url_request.h" | 12 #include "net/url_request/url_request.h" |
| 11 | 13 |
| 12 namespace content { | 14 namespace content { |
| 13 | 15 |
| 14 ThrottlingResourceHandler::ThrottlingResourceHandler( | 16 ThrottlingResourceHandler::ThrottlingResourceHandler( |
| 15 scoped_ptr<ResourceHandler> next_handler, | 17 scoped_ptr<ResourceHandler> next_handler, |
| 16 net::URLRequest* request, | 18 net::URLRequest* request, |
| 17 ScopedVector<ResourceThrottle> throttles) | 19 ScopedVector<ResourceThrottle> throttles) |
| 18 : LayeredResourceHandler(request, next_handler.Pass()), | 20 : LayeredResourceHandler(request, std::move(next_handler)), |
| 19 deferred_stage_(DEFERRED_NONE), | 21 deferred_stage_(DEFERRED_NONE), |
| 20 throttles_(throttles.Pass()), | 22 throttles_(std::move(throttles)), |
| 21 next_index_(0), | 23 next_index_(0), |
| 22 cancelled_by_resource_throttle_(false) { | 24 cancelled_by_resource_throttle_(false) { |
| 23 for (size_t i = 0; i < throttles_.size(); ++i) { | 25 for (size_t i = 0; i < throttles_.size(); ++i) { |
| 24 throttles_[i]->set_controller(this); | 26 throttles_[i]->set_controller(this); |
| 25 // Throttles must have a name, as otherwise, bugs where a throttle fails | 27 // Throttles must have a name, as otherwise, bugs where a throttle fails |
| 26 // to resume a request can be very difficult to debug. | 28 // to resume a request can be very difficult to debug. |
| 27 DCHECK(throttles_[i]->GetNameForLogging()); | 29 DCHECK(throttles_[i]->GetNameForLogging()); |
| 28 } | 30 } |
| 29 } | 31 } |
| 30 | 32 |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 } else if (!defer) { | 227 } else if (!defer) { |
| 226 controller()->Resume(); | 228 controller()->Resume(); |
| 227 } | 229 } |
| 228 } | 230 } |
| 229 | 231 |
| 230 void ThrottlingResourceHandler::OnRequestDefered(int throttle_index) { | 232 void ThrottlingResourceHandler::OnRequestDefered(int throttle_index) { |
| 231 request()->LogBlockedBy(throttles_[throttle_index]->GetNameForLogging()); | 233 request()->LogBlockedBy(throttles_[throttle_index]->GetNameForLogging()); |
| 232 } | 234 } |
| 233 | 235 |
| 234 } // namespace content | 236 } // namespace content |
| OLD | NEW |