| Index: net/http/http_stream_factory_impl_job.cc
|
| diff --git a/net/http/http_stream_factory_impl_job.cc b/net/http/http_stream_factory_impl_job.cc
|
| index c5a5f114b267b5f3d7da282a2a781b6c5bba7b9e..7f8d852a8a17637c337eee3c4df543a835d9762e 100644
|
| --- a/net/http/http_stream_factory_impl_job.cc
|
| +++ b/net/http/http_stream_factory_impl_job.cc
|
| @@ -79,6 +79,7 @@ HttpStreamFactoryImpl::Job::Job(HttpStreamFactoryImpl* stream_factory,
|
| RequestPriority priority,
|
| const SSLConfig& server_ssl_config,
|
| const SSLConfig& proxy_ssl_config,
|
| + AlternativeService alternative_service,
|
| NetLog* net_log)
|
| : request_(NULL),
|
| request_info_(request_info),
|
| @@ -92,11 +93,16 @@ HttpStreamFactoryImpl::Job::Job(HttpStreamFactoryImpl* stream_factory,
|
| stream_factory_(stream_factory),
|
| next_state_(STATE_NONE),
|
| pac_request_(NULL),
|
| + alternative_service_(alternative_service),
|
| + is_spdy_alternative_(
|
| + alternative_service_.protocol >= NPN_SPDY_MINIMUM_VERSION &&
|
| + alternative_service_.protocol <= NPN_SPDY_MAXIMUM_VERSION),
|
| + is_quic_alternative_(alternative_service_.protocol == QUIC),
|
| blocking_job_(NULL),
|
| waiting_job_(NULL),
|
| using_ssl_(false),
|
| using_spdy_(false),
|
| - using_quic_(false),
|
| + using_quic_(is_quic_alternative_),
|
| quic_request_(session_->quic_stream_factory()),
|
| using_existing_quic_session_(false),
|
| spdy_certificate_error_(OK),
|
| @@ -110,6 +116,8 @@ HttpStreamFactoryImpl::Job::Job(HttpStreamFactoryImpl* stream_factory,
|
| ptr_factory_(this) {
|
| DCHECK(stream_factory);
|
| DCHECK(session);
|
| + if (is_quic_alternative_)
|
| + DCHECK(session_->params().enable_quic);
|
| }
|
|
|
| HttpStreamFactoryImpl::Job::~Job() {
|
| @@ -171,16 +179,6 @@ LoadState HttpStreamFactoryImpl::Job::GetLoadState() const {
|
| }
|
| }
|
|
|
| -void HttpStreamFactoryImpl::Job::MarkAsAlternate(
|
| - AlternativeService alternative_service) {
|
| - DCHECK(!IsAlternate());
|
| - alternative_service_ = alternative_service;
|
| - if (alternative_service.protocol == QUIC) {
|
| - DCHECK(session_->params().enable_quic);
|
| - using_quic_ = true;
|
| - }
|
| -}
|
| -
|
| void HttpStreamFactoryImpl::Job::WaitFor(Job* job) {
|
| DCHECK_EQ(STATE_NONE, next_state_);
|
| DCHECK_EQ(STATE_NONE, job->next_state_);
|
| @@ -289,7 +287,7 @@ bool HttpStreamFactoryImpl::Job::CanUseExistingSpdySession() const {
|
| // TODO(ricea): Add "wss" back to this list when SPDY WebSocket support is
|
| // working.
|
| return origin_url_.SchemeIs("https") ||
|
| - proxy_info_.proxy_server().is_https() || IsSpdyAlternate();
|
| + proxy_info_.proxy_server().is_https() || is_spdy_alternative_;
|
| }
|
|
|
| void HttpStreamFactoryImpl::Job::OnStreamReadyCallback() {
|
| @@ -555,7 +553,7 @@ int HttpStreamFactoryImpl::Job::RunLoop(int result) {
|
|
|
| default:
|
| DCHECK(result != ERR_ALTERNATIVE_CERT_NOT_VALID_FOR_ORIGIN ||
|
| - IsAlternate());
|
| + is_spdy_alternative_ || is_quic_alternative_);
|
| if (job_status_ != STATUS_BROKEN) {
|
| DCHECK_EQ(STATUS_RUNNING, job_status_);
|
| job_status_ = STATUS_FAILED;
|
| @@ -639,7 +637,7 @@ int HttpStreamFactoryImpl::Job::StartInternal() {
|
| }
|
|
|
| int HttpStreamFactoryImpl::Job::DoStart() {
|
| - if (IsAlternate()) {
|
| + if (is_spdy_alternative_ || is_quic_alternative_) {
|
| server_ = alternative_service_.host_port_pair();
|
| } else {
|
| server_ = HostPortPair::FromURL(request_info_.url);
|
| @@ -647,7 +645,7 @@ int HttpStreamFactoryImpl::Job::DoStart() {
|
| origin_url_ =
|
| stream_factory_->ApplyHostMappingRules(request_info_.url, &server_);
|
| valid_spdy_session_pool_.reset(new ValidSpdySessionPool(
|
| - session_->spdy_session_pool(), origin_url_, IsSpdyAlternate()));
|
| + session_->spdy_session_pool(), origin_url_, is_spdy_alternative_));
|
|
|
| net_log_.BeginEvent(
|
| NetLog::TYPE_HTTP_STREAM_JOB,
|
| @@ -691,7 +689,7 @@ int HttpStreamFactoryImpl::Job::DoResolveProxy() {
|
| // https://<alternative host>:<alternative port>/...
|
| // so the proxy resolution works with the actual destination, and so
|
| // that the correct socket pool is used.
|
| - if (IsSpdyAlternate()) {
|
| + if (is_spdy_alternative_) {
|
| // TODO(rch): Figure out how to make QUIC iteract with PAC
|
| // scripts. By not re-writing the URL, we will query the PAC script
|
| // for the proxy to use to reach the original URL via TCP. But
|
| @@ -732,7 +730,7 @@ int HttpStreamFactoryImpl::Job::DoResolveProxyComplete(int result) {
|
| } else if (using_quic_ &&
|
| (!proxy_info_.is_quic() && !proxy_info_.is_direct())) {
|
| // QUIC can not be spoken to non-QUIC proxies. This error should not be
|
| - // user visible, because the non-alternate job should be resumed.
|
| + // user visible, because the non-alternative Job should be resumed.
|
| result = ERR_NO_SUPPORTED_PROXIES;
|
| }
|
| }
|
| @@ -782,7 +780,7 @@ int HttpStreamFactoryImpl::Job::DoInitConnection() {
|
| next_state_ = STATE_INIT_CONNECTION_COMPLETE;
|
|
|
| using_ssl_ = origin_url_.SchemeIs("https") || origin_url_.SchemeIs("wss") ||
|
| - IsSpdyAlternate();
|
| + is_spdy_alternative_;
|
| using_spdy_ = false;
|
|
|
| if (ShouldForceQuic())
|
| @@ -857,9 +855,6 @@ int HttpStreamFactoryImpl::Job::DoInitConnection() {
|
| if (proxy_info_.is_http() || proxy_info_.is_https())
|
| establishing_tunnel_ = using_ssl_;
|
|
|
| - // TODO(bnc): s/want_spdy_over_npn/expect_spdy_over_npn/
|
| - bool want_spdy_over_npn = IsAlternate();
|
| -
|
| if (proxy_info_.is_https()) {
|
| InitSSLConfig(proxy_info_.proxy_server().host_port_pair(),
|
| &proxy_ssl_config_,
|
| @@ -887,8 +882,8 @@ int HttpStreamFactoryImpl::Job::DoInitConnection() {
|
| return PreconnectSocketsForHttpRequest(
|
| GetSocketGroup(), server_, request_info_.extra_headers,
|
| request_info_.load_flags, priority_, session_, proxy_info_,
|
| - want_spdy_over_npn, server_ssl_config_, proxy_ssl_config_,
|
| - request_info_.privacy_mode, net_log_, num_streams_);
|
| + /*want_spdy_over_npn=*/is_spdy_alternative_, server_ssl_config_,
|
| + proxy_ssl_config_, request_info_.privacy_mode, net_log_, num_streams_);
|
| }
|
|
|
| // If we can't use a SPDY session, don't bother checking for one after
|
| @@ -905,7 +900,8 @@ int HttpStreamFactoryImpl::Job::DoInitConnection() {
|
| return InitSocketHandleForWebSocketRequest(
|
| GetSocketGroup(), server_, request_info_.extra_headers,
|
| request_info_.load_flags, priority_, session_, proxy_info_,
|
| - want_spdy_over_npn, websocket_server_ssl_config, proxy_ssl_config_,
|
| + /*want_spdy_over_npn=*/is_spdy_alternative_,
|
| + websocket_server_ssl_config, proxy_ssl_config_,
|
| request_info_.privacy_mode, net_log_, connection_.get(),
|
| resolution_callback, io_callback_);
|
| }
|
| @@ -913,9 +909,9 @@ int HttpStreamFactoryImpl::Job::DoInitConnection() {
|
| return InitSocketHandleForHttpRequest(
|
| GetSocketGroup(), server_, request_info_.extra_headers,
|
| request_info_.load_flags, priority_, session_, proxy_info_,
|
| - want_spdy_over_npn, server_ssl_config_, proxy_ssl_config_,
|
| - request_info_.privacy_mode, net_log_, connection_.get(),
|
| - resolution_callback, io_callback_);
|
| + /*want_spdy_over_npn=*/is_spdy_alternative_, server_ssl_config_,
|
| + proxy_ssl_config_, request_info_.privacy_mode, net_log_,
|
| + connection_.get(), resolution_callback, io_callback_);
|
| }
|
|
|
| int HttpStreamFactoryImpl::Job::DoInitConnectionComplete(int result) {
|
| @@ -1014,13 +1010,14 @@ int HttpStreamFactoryImpl::Job::DoInitConnectionComplete(int result) {
|
| return result;
|
| }
|
|
|
| - if (IsSpdyAlternate() && !using_spdy_) {
|
| + if (is_spdy_alternative_ && !using_spdy_) {
|
| job_status_ = STATUS_BROKEN;
|
| MaybeMarkAlternativeServiceBroken();
|
| return ERR_NPN_NEGOTIATION_FAILED;
|
| }
|
|
|
| - if (!ssl_started && result < 0 && IsAlternate()) {
|
| + if (!ssl_started && result < 0 &&
|
| + (is_spdy_alternative_ || is_quic_alternative_)) {
|
| job_status_ = STATUS_BROKEN;
|
| // TODO(bnc): if (result == ERR_ALTERNATIVE_CERT_NOT_VALID_FOR_ORIGIN), then
|
| // instead of marking alternative service broken, mark (origin, alternative
|
| @@ -1056,7 +1053,7 @@ int HttpStreamFactoryImpl::Job::DoInitConnectionComplete(int result) {
|
| if (using_ssl_) {
|
| DCHECK(ssl_started);
|
| if (IsCertificateError(result)) {
|
| - if (using_spdy_ && IsAlternate() && origin_url_.SchemeIs("http")) {
|
| + if (is_spdy_alternative_ && origin_url_.SchemeIs("http")) {
|
| // We ignore certificate errors for http over spdy.
|
| spdy_certificate_error_ = result;
|
| result = OK;
|
| @@ -1107,8 +1104,7 @@ int HttpStreamFactoryImpl::Job::DoCreateStream() {
|
| FROM_HERE_WITH_EXPLICIT_FUNCTION(
|
| "462811 HttpStreamFactoryImpl::Job::DoCreateStream"));
|
| DCHECK(connection_->socket() || existing_spdy_session_.get() || using_quic_);
|
| - if (IsAlternate())
|
| - DCHECK(IsSpdyAlternate());
|
| + DCHECK(!is_quic_alternative_);
|
|
|
| next_state_ = STATE_CREATE_STREAM_COMPLETE;
|
|
|
| @@ -1119,7 +1115,7 @@ int HttpStreamFactoryImpl::Job::DoCreateStream() {
|
| SetSocketMotivation();
|
|
|
| if (!using_spdy_) {
|
| - DCHECK(!IsSpdyAlternate());
|
| + DCHECK(!is_spdy_alternative_);
|
| // We may get ftp scheme when fetching ftp resources through proxy.
|
| bool using_proxy = (proxy_info_.is_http() || proxy_info_.is_https()) &&
|
| (request_info_.url.SchemeIs("http") ||
|
| @@ -1249,7 +1245,7 @@ void HttpStreamFactoryImpl::Job::SetSocketMotivation() {
|
| bool HttpStreamFactoryImpl::Job::IsHttpsProxyAndHttpUrl() const {
|
| if (!proxy_info_.is_https())
|
| return false;
|
| - if (IsAlternate()) {
|
| + if (is_spdy_alternative_ || is_quic_alternative_) {
|
| // We currently only support Alternate-Protocol where the original scheme
|
| // is http.
|
| DCHECK(origin_url_.SchemeIs("http"));
|
| @@ -1258,15 +1254,6 @@ bool HttpStreamFactoryImpl::Job::IsHttpsProxyAndHttpUrl() const {
|
| return request_info_.url.SchemeIs("http");
|
| }
|
|
|
| -bool HttpStreamFactoryImpl::Job::IsAlternate() const {
|
| - return alternative_service_.protocol != UNINITIALIZED_ALTERNATE_PROTOCOL;
|
| -}
|
| -
|
| -bool HttpStreamFactoryImpl::Job::IsSpdyAlternate() const {
|
| - return alternative_service_.protocol >= NPN_SPDY_MINIMUM_VERSION &&
|
| - alternative_service_.protocol <= NPN_SPDY_MAXIMUM_VERSION;
|
| -}
|
| -
|
| void HttpStreamFactoryImpl::Job::InitSSLConfig(const HostPortPair& server,
|
| SSLConfig* ssl_config,
|
| bool is_proxy) const {
|
| @@ -1437,12 +1424,11 @@ void HttpStreamFactoryImpl::Job::ReportJobSucceededForRequest() {
|
| // If an existing session was used, then no TCP connection was
|
| // started.
|
| HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_NO_RACE);
|
| - } else if (IsAlternate()) {
|
| - // This job was the alternate protocol job, and hence won the race.
|
| + } else if (is_spdy_alternative_ || is_quic_alternative_) {
|
| + // This Job was the alternative Job, and hence won the race.
|
| HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_WON_RACE);
|
| } else {
|
| - // This job was the normal job, and hence the alternate protocol job lost
|
| - // the race.
|
| + // This Job was the normal Job, and hence the alternative Job lost the race.
|
| HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_LOST_RACE);
|
| }
|
| }
|
| @@ -1458,7 +1444,7 @@ void HttpStreamFactoryImpl::Job::MaybeMarkAlternativeServiceBroken() {
|
| if (job_status_ == STATUS_RUNNING || other_job_status_ == STATUS_RUNNING)
|
| return;
|
|
|
| - if (IsAlternate()) {
|
| + if (is_spdy_alternative_ || is_quic_alternative_) {
|
| if (job_status_ == STATUS_BROKEN && other_job_status_ == STATUS_SUCCEEDED) {
|
| HistogramBrokenAlternateProtocolLocation(
|
| BROKEN_ALTERNATE_PROTOCOL_LOCATION_HTTP_STREAM_FACTORY_IMPL_JOB_ALT);
|
| @@ -1479,10 +1465,10 @@ void HttpStreamFactoryImpl::Job::MaybeMarkAlternativeServiceBroken() {
|
| HttpStreamFactoryImpl::Job::ValidSpdySessionPool::ValidSpdySessionPool(
|
| SpdySessionPool* spdy_session_pool,
|
| GURL& origin_url,
|
| - bool is_spdy_alternate)
|
| + bool is_spdy_alternative)
|
| : spdy_session_pool_(spdy_session_pool),
|
| origin_url_(origin_url),
|
| - is_spdy_alternate_(is_spdy_alternate) {
|
| + is_spdy_alternative_(is_spdy_alternative) {
|
| }
|
|
|
| int HttpStreamFactoryImpl::Job::ValidSpdySessionPool::FindAvailableSession(
|
| @@ -1508,10 +1494,10 @@ int HttpStreamFactoryImpl::Job::ValidSpdySessionPool::
|
| int HttpStreamFactoryImpl::Job::ValidSpdySessionPool::
|
| CheckAlternativeServiceValidityForOrigin(
|
| base::WeakPtr<SpdySession> spdy_session) {
|
| - // For a SPDY alternate Job, server_.host() might be different than
|
| + // For an alternative Job, server_.host() might be different than
|
| // origin_url_.host(), therefore it needs to be verified that the former
|
| // provides a certificate that is valid for the latter.
|
| - if (!is_spdy_alternate_ || !spdy_session ||
|
| + if (!is_spdy_alternative_ || !spdy_session ||
|
| spdy_session->VerifyDomainAuthentication(origin_url_.host())) {
|
| return OK;
|
| }
|
| @@ -1521,7 +1507,7 @@ int HttpStreamFactoryImpl::Job::ValidSpdySessionPool::
|
| ClientSocketPoolManager::SocketGroupType
|
| HttpStreamFactoryImpl::Job::GetSocketGroup() const {
|
| std::string scheme = origin_url_.scheme();
|
| - if (scheme == "https" || scheme == "wss" || IsSpdyAlternate())
|
| + if (scheme == "https" || scheme == "wss" || is_spdy_alternative_)
|
| return ClientSocketPoolManager::SSL_GROUP;
|
|
|
| if (scheme == "ftp")
|
|
|