Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(257)

Unified Diff: net/base/host_resolver_impl_unittest.cc

Issue 3119027: Adds HostResolveImpl Requests and Jobs to log. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/host_resolver_impl.cc ('k') | net/base/mock_host_resolver.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/host_resolver_impl_unittest.cc
===================================================================
--- net/base/host_resolver_impl_unittest.cc (revision 57182)
+++ net/base/host_resolver_impl_unittest.cc (working copy)
@@ -38,7 +38,8 @@
static const size_t kMaxJobs = 10u;
HostResolverImpl* CreateHostResolverImpl(HostResolverProc* resolver_proc) {
- return new HostResolverImpl(resolver_proc, CreateDefaultCache(), kMaxJobs);
+ return new HostResolverImpl(resolver_proc, CreateDefaultCache(), kMaxJobs,
+ NULL);
}
// Helper to create a HostResolver::RequestInfo.
@@ -329,10 +330,14 @@
scoped_refptr<WaitingHostResolverProc> resolver_proc =
new WaitingHostResolverProc(NULL);
+ CapturingNetLog net_log(CapturingNetLog::kUnbounded);
CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
{
scoped_refptr<HostResolver> host_resolver(
- CreateHostResolverImpl(resolver_proc));
+ new HostResolverImpl(resolver_proc,
+ CreateDefaultCache(),
+ kMaxJobs,
+ &net_log));
AddressList adrlist;
const int kPortnum = 80;
@@ -350,14 +355,34 @@
resolver_proc->Signal();
- EXPECT_EQ(3u, log.entries().size());
+ EXPECT_EQ(2u, log.entries().size());
EXPECT_TRUE(LogContainsBeginEvent(
log.entries(), 0, NetLog::TYPE_HOST_RESOLVER_IMPL));
- EXPECT_TRUE(LogContainsEvent(
- log.entries(), 1, NetLog::TYPE_CANCELLED, NetLog::PHASE_NONE));
EXPECT_TRUE(LogContainsEndEvent(
- log.entries(), 2, NetLog::TYPE_HOST_RESOLVER_IMPL));
+ log.entries(), 1, NetLog::TYPE_HOST_RESOLVER_IMPL));
+ int pos = net::ExpectLogContainsSomewhereAfter(net_log.entries(), 0,
+ net::NetLog::TYPE_HOST_RESOLVER_IMPL_REQUEST,
+ net::NetLog::PHASE_BEGIN);
+ pos = net::ExpectLogContainsSomewhereAfter(net_log.entries(), pos + 1,
+ net::NetLog::TYPE_HOST_RESOLVER_IMPL_JOB,
+ net::NetLog::PHASE_BEGIN);
+ // Both Job and Request need to be cancelled.
+ pos = net::ExpectLogContainsSomewhereAfter(net_log.entries(), pos + 1,
+ net::NetLog::TYPE_CANCELLED,
+ net::NetLog::PHASE_NONE);
+ // Don't care about order in which they end, or when the other one is
+ // cancelled.
+ net::ExpectLogContainsSomewhereAfter(net_log.entries(), pos + 1,
+ net::NetLog::TYPE_CANCELLED,
+ net::NetLog::PHASE_NONE);
+ net::ExpectLogContainsSomewhereAfter(net_log.entries(), pos + 1,
+ net::NetLog::TYPE_HOST_RESOLVER_IMPL_REQUEST,
+ net::NetLog::PHASE_END);
+ net::ExpectLogContainsSomewhereAfter(net_log.entries(), pos + 1,
+ net::NetLog::TYPE_HOST_RESOLVER_IMPL_JOB,
+ net::NetLog::PHASE_END);
+
EXPECT_FALSE(callback_called_);
}
@@ -753,7 +778,7 @@
// Turn off caching for this host resolver.
scoped_refptr<HostResolver> host_resolver(
- new HostResolverImpl(resolver_proc, NULL, kMaxJobs));
+ new HostResolverImpl(resolver_proc, NULL, kMaxJobs, NULL));
// The class will receive callbacks for when each resolve completes. It
// checks that the right things happened.
@@ -1050,7 +1075,7 @@
// Test that IP address changes flush the cache.
TEST_F(HostResolverImplTest, FlushCacheOnIPAddressChange) {
scoped_refptr<HostResolver> host_resolver(
- new HostResolverImpl(NULL, CreateDefaultCache(), kMaxJobs));
+ new HostResolverImpl(NULL, CreateDefaultCache(), kMaxJobs, NULL));
AddressList addrlist;
@@ -1087,7 +1112,8 @@
// This HostResolverImpl will only allow 1 outstanding resolve at a time.
size_t kMaxJobs = 1u;
scoped_refptr<HostResolver> host_resolver(
- new HostResolverImpl(resolver_proc, CreateDefaultCache(), kMaxJobs));
+ new HostResolverImpl(resolver_proc, CreateDefaultCache(), kMaxJobs,
+ NULL));
CapturingObserver observer;
host_resolver->AddObserver(&observer);
@@ -1171,7 +1197,8 @@
// This HostResolverImpl will only allow 1 outstanding resolve at a time.
const size_t kMaxJobs = 1u;
scoped_refptr<HostResolver> host_resolver(
- new HostResolverImpl(resolver_proc, CreateDefaultCache(), kMaxJobs));
+ new HostResolverImpl(resolver_proc, CreateDefaultCache(), kMaxJobs,
+ NULL));
// Note that at this point the CapturingHostResolverProc is blocked, so any
// requests we make will not complete.
@@ -1233,7 +1260,7 @@
// This HostResolverImpl will only allow 1 outstanding resolve at a time.
const size_t kMaxOutstandingJobs = 1u;
scoped_refptr<HostResolverImpl> host_resolver(new HostResolverImpl(
- resolver_proc, CreateDefaultCache(), kMaxOutstandingJobs));
+ resolver_proc, CreateDefaultCache(), kMaxOutstandingJobs, NULL));
// Only allow up to 3 requests to be enqueued at a time.
const size_t kMaxPendingRequests = 3u;
@@ -1311,7 +1338,7 @@
// This HostResolverImpl will only allow 1 outstanding resolve at a time.
const size_t kMaxOutstandingJobs = 1u;
scoped_refptr<HostResolverImpl> host_resolver(new HostResolverImpl(
- resolver_proc, CreateDefaultCache(), kMaxOutstandingJobs));
+ resolver_proc, CreateDefaultCache(), kMaxOutstandingJobs, NULL));
host_resolver->SetDefaultAddressFamily(ADDRESS_FAMILY_IPV4);
@@ -1379,7 +1406,7 @@
// This HostResolverImpl will only allow 1 outstanding resolve at a time.
const size_t kMaxOutstandingJobs = 1u;
scoped_refptr<HostResolverImpl> host_resolver(new HostResolverImpl(
- resolver_proc, CreateDefaultCache(), kMaxOutstandingJobs));
+ resolver_proc, CreateDefaultCache(), kMaxOutstandingJobs, NULL));
host_resolver->SetDefaultAddressFamily(ADDRESS_FAMILY_IPV6);
@@ -1445,7 +1472,7 @@
const size_t kMaxOutstandingJobs = 10u;
scoped_refptr<HostResolverImpl> host_resolver(new HostResolverImpl(
- resolver_proc, CreateDefaultCache(), kMaxOutstandingJobs));
+ resolver_proc, CreateDefaultCache(), kMaxOutstandingJobs, NULL));
host_resolver->SetDefaultAddressFamily(ADDRESS_FAMILY_IPV4);
« no previous file with comments | « net/base/host_resolver_impl.cc ('k') | net/base/mock_host_resolver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698