OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 Loading... |
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 : hostname(hostname), address_family(address_family) {} | 41 HostResolverFlags host_resolver_flags) |
| 42 : hostname(hostname), |
| 43 address_family(address_family), |
| 44 host_resolver_flags(host_resolver_flags) {} |
42 | 45 |
43 bool operator==(const Key& other) const { | 46 bool operator==(const Key& other) const { |
44 return other.hostname == hostname && | 47 return (other.address_family == address_family && |
45 other.address_family == address_family; | 48 other.host_resolver_flags == host_resolver_flags && |
| 49 other.hostname == hostname); |
46 } | 50 } |
47 | 51 |
48 bool operator<(const Key& other) const { | 52 bool operator<(const Key& other) const { |
49 if (address_family == other.address_family) | 53 if (address_family != other.address_family) |
50 return hostname < other.hostname; | 54 return address_family < other.address_family; |
51 return address_family < other.address_family; | 55 if (host_resolver_flags != other.host_resolver_flags) |
| 56 return host_resolver_flags < other.host_resolver_flags; |
| 57 return hostname < other.hostname; |
52 } | 58 } |
53 | 59 |
54 std::string hostname; | 60 std::string hostname; |
55 AddressFamily address_family; | 61 AddressFamily address_family; |
| 62 HostResolverFlags host_resolver_flags; |
56 }; | 63 }; |
57 | 64 |
58 typedef std::map<Key, scoped_refptr<Entry> > EntryMap; | 65 typedef std::map<Key, scoped_refptr<Entry> > EntryMap; |
59 | 66 |
60 // Constructs a HostCache that caches successful host resolves for | 67 // Constructs a HostCache that caches successful host resolves for |
61 // |success_entry_ttl| time, and failed host resolves for | 68 // |success_entry_ttl| time, and failed host resolves for |
62 // |failure_entry_ttl|. The cache will store up to |max_entries|. | 69 // |failure_entry_ttl|. The cache will store up to |max_entries|. |
63 HostCache(size_t max_entries, | 70 HostCache(size_t max_entries, |
64 base::TimeDelta success_entry_ttl, | 71 base::TimeDelta success_entry_ttl, |
65 base::TimeDelta failure_entry_ttl); | 72 base::TimeDelta failure_entry_ttl); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 // Map from hostname (presumably in lowercase canonicalized format) to | 139 // Map from hostname (presumably in lowercase canonicalized format) to |
133 // a resolved result entry. | 140 // a resolved result entry. |
134 EntryMap entries_; | 141 EntryMap entries_; |
135 | 142 |
136 DISALLOW_COPY_AND_ASSIGN(HostCache); | 143 DISALLOW_COPY_AND_ASSIGN(HostCache); |
137 }; | 144 }; |
138 | 145 |
139 } // namespace net | 146 } // namespace net |
140 | 147 |
141 #endif // NET_BASE_HOST_CACHE_H_ | 148 #endif // NET_BASE_HOST_CACHE_H_ |
OLD | NEW |