| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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_controller.h" | 5 #include "net/http/http_stream_factory_impl_job_controller.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 798 } | 798 } |
| 799 | 799 |
| 800 int HttpStreamFactoryImpl::JobController::DoCreateJobs() { | 800 int HttpStreamFactoryImpl::JobController::DoCreateJobs() { |
| 801 DCHECK(!main_job_); | 801 DCHECK(!main_job_); |
| 802 DCHECK(!alternative_job_); | 802 DCHECK(!alternative_job_); |
| 803 | 803 |
| 804 HostPortPair destination(HostPortPair::FromURL(request_info_.url)); | 804 HostPortPair destination(HostPortPair::FromURL(request_info_.url)); |
| 805 GURL origin_url = ApplyHostMappingRules(request_info_.url, &destination); | 805 GURL origin_url = ApplyHostMappingRules(request_info_.url, &destination); |
| 806 | 806 |
| 807 // Create an alternative job if alternative service is set up for this domain. | 807 // Create an alternative job if alternative service is set up for this domain. |
| 808 alternative_service_ = | 808 alternative_service_info_ = |
| 809 GetAlternativeServiceInfoFor(request_info_, delegate_, stream_type_) | 809 GetAlternativeServiceInfoFor(request_info_, delegate_, stream_type_); |
| 810 .alternative_service(); | 810 QuicVersion quic_version = QUIC_VERSION_UNSUPPORTED; |
| 811 if (alternative_service_info_.protocol() == kProtoQUIC) { |
| 812 quic_version = |
| 813 SelectQuicVersion(alternative_service_info_.advertised_versions()); |
| 814 DCHECK_NE(quic_version, QUIC_VERSION_UNSUPPORTED); |
| 815 } |
| 811 | 816 |
| 812 if (is_preconnect_) { | 817 if (is_preconnect_) { |
| 813 // Due to how the socket pools handle priorities and idle sockets, only IDLE | 818 // Due to how the socket pools handle priorities and idle sockets, only IDLE |
| 814 // priority currently makes sense for preconnects. The priority for | 819 // priority currently makes sense for preconnects. The priority for |
| 815 // preconnects is currently ignored (see RequestSocketsForPool()), but could | 820 // preconnects is currently ignored (see RequestSocketsForPool()), but could |
| 816 // be used at some point for proxy resolution or something. | 821 // be used at some point for proxy resolution or something. |
| 817 if (alternative_service_.protocol != kProtoUnknown) { | 822 if (alternative_service_info_.protocol() != kProtoUnknown) { |
| 818 HostPortPair alternative_destination( | 823 HostPortPair alternative_destination( |
| 819 alternative_service_.host_port_pair()); | 824 alternative_service_info_.host_port_pair()); |
| 820 ignore_result( | 825 ignore_result( |
| 821 ApplyHostMappingRules(request_info_.url, &alternative_destination)); | 826 ApplyHostMappingRules(request_info_.url, &alternative_destination)); |
| 822 main_job_ = job_factory_->CreateAltSvcJob( | 827 main_job_ = job_factory_->CreateAltSvcJob( |
| 823 this, PRECONNECT, session_, request_info_, IDLE, proxy_info_, | 828 this, PRECONNECT, session_, request_info_, IDLE, proxy_info_, |
| 824 server_ssl_config_, proxy_ssl_config_, alternative_destination, | 829 server_ssl_config_, proxy_ssl_config_, alternative_destination, |
| 825 origin_url, alternative_service_.protocol, enable_ip_based_pooling_, | 830 origin_url, alternative_service_info_.protocol(), quic_version, |
| 826 session_->net_log()); | 831 enable_ip_based_pooling_, session_->net_log()); |
| 827 } else { | 832 } else { |
| 828 main_job_ = job_factory_->CreateMainJob( | 833 main_job_ = job_factory_->CreateMainJob( |
| 829 this, PRECONNECT, session_, request_info_, IDLE, proxy_info_, | 834 this, PRECONNECT, session_, request_info_, IDLE, proxy_info_, |
| 830 server_ssl_config_, proxy_ssl_config_, destination, origin_url, | 835 server_ssl_config_, proxy_ssl_config_, destination, origin_url, |
| 831 enable_ip_based_pooling_, session_->net_log()); | 836 enable_ip_based_pooling_, session_->net_log()); |
| 832 } | 837 } |
| 833 main_job_->Preconnect(num_streams_); | 838 main_job_->Preconnect(num_streams_); |
| 834 return OK; | 839 return OK; |
| 835 } | 840 } |
| 836 main_job_ = job_factory_->CreateMainJob( | 841 main_job_ = job_factory_->CreateMainJob( |
| 837 this, MAIN, session_, request_info_, priority_, proxy_info_, | 842 this, MAIN, session_, request_info_, priority_, proxy_info_, |
| 838 server_ssl_config_, proxy_ssl_config_, destination, origin_url, | 843 server_ssl_config_, proxy_ssl_config_, destination, origin_url, |
| 839 enable_ip_based_pooling_, net_log_.net_log()); | 844 enable_ip_based_pooling_, net_log_.net_log()); |
| 840 // Alternative Service can only be set for HTTPS requests while Alternative | 845 // Alternative Service can only be set for HTTPS requests while Alternative |
| 841 // Proxy is set for HTTP requests. | 846 // Proxy is set for HTTP requests. |
| 842 if (alternative_service_.protocol != kProtoUnknown) { | 847 if (alternative_service_info_.protocol() != kProtoUnknown) { |
| 843 // Never share connection with other jobs for FTP requests. | 848 // Never share connection with other jobs for FTP requests. |
| 844 DVLOG(1) << "Selected alternative service (host: " | 849 DVLOG(1) << "Selected alternative service (host: " |
| 845 << alternative_service_.host_port_pair().host() | 850 << alternative_service_info_.host_port_pair().host() |
| 846 << " port: " << alternative_service_.host_port_pair().port() | 851 << " port: " << alternative_service_info_.host_port_pair().port() |
| 847 << ")"; | 852 << " version: " << quic_version << ")"; |
| 848 | 853 |
| 849 DCHECK(!request_info_.url.SchemeIs(url::kFtpScheme)); | 854 DCHECK(!request_info_.url.SchemeIs(url::kFtpScheme)); |
| 850 HostPortPair alternative_destination(alternative_service_.host_port_pair()); | 855 HostPortPair alternative_destination( |
| 856 alternative_service_info_.host_port_pair()); |
| 851 ignore_result( | 857 ignore_result( |
| 852 ApplyHostMappingRules(request_info_.url, &alternative_destination)); | 858 ApplyHostMappingRules(request_info_.url, &alternative_destination)); |
| 853 | |
| 854 alternative_job_ = job_factory_->CreateAltSvcJob( | 859 alternative_job_ = job_factory_->CreateAltSvcJob( |
| 855 this, ALTERNATIVE, session_, request_info_, priority_, proxy_info_, | 860 this, ALTERNATIVE, session_, request_info_, priority_, proxy_info_, |
| 856 server_ssl_config_, proxy_ssl_config_, alternative_destination, | 861 server_ssl_config_, proxy_ssl_config_, alternative_destination, |
| 857 origin_url, alternative_service_.protocol, enable_ip_based_pooling_, | 862 origin_url, alternative_service_info_.protocol(), quic_version, |
| 858 net_log_.net_log()); | 863 enable_ip_based_pooling_, net_log_.net_log()); |
| 859 | 864 |
| 860 main_job_is_blocked_ = true; | 865 main_job_is_blocked_ = true; |
| 861 alternative_job_->Start(request_->stream_type()); | 866 alternative_job_->Start(request_->stream_type()); |
| 862 } else { | 867 } else { |
| 863 ProxyServer alternative_proxy_server; | 868 ProxyServer alternative_proxy_server; |
| 864 if (ShouldCreateAlternativeProxyServerJob(proxy_info_, request_info_.url, | 869 if (ShouldCreateAlternativeProxyServerJob(proxy_info_, request_info_.url, |
| 865 &alternative_proxy_server)) { | 870 &alternative_proxy_server)) { |
| 866 DCHECK(!main_job_is_blocked_); | 871 DCHECK(!main_job_is_blocked_); |
| 867 ProxyInfo alternative_proxy_info; | 872 ProxyInfo alternative_proxy_info; |
| 868 alternative_proxy_info.UseProxyServer(alternative_proxy_server); | 873 alternative_proxy_info.UseProxyServer(alternative_proxy_server); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 976 NextProto negotiated_protocol, | 981 NextProto negotiated_protocol, |
| 977 bool using_spdy) { | 982 bool using_spdy) { |
| 978 if (request_) | 983 if (request_) |
| 979 request_->Complete(was_alpn_negotiated, negotiated_protocol, using_spdy); | 984 request_->Complete(was_alpn_negotiated, negotiated_protocol, using_spdy); |
| 980 } | 985 } |
| 981 | 986 |
| 982 void HttpStreamFactoryImpl::JobController::OnAlternativeServiceJobFailed( | 987 void HttpStreamFactoryImpl::JobController::OnAlternativeServiceJobFailed( |
| 983 int net_error) { | 988 int net_error) { |
| 984 DCHECK_EQ(alternative_job_->job_type(), ALTERNATIVE); | 989 DCHECK_EQ(alternative_job_->job_type(), ALTERNATIVE); |
| 985 DCHECK_NE(OK, net_error); | 990 DCHECK_NE(OK, net_error); |
| 986 DCHECK_NE(kProtoUnknown, alternative_service_.protocol); | 991 DCHECK_NE(kProtoUnknown, alternative_service_info_.protocol()); |
| 987 | 992 |
| 988 alternative_job_net_error_ = net_error; | 993 alternative_job_net_error_ = net_error; |
| 989 | 994 |
| 990 if (IsJobOrphaned(alternative_job_.get())) { | 995 if (IsJobOrphaned(alternative_job_.get())) { |
| 991 // If |request_| is gone then it must have been successfully served by | 996 // If |request_| is gone then it must have been successfully served by |
| 992 // |main_job_|. | 997 // |main_job_|. |
| 993 // If |request_| is bound to a different job, then it is being | 998 // If |request_| is bound to a different job, then it is being |
| 994 // successfully serverd by the main job. | 999 // successfully serverd by the main job. |
| 995 ReportBrokenAlternativeService(); | 1000 ReportBrokenAlternativeService(); |
| 996 } | 1001 } |
| 997 } | 1002 } |
| 998 | 1003 |
| 999 void HttpStreamFactoryImpl::JobController::OnAlternativeProxyJobFailed( | 1004 void HttpStreamFactoryImpl::JobController::OnAlternativeProxyJobFailed( |
| 1000 int net_error) { | 1005 int net_error) { |
| 1001 DCHECK_EQ(alternative_job_->job_type(), ALTERNATIVE); | 1006 DCHECK_EQ(alternative_job_->job_type(), ALTERNATIVE); |
| 1002 DCHECK_NE(OK, net_error); | 1007 DCHECK_NE(OK, net_error); |
| 1003 DCHECK(alternative_job_->alternative_proxy_server().is_valid()); | 1008 DCHECK(alternative_job_->alternative_proxy_server().is_valid()); |
| 1004 | 1009 |
| 1005 // Need to mark alt proxy as broken regardless whether the job is bound. | 1010 // Need to mark alt proxy as broken regardless whether the job is bound. |
| 1006 ProxyDelegate* proxy_delegate = session_->context().proxy_delegate; | 1011 ProxyDelegate* proxy_delegate = session_->context().proxy_delegate; |
| 1007 if (proxy_delegate) { | 1012 if (proxy_delegate) { |
| 1008 proxy_delegate->OnAlternativeProxyBroken( | 1013 proxy_delegate->OnAlternativeProxyBroken( |
| 1009 alternative_job_->alternative_proxy_server()); | 1014 alternative_job_->alternative_proxy_server()); |
| 1010 } | 1015 } |
| 1011 } | 1016 } |
| 1012 | 1017 |
| 1013 void HttpStreamFactoryImpl::JobController::ReportBrokenAlternativeService() { | 1018 void HttpStreamFactoryImpl::JobController::ReportBrokenAlternativeService() { |
| 1014 DCHECK(alternative_service_.protocol != kProtoUnknown); | 1019 DCHECK(alternative_service_info_.protocol() != kProtoUnknown); |
| 1015 DCHECK_NE(OK, alternative_job_net_error_); | 1020 DCHECK_NE(OK, alternative_job_net_error_); |
| 1016 | 1021 |
| 1017 int error_to_report = alternative_job_net_error_; | 1022 int error_to_report = alternative_job_net_error_; |
| 1018 alternative_job_net_error_ = OK; | 1023 alternative_job_net_error_ = OK; |
| 1019 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.AlternateServiceFailed", -error_to_report); | 1024 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.AlternateServiceFailed", -error_to_report); |
| 1020 | 1025 |
| 1021 if (error_to_report == ERR_NETWORK_CHANGED || | 1026 if (error_to_report == ERR_NETWORK_CHANGED || |
| 1022 error_to_report == ERR_INTERNET_DISCONNECTED) { | 1027 error_to_report == ERR_INTERNET_DISCONNECTED) { |
| 1023 // No need to mark alternative service or proxy as broken. | 1028 // No need to mark alternative service or proxy as broken. |
| 1024 return; | 1029 return; |
| 1025 } | 1030 } |
| 1026 | 1031 |
| 1027 HistogramBrokenAlternateProtocolLocation( | 1032 HistogramBrokenAlternateProtocolLocation( |
| 1028 BROKEN_ALTERNATE_PROTOCOL_LOCATION_HTTP_STREAM_FACTORY_IMPL_JOB_ALT); | 1033 BROKEN_ALTERNATE_PROTOCOL_LOCATION_HTTP_STREAM_FACTORY_IMPL_JOB_ALT); |
| 1029 session_->http_server_properties()->MarkAlternativeServiceBroken( | 1034 session_->http_server_properties()->MarkAlternativeServiceBroken( |
| 1030 alternative_service_); | 1035 alternative_service_info_.alternative_service()); |
| 1031 } | 1036 } |
| 1032 | 1037 |
| 1033 void HttpStreamFactoryImpl::JobController::MaybeNotifyFactoryOfCompletion() { | 1038 void HttpStreamFactoryImpl::JobController::MaybeNotifyFactoryOfCompletion() { |
| 1034 if (!request_ && !main_job_ && !alternative_job_) { | 1039 if (!request_ && !main_job_ && !alternative_job_) { |
| 1035 DCHECK(!bound_job_); | 1040 DCHECK(!bound_job_); |
| 1036 factory_->OnJobControllerComplete(this); | 1041 factory_->OnJobControllerComplete(this); |
| 1037 } | 1042 } |
| 1038 } | 1043 } |
| 1039 | 1044 |
| 1040 void HttpStreamFactoryImpl::JobController::NotifyRequestFailed(int rv) { | 1045 void HttpStreamFactoryImpl::JobController::NotifyRequestFailed(int rv) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1061 HttpStreamFactoryImpl::JobController::GetAlternativeServiceInfoFor( | 1066 HttpStreamFactoryImpl::JobController::GetAlternativeServiceInfoFor( |
| 1062 const HttpRequestInfo& request_info, | 1067 const HttpRequestInfo& request_info, |
| 1063 HttpStreamRequest::Delegate* delegate, | 1068 HttpStreamRequest::Delegate* delegate, |
| 1064 HttpStreamRequest::StreamType stream_type) { | 1069 HttpStreamRequest::StreamType stream_type) { |
| 1065 if (!enable_alternative_services_) | 1070 if (!enable_alternative_services_) |
| 1066 return AlternativeServiceInfo(); | 1071 return AlternativeServiceInfo(); |
| 1067 | 1072 |
| 1068 AlternativeServiceInfo alternative_service_info = | 1073 AlternativeServiceInfo alternative_service_info = |
| 1069 GetAlternativeServiceInfoInternal(request_info, delegate, stream_type); | 1074 GetAlternativeServiceInfoInternal(request_info, delegate, stream_type); |
| 1070 AlternativeServiceType type; | 1075 AlternativeServiceType type; |
| 1071 if (alternative_service_info.alternative_service().protocol == | 1076 if (alternative_service_info.protocol() == kProtoUnknown) { |
| 1072 kProtoUnknown) { | |
| 1073 type = NO_ALTERNATIVE_SERVICE; | 1077 type = NO_ALTERNATIVE_SERVICE; |
| 1074 } else if (alternative_service_info.alternative_service().protocol == | 1078 } else if (alternative_service_info.protocol() == kProtoQUIC) { |
| 1075 kProtoQUIC) { | |
| 1076 if (request_info.url.host_piece() == | 1079 if (request_info.url.host_piece() == |
| 1077 alternative_service_info.alternative_service().host) { | 1080 alternative_service_info.alternative_service().host) { |
| 1078 type = QUIC_SAME_DESTINATION; | 1081 type = QUIC_SAME_DESTINATION; |
| 1079 } else { | 1082 } else { |
| 1080 type = QUIC_DIFFERENT_DESTINATION; | 1083 type = QUIC_DIFFERENT_DESTINATION; |
| 1081 } | 1084 } |
| 1082 } else { | 1085 } else { |
| 1083 if (request_info.url.host_piece() == | 1086 if (request_info.url.host_piece() == |
| 1084 alternative_service_info.alternative_service().host) { | 1087 alternative_service_info.alternative_service().host) { |
| 1085 type = NOT_QUIC_SAME_DESTINATION; | 1088 type = NOT_QUIC_SAME_DESTINATION; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1111 return AlternativeServiceInfo(); | 1114 return AlternativeServiceInfo(); |
| 1112 | 1115 |
| 1113 bool quic_advertised = false; | 1116 bool quic_advertised = false; |
| 1114 bool quic_all_broken = true; | 1117 bool quic_all_broken = true; |
| 1115 | 1118 |
| 1116 // First alternative service that is not marked as broken. | 1119 // First alternative service that is not marked as broken. |
| 1117 AlternativeServiceInfo first_alternative_service_info; | 1120 AlternativeServiceInfo first_alternative_service_info; |
| 1118 | 1121 |
| 1119 for (const AlternativeServiceInfo& alternative_service_info : | 1122 for (const AlternativeServiceInfo& alternative_service_info : |
| 1120 alternative_service_info_vector) { | 1123 alternative_service_info_vector) { |
| 1121 DCHECK(IsAlternateProtocolValid( | 1124 DCHECK(IsAlternateProtocolValid(alternative_service_info.protocol())); |
| 1122 alternative_service_info.alternative_service().protocol)); | 1125 if (!quic_advertised && alternative_service_info.protocol() == kProtoQUIC) |
| 1123 if (!quic_advertised && | |
| 1124 alternative_service_info.alternative_service().protocol == kProtoQUIC) | |
| 1125 quic_advertised = true; | 1126 quic_advertised = true; |
| 1126 if (http_server_properties.IsAlternativeServiceBroken( | 1127 if (http_server_properties.IsAlternativeServiceBroken( |
| 1127 alternative_service_info.alternative_service())) { | 1128 alternative_service_info.alternative_service())) { |
| 1128 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_BROKEN, false); | 1129 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_BROKEN, false); |
| 1129 continue; | 1130 continue; |
| 1130 } | 1131 } |
| 1131 | 1132 |
| 1132 // Some shared unix systems may have user home directories (like | 1133 // Some shared unix systems may have user home directories (like |
| 1133 // http://foo.com/~mike) which allow users to emit headers. This is a bad | 1134 // http://foo.com/~mike) which allow users to emit headers. This is a bad |
| 1134 // idea already, but with Alternate-Protocol, it provides the ability for a | 1135 // idea already, but with Alternate-Protocol, it provides the ability for a |
| 1135 // single user on a multi-user system to hijack the alternate protocol. | 1136 // single user on a multi-user system to hijack the alternate protocol. |
| 1136 // These systems also enforce ports <1024 as restricted ports. So don't | 1137 // These systems also enforce ports <1024 as restricted ports. So don't |
| 1137 // allow protocol upgrades to user-controllable ports. | 1138 // allow protocol upgrades to user-controllable ports. |
| 1138 const int kUnrestrictedPort = 1024; | 1139 const int kUnrestrictedPort = 1024; |
| 1139 if (!session_->params().enable_user_alternate_protocol_ports && | 1140 if (!session_->params().enable_user_alternate_protocol_ports && |
| 1140 (alternative_service_info.alternative_service().port >= | 1141 (alternative_service_info.alternative_service().port >= |
| 1141 kUnrestrictedPort && | 1142 kUnrestrictedPort && |
| 1142 origin.port() < kUnrestrictedPort)) | 1143 origin.port() < kUnrestrictedPort)) |
| 1143 continue; | 1144 continue; |
| 1144 | 1145 |
| 1145 if (alternative_service_info.alternative_service().protocol == | 1146 if (alternative_service_info.protocol() == kProtoHTTP2) { |
| 1146 kProtoHTTP2) { | |
| 1147 if (!session_->params().enable_http2_alternative_service) | 1147 if (!session_->params().enable_http2_alternative_service) |
| 1148 continue; | 1148 continue; |
| 1149 | 1149 |
| 1150 // Cache this entry if we don't have a non-broken Alt-Svc yet. | 1150 // Cache this entry if we don't have a non-broken Alt-Svc yet. |
| 1151 if (first_alternative_service_info.alternative_service().protocol == | 1151 if (first_alternative_service_info.protocol() == kProtoUnknown) |
| 1152 kProtoUnknown) | |
| 1153 first_alternative_service_info = alternative_service_info; | 1152 first_alternative_service_info = alternative_service_info; |
| 1154 continue; | 1153 continue; |
| 1155 } | 1154 } |
| 1156 | 1155 |
| 1157 DCHECK_EQ(kProtoQUIC, | 1156 DCHECK_EQ(kProtoQUIC, alternative_service_info.protocol()); |
| 1158 alternative_service_info.alternative_service().protocol); | |
| 1159 quic_all_broken = false; | 1157 quic_all_broken = false; |
| 1160 if (!session_->IsQuicEnabled()) | 1158 if (!session_->IsQuicEnabled()) |
| 1161 continue; | 1159 continue; |
| 1162 | 1160 |
| 1163 if (stream_type == HttpStreamRequest::BIDIRECTIONAL_STREAM && | 1161 if (stream_type == HttpStreamRequest::BIDIRECTIONAL_STREAM && |
| 1164 session_->params().quic_disable_bidirectional_streams) { | 1162 session_->params().quic_disable_bidirectional_streams) { |
| 1165 continue; | 1163 continue; |
| 1166 } | 1164 } |
| 1167 | 1165 |
| 1168 if (!original_url.SchemeIs(url::kHttpsScheme)) | 1166 if (!original_url.SchemeIs(url::kHttpsScheme)) |
| 1169 continue; | 1167 continue; |
| 1170 | 1168 |
| 1171 // If there is no QUIC version in the advertised versions supported by | 1169 // If there is no QUIC version in the advertised versions that is |
| 1172 // the net stack, ignore this entry. | 1170 // supported, ignore this entry. |
| 1173 if (SelectQuicVersion(alternative_service_info.advertised_versions()) == | 1171 if (SelectQuicVersion(alternative_service_info.advertised_versions()) == |
| 1174 QUIC_VERSION_UNSUPPORTED) | 1172 QUIC_VERSION_UNSUPPORTED) |
| 1175 continue; | 1173 continue; |
| 1176 | 1174 |
| 1177 // Check whether there is an existing QUIC session to use for this origin. | 1175 // Check whether there is an existing QUIC session to use for this origin. |
| 1178 HostPortPair mapped_origin(origin.host(), origin.port()); | 1176 HostPortPair mapped_origin(origin.host(), origin.port()); |
| 1179 ignore_result(ApplyHostMappingRules(original_url, &mapped_origin)); | 1177 ignore_result(ApplyHostMappingRules(original_url, &mapped_origin)); |
| 1180 QuicServerId server_id(mapped_origin, request_info.privacy_mode); | 1178 QuicServerId server_id(mapped_origin, request_info.privacy_mode); |
| 1181 | 1179 |
| 1182 HostPortPair destination( | 1180 HostPortPair destination(alternative_service_info.host_port_pair()); |
| 1183 alternative_service_info.alternative_service().host_port_pair()); | |
| 1184 ignore_result(ApplyHostMappingRules(original_url, &destination)); | 1181 ignore_result(ApplyHostMappingRules(original_url, &destination)); |
| 1185 | 1182 |
| 1186 if (session_->quic_stream_factory()->CanUseExistingSession(server_id, | 1183 if (session_->quic_stream_factory()->CanUseExistingSession(server_id, |
| 1187 destination)) { | 1184 destination)) |
| 1188 return alternative_service_info; | 1185 return alternative_service_info; |
| 1189 } | |
| 1190 | 1186 |
| 1191 // Cache this entry if we don't have a non-broken Alt-Svc yet. | 1187 // Cache this entry if we don't have a non-broken Alt-Svc yet. |
| 1192 if (first_alternative_service_info.alternative_service().protocol == | 1188 if (first_alternative_service_info.protocol() == kProtoUnknown) |
| 1193 kProtoUnknown) | |
| 1194 first_alternative_service_info = alternative_service_info; | 1189 first_alternative_service_info = alternative_service_info; |
| 1195 } | 1190 } |
| 1196 | 1191 |
| 1197 // Ask delegate to mark QUIC as broken for the origin. | 1192 // Ask delegate to mark QUIC as broken for the origin. |
| 1198 if (quic_advertised && quic_all_broken && delegate != nullptr) | 1193 if (quic_advertised && quic_all_broken && delegate != nullptr) |
| 1199 delegate->OnQuicBroken(); | 1194 delegate->OnQuicBroken(); |
| 1200 | 1195 |
| 1201 return first_alternative_service_info; | 1196 return first_alternative_service_info; |
| 1202 } | 1197 } |
| 1203 | 1198 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1346 // If ReconsiderProxyAfterError() failed synchronously, it means | 1341 // If ReconsiderProxyAfterError() failed synchronously, it means |
| 1347 // there was nothing left to fall-back to, so fail the transaction | 1342 // there was nothing left to fall-back to, so fail the transaction |
| 1348 // with the last connection error we got. | 1343 // with the last connection error we got. |
| 1349 // TODO(eroman): This is a confusing contract, make it more obvious. | 1344 // TODO(eroman): This is a confusing contract, make it more obvious. |
| 1350 rv = error; | 1345 rv = error; |
| 1351 } | 1346 } |
| 1352 return rv; | 1347 return rv; |
| 1353 } | 1348 } |
| 1354 | 1349 |
| 1355 } // namespace net | 1350 } // namespace net |
| OLD | NEW |