| 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_request_http_job.h" | 5 #include "net/url_request/url_request_http_job.h" |
| 6 | 6 |
| 7 #include "base/trace_event/trace_event.h" |
| 7 #include "base/base_switches.h" | 8 #include "base/base_switches.h" |
| 8 #include "base/bind.h" | 9 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 10 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 11 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 12 #include "base/file_version_info.h" | 13 #include "base/file_version_info.h" |
| 13 #include "base/location.h" | 14 #include "base/location.h" |
| 14 #include "base/macros.h" | 15 #include "base/macros.h" |
| 15 #include "base/metrics/field_trial.h" | 16 #include "base/metrics/field_trial.h" |
| 16 #include "base/metrics/histogram_macros.h" | 17 #include "base/metrics/histogram_macros.h" |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 DoneWithRequest(ABORTED); | 236 DoneWithRequest(ABORTED); |
| 236 } | 237 } |
| 237 | 238 |
| 238 void URLRequestHttpJob::SetPriority(RequestPriority priority) { | 239 void URLRequestHttpJob::SetPriority(RequestPriority priority) { |
| 239 priority_ = priority; | 240 priority_ = priority; |
| 240 if (transaction_) | 241 if (transaction_) |
| 241 transaction_->SetPriority(priority_); | 242 transaction_->SetPriority(priority_); |
| 242 } | 243 } |
| 243 | 244 |
| 244 void URLRequestHttpJob::Start() { | 245 void URLRequestHttpJob::Start() { |
| 246 TRACE_EVENT0("toplevel", "URLRequestHttpJob::Start"); |
| 245 // TODO(mmenke): Remove ScopedTracker below once crbug.com/456327 is fixed. | 247 // TODO(mmenke): Remove ScopedTracker below once crbug.com/456327 is fixed. |
| 246 tracked_objects::ScopedTracker tracking_profile( | 248 tracked_objects::ScopedTracker tracking_profile( |
| 247 FROM_HERE_WITH_EXPLICIT_FUNCTION("456327 URLRequestHttpJob::Start")); | 249 FROM_HERE_WITH_EXPLICIT_FUNCTION("456327 URLRequestHttpJob::Start")); |
| 248 | 250 |
| 249 DCHECK(!transaction_.get()); | 251 DCHECK(!transaction_.get()); |
| 250 | 252 |
| 251 // URLRequest::SetReferrer ensures that we do not send username and password | 253 // URLRequest::SetReferrer ensures that we do not send username and password |
| 252 // fields in the referrer. | 254 // fields in the referrer. |
| 253 GURL referrer(request_->referrer()); | 255 GURL referrer(request_->referrer()); |
| 254 | 256 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 281 request_info_.extra_headers.SetHeaderIfMissing( | 283 request_info_.extra_headers.SetHeaderIfMissing( |
| 282 HttpRequestHeaders::kUserAgent, | 284 HttpRequestHeaders::kUserAgent, |
| 283 http_user_agent_settings_ ? | 285 http_user_agent_settings_ ? |
| 284 http_user_agent_settings_->GetUserAgent() : std::string()); | 286 http_user_agent_settings_->GetUserAgent() : std::string()); |
| 285 | 287 |
| 286 AddExtraHeaders(); | 288 AddExtraHeaders(); |
| 287 AddCookieHeaderAndStart(); | 289 AddCookieHeaderAndStart(); |
| 288 } | 290 } |
| 289 | 291 |
| 290 void URLRequestHttpJob::Kill() { | 292 void URLRequestHttpJob::Kill() { |
| 293 TRACE_EVENT0("toplevel", "URLRequestHttpJob::Kill"); |
| 291 weak_factory_.InvalidateWeakPtrs(); | 294 weak_factory_.InvalidateWeakPtrs(); |
| 292 if (transaction_) | 295 if (transaction_) |
| 293 DestroyTransaction(); | 296 DestroyTransaction(); |
| 294 URLRequestJob::Kill(); | 297 URLRequestJob::Kill(); |
| 295 } | 298 } |
| 296 | 299 |
| 297 void URLRequestHttpJob::GetConnectionAttempts(ConnectionAttempts* out) const { | 300 void URLRequestHttpJob::GetConnectionAttempts(ConnectionAttempts* out) const { |
| 298 if (transaction_) | 301 if (transaction_) |
| 299 transaction_->GetConnectionAttempts(out); | 302 transaction_->GetConnectionAttempts(out); |
| 300 else | 303 else |
| 301 out->clear(); | 304 out->clear(); |
| 302 } | 305 } |
| 303 | 306 |
| 304 void URLRequestHttpJob::NotifyBeforeSendProxyHeadersCallback( | 307 void URLRequestHttpJob::NotifyBeforeSendProxyHeadersCallback( |
| 305 const ProxyInfo& proxy_info, | 308 const ProxyInfo& proxy_info, |
| 306 HttpRequestHeaders* request_headers) { | 309 HttpRequestHeaders* request_headers) { |
| 307 DCHECK(request_headers); | 310 DCHECK(request_headers); |
| 308 DCHECK_NE(URLRequestStatus::CANCELED, GetStatus().status()); | 311 DCHECK_NE(URLRequestStatus::CANCELED, GetStatus().status()); |
| 309 if (network_delegate()) { | 312 if (network_delegate()) { |
| 310 network_delegate()->NotifyBeforeSendProxyHeaders( | 313 network_delegate()->NotifyBeforeSendProxyHeaders( |
| 311 request_, | 314 request_, |
| 312 proxy_info, | 315 proxy_info, |
| 313 request_headers); | 316 request_headers); |
| 314 } | 317 } |
| 315 } | 318 } |
| 316 | 319 |
| 317 void URLRequestHttpJob::NotifyBeforeNetworkStart(bool* defer) { | 320 void URLRequestHttpJob::NotifyBeforeNetworkStart(bool* defer) { |
| 321 TRACE_EVENT0("toplevel", "URLRequestHttpJob::NotifyBeforeNetworkStart"); |
| 318 if (!request_) | 322 if (!request_) |
| 319 return; | 323 return; |
| 320 if (backoff_manager_) { | 324 if (backoff_manager_) { |
| 321 if ((request_->load_flags() & LOAD_MAYBE_USER_GESTURE) == 0 && | 325 if ((request_->load_flags() & LOAD_MAYBE_USER_GESTURE) == 0 && |
| 322 backoff_manager_->ShouldRejectRequest(request()->url(), | 326 backoff_manager_->ShouldRejectRequest(request()->url(), |
| 323 request()->request_time())) { | 327 request()->request_time())) { |
| 324 *defer = true; | 328 *defer = true; |
| 325 base::MessageLoop::current()->PostTask( | 329 base::MessageLoop::current()->PostTask( |
| 326 FROM_HERE, | 330 FROM_HERE, |
| 327 base::Bind(&URLRequestHttpJob::OnStartCompleted, | 331 base::Bind(&URLRequestHttpJob::OnStartCompleted, |
| 328 weak_factory_.GetWeakPtr(), ERR_TEMPORARY_BACKOFF)); | 332 weak_factory_.GetWeakPtr(), ERR_TEMPORARY_BACKOFF)); |
| 329 return; | 333 return; |
| 330 } | 334 } |
| 331 } | 335 } |
| 332 URLRequestJob::NotifyBeforeNetworkStart(defer); | 336 URLRequestJob::NotifyBeforeNetworkStart(defer); |
| 333 } | 337 } |
| 334 | 338 |
| 335 void URLRequestHttpJob::NotifyHeadersComplete() { | 339 void URLRequestHttpJob::NotifyHeadersComplete() { |
| 340 TRACE_EVENT0("toplevel", "URLRequestHttpJob::NotifyHeadersComplete"); |
| 336 DCHECK(!response_info_); | 341 DCHECK(!response_info_); |
| 337 | 342 |
| 338 response_info_ = transaction_->GetResponseInfo(); | 343 response_info_ = transaction_->GetResponseInfo(); |
| 339 | 344 |
| 340 // Save boolean, as we'll need this info at destruction time, and filters may | 345 // Save boolean, as we'll need this info at destruction time, and filters may |
| 341 // also need this info. | 346 // also need this info. |
| 342 is_cached_content_ = response_info_->was_cached; | 347 is_cached_content_ = response_info_->was_cached; |
| 343 | 348 |
| 344 if (!is_cached_content_ && throttling_entry_.get()) | 349 if (!is_cached_content_ && throttling_entry_.get()) |
| 345 throttling_entry_->UpdateWithResponse(GetResponseCode()); | 350 throttling_entry_->UpdateWithResponse(GetResponseCode()); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 // where OnBeforeSendHeaders -> OnSendHeaders -> OnBeforeSendHeaders | 425 // where OnBeforeSendHeaders -> OnSendHeaders -> OnBeforeSendHeaders |
| 421 // occurs. | 426 // occurs. |
| 422 RestartTransactionWithAuth(AuthCredentials()); | 427 RestartTransactionWithAuth(AuthCredentials()); |
| 423 return; | 428 return; |
| 424 } | 429 } |
| 425 | 430 |
| 426 URLRequestJob::NotifyHeadersComplete(); | 431 URLRequestJob::NotifyHeadersComplete(); |
| 427 } | 432 } |
| 428 | 433 |
| 429 void URLRequestHttpJob::DestroyTransaction() { | 434 void URLRequestHttpJob::DestroyTransaction() { |
| 435 TRACE_EVENT0("toplevel", "URLRequestHttpJob::DestroyTransaction"); |
| 436 |
| 430 DCHECK(transaction_.get()); | 437 DCHECK(transaction_.get()); |
| 431 | 438 |
| 432 DoneWithRequest(ABORTED); | 439 DoneWithRequest(ABORTED); |
| 433 | 440 |
| 434 total_received_bytes_from_previous_transactions_ += | 441 total_received_bytes_from_previous_transactions_ += |
| 435 transaction_->GetTotalReceivedBytes(); | 442 transaction_->GetTotalReceivedBytes(); |
| 436 total_sent_bytes_from_previous_transactions_ += | 443 total_sent_bytes_from_previous_transactions_ += |
| 437 transaction_->GetTotalSentBytes(); | 444 transaction_->GetTotalSentBytes(); |
| 438 transaction_.reset(); | 445 { |
| 446 TRACE_EVENT0("toplevel", |
| 447 "URLRequestHttpJob::DestroyTransaction::ResetHttpTransaction"); |
| 448 transaction_.reset(); |
| 449 } |
| 439 response_info_ = NULL; | 450 response_info_ = NULL; |
| 440 receive_headers_end_ = base::TimeTicks(); | 451 receive_headers_end_ = base::TimeTicks(); |
| 441 } | 452 } |
| 442 | 453 |
| 443 void URLRequestHttpJob::StartTransaction() { | 454 void URLRequestHttpJob::StartTransaction() { |
| 444 // TODO(mmenke): Remove ScopedTracker below once crbug.com/456327 is fixed. | 455 // TODO(mmenke): Remove ScopedTracker below once crbug.com/456327 is fixed. |
| 445 tracked_objects::ScopedTracker tracking_profile( | 456 tracked_objects::ScopedTracker tracking_profile( |
| 446 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 457 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 447 "456327 URLRequestHttpJob::StartTransaction")); | 458 "456327 URLRequestHttpJob::StartTransaction")); |
| 448 | 459 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 479 StartTransactionInternal(); | 490 StartTransactionInternal(); |
| 480 } else { | 491 } else { |
| 481 std::string source("delegate"); | 492 std::string source("delegate"); |
| 482 request_->net_log().AddEvent(NetLog::TYPE_CANCELLED, | 493 request_->net_log().AddEvent(NetLog::TYPE_CANCELLED, |
| 483 NetLog::StringCallback("source", &source)); | 494 NetLog::StringCallback("source", &source)); |
| 484 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, result)); | 495 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, result)); |
| 485 } | 496 } |
| 486 } | 497 } |
| 487 | 498 |
| 488 void URLRequestHttpJob::StartTransactionInternal() { | 499 void URLRequestHttpJob::StartTransactionInternal() { |
| 500 TRACE_EVENT0("toplevel", "URLRequestHttpJob::StartTransactionInternal"); |
| 489 // This should only be called while the request's status is IO_PENDING. | 501 // This should only be called while the request's status is IO_PENDING. |
| 490 DCHECK_EQ(URLRequestStatus::IO_PENDING, request_->status().status()); | 502 DCHECK_EQ(URLRequestStatus::IO_PENDING, request_->status().status()); |
| 491 | 503 |
| 492 // NOTE: This method assumes that request_info_ is already setup properly. | 504 // NOTE: This method assumes that request_info_ is already setup properly. |
| 493 | 505 |
| 494 // If we already have a transaction, then we should restart the transaction | 506 // If we already have a transaction, then we should restart the transaction |
| 495 // with auth provided by auth_credentials_. | 507 // with auth provided by auth_credentials_. |
| 496 | 508 |
| 497 bool invalid_header_values_in_rfc7230 = false; | 509 bool invalid_header_values_in_rfc7230 = false; |
| 498 for (HttpRequestHeaders::Iterator it(request_info_.extra_headers); | 510 for (HttpRequestHeaders::Iterator it(request_info_.extra_headers); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 http_user_agent_settings_->GetAcceptLanguage(); | 666 http_user_agent_settings_->GetAcceptLanguage(); |
| 655 if (!accept_language.empty()) { | 667 if (!accept_language.empty()) { |
| 656 request_info_.extra_headers.SetHeaderIfMissing( | 668 request_info_.extra_headers.SetHeaderIfMissing( |
| 657 HttpRequestHeaders::kAcceptLanguage, | 669 HttpRequestHeaders::kAcceptLanguage, |
| 658 accept_language); | 670 accept_language); |
| 659 } | 671 } |
| 660 } | 672 } |
| 661 } | 673 } |
| 662 | 674 |
| 663 void URLRequestHttpJob::AddCookieHeaderAndStart() { | 675 void URLRequestHttpJob::AddCookieHeaderAndStart() { |
| 676 TRACE_EVENT0("toplevel", "URLRequestHttpJob::AddCookieHeaderAndStart"); |
| 677 |
| 664 // If the request was destroyed, then there is no more work to do. | 678 // If the request was destroyed, then there is no more work to do. |
| 665 if (!request_) | 679 if (!request_) |
| 666 return; | 680 return; |
| 667 | 681 |
| 668 CookieStore* cookie_store = request_->context()->cookie_store(); | 682 CookieStore* cookie_store = request_->context()->cookie_store(); |
| 669 if (cookie_store && !(request_info_.load_flags & LOAD_DO_NOT_SEND_COOKIES)) { | 683 if (cookie_store && !(request_info_.load_flags & LOAD_DO_NOT_SEND_COOKIES)) { |
| 670 CookieOptions options; | 684 CookieOptions options; |
| 671 options.set_include_httponly(); | 685 options.set_include_httponly(); |
| 672 | 686 |
| 673 // TODO(mkwst): If same-site cookies aren't enabled, pretend the request is | 687 // TODO(mkwst): If same-site cookies aren't enabled, pretend the request is |
| (...skipping 24 matching lines...) Expand all Loading... |
| 698 if (cookie_list.size() && CanGetCookies(cookie_list)) { | 712 if (cookie_list.size() && CanGetCookies(cookie_list)) { |
| 699 request_info_.extra_headers.SetHeader( | 713 request_info_.extra_headers.SetHeader( |
| 700 HttpRequestHeaders::kCookie, CookieStore::BuildCookieLine(cookie_list)); | 714 HttpRequestHeaders::kCookie, CookieStore::BuildCookieLine(cookie_list)); |
| 701 // Disable privacy mode as we are sending cookies anyway. | 715 // Disable privacy mode as we are sending cookies anyway. |
| 702 request_info_.privacy_mode = PRIVACY_MODE_DISABLED; | 716 request_info_.privacy_mode = PRIVACY_MODE_DISABLED; |
| 703 } | 717 } |
| 704 DoStartTransaction(); | 718 DoStartTransaction(); |
| 705 } | 719 } |
| 706 | 720 |
| 707 void URLRequestHttpJob::DoStartTransaction() { | 721 void URLRequestHttpJob::DoStartTransaction() { |
| 722 TRACE_EVENT0("toplevel", "URLRequestHttpJob::DoStartTransaction"); |
| 708 // We may have been canceled while retrieving cookies. | 723 // We may have been canceled while retrieving cookies. |
| 709 if (GetStatus().is_success()) { | 724 if (GetStatus().is_success()) { |
| 710 StartTransaction(); | 725 StartTransaction(); |
| 711 } else { | 726 } else { |
| 712 NotifyCanceled(); | 727 NotifyCanceled(); |
| 713 } | 728 } |
| 714 } | 729 } |
| 715 | 730 |
| 716 void URLRequestHttpJob::SaveCookiesAndNotifyHeadersComplete(int result) { | 731 void URLRequestHttpJob::SaveCookiesAndNotifyHeadersComplete(int result) { |
| 732 TRACE_EVENT0("toplevel", |
| 733 "URLRequestHttpJob::SaveCookiesAndNotifyHeadersComplete"); |
| 717 // End of the call started in OnStartCompleted. | 734 // End of the call started in OnStartCompleted. |
| 718 OnCallToDelegateComplete(); | 735 OnCallToDelegateComplete(); |
| 719 | 736 |
| 720 if (result != OK) { | 737 if (result != OK) { |
| 721 std::string source("delegate"); | 738 std::string source("delegate"); |
| 722 request_->net_log().AddEvent(NetLog::TYPE_CANCELLED, | 739 request_->net_log().AddEvent(NetLog::TYPE_CANCELLED, |
| 723 NetLog::StringCallback("source", &source)); | 740 NetLog::StringCallback("source", &source)); |
| 724 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, result)); | 741 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, result)); |
| 725 return; | 742 return; |
| 726 } | 743 } |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 if (headers->EnumerateHeader(nullptr, "Public-Key-Pins", &value)) | 861 if (headers->EnumerateHeader(nullptr, "Public-Key-Pins", &value)) |
| 845 security_state->AddHPKPHeader(request_info_.url.host(), value, ssl_info); | 862 security_state->AddHPKPHeader(request_info_.url.host(), value, ssl_info); |
| 846 if (headers->EnumerateHeader(nullptr, "Public-Key-Pins-Report-Only", | 863 if (headers->EnumerateHeader(nullptr, "Public-Key-Pins-Report-Only", |
| 847 &value)) { | 864 &value)) { |
| 848 security_state->ProcessHPKPReportOnlyHeader( | 865 security_state->ProcessHPKPReportOnlyHeader( |
| 849 value, HostPortPair::FromURL(request_info_.url), ssl_info); | 866 value, HostPortPair::FromURL(request_info_.url), ssl_info); |
| 850 } | 867 } |
| 851 } | 868 } |
| 852 | 869 |
| 853 void URLRequestHttpJob::OnStartCompleted(int result) { | 870 void URLRequestHttpJob::OnStartCompleted(int result) { |
| 871 TRACE_EVENT0("toplevel", "URLRequestHttpJob::OnStartCompleted"); |
| 854 RecordTimer(); | 872 RecordTimer(); |
| 855 | 873 |
| 856 // If the request was destroyed, then there is no more work to do. | 874 // If the request was destroyed, then there is no more work to do. |
| 857 if (!request_) | 875 if (!request_) |
| 858 return; | 876 return; |
| 859 | 877 |
| 860 // If the job is done (due to cancellation), can just ignore this | 878 // If the job is done (due to cancellation), can just ignore this |
| 861 // notification. | 879 // notification. |
| 862 if (done_) | 880 if (done_) |
| 863 return; | 881 return; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 939 } else { | 957 } else { |
| 940 // Even on an error, there may be useful information in the response | 958 // Even on an error, there may be useful information in the response |
| 941 // info (e.g. whether there's a cached copy). | 959 // info (e.g. whether there's a cached copy). |
| 942 if (transaction_.get()) | 960 if (transaction_.get()) |
| 943 response_info_ = transaction_->GetResponseInfo(); | 961 response_info_ = transaction_->GetResponseInfo(); |
| 944 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, result)); | 962 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, result)); |
| 945 } | 963 } |
| 946 } | 964 } |
| 947 | 965 |
| 948 void URLRequestHttpJob::OnHeadersReceivedCallback(int result) { | 966 void URLRequestHttpJob::OnHeadersReceivedCallback(int result) { |
| 967 TRACE_EVENT0("toplevel", "URLRequestHttpJob::OnHeadersReceivedCallback"); |
| 949 awaiting_callback_ = false; | 968 awaiting_callback_ = false; |
| 950 | 969 |
| 951 // Check that there are no callbacks to already canceled requests. | 970 // Check that there are no callbacks to already canceled requests. |
| 952 DCHECK_NE(URLRequestStatus::CANCELED, GetStatus().status()); | 971 DCHECK_NE(URLRequestStatus::CANCELED, GetStatus().status()); |
| 953 | 972 |
| 954 SaveCookiesAndNotifyHeadersComplete(result); | 973 SaveCookiesAndNotifyHeadersComplete(result); |
| 955 } | 974 } |
| 956 | 975 |
| 957 void URLRequestHttpJob::OnReadCompleted(int result) { | 976 void URLRequestHttpJob::OnReadCompleted(int result) { |
| 958 read_in_progress_ = false; | 977 read_in_progress_ = false; |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1181 proxy_auth_state_ = AUTH_STATE_HAVE_AUTH; | 1200 proxy_auth_state_ = AUTH_STATE_HAVE_AUTH; |
| 1182 } else { | 1201 } else { |
| 1183 DCHECK_EQ(server_auth_state_, AUTH_STATE_NEED_AUTH); | 1202 DCHECK_EQ(server_auth_state_, AUTH_STATE_NEED_AUTH); |
| 1184 server_auth_state_ = AUTH_STATE_HAVE_AUTH; | 1203 server_auth_state_ = AUTH_STATE_HAVE_AUTH; |
| 1185 } | 1204 } |
| 1186 | 1205 |
| 1187 RestartTransactionWithAuth(credentials); | 1206 RestartTransactionWithAuth(credentials); |
| 1188 } | 1207 } |
| 1189 | 1208 |
| 1190 void URLRequestHttpJob::CancelAuth() { | 1209 void URLRequestHttpJob::CancelAuth() { |
| 1210 TRACE_EVENT0("toplevel", "URLRequestHttpJob::CancelAuth"); |
| 1191 // Proxy gets set first, then WWW. | 1211 // Proxy gets set first, then WWW. |
| 1192 if (proxy_auth_state_ == AUTH_STATE_NEED_AUTH) { | 1212 if (proxy_auth_state_ == AUTH_STATE_NEED_AUTH) { |
| 1193 proxy_auth_state_ = AUTH_STATE_CANCELED; | 1213 proxy_auth_state_ = AUTH_STATE_CANCELED; |
| 1194 } else { | 1214 } else { |
| 1195 DCHECK_EQ(server_auth_state_, AUTH_STATE_NEED_AUTH); | 1215 DCHECK_EQ(server_auth_state_, AUTH_STATE_NEED_AUTH); |
| 1196 server_auth_state_ = AUTH_STATE_CANCELED; | 1216 server_auth_state_ = AUTH_STATE_CANCELED; |
| 1197 } | 1217 } |
| 1198 | 1218 |
| 1199 // These will be reset in OnStartCompleted. | 1219 // These will be reset in OnStartCompleted. |
| 1200 response_info_ = NULL; | 1220 response_info_ = NULL; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1211 // We have to do this via InvokeLater to avoid "recursing" the consumer. | 1231 // We have to do this via InvokeLater to avoid "recursing" the consumer. |
| 1212 // | 1232 // |
| 1213 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1233 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 1214 FROM_HERE, base::Bind(&URLRequestHttpJob::OnStartCompleted, | 1234 FROM_HERE, base::Bind(&URLRequestHttpJob::OnStartCompleted, |
| 1215 weak_factory_.GetWeakPtr(), OK)); | 1235 weak_factory_.GetWeakPtr(), OK)); |
| 1216 } | 1236 } |
| 1217 | 1237 |
| 1218 void URLRequestHttpJob::ContinueWithCertificate( | 1238 void URLRequestHttpJob::ContinueWithCertificate( |
| 1219 X509Certificate* client_cert, | 1239 X509Certificate* client_cert, |
| 1220 SSLPrivateKey* client_private_key) { | 1240 SSLPrivateKey* client_private_key) { |
| 1241 TRACE_EVENT0("toplevel", "URLRequestHttpJob::ContinueWithCertificate"); |
| 1221 DCHECK(transaction_.get()); | 1242 DCHECK(transaction_.get()); |
| 1222 | 1243 |
| 1223 DCHECK(!response_info_) << "should not have a response yet"; | 1244 DCHECK(!response_info_) << "should not have a response yet"; |
| 1224 receive_headers_end_ = base::TimeTicks(); | 1245 receive_headers_end_ = base::TimeTicks(); |
| 1225 | 1246 |
| 1226 ResetTimer(); | 1247 ResetTimer(); |
| 1227 | 1248 |
| 1228 int rv = transaction_->RestartWithCertificate(client_cert, client_private_key, | 1249 int rv = transaction_->RestartWithCertificate(client_cert, client_private_key, |
| 1229 start_callback_); | 1250 start_callback_); |
| 1230 if (rv == ERR_IO_PENDING) | 1251 if (rv == ERR_IO_PENDING) |
| 1231 return; | 1252 return; |
| 1232 | 1253 |
| 1233 // The transaction started synchronously, but we need to notify the | 1254 // The transaction started synchronously, but we need to notify the |
| 1234 // URLRequest delegate via the message loop. | 1255 // URLRequest delegate via the message loop. |
| 1235 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1256 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 1236 FROM_HERE, base::Bind(&URLRequestHttpJob::OnStartCompleted, | 1257 FROM_HERE, base::Bind(&URLRequestHttpJob::OnStartCompleted, |
| 1237 weak_factory_.GetWeakPtr(), rv)); | 1258 weak_factory_.GetWeakPtr(), rv)); |
| 1238 } | 1259 } |
| 1239 | 1260 |
| 1240 void URLRequestHttpJob::ContinueDespiteLastError() { | 1261 void URLRequestHttpJob::ContinueDespiteLastError() { |
| 1262 TRACE_EVENT0("toplevel", "URLRequestHttpJob::ContinueDespiteLastError"); |
| 1241 // If the transaction was destroyed, then the job was cancelled. | 1263 // If the transaction was destroyed, then the job was cancelled. |
| 1242 if (!transaction_.get()) | 1264 if (!transaction_.get()) |
| 1243 return; | 1265 return; |
| 1244 | 1266 |
| 1245 DCHECK(!response_info_) << "should not have a response yet"; | 1267 DCHECK(!response_info_) << "should not have a response yet"; |
| 1246 receive_headers_end_ = base::TimeTicks(); | 1268 receive_headers_end_ = base::TimeTicks(); |
| 1247 | 1269 |
| 1248 ResetTimer(); | 1270 ResetTimer(); |
| 1249 | 1271 |
| 1250 int rv = transaction_->RestartIgnoringLastError(start_callback_); | 1272 int rv = transaction_->RestartIgnoringLastError(start_callback_); |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1492 } | 1514 } |
| 1493 | 1515 |
| 1494 if (request_info_.load_flags & LOAD_PREFETCH && !request_->was_cached()) | 1516 if (request_info_.load_flags & LOAD_PREFETCH && !request_->was_cached()) |
| 1495 UMA_HISTOGRAM_COUNTS("Net.Prefetch.PrefilterBytesReadFromNetwork", | 1517 UMA_HISTOGRAM_COUNTS("Net.Prefetch.PrefilterBytesReadFromNetwork", |
| 1496 prefilter_bytes_read()); | 1518 prefilter_bytes_read()); |
| 1497 | 1519 |
| 1498 start_time_ = base::TimeTicks(); | 1520 start_time_ = base::TimeTicks(); |
| 1499 } | 1521 } |
| 1500 | 1522 |
| 1501 void URLRequestHttpJob::DoneWithRequest(CompletionCause reason) { | 1523 void URLRequestHttpJob::DoneWithRequest(CompletionCause reason) { |
| 1524 TRACE_EVENT0("toplevel", "URLRequestHttpJob::DoneWithRequest"); |
| 1502 if (done_) | 1525 if (done_) |
| 1503 return; | 1526 return; |
| 1504 done_ = true; | 1527 done_ = true; |
| 1505 | 1528 |
| 1506 // Notify NetworkQualityEstimator. | 1529 // Notify NetworkQualityEstimator. |
| 1507 if (request() && (reason == FINISHED || reason == ABORTED)) { | 1530 if (request() && (reason == FINISHED || reason == ABORTED)) { |
| 1508 NetworkQualityEstimator* network_quality_estimator = | 1531 NetworkQualityEstimator* network_quality_estimator = |
| 1509 request()->context()->network_quality_estimator(); | 1532 request()->context()->network_quality_estimator(); |
| 1510 if (network_quality_estimator) | 1533 if (network_quality_estimator) |
| 1511 network_quality_estimator->NotifyRequestCompleted(*request()); | 1534 network_quality_estimator->NotifyRequestCompleted(*request()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1522 return override_response_headers_.get() ? | 1545 return override_response_headers_.get() ? |
| 1523 override_response_headers_.get() : | 1546 override_response_headers_.get() : |
| 1524 transaction_->GetResponseInfo()->headers.get(); | 1547 transaction_->GetResponseInfo()->headers.get(); |
| 1525 } | 1548 } |
| 1526 | 1549 |
| 1527 void URLRequestHttpJob::NotifyURLRequestDestroyed() { | 1550 void URLRequestHttpJob::NotifyURLRequestDestroyed() { |
| 1528 awaiting_callback_ = false; | 1551 awaiting_callback_ = false; |
| 1529 } | 1552 } |
| 1530 | 1553 |
| 1531 } // namespace net | 1554 } // namespace net |
| OLD | NEW |