diff options
author | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-26 22:06:52 +0000 |
---|---|---|
committer | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-26 22:06:52 +0000 |
commit | 862a92ee0afc1be6470beed3e19465c24da223e2 (patch) | |
tree | dec2efaa94cf3e1eae580599e87f84e7af082594 | |
parent | f816c01e9c6f6f0365ba80ba3f661e38461a0537 (diff) | |
download | chromium_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
28 files changed, 135 insertions, 153 deletions
diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc index 1e01821..4b788c5 100644 --- a/chrome/browser/net/chrome_url_request_context.cc +++ b/chrome/browser/net/chrome_url_request_context.cc @@ -462,7 +462,4 @@ 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 9e4c8f6..4b821c6 100644 --- a/chrome/browser/net/dns_global.cc +++ b/chrome/browser/net/dns_global.cc @@ -435,9 +435,13 @@ void InitDnsPrefetch(size_t max_concurrent, PrefService* user_prefs) { } void EnsureDnsPrefetchShutdown() { - if (NULL != dns_master) + if (NULL != dns_master) { dns_master->Shutdown(); - FreeGlobalHostResolver(); + + // 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); + } } void FreeDnsPrefetchResources() { @@ -469,14 +473,6 @@ 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 c9a864f..e27062e 100644 --- a/chrome/browser/net/dns_global.h +++ b/chrome/browser/net/dns_global.h @@ -36,13 +36,9 @@ void EnsureDnsPrefetchShutdown(); void FreeDnsPrefetchResources(); // Lazily allocates a HostResolver to be used by the DNS prefetch system, on -// the IO thread. Must be matched by a call to FreeGlobalHostResolver(). +// the IO thread. 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 fa1c783..04fc56f 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_|. - net::HostResolver* host_resolver_; + scoped_refptr<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 e056555..da720fe 100644 --- a/chrome/browser/net/dns_master_unittest.cc +++ b/chrome/browser/net/dns_master_unittest.cc @@ -82,7 +82,6 @@ class DnsMasterTest : public testing::Test { MessageLoop::current()->Run(); } - net::HostResolver host_resolver_; scoped_refptr<net::RuleBasedHostMapper> mapper_; private: @@ -111,10 +110,10 @@ static std::string GetNonexistantDomain() { TimeDelta BlockingDnsLookup(const std::string& hostname) { Time start = Time::Now(); - net::HostResolver resolver; + scoped_refptr<net::HostResolver> resolver(new net::HostResolver); 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; } @@ -163,13 +162,13 @@ TEST_F(DnsMasterTest, OsCachesLookupsTest) { } TEST_F(DnsMasterTest, StartupShutdownTest) { - scoped_refptr<DnsMaster> testing_master = new DnsMaster(&host_resolver_, + scoped_refptr<DnsMaster> testing_master = new DnsMaster(new net::HostResolver, MessageLoop::current(), DnsPrefetcherInit::kMaxConcurrentLookups); testing_master->Shutdown(); } TEST_F(DnsMasterTest, BenefitLookupTest) { - scoped_refptr<DnsMaster> testing_master = new DnsMaster(&host_resolver_, + scoped_refptr<DnsMaster> testing_master = new DnsMaster(new net::HostResolver, MessageLoop::current(), DnsPrefetcherInit::kMaxConcurrentLookups); std::string goog("www.google.com"), @@ -232,7 +231,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(&host_resolver_, + scoped_refptr<DnsMaster> testing_master = new DnsMaster(new net::HostResolver, MessageLoop::current(), DnsPrefetcherInit::kMaxConcurrentLookups); std::string localhost("127.0.0.1"); @@ -255,7 +254,7 @@ TEST_F(DnsMasterTest, ShutdownWhenResolutionIsPendingTest) { } TEST_F(DnsMasterTest, SingleLookupTest) { - scoped_refptr<DnsMaster> testing_master = new DnsMaster(&host_resolver_, + scoped_refptr<DnsMaster> testing_master = new DnsMaster(new net::HostResolver, MessageLoop::current(), DnsPrefetcherInit::kMaxConcurrentLookups); std::string goog("www.google.com"); @@ -284,7 +283,7 @@ TEST_F(DnsMasterTest, SingleLookupTest) { TEST_F(DnsMasterTest, ConcurrentLookupTest) { mapper_->AddSimulatedFailure("*.notfound"); - scoped_refptr<DnsMaster> testing_master = new DnsMaster(&host_resolver_, + scoped_refptr<DnsMaster> testing_master = new DnsMaster(new net::HostResolver, MessageLoop::current(), DnsPrefetcherInit::kMaxConcurrentLookups); std::string goog("www.google.com"), @@ -338,7 +337,7 @@ TEST_F(DnsMasterTest, ConcurrentLookupTest) { TEST_F(DnsMasterTest, DISABLED_MassiveConcurrentLookupTest) { mapper_->AddSimulatedFailure("*.notfound"); - scoped_refptr<DnsMaster> testing_master = new DnsMaster(&host_resolver_, + scoped_refptr<DnsMaster> testing_master = new DnsMaster(new net::HostResolver, MessageLoop::current(), DnsPrefetcherInit::kMaxConcurrentLookups); NameList names; @@ -442,7 +441,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(&host_resolver_, + scoped_refptr<DnsMaster> master = new DnsMaster(new net::HostResolver, MessageLoop::current(), DnsPrefetcherInit::kMaxConcurrentLookups); ListValue referral_list; master->SerializeReferrers(&referral_list); @@ -457,7 +456,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(&host_resolver_, + scoped_refptr<DnsMaster> master = new DnsMaster(new net::HostResolver, MessageLoop::current(), DnsPrefetcherInit::kMaxConcurrentLookups); std::string motivation_hostname = "www.google.com"; std::string subresource_hostname = "icons.google.com"; @@ -481,7 +480,7 @@ TEST_F(DnsMasterTest, ReferrerSerializationSingleReferrerTest) { // Make sure the Trim() functionality works as expected. TEST_F(DnsMasterTest, ReferrerSerializationTrimTest) { - scoped_refptr<DnsMaster> master = new DnsMaster(&host_resolver_, + scoped_refptr<DnsMaster> master = new DnsMaster(new net::HostResolver, 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 0b5c3fc..a912661 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 { +class HostResolver : public base::RefCounted<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. - HostResolver* resolver_; + scoped_refptr<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 8fb0d16..32b6af6 100644 --- a/net/base/host_resolver_unittest.cc +++ b/net/base/host_resolver_unittest.cc @@ -140,6 +140,8 @@ 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_; @@ -170,7 +172,7 @@ class HostResolverTest : public testing::Test { }; TEST_F(HostResolverTest, SynchronousLookup) { - net::HostResolver host_resolver; + scoped_refptr<net::HostResolver> host_resolver(new net::HostResolver); net::AddressList adrlist; const int kPortnum = 80; @@ -179,7 +181,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(); @@ -193,7 +195,7 @@ TEST_F(HostResolverTest, SynchronousLookup) { } TEST_F(HostResolverTest, AsynchronousLookup) { - net::HostResolver host_resolver; + scoped_refptr<net::HostResolver> host_resolver(new net::HostResolver); net::AddressList adrlist; const int kPortnum = 80; @@ -202,7 +204,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(); @@ -225,12 +227,12 @@ TEST_F(HostResolverTest, CanceledAsynchronousLookup) { ScopedHostMapper scoped_mapper(mapper.get()); { - net::HostResolver host_resolver; + scoped_refptr<net::HostResolver> host_resolver(new net::HostResolver); 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. @@ -252,11 +254,11 @@ TEST_F(HostResolverTest, NumericIPv4Address) { mapper->AllowDirectLookup("*"); ScopedHostMapper scoped_mapper(mapper.get()); - net::HostResolver host_resolver; + scoped_refptr<net::HostResolver> host_resolver(new net::HostResolver); 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(); @@ -276,14 +278,14 @@ TEST_F(HostResolverTest, NumericIPv6Address) { // Resolve a plain IPv6 address. Don't worry about [brackets], because // the caller should have removed them. - net::HostResolver host_resolver; + scoped_refptr<net::HostResolver> host_resolver(new net::HostResolver); 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); @@ -310,11 +312,11 @@ TEST_F(HostResolverTest, EmptyHost) { mapper->AllowDirectLookup("*"); ScopedHostMapper scoped_mapper(mapper.get()); - net::HostResolver host_resolver; + scoped_refptr<net::HostResolver> host_resolver(new net::HostResolver); 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); } @@ -370,7 +372,7 @@ TEST_F(HostResolverTest, DeDupeRequests) { scoped_refptr<CapturingHostMapper> mapper = new CapturingHostMapper(); ScopedHostMapper scoped_mapper(mapper.get()); - net::HostResolver host_resolver; + scoped_refptr<net::HostResolver> host_resolver(new net::HostResolver); // The class will receive callbacks for when each resolve completes. It // checks that the right things happened. @@ -379,11 +381,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(); @@ -419,7 +421,7 @@ TEST_F(HostResolverTest, CancelMultipleRequests) { scoped_refptr<CapturingHostMapper> mapper = new CapturingHostMapper(); ScopedHostMapper scoped_mapper(mapper.get()); - net::HostResolver host_resolver; + scoped_refptr<net::HostResolver> host_resolver(new net::HostResolver); // The class will receive callbacks for when each resolve completes. It // checks that the right things happened. @@ -428,11 +430,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(); @@ -504,7 +506,7 @@ TEST_F(HostResolverTest, CancelWithinCallback) { scoped_refptr<CapturingHostMapper> mapper = new CapturingHostMapper(); ScopedHostMapper scoped_mapper(mapper.get()); - net::HostResolver host_resolver; + scoped_refptr<net::HostResolver> host_resolver(new net::HostResolver); // The class will receive callbacks for when each resolve completes. It // checks that the right things happened. @@ -513,10 +515,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); @@ -531,12 +533,18 @@ TEST_F(HostResolverTest, CancelWithinCallback) { // Helper class used by HostResolverTest.DeleteWithinCallback. class DeleteWithinCallbackVerifier : public ResolveRequest::Delegate { public: - DeleteWithinCallbackVerifier() {} + // |host_resolver| is the resolver that the the resolve requests were started + // with. + DeleteWithinCallbackVerifier(net::HostResolver* host_resolver) + : host_resolver_(host_resolver) {} virtual void OnCompleted(ResolveRequest* resolve) { EXPECT_EQ("a", resolve->hostname()); EXPECT_EQ(80, resolve->port()); - delete resolve->resolver(); + + // Release the last reference to the host resolver that started the + // requests. + host_resolver_ = NULL; // Quit after returning from OnCompleted (to give it a chance at // incorrectly running the cancelled tasks). @@ -544,6 +552,7 @@ class DeleteWithinCallbackVerifier : public ResolveRequest::Delegate { } private: + scoped_refptr<net::HostResolver> host_resolver_; DISALLOW_COPY_AND_ASSIGN(DeleteWithinCallbackVerifier); }; @@ -553,13 +562,11 @@ TEST_F(HostResolverTest, DeleteWithinCallback) { scoped_refptr<CapturingHostMapper> mapper = new CapturingHostMapper(); ScopedHostMapper scoped_mapper(mapper.get()); - // This should be deleted by DeleteWithinCallbackVerifier -- if it leaks - // then the test has failed. - net::HostResolver* host_resolver = new net::HostResolver; - // The class will receive callbacks for when each resolve completes. It - // checks that the right things happened. - DeleteWithinCallbackVerifier verifier; + // checks that the right things happened. Note that the verifier holds the + // only reference to |host_resolver|, so it can delete it within callback. + net::HostResolver* host_resolver = new net::HostResolver; + DeleteWithinCallbackVerifier verifier(host_resolver); // Start 4 requests, duplicating hosts "a". Since the mapper is // blocked, these should all pile up until we signal it. @@ -609,7 +616,7 @@ TEST_F(HostResolverTest, StartWithinCallback) { ScopedHostMapper scoped_mapper(mapper.get()); // Turn off caching for this host resolver. - net::HostResolver host_resolver(0, 0); + scoped_refptr<net::HostResolver> host_resolver(new net::HostResolver(0, 0)); // The class will receive callbacks for when each resolve completes. It // checks that the right things happened. @@ -618,10 +625,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(); @@ -673,14 +680,14 @@ class BypassCacheVerifier : public ResolveRequest::Delegate { }; TEST_F(HostResolverTest, BypassCache) { - net::HostResolver host_resolver; + scoped_refptr<net::HostResolver> host_resolver(new net::HostResolver); // 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(); @@ -756,17 +763,17 @@ class CapturingObserver : public net::HostResolver::Observer { // Does not test the cancellation notification since all resolves are // synchronous. TEST_F(HostResolverTest, Observers) { - net::HostResolver host_resolver; + scoped_refptr<net::HostResolver> host_resolver(new net::HostResolver); 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()); @@ -780,7 +787,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()); @@ -794,7 +801,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()); @@ -806,11 +813,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()); @@ -826,8 +833,8 @@ TEST_F(HostResolverTest, CancellationObserver) { CapturingObserver observer; { // Create a host resolver and attach an observer. - net::HostResolver host_resolver; - host_resolver.AddObserver(&observer); + scoped_refptr<net::HostResolver> host_resolver(new net::HostResolver); + host_resolver->AddObserver(&observer); TestCompletionCallback callback; @@ -839,7 +846,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); @@ -851,7 +858,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()); @@ -862,7 +869,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 29c34d2..dcaacad 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: - HostResolver* host_resolver_; + scoped_refptr<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 b45156b..d381b0b 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(&resolver_)), + : session_(new FtpNetworkSession(new HostResolver)), transaction_(session_.get(), &mock_socket_factory_) { } @@ -253,7 +253,6 @@ 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 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); diff --git a/net/proxy/proxy_resolver_perftest.cc b/net/proxy/proxy_resolver_perftest.cc index 85ad554..22f2350 100644 --- a/net/proxy/proxy_resolver_perftest.cc +++ b/net/proxy/proxy_resolver_perftest.cc @@ -185,10 +185,8 @@ TEST(ProxyResolverPerfTest, ProxyResolverMac) { #endif TEST(ProxyResolverPerfTest, ProxyResolverV8) { - net::HostResolver host_resolver; - net::ProxyResolverV8::JSBindings* js_bindings = - net::ProxyResolverV8::CreateDefaultBindings(&host_resolver, NULL); + net::ProxyResolverV8::CreateDefaultBindings(new net::HostResolver, 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 ad4f1eb6..6bbffec 100644 --- a/net/proxy/proxy_resolver_v8.cc +++ b/net/proxy/proxy_resolver_v8.cc @@ -103,7 +103,7 @@ class SyncHostResolverBridge event_.Signal(); } - HostResolver* host_resolver_; + scoped_refptr<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 0e8ba47..7fab7d7 100644 --- a/net/proxy/proxy_resolver_v8_unittest.cc +++ b/net/proxy/proxy_resolver_v8_unittest.cc @@ -378,9 +378,8 @@ 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(&host_resolver, NULL)); + net::ProxyResolverV8::CreateDefaultBindings(new net::HostResolver, NULL)); // Considered an error. EXPECT_EQ("", bindings->DnsResolve("")); @@ -430,9 +429,8 @@ 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(&host_resolver, NULL)); + net::ProxyResolverV8::CreateDefaultBindings(new net::HostResolver, 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 5b16738b..8a7cfb5 100644 --- a/net/proxy/proxy_script_fetcher_unittest.cc +++ b/net/proxy/proxy_script_fetcher_unittest.cc @@ -41,7 +41,6 @@ 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 6280048..c642b48 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 DNS lookups for connecting + // The host resolver that will be used to do host lookups for connecting // sockets. - HostResolver* const host_resolver_; + scoped_refptr<HostResolver> 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 c6308fa..1d68bd1 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; - net::HostResolver resolver; + scoped_refptr<net::HostResolver> resolver(new net::HostResolver); 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; - net::HostResolver resolver; + scoped_refptr<net::HostResolver> resolver(new net::HostResolver); 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; - net::HostResolver resolver; + scoped_refptr<net::HostResolver> resolver(new net::HostResolver); 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; - net::HostResolver resolver; + scoped_refptr<net::HostResolver> resolver(new net::HostResolver); 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; - net::HostResolver resolver; + scoped_refptr<net::HostResolver> resolver(new net::HostResolver); 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; - net::HostResolver resolver; + scoped_refptr<net::HostResolver> resolver(new net::HostResolver); 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 f615662..101cbf5 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; - net::HostResolver resolver; + scoped_refptr<net::HostResolver> resolver(new net::HostResolver); 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 9cd62e8..5d9e630 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, - &host_resolver_, + new HostResolver, &client_socket_factory_)) {} virtual void SetUp() { @@ -242,7 +242,6 @@ 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 519d938..91b0e57 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; - HostResolver resolver; + scoped_refptr<HostResolver> resolver(new HostResolver); 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 1d94ddd..c807007 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; - net::HostResolver resolver; + scoped_refptr<net::HostResolver> resolver(new net::HostResolver); 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; - net::HostResolver resolver; + scoped_refptr<net::HostResolver> resolver(new net::HostResolver); // "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 68022f2..783c91d 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; - net::HostResolver host_resolver; + scoped_refptr<net::HostResolver> host_resolver(new net::HostResolver); 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 374af90..486ade0 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. - net::HostResolver* host_resolver_; + scoped_refptr<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 f5452be..415fb1c 100644 --- a/net/url_request/url_request_unittest.cc +++ b/net/url_request/url_request_unittest.cc @@ -59,7 +59,6 @@ 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 a4ec2fe..dcc1757 100644 --- a/net/url_request/url_request_unittest.h +++ b/net/url_request/url_request_unittest.h @@ -51,10 +51,7 @@ class TestURLRequestContext : public URLRequestContext { } explicit TestURLRequestContext(const std::string& proxy) { - // 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); + host_resolver_ = new net::HostResolver; net::ProxyConfig proxy_config; proxy_config.proxy_rules.ParseFromString(proxy); proxy_service_ = net::ProxyService::CreateFixed(proxy_config); @@ -66,7 +63,6 @@ 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 480ba9c..cd0f31a 100644 --- a/webkit/tools/test_shell/test_shell_request_context.cc +++ b/webkit/tools/test_shell/test_shell_request_context.cc @@ -73,7 +73,6 @@ TestShellRequestContext::~TestShellRequestContext() { delete ftp_transaction_factory_; delete http_transaction_factory_; delete proxy_service_; - delete host_resolver_; } const std::string& TestShellRequestContext::GetUserAgent( |