Chromium Code Reviews| 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/http/http_stream_factory_impl_job.h" | 5 #include "net/http/http_stream_factory_impl_job.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 request_key->ExportRawPublicKey(&raw_request_key) && | 113 request_key->ExportRawPublicKey(&raw_request_key) && |
| 114 raw_socket_key == raw_request_key) { | 114 raw_socket_key == raw_request_key) { |
| 115 match = MATCH; | 115 match = MATCH; |
| 116 } | 116 } |
| 117 } | 117 } |
| 118 UMA_HISTOGRAM_ENUMERATION("Net.TokenBinding.KeyMatch", match, KEY_MATCH_MAX); | 118 UMA_HISTOGRAM_ENUMERATION("Net.TokenBinding.KeyMatch", match, KEY_MATCH_MAX); |
| 119 } | 119 } |
| 120 | 120 |
| 121 } // namespace | 121 } // namespace |
| 122 | 122 |
| 123 // Returns parameters associated with the QUIC request creation. | |
| 124 std::unique_ptr<base::Value> NetLogHttpStreamJobQuicRequestCallback( | |
| 125 int64_t delay, | |
| 126 bool using_existing_quic_session, | |
| 127 NetLogCaptureMode /* capture mode */) { | |
| 128 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | |
| 129 dict->SetString("delay_in_macroseconds", base::Int64ToString(delay)); | |
|
eroman
2017/03/16 04:32:08
microseconds.
Also on a side-note, I expect it wi
| |
| 130 dict->SetBoolean("using_existing_quic_session", using_existing_quic_session); | |
| 131 return std::move(dict); | |
| 132 } | |
| 133 | |
| 123 // Returns parameters associated with the start of a HTTP stream job. | 134 // Returns parameters associated with the start of a HTTP stream job. |
| 124 std::unique_ptr<base::Value> NetLogHttpStreamJobCallback( | 135 std::unique_ptr<base::Value> NetLogHttpStreamJobCallback( |
| 125 const NetLogSource& source, | 136 const NetLogSource& source, |
| 126 const GURL* original_url, | 137 const GURL* original_url, |
| 127 const GURL* url, | 138 const GURL* url, |
| 128 const AlternativeService* alternative_service, | 139 const AlternativeService* alternative_service, |
| 129 RequestPriority priority, | 140 RequestPriority priority, |
| 130 NetLogCaptureMode /* capture_mode */) { | 141 NetLogCaptureMode /* capture_mode */) { |
| 131 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 142 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 132 if (source.IsValid()) | 143 if (source.IsValid()) |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 745 if (!IsPortAllowedForScheme(destination_.port(), | 756 if (!IsPortAllowedForScheme(destination_.port(), |
| 746 request_info_.url.scheme())) { | 757 request_info_.url.scheme())) { |
| 747 return ERR_UNSAFE_PORT; | 758 return ERR_UNSAFE_PORT; |
| 748 } | 759 } |
| 749 | 760 |
| 750 next_state_ = STATE_RESOLVE_PROXY; | 761 next_state_ = STATE_RESOLVE_PROXY; |
| 751 return OK; | 762 return OK; |
| 752 } | 763 } |
| 753 | 764 |
| 754 int HttpStreamFactoryImpl::Job::DoResolveProxy() { | 765 int HttpStreamFactoryImpl::Job::DoResolveProxy() { |
| 766 net_log_.AddEvent(NetLogEventType::HTTP_STREAM_JOB_RESOLVE_PROXY); | |
| 767 | |
| 755 DCHECK(!pac_request_); | 768 DCHECK(!pac_request_); |
| 756 DCHECK(session_); | 769 DCHECK(session_); |
| 757 | 770 |
| 758 next_state_ = STATE_RESOLVE_PROXY_COMPLETE; | 771 next_state_ = STATE_RESOLVE_PROXY_COMPLETE; |
| 759 | 772 |
| 760 if (request_info_.load_flags & LOAD_BYPASS_PROXY) { | 773 if (request_info_.load_flags & LOAD_BYPASS_PROXY) { |
| 761 proxy_info_.UseDirect(); | 774 proxy_info_.UseDirect(); |
| 762 return OK; | 775 return OK; |
| 763 } | 776 } |
| 764 | 777 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 840 } | 853 } |
| 841 | 854 |
| 842 int HttpStreamFactoryImpl::Job::DoWaitComplete(int result) { | 855 int HttpStreamFactoryImpl::Job::DoWaitComplete(int result) { |
| 843 net_log_.EndEvent(NetLogEventType::HTTP_STREAM_JOB_WAITING); | 856 net_log_.EndEvent(NetLogEventType::HTTP_STREAM_JOB_WAITING); |
| 844 DCHECK_EQ(OK, result); | 857 DCHECK_EQ(OK, result); |
| 845 next_state_ = STATE_INIT_CONNECTION; | 858 next_state_ = STATE_INIT_CONNECTION; |
| 846 return OK; | 859 return OK; |
| 847 } | 860 } |
| 848 | 861 |
| 849 int HttpStreamFactoryImpl::Job::DoInitConnection() { | 862 int HttpStreamFactoryImpl::Job::DoInitConnection() { |
| 863 net_log_.BeginEvent(NetLogEventType::HTTP_STREAM_JOB_INIT_CONNECTION); | |
| 850 int result = DoInitConnectionImpl(); | 864 int result = DoInitConnectionImpl(); |
| 865 bool should_resume = | |
| 866 (result != ERR_SPDY_SESSION_ALREADY_EXISTS && result != OK); | |
| 867 net_log_.EndEvent(NetLogEventType::HTTP_STREAM_JOB_INIT_CONNECTION_IMPL, | |
| 868 NetLog::BoolCallback("should_resume", should_resume)); | |
| 851 if (result != ERR_SPDY_SESSION_ALREADY_EXISTS) | 869 if (result != ERR_SPDY_SESSION_ALREADY_EXISTS) |
| 852 delegate_->OnConnectionInitialized(this, result); | 870 delegate_->OnConnectionInitialized(this, result); |
| 853 | 871 |
| 854 return result; | 872 return result; |
| 855 } | 873 } |
| 856 | 874 |
| 857 int HttpStreamFactoryImpl::Job::DoInitConnectionImpl() { | 875 int HttpStreamFactoryImpl::Job::DoInitConnectionImpl() { |
| 876 net_log_.BeginEvent(NetLogEventType::HTTP_STREAM_JOB_INIT_CONNECTION_IMPL); | |
| 858 // TODO(pkasting): Remove ScopedTracker below once crbug.com/462812 is fixed. | 877 // TODO(pkasting): Remove ScopedTracker below once crbug.com/462812 is fixed. |
| 859 tracked_objects::ScopedTracker tracking_profile( | 878 tracked_objects::ScopedTracker tracking_profile( |
| 860 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 879 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 861 "462812 HttpStreamFactoryImpl::Job::DoInitConnection")); | 880 "462812 HttpStreamFactoryImpl::Job::DoInitConnection")); |
| 862 DCHECK(!connection_->is_initialized()); | 881 DCHECK(!connection_->is_initialized()); |
| 863 DCHECK(proxy_info_.proxy_server().is_valid()); | 882 DCHECK(proxy_info_.proxy_server().is_valid()); |
| 864 next_state_ = STATE_INIT_CONNECTION_COMPLETE; | 883 next_state_ = STATE_INIT_CONNECTION_COMPLETE; |
| 865 | 884 |
| 866 if (delegate_->OnInitConnection(proxy_info_)) { | 885 if (delegate_->OnInitConnection(proxy_info_)) { |
| 867 // Return since the connection initialization can be skipped. | 886 // Return since the connection initialization can be skipped. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 925 // The certificate of a QUIC alternative server is expected to be valid | 944 // The certificate of a QUIC alternative server is expected to be valid |
| 926 // for the origin of the request (in addition to being valid for the | 945 // for the origin of the request (in addition to being valid for the |
| 927 // server itself). | 946 // server itself). |
| 928 destination = destination_; | 947 destination = destination_; |
| 929 ssl_config = &server_ssl_config_; | 948 ssl_config = &server_ssl_config_; |
| 930 } | 949 } |
| 931 int rv = | 950 int rv = |
| 932 quic_request_.Request(destination, request_info_.privacy_mode, | 951 quic_request_.Request(destination, request_info_.privacy_mode, |
| 933 ssl_config->GetCertVerifyFlags(), url, | 952 ssl_config->GetCertVerifyFlags(), url, |
| 934 request_info_.method, net_log_, io_callback_); | 953 request_info_.method, net_log_, io_callback_); |
| 954 int64_t delay = 0; | |
| 935 if (rv == OK) { | 955 if (rv == OK) { |
| 936 using_existing_quic_session_ = true; | 956 using_existing_quic_session_ = true; |
| 937 } else { | 957 } else { |
| 938 // There's no available QUIC session. Inform the delegate how long to | 958 // There's no available QUIC session. Inform the delegate how long to |
| 939 // delay the main job. | 959 // delay the main job. |
| 940 if (rv == ERR_IO_PENDING) { | 960 if (rv == ERR_IO_PENDING) { |
| 941 delegate_->MaybeSetWaitTimeForMainJob( | 961 base::TimeDelta delay_delta = quic_request_.GetTimeDelayForWaitingJob(); |
| 942 quic_request_.GetTimeDelayForWaitingJob()); | 962 delay = delay_delta.InMicroseconds(); |
| 963 delegate_->MaybeSetWaitTimeForMainJob(delay_delta); | |
| 943 } | 964 } |
| 944 } | 965 } |
| 966 net_log_.AddEvent(NetLogEventType::HTTP_STREAM_JOB_CREATE_QUIC_REQUEST, | |
| 967 base::Bind(&NetLogHttpStreamJobQuicRequestCallback, delay, | |
| 968 using_existing_quic_session_)); | |
| 945 return rv; | 969 return rv; |
| 946 } | 970 } |
| 947 | 971 |
| 948 SpdySessionKey spdy_session_key = GetSpdySessionKey(); | 972 SpdySessionKey spdy_session_key = GetSpdySessionKey(); |
| 949 | 973 |
| 950 // Check first if we have a spdy session for this group. If so, then go | 974 // Check first if we have a spdy session for this group. If so, then go |
| 951 // straight to using that. | 975 // straight to using that. |
| 952 if (CanUseExistingSpdySession()) { | 976 if (CanUseExistingSpdySession()) { |
| 953 base::WeakPtr<SpdySession> spdy_session = | 977 base::WeakPtr<SpdySession> spdy_session = |
| 954 session_->spdy_session_pool()->FindAvailableSession( | 978 session_->spdy_session_pool()->FindAvailableSession( |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1014 } | 1038 } |
| 1015 | 1039 |
| 1016 return InitSocketHandleForHttpRequest( | 1040 return InitSocketHandleForHttpRequest( |
| 1017 GetSocketGroup(), destination_, request_info_.extra_headers, | 1041 GetSocketGroup(), destination_, request_info_.extra_headers, |
| 1018 request_info_.load_flags, priority_, session_, proxy_info_, expect_spdy, | 1042 request_info_.load_flags, priority_, session_, proxy_info_, expect_spdy, |
| 1019 server_ssl_config_, proxy_ssl_config_, request_info_.privacy_mode, | 1043 server_ssl_config_, proxy_ssl_config_, request_info_.privacy_mode, |
| 1020 net_log_, connection_.get(), resolution_callback, io_callback_); | 1044 net_log_, connection_.get(), resolution_callback, io_callback_); |
| 1021 } | 1045 } |
| 1022 | 1046 |
| 1023 int HttpStreamFactoryImpl::Job::DoInitConnectionComplete(int result) { | 1047 int HttpStreamFactoryImpl::Job::DoInitConnectionComplete(int result) { |
| 1048 net_log_.EndEvent(NetLogEventType::HTTP_STREAM_JOB_INIT_CONNECTION); | |
| 1024 if (job_type_ == PRECONNECT) { | 1049 if (job_type_ == PRECONNECT) { |
| 1025 if (using_quic_) | 1050 if (using_quic_) |
| 1026 return result; | 1051 return result; |
| 1027 DCHECK_EQ(OK, result); | 1052 DCHECK_EQ(OK, result); |
| 1028 return OK; | 1053 return OK; |
| 1029 } | 1054 } |
| 1030 | 1055 |
| 1031 if (result == ERR_SPDY_SESSION_ALREADY_EXISTS) { | 1056 if (result == ERR_SPDY_SESSION_ALREADY_EXISTS) { |
| 1032 // We found a SPDY connection after resolving the host. This is | 1057 // We found a SPDY connection after resolving the host. This is |
| 1033 // probably an IP pooled connection. | 1058 // probably an IP pooled connection. |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1551 | 1576 |
| 1552 ConnectionAttempts socket_attempts = connection_->connection_attempts(); | 1577 ConnectionAttempts socket_attempts = connection_->connection_attempts(); |
| 1553 if (connection_->socket()) { | 1578 if (connection_->socket()) { |
| 1554 connection_->socket()->GetConnectionAttempts(&socket_attempts); | 1579 connection_->socket()->GetConnectionAttempts(&socket_attempts); |
| 1555 } | 1580 } |
| 1556 | 1581 |
| 1557 delegate_->AddConnectionAttemptsToRequest(this, socket_attempts); | 1582 delegate_->AddConnectionAttemptsToRequest(this, socket_attempts); |
| 1558 } | 1583 } |
| 1559 | 1584 |
| 1560 } // namespace net | 1585 } // namespace net |
| OLD | NEW |