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

Unified Diff: net/base/host_cache.h

Issue 1593015: HostResolver supports optional CNAME lookups. (Closed)
Patch Set: Addressing wtc's nits. 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
Index: net/base/host_cache.h
diff --git a/net/base/host_cache.h b/net/base/host_cache.h
index c13c6a0ee35f2dbc724e789c8498cea180986c52..94022e4ac57eb6e83543c92786aad9c9fb29ce8e 100644
--- a/net/base/host_cache.h
+++ b/net/base/host_cache.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -37,22 +37,35 @@ class HostCache {
};
struct Key {
- Key(const std::string& hostname, AddressFamily address_family)
- : hostname(hostname), address_family(address_family) {}
+ Key(const std::string& hostname, AddressFamily address_family,
+ HostResolverFlags host_resolver_flags)
+ : hostname(hostname),
+ address_family(address_family),
+ host_resolver_flags(host_resolver_flags) {}
bool operator==(const Key& other) const {
- return other.hostname == hostname &&
- other.address_family == address_family;
+ // |address_family| and |host_resolver_flags| are compared before
+ // |hostname| under assumption that integer comparisons are faster than
+ // string comparisons.
+ return (other.address_family == address_family &&
+ other.host_resolver_flags == host_resolver_flags &&
+ other.hostname == hostname);
}
bool operator<(const Key& other) const {
- if (address_family == other.address_family)
- return hostname < other.hostname;
- return address_family < other.address_family;
+ // |address_family| and |host_resolver_flags| are compared before
+ // |hostname| under assumption that integer comparisons are faster than
+ // string comparisons.
+ if (address_family != other.address_family)
+ return address_family < other.address_family;
+ if (host_resolver_flags != other.host_resolver_flags)
+ return host_resolver_flags < other.host_resolver_flags;
+ return hostname < other.hostname;
}
std::string hostname;
AddressFamily address_family;
+ HostResolverFlags host_resolver_flags;
};
typedef std::map<Key, scoped_refptr<Entry> > EntryMap;

Powered by Google App Engine
This is Rietveld 408576698