diff options
author | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-22 21:23:08 +0000 |
---|---|---|
committer | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-22 21:23:08 +0000 |
commit | a3b006eeabf17338e01dee885e9dfd19ec514c92 (patch) | |
tree | 1cfba5bd7f783d730a7504005055bb7eb424ef29 /net | |
parent | d50940e2d32793185f0c872e73c4d70691a0257c (diff) | |
download | chromium_src-a3b006eeabf17338e01dee885e9dfd19ec514c92.zip chromium_src-a3b006eeabf17338e01dee885e9dfd19ec514c92.tar.gz chromium_src-a3b006eeabf17338e01dee885e9dfd19ec514c92.tar.bz2 |
Defer the HttpNetworkSession initialization to first time CreateTransaction is called.
http://code.google.com/p/chromium/issues/detail?id=3639
Review URL: http://codereview.chromium.org/7854
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3767 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/http/http_network_layer.cc | 13 | ||||
-rw-r--r-- | net/http/http_network_layer.h | 6 |
2 files changed, 13 insertions, 6 deletions
diff --git a/net/http/http_network_layer.cc b/net/http/http_network_layer.cc index 1107884..1aaa226 100644 --- a/net/http/http_network_layer.cc +++ b/net/http/http_network_layer.cc @@ -46,18 +46,16 @@ void HttpNetworkLayer::UseWinHttp(bool value) { HttpNetworkLayer::HttpNetworkLayer(const ProxyInfo* pi) : suspended_(false) { - ProxyResolver* proxy_resolver; if (pi) { - proxy_resolver = new ProxyResolverFixed(*pi); + proxy_resolver_.reset(new ProxyResolverFixed(*pi)); } else { #if defined(OS_WIN) - proxy_resolver = new ProxyResolverWinHttp(); + proxy_resolver_.reset(new ProxyResolverWinHttp()); #else NOTIMPLEMENTED(); - proxy_resolver = new ProxyResolverNull(); + proxy_resolver_.reset(new ProxyResolverNull()); #endif } - session_ = new HttpNetworkSession(proxy_resolver); } HttpNetworkLayer::~HttpNetworkLayer() { @@ -67,6 +65,9 @@ HttpTransaction* HttpNetworkLayer::CreateTransaction() { if (suspended_) return NULL; + if (!session_) + session_ = new HttpNetworkSession(proxy_resolver_.release()); + return new HttpNetworkTransaction( session_, ClientSocketFactory::GetDefaultFactory()); } @@ -82,7 +83,7 @@ AuthCache* HttpNetworkLayer::GetAuthCache() { void HttpNetworkLayer::Suspend(bool suspend) { suspended_ = suspend; - if (suspend) + if (suspend && session_) session_->connection_pool()->CloseIdleSockets(); } diff --git a/net/http/http_network_layer.h b/net/http/http_network_layer.h index b4526a9..7597736 100644 --- a/net/http/http_network_layer.h +++ b/net/http/http_network_layer.h @@ -6,12 +6,14 @@ #define NET_HTTP_HTTP_NETWORK_LAYER_H_ #include "base/ref_counted.h" +#include "base/scoped_ptr.h" #include "net/http/http_transaction_factory.h" namespace net { class HttpNetworkSession; class ProxyInfo; +class ProxyResolver; class HttpNetworkLayer : public HttpTransactionFactory { public: @@ -38,6 +40,10 @@ class HttpNetworkLayer : public HttpTransactionFactory { static bool use_winhttp_; #endif + // The pending proxy resolver to use when lazily creating session_. + // NULL afterwards. + scoped_ptr<ProxyResolver> proxy_resolver_; + scoped_refptr<HttpNetworkSession> session_; bool suspended_; }; |