| 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" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/profiler/scoped_tracker.h" |
| 12 #include "base/sequenced_task_runner.h" | 13 #include "base/sequenced_task_runner.h" |
| 13 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
| 14 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
| 15 #include "base/thread_task_runner_handle.h" | 16 #include "base/thread_task_runner_handle.h" |
| 16 #include "base/tracked_objects.h" | 17 #include "base/tracked_objects.h" |
| 17 #include "net/base/elements_upload_data_stream.h" | 18 #include "net/base/elements_upload_data_stream.h" |
| 18 #include "net/base/io_buffer.h" | 19 #include "net/base/io_buffer.h" |
| 19 #include "net/base/load_flags.h" | 20 #include "net/base/load_flags.h" |
| 20 #include "net/base/net_errors.h" | 21 #include "net/base/net_errors.h" |
| 21 #include "net/base/request_priority.h" | 22 #include "net/base/request_priority.h" |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 stopped_on_redirect_ = true; | 383 stopped_on_redirect_ = true; |
| 383 url_ = redirect_info.new_url; | 384 url_ = redirect_info.new_url; |
| 384 response_code_ = request_->GetResponseCode(); | 385 response_code_ = request_->GetResponseCode(); |
| 385 was_fetched_via_proxy_ = request_->was_fetched_via_proxy(); | 386 was_fetched_via_proxy_ = request_->was_fetched_via_proxy(); |
| 386 request->Cancel(); | 387 request->Cancel(); |
| 387 OnReadCompleted(request, 0); | 388 OnReadCompleted(request, 0); |
| 388 } | 389 } |
| 389 } | 390 } |
| 390 | 391 |
| 391 void URLFetcherCore::OnResponseStarted(URLRequest* request) { | 392 void URLFetcherCore::OnResponseStarted(URLRequest* request) { |
| 393 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed. |
| 394 tracked_objects::ScopedTracker tracking_profile( |
| 395 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 396 "423948 URLFetcherCore::OnResponseStarted")); |
| 397 |
| 392 DCHECK_EQ(request, request_.get()); | 398 DCHECK_EQ(request, request_.get()); |
| 393 DCHECK(network_task_runner_->BelongsToCurrentThread()); | 399 DCHECK(network_task_runner_->BelongsToCurrentThread()); |
| 394 if (request_->status().is_success()) { | 400 if (request_->status().is_success()) { |
| 395 response_code_ = request_->GetResponseCode(); | 401 response_code_ = request_->GetResponseCode(); |
| 396 response_headers_ = request_->response_headers(); | 402 response_headers_ = request_->response_headers(); |
| 397 socket_address_ = request_->GetSocketAddress(); | 403 socket_address_ = request_->GetSocketAddress(); |
| 398 was_fetched_via_proxy_ = request_->was_fetched_via_proxy(); | 404 was_fetched_via_proxy_ = request_->was_fetched_via_proxy(); |
| 399 total_response_bytes_ = request_->GetExpectedContentSize(); | 405 total_response_bytes_ = request_->GetExpectedContentSize(); |
| 400 } | 406 } |
| 401 | 407 |
| 402 ReadResponse(); | 408 ReadResponse(); |
| 403 } | 409 } |
| 404 | 410 |
| 405 void URLFetcherCore::OnCertificateRequested( | 411 void URLFetcherCore::OnCertificateRequested( |
| 406 URLRequest* request, | 412 URLRequest* request, |
| 407 SSLCertRequestInfo* cert_request_info) { | 413 SSLCertRequestInfo* cert_request_info) { |
| 408 DCHECK_EQ(request, request_.get()); | 414 DCHECK_EQ(request, request_.get()); |
| 409 DCHECK(network_task_runner_->BelongsToCurrentThread()); | 415 DCHECK(network_task_runner_->BelongsToCurrentThread()); |
| 410 | 416 |
| 411 if (g_ignore_certificate_requests) { | 417 if (g_ignore_certificate_requests) { |
| 412 request->ContinueWithCertificate(NULL); | 418 request->ContinueWithCertificate(NULL); |
| 413 } else { | 419 } else { |
| 414 request->Cancel(); | 420 request->Cancel(); |
| 415 } | 421 } |
| 416 } | 422 } |
| 417 | 423 |
| 418 void URLFetcherCore::OnReadCompleted(URLRequest* request, | 424 void URLFetcherCore::OnReadCompleted(URLRequest* request, |
| 419 int bytes_read) { | 425 int bytes_read) { |
| 426 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed. |
| 427 tracked_objects::ScopedTracker tracking_profile( |
| 428 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 429 "423948 URLFetcherCore::OnReadCompleted")); |
| 430 |
| 420 DCHECK(request == request_); | 431 DCHECK(request == request_); |
| 421 DCHECK(network_task_runner_->BelongsToCurrentThread()); | 432 DCHECK(network_task_runner_->BelongsToCurrentThread()); |
| 422 | 433 |
| 423 if (!stopped_on_redirect_) | 434 if (!stopped_on_redirect_) |
| 424 url_ = request->url(); | 435 url_ = request->url(); |
| 425 URLRequestThrottlerManager* throttler_manager = | 436 URLRequestThrottlerManager* throttler_manager = |
| 426 request->context()->throttler_manager(); | 437 request->context()->throttler_manager(); |
| 427 if (throttler_manager) { | 438 if (throttler_manager) { |
| 428 url_throttler_entry_ = throttler_manager->RegisterRequestUrl(url_); | 439 url_throttler_entry_ = throttler_manager->RegisterRequestUrl(url_); |
| 429 } | 440 } |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 } | 899 } |
| 889 | 900 |
| 890 void URLFetcherCore::InformDelegateDownloadProgressInDelegateThread( | 901 void URLFetcherCore::InformDelegateDownloadProgressInDelegateThread( |
| 891 int64 current, int64 total) { | 902 int64 current, int64 total) { |
| 892 DCHECK(delegate_task_runner_->BelongsToCurrentThread()); | 903 DCHECK(delegate_task_runner_->BelongsToCurrentThread()); |
| 893 if (delegate_) | 904 if (delegate_) |
| 894 delegate_->OnURLFetchDownloadProgress(fetcher_, current, total); | 905 delegate_->OnURLFetchDownloadProgress(fetcher_, current, total); |
| 895 } | 906 } |
| 896 | 907 |
| 897 } // namespace net | 908 } // namespace net |
| OLD | NEW |