Chromium Code Reviews| Index: net/http/http_stream_factory_impl_job_controller.cc |
| diff --git a/net/http/http_stream_factory_impl_job_controller.cc b/net/http/http_stream_factory_impl_job_controller.cc |
| index 9a214234abd6de9006e10ddc4152be1d1f43e947..8ff49579bb2eaf714e6429c8d54cc6fd9a113be6 100644 |
| --- a/net/http/http_stream_factory_impl_job_controller.cc |
| +++ b/net/http/http_stream_factory_impl_job_controller.cc |
| @@ -633,6 +633,11 @@ const NetLogWithSource* HttpStreamFactoryImpl::JobController::GetNetLog() |
| return &net_log_; |
| } |
| +const QuicVersionVector& |
| +HttpStreamFactoryImpl::JobController::GetAdvertisedQuicVersions() const { |
| + return alternative_service_info_.advertised_versions(); |
| +} |
| + |
| void HttpStreamFactoryImpl::JobController::MaybeSetWaitTimeForMainJob( |
| const base::TimeDelta& delay) { |
| if (main_job_is_blocked_) { |
| @@ -770,25 +775,24 @@ int HttpStreamFactoryImpl::JobController::DoCreateJobs() { |
| GURL origin_url = ApplyHostMappingRules(request_info_.url, &destination); |
| // Create an alternative job if alternative service is set up for this domain. |
| - alternative_service_ = |
| - GetAlternativeServiceInfoFor(request_info_, delegate_, stream_type_) |
| - .alternative_service(); |
| + alternative_service_info_ = |
| + GetAlternativeServiceInfoFor(request_info_, delegate_, stream_type_); |
| if (is_preconnect_) { |
| // Due to how the socket pools handle priorities and idle sockets, only IDLE |
| // priority currently makes sense for preconnects. The priority for |
| // preconnects is currently ignored (see RequestSocketsForPool()), but could |
| // be used at some point for proxy resolution or something. |
| - if (alternative_service_.protocol != kProtoUnknown) { |
| + if (alternative_service_info_.protocol() != kProtoUnknown) { |
| HostPortPair alternative_destination( |
| - alternative_service_.host_port_pair()); |
| + alternative_service_info_.host_port_pair()); |
| ignore_result( |
| ApplyHostMappingRules(request_info_.url, &alternative_destination)); |
| main_job_ = job_factory_->CreateAltSvcJob( |
| this, PRECONNECT, session_, request_info_, IDLE, proxy_info_, |
| server_ssl_config_, proxy_ssl_config_, alternative_destination, |
| - origin_url, alternative_service_.protocol, enable_ip_based_pooling_, |
| - session_->net_log()); |
| + origin_url, alternative_service_info_.protocol(), |
| + enable_ip_based_pooling_, session_->net_log()); |
| } else { |
| main_job_ = job_factory_->CreateMainJob( |
| this, PRECONNECT, session_, request_info_, IDLE, proxy_info_, |
| @@ -804,23 +808,24 @@ int HttpStreamFactoryImpl::JobController::DoCreateJobs() { |
| enable_ip_based_pooling_, net_log_.net_log()); |
| // Alternative Service can only be set for HTTPS requests while Alternative |
| // Proxy is set for HTTP requests. |
| - if (alternative_service_.protocol != kProtoUnknown) { |
| + if (alternative_service_info_.protocol() != kProtoUnknown) { |
| // Never share connection with other jobs for FTP requests. |
| DVLOG(1) << "Selected alternative service (host: " |
| - << alternative_service_.host_port_pair().host() |
| - << " port: " << alternative_service_.host_port_pair().port() |
| + << alternative_service_info_.host_port_pair().host() |
| + << " port: " << alternative_service_info_.host_port_pair().port() |
| << ")"; |
| DCHECK(!request_info_.url.SchemeIs(url::kFtpScheme)); |
| - HostPortPair alternative_destination(alternative_service_.host_port_pair()); |
| + HostPortPair alternative_destination( |
| + alternative_service_info_.host_port_pair()); |
| ignore_result( |
| ApplyHostMappingRules(request_info_.url, &alternative_destination)); |
| alternative_job_ = job_factory_->CreateAltSvcJob( |
| this, ALTERNATIVE, session_, request_info_, priority_, proxy_info_, |
| server_ssl_config_, proxy_ssl_config_, alternative_destination, |
| - origin_url, alternative_service_.protocol, enable_ip_based_pooling_, |
| - net_log_.net_log()); |
| + origin_url, alternative_service_info_.protocol(), |
|
Ryan Hamilton
2017/06/28 18:53:14
Since we're already passing in some of the Alterna
Zhongyi Shi
2017/07/05 23:08:59
Done. Changed to only pass the selected QUIC versi
|
| + enable_ip_based_pooling_, net_log_.net_log()); |
| main_job_is_blocked_ = true; |
| alternative_job_->Start(request_->stream_type()); |
| @@ -948,7 +953,7 @@ void HttpStreamFactoryImpl::JobController::OnAlternativeServiceJobFailed( |
| int net_error) { |
| DCHECK_EQ(alternative_job_->job_type(), ALTERNATIVE); |
| DCHECK_NE(OK, net_error); |
| - DCHECK_NE(kProtoUnknown, alternative_service_.protocol); |
| + DCHECK_NE(kProtoUnknown, alternative_service_info_.protocol()); |
| alternative_job_net_error_ = net_error; |
| @@ -976,7 +981,7 @@ void HttpStreamFactoryImpl::JobController::OnAlternativeProxyJobFailed( |
| } |
| void HttpStreamFactoryImpl::JobController::ReportBrokenAlternativeService() { |
| - DCHECK(alternative_service_.protocol != kProtoUnknown); |
| + DCHECK(alternative_service_info_.protocol() != kProtoUnknown); |
| DCHECK_NE(OK, alternative_job_net_error_); |
| int error_to_report = alternative_job_net_error_; |
| @@ -992,7 +997,7 @@ void HttpStreamFactoryImpl::JobController::ReportBrokenAlternativeService() { |
| HistogramBrokenAlternateProtocolLocation( |
| BROKEN_ALTERNATE_PROTOCOL_LOCATION_HTTP_STREAM_FACTORY_IMPL_JOB_ALT); |
| session_->http_server_properties()->MarkAlternativeServiceBroken( |
| - alternative_service_); |
| + alternative_service_info_.alternative_service()); |
| } |
| void HttpStreamFactoryImpl::JobController::MaybeNotifyFactoryOfCompletion() { |
| @@ -1033,11 +1038,9 @@ HttpStreamFactoryImpl::JobController::GetAlternativeServiceInfoFor( |
| AlternativeServiceInfo alternative_service_info = |
| GetAlternativeServiceInfoInternal(request_info, delegate, stream_type); |
| AlternativeServiceType type; |
| - if (alternative_service_info.alternative_service().protocol == |
| - kProtoUnknown) { |
| + if (alternative_service_info.protocol() == kProtoUnknown) { |
| type = NO_ALTERNATIVE_SERVICE; |
| - } else if (alternative_service_info.alternative_service().protocol == |
| - kProtoQUIC) { |
| + } else if (alternative_service_info.protocol() == kProtoQUIC) { |
| if (request_info.url.host_piece() == |
| alternative_service_info.alternative_service().host) { |
| type = QUIC_SAME_DESTINATION; |
| @@ -1083,10 +1086,8 @@ HttpStreamFactoryImpl::JobController::GetAlternativeServiceInfoInternal( |
| for (const AlternativeServiceInfo& alternative_service_info : |
| alternative_service_info_vector) { |
| - DCHECK(IsAlternateProtocolValid( |
| - alternative_service_info.alternative_service().protocol)); |
| - if (!quic_advertised && |
| - alternative_service_info.alternative_service().protocol == kProtoQUIC) |
| + DCHECK(IsAlternateProtocolValid(alternative_service_info.protocol())); |
| + if (!quic_advertised && alternative_service_info.protocol() == kProtoQUIC) |
| quic_advertised = true; |
| if (http_server_properties.IsAlternativeServiceBroken( |
| alternative_service_info.alternative_service())) { |
| @@ -1107,20 +1108,17 @@ HttpStreamFactoryImpl::JobController::GetAlternativeServiceInfoInternal( |
| origin.port() < kUnrestrictedPort)) |
| continue; |
| - if (alternative_service_info.alternative_service().protocol == |
| - kProtoHTTP2) { |
| + if (alternative_service_info.protocol() == kProtoHTTP2) { |
| if (!session_->params().enable_http2_alternative_service) |
| continue; |
| // Cache this entry if we don't have a non-broken Alt-Svc yet. |
| - if (first_alternative_service_info.alternative_service().protocol == |
| - kProtoUnknown) |
| + if (first_alternative_service_info.protocol() == kProtoUnknown) |
| first_alternative_service_info = alternative_service_info; |
| continue; |
| } |
| - DCHECK_EQ(kProtoQUIC, |
| - alternative_service_info.alternative_service().protocol); |
| + DCHECK_EQ(kProtoQUIC, alternative_service_info.protocol()); |
| quic_all_broken = false; |
| if (!session_->IsQuicEnabled()) |
| continue; |
| @@ -1138,8 +1136,7 @@ HttpStreamFactoryImpl::JobController::GetAlternativeServiceInfoInternal( |
| ignore_result(ApplyHostMappingRules(original_url, &mapped_origin)); |
| QuicServerId server_id(mapped_origin, request_info.privacy_mode); |
| - HostPortPair destination( |
| - alternative_service_info.alternative_service().host_port_pair()); |
| + HostPortPair destination(alternative_service_info.host_port_pair()); |
| ignore_result(ApplyHostMappingRules(original_url, &destination)); |
| if (session_->quic_stream_factory()->CanUseExistingSession(server_id, |
| @@ -1148,8 +1145,7 @@ HttpStreamFactoryImpl::JobController::GetAlternativeServiceInfoInternal( |
| } |
| // Cache this entry if we don't have a non-broken Alt-Svc yet. |
| - if (first_alternative_service_info.alternative_service().protocol == |
| - kProtoUnknown) |
| + if (first_alternative_service_info.protocol() == kProtoUnknown) |
| first_alternative_service_info = alternative_service_info; |
| } |