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/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 #include "net/cookies/cookie_store.h" | 34 #include "net/cookies/cookie_store.h" |
35 #include "net/http/http_content_disposition.h" | 35 #include "net/http/http_content_disposition.h" |
36 #include "net/http/http_network_session.h" | 36 #include "net/http/http_network_session.h" |
37 #include "net/http/http_request_headers.h" | 37 #include "net/http/http_request_headers.h" |
38 #include "net/http/http_response_headers.h" | 38 #include "net/http/http_response_headers.h" |
39 #include "net/http/http_response_info.h" | 39 #include "net/http/http_response_info.h" |
40 #include "net/http/http_status_code.h" | 40 #include "net/http/http_status_code.h" |
41 #include "net/http/http_transaction.h" | 41 #include "net/http/http_transaction.h" |
42 #include "net/http/http_transaction_factory.h" | 42 #include "net/http/http_transaction_factory.h" |
43 #include "net/http/http_util.h" | 43 #include "net/http/http_util.h" |
| 44 #include "net/log/net_log_event_type.h" |
44 #include "net/nqe/network_quality_estimator.h" | 45 #include "net/nqe/network_quality_estimator.h" |
45 #include "net/proxy/proxy_info.h" | 46 #include "net/proxy/proxy_info.h" |
46 #include "net/proxy/proxy_retry_info.h" | 47 #include "net/proxy/proxy_retry_info.h" |
47 #include "net/proxy/proxy_service.h" | 48 #include "net/proxy/proxy_service.h" |
48 #include "net/ssl/channel_id_service.h" | 49 #include "net/ssl/channel_id_service.h" |
49 #include "net/ssl/ssl_cert_request_info.h" | 50 #include "net/ssl/ssl_cert_request_info.h" |
50 #include "net/ssl/ssl_config_service.h" | 51 #include "net/ssl/ssl_config_service.h" |
51 #include "net/url_request/http_user_agent_settings.h" | 52 #include "net/url_request/http_user_agent_settings.h" |
52 #include "net/url_request/url_request.h" | 53 #include "net/url_request/url_request.h" |
53 #include "net/url_request/url_request_context.h" | 54 #include "net/url_request/url_request_context.h" |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 ProcessPublicKeyPinsHeader(); | 441 ProcessPublicKeyPinsHeader(); |
441 ProcessExpectCTHeader(); | 442 ProcessExpectCTHeader(); |
442 | 443 |
443 // Handle the server notification of a new SDCH dictionary. | 444 // Handle the server notification of a new SDCH dictionary. |
444 SdchManager* sdch_manager(request()->context()->sdch_manager()); | 445 SdchManager* sdch_manager(request()->context()->sdch_manager()); |
445 if (sdch_manager) { | 446 if (sdch_manager) { |
446 SdchProblemCode rv = sdch_manager->IsInSupportedDomain(request()->url()); | 447 SdchProblemCode rv = sdch_manager->IsInSupportedDomain(request()->url()); |
447 if (rv != SDCH_OK) { | 448 if (rv != SDCH_OK) { |
448 SdchManager::SdchErrorRecovery(rv); | 449 SdchManager::SdchErrorRecovery(rv); |
449 request()->net_log().AddEvent( | 450 request()->net_log().AddEvent( |
450 NetLog::TYPE_SDCH_DECODING_ERROR, | 451 NetLogEventType::SDCH_DECODING_ERROR, |
451 base::Bind(&NetLogSdchResourceProblemCallback, rv)); | 452 base::Bind(&NetLogSdchResourceProblemCallback, rv)); |
452 } else { | 453 } else { |
453 const std::string name = "Get-Dictionary"; | 454 const std::string name = "Get-Dictionary"; |
454 std::string url_text; | 455 std::string url_text; |
455 size_t iter = 0; | 456 size_t iter = 0; |
456 // TODO(jar): We need to not fetch dictionaries the first time they are | 457 // TODO(jar): We need to not fetch dictionaries the first time they are |
457 // seen, but rather wait until we can justify their usefulness. | 458 // seen, but rather wait until we can justify their usefulness. |
458 // For now, we will only fetch the first dictionary, which will at least | 459 // For now, we will only fetch the first dictionary, which will at least |
459 // require multiple suggestions before we get additional ones for this | 460 // require multiple suggestions before we get additional ones for this |
460 // site. Eventually we should wait until a dictionary is requested | 461 // site. Eventually we should wait until a dictionary is requested |
461 // several times | 462 // several times |
462 // before we even download it (so that we don't waste memory or | 463 // before we even download it (so that we don't waste memory or |
463 // bandwidth). | 464 // bandwidth). |
464 if (GetResponseHeaders()->EnumerateHeader(&iter, name, &url_text)) { | 465 if (GetResponseHeaders()->EnumerateHeader(&iter, name, &url_text)) { |
465 // Resolve suggested URL relative to request url. | 466 // Resolve suggested URL relative to request url. |
466 GURL sdch_dictionary_url = request_->url().Resolve(url_text); | 467 GURL sdch_dictionary_url = request_->url().Resolve(url_text); |
467 // Don't try to download Dictionary for cached responses. It's either | 468 // Don't try to download Dictionary for cached responses. It's either |
468 // useless or too late. | 469 // useless or too late. |
469 if (sdch_dictionary_url.is_valid() && !is_cached_content_) { | 470 if (sdch_dictionary_url.is_valid() && !is_cached_content_) { |
470 rv = sdch_manager->OnGetDictionary(request_->url(), | 471 rv = sdch_manager->OnGetDictionary(request_->url(), |
471 sdch_dictionary_url); | 472 sdch_dictionary_url); |
472 if (rv != SDCH_OK) { | 473 if (rv != SDCH_OK) { |
473 SdchManager::SdchErrorRecovery(rv); | 474 SdchManager::SdchErrorRecovery(rv); |
474 request_->net_log().AddEvent( | 475 request_->net_log().AddEvent( |
475 NetLog::TYPE_SDCH_DICTIONARY_ERROR, | 476 NetLogEventType::SDCH_DICTIONARY_ERROR, |
476 base::Bind(&NetLogSdchDictionaryFetchProblemCallback, rv, | 477 base::Bind(&NetLogSdchDictionaryFetchProblemCallback, rv, |
477 sdch_dictionary_url, false)); | 478 sdch_dictionary_url, false)); |
478 } | 479 } |
479 } | 480 } |
480 } | 481 } |
481 } | 482 } |
482 } | 483 } |
483 | 484 |
484 // Handle the server signalling no SDCH encoding. | 485 // Handle the server signalling no SDCH encoding. |
485 if (dictionaries_advertised_) { | 486 if (dictionaries_advertised_) { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 // TODO(mmenke): Remove ScopedTracker below once crbug.com/456327 is fixed. | 562 // TODO(mmenke): Remove ScopedTracker below once crbug.com/456327 is fixed. |
562 tracked_objects::ScopedTracker tracking_profile( | 563 tracked_objects::ScopedTracker tracking_profile( |
563 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 564 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
564 "456327 URLRequestHttpJob::MaybeStartTransactionInternal")); | 565 "456327 URLRequestHttpJob::MaybeStartTransactionInternal")); |
565 | 566 |
566 OnCallToDelegateComplete(); | 567 OnCallToDelegateComplete(); |
567 if (result == OK) { | 568 if (result == OK) { |
568 StartTransactionInternal(); | 569 StartTransactionInternal(); |
569 } else { | 570 } else { |
570 std::string source("delegate"); | 571 std::string source("delegate"); |
571 request_->net_log().AddEvent(NetLog::TYPE_CANCELLED, | 572 request_->net_log().AddEvent(NetLogEventType::CANCELLED, |
572 NetLog::StringCallback("source", &source)); | 573 NetLog::StringCallback("source", &source)); |
573 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, result)); | 574 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, result)); |
574 } | 575 } |
575 } | 576 } |
576 | 577 |
577 void URLRequestHttpJob::StartTransactionInternal() { | 578 void URLRequestHttpJob::StartTransactionInternal() { |
578 // This should only be called while the request's status is IO_PENDING. | 579 // This should only be called while the request's status is IO_PENDING. |
579 DCHECK_EQ(URLRequestStatus::IO_PENDING, request_->status().status()); | 580 DCHECK_EQ(URLRequestStatus::IO_PENDING, request_->status().status()); |
580 | 581 |
581 // NOTE: This method assumes that request_info_ is already setup properly. | 582 // NOTE: This method assumes that request_info_ is already setup properly. |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 // of having SDCH encoded responses returned (e.g. by the cache) | 660 // of having SDCH encoded responses returned (e.g. by the cache) |
660 // which we cannot decode, and in those situations, we will need | 661 // which we cannot decode, and in those situations, we will need |
661 // to retransmit the request without SDCH, which is illegal for a POST. | 662 // to retransmit the request without SDCH, which is illegal for a POST. |
662 bool advertise_sdch = sdch_manager != NULL && request()->method() != "POST"; | 663 bool advertise_sdch = sdch_manager != NULL && request()->method() != "POST"; |
663 if (advertise_sdch) { | 664 if (advertise_sdch) { |
664 SdchProblemCode rv = sdch_manager->IsInSupportedDomain(request()->url()); | 665 SdchProblemCode rv = sdch_manager->IsInSupportedDomain(request()->url()); |
665 if (rv != SDCH_OK) { | 666 if (rv != SDCH_OK) { |
666 advertise_sdch = false; | 667 advertise_sdch = false; |
667 SdchManager::SdchErrorRecovery(rv); | 668 SdchManager::SdchErrorRecovery(rv); |
668 request()->net_log().AddEvent( | 669 request()->net_log().AddEvent( |
669 NetLog::TYPE_SDCH_DECODING_ERROR, | 670 NetLogEventType::SDCH_DECODING_ERROR, |
670 base::Bind(&NetLogSdchResourceProblemCallback, rv)); | 671 base::Bind(&NetLogSdchResourceProblemCallback, rv)); |
671 } | 672 } |
672 } | 673 } |
673 if (advertise_sdch) { | 674 if (advertise_sdch) { |
674 dictionaries_advertised_ = | 675 dictionaries_advertised_ = |
675 sdch_manager->GetDictionarySet(request_->url()); | 676 sdch_manager->GetDictionarySet(request_->url()); |
676 } | 677 } |
677 | 678 |
678 // The AllowLatencyExperiment() is only true if we've successfully done a | 679 // The AllowLatencyExperiment() is only true if we've successfully done a |
679 // full SDCH compression recently in this browser session for this host. | 680 // full SDCH compression recently in this browser session for this host. |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
812 NotifyCanceled(); | 813 NotifyCanceled(); |
813 } | 814 } |
814 } | 815 } |
815 | 816 |
816 void URLRequestHttpJob::SaveCookiesAndNotifyHeadersComplete(int result) { | 817 void URLRequestHttpJob::SaveCookiesAndNotifyHeadersComplete(int result) { |
817 // End of the call started in OnStartCompleted. | 818 // End of the call started in OnStartCompleted. |
818 OnCallToDelegateComplete(); | 819 OnCallToDelegateComplete(); |
819 | 820 |
820 if (result != OK) { | 821 if (result != OK) { |
821 std::string source("delegate"); | 822 std::string source("delegate"); |
822 request_->net_log().AddEvent(NetLog::TYPE_CANCELLED, | 823 request_->net_log().AddEvent(NetLogEventType::CANCELLED, |
823 NetLog::StringCallback("source", &source)); | 824 NetLog::StringCallback("source", &source)); |
824 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, result)); | 825 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, result)); |
825 return; | 826 return; |
826 } | 827 } |
827 | 828 |
828 std::vector<std::string> response_cookies; | 829 std::vector<std::string> response_cookies; |
829 FetchResponseCookies(&response_cookies); | 830 FetchResponseCookies(&response_cookies); |
830 | 831 |
831 base::Time response_date; | 832 base::Time response_date; |
832 if (!GetResponseHeaders()->GetDateValue(&response_date)) | 833 if (!GetResponseHeaders()->GetDateValue(&response_date)) |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
986 request_, | 987 request_, |
987 on_headers_received_callback_, | 988 on_headers_received_callback_, |
988 headers.get(), | 989 headers.get(), |
989 &override_response_headers_, | 990 &override_response_headers_, |
990 &allowed_unsafe_redirect_url_); | 991 &allowed_unsafe_redirect_url_); |
991 if (error != OK) { | 992 if (error != OK) { |
992 if (error == ERR_IO_PENDING) { | 993 if (error == ERR_IO_PENDING) { |
993 awaiting_callback_ = true; | 994 awaiting_callback_ = true; |
994 } else { | 995 } else { |
995 std::string source("delegate"); | 996 std::string source("delegate"); |
996 request_->net_log().AddEvent(NetLog::TYPE_CANCELLED, | 997 request_->net_log().AddEvent( |
997 NetLog::StringCallback("source", | 998 NetLogEventType::CANCELLED, |
998 &source)); | 999 NetLog::StringCallback("source", &source)); |
999 OnCallToDelegateComplete(); | 1000 OnCallToDelegateComplete(); |
1000 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, error)); | 1001 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, error)); |
1001 } | 1002 } |
1002 return; | 1003 return; |
1003 } | 1004 } |
1004 } | 1005 } |
1005 if (transaction_ && transaction_->GetResponseInfo()) { | 1006 if (transaction_ && transaction_->GetResponseInfo()) { |
1006 LogChannelIDAndCookieStores(request_->url(), request_->context(), | 1007 LogChannelIDAndCookieStores(request_->url(), request_->context(), |
1007 transaction_->GetResponseInfo()->ssl_info); | 1008 transaction_->GetResponseInfo()->ssl_info); |
1008 } | 1009 } |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1608 // Notify NetworkQualityEstimator. | 1609 // Notify NetworkQualityEstimator. |
1609 if (request()) { | 1610 if (request()) { |
1610 NetworkQualityEstimator* network_quality_estimator = | 1611 NetworkQualityEstimator* network_quality_estimator = |
1611 request()->context()->network_quality_estimator(); | 1612 request()->context()->network_quality_estimator(); |
1612 if (network_quality_estimator) | 1613 if (network_quality_estimator) |
1613 network_quality_estimator->NotifyURLRequestDestroyed(*request()); | 1614 network_quality_estimator->NotifyURLRequestDestroyed(*request()); |
1614 } | 1615 } |
1615 } | 1616 } |
1616 | 1617 |
1617 } // namespace net | 1618 } // namespace net |
OLD | NEW |