diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/http/http_request_info.h | 15 | ||||
-rw-r--r-- | net/http/http_stream_request.cc | 17 | ||||
-rw-r--r-- | net/http/http_stream_request.h | 3 |
3 files changed, 34 insertions, 1 deletions
diff --git a/net/http/http_request_info.h b/net/http/http_request_info.h index 1cd05e0..3c072c0 100644 --- a/net/http/http_request_info.h +++ b/net/http/http_request_info.h @@ -17,7 +17,17 @@ namespace net { struct HttpRequestInfo { public: - HttpRequestInfo() : load_flags(0), priority(LOWEST) { + enum RequestMotivation{ + // TODO(mbelshe): move these into Client Socket. + PRECONNECT_MOTIVATED, // This request was motivated by a prefetch. + OMNIBOX_MOTIVATED, // This request was motivated by the omnibox. + NORMAL_MOTIVATION // No special motivation associated with the request. + }; + + HttpRequestInfo() + : load_flags(0), + priority(LOWEST), + motivation(NORMAL_MOTIVATION) { } // The requested URL. @@ -40,6 +50,9 @@ struct HttpRequestInfo { // The priority level for this request. RequestPriority priority; + + // The motivation behind this request. + RequestMotivation motivation; }; } // namespace net diff --git a/net/http/http_stream_request.cc b/net/http/http_stream_request.cc index 4d6895c..d979e0a 100644 --- a/net/http/http_stream_request.cc +++ b/net/http/http_stream_request.cc @@ -14,6 +14,7 @@ #include "net/http/http_basic_stream.h" #include "net/http/http_network_session.h" #include "net/http/http_proxy_client_socket.h" +#include "net/http/http_request_info.h" #include "net/http/http_stream_handle.h" #include "net/spdy/spdy_http_stream.h" #include "net/spdy/spdy_session.h" @@ -665,6 +666,12 @@ int HttpStreamRequest::DoWaitingUserAction(int result) { int HttpStreamRequest::DoCreateStream() { next_state_ = STATE_CREATE_STREAM_COMPLETE; + // We only set the socket motivation if we're the first to use + // this socket. Is there a race for two SPDY requests? We really + // need to plumb this through to the connect level. + if (connection_.get() && connection_->is_reused()) + SetSocketMotivation(); + if (!using_spdy_) { HttpBasicStream* stream = new HttpBasicStream(connection_.get()); stream_.reset(new HttpStreamHandle(connection_.release(), stream)); @@ -750,6 +757,16 @@ int HttpStreamRequest::DoRestartTunnelAuthComplete(int result) { return ReconsiderProxyAfterError(result); } +void HttpStreamRequest::SetSocketMotivation() { + DCHECK(connection_.get()); + DCHECK(connection_->socket()); + if (request_info_->motivation == HttpRequestInfo::PRECONNECT_MOTIVATED) + connection_->socket()->SetSubresourceSpeculation(); + else if (request_info_->motivation == HttpRequestInfo::OMNIBOX_MOTIVATED) + connection_->socket()->SetOmniboxSpeculation(); + // TODO(mbelshe): Add other motivations (like EARLY_LOAD_MOTIVATED). +} + // Returns a newly create SSLSocketParams, and sets several // fields of ssl_config_. scoped_refptr<SSLSocketParams> HttpStreamRequest::GenerateSslParams( diff --git a/net/http/http_stream_request.h b/net/http/http_stream_request.h index 217d792..8b45530 100644 --- a/net/http/http_stream_request.h +++ b/net/http/http_stream_request.h @@ -108,6 +108,9 @@ class HttpStreamRequest : public StreamFactory::StreamRequestJob { int DoRestartTunnelAuth(); int DoRestartTunnelAuthComplete(int result); + // Set the motivation for this request onto the underlying socket. + void SetSocketMotivation(); + // Returns a newly create SSLSocketParams, and sets several // fields of ssl_config_. scoped_refptr<SSLSocketParams> GenerateSslParams( |