diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-23 00:08:48 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-23 00:08:48 +0000 |
commit | c4744cdbbe22df6848e354dbfa9dbb1dc36e76d8 (patch) | |
tree | b6d92d6b17ae0e140485fb53b53ef0017a99a6c0 /chrome/browser/net/preconnect.h | |
parent | 95fb385e5e68a69a39c77d66d801bebdaf39c311 (diff) | |
download | chromium_src-c4744cdbbe22df6848e354dbfa9dbb1dc36e76d8.zip chromium_src-c4744cdbbe22df6848e354dbfa9dbb1dc36e76d8.tar.gz chromium_src-c4744cdbbe22df6848e354dbfa9dbb1dc36e76d8.tar.bz2 |
Revert 75668 for breaking ChromeOS build - Refactor HttpStreamFactory.
Rename StreamFactory and StreamRequest to HttpStreamFactory and HttpStreamRequest.
Rename HttpStreamFactory to HttpStreamFactoryImpl.
Create HttpStreamFactoryImpl::Request (inherits from HttpStreamRequest) and HttpStreamFactoryImpl::Job (most of the old HttpStreamRequest code, other than the interface, moved here).
Currently there is still a strong binding within HttpStreamFactoryImpl between requests and jobs. This will be removed in a future changelist.
Note that due to the preparation for late binding, information like HttpRequestInfo and SSLConfig and ProxyInfo are just copied. It's possible we can consider refcounting them to reduce copies, but I think it's not worth the effort / ugliness.
I also did some minor cleanups like moving SpdySettingsStorage into SpdySessionPool and some CloseIdleConnections() cleanup.
BUG=54371,42669
TEST=unit tests
Review URL: http://codereview.chromium.org/6543004
TBR=willchan@chromium.org
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75670 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net/preconnect.h')
-rw-r--r-- | chrome/browser/net/preconnect.h | 75 |
1 files changed, 61 insertions, 14 deletions
diff --git a/chrome/browser/net/preconnect.h b/chrome/browser/net/preconnect.h index 0175122..a950167 100644 --- a/chrome/browser/net/preconnect.h +++ b/chrome/browser/net/preconnect.h @@ -9,25 +9,72 @@ #define CHROME_BROWSER_NET_PRECONNECT_H_ #pragma once +#include "base/scoped_ptr.h" #include "chrome/browser/net/url_info.h" +#include "net/base/completion_callback.h" +#include "net/base/net_log.h" +#include "net/http/http_request_info.h" +#include "net/http/stream_factory.h" -class GURL; +namespace net { + +class ProxyInfo; +struct SSLConfig; + +} // namespace net namespace chrome_browser_net { -// Try to preconnect. Typically motivated by OMNIBOX to reach search service. -// |count| may be used to request more than one connection be established in -// parallel. -void PreconnectOnUIThread(const GURL& url, - UrlInfo::ResolutionMotivation motivation, - int count); - -// Try to preconnect. Typically used by predictor when a subresource probably -// needs a connection. |count| may be used to request more than one connection -// be established in parallel. -void PreconnectOnIOThread(const GURL& url, - UrlInfo::ResolutionMotivation motivation, - int count); +class Preconnect { + public: + // Try to preconnect. Typically motivated by OMNIBOX to reach search service. + // |count| may be used to request more than one connection be established in + // parallel. + static void PreconnectOnUIThread(const GURL& url, + UrlInfo::ResolutionMotivation motivation, + int count); + + // Try to preconnect. Typically used by predictor when a subresource probably + // needs a connection. |count| may be used to request more than one connection + // be established in parallel. + static void PreconnectOnIOThread(const GURL& url, + UrlInfo::ResolutionMotivation motivation, + int count); + + private: + explicit Preconnect(UrlInfo::ResolutionMotivation motivation); + virtual ~Preconnect(); + + void OnPreconnectComplete(int error_code); + + // Request actual connection, via interface that tags request as needed for + // preconnect only (so that they can be merged with connections needed for + // navigations). + void Connect(const GURL& url, int count); + + // Generally either LEARNED_REFERAL_MOTIVATED, OMNIBOX_MOTIVATED or + // EARLY_LOAD_MOTIVATED to indicate why we were trying to do a preconnection. + const UrlInfo::ResolutionMotivation motivation_; + + // HttpRequestInfo used for connecting. + scoped_ptr<net::HttpRequestInfo> request_info_; + + // SSLConfig used for connecting. + scoped_ptr<net::SSLConfig> ssl_config_; + + // ProxyInfo used for connecting. + scoped_ptr<net::ProxyInfo> proxy_info_; + + // A net log to use for this preconnect. + net::BoundNetLog net_log_; + + // Our preconnect. + scoped_ptr<net::StreamRequest> stream_request_; + + net::CompletionCallbackImpl<Preconnect> io_callback_; + + DISALLOW_COPY_AND_ASSIGN(Preconnect); +}; } // namespace chrome_browser_net |