diff options
22 files changed, 183 insertions, 151 deletions
diff --git a/chrome/browser/profile.cc b/chrome/browser/profile.cc index 8cd01f8..d8f2f64 100644 --- a/chrome/browser/profile.cc +++ b/chrome/browser/profile.cc @@ -110,6 +110,7 @@ class ProfileImpl::RequestContext : public URLRequestContext, const std::wstring& disk_cache_path, PrefService* prefs) : prefs_(prefs) { + cookie_store_ = NULL; // setup user agent user_agent_ = webkit_glue::GetUserAgent(); @@ -134,18 +135,18 @@ class ProfileImpl::RequestContext : public URLRequestContext, if (record_mode || playback_mode) { // Don't use existing cookies and use an in-memory store. - cookie_store_.reset(new net::CookieMonster()); + cookie_store_ = new net::CookieMonster(); cache->set_mode( record_mode ? net::HttpCache::RECORD : net::HttpCache::PLAYBACK); } - http_transaction_factory_.reset(cache); + http_transaction_factory_ = cache; // setup cookie store - if (!cookie_store_.get()) { + if (!cookie_store_) { DCHECK(!cookie_store_path.empty()); cookie_db_.reset(new SQLitePersistentCookieStore( cookie_store_path, g_browser_process->db_thread()->message_loop())); - cookie_store_.reset(new net::CookieMonster(cookie_db_.get())); + cookie_store_ = new net::CookieMonster(cookie_db_.get()); } cookie_policy_.SetType(net::CookiePolicy::FromInt( @@ -215,6 +216,10 @@ class ProfileImpl::RequestContext : public URLRequestContext, virtual ~RequestContext() { DCHECK(NULL == prefs_); + delete cookie_store_; + delete http_transaction_factory_; + delete proxy_service_; + if (default_request_context_ == this) default_request_context_ = NULL; } @@ -249,12 +254,13 @@ class OffTheRecordRequestContext : public URLRequestContext, // context to make sure it doesn't go away when we delete the object graph. original_context_ = profile->GetRequestContext(); - // Share the same proxy service as the original profile (adds a reference). + // Share the same proxy service as the original profile. This proxy + // service's lifespan is dependent on the lifespan of the original profile, + // which we reference (see above). proxy_service_ = original_context_->proxy_service(); - http_transaction_factory_.reset( - new net::HttpCache(proxy_service_, 0)); - cookie_store_.reset(new net::CookieMonster); + http_transaction_factory_ = new net::HttpCache(proxy_service_, 0); + cookie_store_ = new net::CookieMonster; cookie_policy_.SetType(net::CookiePolicy::FromInt( prefs_->GetInteger(prefs::kCookieBehavior))); user_agent_ = original_context_->user_agent(); @@ -320,6 +326,10 @@ class OffTheRecordRequestContext : public URLRequestContext, virtual ~OffTheRecordRequestContext() { DCHECK(NULL == prefs_); + delete cookie_store_; + delete http_transaction_factory_; + // NOTE: do not delete |proxy_service_| as is owned by the original profile. + // The OffTheRecordRequestContext simply act as a proxy to the real context. // There is nothing else to delete. } diff --git a/net/build/net.vcproj b/net/build/net.vcproj index 581e56f..0371f78 100644 --- a/net/build/net.vcproj +++ b/net/build/net.vcproj @@ -553,10 +553,6 @@ >
</File>
<File
- RelativePath="..\url_request\url_request_context.cc"
- >
- </File>
- <File
RelativePath="..\url_request\url_request_context.h"
>
</File>
diff --git a/net/http/http_network_layer.h b/net/http/http_network_layer.h index 262cc55..5364642 100644 --- a/net/http/http_network_layer.h +++ b/net/http/http_network_layer.h @@ -17,6 +17,7 @@ class ProxyService; class HttpNetworkLayer : public HttpTransactionFactory { public: + // |proxy_service| must remain valid for the lifetime of HttpNetworkLayer. explicit HttpNetworkLayer(ProxyService* proxy_service); ~HttpNetworkLayer(); @@ -40,7 +41,7 @@ class HttpNetworkLayer : public HttpTransactionFactory { #endif // The proxy service being used for the session. - scoped_refptr<ProxyService> proxy_service_; + 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 deac71d..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,12 +22,15 @@ class HttpNetworkLayerTest : public PlatformTest { }; TEST_F(HttpNetworkLayerTest, CreateAndDestroy) { - net::HttpNetworkLayer factory(net::ProxyService::CreateNull()); + 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(net::ProxyService::CreateNull()); + net::ProxyService proxy_service(new net::ProxyResolverNull); + net::HttpNetworkLayer factory(&proxy_service); scoped_ptr<net::HttpTransaction> trans(factory.CreateTransaction()); trans.reset(); @@ -42,7 +46,8 @@ TEST_F(HttpNetworkLayerTest, Suspend) { } TEST_F(HttpNetworkLayerTest, GoogleGET) { - net::HttpNetworkLayer factory(net::ProxyService::CreateNull()); + 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 3e8c36e..d998665 100644 --- a/net/http/http_network_session.h +++ b/net/http/http_network_session.h @@ -38,7 +38,7 @@ class HttpNetworkSession : public base::RefCounted<HttpNetworkSession> { private: HttpAuthCache auth_cache_; scoped_refptr<ClientSocketPool> connection_pool_; - scoped_refptr<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 7393a191..903f6d9 100644 --- a/net/http/http_network_transaction_unittest.cc +++ b/net/http/http_network_transaction_unittest.cc @@ -12,6 +12,7 @@ #include "net/http/http_network_transaction.h" #include "net/http/http_transaction_unittest.h" #include "net/proxy/proxy_resolver_fixed.h" +#include "net/proxy/proxy_resolver_null.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h" @@ -199,15 +200,13 @@ class MockClientSocketFactory : public net::ClientSocketFactory { MockClientSocketFactory mock_socket_factory; -net::HttpNetworkSession* CreateSessionWithProxy(const std::string& proxy) { - net::ProxyInfo proxy_info; - proxy_info.UseNamedProxy(proxy); - return new net::HttpNetworkSession( - new net::ProxyService(new net::ProxyResolverFixed(proxy_info))); +// 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 new net::HttpNetworkSession(net::ProxyService::CreateNull()); +net::HttpNetworkSession* CreateSession(net::ProxyService* proxy_service) { + return new net::HttpNetworkSession(proxy_service); } class HttpNetworkTransactionTest : public PlatformTest { @@ -237,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"; @@ -289,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) { @@ -397,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"), @@ -446,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"; @@ -491,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"; @@ -556,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"; @@ -610,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"; @@ -701,9 +709,14 @@ TEST_F(HttpNetworkTransactionTest, BasicAuth) { // authentication. Again, this uses basic auth for both since that is // the simplest to mock. 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( - CreateSessionWithProxy("myproxy:70"), &mock_socket_factory)); + CreateSession(&proxy_service), + &mock_socket_factory)); net::HttpRequestInfo request; request.method = "GET"; @@ -835,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"; @@ -875,8 +889,12 @@ TEST_F(HttpNetworkTransactionTest, LargeHeadersNoBody) { // http://code.google.com/p/chromium/issues/detail?id=3772 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( - CreateSessionWithProxy("myproxy:70")); + CreateSession(&proxy_service)); scoped_ptr<net::HttpTransaction> trans(new net::HttpNetworkTransaction( session.get(), &mock_socket_factory)); @@ -953,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. @@ -1029,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"; @@ -1098,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 e4023905..b1ecf2a 100644 --- a/net/http/http_transaction_winhttp.cc +++ b/net/http/http_transaction_winhttp.cc @@ -240,7 +240,7 @@ class HttpTransactionWinHttp::Session HINTERNET internet_; HINTERNET internet_no_tls_; MessageLoop* message_loop_; - scoped_refptr<ProxyService> proxy_service_; + ProxyService* proxy_service_; AuthCache auth_cache_; // This event object is used when destroying a transaction. It is given diff --git a/net/http/http_transaction_winhttp.h b/net/http/http_transaction_winhttp.h index fd6ad6b..27ad730 100644 --- a/net/http/http_transaction_winhttp.h +++ b/net/http/http_transaction_winhttp.h @@ -40,7 +40,7 @@ class HttpTransactionWinHttp : public HttpTransaction { private: Session* session_; - scoped_refptr<ProxyService> proxy_service_; + 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 03787dd..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::CreateNull()); + 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::CreateNull()); + 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::CreateNull()); + net::ProxyService proxy_service(new net::ProxyResolverNull); + net::HttpTransactionWinHttp::Factory factory(&proxy_service); TestCompletionCallback callback; scoped_ptr<net::HttpTransaction> trans(factory.CreateTransaction()); diff --git a/net/net.xcodeproj/project.pbxproj b/net/net.xcodeproj/project.pbxproj index 00cebd4..ee6a70c 100644 --- a/net/net.xcodeproj/project.pbxproj +++ b/net/net.xcodeproj/project.pbxproj @@ -34,7 +34,6 @@ /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ - 0408F92F0EF31FCC00F73396 /* url_request_context.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0408F92E0EF31FCC00F73396 /* url_request_context.cc */; }; 042A4AB20ED4F02D0001DBED /* url_request_file_dir_job.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7BED33970E5A198600A747DB /* url_request_file_dir_job.cc */; }; 042A4AB90ED4F0540001DBED /* directory_lister.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7BED325C0E5A181C00A747DB /* directory_lister.cc */; }; 042A4D480EC4F4500083281F /* http_auth_cache_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 042A4D470EC4F4500083281F /* http_auth_cache_unittest.cc */; }; @@ -420,7 +419,6 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ - 0408F92E0EF31FCC00F73396 /* url_request_context.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = url_request_context.cc; sourceTree = "<group>"; }; 042A4D470EC4F4500083281F /* http_auth_cache_unittest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = http_auth_cache_unittest.cc; sourceTree = "<group>"; }; 0435A4650E8DD69C00E4DF08 /* http_auth.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = http_auth.cc; sourceTree = "<group>"; }; 0435A4670E8DD6B300E4DF08 /* http_auth.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = http_auth.h; sourceTree = "<group>"; }; @@ -1118,7 +1116,6 @@ 7BED33AE0E5A198600A747DB /* url_request.h */, 7BED33A20E5A198600A747DB /* url_request_about_job.cc */, 7BED33B80E5A198600A747DB /* url_request_about_job.h */, - 0408F92E0EF31FCC00F73396 /* url_request_context.cc */, 7BED33B50E5A198600A747DB /* url_request_context.h */, 7BED33B20E5A198600A747DB /* url_request_error_job.cc */, 7BED33A50E5A198600A747DB /* url_request_error_job.h */, @@ -1541,7 +1538,6 @@ 821F20A50E5CD414003C7E38 /* url_request_view_cache_job.cc in Sources */, 82113BBD0E892E5800E3848F /* x509_certificate.cc in Sources */, 827E139D0E81611D00183614 /* x509_certificate_mac.cc in Sources */, - 0408F92F0EF31FCC00F73396 /* url_request_context.cc in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/net/net_lib.scons b/net/net_lib.scons index c64b2c3..972dd31 100644 --- a/net/net_lib.scons +++ b/net/net_lib.scons @@ -84,7 +84,6 @@ input_files = [ 'url_request/mime_sniffer_proxy.cc', 'url_request/url_request.cc', 'url_request/url_request_about_job.cc', - 'url_request/url_request_context.cc', 'url_request/url_request_error_job.cc', 'url_request/url_request_file_dir_job.cc', 'url_request/url_request_file_job.cc', diff --git a/net/proxy/proxy_script_fetcher_unittest.cc b/net/proxy/proxy_script_fetcher_unittest.cc index 50a2f28d..22cb91e 100644 --- a/net/proxy/proxy_script_fetcher_unittest.cc +++ b/net/proxy/proxy_script_fetcher_unittest.cc @@ -28,8 +28,12 @@ class RequestContext : public URLRequestContext { RequestContext() { net::ProxyInfo no_proxy; proxy_service_ = net::ProxyService::Create(&no_proxy); - http_transaction_factory_.reset(net::HttpNetworkLayer::CreateFactory( - proxy_service_)); + http_transaction_factory_ = net::HttpNetworkLayer::CreateFactory( + proxy_service_); + } + ~RequestContext() { + delete http_transaction_factory_; + delete proxy_service_; } }; diff --git a/net/proxy/proxy_service.cc b/net/proxy/proxy_service.cc index e8fa060..5f0f6b2 100644 --- a/net/proxy/proxy_service.cc +++ b/net/proxy/proxy_service.cc @@ -305,11 +305,6 @@ ProxyService* ProxyService::Create(const ProxyInfo* pi) { #endif } -// static -ProxyService* ProxyService::CreateNull() { - return new ProxyService(new ProxyResolverNull()); -} - int ProxyService::ResolveProxy(const GURL& url, ProxyInfo* result, CompletionCallback* callback, PacRequest** pac_request) { diff --git a/net/proxy/proxy_service.h b/net/proxy/proxy_service.h index 6ab6a1b..bea4aef 100644 --- a/net/proxy/proxy_service.h +++ b/net/proxy/proxy_service.h @@ -83,7 +83,7 @@ typedef std::map<std::string, ProxyRetryInfo> ProxyRetryInfoMap; // This class can be used to resolve the proxy server to use when loading a // HTTP(S) URL. It uses the given ProxyResolver to handle the actual proxy // resolution. See ProxyResolverWinHttp for example. -class ProxyService : public base::RefCounted<ProxyService> { +class ProxyService { public: // The instance takes ownership of |resolver|. explicit ProxyService(ProxyResolver* resolver); @@ -138,10 +138,6 @@ class ProxyService : public base::RefCounted<ProxyService> { // use IE's settings). static ProxyService* Create(const ProxyInfo* pi); - // Create a ProxyService which fails every request, causing fallback to a - // direct connection. Convenience function used by unit tests. - static ProxyService* CreateNull(); - // TODO(eroman): remove once WinHTTP is gone. // Get the ProxyInfo used to create this proxy service (only used by WinHTTP). const ProxyInfo* proxy_info() const { diff --git a/net/proxy/proxy_service_unittest.cc b/net/proxy/proxy_service_unittest.cc index 8be7762..1ad7d32 100644 --- a/net/proxy/proxy_service_unittest.cc +++ b/net/proxy/proxy_service_unittest.cc @@ -62,13 +62,12 @@ TEST(ProxyListTest, GetAnnotatedList) { } TEST(ProxyServiceTest, Direct) { - scoped_refptr<net::ProxyService> service = - new net::ProxyService(new MockProxyResolver); + net::ProxyService service(new MockProxyResolver); GURL url("http://www.google.com/"); net::ProxyInfo info; - int rv = service->ResolveProxy(url, &info, NULL, NULL); + int rv = service.ResolveProxy(url, &info, NULL, NULL); EXPECT_EQ(rv, net::OK); EXPECT_TRUE(info.is_direct()); } @@ -79,12 +78,12 @@ TEST(ProxyServiceTest, PAC) { resolver->info.UseNamedProxy("foopy"); resolver->info_predicate_query_host = "www.google.com"; - scoped_refptr<net::ProxyService> service = new net::ProxyService(resolver); + net::ProxyService service(resolver); GURL url("http://www.google.com/"); net::ProxyInfo info; - int rv = service->ResolveProxy(url, &info, NULL, NULL); + int rv = service.ResolveProxy(url, &info, NULL, NULL); EXPECT_EQ(rv, net::OK); EXPECT_FALSE(info.is_direct()); EXPECT_EQ(info.proxy_server(), "foopy"); @@ -96,18 +95,18 @@ TEST(ProxyServiceTest, PAC_FailoverToDirect) { resolver->info.UseNamedProxy("foopy:8080"); resolver->info_predicate_query_host = "www.google.com"; - scoped_refptr<net::ProxyService> service = new net::ProxyService(resolver); + net::ProxyService service(resolver); GURL url("http://www.google.com/"); net::ProxyInfo info; - int rv = service->ResolveProxy(url, &info, NULL, NULL); + int rv = service.ResolveProxy(url, &info, NULL, NULL); EXPECT_EQ(rv, net::OK); EXPECT_FALSE(info.is_direct()); EXPECT_EQ(info.proxy_server(), "foopy:8080"); // Now, imagine that connecting to foopy:8080 fails. - rv = service->ReconsiderProxyAfterError(url, &info, NULL, NULL); + rv = service.ReconsiderProxyAfterError(url, &info, NULL, NULL); EXPECT_EQ(rv, net::OK); EXPECT_TRUE(info.is_direct()); } @@ -121,15 +120,15 @@ TEST(ProxyServiceTest, PAC_FailsToDownload) { resolver->info_predicate_query_host = "www.google.com"; resolver->fail_get_proxy_for_url = true; - scoped_refptr<net::ProxyService> service = new net::ProxyService(resolver); + net::ProxyService service(resolver); GURL url("http://www.google.com/"); net::ProxyInfo info; - int rv = service->ResolveProxy(url, &info, NULL, NULL); + int rv = service.ResolveProxy(url, &info, NULL, NULL); EXPECT_EQ(rv, net::OK); EXPECT_TRUE(info.is_direct()); - rv = service->ResolveProxy(url, &info, NULL, NULL); + rv = service.ResolveProxy(url, &info, NULL, NULL); EXPECT_EQ(rv, net::OK); EXPECT_TRUE(info.is_direct()); @@ -138,7 +137,7 @@ TEST(ProxyServiceTest, PAC_FailsToDownload) { // But, if that fails, then we should give the proxy config another shot // since we have never tried it with this URL before. - rv = service->ReconsiderProxyAfterError(url, &info, NULL, NULL); + rv = service.ReconsiderProxyAfterError(url, &info, NULL, NULL); EXPECT_EQ(rv, net::OK); EXPECT_FALSE(info.is_direct()); EXPECT_EQ(info.proxy_server(), "foopy_valid:8080"); @@ -154,13 +153,13 @@ TEST(ProxyServiceTest, ProxyFallback) { resolver->info_predicate_query_host = "www.google.com"; resolver->fail_get_proxy_for_url = false; - scoped_refptr<net::ProxyService> service = new net::ProxyService(resolver); + net::ProxyService service(resolver); GURL url("http://www.google.com/"); // Get the proxy information. net::ProxyInfo info; - int rv = service->ResolveProxy(url, &info, NULL, NULL); + int rv = service.ResolveProxy(url, &info, NULL, NULL); EXPECT_EQ(rv, net::OK); EXPECT_FALSE(info.is_direct()); @@ -168,7 +167,7 @@ TEST(ProxyServiceTest, ProxyFallback) { EXPECT_EQ(info.proxy_server(), "foopy1:8080"); // Fake an error on the proxy. - rv = service->ReconsiderProxyAfterError(url, &info, NULL, NULL); + rv = service.ReconsiderProxyAfterError(url, &info, NULL, NULL); EXPECT_EQ(rv, net::OK); // The second proxy should be specified. @@ -181,23 +180,23 @@ TEST(ProxyServiceTest, ProxyFallback) { resolver->info_predicate_query_host = "www.google.com"; resolver->fail_get_proxy_for_url = false; - rv = service->ResolveProxy(url, &info, NULL, NULL); + rv = service.ResolveProxy(url, &info, NULL, NULL); EXPECT_EQ(rv, net::OK); EXPECT_FALSE(info.is_direct()); EXPECT_EQ(info.proxy_server(), "foopy3:7070"); // We fake another error. It should now try the third one. - rv = service->ReconsiderProxyAfterError(url, &info, NULL, NULL); + rv = service.ReconsiderProxyAfterError(url, &info, NULL, NULL); EXPECT_EQ(rv, net::OK); EXPECT_EQ(info.proxy_server(), "foopy2:9090"); // Fake another error, the last proxy is gone, the list should now be empty. - rv = service->ReconsiderProxyAfterError(url, &info, NULL, NULL); + rv = service.ReconsiderProxyAfterError(url, &info, NULL, NULL); EXPECT_EQ(rv, net::OK); // We try direct. EXPECT_TRUE(info.is_direct()); // If it fails again, we don't have anything else to try. - rv = service->ReconsiderProxyAfterError(url, &info, NULL, NULL); + rv = service.ReconsiderProxyAfterError(url, &info, NULL, NULL); EXPECT_EQ(rv, net::ERR_FAILED); // We try direct. // TODO(nsylvain): Test that the proxy can be retried after the delay. @@ -212,13 +211,13 @@ TEST(ProxyServiceTest, ProxyFallback_NewSettings) { resolver->info_predicate_query_host = "www.google.com"; resolver->fail_get_proxy_for_url = false; - scoped_refptr<net::ProxyService> service = new net::ProxyService(resolver); + net::ProxyService service(resolver); GURL url("http://www.google.com/"); // Get the proxy information. net::ProxyInfo info; - int rv = service->ResolveProxy(url, &info, NULL, NULL); + int rv = service.ResolveProxy(url, &info, NULL, NULL); EXPECT_EQ(rv, net::OK); EXPECT_FALSE(info.is_direct()); @@ -229,14 +228,14 @@ TEST(ProxyServiceTest, ProxyFallback_NewSettings) { resolver->config = net::ProxyConfig(); resolver->config.pac_url = GURL("http://foopy-new/proxy.pac"); - rv = service->ReconsiderProxyAfterError(url, &info, NULL, NULL); + rv = service.ReconsiderProxyAfterError(url, &info, NULL, NULL); EXPECT_EQ(rv, net::OK); // The first proxy is still there since the configuration changed. EXPECT_EQ(info.proxy_server(), "foopy1:8080"); // We fake another error. It should now ignore the first one. - rv = service->ReconsiderProxyAfterError(url, &info, NULL, NULL); + rv = service.ReconsiderProxyAfterError(url, &info, NULL, NULL); EXPECT_EQ(rv, net::OK); EXPECT_EQ(info.proxy_server(), "foopy2:9090"); @@ -245,7 +244,7 @@ TEST(ProxyServiceTest, ProxyFallback_NewSettings) { resolver->config.pac_url = GURL("http://foopy-new2/proxy.pac"); // We fake anothe error. It should go back to the first proxy. - rv = service->ReconsiderProxyAfterError(url, &info, NULL, NULL); + rv = service.ReconsiderProxyAfterError(url, &info, NULL, NULL); EXPECT_EQ(rv, net::OK); EXPECT_EQ(info.proxy_server(), "foopy1:8080"); } @@ -259,13 +258,13 @@ TEST(ProxyServiceTest, ProxyFallback_BadConfig) { resolver->info_predicate_query_host = "www.google.com"; resolver->fail_get_proxy_for_url = false; - scoped_refptr<net::ProxyService> service = new net::ProxyService(resolver); + net::ProxyService service(resolver); GURL url("http://www.google.com/"); // Get the proxy information. net::ProxyInfo info; - int rv = service->ResolveProxy(url, &info, NULL, NULL); + int rv = service.ResolveProxy(url, &info, NULL, NULL); EXPECT_EQ(rv, net::OK); EXPECT_FALSE(info.is_direct()); @@ -273,7 +272,7 @@ TEST(ProxyServiceTest, ProxyFallback_BadConfig) { EXPECT_EQ(info.proxy_server(), "foopy1:8080"); // Fake a proxy error. - rv = service->ReconsiderProxyAfterError(url, &info, NULL, NULL); + rv = service.ReconsiderProxyAfterError(url, &info, NULL, NULL); EXPECT_EQ(rv, net::OK); // The first proxy is ignored, and the second one is selected. @@ -283,7 +282,7 @@ TEST(ProxyServiceTest, ProxyFallback_BadConfig) { // Fake a PAC failure. net::ProxyInfo info2; resolver->fail_get_proxy_for_url = true; - rv = service->ResolveProxy(url, &info2, NULL, NULL); + rv = service.ResolveProxy(url, &info2, NULL, NULL); EXPECT_EQ(rv, net::OK); // No proxy servers are returned. It's a direct connection. @@ -296,14 +295,14 @@ TEST(ProxyServiceTest, ProxyFallback_BadConfig) { // Try to resolve, it will still return "direct" because we have no reason // to check the config since everything works. net::ProxyInfo info3; - rv = service->ResolveProxy(url, &info3, NULL, NULL); + rv = service.ResolveProxy(url, &info3, NULL, NULL); EXPECT_EQ(rv, net::OK); EXPECT_TRUE(info3.is_direct()); // But if the direct connection fails, we check if the ProxyInfo tried to // resolve the proxy before, and if not (like in this case), we give the // PAC another try. - rv = service->ReconsiderProxyAfterError(url, &info3, NULL, NULL); + rv = service.ReconsiderProxyAfterError(url, &info3, NULL, NULL); EXPECT_EQ(rv, net::OK); // The first proxy is still there since the list of bad proxies got cleared. @@ -319,20 +318,18 @@ TEST(ProxyServiceTest, ProxyBypassList) { config.auto_detect = false; config.proxy_bypass_local_names = true; - scoped_refptr<net::ProxyService> service = - new net::ProxyService(new MockProxyResolver(config)); + net::ProxyService service(new MockProxyResolver(config)); GURL url("http://www.google.com/"); // Get the proxy information. net::ProxyInfo info; - int rv = service->ResolveProxy(url, &info, NULL, NULL); + int rv = service.ResolveProxy(url, &info, NULL, NULL); EXPECT_EQ(rv, net::OK); EXPECT_FALSE(info.is_direct()); - scoped_refptr<net::ProxyService> service1 = - new net::ProxyService(new MockProxyResolver(config)); + net::ProxyService service1(new MockProxyResolver(config)); GURL test_url1("local"); net::ProxyInfo info1; - rv = service1->ResolveProxy(test_url1, &info1, NULL, NULL); + rv = service1.ResolveProxy(test_url1, &info1, NULL, NULL); EXPECT_EQ(rv, net::OK); EXPECT_TRUE(info1.is_direct()); @@ -340,10 +337,10 @@ TEST(ProxyServiceTest, ProxyBypassList) { config.proxy_bypass.push_back("*.org"); config.proxy_bypass_local_names = true; MockProxyResolver* resolver = new MockProxyResolver(config); - scoped_refptr<net::ProxyService> service2 = new net::ProxyService(resolver); + net::ProxyService service2(resolver); GURL test_url2("http://www.webkit.org"); net::ProxyInfo info2; - rv = service2->ResolveProxy(test_url2, &info2, NULL, NULL); + rv = service2.ResolveProxy(test_url2, &info2, NULL, NULL); EXPECT_EQ(rv, net::OK); EXPECT_TRUE(info2.is_direct()); @@ -352,10 +349,10 @@ TEST(ProxyServiceTest, ProxyBypassList) { config.proxy_bypass.push_back("7*"); config.proxy_bypass_local_names = true; resolver = new MockProxyResolver(config); - scoped_refptr<net::ProxyService> service3 = new net::ProxyService(resolver); + net::ProxyService service3(resolver); GURL test_url3("http://74.125.19.147"); net::ProxyInfo info3; - rv = service3->ResolveProxy(test_url3, &info3, NULL, NULL); + rv = service3.ResolveProxy(test_url3, &info3, NULL, NULL); EXPECT_EQ(rv, net::OK); EXPECT_TRUE(info3.is_direct()); @@ -363,10 +360,10 @@ TEST(ProxyServiceTest, ProxyBypassList) { config.proxy_bypass.push_back("*.org"); config.proxy_bypass_local_names = true; resolver = new MockProxyResolver(config); - scoped_refptr<net::ProxyService> service4 = new net::ProxyService(resolver); + net::ProxyService service4(resolver); GURL test_url4("http://www.msn.com"); net::ProxyInfo info4; - rv = service4->ResolveProxy(test_url4, &info4, NULL, NULL); + rv = service4.ResolveProxy(test_url4, &info4, NULL, NULL); EXPECT_EQ(rv, net::OK); EXPECT_FALSE(info4.is_direct()); @@ -374,10 +371,10 @@ TEST(ProxyServiceTest, ProxyBypassList) { config.proxy_bypass.push_back("*.MSN.COM"); config.proxy_bypass_local_names = true; resolver = new MockProxyResolver(config); - scoped_refptr<net::ProxyService> service5 = new net::ProxyService(resolver); + net::ProxyService service5(resolver); GURL test_url5("http://www.msnbc.msn.com"); net::ProxyInfo info5; - rv = service5->ResolveProxy(test_url5, &info5, NULL, NULL); + rv = service5.ResolveProxy(test_url5, &info5, NULL, NULL); EXPECT_EQ(rv, net::OK); EXPECT_TRUE(info5.is_direct()); @@ -385,10 +382,10 @@ TEST(ProxyServiceTest, ProxyBypassList) { config.proxy_bypass.push_back("*.msn.com"); config.proxy_bypass_local_names = true; resolver = new MockProxyResolver(config); - scoped_refptr<net::ProxyService> service6 = new net::ProxyService(resolver); + net::ProxyService service6(resolver); GURL test_url6("HTTP://WWW.MSNBC.MSN.COM"); net::ProxyInfo info6; - rv = service6->ResolveProxy(test_url6, &info6, NULL, NULL); + rv = service6.ResolveProxy(test_url6, &info6, NULL, NULL); EXPECT_EQ(rv, net::OK); EXPECT_TRUE(info6.is_direct()); } @@ -398,40 +395,36 @@ TEST(ProxyServiceTest, PerProtocolProxyTests) { config.proxy_server = "http=foopy1:8080;https=foopy2:8080"; config.auto_detect = false; - scoped_refptr<net::ProxyService> service1 = - new net::ProxyService(new MockProxyResolver(config)); + net::ProxyService service1(new MockProxyResolver(config)); GURL test_url1("http://www.msn.com"); net::ProxyInfo info1; - int rv = service1->ResolveProxy(test_url1, &info1, NULL, NULL); + int rv = service1.ResolveProxy(test_url1, &info1, NULL, NULL); EXPECT_EQ(rv, net::OK); EXPECT_FALSE(info1.is_direct()); EXPECT_TRUE(info1.proxy_server() == "foopy1:8080"); - scoped_refptr<net::ProxyService> service2 = - new net::ProxyService(new MockProxyResolver(config)); + net::ProxyService service2(new MockProxyResolver(config)); GURL test_url2("ftp://ftp.google.com"); net::ProxyInfo info2; - rv = service2->ResolveProxy(test_url2, &info2, NULL, NULL); + rv = service2.ResolveProxy(test_url2, &info2, NULL, NULL); EXPECT_EQ(rv, net::OK); EXPECT_TRUE(info2.is_direct()); EXPECT_TRUE(info2.proxy_server() == ""); - scoped_refptr<net::ProxyService> service3 = - new net::ProxyService(new MockProxyResolver(config)); + net::ProxyService service3(new MockProxyResolver(config)); GURL test_url3("https://webbranch.techcu.com"); net::ProxyInfo info3; - rv = service3->ResolveProxy(test_url3, &info3, NULL, NULL); + rv = service3.ResolveProxy(test_url3, &info3, NULL, NULL); EXPECT_EQ(rv, net::OK); EXPECT_FALSE(info3.is_direct()); EXPECT_TRUE(info3.proxy_server() == "foopy2:8080"); MockProxyResolver* resolver = new MockProxyResolver(config); resolver->config.proxy_server = "foopy1:8080"; - scoped_refptr<net::ProxyService> service4 = - new net::ProxyService(resolver); + net::ProxyService service4(resolver); GURL test_url4("www.microsoft.com"); net::ProxyInfo info4; - rv = service4->ResolveProxy(test_url4, &info4, NULL, NULL); + rv = service4.ResolveProxy(test_url4, &info4, NULL, NULL); EXPECT_EQ(rv, net::OK); EXPECT_FALSE(info4.is_direct()); EXPECT_TRUE(info4.proxy_server() == "foopy1:8080"); diff --git a/net/url_request/url_request_context.cc b/net/url_request/url_request_context.cc deleted file mode 100644 index 84c2229..0000000 --- a/net/url_request/url_request_context.cc +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) 2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "net/url_request/url_request_context.h" - -// These headers are used implicitly by the destructor when destroying the -// scoped_[ref]ptr. - -#include "net/proxy/proxy_service.h" -#include "net/base/cookie_monster.h" - -URLRequestContext::URLRequestContext() : is_off_the_record_(false) {} -URLRequestContext::~URLRequestContext() {} diff --git a/net/url_request/url_request_context.h b/net/url_request/url_request_context.h index 7b7d392..5ea25db 100644 --- a/net/url_request/url_request_context.h +++ b/net/url_request/url_request_context.h @@ -28,8 +28,13 @@ class ProxyService; class URLRequestContext : public base::RefCountedThreadSafe<URLRequestContext> { public: - URLRequestContext(); - + URLRequestContext() + : proxy_service_(NULL), + http_transaction_factory_(NULL), + cookie_store_(NULL), + is_off_the_record_(false) { + } + // Get the proxy service for this context. net::ProxyService* proxy_service() const { return proxy_service_; @@ -37,11 +42,11 @@ class URLRequestContext : // Gets the http transaction factory for this context. net::HttpTransactionFactory* http_transaction_factory() { - return http_transaction_factory_.get(); + return http_transaction_factory_; } // Gets the cookie store for this context. - net::CookieMonster* cookie_store() { return cookie_store_.get(); } + net::CookieMonster* cookie_store() { return cookie_store_; } // Gets the cookie policy for this context. net::CookiePolicy* cookie_policy() { return &cookie_policy_; } @@ -63,13 +68,14 @@ class URLRequestContext : // Do not call this directly. TODO(darin): extending from RefCounted* should // not require a public destructor! - virtual ~URLRequestContext(); + virtual ~URLRequestContext() {} protected: - // The following members are expected to be initialized by subclasses. - scoped_refptr<net::ProxyService> proxy_service_; - scoped_ptr<net::HttpTransactionFactory> http_transaction_factory_; - scoped_ptr<net::CookieMonster> cookie_store_; + // The following members are expected to be initialized and owned by + // subclasses. + net::ProxyService* proxy_service_; + net::HttpTransactionFactory* http_transaction_factory_; + net::CookieMonster* cookie_store_; net::CookiePolicy cookie_policy_; net::AuthCache ftp_auth_cache_; std::string user_agent_; diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc index 193cc21..d344319 100644 --- a/net/url_request/url_request_unittest.cc +++ b/net/url_request/url_request_unittest.cc @@ -29,6 +29,7 @@ #include "net/disk_cache/disk_cache.h" #include "net/http/http_cache.h" #include "net/http/http_network_layer.h" +#include "net/proxy/proxy_resolver_null.h" #include "net/proxy/proxy_service.h" #include "net/url_request/url_request.h" #include "testing/gtest/include/gtest/gtest.h" @@ -41,10 +42,15 @@ namespace { class URLRequestHttpCacheContext : public URLRequestContext { public: URLRequestHttpCacheContext() { - proxy_service_ = net::ProxyService::CreateNull(); - http_transaction_factory_.reset( + proxy_service_ = new net::ProxyService(new net::ProxyResolverNull); + http_transaction_factory_ = new net::HttpCache(net::HttpNetworkLayer::CreateFactory(proxy_service_), - disk_cache::CreateInMemoryCacheBackend(0))); + disk_cache::CreateInMemoryCacheBackend(0)); + } + + virtual ~URLRequestHttpCacheContext() { + delete http_transaction_factory_; + delete proxy_service_; } }; diff --git a/net/url_request/url_request_unittest.h b/net/url_request/url_request_unittest.h index 58b3f606d..e2b8ca3 100644 --- a/net/url_request/url_request_unittest.h +++ b/net/url_request/url_request_unittest.h @@ -23,6 +23,7 @@ #include "net/base/net_errors.h" #include "net/http/http_network_layer.h" #include "net/url_request/url_request.h" +#include "net/proxy/proxy_resolver_null.h" #include "net/proxy/proxy_service.h" #include "testing/gtest/include/gtest/gtest.h" #include "googleurl/src/url_util.h" @@ -34,9 +35,14 @@ const std::string kDefaultHostName("localhost"); class TestURLRequestContext : public URLRequestContext { public: TestURLRequestContext() { - proxy_service_ = net::ProxyService::CreateNull(); - http_transaction_factory_.reset( - net::HttpNetworkLayer::CreateFactory(proxy_service_)); + proxy_service_ = new net::ProxyService(new net::ProxyResolverNull); + http_transaction_factory_ = + net::HttpNetworkLayer::CreateFactory(proxy_service_); + } + + virtual ~TestURLRequestContext() { + delete http_transaction_factory_; + delete proxy_service_; } }; diff --git a/webkit/glue/plugins/mozilla_extensions.cc b/webkit/glue/plugins/mozilla_extensions.cc index b70e87b..5c0f47f 100644 --- a/webkit/glue/plugins/mozilla_extensions.cc +++ b/webkit/glue/plugins/mozilla_extensions.cc @@ -42,8 +42,7 @@ bool MozillaExtensionApi::FindProxyForUrl(const char* url, return result; } - scoped_refptr<net::ProxyService> proxy_service( - net::ProxyService::Create(NULL)); + scoped_ptr<net::ProxyService> proxy_service(net::ProxyService::Create(NULL)); if (!proxy_service.get()) { NOTREACHED(); return result; diff --git a/webkit/tools/test_shell/plugin_tests.cc b/webkit/tools/test_shell/plugin_tests.cc index 6b555a0..a7095dc 100644 --- a/webkit/tools/test_shell/plugin_tests.cc +++ b/webkit/tools/test_shell/plugin_tests.cc @@ -29,7 +29,11 @@ class PluginTest : public TestShellTest { class RequestContext : public TestURLRequestContext { public: RequestContext() { - cookie_store_.reset(new net::CookieMonster()); + cookie_store_ = new net::CookieMonster(); + } + + virtual ~RequestContext() { + delete cookie_store_; } }; diff --git a/webkit/tools/test_shell/test_shell_request_context.cc b/webkit/tools/test_shell/test_shell_request_context.cc index 6c09cfd..8f8202d 100644 --- a/webkit/tools/test_shell/test_shell_request_context.cc +++ b/webkit/tools/test_shell/test_shell_request_context.cc @@ -23,7 +23,7 @@ void TestShellRequestContext::Init( const std::wstring& cache_path, net::HttpCache::Mode cache_mode, bool no_proxy) { - cookie_store_.reset(new net::CookieMonster()); + cookie_store_ = new net::CookieMonster(); user_agent_ = webkit_glue::GetUserAgent(); @@ -42,9 +42,12 @@ void TestShellRequestContext::Init( cache = new net::HttpCache(proxy_service_, cache_path, 0); } cache->set_mode(cache_mode); - http_transaction_factory_.reset(cache); + http_transaction_factory_ = cache; } TestShellRequestContext::~TestShellRequestContext() { + delete cookie_store_; + delete http_transaction_factory_; + delete proxy_service_; } |