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/renderer_host/async_resource_handler.h" | 5 #include "content/browser/renderer_host/async_resource_handler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/debug/alias.h" | 10 #include "base/debug/alias.h" |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 | 302 |
303 // TODO(gavinp): Remove this CHECK when we figure out the cause of | 303 // TODO(gavinp): Remove this CHECK when we figure out the cause of |
304 // http://crbug.com/124680 . This check mirrors closely check in | 304 // http://crbug.com/124680 . This check mirrors closely check in |
305 // WebURLLoaderImpl::OnCompletedRequest that routes this message to a WebCore | 305 // WebURLLoaderImpl::OnCompletedRequest that routes this message to a WebCore |
306 // ResourceHandleInternal which asserts on its state and crashes. By crashing | 306 // ResourceHandleInternal which asserts on its state and crashes. By crashing |
307 // when the message is sent, we should get better crash reports. | 307 // when the message is sent, we should get better crash reports. |
308 CHECK(status.status() != net::URLRequestStatus::SUCCESS || | 308 CHECK(status.status() != net::URLRequestStatus::SUCCESS || |
309 sent_received_response_msg_); | 309 sent_received_response_msg_); |
310 | 310 |
311 TimeTicks completion_time = TimeTicks::Now(); | 311 TimeTicks completion_time = TimeTicks::Now(); |
| 312 |
| 313 int error_code = status.error(); |
| 314 bool was_ignored_by_handler = |
| 315 ResourceRequestInfoImpl::ForRequest(request_)->WasIgnoredByHandler(); |
| 316 |
| 317 DCHECK(status.status() != net::URLRequestStatus::IO_PENDING); |
| 318 // If this check fails, then we're in an inconsistent state because all |
| 319 // requests ignored by the handler should be canceled (which should result in |
| 320 // the ERR_ABORTED error code). |
| 321 DCHECK(!was_ignored_by_handler || error_code == net::ERR_ABORTED); |
| 322 |
| 323 // TODO(mkosiba): Fix up cases where we create a URLRequestStatus |
| 324 // with a status() != SUCCESS and an error_code() == net::OK. |
| 325 if (status.status() == net::URLRequestStatus::CANCELED && |
| 326 error_code == net::OK) { |
| 327 error_code = net::ERR_ABORTED; |
| 328 } else if (status.status() == net::URLRequestStatus::FAILED && |
| 329 error_code == net::OK) { |
| 330 error_code = net::ERR_FAILED; |
| 331 } |
| 332 |
312 filter_->Send(new ResourceMsg_RequestComplete(routing_id_, | 333 filter_->Send(new ResourceMsg_RequestComplete(routing_id_, |
313 request_id, | 334 request_id, |
314 status, | 335 error_code, |
| 336 was_ignored_by_handler, |
315 security_info, | 337 security_info, |
316 completion_time)); | 338 completion_time)); |
317 | 339 |
318 // If we still have a read buffer, then see about caching it for later... | 340 // If we still have a read buffer, then see about caching it for later... |
319 // Note that we have to make sure the buffer is not still being used, so we | 341 // Note that we have to make sure the buffer is not still being used, so we |
320 // have to perform an explicit check on the status code. | 342 // have to perform an explicit check on the status code. |
321 if (g_spare_read_buffer || | 343 if (g_spare_read_buffer || |
322 net::URLRequestStatus::SUCCESS != status.status()) { | 344 net::URLRequestStatus::SUCCESS != status.status()) { |
323 read_buffer_ = NULL; | 345 read_buffer_ = NULL; |
324 } else if (read_buffer_.get()) { | 346 } else if (read_buffer_.get()) { |
(...skipping 27 matching lines...) Expand all Loading... |
352 } | 374 } |
353 | 375 |
354 void AsyncResourceHandler::ResumeIfDeferred() { | 376 void AsyncResourceHandler::ResumeIfDeferred() { |
355 if (did_defer_) { | 377 if (did_defer_) { |
356 did_defer_ = false; | 378 did_defer_ = false; |
357 controller()->Resume(); | 379 controller()->Resume(); |
358 } | 380 } |
359 } | 381 } |
360 | 382 |
361 } // namespace content | 383 } // namespace content |
OLD | NEW |