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

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: Re #26 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 // The Job is forced to use QUIC without a designated version, try the
214 // preferred QUIC version that is supported by default.
215 if (quic_version_ == QUIC_VERSION_UNSUPPORTED &&
216 ShouldForceQuic(session, destination, origin_url, proxy_info)) {
217 quic_version_ = session->params().quic_supported_versions[0];
218 }
219
220 if (using_quic_)
221 DCHECK_NE(quic_version_, QUIC_VERSION_UNSUPPORTED);
222
211 DCHECK(session); 223 DCHECK(session);
212 if (alternative_protocol != kProtoUnknown) { 224 if (alternative_protocol != kProtoUnknown) {
213 // The job cannot have protocol requirements dictated by alternative service 225 // The job cannot have protocol requirements dictated by alternative service
214 // and have an alternative proxy server set at the same time, since 226 // and have an alternative proxy server set at the same time, since
215 // alternative services are used for requests that are fetched directly, 227 // alternative services are used for requests that are fetched directly,
216 // while the alternative proxy server is used for requests that should be 228 // while the alternative proxy server is used for requests that should be
217 // fetched using proxy. 229 // fetched using proxy.
218 DCHECK(!alternative_proxy_server_.is_valid()); 230 DCHECK(!alternative_proxy_server_.is_valid());
219 // If the alternative service protocol is specified, then the job type must 231 // If the alternative service protocol is specified, then the job type must
220 // be either ALTERNATIVE or PRECONNECT. 232 // be either ALTERNATIVE or PRECONNECT.
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 replacements.ClearRef(); 903 replacements.ClearRef();
892 url = url.ReplaceComponents(replacements); 904 url = url.ReplaceComponents(replacements);
893 } else { 905 } else {
894 DCHECK(using_ssl_); 906 DCHECK(using_ssl_);
895 // The certificate of a QUIC alternative server is expected to be valid 907 // 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 908 // for the origin of the request (in addition to being valid for the
897 // server itself). 909 // server itself).
898 destination = destination_; 910 destination = destination_;
899 ssl_config = &server_ssl_config_; 911 ssl_config = &server_ssl_config_;
900 } 912 }
901 int rv = 913 int rv = quic_request_.Request(
902 quic_request_.Request(destination, request_info_.privacy_mode, 914 destination, quic_version_, request_info_.privacy_mode,
903 ssl_config->GetCertVerifyFlags(), url, 915 ssl_config->GetCertVerifyFlags(), url, request_info_.method, net_log_,
904 request_info_.method, net_log_, io_callback_); 916 io_callback_);
905 if (rv == OK) { 917 if (rv == OK) {
906 using_existing_quic_session_ = true; 918 using_existing_quic_session_ = true;
907 } else { 919 } else {
908 // There's no available QUIC session. Inform the delegate how long to 920 // There's no available QUIC session. Inform the delegate how long to
909 // delay the main job. 921 // delay the main job.
910 if (rv == ERR_IO_PENDING) { 922 if (rv == ERR_IO_PENDING) {
911 delegate_->MaybeSetWaitTimeForMainJob( 923 delegate_->MaybeSetWaitTimeForMainJob(
912 quic_request_.GetTimeDelayForWaitingJob()); 924 quic_request_.GetTimeDelayForWaitingJob());
913 } 925 }
914 } 926 }
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
1459 const ProxyInfo& proxy_info, 1471 const ProxyInfo& proxy_info,
1460 const SSLConfig& server_ssl_config, 1472 const SSLConfig& server_ssl_config,
1461 const SSLConfig& proxy_ssl_config, 1473 const SSLConfig& proxy_ssl_config,
1462 HostPortPair destination, 1474 HostPortPair destination,
1463 GURL origin_url, 1475 GURL origin_url,
1464 bool enable_ip_based_pooling, 1476 bool enable_ip_based_pooling,
1465 NetLog* net_log) { 1477 NetLog* net_log) {
1466 return base::MakeUnique<HttpStreamFactoryImpl::Job>( 1478 return base::MakeUnique<HttpStreamFactoryImpl::Job>(
1467 delegate, job_type, session, request_info, priority, proxy_info, 1479 delegate, job_type, session, request_info, priority, proxy_info,
1468 server_ssl_config, proxy_ssl_config, destination, origin_url, 1480 server_ssl_config, proxy_ssl_config, destination, origin_url,
1469 kProtoUnknown, ProxyServer(), enable_ip_based_pooling, net_log); 1481 kProtoUnknown, QUIC_VERSION_UNSUPPORTED, ProxyServer(),
1482 enable_ip_based_pooling, net_log);
1470 } 1483 }
1471 1484
1472 std::unique_ptr<HttpStreamFactoryImpl::Job> 1485 std::unique_ptr<HttpStreamFactoryImpl::Job>
1473 HttpStreamFactoryImpl::JobFactory::CreateAltSvcJob( 1486 HttpStreamFactoryImpl::JobFactory::CreateAltSvcJob(
1474 HttpStreamFactoryImpl::Job::Delegate* delegate, 1487 HttpStreamFactoryImpl::Job::Delegate* delegate,
1475 HttpStreamFactoryImpl::JobType job_type, 1488 HttpStreamFactoryImpl::JobType job_type,
1476 HttpNetworkSession* session, 1489 HttpNetworkSession* session,
1477 const HttpRequestInfo& request_info, 1490 const HttpRequestInfo& request_info,
1478 RequestPriority priority, 1491 RequestPriority priority,
1479 const ProxyInfo& proxy_info, 1492 const ProxyInfo& proxy_info,
1480 const SSLConfig& server_ssl_config, 1493 const SSLConfig& server_ssl_config,
1481 const SSLConfig& proxy_ssl_config, 1494 const SSLConfig& proxy_ssl_config,
1482 HostPortPair destination, 1495 HostPortPair destination,
1483 GURL origin_url, 1496 GURL origin_url,
1484 NextProto alternative_protocol, 1497 NextProto alternative_protocol,
1498 QuicVersion quic_version,
1485 bool enable_ip_based_pooling, 1499 bool enable_ip_based_pooling,
1486 NetLog* net_log) { 1500 NetLog* net_log) {
1487 return base::MakeUnique<HttpStreamFactoryImpl::Job>( 1501 return base::MakeUnique<HttpStreamFactoryImpl::Job>(
1488 delegate, job_type, session, request_info, priority, proxy_info, 1502 delegate, job_type, session, request_info, priority, proxy_info,
1489 server_ssl_config, proxy_ssl_config, destination, origin_url, 1503 server_ssl_config, proxy_ssl_config, destination, origin_url,
1490 alternative_protocol, ProxyServer(), enable_ip_based_pooling, net_log); 1504 alternative_protocol, quic_version, ProxyServer(),
1505 enable_ip_based_pooling, net_log);
1491 } 1506 }
1492 1507
1493 std::unique_ptr<HttpStreamFactoryImpl::Job> 1508 std::unique_ptr<HttpStreamFactoryImpl::Job>
1494 HttpStreamFactoryImpl::JobFactory::CreateAltProxyJob( 1509 HttpStreamFactoryImpl::JobFactory::CreateAltProxyJob(
1495 HttpStreamFactoryImpl::Job::Delegate* delegate, 1510 HttpStreamFactoryImpl::Job::Delegate* delegate,
1496 HttpStreamFactoryImpl::JobType job_type, 1511 HttpStreamFactoryImpl::JobType job_type,
1497 HttpNetworkSession* session, 1512 HttpNetworkSession* session,
1498 const HttpRequestInfo& request_info, 1513 const HttpRequestInfo& request_info,
1499 RequestPriority priority, 1514 RequestPriority priority,
1500 const ProxyInfo& proxy_info, 1515 const ProxyInfo& proxy_info,
1501 const SSLConfig& server_ssl_config, 1516 const SSLConfig& server_ssl_config,
1502 const SSLConfig& proxy_ssl_config, 1517 const SSLConfig& proxy_ssl_config,
1503 HostPortPair destination, 1518 HostPortPair destination,
1504 GURL origin_url, 1519 GURL origin_url,
1505 const ProxyServer& alternative_proxy_server, 1520 const ProxyServer& alternative_proxy_server,
1506 bool enable_ip_based_pooling, 1521 bool enable_ip_based_pooling,
1507 NetLog* net_log) { 1522 NetLog* net_log) {
1508 return base::MakeUnique<HttpStreamFactoryImpl::Job>( 1523 return base::MakeUnique<HttpStreamFactoryImpl::Job>(
1509 delegate, job_type, session, request_info, priority, proxy_info, 1524 delegate, job_type, session, request_info, priority, proxy_info,
1510 server_ssl_config, proxy_ssl_config, destination, origin_url, 1525 server_ssl_config, proxy_ssl_config, destination, origin_url,
1511 kProtoUnknown, alternative_proxy_server, enable_ip_based_pooling, 1526 kProtoUnknown, QUIC_VERSION_UNSUPPORTED, alternative_proxy_server,
1512 net_log); 1527 enable_ip_based_pooling, net_log);
1513 } 1528 }
1514 1529
1515 } // namespace net 1530 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_stream_factory_impl_job.h ('k') | net/http/http_stream_factory_impl_job_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698