diff options
author | mbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-03 09:08:10 +0000 |
---|---|---|
committer | mbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-03 09:08:10 +0000 |
commit | e326922daea12d085dc61eec267148e284a1bb0e (patch) | |
tree | 4e5bbf2ff781147be0c9d5668f5b1965be704a70 /net | |
parent | 66da158f592f654fab11b6c98d2d9d5290c7ece4 (diff) | |
download | chromium_src-e326922daea12d085dc61eec267148e284a1bb0e.zip chromium_src-e326922daea12d085dc61eec267148e284a1bb0e.tar.gz chromium_src-e326922daea12d085dc61eec267148e284a1bb0e.tar.bz2 |
Update the Preconnect logic to use the new HttpStreamFactory for
creating connections rather than doing it manually.
With this update, I believe we no longer need to avoid preconnects
through proxies. The new logic can handle that case.
Also updated the predictor_api slightly for the next wave of work.
BUG=none
TEST=existing
Review URL: http://codereview.chromium.org/3226011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58464 0039d316-1c4b-4281-b951-d872f2087c98
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( |