diff options
author | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-10 04:11:27 +0000 |
---|---|---|
committer | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-10 04:11:27 +0000 |
commit | 63de95b265c665320b776c821f4cc44872c65c87 (patch) | |
tree | d60769b5e1907b060870af7d88ed567671a24e4e /net/http | |
parent | bcdae8c9c9d90889fa0ca6491ae191a9e2f944b4 (diff) | |
download | chromium_src-63de95b265c665320b776c821f4cc44872c65c87.zip chromium_src-63de95b265c665320b776c821f4cc44872c65c87.tar.gz chromium_src-63de95b265c665320b776c821f4cc44872c65c87.tar.bz2 |
Misc proxy service changes.
(1) Changed the proxy service ownership model -- rather than being a
detail of the HTTP stack, it is now a dependency owned by
UrlRequestContext.
- ProxyService is owned by UrlRequestContext (before was
HttpNetworkSession)
- ProxyResolver is owned by ProxyService (before was
HttpNetworkSession)
Being able to share the proxy service is needed in several places,
including incognito mode http context (http://crbug.com/3564), and for
proxy resolving in the new FTP stack.
(2) Added an IPC for getting of the ProxyResolverWinHttp dependency in
the plugin process. Not hooked up yet, but intent is to route the
proxy resolve requests through the browser process.
(3) Changed some unit tests which were depending on the system proxy
settings (this was a sideffect of their calling
HttpNetworkLayer::CreateFactory(NULL)).
(4) Moved the first-time ProxyService::UpdateConfig out of the
constructor and into the initial request. Done to avoid startup
perf regressions, since the ProxyService construction is now done
earlier (on the startup critical path).
BUG=3564
Review URL: http://codereview.chromium.org/12938
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6693 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http')
-rw-r--r-- | net/http/http_cache.cc | 8 | ||||
-rw-r--r-- | net/http/http_cache.h | 10 | ||||
-rw-r--r-- | net/http/http_network_layer.cc | 35 | ||||
-rw-r--r-- | net/http/http_network_layer.h | 12 | ||||
-rw-r--r-- | net/http/http_network_layer_unittest.cc | 11 | ||||
-rw-r--r-- | net/http/http_network_session.h | 14 | ||||
-rw-r--r-- | net/http/http_network_transaction_unittest.cc | 55 | ||||
-rw-r--r-- | net/http/http_transaction_winhttp.cc | 24 | ||||
-rw-r--r-- | net/http/http_transaction_winhttp.h | 12 | ||||
-rw-r--r-- | net/http/http_transaction_winhttp_unittest.cc | 10 |
10 files changed, 89 insertions, 102 deletions
diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc index b82795c..fbc2b0f 100644 --- a/net/http/http_cache.cc +++ b/net/http/http_cache.cc @@ -916,20 +916,20 @@ void HttpCache::Transaction::OnCacheReadCompleted(int result) { //----------------------------------------------------------------------------- -HttpCache::HttpCache(const ProxyInfo* proxy_info, +HttpCache::HttpCache(ProxyService* proxy_service, const std::wstring& cache_dir, int cache_size) : disk_cache_dir_(cache_dir), mode_(NORMAL), - network_layer_(HttpNetworkLayer::CreateFactory(proxy_info)), + network_layer_(HttpNetworkLayer::CreateFactory(proxy_service)), ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)), in_memory_cache_(false), cache_size_(cache_size) { } -HttpCache::HttpCache(const ProxyInfo* proxy_info, int cache_size) +HttpCache::HttpCache(ProxyService* proxy_service, int cache_size) : mode_(NORMAL), - network_layer_(HttpNetworkLayer::CreateFactory(proxy_info)), + network_layer_(HttpNetworkLayer::CreateFactory(proxy_service)), ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)), in_memory_cache_(true), cache_size_(cache_size) { diff --git a/net/http/http_cache.h b/net/http/http_cache.h index 22f0754..9729527 100644 --- a/net/http/http_cache.h +++ b/net/http/http_cache.h @@ -31,7 +31,7 @@ namespace net { class HttpRequestInfo; class HttpResponseInfo; -class ProxyInfo; +class ProxyService; class HttpCache : public HttpTransactionFactory { public: @@ -51,16 +51,14 @@ class HttpCache : public HttpTransactionFactory { // Initialize the cache from the directory where its data is stored. The // disk cache is initialized lazily (by CreateTransaction) in this case. If // |cache_size| is zero, a default value will be calculated automatically. - // If the proxy information is null, then the system settings will be used. - HttpCache(const ProxyInfo* proxy_info, + HttpCache(ProxyService* proxy_service, const std::wstring& cache_dir, int cache_size); // Initialize using an in-memory cache. The cache is initialized lazily // (by CreateTransaction) in this case. If |cache_size| is zero, a default - // value will be calculated automatically. If the proxy information is null, - // then the system settings will be used. - HttpCache(const ProxyInfo* proxy_info, int cache_size); + // value will be calculated automatically. + HttpCache(ProxyService* proxy_service, int cache_size); // Initialize the cache from its component parts, which is useful for // testing. The lifetime of the network_layer and disk_cache are managed by diff --git a/net/http/http_network_layer.cc b/net/http/http_network_layer.cc index 78b8aa6..2b84682 100644 --- a/net/http/http_network_layer.cc +++ b/net/http/http_network_layer.cc @@ -8,13 +8,8 @@ #include "net/base/client_socket_factory.h" #include "net/http/http_network_session.h" #include "net/http/http_network_transaction.h" -#include "net/proxy/proxy_resolver_fixed.h" -#include "net/proxy/proxy_resolver_null.h" #if defined(OS_WIN) #include "net/http/http_transaction_winhttp.h" -#include "net/proxy/proxy_resolver_winhttp.h" -#elif defined(OS_MACOSX) -#include "net/proxy/proxy_resolver_mac.h" #endif namespace net { @@ -28,13 +23,14 @@ bool HttpNetworkLayer::use_winhttp_ = false; // static HttpTransactionFactory* HttpNetworkLayer::CreateFactory( - const ProxyInfo* pi) { + ProxyService* proxy_service) { + DCHECK(proxy_service); #if defined(OS_WIN) if (use_winhttp_) - return new HttpTransactionWinHttp::Factory(pi); + return new HttpTransactionWinHttp::Factory(proxy_service); #endif - return new HttpNetworkLayer(pi); + return new HttpNetworkLayer(proxy_service); } #if defined(OS_WIN) @@ -46,24 +42,9 @@ void HttpNetworkLayer::UseWinHttp(bool value) { //----------------------------------------------------------------------------- -HttpNetworkLayer::HttpNetworkLayer(const ProxyInfo* pi) - : suspended_(false) { - if (pi) { - proxy_resolver_.reset(new ProxyResolverFixed(*pi)); - } else { -#if defined(OS_WIN) - proxy_resolver_.reset(new ProxyResolverWinHttp()); -#elif defined(OS_MACOSX) - proxy_resolver_.reset(new ProxyResolverMac()); -#else - // This used to be a NOTIMPLEMENTED(), but that logs as an error, - // screwing up layout tests. - LOG(WARNING) << "Proxies are not implemented; remove me once that's fixed."; - // http://code.google.com/p/chromium/issues/detail?id=4523 is the bug - // to implement this. - proxy_resolver_.reset(new ProxyResolverNull()); -#endif - } +HttpNetworkLayer::HttpNetworkLayer(ProxyService* proxy_service) + : proxy_service_(proxy_service), suspended_(false) { + DCHECK(proxy_service_); } HttpNetworkLayer::~HttpNetworkLayer() { @@ -74,7 +55,7 @@ HttpTransaction* HttpNetworkLayer::CreateTransaction() { return NULL; if (!session_) - session_ = new HttpNetworkSession(proxy_resolver_.release()); + session_ = new HttpNetworkSession(proxy_service_); return new HttpNetworkTransaction( session_, ClientSocketFactory::GetDefaultFactory()); diff --git a/net/http/http_network_layer.h b/net/http/http_network_layer.h index 93e7eb4..5364642 100644 --- a/net/http/http_network_layer.h +++ b/net/http/http_network_layer.h @@ -13,16 +13,17 @@ namespace net { class HttpNetworkSession; class ProxyInfo; -class ProxyResolver; +class ProxyService; class HttpNetworkLayer : public HttpTransactionFactory { public: - explicit HttpNetworkLayer(const ProxyInfo* pi); + // |proxy_service| must remain valid for the lifetime of HttpNetworkLayer. + explicit HttpNetworkLayer(ProxyService* proxy_service); ~HttpNetworkLayer(); // This function hides the details of how a network layer gets instantiated // and allows other implementations to be substituted. - static HttpTransactionFactory* CreateFactory(const ProxyInfo* pi); + static HttpTransactionFactory* CreateFactory(ProxyService* proxy_service); #if defined(OS_WIN) // If value is true, then WinHTTP will be used. @@ -39,9 +40,8 @@ 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_; + // The proxy service being used for the session. + ProxyService* proxy_service_; scoped_refptr<HttpNetworkSession> session_; bool suspended_; diff --git a/net/http/http_network_layer_unittest.cc b/net/http/http_network_layer_unittest.cc index 2bccd8a..0460947 100644 --- a/net/http/http_network_layer_unittest.cc +++ b/net/http/http_network_layer_unittest.cc @@ -5,6 +5,7 @@ #include "net/base/scoped_host_mapper.h" #include "net/http/http_network_layer.h" #include "net/http/http_transaction_unittest.h" +#include "net/proxy/proxy_resolver_null.h" #include "net/proxy/proxy_service.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h" @@ -21,13 +22,15 @@ class HttpNetworkLayerTest : public PlatformTest { }; TEST_F(HttpNetworkLayerTest, CreateAndDestroy) { - net::HttpNetworkLayer factory(NULL); + net::ProxyService proxy_service(new net::ProxyResolverNull); + net::HttpNetworkLayer factory(&proxy_service); scoped_ptr<net::HttpTransaction> trans(factory.CreateTransaction()); } TEST_F(HttpNetworkLayerTest, Suspend) { - net::HttpNetworkLayer factory(NULL); + net::ProxyService proxy_service(new net::ProxyResolverNull); + net::HttpNetworkLayer factory(&proxy_service); scoped_ptr<net::HttpTransaction> trans(factory.CreateTransaction()); trans.reset(); @@ -43,8 +46,8 @@ TEST_F(HttpNetworkLayerTest, Suspend) { } TEST_F(HttpNetworkLayerTest, GoogleGET) { - net::ProxyInfo no_proxy; // Avoid using a proxy server. - net::HttpNetworkLayer factory(&no_proxy); + net::ProxyService proxy_service(new net::ProxyResolverNull); + net::HttpNetworkLayer factory(&proxy_service); TestCompletionCallback callback; diff --git a/net/http/http_network_session.h b/net/http/http_network_session.h index 11ccc26c..d998665 100644 --- a/net/http/http_network_session.h +++ b/net/http/http_network_session.h @@ -9,10 +9,11 @@ #include "net/base/client_socket_pool.h" #include "net/base/ssl_config_service.h" #include "net/http/http_auth_cache.h" -#include "net/proxy/proxy_service.h" namespace net { +class ProxyService; + // This class holds session objects used by HttpNetworkTransaction objects. class HttpNetworkSession : public base::RefCounted<HttpNetworkSession> { public: @@ -21,15 +22,15 @@ class HttpNetworkSession : public base::RefCounted<HttpNetworkSession> { MAX_SOCKETS_PER_GROUP = 6 }; - explicit HttpNetworkSession(ProxyResolver* proxy_resolver) + explicit HttpNetworkSession(ProxyService* proxy_service) : connection_pool_(new ClientSocketPool(MAX_SOCKETS_PER_GROUP)), - proxy_resolver_(proxy_resolver), - proxy_service_(proxy_resolver) { + proxy_service_(proxy_service) { + DCHECK(proxy_service); } HttpAuthCache* auth_cache() { return &auth_cache_; } ClientSocketPool* connection_pool() { return connection_pool_; } - ProxyService* proxy_service() { return &proxy_service_; } + ProxyService* proxy_service() { return proxy_service_; } #if defined(OS_WIN) SSLConfigService* ssl_config_service() { return &ssl_config_service_; } #endif @@ -37,8 +38,7 @@ class HttpNetworkSession : public base::RefCounted<HttpNetworkSession> { private: HttpAuthCache auth_cache_; scoped_refptr<ClientSocketPool> connection_pool_; - scoped_ptr<ProxyResolver> proxy_resolver_; - ProxyService proxy_service_; + ProxyService* proxy_service_; #if defined(OS_WIN) // TODO(port): Port the SSLConfigService class to Linux and Mac OS X. SSLConfigService ssl_config_service_; diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc index 68a643e..903f6d9 100644 --- a/net/http/http_network_transaction_unittest.cc +++ b/net/http/http_network_transaction_unittest.cc @@ -200,15 +200,13 @@ class MockClientSocketFactory : public net::ClientSocketFactory { MockClientSocketFactory mock_socket_factory; -net::HttpNetworkSession* CreateSession(net::ProxyResolver* proxy_resolver) { - if (!proxy_resolver) { - proxy_resolver = new net::ProxyResolverNull(); - } - return new net::HttpNetworkSession(proxy_resolver); +// Create a proxy service which fails on all requests (falls back to direct). +net::ProxyService* CreateNullProxyService() { + return new net::ProxyService(new net::ProxyResolverNull); } -net::HttpNetworkSession* CreateSession() { - return CreateSession(NULL); +net::HttpNetworkSession* CreateSession(net::ProxyService* proxy_service) { + return new net::HttpNetworkSession(proxy_service); } class HttpNetworkTransactionTest : public PlatformTest { @@ -238,8 +236,9 @@ struct SimpleGetHelperResult { SimpleGetHelperResult SimpleGetHelper(MockRead data_reads[]) { SimpleGetHelperResult out; + scoped_ptr<net::ProxyService> proxy_service(CreateNullProxyService()); scoped_ptr<net::HttpTransaction> trans(new net::HttpNetworkTransaction( - CreateSession(), &mock_socket_factory)); + CreateSession(proxy_service.get()), &mock_socket_factory)); net::HttpRequestInfo request; request.method = "GET"; @@ -290,8 +289,9 @@ void FillLargeHeadersString(std::string* str, int size) { //----------------------------------------------------------------------------- TEST_F(HttpNetworkTransactionTest, Basic) { + scoped_ptr<net::ProxyService> proxy_service(CreateNullProxyService()); scoped_ptr<net::HttpTransaction> trans(new net::HttpNetworkTransaction( - CreateSession(), &mock_socket_factory)); + CreateSession(proxy_service.get()), &mock_socket_factory)); } TEST_F(HttpNetworkTransactionTest, SimpleGET) { @@ -398,7 +398,9 @@ TEST_F(HttpNetworkTransactionTest, StopsReading204) { } TEST_F(HttpNetworkTransactionTest, ReuseConnection) { - scoped_refptr<net::HttpNetworkSession> session = CreateSession(); + scoped_ptr<net::ProxyService> proxy_service(CreateNullProxyService()); + scoped_refptr<net::HttpNetworkSession> session = + CreateSession(proxy_service.get()); MockRead data_reads[] = { MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"), @@ -447,8 +449,9 @@ TEST_F(HttpNetworkTransactionTest, ReuseConnection) { } TEST_F(HttpNetworkTransactionTest, Ignores100) { + scoped_ptr<net::ProxyService> proxy_service(CreateNullProxyService()); scoped_ptr<net::HttpTransaction> trans(new net::HttpNetworkTransaction( - CreateSession(), &mock_socket_factory)); + CreateSession(proxy_service.get()), &mock_socket_factory)); net::HttpRequestInfo request; request.method = "POST"; @@ -492,7 +495,9 @@ TEST_F(HttpNetworkTransactionTest, Ignores100) { // transaction to resend the request. void HttpNetworkTransactionTest::KeepAliveConnectionResendRequestTest( const MockRead& read_failure) { - scoped_refptr<net::HttpNetworkSession> session = CreateSession(); + scoped_ptr<net::ProxyService> proxy_service(CreateNullProxyService()); + scoped_refptr<net::HttpNetworkSession> session = + CreateSession(proxy_service.get()); net::HttpRequestInfo request; request.method = "GET"; @@ -557,8 +562,9 @@ TEST_F(HttpNetworkTransactionTest, KeepAliveConnectionEOF) { } TEST_F(HttpNetworkTransactionTest, NonKeepAliveConnectionReset) { + scoped_ptr<net::ProxyService> proxy_service(CreateNullProxyService()); scoped_ptr<net::HttpTransaction> trans(new net::HttpNetworkTransaction( - CreateSession(), &mock_socket_factory)); + CreateSession(proxy_service.get()), &mock_socket_factory)); net::HttpRequestInfo request; request.method = "GET"; @@ -611,8 +617,9 @@ TEST_F(HttpNetworkTransactionTest, NonKeepAliveConnectionEOF) { // Test the request-challenge-retry sequence for basic auth. // (basic auth is the easiest to mock, because it has no randomness). TEST_F(HttpNetworkTransactionTest, BasicAuth) { + scoped_ptr<net::ProxyService> proxy_service(CreateNullProxyService()); scoped_ptr<net::HttpTransaction> trans(new net::HttpNetworkTransaction( - CreateSession(), &mock_socket_factory)); + CreateSession(proxy_service.get()), &mock_socket_factory)); net::HttpRequestInfo request; request.method = "GET"; @@ -704,10 +711,11 @@ TEST_F(HttpNetworkTransactionTest, BasicAuth) { TEST_F(HttpNetworkTransactionTest, BasicAuthProxyThenServer) { net::ProxyInfo proxy_info; proxy_info.UseNamedProxy("myproxy:70"); + net::ProxyService proxy_service(new net::ProxyResolverFixed(proxy_info)); // Configure against proxy server "myproxy:70". scoped_ptr<net::HttpTransaction> trans(new net::HttpNetworkTransaction( - CreateSession(new net::ProxyResolverFixed(proxy_info)), + CreateSession(&proxy_service), &mock_socket_factory)); net::HttpRequestInfo request; @@ -840,8 +848,9 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthProxyThenServer) { // After some maximum number of bytes is consumed, the transaction should // fail with ERR_RESPONSE_HEADERS_TOO_BIG. TEST_F(HttpNetworkTransactionTest, LargeHeadersNoBody) { + scoped_ptr<net::ProxyService> proxy_service(CreateNullProxyService()); scoped_ptr<net::HttpTransaction> trans(new net::HttpNetworkTransaction( - CreateSession(), &mock_socket_factory)); + CreateSession(proxy_service.get()), &mock_socket_factory)); net::HttpRequestInfo request; request.method = "GET"; @@ -882,9 +891,10 @@ TEST_F(HttpNetworkTransactionTest, DontRecycleTCPSocketForSSLTunnel) { // Configure against proxy server "myproxy:70". net::ProxyInfo proxy_info; proxy_info.UseNamedProxy("myproxy:70"); + net::ProxyService proxy_service(new net::ProxyResolverFixed(proxy_info)); scoped_refptr<net::HttpNetworkSession> session( - CreateSession(new net::ProxyResolverFixed(proxy_info))); + CreateSession(&proxy_service)); scoped_ptr<net::HttpTransaction> trans(new net::HttpNetworkTransaction( session.get(), &mock_socket_factory)); @@ -961,7 +971,9 @@ TEST_F(HttpNetworkTransactionTest, ResendRequestOnWriteBodyError) { request[1].upload_data->AppendBytes("foo", 3); request[1].load_flags = 0; - scoped_refptr<net::HttpNetworkSession> session = CreateSession(); + scoped_ptr<net::ProxyService> proxy_service(CreateNullProxyService()); + scoped_refptr<net::HttpNetworkSession> session = + CreateSession(proxy_service.get()); // The first socket is used for transaction 1 and the first attempt of // transaction 2. @@ -1037,8 +1049,9 @@ TEST_F(HttpNetworkTransactionTest, ResendRequestOnWriteBodyError) { // an identity in the URL. The request should be sent as normal, but when // it fails the identity from the URL is used to answer the challenge. TEST_F(HttpNetworkTransactionTest, AuthIdentityInUrl) { + scoped_ptr<net::ProxyService> proxy_service(CreateNullProxyService()); scoped_ptr<net::HttpTransaction> trans(new net::HttpNetworkTransaction( - CreateSession(), &mock_socket_factory)); + CreateSession(proxy_service.get()), &mock_socket_factory)); net::HttpRequestInfo request; request.method = "GET"; @@ -1106,7 +1119,9 @@ TEST_F(HttpNetworkTransactionTest, AuthIdentityInUrl) { // Test that previously tried username/passwords for a realm get re-used. TEST_F(HttpNetworkTransactionTest, BasicAuthCacheAndPreauth) { - scoped_refptr<net::HttpNetworkSession> session = CreateSession(); + scoped_ptr<net::ProxyService> proxy_service(CreateNullProxyService()); + scoped_refptr<net::HttpNetworkSession> session = + CreateSession(proxy_service.get()); // Transaction 1: authenticate (foo, bar) on MyRealm1 { diff --git a/net/http/http_transaction_winhttp.cc b/net/http/http_transaction_winhttp.cc index 20019ef..b1ecf2a 100644 --- a/net/http/http_transaction_winhttp.cc +++ b/net/http/http_transaction_winhttp.cc @@ -172,7 +172,7 @@ class HttpTransactionWinHttp::Session WINHTTP_FLAG_SECURE_PROTOCOL_TLS1 }; - Session(); + Session(ProxyService* proxy_service); // Opens the primary WinHttp session handle. bool Init(const std::string& user_agent); @@ -195,7 +195,7 @@ class HttpTransactionWinHttp::Session // The message loop of the thread where the session was created. MessageLoop* message_loop() { return message_loop_; } - ProxyService* proxy_service() { return proxy_service_.get(); } + ProxyService* proxy_service() { return proxy_service_; } // Gets the HTTP authentication cache for the session. AuthCache* auth_cache() { return &auth_cache_; } @@ -240,8 +240,7 @@ class HttpTransactionWinHttp::Session HINTERNET internet_; HINTERNET internet_no_tls_; MessageLoop* message_loop_; - scoped_ptr<ProxyService> proxy_service_; - scoped_ptr<ProxyResolver> proxy_resolver_; + ProxyService* proxy_service_; AuthCache auth_cache_; // This event object is used when destroying a transaction. It is given @@ -296,14 +295,12 @@ class HttpTransactionWinHttp::Session WinHttpRequestThrottle request_throttle_; }; -HttpTransactionWinHttp::Session::Session() +HttpTransactionWinHttp::Session::Session(ProxyService* proxy_service) : internet_(NULL), internet_no_tls_(NULL), + proxy_service_(proxy_service), session_callback_ref_count_(0), quitting_(false) { - proxy_resolver_.reset(new ProxyResolverWinHttp()); - proxy_service_.reset(new ProxyService(proxy_resolver_.get())); - GetSSLConfig(); // Save the current message loop for callback notifications. @@ -321,13 +318,6 @@ HttpTransactionWinHttp::Session::Session() } HttpTransactionWinHttp::Session::~Session() { - // It is important to shutdown the proxy service before closing the WinHTTP - // session handle since the proxy service uses the WinHTTP session handle. - proxy_service_.reset(); - - // Next, the resolver which also references our session handle. - proxy_resolver_.reset(); - if (internet_) { WinHttpCloseHandle(internet_); if (internet_no_tls_) @@ -745,10 +735,10 @@ HttpTransaction* HttpTransactionWinHttp::Factory::CreateTransaction() { return NULL; if (!session_) { - session_ = new Session(); + session_ = new Session(proxy_service_); session_->AddRef(); } - return new HttpTransactionWinHttp(session_, proxy_info_.get()); + return new HttpTransactionWinHttp(session_, proxy_service_->proxy_info()); } HttpCache* HttpTransactionWinHttp::Factory::GetCache() { diff --git a/net/http/http_transaction_winhttp.h b/net/http/http_transaction_winhttp.h index 3d46306..27ad730 100644 --- a/net/http/http_transaction_winhttp.h +++ b/net/http/http_transaction_winhttp.h @@ -28,13 +28,9 @@ class HttpTransactionWinHttp : public HttpTransaction { // Instantiate this class, and use it to create HttpTransaction objects. class Factory : public HttpTransactionFactory { public: - Factory() : session_(NULL), proxy_info_(NULL), is_suspended_(false) {} - explicit Factory(const ProxyInfo* info) - : session_(NULL), proxy_info_(NULL), is_suspended_(false) { - if (info) { - proxy_info_.reset(new ProxyInfo()); - proxy_info_->Use(*info); - } + explicit Factory(ProxyService* proxy_service) + : session_(NULL), proxy_service_(proxy_service), is_suspended_(false) { + DCHECK(proxy_service); } ~Factory(); @@ -44,7 +40,7 @@ class HttpTransactionWinHttp : public HttpTransaction { private: Session* session_; - scoped_ptr<ProxyInfo> proxy_info_; + ProxyService* proxy_service_; bool is_suspended_; DISALLOW_EVIL_CONSTRUCTORS(Factory); }; diff --git a/net/http/http_transaction_winhttp_unittest.cc b/net/http/http_transaction_winhttp_unittest.cc index cf462e5..acc4e08 100644 --- a/net/http/http_transaction_winhttp_unittest.cc +++ b/net/http/http_transaction_winhttp_unittest.cc @@ -4,16 +4,19 @@ #include "net/http/http_transaction_winhttp.h" #include "net/http/http_transaction_unittest.h" +#include "net/proxy/proxy_resolver_null.h" #include "testing/gtest/include/gtest/gtest.h" TEST(HttpTransactionWinHttp, CreateAndDestroy) { - net::HttpTransactionWinHttp::Factory factory; + net::ProxyService proxy_service(new net::ProxyResolverNull); + net::HttpTransactionWinHttp::Factory factory(&proxy_service); scoped_ptr<net::HttpTransaction> trans(factory.CreateTransaction()); } TEST(HttpTransactionWinHttp, Suspend) { - net::HttpTransactionWinHttp::Factory factory; + net::ProxyService proxy_service(new net::ProxyResolverNull); + net::HttpTransactionWinHttp::Factory factory(&proxy_service); scoped_ptr<net::HttpTransaction> trans(factory.CreateTransaction()); trans.reset(); @@ -29,7 +32,8 @@ TEST(HttpTransactionWinHttp, Suspend) { } TEST(HttpTransactionWinHttp, GoogleGET) { - net::HttpTransactionWinHttp::Factory factory; + net::ProxyService proxy_service(new net::ProxyResolverNull); + net::HttpTransactionWinHttp::Factory factory(&proxy_service); TestCompletionCallback callback; scoped_ptr<net::HttpTransaction> trans(factory.CreateTransaction()); |