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

Side by Side Diff: net/base/host_cache.h

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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/base/address_list_unittest.cc ('k') | net/base/host_cache_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_BASE_HOST_CACHE_H_ 5 #ifndef NET_BASE_HOST_CACHE_H_
6 #define NET_BASE_HOST_CACHE_H_ 6 #define NET_BASE_HOST_CACHE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/ref_counted.h" 11 #include "base/ref_counted.h"
(...skipping 18 matching lines...) Expand all
30 // The time when this entry expires. 30 // The time when this entry expires.
31 base::TimeTicks expiration; 31 base::TimeTicks expiration;
32 32
33 private: 33 private:
34 friend class base::RefCounted<Entry>; 34 friend class base::RefCounted<Entry>;
35 35
36 ~Entry(); 36 ~Entry();
37 }; 37 };
38 38
39 struct Key { 39 struct Key {
40 Key(const std::string& hostname, AddressFamily address_family, 40 Key(const std::string& hostname, AddressFamily address_family)
41 HostResolverFlags host_resolver_flags) 41 : hostname(hostname), address_family(address_family) {}
42 : hostname(hostname),
43 address_family(address_family),
44 host_resolver_flags(host_resolver_flags) {}
45 42
46 bool operator==(const Key& other) const { 43 bool operator==(const Key& other) const {
47 return (other.address_family == address_family && 44 return other.hostname == hostname &&
48 other.host_resolver_flags == host_resolver_flags && 45 other.address_family == address_family;
49 other.hostname == hostname);
50 } 46 }
51 47
52 bool operator<(const Key& other) const { 48 bool operator<(const Key& other) const {
53 if (address_family != other.address_family) 49 if (address_family == other.address_family)
54 return address_family < other.address_family; 50 return hostname < other.hostname;
55 if (host_resolver_flags != other.host_resolver_flags) 51 return address_family < other.address_family;
56 return host_resolver_flags < other.host_resolver_flags;
57 return hostname < other.hostname;
58 } 52 }
59 53
60 std::string hostname; 54 std::string hostname;
61 AddressFamily address_family; 55 AddressFamily address_family;
62 HostResolverFlags host_resolver_flags;
63 }; 56 };
64 57
65 typedef std::map<Key, scoped_refptr<Entry> > EntryMap; 58 typedef std::map<Key, scoped_refptr<Entry> > EntryMap;
66 59
67 // Constructs a HostCache that caches successful host resolves for 60 // Constructs a HostCache that caches successful host resolves for
68 // |success_entry_ttl| time, and failed host resolves for 61 // |success_entry_ttl| time, and failed host resolves for
69 // |failure_entry_ttl|. The cache will store up to |max_entries|. 62 // |failure_entry_ttl|. The cache will store up to |max_entries|.
70 HostCache(size_t max_entries, 63 HostCache(size_t max_entries,
71 base::TimeDelta success_entry_ttl, 64 base::TimeDelta success_entry_ttl,
72 base::TimeDelta failure_entry_ttl); 65 base::TimeDelta failure_entry_ttl);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 // Map from hostname (presumably in lowercase canonicalized format) to 132 // Map from hostname (presumably in lowercase canonicalized format) to
140 // a resolved result entry. 133 // a resolved result entry.
141 EntryMap entries_; 134 EntryMap entries_;
142 135
143 DISALLOW_COPY_AND_ASSIGN(HostCache); 136 DISALLOW_COPY_AND_ASSIGN(HostCache);
144 }; 137 };
145 138
146 } // namespace net 139 } // namespace net
147 140
148 #endif // NET_BASE_HOST_CACHE_H_ 141 #endif // NET_BASE_HOST_CACHE_H_
OLDNEW
« no previous file with comments | « net/base/address_list_unittest.cc ('k') | net/base/host_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698