summaryrefslogtreecommitdiffstats
path: root/net/http
diff options
context:
space:
mode:
authorericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-26 22:06:52 +0000
committerericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-26 22:06:52 +0000
commit862a92ee0afc1be6470beed3e19465c24da223e2 (patch)
treedec2efaa94cf3e1eae580599e87f84e7af082594 /net/http
parentf816c01e9c6f6f0365ba80ba3f661e38461a0537 (diff)
downloadchromium_src-862a92ee0afc1be6470beed3e19465c24da223e2.zip
chromium_src-862a92ee0afc1be6470beed3e19465c24da223e2.tar.gz
chromium_src-862a92ee0afc1be6470beed3e19465c24da223e2.tar.bz2
Make net::HostResolver refcounted.
This way it can be properly shared between the url request contexts, and the dns prefetcher, and dns observer. BUG=http://crbug.com/14664 TEST=existing unit tests. Review URL: http://codereview.chromium.org/149053 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19425 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http')
-rw-r--r--net/http/http_network_layer.h2
-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.cc15
4 files changed, 15 insertions, 15 deletions
diff --git a/net/http/http_network_layer.h b/net/http/http_network_layer.h
index 74cf3df..b4b430f 100644
--- a/net/http/http_network_layer.h
+++ b/net/http/http_network_layer.h
@@ -52,7 +52,7 @@ class HttpNetworkLayer : public HttpTransactionFactory {
ClientSocketFactory* socket_factory_;
// The host resolver being used for the session.
- HostResolver* host_resolver_;
+ scoped_refptr<HostResolver> host_resolver_;
// The proxy service being used for the session.
ProxyService* proxy_service_;
diff --git a/net/http/http_network_layer_unittest.cc b/net/http/http_network_layer_unittest.cc
index 32888f0..9fd35ea 100644
--- a/net/http/http_network_layer_unittest.cc
+++ b/net/http/http_network_layer_unittest.cc
@@ -14,17 +14,17 @@ class HttpNetworkLayerTest : public PlatformTest {
};
TEST_F(HttpNetworkLayerTest, CreateAndDestroy) {
- net::HostResolver host_resolver;
scoped_ptr<net::ProxyService> proxy_service(net::ProxyService::CreateNull());
- net::HttpNetworkLayer factory(NULL, &host_resolver, proxy_service.get());
+ net::HttpNetworkLayer factory(
+ NULL, new net::HostResolver, proxy_service.get());
scoped_ptr<net::HttpTransaction> trans(factory.CreateTransaction());
}
TEST_F(HttpNetworkLayerTest, Suspend) {
- net::HostResolver host_resolver;
scoped_ptr<net::ProxyService> proxy_service(net::ProxyService::CreateNull());
- net::HttpNetworkLayer factory(NULL, &host_resolver, proxy_service.get());
+ net::HttpNetworkLayer factory(
+ NULL, new net::HostResolver, proxy_service.get());
scoped_ptr<net::HttpTransaction> trans(factory.CreateTransaction());
trans.reset();
@@ -55,9 +55,8 @@ TEST_F(HttpNetworkLayerTest, GET) {
net::StaticMockSocket data(data_reads, data_writes);
mock_socket_factory.AddMockSocket(&data);
- net::HostResolver host_resolver;
scoped_ptr<net::ProxyService> proxy_service(net::ProxyService::CreateNull());
- net::HttpNetworkLayer factory(&mock_socket_factory, &host_resolver,
+ net::HttpNetworkLayer factory(&mock_socket_factory, new net::HostResolver,
proxy_service.get());
TestCompletionCallback callback;
diff --git a/net/http/http_network_session.h b/net/http/http_network_session.h
index a084ec7..3529bc8 100644
--- a/net/http/http_network_session.h
+++ b/net/http/http_network_session.h
@@ -54,7 +54,7 @@ class HttpNetworkSession : public base::RefCounted<HttpNetworkSession> {
HttpAuthCache auth_cache_;
SSLClientAuthCache ssl_client_auth_cache_;
scoped_refptr<ClientSocketPool> connection_pool_;
- HostResolver* host_resolver_;
+ scoped_refptr<HostResolver> host_resolver_;
ProxyService* proxy_service_;
#if defined(OS_WIN)
// TODO(port): Port the SSLConfigService class to Linux and Mac OS X.
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc
index ba68db1..bcb22a9 100644
--- a/net/http/http_network_transaction_unittest.cc
+++ b/net/http/http_network_transaction_unittest.cc
@@ -35,13 +35,14 @@ ProxyService* CreateNullProxyService() {
class SessionDependencies {
public:
// Default set of dependencies -- "null" proxy service.
- SessionDependencies() : proxy_service(CreateNullProxyService()) {}
+ SessionDependencies() : host_resolver(new HostResolver),
+ proxy_service(CreateNullProxyService()) {}
// Custom proxy service dependency.
explicit SessionDependencies(ProxyService* proxy_service)
- : proxy_service(proxy_service) {}
+ : host_resolver(new HostResolver), proxy_service(proxy_service) {}
- HostResolver host_resolver;
+ scoped_refptr<HostResolver> host_resolver;
scoped_ptr<ProxyService> proxy_service;
MockClientSocketFactory socket_factory;
};
@@ -54,7 +55,7 @@ ProxyService* CreateFixedProxyService(const std::string& proxy) {
HttpNetworkSession* CreateSession(SessionDependencies* session_deps) {
- return new HttpNetworkSession(&session_deps->host_resolver,
+ return new HttpNetworkSession(session_deps->host_resolver,
session_deps->proxy_service.get(),
&session_deps->socket_factory);
}
@@ -3302,7 +3303,7 @@ TEST_F(HttpNetworkTransactionTest, ResolveMadeWithReferrer) {
CreateSession(&session_deps), &session_deps.socket_factory));
// Attach an observer to watch the host resolutions being made.
- session_deps.host_resolver.AddObserver(&resolution_observer);
+ session_deps.host_resolver->AddObserver(&resolution_observer);
// Connect up a mock socket which will fail when reading.
MockRead data_reads[] = {
@@ -3338,14 +3339,14 @@ TEST_F(HttpNetworkTransactionTest, BypassHostCacheOnRefresh) {
// Warm up the host cache so it has an entry for "www.google.com" (by doing
// a synchronous lookup.)
AddressList addrlist;
- int rv = session_deps.host_resolver.Resolve(
+ int rv = session_deps.host_resolver->Resolve(
HostResolver::RequestInfo("www.google.com", 80), &addrlist, NULL, NULL);
EXPECT_EQ(OK, rv);
// Verify that it was added to host cache, by doing a subsequent async lookup
// and confirming it completes synchronously.
TestCompletionCallback resolve_callback;
- rv = session_deps.host_resolver.Resolve(
+ rv = session_deps.host_resolver->Resolve(
HostResolver::RequestInfo("www.google.com", 80), &addrlist,
&resolve_callback, NULL);
EXPECT_EQ(OK, rv);