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 8cd2de0dbdf2a48d729226f74da1c951d6475426..c019da5e90b256907cf821aff88d8f79f68e8bd2 100644 |
--- a/net/http/http_stream_factory_impl_job.cc |
+++ b/net/http/http_stream_factory_impl_job.cc |
@@ -140,9 +140,8 @@ void HttpStreamFactoryImpl::Job::Start(Request* request) { |
int HttpStreamFactoryImpl::Job::Preconnect(int num_streams) { |
DCHECK_GT(num_streams, 0); |
- HostPortPair origin_server = |
- HostPortPair(request_info_.url.HostNoBrackets(), |
- request_info_.url.EffectiveIntPort()); |
+ HostPortPair origin_server = HostPortPair( |
+ request_info_.url.HostNoBrackets(), request_info_.url.EffectiveIntPort()); |
base::WeakPtr<HttpServerProperties> http_server_properties = |
session_->http_server_properties(); |
if (http_server_properties && |
@@ -204,7 +203,8 @@ void HttpStreamFactoryImpl::Job::Resume(Job* job) { |
base::MessageLoop::current()->PostTask( |
FROM_HERE, |
base::Bind(&HttpStreamFactoryImpl::Job::OnIOComplete, |
- ptr_factory_.GetWeakPtr(), OK)); |
+ ptr_factory_.GetWeakPtr(), |
+ OK)); |
} |
} |
@@ -217,8 +217,8 @@ void HttpStreamFactoryImpl::Job::Orphan(const Request* request) { |
DCHECK(blocking_job_->waiting_job_); |
blocking_job_->waiting_job_ = NULL; |
blocking_job_ = NULL; |
- if (stream_factory_->for_websockets_ && |
- connection_ && connection_->socket()) |
+ if (stream_factory_->for_websockets_ && connection_ && |
+ connection_->socket()) |
connection_->socket()->Disconnect(); |
stream_factory_->OnOrphanedJobComplete(this); |
} else if (stream_factory_->for_websockets_) { |
@@ -280,9 +280,7 @@ SpdySessionKey HttpStreamFactoryImpl::Job::GetSpdySessionKey() const { |
ProxyServer::Direct(), |
privacy_mode); |
} else { |
- return SpdySessionKey(origin_, |
- proxy_info_.proxy_server(), |
- privacy_mode); |
+ return SpdySessionKey(origin_, proxy_info_.proxy_server(), privacy_mode); |
} |
} |
@@ -295,8 +293,7 @@ bool HttpStreamFactoryImpl::Job::CanUseExistingSpdySession() const { |
// TODO(ricea): Add "wss" back to this list when SPDY WebSocket support is |
// working. |
return request_info_.url.SchemeIs("https") || |
- proxy_info_.proxy_server().is_https() || |
- force_spdy_always_; |
+ proxy_info_.proxy_server().is_https() || force_spdy_always_; |
} |
void HttpStreamFactoryImpl::Job::OnStreamReadyCallback() { |
@@ -306,12 +303,10 @@ void HttpStreamFactoryImpl::Job::OnStreamReadyCallback() { |
if (IsOrphaned()) { |
stream_factory_->OnOrphanedJobComplete(this); |
} else { |
- request_->Complete(was_npn_negotiated(), |
- protocol_negotiated(), |
- using_spdy(), |
- net_log_); |
- request_->OnStreamReady(this, server_ssl_config_, proxy_info_, |
- stream_.release()); |
+ request_->Complete( |
+ was_npn_negotiated(), protocol_negotiated(), using_spdy(), net_log_); |
+ request_->OnStreamReady( |
+ this, server_ssl_config_, proxy_info_, stream_.release()); |
} |
// |this| may be deleted after this call. |
} |
@@ -323,14 +318,10 @@ void HttpStreamFactoryImpl::Job::OnWebSocketHandshakeStreamReadyCallback() { |
// An orphaned WebSocket job will be closed immediately and |
// never be ready. |
DCHECK(!IsOrphaned()); |
- request_->Complete(was_npn_negotiated(), |
- protocol_negotiated(), |
- using_spdy(), |
- net_log_); |
- request_->OnWebSocketHandshakeStreamReady(this, |
- server_ssl_config_, |
- proxy_info_, |
- websocket_stream_.release()); |
+ request_->Complete( |
+ was_npn_negotiated(), protocol_negotiated(), using_spdy(), net_log_); |
+ request_->OnWebSocketHandshakeStreamReady( |
+ this, server_ssl_config_, proxy_info_, websocket_stream_.release()); |
// |this| may be deleted after this call. |
} |
@@ -344,9 +335,14 @@ void HttpStreamFactoryImpl::Job::OnNewSpdySessionReadyCallback() { |
new_spdy_session_.reset(); |
if (IsOrphaned()) { |
if (spdy_session) { |
- stream_factory_->OnNewSpdySessionReady( |
- spdy_session, spdy_session_direct_, server_ssl_config_, proxy_info_, |
- was_npn_negotiated(), protocol_negotiated(), using_spdy(), net_log_); |
+ stream_factory_->OnNewSpdySessionReady(spdy_session, |
+ spdy_session_direct_, |
+ server_ssl_config_, |
+ proxy_info_, |
+ was_npn_negotiated(), |
+ protocol_negotiated(), |
+ using_spdy(), |
+ net_log_); |
} |
stream_factory_->OnOrphanedJobComplete(this); |
} else { |
@@ -366,7 +362,8 @@ void HttpStreamFactoryImpl::Job::OnStreamFailedCallback(int result) { |
} |
void HttpStreamFactoryImpl::Job::OnCertificateErrorCallback( |
- int result, const SSLInfo& ssl_info) { |
+ int result, |
+ const SSLInfo& ssl_info) { |
DCHECK(!IsPreconnecting()); |
if (IsOrphaned()) |
stream_factory_->OnOrphanedJobComplete(this); |
@@ -434,9 +431,9 @@ int HttpStreamFactoryImpl::Job::OnHostResolution( |
// It is OK to dereference spdy_session_pool, because the |
// ClientSocketPoolManager will be destroyed in the same callback that |
// destroys the SpdySessionPool. |
- return |
- spdy_session_pool->FindAvailableSession(spdy_session_key, net_log) ? |
- ERR_SPDY_SESSION_ALREADY_EXISTS : OK; |
+ return spdy_session_pool->FindAvailableSession(spdy_session_key, net_log) |
+ ? ERR_SPDY_SESSION_ALREADY_EXISTS |
+ : OK; |
} |
void HttpStreamFactoryImpl::Job::OnIOComplete(int result) { |
@@ -469,7 +466,9 @@ int HttpStreamFactoryImpl::Job::RunLoop(int result) { |
base::MessageLoop::current()->PostTask( |
FROM_HERE, |
base::Bind(&HttpStreamFactoryImpl::Job::OnCertificateErrorCallback, |
- ptr_factory_.GetWeakPtr(), result, ssl_info_)); |
+ ptr_factory_.GetWeakPtr(), |
+ result, |
+ ssl_info_)); |
return ERR_IO_PENDING; |
} |
@@ -484,7 +483,8 @@ int HttpStreamFactoryImpl::Job::RunLoop(int result) { |
static_cast<ProxyClientSocket*>(connection_->socket()); |
base::MessageLoop::current()->PostTask( |
FROM_HERE, |
- base::Bind(&Job::OnNeedsProxyAuthCallback, ptr_factory_.GetWeakPtr(), |
+ base::Bind(&Job::OnNeedsProxyAuthCallback, |
+ ptr_factory_.GetWeakPtr(), |
*proxy_socket->GetConnectResponseInfo(), |
proxy_socket->GetAuthController())); |
return ERR_IO_PENDING; |
@@ -493,7 +493,8 @@ int HttpStreamFactoryImpl::Job::RunLoop(int result) { |
case ERR_SSL_CLIENT_AUTH_CERT_NEEDED: |
base::MessageLoop::current()->PostTask( |
FROM_HERE, |
- base::Bind(&Job::OnNeedsClientAuthCallback, ptr_factory_.GetWeakPtr(), |
+ base::Bind(&Job::OnNeedsClientAuthCallback, |
+ ptr_factory_.GetWeakPtr(), |
connection_->ssl_error_response_info().cert_request_info)); |
return ERR_IO_PENDING; |
@@ -537,8 +538,8 @@ int HttpStreamFactoryImpl::Job::RunLoop(int result) { |
default: |
base::MessageLoop::current()->PostTask( |
FROM_HERE, |
- base::Bind(&Job::OnStreamFailedCallback, ptr_factory_.GetWeakPtr(), |
- result)); |
+ base::Bind( |
+ &Job::OnStreamFailedCallback, ptr_factory_.GetWeakPtr(), result)); |
return ERR_IO_PENDING; |
} |
} |
@@ -612,13 +613,14 @@ int HttpStreamFactoryImpl::Job::StartInternal() { |
int HttpStreamFactoryImpl::Job::DoStart() { |
int port = request_info_.url.EffectiveIntPort(); |
origin_ = HostPortPair(request_info_.url.HostNoBrackets(), port); |
- origin_url_ = stream_factory_->ApplyHostMappingRules( |
- request_info_.url, &origin_); |
+ origin_url_ = |
+ stream_factory_->ApplyHostMappingRules(request_info_.url, &origin_); |
http_pipelining_key_.reset(new HttpPipelinedHost::Key(origin_)); |
net_log_.BeginEvent(NetLog::TYPE_HTTP_STREAM_JOB, |
base::Bind(&NetLogHttpStreamJobCallback, |
- &request_info_.url, &origin_url_, |
+ &request_info_.url, |
+ &origin_url_, |
priority_)); |
// Don't connect to restricted ports. |
@@ -704,8 +706,8 @@ bool HttpStreamFactoryImpl::Job::ShouldForceSpdyWithoutSSL() const { |
bool HttpStreamFactoryImpl::Job::ShouldForceQuic() const { |
return session_->params().enable_quic && |
- session_->params().origin_to_force_quic_on.Equals(origin_) && |
- proxy_info_.is_direct(); |
+ session_->params().origin_to_force_quic_on.Equals(origin_) && |
+ proxy_info_.is_direct(); |
} |
int HttpStreamFactoryImpl::Job::DoWaitForJob() { |
@@ -728,7 +730,7 @@ int HttpStreamFactoryImpl::Job::DoInitConnection() { |
next_state_ = STATE_INIT_CONNECTION_COMPLETE; |
using_ssl_ = request_info_.url.SchemeIs("https") || |
- request_info_.url.SchemeIs("wss") || ShouldForceSpdySSL(); |
+ request_info_.url.SchemeIs("wss") || ShouldForceSpdySSL(); |
using_spdy_ = false; |
if (ShouldForceQuic()) |
@@ -744,13 +746,17 @@ int HttpStreamFactoryImpl::Job::DoInitConnection() { |
// TODO(rch): support QUIC proxies for HTTPS urls. |
return ERR_NOT_IMPLEMENTED; |
} |
- HostPortPair destination = proxy_info_.is_quic() ? |
- proxy_info_.proxy_server().host_port_pair() : origin_; |
+ HostPortPair destination = proxy_info_.is_quic() |
+ ? proxy_info_.proxy_server().host_port_pair() |
+ : origin_; |
next_state_ = STATE_INIT_CONNECTION_COMPLETE; |
bool secure_quic = using_ssl_ || proxy_info_.is_quic(); |
- int rv = quic_request_.Request( |
- destination, secure_quic, request_info_.privacy_mode, |
- request_info_.method, net_log_, io_callback_); |
+ int rv = quic_request_.Request(destination, |
+ secure_quic, |
+ request_info_.privacy_mode, |
+ request_info_.method, |
+ net_log_, |
+ io_callback_); |
if (rv == OK) { |
using_existing_quic_session_ = true; |
} else { |
@@ -768,8 +774,8 @@ int HttpStreamFactoryImpl::Job::DoInitConnection() { |
// straight to using that. |
SpdySessionKey spdy_session_key = GetSpdySessionKey(); |
base::WeakPtr<SpdySession> spdy_session = |
- session_->spdy_session_pool()->FindAvailableSession( |
- spdy_session_key, net_log_); |
+ session_->spdy_session_pool()->FindAvailableSession(spdy_session_key, |
+ net_log_); |
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. |
@@ -791,13 +797,14 @@ int HttpStreamFactoryImpl::Job::DoInitConnection() { |
// this key. This is different than normal pipelines, which may be |
// unavailable or unusable. So, there is no need to worry about a race |
// between when a pipeline becomes available and when this job blocks. |
- existing_available_pipeline_ = stream_factory_->http_pipelined_host_pool_. |
- IsExistingPipelineAvailableForKey(*http_pipelining_key_.get()); |
+ existing_available_pipeline_ = |
+ stream_factory_->http_pipelined_host_pool_ |
+ .IsExistingPipelineAvailableForKey(*http_pipelining_key_.get()); |
if (existing_available_pipeline_) { |
return OK; |
} else { |
- bool was_new_key = request_->SetHttpPipeliningKey( |
- *http_pipelining_key_.get()); |
+ bool was_new_key = |
+ request_->SetHttpPipeliningKey(*http_pipelining_key_.get()); |
if (!was_new_key && session_->force_http_pipelining()) { |
return ERR_IO_PENDING; |
} |
@@ -826,50 +833,67 @@ int HttpStreamFactoryImpl::Job::DoInitConnection() { |
proxy_ssl_config_.rev_checking_enabled = false; |
} |
if (using_ssl_) { |
- InitSSLConfig(origin_, &server_ssl_config_, |
- false /* not a proxy server */); |
+ InitSSLConfig(origin_, &server_ssl_config_, false /* not a proxy server */); |
} |
if (IsPreconnecting()) { |
DCHECK(!stream_factory_->for_websockets_); |
- return PreconnectSocketsForHttpRequest( |
- origin_url_, |
- request_info_.extra_headers, |
- request_info_.load_flags, |
- priority_, |
- session_, |
- proxy_info_, |
- ShouldForceSpdySSL(), |
- want_spdy_over_npn, |
- server_ssl_config_, |
- proxy_ssl_config_, |
- request_info_.privacy_mode, |
- net_log_, |
- num_streams_); |
+ return PreconnectSocketsForHttpRequest(origin_url_, |
+ request_info_.extra_headers, |
+ request_info_.load_flags, |
+ priority_, |
+ session_, |
+ proxy_info_, |
+ ShouldForceSpdySSL(), |
+ want_spdy_over_npn, |
+ server_ssl_config_, |
+ proxy_ssl_config_, |
+ request_info_.privacy_mode, |
+ 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(); |
+ OnHostResolutionCallback resolution_callback = |
+ CanUseExistingSpdySession() ? base::Bind(&Job::OnHostResolution, |
+ session_->spdy_session_pool(), |
+ GetSpdySessionKey()) |
+ : OnHostResolutionCallback(); |
if (stream_factory_->for_websockets_) { |
// TODO(ricea): Re-enable NPN when WebSockets over SPDY is supported. |
SSLConfig websocket_server_ssl_config = server_ssl_config_; |
websocket_server_ssl_config.next_protos.clear(); |
- return InitSocketHandleForWebSocketRequest( |
- origin_url_, request_info_.extra_headers, request_info_.load_flags, |
- priority_, session_, proxy_info_, ShouldForceSpdySSL(), |
- want_spdy_over_npn, websocket_server_ssl_config, proxy_ssl_config_, |
- request_info_.privacy_mode, net_log_, |
- connection_.get(), resolution_callback, io_callback_); |
+ return InitSocketHandleForWebSocketRequest(origin_url_, |
+ request_info_.extra_headers, |
+ request_info_.load_flags, |
+ priority_, |
+ session_, |
+ proxy_info_, |
+ ShouldForceSpdySSL(), |
+ want_spdy_over_npn, |
+ websocket_server_ssl_config, |
+ proxy_ssl_config_, |
+ request_info_.privacy_mode, |
+ net_log_, |
+ connection_.get(), |
+ resolution_callback, |
+ io_callback_); |
} |
- return InitSocketHandleForHttpRequest( |
- origin_url_, request_info_.extra_headers, request_info_.load_flags, |
- priority_, session_, proxy_info_, ShouldForceSpdySSL(), |
- want_spdy_over_npn, server_ssl_config_, proxy_ssl_config_, |
- request_info_.privacy_mode, net_log_, |
- connection_.get(), resolution_callback, io_callback_); |
+ return InitSocketHandleForHttpRequest(origin_url_, |
+ request_info_.extra_headers, |
+ request_info_.load_flags, |
+ priority_, |
+ session_, |
+ proxy_info_, |
+ ShouldForceSpdySSL(), |
+ want_spdy_over_npn, |
+ server_ssl_config_, |
+ proxy_ssl_config_, |
+ request_info_.privacy_mode, |
+ net_log_, |
+ connection_.get(), |
+ resolution_callback, |
+ io_callback_); |
} |
} |
@@ -886,8 +910,8 @@ int HttpStreamFactoryImpl::Job::DoInitConnectionComplete(int result) { |
// probably an IP pooled connection. |
SpdySessionKey spdy_session_key = GetSpdySessionKey(); |
existing_spdy_session_ = |
- session_->spdy_session_pool()->FindAvailableSession( |
- spdy_session_key, net_log_); |
+ session_->spdy_session_pool()->FindAvailableSession(spdy_session_key, |
+ net_log_); |
if (existing_spdy_session_) { |
using_spdy_ = true; |
next_state_ = STATE_CREATE_STREAM; |
@@ -939,20 +963,20 @@ int HttpStreamFactoryImpl::Job::DoInitConnectionComplete(int result) { |
NextProto protocol_negotiated = |
SSLClientSocket::NextProtoFromString(proto); |
protocol_negotiated_ = protocol_negotiated; |
- net_log_.AddEvent( |
- NetLog::TYPE_HTTP_STREAM_REQUEST_PROTO, |
- base::Bind(&NetLogHttpStreamProtoCallback, |
- status, &proto, &server_protos)); |
+ net_log_.AddEvent(NetLog::TYPE_HTTP_STREAM_REQUEST_PROTO, |
+ base::Bind(&NetLogHttpStreamProtoCallback, |
+ status, |
+ &proto, |
+ &server_protos)); |
if (ssl_socket->was_spdy_negotiated()) |
SwitchToSpdyMode(); |
} |
if (ShouldForceSpdySSL()) |
SwitchToSpdyMode(); |
} |
- } else if (proxy_info_.is_https() && connection_->socket() && |
- result == OK) { |
+ } else if (proxy_info_.is_https() && connection_->socket() && result == OK) { |
ProxyClientSocket* proxy_socket = |
- static_cast<ProxyClientSocket*>(connection_->socket()); |
+ static_cast<ProxyClientSocket*>(connection_->socket()); |
if (proxy_socket->IsUsingSpdy()) { |
was_npn_negotiated_ = true; |
protocol_negotiated_ = proxy_socket->GetProtocolNegotiated(); |
@@ -1059,12 +1083,12 @@ int HttpStreamFactoryImpl::Job::DoCreateStream() { |
bool using_proxy = (proxy_info_.is_http() || proxy_info_.is_https()) && |
(request_info_.url.SchemeIs("http") || |
request_info_.url.SchemeIs("ftp")); |
- if (stream_factory_->http_pipelined_host_pool_. |
- IsExistingPipelineAvailableForKey(*http_pipelining_key_.get())) { |
+ if (stream_factory_->http_pipelined_host_pool_ |
+ .IsExistingPipelineAvailableForKey(*http_pipelining_key_.get())) { |
DCHECK(!stream_factory_->for_websockets_); |
- stream_.reset(stream_factory_->http_pipelined_host_pool_. |
- CreateStreamOnExistingPipeline( |
- *http_pipelining_key_.get())); |
+ stream_.reset( |
+ stream_factory_->http_pipelined_host_pool_ |
+ .CreateStreamOnExistingPipeline(*http_pipelining_key_.get())); |
CHECK(stream_.get()); |
} else if (stream_factory_->for_websockets_) { |
DCHECK(request_); |
@@ -1268,20 +1292,19 @@ void HttpStreamFactoryImpl::Job::InitSSLConfig( |
break; |
} |
} |
- UMA_HISTOGRAM_ENUMERATION("Net.ConnectionUsedSSLVersionFallback", |
- fallback, FALLBACK_MAX); |
+ UMA_HISTOGRAM_ENUMERATION( |
+ "Net.ConnectionUsedSSLVersionFallback", fallback, FALLBACK_MAX); |
// We also wish to measure the amount of fallback connections for a host that |
// we know implements TLS up to 1.2. Ideally there would be no fallback here |
// but high numbers of SSLv3 would suggest that SSLv3 fallback is being |
// caused by network middleware rather than buggy HTTPS servers. |
const std::string& host = origin_server.host(); |
- if (!is_proxy && |
- host.size() >= 10 && |
+ if (!is_proxy && host.size() >= 10 && |
host.compare(host.size() - 10, 10, "google.com") == 0 && |
- (host.size() == 10 || host[host.size()-11] == '.')) { |
- UMA_HISTOGRAM_ENUMERATION("Net.GoogleConnectionUsedSSLVersionFallback", |
- fallback, FALLBACK_MAX); |
+ (host.size() == 10 || host[host.size() - 11] == '.')) { |
+ UMA_HISTOGRAM_ENUMERATION( |
+ "Net.GoogleConnectionUsedSSLVersionFallback", fallback, FALLBACK_MAX); |
} |
if (request_info_.load_flags & LOAD_VERIFY_EV_CERT) |
@@ -1292,7 +1315,6 @@ void HttpStreamFactoryImpl::Job::InitSSLConfig( |
ssl_config->channel_id_enabled = false; |
} |
- |
int HttpStreamFactoryImpl::Job::ReconsiderProxyAfterError(int error) { |
DCHECK(!pac_request_); |
@@ -1412,8 +1434,8 @@ void HttpStreamFactoryImpl::Job::SwitchToSpdyMode() { |
// static |
void HttpStreamFactoryImpl::Job::LogHttpConnectedMetrics( |
const ClientSocketHandle& handle) { |
- UMA_HISTOGRAM_ENUMERATION("Net.HttpSocketType", handle.reuse_type(), |
- ClientSocketHandle::NUM_TYPES); |
+ UMA_HISTOGRAM_ENUMERATION( |
+ "Net.HttpSocketType", handle.reuse_type(), ClientSocketHandle::NUM_TYPES); |
switch (handle.reuse_type()) { |
case ClientSocketHandle::UNUSED: |
@@ -1486,9 +1508,8 @@ bool HttpStreamFactoryImpl::Job::IsRequestEligibleForPipelining() { |
if (request_info_.method != "GET" && request_info_.method != "HEAD") { |
return false; |
} |
- if (request_info_.load_flags & |
- (net::LOAD_MAIN_FRAME | net::LOAD_SUB_FRAME | net::LOAD_PREFETCH | |
- net::LOAD_IS_DOWNLOAD)) { |
+ if (request_info_.load_flags & (net::LOAD_MAIN_FRAME | net::LOAD_SUB_FRAME | |
+ net::LOAD_PREFETCH | net::LOAD_IS_DOWNLOAD)) { |
// Avoid pipelining resources that may be streamed for a long time. |
return false; |
} |