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/async_resource_handler.h" | 5 #include "content/browser/loader/async_resource_handler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 base::debug::Alias(url_buf); | 328 base::debug::Alias(url_buf); |
329 | 329 |
330 // TODO(gavinp): Remove this CHECK when we figure out the cause of | 330 // TODO(gavinp): Remove this CHECK when we figure out the cause of |
331 // http://crbug.com/124680 . This check mirrors closely check in | 331 // http://crbug.com/124680 . This check mirrors closely check in |
332 // WebURLLoaderImpl::OnCompletedRequest that routes this message to a WebCore | 332 // WebURLLoaderImpl::OnCompletedRequest that routes this message to a WebCore |
333 // ResourceHandleInternal which asserts on its state and crashes. By crashing | 333 // ResourceHandleInternal which asserts on its state and crashes. By crashing |
334 // when the message is sent, we should get better crash reports. | 334 // when the message is sent, we should get better crash reports. |
335 CHECK(status.status() != net::URLRequestStatus::SUCCESS || | 335 CHECK(status.status() != net::URLRequestStatus::SUCCESS || |
336 sent_received_response_msg_); | 336 sent_received_response_msg_); |
337 | 337 |
338 TimeTicks completion_time = TimeTicks::Now(); | |
339 | |
340 int error_code = status.error(); | 338 int error_code = status.error(); |
341 bool was_ignored_by_handler = info->WasIgnoredByHandler(); | 339 bool was_ignored_by_handler = info->WasIgnoredByHandler(); |
342 | 340 |
343 DCHECK(status.status() != net::URLRequestStatus::IO_PENDING); | 341 DCHECK(status.status() != net::URLRequestStatus::IO_PENDING); |
344 // If this check fails, then we're in an inconsistent state because all | 342 // If this check fails, then we're in an inconsistent state because all |
345 // requests ignored by the handler should be canceled (which should result in | 343 // requests ignored by the handler should be canceled (which should result in |
346 // the ERR_ABORTED error code). | 344 // the ERR_ABORTED error code). |
347 DCHECK(!was_ignored_by_handler || error_code == net::ERR_ABORTED); | 345 DCHECK(!was_ignored_by_handler || error_code == net::ERR_ABORTED); |
348 | 346 |
349 // TODO(mkosiba): Fix up cases where we create a URLRequestStatus | 347 // TODO(mkosiba): Fix up cases where we create a URLRequestStatus |
350 // with a status() != SUCCESS and an error_code() == net::OK. | 348 // with a status() != SUCCESS and an error_code() == net::OK. |
351 if (status.status() == net::URLRequestStatus::CANCELED && | 349 if (status.status() == net::URLRequestStatus::CANCELED && |
352 error_code == net::OK) { | 350 error_code == net::OK) { |
353 error_code = net::ERR_ABORTED; | 351 error_code = net::ERR_ABORTED; |
354 } else if (status.status() == net::URLRequestStatus::FAILED && | 352 } else if (status.status() == net::URLRequestStatus::FAILED && |
355 error_code == net::OK) { | 353 error_code == net::OK) { |
356 error_code = net::ERR_FAILED; | 354 error_code = net::ERR_FAILED; |
357 } | 355 } |
358 | 356 |
| 357 ResourceMsg_RequestCompleteData request_complete_data; |
| 358 request_complete_data.error_code = error_code; |
| 359 request_complete_data.was_ignored_by_handler = was_ignored_by_handler; |
| 360 request_complete_data.exists_in_cache = request()->response_info().was_cached; |
| 361 request_complete_data.security_info = security_info; |
| 362 request_complete_data.completion_time = TimeTicks::Now(); |
359 info->filter()->Send( | 363 info->filter()->Send( |
360 new ResourceMsg_RequestComplete(request_id, | 364 new ResourceMsg_RequestComplete(request_id, request_complete_data)); |
361 error_code, | |
362 was_ignored_by_handler, | |
363 security_info, | |
364 completion_time)); | |
365 } | 365 } |
366 | 366 |
367 bool AsyncResourceHandler::EnsureResourceBufferIsInitialized() { | 367 bool AsyncResourceHandler::EnsureResourceBufferIsInitialized() { |
368 if (buffer_.get() && buffer_->IsInitialized()) | 368 if (buffer_.get() && buffer_->IsInitialized()) |
369 return true; | 369 return true; |
370 | 370 |
371 if (!has_checked_for_sufficient_resources_) { | 371 if (!has_checked_for_sufficient_resources_) { |
372 has_checked_for_sufficient_resources_ = true; | 372 has_checked_for_sufficient_resources_ = true; |
373 if (!rdh_->HasSufficientResourcesForRequest(request())) { | 373 if (!rdh_->HasSufficientResourcesForRequest(request())) { |
374 controller()->CancelWithError(net::ERR_INSUFFICIENT_RESOURCES); | 374 controller()->CancelWithError(net::ERR_INSUFFICIENT_RESOURCES); |
(...skipping 13 matching lines...) Expand all Loading... |
388 request()->LogUnblocked(); | 388 request()->LogUnblocked(); |
389 controller()->Resume(); | 389 controller()->Resume(); |
390 } | 390 } |
391 } | 391 } |
392 | 392 |
393 void AsyncResourceHandler::OnDefer() { | 393 void AsyncResourceHandler::OnDefer() { |
394 request()->LogBlockedBy("AsyncResourceHandler"); | 394 request()->LogBlockedBy("AsyncResourceHandler"); |
395 } | 395 } |
396 | 396 |
397 } // namespace content | 397 } // namespace content |
OLD | NEW |