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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
9 #include "content/browser/loader/resource_request_info_impl.h" | 9 #include "content/browser/loader/resource_request_info_impl.h" |
10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
11 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
| 12 #include "net/url_request/url_request.h" |
12 #include "net/url_request/url_request_status.h" | 13 #include "net/url_request/url_request_status.h" |
13 | 14 |
14 namespace { | 15 namespace { |
15 // This matches the maximum allocation size of AsyncResourceHandler. | 16 // This matches the maximum allocation size of AsyncResourceHandler. |
16 const int kReadBufSize = 32 * 1024; | 17 const int kReadBufSize = 32 * 1024; |
17 } | 18 } |
18 | 19 |
19 namespace content { | 20 namespace content { |
20 | 21 |
21 DetachableResourceHandler::DetachableResourceHandler( | 22 DetachableResourceHandler::DetachableResourceHandler( |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 next_handler_.reset(); | 63 next_handler_.reset(); |
63 | 64 |
64 // Time the request out if it takes too long. | 65 // Time the request out if it takes too long. |
65 detached_timer_.reset(new base::OneShotTimer<DetachableResourceHandler>()); | 66 detached_timer_.reset(new base::OneShotTimer<DetachableResourceHandler>()); |
66 detached_timer_->Start( | 67 detached_timer_->Start( |
67 FROM_HERE, cancel_delay_, this, &DetachableResourceHandler::Cancel); | 68 FROM_HERE, cancel_delay_, this, &DetachableResourceHandler::Cancel); |
68 | 69 |
69 // Resume if necessary. The request may have been deferred, say, waiting on a | 70 // Resume if necessary. The request may have been deferred, say, waiting on a |
70 // full buffer in AsyncResourceHandler. Now that it has been detached, resume | 71 // full buffer in AsyncResourceHandler. Now that it has been detached, resume |
71 // and drain it. | 72 // and drain it. |
72 if (is_deferred_) | 73 if (is_deferred_) { |
| 74 // The nested ResourceHandler may have logged that it's blocking the |
| 75 // request. Log it as no longer doing so, to avoid a DCHECK on resume. |
| 76 request()->LogUnblocked(); |
73 Resume(); | 77 Resume(); |
| 78 } |
74 } | 79 } |
75 | 80 |
76 void DetachableResourceHandler::SetController(ResourceController* controller) { | 81 void DetachableResourceHandler::SetController(ResourceController* controller) { |
77 ResourceHandler::SetController(controller); | 82 ResourceHandler::SetController(controller); |
78 | 83 |
79 // Intercept the ResourceController for downstream handlers to keep track of | 84 // Intercept the ResourceController for downstream handlers to keep track of |
80 // whether the request is deferred. | 85 // whether the request is deferred. |
81 if (next_handler_) | 86 if (next_handler_) |
82 next_handler_->SetController(this); | 87 next_handler_->SetController(this); |
83 } | 88 } |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 | 208 |
204 void DetachableResourceHandler::CancelAndIgnore() { | 209 void DetachableResourceHandler::CancelAndIgnore() { |
205 controller()->CancelAndIgnore(); | 210 controller()->CancelAndIgnore(); |
206 } | 211 } |
207 | 212 |
208 void DetachableResourceHandler::CancelWithError(int error_code) { | 213 void DetachableResourceHandler::CancelWithError(int error_code) { |
209 controller()->CancelWithError(error_code); | 214 controller()->CancelWithError(error_code); |
210 } | 215 } |
211 | 216 |
212 } // namespace content | 217 } // namespace content |
OLD | NEW |