| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/detachable_resource_handler.h" | 5 #include "content/browser/loader/detachable_resource_handler.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 if (!next_handler_) { | 177 if (!next_handler_) { |
| 178 controller->Resume(); | 178 controller->Resume(); |
| 179 return; | 179 return; |
| 180 } | 180 } |
| 181 | 181 |
| 182 HoldController(std::move(controller)); | 182 HoldController(std::move(controller)); |
| 183 next_handler_->OnWillStart(url, base::MakeUnique<Controller>(this)); | 183 next_handler_->OnWillStart(url, base::MakeUnique<Controller>(this)); |
| 184 } | 184 } |
| 185 | 185 |
| 186 bool DetachableResourceHandler::OnWillRead(scoped_refptr<net::IOBuffer>* buf, | 186 bool DetachableResourceHandler::OnWillRead(scoped_refptr<net::IOBuffer>* buf, |
| 187 int* buf_size, | 187 int* buf_size) { |
| 188 int min_size) { | |
| 189 if (!next_handler_) { | 188 if (!next_handler_) { |
| 190 DCHECK_EQ(-1, min_size); | |
| 191 if (!read_buffer_.get()) | 189 if (!read_buffer_.get()) |
| 192 read_buffer_ = new net::IOBuffer(kReadBufSize); | 190 read_buffer_ = new net::IOBuffer(kReadBufSize); |
| 193 *buf = read_buffer_; | 191 *buf = read_buffer_; |
| 194 *buf_size = kReadBufSize; | 192 *buf_size = kReadBufSize; |
| 195 return true; | 193 return true; |
| 196 } | 194 } |
| 197 | 195 |
| 198 return next_handler_->OnWillRead(buf, buf_size, min_size); | 196 return next_handler_->OnWillRead(buf, buf_size); |
| 199 } | 197 } |
| 200 | 198 |
| 201 void DetachableResourceHandler::OnReadCompleted( | 199 void DetachableResourceHandler::OnReadCompleted( |
| 202 int bytes_read, | 200 int bytes_read, |
| 203 std::unique_ptr<ResourceController> controller) { | 201 std::unique_ptr<ResourceController> controller) { |
| 204 DCHECK(!has_controller()); | 202 DCHECK(!has_controller()); |
| 205 | 203 |
| 206 if (!next_handler_) { | 204 if (!next_handler_) { |
| 207 controller->Resume(); | 205 controller->Resume(); |
| 208 return; | 206 return; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 void DetachableResourceHandler::OnTimedOut() { | 239 void DetachableResourceHandler::OnTimedOut() { |
| 242 // Requests are only timed out after being detached, and shouldn't be deferred | 240 // Requests are only timed out after being detached, and shouldn't be deferred |
| 243 // once detached. | 241 // once detached. |
| 244 DCHECK(!next_handler_); | 242 DCHECK(!next_handler_); |
| 245 DCHECK(!has_controller()); | 243 DCHECK(!has_controller()); |
| 246 | 244 |
| 247 OutOfBandCancel(net::ERR_ABORTED, true /* tell_renderer */); | 245 OutOfBandCancel(net::ERR_ABORTED, true /* tell_renderer */); |
| 248 } | 246 } |
| 249 | 247 |
| 250 } // namespace content | 248 } // namespace content |
| OLD | NEW |