summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-13 03:44:24 +0000
committerericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-13 03:44:24 +0000
commitd49801990067e7fe9a3caf141f31c6e6ba58fcfc (patch)
tree502fef7a064f7e1b67291d418b897117e2427822
parent96508147cf0947fdd4ae19d9ee7f5f2e13268a5f (diff)
downloadchromium_src-d49801990067e7fe9a3caf141f31c6e6ba58fcfc.zip
chromium_src-d49801990067e7fe9a3caf141f31c6e6ba58fcfc.tar.gz
chromium_src-d49801990067e7fe9a3caf141f31c6e6ba58fcfc.tar.bz2
Use automatic memory management for URLRequestContext's members.
Also make ProxyService refcounted so the sharing between profiles is explicit. Review URL: http://codereview.chromium.org/13701 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6966 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/profile.cc26
-rw-r--r--net/build/net.vcproj4
-rw-r--r--net/http/http_network_layer.h3
-rw-r--r--net/http/http_network_layer_unittest.cc11
-rw-r--r--net/http/http_network_session.h2
-rw-r--r--net/http/http_network_transaction_unittest.cc63
-rw-r--r--net/http/http_transaction_winhttp.cc2
-rw-r--r--net/http/http_transaction_winhttp.h2
-rw-r--r--net/http/http_transaction_winhttp_unittest.cc10
-rw-r--r--net/net.xcodeproj/project.pbxproj4
-rw-r--r--net/net_lib.scons1
-rw-r--r--net/proxy/proxy_script_fetcher_unittest.cc8
-rw-r--r--net/proxy/proxy_service.cc5
-rw-r--r--net/proxy/proxy_service.h6
-rw-r--r--net/proxy/proxy_service_unittest.cc109
-rw-r--r--net/url_request/url_request_context.cc14
-rw-r--r--net/url_request/url_request_context.h24
-rw-r--r--net/url_request/url_request_unittest.cc12
-rw-r--r--net/url_request/url_request_unittest.h12
-rw-r--r--webkit/glue/plugins/mozilla_extensions.cc3
-rw-r--r--webkit/tools/test_shell/plugin_tests.cc6
-rw-r--r--webkit/tools/test_shell/test_shell_request_context.cc7
22 files changed, 151 insertions, 183 deletions
diff --git a/chrome/browser/profile.cc b/chrome/browser/profile.cc
index d8f2f64..8cd01f8 100644
--- a/chrome/browser/profile.cc
+++ b/chrome/browser/profile.cc
@@ -110,7 +110,6 @@ 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();
@@ -135,18 +134,18 @@ class ProfileImpl::RequestContext : public URLRequestContext,
if (record_mode || playback_mode) {
// Don't use existing cookies and use an in-memory store.
- cookie_store_ = new net::CookieMonster();
+ cookie_store_.reset(new net::CookieMonster());
cache->set_mode(
record_mode ? net::HttpCache::RECORD : net::HttpCache::PLAYBACK);
}
- http_transaction_factory_ = cache;
+ http_transaction_factory_.reset(cache);
// setup cookie store
- if (!cookie_store_) {
+ if (!cookie_store_.get()) {
DCHECK(!cookie_store_path.empty());
cookie_db_.reset(new SQLitePersistentCookieStore(
cookie_store_path, g_browser_process->db_thread()->message_loop()));
- cookie_store_ = new net::CookieMonster(cookie_db_.get());
+ cookie_store_.reset(new net::CookieMonster(cookie_db_.get()));
}
cookie_policy_.SetType(net::CookiePolicy::FromInt(
@@ -216,10 +215,6 @@ 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;
}
@@ -254,13 +249,12 @@ 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. This proxy
- // service's lifespan is dependent on the lifespan of the original profile,
- // which we reference (see above).
+ // Share the same proxy service as the original profile (adds a reference).
proxy_service_ = original_context_->proxy_service();
- http_transaction_factory_ = new net::HttpCache(proxy_service_, 0);
- cookie_store_ = new net::CookieMonster;
+ http_transaction_factory_.reset(
+ new net::HttpCache(proxy_service_, 0));
+ cookie_store_.reset(new net::CookieMonster);
cookie_policy_.SetType(net::CookiePolicy::FromInt(
prefs_->GetInteger(prefs::kCookieBehavior)));
user_agent_ = original_context_->user_agent();
@@ -326,10 +320,6 @@ 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 0371f78..581e56f 100644
--- a/net/build/net.vcproj
+++ b/net/build/net.vcproj
@@ -553,6 +553,10 @@
>
</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 5364642..262cc55 100644
--- a/net/http/http_network_layer.h
+++ b/net/http/http_network_layer.h
@@ -17,7 +17,6 @@ class ProxyService;
class HttpNetworkLayer : public HttpTransactionFactory {
public:
- // |proxy_service| must remain valid for the lifetime of HttpNetworkLayer.
explicit HttpNetworkLayer(ProxyService* proxy_service);
~HttpNetworkLayer();
@@ -41,7 +40,7 @@ class HttpNetworkLayer : public HttpTransactionFactory {
#endif
// The proxy service being used for the session.
- ProxyService* proxy_service_;
+ scoped_refptr<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 0460947..deac71d 100644
--- a/net/http/http_network_layer_unittest.cc
+++ b/net/http/http_network_layer_unittest.cc
@@ -5,7 +5,6 @@
#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"
@@ -22,15 +21,12 @@ class HttpNetworkLayerTest : public PlatformTest {
};
TEST_F(HttpNetworkLayerTest, CreateAndDestroy) {
- net::ProxyService proxy_service(new net::ProxyResolverNull);
- net::HttpNetworkLayer factory(&proxy_service);
-
+ net::HttpNetworkLayer factory(net::ProxyService::CreateNull());
scoped_ptr<net::HttpTransaction> trans(factory.CreateTransaction());
}
TEST_F(HttpNetworkLayerTest, Suspend) {
- net::ProxyService proxy_service(new net::ProxyResolverNull);
- net::HttpNetworkLayer factory(&proxy_service);
+ net::HttpNetworkLayer factory(net::ProxyService::CreateNull());
scoped_ptr<net::HttpTransaction> trans(factory.CreateTransaction());
trans.reset();
@@ -46,8 +42,7 @@ TEST_F(HttpNetworkLayerTest, Suspend) {
}
TEST_F(HttpNetworkLayerTest, GoogleGET) {
- net::ProxyService proxy_service(new net::ProxyResolverNull);
- net::HttpNetworkLayer factory(&proxy_service);
+ net::HttpNetworkLayer factory(net::ProxyService::CreateNull());
TestCompletionCallback callback;
diff --git a/net/http/http_network_session.h b/net/http/http_network_session.h
index d998665..3e8c36e 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_;
- ProxyService* proxy_service_;
+ scoped_refptr<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 903f6d9..7393a191 100644
--- a/net/http/http_network_transaction_unittest.cc
+++ b/net/http/http_network_transaction_unittest.cc
@@ -12,7 +12,6 @@
#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"
@@ -200,13 +199,15 @@ class MockClientSocketFactory : public net::ClientSocketFactory {
MockClientSocketFactory mock_socket_factory;
-// 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* 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)));
}
-net::HttpNetworkSession* CreateSession(net::ProxyService* proxy_service) {
- return new net::HttpNetworkSession(proxy_service);
+net::HttpNetworkSession* CreateSession() {
+ return new net::HttpNetworkSession(net::ProxyService::CreateNull());
}
class HttpNetworkTransactionTest : public PlatformTest {
@@ -236,9 +237,8 @@ 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(proxy_service.get()), &mock_socket_factory));
+ CreateSession(), &mock_socket_factory));
net::HttpRequestInfo request;
request.method = "GET";
@@ -289,9 +289,8 @@ 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(proxy_service.get()), &mock_socket_factory));
+ CreateSession(), &mock_socket_factory));
}
TEST_F(HttpNetworkTransactionTest, SimpleGET) {
@@ -398,9 +397,7 @@ TEST_F(HttpNetworkTransactionTest, StopsReading204) {
}
TEST_F(HttpNetworkTransactionTest, ReuseConnection) {
- scoped_ptr<net::ProxyService> proxy_service(CreateNullProxyService());
- scoped_refptr<net::HttpNetworkSession> session =
- CreateSession(proxy_service.get());
+ scoped_refptr<net::HttpNetworkSession> session = CreateSession();
MockRead data_reads[] = {
MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"),
@@ -449,9 +446,8 @@ TEST_F(HttpNetworkTransactionTest, ReuseConnection) {
}
TEST_F(HttpNetworkTransactionTest, Ignores100) {
- scoped_ptr<net::ProxyService> proxy_service(CreateNullProxyService());
scoped_ptr<net::HttpTransaction> trans(new net::HttpNetworkTransaction(
- CreateSession(proxy_service.get()), &mock_socket_factory));
+ CreateSession(), &mock_socket_factory));
net::HttpRequestInfo request;
request.method = "POST";
@@ -495,9 +491,7 @@ TEST_F(HttpNetworkTransactionTest, Ignores100) {
// transaction to resend the request.
void HttpNetworkTransactionTest::KeepAliveConnectionResendRequestTest(
const MockRead& read_failure) {
- scoped_ptr<net::ProxyService> proxy_service(CreateNullProxyService());
- scoped_refptr<net::HttpNetworkSession> session =
- CreateSession(proxy_service.get());
+ scoped_refptr<net::HttpNetworkSession> session = CreateSession();
net::HttpRequestInfo request;
request.method = "GET";
@@ -562,9 +556,8 @@ TEST_F(HttpNetworkTransactionTest, KeepAliveConnectionEOF) {
}
TEST_F(HttpNetworkTransactionTest, NonKeepAliveConnectionReset) {
- scoped_ptr<net::ProxyService> proxy_service(CreateNullProxyService());
scoped_ptr<net::HttpTransaction> trans(new net::HttpNetworkTransaction(
- CreateSession(proxy_service.get()), &mock_socket_factory));
+ CreateSession(), &mock_socket_factory));
net::HttpRequestInfo request;
request.method = "GET";
@@ -617,9 +610,8 @@ 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(proxy_service.get()), &mock_socket_factory));
+ CreateSession(), &mock_socket_factory));
net::HttpRequestInfo request;
request.method = "GET";
@@ -709,14 +701,9 @@ 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(
- CreateSession(&proxy_service),
- &mock_socket_factory));
+ CreateSessionWithProxy("myproxy:70"), &mock_socket_factory));
net::HttpRequestInfo request;
request.method = "GET";
@@ -848,9 +835,8 @@ 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(proxy_service.get()), &mock_socket_factory));
+ CreateSession(), &mock_socket_factory));
net::HttpRequestInfo request;
request.method = "GET";
@@ -889,12 +875,8 @@ 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(
- CreateSession(&proxy_service));
+ CreateSessionWithProxy("myproxy:70"));
scoped_ptr<net::HttpTransaction> trans(new net::HttpNetworkTransaction(
session.get(), &mock_socket_factory));
@@ -971,9 +953,7 @@ TEST_F(HttpNetworkTransactionTest, ResendRequestOnWriteBodyError) {
request[1].upload_data->AppendBytes("foo", 3);
request[1].load_flags = 0;
- scoped_ptr<net::ProxyService> proxy_service(CreateNullProxyService());
- scoped_refptr<net::HttpNetworkSession> session =
- CreateSession(proxy_service.get());
+ scoped_refptr<net::HttpNetworkSession> session = CreateSession();
// The first socket is used for transaction 1 and the first attempt of
// transaction 2.
@@ -1049,9 +1029,8 @@ 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(proxy_service.get()), &mock_socket_factory));
+ CreateSession(), &mock_socket_factory));
net::HttpRequestInfo request;
request.method = "GET";
@@ -1119,9 +1098,7 @@ TEST_F(HttpNetworkTransactionTest, AuthIdentityInUrl) {
// Test that previously tried username/passwords for a realm get re-used.
TEST_F(HttpNetworkTransactionTest, BasicAuthCacheAndPreauth) {
- scoped_ptr<net::ProxyService> proxy_service(CreateNullProxyService());
- scoped_refptr<net::HttpNetworkSession> session =
- CreateSession(proxy_service.get());
+ scoped_refptr<net::HttpNetworkSession> session = CreateSession();
// Transaction 1: authenticate (foo, bar) on MyRealm1
{
diff --git a/net/http/http_transaction_winhttp.cc b/net/http/http_transaction_winhttp.cc
index b1ecf2a..e4023905 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_;
- ProxyService* proxy_service_;
+ scoped_refptr<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 27ad730..fd6ad6b 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_;
- ProxyService* proxy_service_;
+ scoped_refptr<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 acc4e08..03787dd 100644
--- a/net/http/http_transaction_winhttp_unittest.cc
+++ b/net/http/http_transaction_winhttp_unittest.cc
@@ -4,19 +4,16 @@
#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::ProxyService proxy_service(new net::ProxyResolverNull);
- net::HttpTransactionWinHttp::Factory factory(&proxy_service);
+ net::HttpTransactionWinHttp::Factory factory(net::ProxyService::CreateNull());
scoped_ptr<net::HttpTransaction> trans(factory.CreateTransaction());
}
TEST(HttpTransactionWinHttp, Suspend) {
- net::ProxyService proxy_service(new net::ProxyResolverNull);
- net::HttpTransactionWinHttp::Factory factory(&proxy_service);
+ net::HttpTransactionWinHttp::Factory factory(net::ProxyService::CreateNull());
scoped_ptr<net::HttpTransaction> trans(factory.CreateTransaction());
trans.reset();
@@ -32,8 +29,7 @@ TEST(HttpTransactionWinHttp, Suspend) {
}
TEST(HttpTransactionWinHttp, GoogleGET) {
- net::ProxyService proxy_service(new net::ProxyResolverNull);
- net::HttpTransactionWinHttp::Factory factory(&proxy_service);
+ net::HttpTransactionWinHttp::Factory factory(net::ProxyService::CreateNull());
TestCompletionCallback callback;
scoped_ptr<net::HttpTransaction> trans(factory.CreateTransaction());
diff --git a/net/net.xcodeproj/project.pbxproj b/net/net.xcodeproj/project.pbxproj
index ee6a70c..00cebd4 100644
--- a/net/net.xcodeproj/project.pbxproj
+++ b/net/net.xcodeproj/project.pbxproj
@@ -34,6 +34,7 @@
/* 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 */; };
@@ -419,6 +420,7 @@
/* 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>"; };
@@ -1116,6 +1118,7 @@
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 */,
@@ -1538,6 +1541,7 @@
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 972dd31..c64b2c3 100644
--- a/net/net_lib.scons
+++ b/net/net_lib.scons
@@ -84,6 +84,7 @@ 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 22cb91e..50a2f28d 100644
--- a/net/proxy/proxy_script_fetcher_unittest.cc
+++ b/net/proxy/proxy_script_fetcher_unittest.cc
@@ -28,12 +28,8 @@ class RequestContext : public URLRequestContext {
RequestContext() {
net::ProxyInfo no_proxy;
proxy_service_ = net::ProxyService::Create(&no_proxy);
- http_transaction_factory_ = net::HttpNetworkLayer::CreateFactory(
- proxy_service_);
- }
- ~RequestContext() {
- delete http_transaction_factory_;
- delete proxy_service_;
+ http_transaction_factory_.reset(net::HttpNetworkLayer::CreateFactory(
+ proxy_service_));
}
};
diff --git a/net/proxy/proxy_service.cc b/net/proxy/proxy_service.cc
index 5f0f6b2..e8fa060 100644
--- a/net/proxy/proxy_service.cc
+++ b/net/proxy/proxy_service.cc
@@ -305,6 +305,11 @@ 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 bea4aef..6ab6a1b 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 {
+class ProxyService : public base::RefCounted<ProxyService> {
public:
// The instance takes ownership of |resolver|.
explicit ProxyService(ProxyResolver* resolver);
@@ -138,6 +138,10 @@ class 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 1ad7d32..8be7762 100644
--- a/net/proxy/proxy_service_unittest.cc
+++ b/net/proxy/proxy_service_unittest.cc
@@ -62,12 +62,13 @@ TEST(ProxyListTest, GetAnnotatedList) {
}
TEST(ProxyServiceTest, Direct) {
- net::ProxyService service(new MockProxyResolver);
+ scoped_refptr<net::ProxyService> service =
+ new net::ProxyService(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());
}
@@ -78,12 +79,12 @@ TEST(ProxyServiceTest, PAC) {
resolver->info.UseNamedProxy("foopy");
resolver->info_predicate_query_host = "www.google.com";
- net::ProxyService service(resolver);
+ scoped_refptr<net::ProxyService> service = new net::ProxyService(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");
@@ -95,18 +96,18 @@ TEST(ProxyServiceTest, PAC_FailoverToDirect) {
resolver->info.UseNamedProxy("foopy:8080");
resolver->info_predicate_query_host = "www.google.com";
- net::ProxyService service(resolver);
+ scoped_refptr<net::ProxyService> service = new net::ProxyService(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());
}
@@ -120,15 +121,15 @@ TEST(ProxyServiceTest, PAC_FailsToDownload) {
resolver->info_predicate_query_host = "www.google.com";
resolver->fail_get_proxy_for_url = true;
- net::ProxyService service(resolver);
+ scoped_refptr<net::ProxyService> service = new net::ProxyService(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());
@@ -137,7 +138,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");
@@ -153,13 +154,13 @@ TEST(ProxyServiceTest, ProxyFallback) {
resolver->info_predicate_query_host = "www.google.com";
resolver->fail_get_proxy_for_url = false;
- net::ProxyService service(resolver);
+ scoped_refptr<net::ProxyService> service = new net::ProxyService(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());
@@ -167,7 +168,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.
@@ -180,23 +181,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.
@@ -211,13 +212,13 @@ TEST(ProxyServiceTest, ProxyFallback_NewSettings) {
resolver->info_predicate_query_host = "www.google.com";
resolver->fail_get_proxy_for_url = false;
- net::ProxyService service(resolver);
+ scoped_refptr<net::ProxyService> service = new net::ProxyService(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());
@@ -228,14 +229,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");
@@ -244,7 +245,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");
}
@@ -258,13 +259,13 @@ TEST(ProxyServiceTest, ProxyFallback_BadConfig) {
resolver->info_predicate_query_host = "www.google.com";
resolver->fail_get_proxy_for_url = false;
- net::ProxyService service(resolver);
+ scoped_refptr<net::ProxyService> service = new net::ProxyService(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());
@@ -272,7 +273,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.
@@ -282,7 +283,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.
@@ -295,14 +296,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.
@@ -318,18 +319,20 @@ TEST(ProxyServiceTest, ProxyBypassList) {
config.auto_detect = false;
config.proxy_bypass_local_names = true;
- net::ProxyService service(new MockProxyResolver(config));
+ scoped_refptr<net::ProxyService> service =
+ new net::ProxyService(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());
- net::ProxyService service1(new MockProxyResolver(config));
+ scoped_refptr<net::ProxyService> service1 =
+ new net::ProxyService(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());
@@ -337,10 +340,10 @@ TEST(ProxyServiceTest, ProxyBypassList) {
config.proxy_bypass.push_back("*.org");
config.proxy_bypass_local_names = true;
MockProxyResolver* resolver = new MockProxyResolver(config);
- net::ProxyService service2(resolver);
+ scoped_refptr<net::ProxyService> service2 = new net::ProxyService(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());
@@ -349,10 +352,10 @@ TEST(ProxyServiceTest, ProxyBypassList) {
config.proxy_bypass.push_back("7*");
config.proxy_bypass_local_names = true;
resolver = new MockProxyResolver(config);
- net::ProxyService service3(resolver);
+ scoped_refptr<net::ProxyService> service3 = new net::ProxyService(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());
@@ -360,10 +363,10 @@ TEST(ProxyServiceTest, ProxyBypassList) {
config.proxy_bypass.push_back("*.org");
config.proxy_bypass_local_names = true;
resolver = new MockProxyResolver(config);
- net::ProxyService service4(resolver);
+ scoped_refptr<net::ProxyService> service4 = new net::ProxyService(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());
@@ -371,10 +374,10 @@ TEST(ProxyServiceTest, ProxyBypassList) {
config.proxy_bypass.push_back("*.MSN.COM");
config.proxy_bypass_local_names = true;
resolver = new MockProxyResolver(config);
- net::ProxyService service5(resolver);
+ scoped_refptr<net::ProxyService> service5 = new net::ProxyService(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());
@@ -382,10 +385,10 @@ TEST(ProxyServiceTest, ProxyBypassList) {
config.proxy_bypass.push_back("*.msn.com");
config.proxy_bypass_local_names = true;
resolver = new MockProxyResolver(config);
- net::ProxyService service6(resolver);
+ scoped_refptr<net::ProxyService> service6 = new net::ProxyService(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());
}
@@ -395,36 +398,40 @@ TEST(ProxyServiceTest, PerProtocolProxyTests) {
config.proxy_server = "http=foopy1:8080;https=foopy2:8080";
config.auto_detect = false;
- net::ProxyService service1(new MockProxyResolver(config));
+ scoped_refptr<net::ProxyService> service1 =
+ new net::ProxyService(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");
- net::ProxyService service2(new MockProxyResolver(config));
+ scoped_refptr<net::ProxyService> service2 =
+ new net::ProxyService(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() == "");
- net::ProxyService service3(new MockProxyResolver(config));
+ scoped_refptr<net::ProxyService> service3 =
+ new net::ProxyService(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";
- net::ProxyService service4(resolver);
+ scoped_refptr<net::ProxyService> service4 =
+ new net::ProxyService(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
new file mode 100644
index 0000000..84c2229
--- /dev/null
+++ b/net/url_request/url_request_context.cc
@@ -0,0 +1,14 @@
+// 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 5ea25db..7b7d392 100644
--- a/net/url_request/url_request_context.h
+++ b/net/url_request/url_request_context.h
@@ -28,13 +28,8 @@ class ProxyService;
class URLRequestContext :
public base::RefCountedThreadSafe<URLRequestContext> {
public:
- URLRequestContext()
- : proxy_service_(NULL),
- http_transaction_factory_(NULL),
- cookie_store_(NULL),
- is_off_the_record_(false) {
- }
-
+ URLRequestContext();
+
// Get the proxy service for this context.
net::ProxyService* proxy_service() const {
return proxy_service_;
@@ -42,11 +37,11 @@ class URLRequestContext :
// Gets the http transaction factory for this context.
net::HttpTransactionFactory* http_transaction_factory() {
- return http_transaction_factory_;
+ return http_transaction_factory_.get();
}
// Gets the cookie store for this context.
- net::CookieMonster* cookie_store() { return cookie_store_; }
+ net::CookieMonster* cookie_store() { return cookie_store_.get(); }
// Gets the cookie policy for this context.
net::CookiePolicy* cookie_policy() { return &cookie_policy_; }
@@ -68,14 +63,13 @@ 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 and owned by
- // subclasses.
- net::ProxyService* proxy_service_;
- net::HttpTransactionFactory* http_transaction_factory_;
- net::CookieMonster* cookie_store_;
+ // 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_;
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 d344319..193cc21 100644
--- a/net/url_request/url_request_unittest.cc
+++ b/net/url_request/url_request_unittest.cc
@@ -29,7 +29,6 @@
#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"
@@ -42,15 +41,10 @@ namespace {
class URLRequestHttpCacheContext : public URLRequestContext {
public:
URLRequestHttpCacheContext() {
- proxy_service_ = new net::ProxyService(new net::ProxyResolverNull);
- http_transaction_factory_ =
+ proxy_service_ = net::ProxyService::CreateNull();
+ http_transaction_factory_.reset(
new net::HttpCache(net::HttpNetworkLayer::CreateFactory(proxy_service_),
- disk_cache::CreateInMemoryCacheBackend(0));
- }
-
- virtual ~URLRequestHttpCacheContext() {
- delete http_transaction_factory_;
- delete proxy_service_;
+ disk_cache::CreateInMemoryCacheBackend(0)));
}
};
diff --git a/net/url_request/url_request_unittest.h b/net/url_request/url_request_unittest.h
index e2b8ca3..58b3f606d 100644
--- a/net/url_request/url_request_unittest.h
+++ b/net/url_request/url_request_unittest.h
@@ -23,7 +23,6 @@
#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"
@@ -35,14 +34,9 @@ const std::string kDefaultHostName("localhost");
class TestURLRequestContext : public URLRequestContext {
public:
TestURLRequestContext() {
- 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_;
+ proxy_service_ = net::ProxyService::CreateNull();
+ http_transaction_factory_.reset(
+ net::HttpNetworkLayer::CreateFactory(proxy_service_));
}
};
diff --git a/webkit/glue/plugins/mozilla_extensions.cc b/webkit/glue/plugins/mozilla_extensions.cc
index 5c0f47f..b70e87b 100644
--- a/webkit/glue/plugins/mozilla_extensions.cc
+++ b/webkit/glue/plugins/mozilla_extensions.cc
@@ -42,7 +42,8 @@ bool MozillaExtensionApi::FindProxyForUrl(const char* url,
return result;
}
- scoped_ptr<net::ProxyService> proxy_service(net::ProxyService::Create(NULL));
+ scoped_refptr<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 a7095dc..6b555a0 100644
--- a/webkit/tools/test_shell/plugin_tests.cc
+++ b/webkit/tools/test_shell/plugin_tests.cc
@@ -29,11 +29,7 @@ class PluginTest : public TestShellTest {
class RequestContext : public TestURLRequestContext {
public:
RequestContext() {
- cookie_store_ = new net::CookieMonster();
- }
-
- virtual ~RequestContext() {
- delete cookie_store_;
+ cookie_store_.reset(new net::CookieMonster());
}
};
diff --git a/webkit/tools/test_shell/test_shell_request_context.cc b/webkit/tools/test_shell/test_shell_request_context.cc
index 8f8202d..6c09cfd 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_ = new net::CookieMonster();
+ cookie_store_.reset(new net::CookieMonster());
user_agent_ = webkit_glue::GetUserAgent();
@@ -42,12 +42,9 @@ void TestShellRequestContext::Init(
cache = new net::HttpCache(proxy_service_, cache_path, 0);
}
cache->set_mode(cache_mode);
- http_transaction_factory_ = cache;
+ http_transaction_factory_.reset(cache);
}
TestShellRequestContext::~TestShellRequestContext() {
- delete cookie_store_;
- delete http_transaction_factory_;
- delete proxy_service_;
}