| 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 b88b622c19d76bac4a487c1ebeb5ede011019841..5ef3379151bcaa00d2e3d708dd102d2d56845f5e 100644
|
| --- a/net/http/http_stream_factory_impl_job.cc
|
| +++ b/net/http/http_stream_factory_impl_job.cc
|
| @@ -241,6 +241,9 @@ void HttpStreamFactoryImpl::Job::GetSSLInfo() {
|
| }
|
|
|
| HostPortProxyPair HttpStreamFactoryImpl::Job::GetSpdySessionKey() const {
|
| + // In the case that we're using an HTTPS proxy for an HTTP url,
|
| + // we look for a SPDY session *to* the proxy, instead of to the
|
| + // origin server.
|
| if (IsHttpsProxyAndHttpUrl()) {
|
| return HostPortProxyPair(proxy_info_.proxy_server().host_port_pair(),
|
| ProxyServer::Direct());
|
| @@ -249,6 +252,17 @@ HostPortProxyPair HttpStreamFactoryImpl::Job::GetSpdySessionKey() const {
|
| }
|
| }
|
|
|
| +bool HttpStreamFactoryImpl::Job::CanUseExistingSpdySession() const {
|
| + // We need to make sure that if a spdy session was created for
|
| + // https://somehost/ that we don't use that session for http://somehost:443/.
|
| + // The only time we can use an existing session is if the request URL is
|
| + // https (the normal case) or if we're connection to a SPDY proxy, or
|
| + // if we're running with force_spdy_always_. crbug.com/133176
|
| + return request_info_.url.SchemeIs("https") ||
|
| + proxy_info_.proxy_server().is_https() ||
|
| + force_spdy_always_;
|
| +}
|
| +
|
| void HttpStreamFactoryImpl::Job::OnStreamReadyCallback() {
|
| DCHECK(stream_.get());
|
| DCHECK(!IsPreconnecting());
|
| @@ -651,7 +665,7 @@ int HttpStreamFactoryImpl::Job::DoInitConnection() {
|
| HostPortProxyPair spdy_session_key = GetSpdySessionKey();
|
| scoped_refptr<SpdySession> spdy_session =
|
| session_->spdy_session_pool()->GetIfExists(spdy_session_key, net_log_);
|
| - if (spdy_session) {
|
| + if (spdy_session && CanUseExistingSpdySession()) {
|
| // If we're preconnecting, but we already have a SpdySession, we don't
|
| // actually need to preconnect any sockets, so we're done.
|
| if (IsPreconnecting())
|
| @@ -724,15 +738,17 @@ int HttpStreamFactoryImpl::Job::DoInitConnection() {
|
| net_log_,
|
| num_streams_);
|
| } else {
|
| + // If we can't use a SPDY session, don't both checking for one after
|
| + // the hostname is resolved.
|
| + OnHostResolutionCallback resolution_callback = CanUseExistingSpdySession() ?
|
| + base::Bind(&Job::OnHostResolution, session_->spdy_session_pool(),
|
| + GetSpdySessionKey()) :
|
| + OnHostResolutionCallback();
|
| return InitSocketHandleForHttpRequest(
|
| origin_url_, request_info_.extra_headers, request_info_.load_flags,
|
| request_info_.priority, session_, proxy_info_, ShouldForceSpdySSL(),
|
| want_spdy_over_npn, server_ssl_config_, proxy_ssl_config_, net_log_,
|
| - connection_.get(),
|
| - //OnHostResolutionCallback(),
|
| - base::Bind(&Job::OnHostResolution, session_->spdy_session_pool(),
|
| - GetSpdySessionKey()),
|
| - io_callback_);
|
| + connection_.get(), resolution_callback, io_callback_);
|
| }
|
| }
|
|
|
|
|