Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1204)

Side by Side Diff: net/http/http_stream_factory_impl_job_controller.cc

Issue 2964603002: JobController: do not create alternative job for those AlternativeServiceInfo (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 continue; 1126 continue;
1127 1127
1128 if (stream_type == HttpStreamRequest::BIDIRECTIONAL_STREAM && 1128 if (stream_type == HttpStreamRequest::BIDIRECTIONAL_STREAM &&
1129 session_->params().quic_disable_bidirectional_streams) { 1129 session_->params().quic_disable_bidirectional_streams) {
1130 continue; 1130 continue;
1131 } 1131 }
1132 1132
1133 if (!original_url.SchemeIs(url::kHttpsScheme)) 1133 if (!original_url.SchemeIs(url::kHttpsScheme))
1134 continue; 1134 continue;
1135 1135
1136 // If there is no QUIC version in the advertised versions supported by
1137 // the net stack, ignore this entry.
1138 if (SelectQuicVersion(alternative_service_info.advertised_versions()) ==
1139 QUIC_VERSION_UNSUPPORTED)
Ryan Hamilton 2017/06/30 02:45:11 Since we don't do anything with the return value f
Zhongyi Shi 2017/06/30 21:08:43 I could change to return a boolean in this one, th
Ryan Hamilton 2017/06/30 21:17:31 Makes sense.
1140 continue;
1141
1136 // Check whether there is an existing QUIC session to use for this origin. 1142 // Check whether there is an existing QUIC session to use for this origin.
1137 HostPortPair mapped_origin(origin.host(), origin.port()); 1143 HostPortPair mapped_origin(origin.host(), origin.port());
1138 ignore_result(ApplyHostMappingRules(original_url, &mapped_origin)); 1144 ignore_result(ApplyHostMappingRules(original_url, &mapped_origin));
1139 QuicServerId server_id(mapped_origin, request_info.privacy_mode); 1145 QuicServerId server_id(mapped_origin, request_info.privacy_mode);
1140 1146
1141 HostPortPair destination( 1147 HostPortPair destination(
1142 alternative_service_info.alternative_service().host_port_pair()); 1148 alternative_service_info.alternative_service().host_port_pair());
1143 ignore_result(ApplyHostMappingRules(original_url, &destination)); 1149 ignore_result(ApplyHostMappingRules(original_url, &destination));
1144 1150
1145 if (session_->quic_stream_factory()->CanUseExistingSession(server_id, 1151 if (session_->quic_stream_factory()->CanUseExistingSession(server_id,
1146 destination)) { 1152 destination)) {
1147 return alternative_service_info; 1153 return alternative_service_info;
1148 } 1154 }
1149 1155
1150 // Cache this entry if we don't have a non-broken Alt-Svc yet. 1156 // Cache this entry if we don't have a non-broken Alt-Svc yet.
1151 if (first_alternative_service_info.alternative_service().protocol == 1157 if (first_alternative_service_info.alternative_service().protocol ==
1152 kProtoUnknown) 1158 kProtoUnknown)
1153 first_alternative_service_info = alternative_service_info; 1159 first_alternative_service_info = alternative_service_info;
1154 } 1160 }
1155 1161
1156 // Ask delegate to mark QUIC as broken for the origin. 1162 // Ask delegate to mark QUIC as broken for the origin.
1157 if (quic_advertised && quic_all_broken && delegate != nullptr) 1163 if (quic_advertised && quic_all_broken && delegate != nullptr)
1158 delegate->OnQuicBroken(); 1164 delegate->OnQuicBroken();
1159 1165
1160 return first_alternative_service_info; 1166 return first_alternative_service_info;
1161 } 1167 }
1162 1168
1169 QuicVersion HttpStreamFactoryImpl::JobController::SelectQuicVersion(
1170 const QuicVersionVector& advertised_versions) {
1171 const QuicVersionVector& supported_versions =
1172 session_->params().quic_supported_versions;
1173 if (advertised_versions.empty())
1174 return supported_versions[0];
1175
1176 for (const QuicVersion& supported : supported_versions) {
1177 for (const QuicVersion& advertised : advertised_versions) {
1178 if (supported == advertised) {
1179 DCHECK_NE(QUIC_VERSION_UNSUPPORTED, supported);
1180 return supported;
1181 }
1182 }
1183 }
1184
1185 return QUIC_VERSION_UNSUPPORTED;
1186 }
1187
1163 bool HttpStreamFactoryImpl::JobController:: 1188 bool HttpStreamFactoryImpl::JobController::
1164 ShouldCreateAlternativeProxyServerJob( 1189 ShouldCreateAlternativeProxyServerJob(
1165 const ProxyInfo& proxy_info, 1190 const ProxyInfo& proxy_info,
1166 const GURL& url, 1191 const GURL& url,
1167 ProxyServer* alternative_proxy_server) const { 1192 ProxyServer* alternative_proxy_server) const {
1168 DCHECK(!alternative_proxy_server->is_valid()); 1193 DCHECK(!alternative_proxy_server->is_valid());
1169 1194
1170 if (!enable_alternative_services_) 1195 if (!enable_alternative_services_)
1171 return false; 1196 return false;
1172 1197
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1286 // If ReconsiderProxyAfterError() failed synchronously, it means 1311 // If ReconsiderProxyAfterError() failed synchronously, it means
1287 // there was nothing left to fall-back to, so fail the transaction 1312 // there was nothing left to fall-back to, so fail the transaction
1288 // with the last connection error we got. 1313 // with the last connection error we got.
1289 // TODO(eroman): This is a confusing contract, make it more obvious. 1314 // TODO(eroman): This is a confusing contract, make it more obvious.
1290 rv = error; 1315 rv = error;
1291 } 1316 }
1292 return rv; 1317 return rv;
1293 } 1318 }
1294 1319
1295 } // namespace net 1320 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698