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

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

Issue 2958133002: Change QuicStreamRequest::Request() to take a preferred QuicVersion so that (Closed)
Patch Set: self review 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) 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 JobType job_type, 155 JobType job_type,
156 HttpNetworkSession* session, 156 HttpNetworkSession* session,
157 const HttpRequestInfo& request_info, 157 const HttpRequestInfo& request_info,
158 RequestPriority priority, 158 RequestPriority priority,
159 const ProxyInfo& proxy_info, 159 const ProxyInfo& proxy_info,
160 const SSLConfig& server_ssl_config, 160 const SSLConfig& server_ssl_config,
161 const SSLConfig& proxy_ssl_config, 161 const SSLConfig& proxy_ssl_config,
162 HostPortPair destination, 162 HostPortPair destination,
163 GURL origin_url, 163 GURL origin_url,
164 NextProto alternative_protocol, 164 NextProto alternative_protocol,
165 QuicVersion quic_version,
165 const ProxyServer& alternative_proxy_server, 166 const ProxyServer& alternative_proxy_server,
166 bool enable_ip_based_pooling, 167 bool enable_ip_based_pooling,
167 NetLog* net_log) 168 NetLog* net_log)
168 : request_info_(request_info), 169 : request_info_(request_info),
169 priority_(priority), 170 priority_(priority),
170 proxy_info_(proxy_info), 171 proxy_info_(proxy_info),
171 server_ssl_config_(server_ssl_config), 172 server_ssl_config_(server_ssl_config),
172 proxy_ssl_config_(proxy_ssl_config), 173 proxy_ssl_config_(proxy_ssl_config),
173 net_log_( 174 net_log_(
174 NetLogWithSource::Make(net_log, NetLogSourceType::HTTP_STREAM_JOB)), 175 NetLogWithSource::Make(net_log, NetLogSourceType::HTTP_STREAM_JOB)),
175 io_callback_(base::Bind(&Job::OnIOComplete, base::Unretained(this))), 176 io_callback_(base::Bind(&Job::OnIOComplete, base::Unretained(this))),
176 connection_(new ClientSocketHandle), 177 connection_(new ClientSocketHandle),
177 session_(session), 178 session_(session),
178 state_(STATE_NONE), 179 state_(STATE_NONE),
179 next_state_(STATE_NONE), 180 next_state_(STATE_NONE),
180 destination_(destination), 181 destination_(destination),
181 origin_url_(origin_url), 182 origin_url_(origin_url),
182 alternative_proxy_server_(alternative_proxy_server), 183 alternative_proxy_server_(alternative_proxy_server),
183 enable_ip_based_pooling_(enable_ip_based_pooling), 184 enable_ip_based_pooling_(enable_ip_based_pooling),
184 delegate_(delegate), 185 delegate_(delegate),
185 job_type_(job_type), 186 job_type_(job_type),
186 using_ssl_(origin_url_.SchemeIs(url::kHttpsScheme) || 187 using_ssl_(origin_url_.SchemeIs(url::kHttpsScheme) ||
187 origin_url_.SchemeIs(url::kWssScheme)), 188 origin_url_.SchemeIs(url::kWssScheme)),
188 using_quic_( 189 using_quic_(
189 alternative_protocol == kProtoQUIC || 190 alternative_protocol == kProtoQUIC ||
190 ShouldForceQuic(session, destination, origin_url, proxy_info)), 191 ShouldForceQuic(session, destination, origin_url, proxy_info)),
192 quic_version_(quic_version),
191 expect_spdy_(alternative_protocol == kProtoHTTP2 && !using_quic_), 193 expect_spdy_(alternative_protocol == kProtoHTTP2 && !using_quic_),
192 using_spdy_(false), 194 using_spdy_(false),
193 should_reconsider_proxy_(false), 195 should_reconsider_proxy_(false),
194 quic_request_(session_->quic_stream_factory()), 196 quic_request_(session_->quic_stream_factory()),
195 using_existing_quic_session_(false), 197 using_existing_quic_session_(false),
196 establishing_tunnel_(false), 198 establishing_tunnel_(false),
197 was_alpn_negotiated_(false), 199 was_alpn_negotiated_(false),
198 negotiated_protocol_(kProtoUnknown), 200 negotiated_protocol_(kProtoUnknown),
199 num_streams_(0), 201 num_streams_(0),
200 spdy_session_direct_( 202 spdy_session_direct_(
201 !(proxy_info.is_https() && origin_url_.SchemeIs(url::kHttpScheme))), 203 !(proxy_info.is_https() && origin_url_.SchemeIs(url::kHttpScheme))),
202 spdy_session_key_(using_quic_ 204 spdy_session_key_(using_quic_
203 ? SpdySessionKey() 205 ? SpdySessionKey()
204 : GetSpdySessionKey(spdy_session_direct_, 206 : GetSpdySessionKey(spdy_session_direct_,
205 proxy_info_.proxy_server(), 207 proxy_info_.proxy_server(),
206 origin_url_, 208 origin_url_,
207 request_info_.privacy_mode)), 209 request_info_.privacy_mode)),
208 stream_type_(HttpStreamRequest::BIDIRECTIONAL_STREAM), 210 stream_type_(HttpStreamRequest::BIDIRECTIONAL_STREAM),
209 init_connection_already_resumed_(false), 211 init_connection_already_resumed_(false),
210 ptr_factory_(this) { 212 ptr_factory_(this) {
213 if (quic_version_ == QUIC_VERSION_UNSUPPORTED &&
214 ShouldForceQuic(session, destination, origin_url, proxy_info))
Ryan Hamilton 2017/07/06 13:27:45 Why does this only apply when "ShouldForceQuic" is
Zhongyi Shi 2017/07/06 18:13:39 When we create the Jobs in JobController, we pass
Ryan Hamilton 2017/07/06 19:00:04 (I guess an alternative would be to pass in suppor
Zhongyi Shi 2017/07/06 19:40:56 This could work. However, it might also be confusi
215 quic_version_ = session->params().quic_supported_versions[0];
Ryan Hamilton 2017/07/06 13:27:45 nit: {}s since the if predicate is more than one l
Zhongyi Shi 2017/07/06 18:13:40 Done.
216
211 DCHECK(session); 217 DCHECK(session);
212 if (alternative_protocol != kProtoUnknown) { 218 if (alternative_protocol != kProtoUnknown) {
213 // The job cannot have protocol requirements dictated by alternative service 219 // The job cannot have protocol requirements dictated by alternative service
214 // and have an alternative proxy server set at the same time, since 220 // and have an alternative proxy server set at the same time, since
215 // alternative services are used for requests that are fetched directly, 221 // alternative services are used for requests that are fetched directly,
216 // while the alternative proxy server is used for requests that should be 222 // while the alternative proxy server is used for requests that should be
217 // fetched using proxy. 223 // fetched using proxy.
218 DCHECK(!alternative_proxy_server_.is_valid()); 224 DCHECK(!alternative_proxy_server_.is_valid());
219 // If the alternative service protocol is specified, then the job type must 225 // If the alternative service protocol is specified, then the job type must
220 // be either ALTERNATIVE or PRECONNECT. 226 // be either ALTERNATIVE or PRECONNECT.
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 replacements.ClearRef(); 897 replacements.ClearRef();
892 url = url.ReplaceComponents(replacements); 898 url = url.ReplaceComponents(replacements);
893 } else { 899 } else {
894 DCHECK(using_ssl_); 900 DCHECK(using_ssl_);
895 // The certificate of a QUIC alternative server is expected to be valid 901 // The certificate of a QUIC alternative server is expected to be valid
896 // for the origin of the request (in addition to being valid for the 902 // for the origin of the request (in addition to being valid for the
897 // server itself). 903 // server itself).
898 destination = destination_; 904 destination = destination_;
899 ssl_config = &server_ssl_config_; 905 ssl_config = &server_ssl_config_;
900 } 906 }
901 int rv = 907 int rv = quic_request_.Request(
902 quic_request_.Request(destination, request_info_.privacy_mode, 908 destination, quic_version_, request_info_.privacy_mode,
903 ssl_config->GetCertVerifyFlags(), url, 909 ssl_config->GetCertVerifyFlags(), url, request_info_.method, net_log_,
904 request_info_.method, net_log_, io_callback_); 910 io_callback_);
905 if (rv == OK) { 911 if (rv == OK) {
906 using_existing_quic_session_ = true; 912 using_existing_quic_session_ = true;
907 } else { 913 } else {
908 // There's no available QUIC session. Inform the delegate how long to 914 // There's no available QUIC session. Inform the delegate how long to
909 // delay the main job. 915 // delay the main job.
910 if (rv == ERR_IO_PENDING) { 916 if (rv == ERR_IO_PENDING) {
911 delegate_->MaybeSetWaitTimeForMainJob( 917 delegate_->MaybeSetWaitTimeForMainJob(
912 quic_request_.GetTimeDelayForWaitingJob()); 918 quic_request_.GetTimeDelayForWaitingJob());
913 } 919 }
914 } 920 }
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
1460 const ProxyInfo& proxy_info, 1466 const ProxyInfo& proxy_info,
1461 const SSLConfig& server_ssl_config, 1467 const SSLConfig& server_ssl_config,
1462 const SSLConfig& proxy_ssl_config, 1468 const SSLConfig& proxy_ssl_config,
1463 HostPortPair destination, 1469 HostPortPair destination,
1464 GURL origin_url, 1470 GURL origin_url,
1465 bool enable_ip_based_pooling, 1471 bool enable_ip_based_pooling,
1466 NetLog* net_log) { 1472 NetLog* net_log) {
1467 return base::MakeUnique<HttpStreamFactoryImpl::Job>( 1473 return base::MakeUnique<HttpStreamFactoryImpl::Job>(
1468 delegate, job_type, session, request_info, priority, proxy_info, 1474 delegate, job_type, session, request_info, priority, proxy_info,
1469 server_ssl_config, proxy_ssl_config, destination, origin_url, 1475 server_ssl_config, proxy_ssl_config, destination, origin_url,
1470 kProtoUnknown, ProxyServer(), enable_ip_based_pooling, net_log); 1476 kProtoUnknown, QUIC_VERSION_UNSUPPORTED, ProxyServer(),
1477 enable_ip_based_pooling, net_log);
1471 } 1478 }
1472 1479
1473 std::unique_ptr<HttpStreamFactoryImpl::Job> 1480 std::unique_ptr<HttpStreamFactoryImpl::Job>
1474 HttpStreamFactoryImpl::JobFactory::CreateAltSvcJob( 1481 HttpStreamFactoryImpl::JobFactory::CreateAltSvcJob(
1475 HttpStreamFactoryImpl::Job::Delegate* delegate, 1482 HttpStreamFactoryImpl::Job::Delegate* delegate,
1476 HttpStreamFactoryImpl::JobType job_type, 1483 HttpStreamFactoryImpl::JobType job_type,
1477 HttpNetworkSession* session, 1484 HttpNetworkSession* session,
1478 const HttpRequestInfo& request_info, 1485 const HttpRequestInfo& request_info,
1479 RequestPriority priority, 1486 RequestPriority priority,
1480 const ProxyInfo& proxy_info, 1487 const ProxyInfo& proxy_info,
1481 const SSLConfig& server_ssl_config, 1488 const SSLConfig& server_ssl_config,
1482 const SSLConfig& proxy_ssl_config, 1489 const SSLConfig& proxy_ssl_config,
1483 HostPortPair destination, 1490 HostPortPair destination,
1484 GURL origin_url, 1491 GURL origin_url,
1485 NextProto alternative_protocol, 1492 NextProto alternative_protocol,
1493 QuicVersion quic_version,
1486 bool enable_ip_based_pooling, 1494 bool enable_ip_based_pooling,
1487 NetLog* net_log) { 1495 NetLog* net_log) {
1488 return base::MakeUnique<HttpStreamFactoryImpl::Job>( 1496 return base::MakeUnique<HttpStreamFactoryImpl::Job>(
1489 delegate, job_type, session, request_info, priority, proxy_info, 1497 delegate, job_type, session, request_info, priority, proxy_info,
1490 server_ssl_config, proxy_ssl_config, destination, origin_url, 1498 server_ssl_config, proxy_ssl_config, destination, origin_url,
1491 alternative_protocol, ProxyServer(), enable_ip_based_pooling, net_log); 1499 alternative_protocol, quic_version, ProxyServer(),
1500 enable_ip_based_pooling, net_log);
1492 } 1501 }
1493 1502
1494 std::unique_ptr<HttpStreamFactoryImpl::Job> 1503 std::unique_ptr<HttpStreamFactoryImpl::Job>
1495 HttpStreamFactoryImpl::JobFactory::CreateAltProxyJob( 1504 HttpStreamFactoryImpl::JobFactory::CreateAltProxyJob(
1496 HttpStreamFactoryImpl::Job::Delegate* delegate, 1505 HttpStreamFactoryImpl::Job::Delegate* delegate,
1497 HttpStreamFactoryImpl::JobType job_type, 1506 HttpStreamFactoryImpl::JobType job_type,
1498 HttpNetworkSession* session, 1507 HttpNetworkSession* session,
1499 const HttpRequestInfo& request_info, 1508 const HttpRequestInfo& request_info,
1500 RequestPriority priority, 1509 RequestPriority priority,
1501 const ProxyInfo& proxy_info, 1510 const ProxyInfo& proxy_info,
1502 const SSLConfig& server_ssl_config, 1511 const SSLConfig& server_ssl_config,
1503 const SSLConfig& proxy_ssl_config, 1512 const SSLConfig& proxy_ssl_config,
1504 HostPortPair destination, 1513 HostPortPair destination,
1505 GURL origin_url, 1514 GURL origin_url,
1506 const ProxyServer& alternative_proxy_server, 1515 const ProxyServer& alternative_proxy_server,
1507 bool enable_ip_based_pooling, 1516 bool enable_ip_based_pooling,
1508 NetLog* net_log) { 1517 NetLog* net_log) {
1509 return base::MakeUnique<HttpStreamFactoryImpl::Job>( 1518 return base::MakeUnique<HttpStreamFactoryImpl::Job>(
1510 delegate, job_type, session, request_info, priority, proxy_info, 1519 delegate, job_type, session, request_info, priority, proxy_info,
1511 server_ssl_config, proxy_ssl_config, destination, origin_url, 1520 server_ssl_config, proxy_ssl_config, destination, origin_url,
1512 kProtoUnknown, alternative_proxy_server, enable_ip_based_pooling, 1521 kProtoUnknown, QUIC_VERSION_UNSUPPORTED, alternative_proxy_server,
1513 net_log); 1522 enable_ip_based_pooling, net_log);
1514 } 1523 }
1515 1524
1516 } // namespace net 1525 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698