summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/net/chrome_url_request_context.cc3
-rw-r--r--chrome/browser/net/dns_global.cc16
-rw-r--r--chrome/browser/net/dns_global.h6
-rw-r--r--chrome/browser/net/dns_master.h2
-rw-r--r--chrome/browser/net/dns_master_unittest.cc23
-rw-r--r--net/base/host_resolver.h4
-rw-r--r--net/base/host_resolver_unittest.cc121
-rw-r--r--net/ftp/ftp_network_session.h2
-rw-r--r--net/ftp/ftp_network_transaction_unittest.cc3
-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
-rw-r--r--net/proxy/proxy_resolver_perftest.cc4
-rw-r--r--net/proxy/proxy_resolver_v8.cc2
-rw-r--r--net/proxy/proxy_resolver_v8_unittest.cc6
-rw-r--r--net/proxy/proxy_script_fetcher_unittest.cc1
-rw-r--r--net/socket/client_socket_pool_base.h4
-rw-r--r--net/socket/ssl_client_socket_unittest.cc24
-rw-r--r--net/socket/ssl_test_util.cc4
-rw-r--r--net/socket/tcp_client_socket_pool_unittest.cc3
-rw-r--r--net/socket/tcp_client_socket_unittest.cc4
-rw-r--r--net/socket/tcp_pinger_unittest.cc8
-rw-r--r--net/tools/fetch/fetch_client.cc6
-rw-r--r--net/url_request/url_request_context.h4
-rw-r--r--net/url_request/url_request_unittest.cc1
-rw-r--r--net/url_request/url_request_unittest.h6
-rw-r--r--webkit/tools/test_shell/test_shell_request_context.cc1
28 files changed, 153 insertions, 135 deletions
diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc
index 4b788c5..1e01821 100644
--- a/chrome/browser/net/chrome_url_request_context.cc
+++ b/chrome/browser/net/chrome_url_request_context.cc
@@ -462,4 +462,7 @@ ChromeURLRequestContext::~ChromeURLRequestContext() {
// it is owned by the original URLRequestContext.
if (!is_off_the_record_ && !is_media_)
delete proxy_service_;
+
+ // Do not delete host_resolver_; it will be freed by FreeGlobalHostResolver()
+ // during the teardown of DNS prefetching.
}
diff --git a/chrome/browser/net/dns_global.cc b/chrome/browser/net/dns_global.cc
index 4b821c6..9e4c8f6 100644
--- a/chrome/browser/net/dns_global.cc
+++ b/chrome/browser/net/dns_global.cc
@@ -435,13 +435,9 @@ void InitDnsPrefetch(size_t max_concurrent, PrefService* user_prefs) {
}
void EnsureDnsPrefetchShutdown() {
- if (NULL != dns_master) {
+ if (NULL != dns_master)
dns_master->Shutdown();
-
- // Stop observing DNS resolutions. Note that dns_master holds a reference
- // to the global host resolver, so is guaranteed to be live.
- GetGlobalHostResolver()->RemoveObserver(&dns_resolution_observer);
- }
+ FreeGlobalHostResolver();
}
void FreeDnsPrefetchResources() {
@@ -473,6 +469,14 @@ net::HostResolver* GetGlobalHostResolver() {
return global_host_resolver;
}
+void FreeGlobalHostResolver() {
+ if (global_host_resolver) {
+ // Called from IO thread.
+ delete global_host_resolver;
+ global_host_resolver = NULL;
+ }
+}
+
//------------------------------------------------------------------------------
// Functions to handle saving of hostnames from one session to the next, to
// expedite startup times.
diff --git a/chrome/browser/net/dns_global.h b/chrome/browser/net/dns_global.h
index e27062e..c9a864f 100644
--- a/chrome/browser/net/dns_global.h
+++ b/chrome/browser/net/dns_global.h
@@ -36,9 +36,13 @@ void EnsureDnsPrefetchShutdown();
void FreeDnsPrefetchResources();
// Lazily allocates a HostResolver to be used by the DNS prefetch system, on
-// the IO thread.
+// the IO thread. Must be matched by a call to FreeGlobalHostResolver().
net::HostResolver* GetGlobalHostResolver();
+// Frees the HostResolver allocated by GetGlobalHostResolver(). Must be called
+// on the IO thread.
+void FreeGlobalHostResolver();
+
//------------------------------------------------------------------------------
// Global APIs relating to Prefetching in browser
void EnableDnsPrefetch(bool enable);
diff --git a/chrome/browser/net/dns_master.h b/chrome/browser/net/dns_master.h
index 04fc56f..fa1c783 100644
--- a/chrome/browser/net/dns_master.h
+++ b/chrome/browser/net/dns_master.h
@@ -229,7 +229,7 @@ class DnsMaster : public base::RefCountedThreadSafe<DnsMaster> {
// The host resovler we warm DNS entries for. The resolver (which is not
// thread safe) should be accessed only on |host_resolver_loop_|.
- scoped_refptr<net::HostResolver> host_resolver_;
+ net::HostResolver* host_resolver_;
MessageLoop* host_resolver_loop_;
DISALLOW_COPY_AND_ASSIGN(DnsMaster);
diff --git a/chrome/browser/net/dns_master_unittest.cc b/chrome/browser/net/dns_master_unittest.cc
index da720fe..e056555 100644
--- a/chrome/browser/net/dns_master_unittest.cc
+++ b/chrome/browser/net/dns_master_unittest.cc
@@ -82,6 +82,7 @@ class DnsMasterTest : public testing::Test {
MessageLoop::current()->Run();
}
+ net::HostResolver host_resolver_;
scoped_refptr<net::RuleBasedHostMapper> mapper_;
private:
@@ -110,10 +111,10 @@ static std::string GetNonexistantDomain() {
TimeDelta BlockingDnsLookup(const std::string& hostname) {
Time start = Time::Now();
- scoped_refptr<net::HostResolver> resolver(new net::HostResolver);
+ net::HostResolver resolver;
net::AddressList addresses;
net::HostResolver::RequestInfo info(hostname, 80);
- resolver->Resolve(info, &addresses, NULL, NULL);
+ resolver.Resolve(info, &addresses, NULL, NULL);
return Time::Now() - start;
}
@@ -162,13 +163,13 @@ TEST_F(DnsMasterTest, OsCachesLookupsTest) {
}
TEST_F(DnsMasterTest, StartupShutdownTest) {
- scoped_refptr<DnsMaster> testing_master = new DnsMaster(new net::HostResolver,
+ scoped_refptr<DnsMaster> testing_master = new DnsMaster(&host_resolver_,
MessageLoop::current(), DnsPrefetcherInit::kMaxConcurrentLookups);
testing_master->Shutdown();
}
TEST_F(DnsMasterTest, BenefitLookupTest) {
- scoped_refptr<DnsMaster> testing_master = new DnsMaster(new net::HostResolver,
+ scoped_refptr<DnsMaster> testing_master = new DnsMaster(&host_resolver_,
MessageLoop::current(), DnsPrefetcherInit::kMaxConcurrentLookups);
std::string goog("www.google.com"),
@@ -231,7 +232,7 @@ TEST_F(DnsMasterTest, ShutdownWhenResolutionIsPendingTest) {
scoped_refptr<net::WaitingHostMapper> mapper = new net::WaitingHostMapper();
net::ScopedHostMapper scoped_mapper(mapper.get());
- scoped_refptr<DnsMaster> testing_master = new DnsMaster(new net::HostResolver,
+ scoped_refptr<DnsMaster> testing_master = new DnsMaster(&host_resolver_,
MessageLoop::current(), DnsPrefetcherInit::kMaxConcurrentLookups);
std::string localhost("127.0.0.1");
@@ -254,7 +255,7 @@ TEST_F(DnsMasterTest, ShutdownWhenResolutionIsPendingTest) {
}
TEST_F(DnsMasterTest, SingleLookupTest) {
- scoped_refptr<DnsMaster> testing_master = new DnsMaster(new net::HostResolver,
+ scoped_refptr<DnsMaster> testing_master = new DnsMaster(&host_resolver_,
MessageLoop::current(), DnsPrefetcherInit::kMaxConcurrentLookups);
std::string goog("www.google.com");
@@ -283,7 +284,7 @@ TEST_F(DnsMasterTest, SingleLookupTest) {
TEST_F(DnsMasterTest, ConcurrentLookupTest) {
mapper_->AddSimulatedFailure("*.notfound");
- scoped_refptr<DnsMaster> testing_master = new DnsMaster(new net::HostResolver,
+ scoped_refptr<DnsMaster> testing_master = new DnsMaster(&host_resolver_,
MessageLoop::current(), DnsPrefetcherInit::kMaxConcurrentLookups);
std::string goog("www.google.com"),
@@ -337,7 +338,7 @@ TEST_F(DnsMasterTest, ConcurrentLookupTest) {
TEST_F(DnsMasterTest, DISABLED_MassiveConcurrentLookupTest) {
mapper_->AddSimulatedFailure("*.notfound");
- scoped_refptr<DnsMaster> testing_master = new DnsMaster(new net::HostResolver,
+ scoped_refptr<DnsMaster> testing_master = new DnsMaster(&host_resolver_,
MessageLoop::current(), DnsPrefetcherInit::kMaxConcurrentLookups);
NameList names;
@@ -441,7 +442,7 @@ int GetLatencyFromSerialization(const std::string& motivation,
// Make sure nil referral lists really have no entries, and no latency listed.
TEST_F(DnsMasterTest, ReferrerSerializationNilTest) {
- scoped_refptr<DnsMaster> master = new DnsMaster(new net::HostResolver,
+ scoped_refptr<DnsMaster> master = new DnsMaster(&host_resolver_,
MessageLoop::current(), DnsPrefetcherInit::kMaxConcurrentLookups);
ListValue referral_list;
master->SerializeReferrers(&referral_list);
@@ -456,7 +457,7 @@ TEST_F(DnsMasterTest, ReferrerSerializationNilTest) {
// deserialized into the database, and can be extracted back out via
// serialization without being changed.
TEST_F(DnsMasterTest, ReferrerSerializationSingleReferrerTest) {
- scoped_refptr<DnsMaster> master = new DnsMaster(new net::HostResolver,
+ scoped_refptr<DnsMaster> master = new DnsMaster(&host_resolver_,
MessageLoop::current(), DnsPrefetcherInit::kMaxConcurrentLookups);
std::string motivation_hostname = "www.google.com";
std::string subresource_hostname = "icons.google.com";
@@ -480,7 +481,7 @@ TEST_F(DnsMasterTest, ReferrerSerializationSingleReferrerTest) {
// Make sure the Trim() functionality works as expected.
TEST_F(DnsMasterTest, ReferrerSerializationTrimTest) {
- scoped_refptr<DnsMaster> master = new DnsMaster(new net::HostResolver,
+ scoped_refptr<DnsMaster> master = new DnsMaster(&host_resolver_,
MessageLoop::current(), DnsPrefetcherInit::kMaxConcurrentLookups);
std::string motivation_hostname = "www.google.com";
std::string icon_subresource_hostname = "icons.google.com";
diff --git a/net/base/host_resolver.h b/net/base/host_resolver.h
index a912661..0b5c3fc 100644
--- a/net/base/host_resolver.h
+++ b/net/base/host_resolver.h
@@ -57,7 +57,7 @@ class HostMapper;
// Thread safety: This class is not threadsafe, and must only be called
// from one thread!
//
-class HostResolver : public base::RefCounted<HostResolver> {
+class HostResolver {
public:
// The parameters for doing a Resolve(). |hostname| and |port| are required,
// the rest are optional (and have reasonable defaults).
@@ -236,7 +236,7 @@ class SingleRequestHostResolver {
void OnResolveCompletion(int result);
// The actual host resolver that will handle the request.
- scoped_refptr<HostResolver> resolver_;
+ HostResolver* resolver_;
// The current request (if any).
HostResolver::Request* cur_request_;
diff --git a/net/base/host_resolver_unittest.cc b/net/base/host_resolver_unittest.cc
index 32b6af6..8fb0d16 100644
--- a/net/base/host_resolver_unittest.cc
+++ b/net/base/host_resolver_unittest.cc
@@ -140,8 +140,6 @@ class ResolveRequest {
int result_;
net::AddressList addrlist_;
- // We don't use a scoped_refptr, to simplify deleting shared resolver in
- // DeleteWithinCallback test.
net::HostResolver* resolver_;
Delegate* delegate_;
@@ -172,7 +170,7 @@ class HostResolverTest : public testing::Test {
};
TEST_F(HostResolverTest, SynchronousLookup) {
- scoped_refptr<net::HostResolver> host_resolver(new net::HostResolver);
+ net::HostResolver host_resolver;
net::AddressList adrlist;
const int kPortnum = 80;
@@ -181,7 +179,7 @@ TEST_F(HostResolverTest, SynchronousLookup) {
ScopedHostMapper scoped_mapper(mapper.get());
net::HostResolver::RequestInfo info("just.testing", kPortnum);
- int err = host_resolver->Resolve(info, &adrlist, NULL, NULL);
+ int err = host_resolver.Resolve(info, &adrlist, NULL, NULL);
EXPECT_EQ(net::OK, err);
const struct addrinfo* ainfo = adrlist.head();
@@ -195,7 +193,7 @@ TEST_F(HostResolverTest, SynchronousLookup) {
}
TEST_F(HostResolverTest, AsynchronousLookup) {
- scoped_refptr<net::HostResolver> host_resolver(new net::HostResolver);
+ net::HostResolver host_resolver;
net::AddressList adrlist;
const int kPortnum = 80;
@@ -204,7 +202,7 @@ TEST_F(HostResolverTest, AsynchronousLookup) {
ScopedHostMapper scoped_mapper(mapper.get());
net::HostResolver::RequestInfo info("just.testing", kPortnum);
- int err = host_resolver->Resolve(info, &adrlist, &callback_, NULL);
+ int err = host_resolver.Resolve(info, &adrlist, &callback_, NULL);
EXPECT_EQ(net::ERR_IO_PENDING, err);
MessageLoop::current()->Run();
@@ -227,12 +225,12 @@ TEST_F(HostResolverTest, CanceledAsynchronousLookup) {
ScopedHostMapper scoped_mapper(mapper.get());
{
- scoped_refptr<net::HostResolver> host_resolver(new net::HostResolver);
+ net::HostResolver host_resolver;
net::AddressList adrlist;
const int kPortnum = 80;
net::HostResolver::RequestInfo info("just.testing", kPortnum);
- int err = host_resolver->Resolve(info, &adrlist, &callback_, NULL);
+ int err = host_resolver.Resolve(info, &adrlist, &callback_, NULL);
EXPECT_EQ(net::ERR_IO_PENDING, err);
// Make sure we will exit the queue even when callback is not called.
@@ -254,11 +252,11 @@ TEST_F(HostResolverTest, NumericIPv4Address) {
mapper->AllowDirectLookup("*");
ScopedHostMapper scoped_mapper(mapper.get());
- scoped_refptr<net::HostResolver> host_resolver(new net::HostResolver);
+ net::HostResolver host_resolver;
net::AddressList adrlist;
const int kPortnum = 5555;
net::HostResolver::RequestInfo info("127.1.2.3", kPortnum);
- int err = host_resolver->Resolve(info, &adrlist, NULL, NULL);
+ int err = host_resolver.Resolve(info, &adrlist, NULL, NULL);
EXPECT_EQ(net::OK, err);
const struct addrinfo* ainfo = adrlist.head();
@@ -278,14 +276,14 @@ TEST_F(HostResolverTest, NumericIPv6Address) {
// Resolve a plain IPv6 address. Don't worry about [brackets], because
// the caller should have removed them.
- scoped_refptr<net::HostResolver> host_resolver(new net::HostResolver);
+ net::HostResolver host_resolver;
net::AddressList adrlist;
const int kPortnum = 5555;
net::HostResolver::RequestInfo info("2001:db8::1", kPortnum);
- int err = host_resolver->Resolve(info, &adrlist, NULL, NULL);
+ int err = host_resolver.Resolve(info, &adrlist, NULL, NULL);
// On computers without IPv6 support, getaddrinfo cannot convert IPv6
// address literals to addresses (getaddrinfo returns EAI_NONAME). So this
- // test has to allow host_resolver->Resolve to fail.
+ // test has to allow host_resolver.Resolve to fail.
if (err == net::ERR_NAME_NOT_RESOLVED)
return;
EXPECT_EQ(net::OK, err);
@@ -312,11 +310,11 @@ TEST_F(HostResolverTest, EmptyHost) {
mapper->AllowDirectLookup("*");
ScopedHostMapper scoped_mapper(mapper.get());
- scoped_refptr<net::HostResolver> host_resolver(new net::HostResolver);
+ net::HostResolver host_resolver;
net::AddressList adrlist;
const int kPortnum = 5555;
net::HostResolver::RequestInfo info("", kPortnum);
- int err = host_resolver->Resolve(info, &adrlist, NULL, NULL);
+ int err = host_resolver.Resolve(info, &adrlist, NULL, NULL);
EXPECT_EQ(net::ERR_NAME_NOT_RESOLVED, err);
}
@@ -372,7 +370,7 @@ TEST_F(HostResolverTest, DeDupeRequests) {
scoped_refptr<CapturingHostMapper> mapper = new CapturingHostMapper();
ScopedHostMapper scoped_mapper(mapper.get());
- scoped_refptr<net::HostResolver> host_resolver(new net::HostResolver);
+ net::HostResolver host_resolver;
// The class will receive callbacks for when each resolve completes. It
// checks that the right things happened.
@@ -381,11 +379,11 @@ TEST_F(HostResolverTest, DeDupeRequests) {
// Start 5 requests, duplicating hosts "a" and "b". Since the mapper is
// blocked, these should all pile up until we signal it.
- ResolveRequest req1(host_resolver, "a", 80, &verifier);
- ResolveRequest req2(host_resolver, "b", 80, &verifier);
- ResolveRequest req3(host_resolver, "b", 81, &verifier);
- ResolveRequest req4(host_resolver, "a", 82, &verifier);
- ResolveRequest req5(host_resolver, "b", 83, &verifier);
+ ResolveRequest req1(&host_resolver, "a", 80, &verifier);
+ ResolveRequest req2(&host_resolver, "b", 80, &verifier);
+ ResolveRequest req3(&host_resolver, "b", 81, &verifier);
+ ResolveRequest req4(&host_resolver, "a", 82, &verifier);
+ ResolveRequest req5(&host_resolver, "b", 83, &verifier);
// Ready, Set, GO!!!
mapper->Signal();
@@ -421,7 +419,7 @@ TEST_F(HostResolverTest, CancelMultipleRequests) {
scoped_refptr<CapturingHostMapper> mapper = new CapturingHostMapper();
ScopedHostMapper scoped_mapper(mapper.get());
- scoped_refptr<net::HostResolver> host_resolver(new net::HostResolver);
+ net::HostResolver host_resolver;
// The class will receive callbacks for when each resolve completes. It
// checks that the right things happened.
@@ -430,11 +428,11 @@ TEST_F(HostResolverTest, CancelMultipleRequests) {
// Start 5 requests, duplicating hosts "a" and "b". Since the mapper is
// blocked, these should all pile up until we signal it.
- ResolveRequest req1(host_resolver, "a", 80, &verifier);
- ResolveRequest req2(host_resolver, "b", 80, &verifier);
- ResolveRequest req3(host_resolver, "b", 81, &verifier);
- ResolveRequest req4(host_resolver, "a", 82, &verifier);
- ResolveRequest req5(host_resolver, "b", 83, &verifier);
+ ResolveRequest req1(&host_resolver, "a", 80, &verifier);
+ ResolveRequest req2(&host_resolver, "b", 80, &verifier);
+ ResolveRequest req3(&host_resolver, "b", 81, &verifier);
+ ResolveRequest req4(&host_resolver, "a", 82, &verifier);
+ ResolveRequest req5(&host_resolver, "b", 83, &verifier);
// Cancel everything except request 4.
req1.Cancel();
@@ -506,7 +504,7 @@ TEST_F(HostResolverTest, CancelWithinCallback) {
scoped_refptr<CapturingHostMapper> mapper = new CapturingHostMapper();
ScopedHostMapper scoped_mapper(mapper.get());
- scoped_refptr<net::HostResolver> host_resolver(new net::HostResolver);
+ net::HostResolver host_resolver;
// The class will receive callbacks for when each resolve completes. It
// checks that the right things happened.
@@ -515,10 +513,10 @@ TEST_F(HostResolverTest, CancelWithinCallback) {
// Start 4 requests, duplicating hosts "a". Since the mapper is
// blocked, these should all pile up until we signal it.
- ResolveRequest req1(host_resolver, "a", 80, &verifier);
- ResolveRequest req2(host_resolver, "a", 81, &verifier);
- ResolveRequest req3(host_resolver, "a", 82, &verifier);
- ResolveRequest req4(host_resolver, "a", 83, &verifier);
+ ResolveRequest req1(&host_resolver, "a", 80, &verifier);
+ ResolveRequest req2(&host_resolver, "a", 81, &verifier);
+ ResolveRequest req3(&host_resolver, "a", 82, &verifier);
+ ResolveRequest req4(&host_resolver, "a", 83, &verifier);
// Once "a:80" completes, it will cancel "a:81" and "a:82".
verifier.SetRequestsToCancel(&req2, &req3);
@@ -533,18 +531,12 @@ TEST_F(HostResolverTest, CancelWithinCallback) {
// Helper class used by HostResolverTest.DeleteWithinCallback.
class DeleteWithinCallbackVerifier : public ResolveRequest::Delegate {
public:
- // |host_resolver| is the resolver that the the resolve requests were started
- // with.
- DeleteWithinCallbackVerifier(net::HostResolver* host_resolver)
- : host_resolver_(host_resolver) {}
+ DeleteWithinCallbackVerifier() {}
virtual void OnCompleted(ResolveRequest* resolve) {
EXPECT_EQ("a", resolve->hostname());
EXPECT_EQ(80, resolve->port());
-
- // Release the last reference to the host resolver that started the
- // requests.
- host_resolver_ = NULL;
+ delete resolve->resolver();
// Quit after returning from OnCompleted (to give it a chance at
// incorrectly running the cancelled tasks).
@@ -552,7 +544,6 @@ class DeleteWithinCallbackVerifier : public ResolveRequest::Delegate {
}
private:
- scoped_refptr<net::HostResolver> host_resolver_;
DISALLOW_COPY_AND_ASSIGN(DeleteWithinCallbackVerifier);
};
@@ -562,11 +553,13 @@ TEST_F(HostResolverTest, DeleteWithinCallback) {
scoped_refptr<CapturingHostMapper> mapper = new CapturingHostMapper();
ScopedHostMapper scoped_mapper(mapper.get());
- // The class will receive callbacks for when each resolve completes. It
- // checks that the right things happened. Note that the verifier holds the
- // only reference to |host_resolver|, so it can delete it within callback.
+ // This should be deleted by DeleteWithinCallbackVerifier -- if it leaks
+ // then the test has failed.
net::HostResolver* host_resolver = new net::HostResolver;
- DeleteWithinCallbackVerifier verifier(host_resolver);
+
+ // The class will receive callbacks for when each resolve completes. It
+ // checks that the right things happened.
+ DeleteWithinCallbackVerifier verifier;
// Start 4 requests, duplicating hosts "a". Since the mapper is
// blocked, these should all pile up until we signal it.
@@ -616,7 +609,7 @@ TEST_F(HostResolverTest, StartWithinCallback) {
ScopedHostMapper scoped_mapper(mapper.get());
// Turn off caching for this host resolver.
- scoped_refptr<net::HostResolver> host_resolver(new net::HostResolver(0, 0));
+ net::HostResolver host_resolver(0, 0);
// The class will receive callbacks for when each resolve completes. It
// checks that the right things happened.
@@ -625,10 +618,10 @@ TEST_F(HostResolverTest, StartWithinCallback) {
// Start 4 requests, duplicating hosts "a". Since the mapper is
// blocked, these should all pile up until we signal it.
- ResolveRequest req1(host_resolver, "a", 80, &verifier);
- ResolveRequest req2(host_resolver, "a", 81, &verifier);
- ResolveRequest req3(host_resolver, "a", 82, &verifier);
- ResolveRequest req4(host_resolver, "a", 83, &verifier);
+ ResolveRequest req1(&host_resolver, "a", 80, &verifier);
+ ResolveRequest req2(&host_resolver, "a", 81, &verifier);
+ ResolveRequest req3(&host_resolver, "a", 82, &verifier);
+ ResolveRequest req4(&host_resolver, "a", 83, &verifier);
// Ready, Set, GO!!!
mapper->Signal();
@@ -680,14 +673,14 @@ class BypassCacheVerifier : public ResolveRequest::Delegate {
};
TEST_F(HostResolverTest, BypassCache) {
- scoped_refptr<net::HostResolver> host_resolver(new net::HostResolver);
+ net::HostResolver host_resolver;
// The class will receive callbacks for when each resolve completes. It
// checks that the right things happened.
BypassCacheVerifier verifier;
// Start a request.
- ResolveRequest req1(host_resolver, "a", 80, &verifier);
+ ResolveRequest req1(&host_resolver, "a", 80, &verifier);
// |verifier| will send quit message once all the requests have finished.
MessageLoop::current()->Run();
@@ -763,17 +756,17 @@ class CapturingObserver : public net::HostResolver::Observer {
// Does not test the cancellation notification since all resolves are
// synchronous.
TEST_F(HostResolverTest, Observers) {
- scoped_refptr<net::HostResolver> host_resolver(new net::HostResolver);
+ net::HostResolver host_resolver;
CapturingObserver observer;
- host_resolver->AddObserver(&observer);
+ host_resolver.AddObserver(&observer);
net::AddressList addrlist;
// Resolve "host1".
net::HostResolver::RequestInfo info1("host1", 70);
- int rv = host_resolver->Resolve(info1, &addrlist, NULL, NULL);
+ int rv = host_resolver.Resolve(info1, &addrlist, NULL, NULL);
EXPECT_EQ(net::OK, rv);
EXPECT_EQ(1U, observer.start_log.size());
@@ -787,7 +780,7 @@ TEST_F(HostResolverTest, Observers) {
// Resolve "host1" again -- this time it will be served from cache, but it
// should still notify of completion.
TestCompletionCallback callback;
- rv = host_resolver->Resolve(info1, &addrlist, &callback, NULL);
+ rv = host_resolver.Resolve(info1, &addrlist, &callback, NULL);
ASSERT_EQ(net::OK, rv); // Should complete synchronously.
EXPECT_EQ(2U, observer.start_log.size());
@@ -801,7 +794,7 @@ TEST_F(HostResolverTest, Observers) {
// Resolve "host2", setting referrer to "http://foobar.com"
net::HostResolver::RequestInfo info2("host2", 70);
info2.set_referrer(GURL("http://foobar.com"));
- rv = host_resolver->Resolve(info2, &addrlist, NULL, NULL);
+ rv = host_resolver.Resolve(info2, &addrlist, NULL, NULL);
EXPECT_EQ(net::OK, rv);
EXPECT_EQ(3U, observer.start_log.size());
@@ -813,11 +806,11 @@ TEST_F(HostResolverTest, Observers) {
CapturingObserver::FinishEntry(2, true, info2));
// Unregister the observer.
- host_resolver->RemoveObserver(&observer);
+ host_resolver.RemoveObserver(&observer);
// Resolve "host3"
net::HostResolver::RequestInfo info3("host3", 70);
- host_resolver->Resolve(info3, &addrlist, NULL, NULL);
+ host_resolver.Resolve(info3, &addrlist, NULL, NULL);
// No effect this time, since observer was removed.
EXPECT_EQ(3U, observer.start_log.size());
@@ -833,8 +826,8 @@ TEST_F(HostResolverTest, CancellationObserver) {
CapturingObserver observer;
{
// Create a host resolver and attach an observer.
- scoped_refptr<net::HostResolver> host_resolver(new net::HostResolver);
- host_resolver->AddObserver(&observer);
+ net::HostResolver host_resolver;
+ host_resolver.AddObserver(&observer);
TestCompletionCallback callback;
@@ -846,7 +839,7 @@ TEST_F(HostResolverTest, CancellationObserver) {
net::HostResolver::RequestInfo info1("host1", 70);
net::HostResolver::Request* req = NULL;
net::AddressList addrlist;
- int rv = host_resolver->Resolve(info1, &addrlist, &callback, &req);
+ int rv = host_resolver.Resolve(info1, &addrlist, &callback, &req);
EXPECT_EQ(net::ERR_IO_PENDING, rv);
EXPECT_TRUE(NULL != req);
@@ -858,7 +851,7 @@ TEST_F(HostResolverTest, CancellationObserver) {
CapturingObserver::StartOrCancelEntry(0, info1));
// Cancel the request (host mapper is blocked so it cant be finished yet).
- host_resolver->CancelRequest(req);
+ host_resolver.CancelRequest(req);
EXPECT_EQ(1U, observer.start_log.size());
EXPECT_EQ(0U, observer.finish_log.size());
@@ -869,7 +862,7 @@ TEST_F(HostResolverTest, CancellationObserver) {
// Start an async request for (host2:60)
net::HostResolver::RequestInfo info2("host2", 60);
- rv = host_resolver->Resolve(info2, &addrlist, &callback, NULL);
+ rv = host_resolver.Resolve(info2, &addrlist, &callback, NULL);
EXPECT_EQ(net::ERR_IO_PENDING, rv);
EXPECT_TRUE(NULL != req);
diff --git a/net/ftp/ftp_network_session.h b/net/ftp/ftp_network_session.h
index dcaacad..29c34d2 100644
--- a/net/ftp/ftp_network_session.h
+++ b/net/ftp/ftp_network_session.h
@@ -22,7 +22,7 @@ class FtpNetworkSession : public base::RefCounted<FtpNetworkSession> {
FtpAuthCache* auth_cache() { return &auth_cache_; }
private:
- scoped_refptr<HostResolver> host_resolver_;
+ HostResolver* host_resolver_;
FtpAuthCache auth_cache_;
};
diff --git a/net/ftp/ftp_network_transaction_unittest.cc b/net/ftp/ftp_network_transaction_unittest.cc
index d381b0b..b45156b 100644
--- a/net/ftp/ftp_network_transaction_unittest.cc
+++ b/net/ftp/ftp_network_transaction_unittest.cc
@@ -224,7 +224,7 @@ class FtpMockControlSocketFileDownloadRetrFail
class FtpNetworkTransactionTest : public PlatformTest {
public:
FtpNetworkTransactionTest()
- : session_(new FtpNetworkSession(new HostResolver)),
+ : session_(new FtpNetworkSession(&resolver_)),
transaction_(session_.get(), &mock_socket_factory_) {
}
@@ -253,6 +253,7 @@ class FtpNetworkTransactionTest : public PlatformTest {
EXPECT_EQ(FtpMockControlSocket::QUIT, ctrl_socket->state());
}
+ HostResolver resolver_;
scoped_refptr<FtpNetworkSession> session_;
MockClientSocketFactory mock_socket_factory_;
FtpNetworkTransaction transaction_;
diff --git a/net/http/http_network_layer.h b/net/http/http_network_layer.h
index b4b430f..74cf3df 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.
- scoped_refptr<HostResolver> host_resolver_;
+ 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 9fd35ea..32888f0 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, new net::HostResolver, proxy_service.get());
+ net::HttpNetworkLayer factory(NULL, &host_resolver, 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, new net::HostResolver, proxy_service.get());
+ net::HttpNetworkLayer factory(NULL, &host_resolver, proxy_service.get());
scoped_ptr<net::HttpTransaction> trans(factory.CreateTransaction());
trans.reset();
@@ -55,8 +55,9 @@ 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, new net::HostResolver,
+ net::HttpNetworkLayer factory(&mock_socket_factory, &host_resolver,
proxy_service.get());
TestCompletionCallback callback;
diff --git a/net/http/http_network_session.h b/net/http/http_network_session.h
index 3529bc8..a084ec7 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_;
- scoped_refptr<HostResolver> host_resolver_;
+ 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 bcb22a9..ba68db1 100644
--- a/net/http/http_network_transaction_unittest.cc
+++ b/net/http/http_network_transaction_unittest.cc
@@ -35,14 +35,13 @@ ProxyService* CreateNullProxyService() {
class SessionDependencies {
public:
// Default set of dependencies -- "null" proxy service.
- SessionDependencies() : host_resolver(new HostResolver),
- proxy_service(CreateNullProxyService()) {}
+ SessionDependencies() : proxy_service(CreateNullProxyService()) {}
// Custom proxy service dependency.
explicit SessionDependencies(ProxyService* proxy_service)
- : host_resolver(new HostResolver), proxy_service(proxy_service) {}
+ : proxy_service(proxy_service) {}
- scoped_refptr<HostResolver> host_resolver;
+ HostResolver host_resolver;
scoped_ptr<ProxyService> proxy_service;
MockClientSocketFactory socket_factory;
};
@@ -55,7 +54,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);
}
@@ -3303,7 +3302,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[] = {
@@ -3339,14 +3338,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);
diff --git a/net/proxy/proxy_resolver_perftest.cc b/net/proxy/proxy_resolver_perftest.cc
index 22f2350..85ad554 100644
--- a/net/proxy/proxy_resolver_perftest.cc
+++ b/net/proxy/proxy_resolver_perftest.cc
@@ -185,8 +185,10 @@ TEST(ProxyResolverPerfTest, ProxyResolverMac) {
#endif
TEST(ProxyResolverPerfTest, ProxyResolverV8) {
+ net::HostResolver host_resolver;
+
net::ProxyResolverV8::JSBindings* js_bindings =
- net::ProxyResolverV8::CreateDefaultBindings(new net::HostResolver, NULL);
+ net::ProxyResolverV8::CreateDefaultBindings(&host_resolver, NULL);
net::ProxyResolverV8 resolver(js_bindings);
PacPerfSuiteRunner runner(&resolver, "ProxyResolverV8");
diff --git a/net/proxy/proxy_resolver_v8.cc b/net/proxy/proxy_resolver_v8.cc
index 6bbffec..ad4f1eb6 100644
--- a/net/proxy/proxy_resolver_v8.cc
+++ b/net/proxy/proxy_resolver_v8.cc
@@ -103,7 +103,7 @@ class SyncHostResolverBridge
event_.Signal();
}
- scoped_refptr<HostResolver> host_resolver_;
+ HostResolver* host_resolver_;
MessageLoop* host_resolver_loop_;
// Event to notify completion of resolve request.
diff --git a/net/proxy/proxy_resolver_v8_unittest.cc b/net/proxy/proxy_resolver_v8_unittest.cc
index 7fab7d7..0e8ba47 100644
--- a/net/proxy/proxy_resolver_v8_unittest.cc
+++ b/net/proxy/proxy_resolver_v8_unittest.cc
@@ -378,8 +378,9 @@ TEST(ProxyResolverV8Test, V8Bindings) {
TEST(ProxyResolverV8DefaultBindingsTest, DnsResolve) {
// Get a hold of a DefaultJSBindings* (it is a hidden impl class).
+ net::HostResolver host_resolver;
scoped_ptr<net::ProxyResolverV8::JSBindings> bindings(
- net::ProxyResolverV8::CreateDefaultBindings(new net::HostResolver, NULL));
+ net::ProxyResolverV8::CreateDefaultBindings(&host_resolver, NULL));
// Considered an error.
EXPECT_EQ("", bindings->DnsResolve(""));
@@ -429,8 +430,9 @@ TEST(ProxyResolverV8DefaultBindingsTest, DnsResolve) {
TEST(ProxyResolverV8DefaultBindingsTest, MyIpAddress) {
// Get a hold of a DefaultJSBindings* (it is a hidden impl class).
+ net::HostResolver host_resolver;
scoped_ptr<net::ProxyResolverV8::JSBindings> bindings(
- net::ProxyResolverV8::CreateDefaultBindings(new net::HostResolver, NULL));
+ net::ProxyResolverV8::CreateDefaultBindings(&host_resolver, NULL));
// Our ip address is always going to be 127.0.0.1, since we are using a
// mock host mapper when running in unit-test mode.
diff --git a/net/proxy/proxy_script_fetcher_unittest.cc b/net/proxy/proxy_script_fetcher_unittest.cc
index 8a7cfb5..5b16738b 100644
--- a/net/proxy/proxy_script_fetcher_unittest.cc
+++ b/net/proxy/proxy_script_fetcher_unittest.cc
@@ -41,6 +41,7 @@ class RequestContext : public URLRequestContext {
~RequestContext() {
delete http_transaction_factory_;
delete proxy_service_;
+ delete host_resolver_;
}
};
diff --git a/net/socket/client_socket_pool_base.h b/net/socket/client_socket_pool_base.h
index c642b48..6280048 100644
--- a/net/socket/client_socket_pool_base.h
+++ b/net/socket/client_socket_pool_base.h
@@ -218,9 +218,9 @@ class ClientSocketPoolBase : public base::RefCounted<ClientSocketPoolBase> {
// The maximum number of sockets kept per group.
const int max_sockets_per_group_;
- // The host resolver that will be used to do host lookups for connecting
+ // The host resolver that will be used to do DNS lookups for connecting
// sockets.
- scoped_refptr<HostResolver> host_resolver_;
+ HostResolver* const host_resolver_;
scoped_ptr<ConnectJobFactory> connect_job_factory_;
diff --git a/net/socket/ssl_client_socket_unittest.cc b/net/socket/ssl_client_socket_unittest.cc
index 1d68bd1..c6308fa 100644
--- a/net/socket/ssl_client_socket_unittest.cc
+++ b/net/socket/ssl_client_socket_unittest.cc
@@ -86,11 +86,11 @@ TEST_F(SSLClientSocketTest, MAYBE_Connect) {
StartOKServer();
net::AddressList addr;
- scoped_refptr<net::HostResolver> resolver(new net::HostResolver);
+ net::HostResolver resolver;
TestCompletionCallback callback;
net::HostResolver::RequestInfo info(server_.kHostName, server_.kOKHTTPSPort);
- int rv = resolver->Resolve(info, &addr, NULL, NULL);
+ int rv = resolver.Resolve(info, &addr, NULL, NULL);
EXPECT_EQ(net::OK, rv);
net::ClientSocket *transport = new net::TCPClientSocket(addr);
@@ -124,11 +124,11 @@ TEST_F(SSLClientSocketTest, MAYBE_ConnectExpired) {
StartExpiredServer();
net::AddressList addr;
- scoped_refptr<net::HostResolver> resolver(new net::HostResolver);
+ net::HostResolver resolver;
TestCompletionCallback callback;
net::HostResolver::RequestInfo info(server_.kHostName, server_.kBadHTTPSPort);
- int rv = resolver->Resolve(info, &addr, NULL, NULL);
+ int rv = resolver.Resolve(info, &addr, NULL, NULL);
EXPECT_EQ(net::OK, rv);
net::ClientSocket *transport = new net::TCPClientSocket(addr);
@@ -161,12 +161,12 @@ TEST_F(SSLClientSocketTest, MAYBE_ConnectMismatched) {
StartMismatchedServer();
net::AddressList addr;
- scoped_refptr<net::HostResolver> resolver(new net::HostResolver);
+ net::HostResolver resolver;
TestCompletionCallback callback;
net::HostResolver::RequestInfo info(server_.kMismatchedHostName,
server_.kOKHTTPSPort);
- int rv = resolver->Resolve(info, &addr, NULL, NULL);
+ int rv = resolver.Resolve(info, &addr, NULL, NULL);
EXPECT_EQ(net::OK, rv);
net::ClientSocket *transport = new net::TCPClientSocket(addr);
@@ -204,11 +204,11 @@ TEST_F(SSLClientSocketTest, MAYBE_Read) {
StartOKServer();
net::AddressList addr;
- scoped_refptr<net::HostResolver> resolver(new net::HostResolver);
+ net::HostResolver resolver;
TestCompletionCallback callback;
net::HostResolver::RequestInfo info(server_.kHostName, server_.kOKHTTPSPort);
- int rv = resolver->Resolve(info, &addr, &callback, NULL);
+ int rv = resolver.Resolve(info, &addr, &callback, NULL);
EXPECT_EQ(net::ERR_IO_PENDING, rv);
rv = callback.WaitForResult();
@@ -265,11 +265,11 @@ TEST_F(SSLClientSocketTest, MAYBE_Read_SmallChunks) {
StartOKServer();
net::AddressList addr;
- scoped_refptr<net::HostResolver> resolver(new net::HostResolver);
+ net::HostResolver resolver;
TestCompletionCallback callback;
net::HostResolver::RequestInfo info(server_.kHostName, server_.kOKHTTPSPort);
- int rv = resolver->Resolve(info, &addr, NULL, NULL);
+ int rv = resolver.Resolve(info, &addr, NULL, NULL);
EXPECT_EQ(net::OK, rv);
net::ClientSocket *transport = new net::TCPClientSocket(addr);
@@ -321,11 +321,11 @@ TEST_F(SSLClientSocketTest, MAYBE_Read_Interrupted) {
StartOKServer();
net::AddressList addr;
- scoped_refptr<net::HostResolver> resolver(new net::HostResolver);
+ net::HostResolver resolver;
TestCompletionCallback callback;
net::HostResolver::RequestInfo info(server_.kHostName, server_.kOKHTTPSPort);
- int rv = resolver->Resolve(info, &addr, NULL, NULL);
+ int rv = resolver.Resolve(info, &addr, NULL, NULL);
EXPECT_EQ(net::OK, rv);
net::ClientSocket *transport = new net::TCPClientSocket(addr);
diff --git a/net/socket/ssl_test_util.cc b/net/socket/ssl_test_util.cc
index 101cbf5..f615662 100644
--- a/net/socket/ssl_test_util.cc
+++ b/net/socket/ssl_test_util.cc
@@ -246,9 +246,9 @@ bool TestServerLauncher::WaitToStart(const std::string& host_name, int port) {
// Verify that the webserver is actually started.
// Otherwise tests can fail if they run faster than Python can start.
net::AddressList addr;
- scoped_refptr<net::HostResolver> resolver(new net::HostResolver);
+ net::HostResolver resolver;
net::HostResolver::RequestInfo info(host_name, port);
- int rv = resolver->Resolve(info, &addr, NULL, NULL);
+ int rv = resolver.Resolve(info, &addr, NULL, NULL);
if (rv != net::OK)
return false;
diff --git a/net/socket/tcp_client_socket_pool_unittest.cc b/net/socket/tcp_client_socket_pool_unittest.cc
index 5d9e630..9cd62e8 100644
--- a/net/socket/tcp_client_socket_pool_unittest.cc
+++ b/net/socket/tcp_client_socket_pool_unittest.cc
@@ -225,7 +225,7 @@ class TCPClientSocketPoolTest : public testing::Test {
protected:
TCPClientSocketPoolTest()
: pool_(new TCPClientSocketPool(kMaxSocketsPerGroup,
- new HostResolver,
+ &host_resolver_,
&client_socket_factory_)) {}
virtual void SetUp() {
@@ -242,6 +242,7 @@ class TCPClientSocketPoolTest : public testing::Test {
}
ScopedHostMapper scoped_host_mapper_;
+ HostResolver host_resolver_;
MockClientSocketFactory client_socket_factory_;
scoped_refptr<ClientSocketPool> pool_;
std::vector<TestSocketRequest*> request_order_;
diff --git a/net/socket/tcp_client_socket_unittest.cc b/net/socket/tcp_client_socket_unittest.cc
index 91b0e57..519d938 100644
--- a/net/socket/tcp_client_socket_unittest.cc
+++ b/net/socket/tcp_client_socket_unittest.cc
@@ -86,9 +86,9 @@ void TCPClientSocketTest::SetUp() {
listen_port_ = port;
AddressList addr;
- scoped_refptr<HostResolver> resolver(new HostResolver);
+ HostResolver resolver;
HostResolver::RequestInfo info("localhost", listen_port_);
- int rv = resolver->Resolve(info, &addr, NULL, NULL);
+ int rv = resolver.Resolve(info, &addr, NULL, NULL);
CHECK(rv == OK);
sock_.reset(new TCPClientSocket(addr));
}
diff --git a/net/socket/tcp_pinger_unittest.cc b/net/socket/tcp_pinger_unittest.cc
index c807007..1d94ddd 100644
--- a/net/socket/tcp_pinger_unittest.cc
+++ b/net/socket/tcp_pinger_unittest.cc
@@ -65,10 +65,10 @@ void TCPPingerTest::SetUp() {
TEST_F(TCPPingerTest, Ping) {
net::AddressList addr;
- scoped_refptr<net::HostResolver> resolver(new net::HostResolver);
+ net::HostResolver resolver;
net::HostResolver::RequestInfo info("localhost", listen_port_);
- int rv = resolver->Resolve(info, &addr, NULL, NULL);
+ int rv = resolver.Resolve(info, &addr, NULL, NULL);
EXPECT_EQ(rv, net::OK);
net::TCPPinger pinger(addr);
@@ -78,13 +78,13 @@ TEST_F(TCPPingerTest, Ping) {
TEST_F(TCPPingerTest, PingFail) {
net::AddressList addr;
- scoped_refptr<net::HostResolver> resolver(new net::HostResolver);
+ net::HostResolver resolver;
// "Kill" "server"
listen_sock_ = NULL;
net::HostResolver::RequestInfo info("localhost", listen_port_);
- int rv = resolver->Resolve(info, &addr, NULL, NULL);
+ int rv = resolver.Resolve(info, &addr, NULL, NULL);
EXPECT_EQ(rv, net::OK);
net::TCPPinger pinger(addr);
diff --git a/net/tools/fetch/fetch_client.cc b/net/tools/fetch/fetch_client.cc
index 783c91d..68022f2 100644
--- a/net/tools/fetch/fetch_client.cc
+++ b/net/tools/fetch/fetch_client.cc
@@ -127,14 +127,14 @@ int main(int argc, char**argv) {
// Do work here.
MessageLoop loop;
- scoped_refptr<net::HostResolver> host_resolver(new net::HostResolver);
+ net::HostResolver host_resolver;
scoped_ptr<net::ProxyService> proxy_service(net::ProxyService::CreateNull());
net::HttpTransactionFactory* factory = NULL;
if (use_cache) {
- factory = new net::HttpCache(host_resolver, proxy_service.get(), 0);
+ factory = new net::HttpCache(&host_resolver, proxy_service.get(), 0);
} else {
factory = new net::HttpNetworkLayer(
- net::ClientSocketFactory::GetDefaultFactory(), host_resolver,
+ net::ClientSocketFactory::GetDefaultFactory(), &host_resolver,
proxy_service.get());
}
diff --git a/net/url_request/url_request_context.h b/net/url_request/url_request_context.h
index 486ade0..374af90 100644
--- a/net/url_request/url_request_context.h
+++ b/net/url_request/url_request_context.h
@@ -13,13 +13,13 @@
#include "base/ref_counted.h"
#include "base/string_util.h"
#include "net/base/cookie_policy.h"
-#include "net/base/host_resolver.h"
#include "net/ftp/ftp_auth_cache.h"
namespace net {
class CookieMonster;
class ForceTLSState;
class FtpTransactionFactory;
+class HostResolver;
class HttpTransactionFactory;
class ProxyService;
}
@@ -113,7 +113,7 @@ class URLRequestContext :
// The following members are expected to be initialized and owned by
// subclasses.
- scoped_refptr<net::HostResolver> host_resolver_;
+ net::HostResolver* host_resolver_;
net::ProxyService* proxy_service_;
net::HttpTransactionFactory* http_transaction_factory_;
net::FtpTransactionFactory* ftp_transaction_factory_;
diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc
index 415fb1c..f5452be 100644
--- a/net/url_request/url_request_unittest.cc
+++ b/net/url_request/url_request_unittest.cc
@@ -59,6 +59,7 @@ class URLRequestHttpCacheContext : public URLRequestContext {
delete cookie_store_;
delete http_transaction_factory_;
delete proxy_service_;
+ delete host_resolver_;
}
};
diff --git a/net/url_request/url_request_unittest.h b/net/url_request/url_request_unittest.h
index dcc1757..a4ec2fe 100644
--- a/net/url_request/url_request_unittest.h
+++ b/net/url_request/url_request_unittest.h
@@ -51,7 +51,10 @@ class TestURLRequestContext : public URLRequestContext {
}
explicit TestURLRequestContext(const std::string& proxy) {
- host_resolver_ = new net::HostResolver;
+ // TODO(eroman): we turn off host caching to see if synchronous
+ // host resolving interacts poorly with client socket pool. [experiment]
+ // http://crbug.com/13952
+ host_resolver_ = new net::HostResolver(0, 0);
net::ProxyConfig proxy_config;
proxy_config.proxy_rules.ParseFromString(proxy);
proxy_service_ = net::ProxyService::CreateFixed(proxy_config);
@@ -63,6 +66,7 @@ class TestURLRequestContext : public URLRequestContext {
virtual ~TestURLRequestContext() {
delete http_transaction_factory_;
delete proxy_service_;
+ delete host_resolver_;
}
};
diff --git a/webkit/tools/test_shell/test_shell_request_context.cc b/webkit/tools/test_shell/test_shell_request_context.cc
index cd0f31a..480ba9c 100644
--- a/webkit/tools/test_shell/test_shell_request_context.cc
+++ b/webkit/tools/test_shell/test_shell_request_context.cc
@@ -73,6 +73,7 @@ TestShellRequestContext::~TestShellRequestContext() {
delete ftp_transaction_factory_;
delete http_transaction_factory_;
delete proxy_service_;
+ delete host_resolver_;
}
const std::string& TestShellRequestContext::GetUserAgent(