| 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 "net/url_request/url_fetcher_core.h" | 5 #include "net/url_request/url_fetcher_core.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 "423948 URLFetcherCore::OnReadCompleted")); | 429 "423948 URLFetcherCore::OnReadCompleted")); |
| 430 | 430 |
| 431 DCHECK(request == request_); | 431 DCHECK(request == request_); |
| 432 DCHECK(network_task_runner_->BelongsToCurrentThread()); | 432 DCHECK(network_task_runner_->BelongsToCurrentThread()); |
| 433 | 433 |
| 434 if (!stopped_on_redirect_) | 434 if (!stopped_on_redirect_) |
| 435 url_ = request->url(); | 435 url_ = request->url(); |
| 436 URLRequestThrottlerManager* throttler_manager = | 436 URLRequestThrottlerManager* throttler_manager = |
| 437 request->context()->throttler_manager(); | 437 request->context()->throttler_manager(); |
| 438 if (throttler_manager) { | 438 if (throttler_manager) { |
| 439 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed. |
| 440 tracked_objects::ScopedTracker tracking_profile1( |
| 441 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 442 "423948 URLFetcherCore::OnReadCompleted1")); |
| 443 |
| 439 url_throttler_entry_ = throttler_manager->RegisterRequestUrl(url_); | 444 url_throttler_entry_ = throttler_manager->RegisterRequestUrl(url_); |
| 440 } | 445 } |
| 441 | 446 |
| 447 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed. |
| 448 tracked_objects::ScopedTracker tracking_profile2( |
| 449 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 450 "423948 URLFetcherCore::OnReadCompleted2")); |
| 451 |
| 442 do { | 452 do { |
| 443 if (!request_->status().is_success() || bytes_read <= 0) | 453 if (!request_->status().is_success() || bytes_read <= 0) |
| 444 break; | 454 break; |
| 445 | 455 |
| 456 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed. |
| 457 tracked_objects::ScopedTracker tracking_profile3( |
| 458 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 459 "423948 URLFetcherCore::OnReadCompleted3")); |
| 460 |
| 446 current_response_bytes_ += bytes_read; | 461 current_response_bytes_ += bytes_read; |
| 447 InformDelegateDownloadProgress(); | 462 InformDelegateDownloadProgress(); |
| 448 | 463 |
| 464 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed. |
| 465 tracked_objects::ScopedTracker tracking_profile4( |
| 466 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 467 "423948 URLFetcherCore::OnReadCompleted4")); |
| 468 |
| 449 const int result = | 469 const int result = |
| 450 WriteBuffer(new DrainableIOBuffer(buffer_.get(), bytes_read)); | 470 WriteBuffer(new DrainableIOBuffer(buffer_.get(), bytes_read)); |
| 451 if (result < 0) { | 471 if (result < 0) { |
| 452 // Write failed or waiting for write completion. | 472 // Write failed or waiting for write completion. |
| 453 return; | 473 return; |
| 454 } | 474 } |
| 455 } while (request_->Read(buffer_.get(), kBufferSize, &bytes_read)); | 475 } while (request_->Read(buffer_.get(), kBufferSize, &bytes_read)); |
| 456 | 476 |
| 457 const URLRequestStatus status = request_->status(); | 477 const URLRequestStatus status = request_->status(); |
| 458 | 478 |
| 479 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed. |
| 480 tracked_objects::ScopedTracker tracking_profile5( |
| 481 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 482 "423948 URLFetcherCore::OnReadCompleted5")); |
| 483 |
| 459 if (status.is_success()) | 484 if (status.is_success()) |
| 460 request_->GetResponseCookies(&cookies_); | 485 request_->GetResponseCookies(&cookies_); |
| 461 | 486 |
| 462 // See comments re: HEAD requests in ReadResponse(). | 487 // See comments re: HEAD requests in ReadResponse(). |
| 463 if (!status.is_io_pending() || request_type_ == URLFetcher::HEAD) { | 488 if (!status.is_io_pending() || request_type_ == URLFetcher::HEAD) { |
| 489 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed. |
| 490 tracked_objects::ScopedTracker tracking_profile6( |
| 491 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 492 "423948 URLFetcherCore::OnReadCompleted6")); |
| 493 |
| 464 status_ = status; | 494 status_ = status; |
| 465 ReleaseRequest(); | 495 ReleaseRequest(); |
| 466 | 496 |
| 497 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed. |
| 498 tracked_objects::ScopedTracker tracking_profile7( |
| 499 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 500 "423948 URLFetcherCore::OnReadCompleted7")); |
| 501 |
| 467 // No more data to write. | 502 // No more data to write. |
| 468 const int result = response_writer_->Finish( | 503 const int result = response_writer_->Finish( |
| 469 base::Bind(&URLFetcherCore::DidFinishWriting, this)); | 504 base::Bind(&URLFetcherCore::DidFinishWriting, this)); |
| 505 |
| 506 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed. |
| 507 tracked_objects::ScopedTracker tracking_profile8( |
| 508 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 509 "423948 URLFetcherCore::OnReadCompleted8")); |
| 510 |
| 470 if (result != ERR_IO_PENDING) | 511 if (result != ERR_IO_PENDING) |
| 471 DidFinishWriting(result); | 512 DidFinishWriting(result); |
| 472 } | 513 } |
| 473 } | 514 } |
| 474 | 515 |
| 475 void URLFetcherCore::CancelAll() { | 516 void URLFetcherCore::CancelAll() { |
| 476 g_registry.Get().CancelAll(); | 517 g_registry.Get().CancelAll(); |
| 477 } | 518 } |
| 478 | 519 |
| 479 int URLFetcherCore::GetNumFetcherCores() { | 520 int URLFetcherCore::GetNumFetcherCores() { |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 } | 940 } |
| 900 | 941 |
| 901 void URLFetcherCore::InformDelegateDownloadProgressInDelegateThread( | 942 void URLFetcherCore::InformDelegateDownloadProgressInDelegateThread( |
| 902 int64 current, int64 total) { | 943 int64 current, int64 total) { |
| 903 DCHECK(delegate_task_runner_->BelongsToCurrentThread()); | 944 DCHECK(delegate_task_runner_->BelongsToCurrentThread()); |
| 904 if (delegate_) | 945 if (delegate_) |
| 905 delegate_->OnURLFetchDownloadProgress(fetcher_, current, total); | 946 delegate_->OnURLFetchDownloadProgress(fetcher_, current, total); |
| 906 } | 947 } |
| 907 | 948 |
| 908 } // namespace net | 949 } // namespace net |
| OLD | NEW |