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

Unified Diff: net/base/host_cache_unittest.cc

Issue 1629005: Revert 43826 - HostResolver now adds AI_CANONNAME to the hint flags if a requ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 8 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_cache.h ('k') | net/base/host_resolver.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/host_cache_unittest.cc
===================================================================
--- net/base/host_cache_unittest.cc (revision 43832)
+++ net/base/host_cache_unittest.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -20,7 +20,7 @@
// Builds a key for |hostname|, defaulting the address family to unspecified.
HostCache::Key Key(const std::string& hostname) {
- return HostCache::Key(hostname, ADDRESS_FAMILY_UNSPECIFIED, 0);
+ return HostCache::Key(hostname, ADDRESS_FAMILY_UNSPECIFIED);
}
} // namespace
@@ -276,8 +276,8 @@
// t=0.
base::TimeTicks now;
- HostCache::Key key1("foobar.com", ADDRESS_FAMILY_UNSPECIFIED, 0);
- HostCache::Key key2("foobar.com", ADDRESS_FAMILY_IPV4, 0);
+ HostCache::Key key1("foobar.com", ADDRESS_FAMILY_UNSPECIFIED);
+ HostCache::Key key2("foobar.com", ADDRESS_FAMILY_IPV4);
const HostCache::Entry* entry1 = NULL; // Entry for key1
const HostCache::Entry* entry2 = NULL; // Entry for key2
@@ -303,42 +303,6 @@
EXPECT_NE(entry1, entry2);
}
-// Tests that the same hostname can be duplicated in the cache, so long as
-// the HostResolverFlags differ.
-TEST(HostCacheTest, HostResolverFlagsArePartOfKey) {
- HostCache cache(kMaxCacheEntries, kSuccessEntryTTL, kFailureEntryTTL);
-
- // t=0.
- base::TimeTicks now;
-
- HostCache::Key key1("foobar.com", ADDRESS_FAMILY_IPV4, 0);
- HostCache::Key key2("foobar.com", ADDRESS_FAMILY_IPV4,
- HOST_RESOLVER_FLAGS_CANONNAME);
-
- const HostCache::Entry* entry1 = NULL; // Entry for key1
- const HostCache::Entry* entry2 = NULL; // Entry for key2
-
- EXPECT_EQ(0U, cache.size());
-
- // Add an entry for ("foobar.com", IPV4, NONE) at t=0.
- EXPECT_TRUE(cache.Lookup(key1, base::TimeTicks()) == NULL);
- cache.Set(key1, OK, AddressList(), now);
- entry1 = cache.Lookup(key1, base::TimeTicks());
- EXPECT_FALSE(entry1 == NULL);
- EXPECT_EQ(1U, cache.size());
-
- // Add an entry for ("foobar.com", IPV4, CANONNAME) at t=0.
- EXPECT_TRUE(cache.Lookup(key2, base::TimeTicks()) == NULL);
- cache.Set(key2, OK, AddressList(), now);
- entry2 = cache.Lookup(key2, base::TimeTicks());
- EXPECT_FALSE(entry2 == NULL);
- EXPECT_EQ(2U, cache.size());
-
- // Even though the hostnames were the same, we should have two unique
- // entries (because the HostResolverFlags differ).
- EXPECT_NE(entry1, entry2);
-}
-
TEST(HostCacheTest, NoCache) {
// Disable caching.
HostCache cache(0, kSuccessEntryTTL, kFailureEntryTTL);
@@ -389,54 +353,35 @@
int expected_comparison;
} tests[] = {
{
- HostCache::Key("host1", ADDRESS_FAMILY_UNSPECIFIED, 0),
- HostCache::Key("host1", ADDRESS_FAMILY_UNSPECIFIED, 0),
+ HostCache::Key("host1", ADDRESS_FAMILY_UNSPECIFIED),
+ HostCache::Key("host1", ADDRESS_FAMILY_UNSPECIFIED),
0
},
{
- HostCache::Key("host1", ADDRESS_FAMILY_IPV4, 0),
- HostCache::Key("host1", ADDRESS_FAMILY_UNSPECIFIED, 0),
+ HostCache::Key("host1", ADDRESS_FAMILY_IPV4),
+ HostCache::Key("host1", ADDRESS_FAMILY_UNSPECIFIED),
1
},
{
- HostCache::Key("host1", ADDRESS_FAMILY_UNSPECIFIED, 0),
- HostCache::Key("host1", ADDRESS_FAMILY_IPV4, 0),
+ HostCache::Key("host1", ADDRESS_FAMILY_UNSPECIFIED),
+ HostCache::Key("host1", ADDRESS_FAMILY_IPV4),
-1
},
{
- HostCache::Key("host1", ADDRESS_FAMILY_UNSPECIFIED, 0),
- HostCache::Key("host2", ADDRESS_FAMILY_UNSPECIFIED, 0),
+ HostCache::Key("host1", ADDRESS_FAMILY_UNSPECIFIED),
+ HostCache::Key("host2", ADDRESS_FAMILY_UNSPECIFIED),
-1
},
{
- HostCache::Key("host1", ADDRESS_FAMILY_IPV4, 0),
- HostCache::Key("host2", ADDRESS_FAMILY_UNSPECIFIED, 0),
+ HostCache::Key("host1", ADDRESS_FAMILY_IPV4),
+ HostCache::Key("host2", ADDRESS_FAMILY_UNSPECIFIED),
1
},
{
- HostCache::Key("host1", ADDRESS_FAMILY_UNSPECIFIED, 0),
- HostCache::Key("host2", ADDRESS_FAMILY_IPV4, 0),
+ HostCache::Key("host1", ADDRESS_FAMILY_UNSPECIFIED),
+ HostCache::Key("host2", ADDRESS_FAMILY_IPV4),
-1
},
- {
- HostCache::Key("host1", ADDRESS_FAMILY_UNSPECIFIED, 0),
- HostCache::Key("host1", ADDRESS_FAMILY_UNSPECIFIED,
- HOST_RESOLVER_FLAGS_CANONNAME),
- -1
- },
- {
- HostCache::Key("host1", ADDRESS_FAMILY_UNSPECIFIED,
- HOST_RESOLVER_FLAGS_CANONNAME),
- HostCache::Key("host1", ADDRESS_FAMILY_UNSPECIFIED, 0),
- 1
- },
- {
- HostCache::Key("host1", ADDRESS_FAMILY_UNSPECIFIED,
- HOST_RESOLVER_FLAGS_CANONNAME),
- HostCache::Key("host2", ADDRESS_FAMILY_UNSPECIFIED,
- HOST_RESOLVER_FLAGS_CANONNAME),
- -1
- },
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
« no previous file with comments | « net/base/host_cache.h ('k') | net/base/host_resolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698