| Index: net/base/host_resolver_impl_unittest.cc
|
| ===================================================================
|
| --- net/base/host_resolver_impl_unittest.cc (revision 34231)
|
| +++ net/base/host_resolver_impl_unittest.cc (working copy)
|
| @@ -30,9 +30,14 @@
|
|
|
| namespace net {
|
| namespace {
|
| -const int kMaxCacheEntries = 100;
|
| -const int kMaxCacheAgeMs = 60000;
|
|
|
| +HostCache* CreateDefaultCache() {
|
| + return new HostCache(
|
| + 100, // max cache entries.
|
| + base::TimeDelta::FromMinutes(1),
|
| + base::TimeDelta::FromSeconds(0));
|
| +}
|
| +
|
| // A variant of WaitingHostResolverProc that pushes each host mapped into a
|
| // list.
|
| // (and uses a manual-reset event rather than auto-reset).
|
| @@ -186,7 +191,7 @@
|
| resolver_proc->AddRule("just.testing", "192.168.1.42");
|
|
|
| scoped_refptr<HostResolver> host_resolver(
|
| - new HostResolverImpl(resolver_proc, kMaxCacheEntries, kMaxCacheAgeMs));
|
| + new HostResolverImpl(resolver_proc, CreateDefaultCache()));
|
|
|
| HostResolver::RequestInfo info("just.testing", kPortnum);
|
| scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
|
| @@ -218,7 +223,7 @@
|
| resolver_proc->AddRule("just.testing", "192.168.1.42");
|
|
|
| scoped_refptr<HostResolver> host_resolver(
|
| - new HostResolverImpl(resolver_proc, kMaxCacheEntries, kMaxCacheAgeMs));
|
| + new HostResolverImpl(resolver_proc, CreateDefaultCache()));
|
|
|
| HostResolver::RequestInfo info("just.testing", kPortnum);
|
| scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
|
| @@ -255,7 +260,7 @@
|
| scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
|
| {
|
| scoped_refptr<HostResolver> host_resolver(
|
| - new HostResolverImpl(resolver_proc, kMaxCacheEntries, kMaxCacheAgeMs));
|
| + new HostResolverImpl(resolver_proc, CreateDefaultCache()));
|
| AddressList adrlist;
|
| const int kPortnum = 80;
|
|
|
| @@ -290,7 +295,7 @@
|
| resolver_proc->AllowDirectLookup("*");
|
|
|
| scoped_refptr<HostResolver> host_resolver(
|
| - new HostResolverImpl(resolver_proc, kMaxCacheEntries, kMaxCacheAgeMs));
|
| + new HostResolverImpl(resolver_proc, CreateDefaultCache()));
|
| AddressList adrlist;
|
| const int kPortnum = 5555;
|
| HostResolver::RequestInfo info("127.1.2.3", kPortnum);
|
| @@ -315,7 +320,7 @@
|
| // Resolve a plain IPv6 address. Don't worry about [brackets], because
|
| // the caller should have removed them.
|
| scoped_refptr<HostResolver> host_resolver(
|
| - new HostResolverImpl(resolver_proc, kMaxCacheEntries, kMaxCacheAgeMs));
|
| + new HostResolverImpl(resolver_proc, CreateDefaultCache()));
|
| AddressList adrlist;
|
| const int kPortnum = 5555;
|
| HostResolver::RequestInfo info("2001:db8::1", kPortnum);
|
| @@ -350,7 +355,7 @@
|
| resolver_proc->AllowDirectLookup("*");
|
|
|
| scoped_refptr<HostResolver> host_resolver(
|
| - new HostResolverImpl(resolver_proc, kMaxCacheEntries, kMaxCacheAgeMs));
|
| + new HostResolverImpl(resolver_proc, CreateDefaultCache()));
|
| AddressList adrlist;
|
| const int kPortnum = 5555;
|
| HostResolver::RequestInfo info("", kPortnum);
|
| @@ -411,7 +416,7 @@
|
| new CapturingHostResolverProc(NULL);
|
|
|
| scoped_refptr<HostResolver> host_resolver(
|
| - new HostResolverImpl(resolver_proc, kMaxCacheEntries, kMaxCacheAgeMs));
|
| + new HostResolverImpl(resolver_proc, CreateDefaultCache()));
|
|
|
| // The class will receive callbacks for when each resolve completes. It
|
| // checks that the right things happened.
|
| @@ -462,7 +467,7 @@
|
| new CapturingHostResolverProc(NULL);
|
|
|
| scoped_refptr<HostResolver> host_resolver(
|
| - new HostResolverImpl(resolver_proc, kMaxCacheEntries, kMaxCacheAgeMs));
|
| + new HostResolverImpl(resolver_proc, CreateDefaultCache()));
|
|
|
| // The class will receive callbacks for when each resolve completes. It
|
| // checks that the right things happened.
|
| @@ -549,7 +554,7 @@
|
| new CapturingHostResolverProc(NULL);
|
|
|
| scoped_refptr<HostResolver> host_resolver(
|
| - new HostResolverImpl(resolver_proc, kMaxCacheEntries, kMaxCacheAgeMs));
|
| + new HostResolverImpl(resolver_proc, CreateDefaultCache()));
|
|
|
| // The class will receive callbacks for when each resolve completes. It
|
| // checks that the right things happened.
|
| @@ -610,7 +615,7 @@
|
| // checks that the right things happened. Note that the verifier holds the
|
| // only reference to |host_resolver|, so it can delete it within callback.
|
| HostResolver* host_resolver =
|
| - new HostResolverImpl(resolver_proc, kMaxCacheEntries, kMaxCacheAgeMs);
|
| + new HostResolverImpl(resolver_proc, CreateDefaultCache());
|
| DeleteWithinCallbackVerifier verifier(host_resolver);
|
|
|
| // Start 4 requests, duplicating hosts "a". Since the resolver_proc is
|
| @@ -663,7 +668,7 @@
|
|
|
| // Turn off caching for this host resolver.
|
| scoped_refptr<HostResolver> host_resolver(
|
| - new HostResolverImpl(resolver_proc, 0, 0));
|
| + new HostResolverImpl(resolver_proc, NULL));
|
|
|
| // The class will receive callbacks for when each resolve completes. It
|
| // checks that the right things happened.
|
| @@ -728,7 +733,7 @@
|
|
|
| TEST_F(HostResolverImplTest, BypassCache) {
|
| scoped_refptr<HostResolver> host_resolver(
|
| - new HostResolverImpl(NULL, kMaxCacheEntries, kMaxCacheAgeMs));
|
| + new HostResolverImpl(NULL, CreateDefaultCache()));
|
|
|
| // The class will receive callbacks for when each resolve completes. It
|
| // checks that the right things happened.
|
| @@ -812,7 +817,7 @@
|
| // synchronous.
|
| TEST_F(HostResolverImplTest, Observers) {
|
| scoped_refptr<HostResolver> host_resolver(
|
| - new HostResolverImpl(NULL, kMaxCacheEntries, kMaxCacheAgeMs));
|
| + new HostResolverImpl(NULL, CreateDefaultCache()));
|
|
|
| CapturingObserver observer;
|
|
|
| @@ -898,7 +903,7 @@
|
| {
|
| // Create a host resolver and attach an observer.
|
| scoped_refptr<HostResolver> host_resolver(
|
| - new HostResolverImpl(NULL, kMaxCacheEntries, kMaxCacheAgeMs));
|
| + new HostResolverImpl(NULL, CreateDefaultCache()));
|
| host_resolver->AddObserver(&observer);
|
|
|
| TestCompletionCallback callback;
|
|
|