OLD | NEW |
1 // Copyright (c) 2009 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 |
(...skipping 24 matching lines...) Expand all Loading... |
35 struct Key { | 35 struct Key { |
36 Key(const std::string& hostname, AddressFamily address_family) | 36 Key(const std::string& hostname, AddressFamily address_family) |
37 : hostname(hostname), address_family(address_family) {} | 37 : hostname(hostname), address_family(address_family) {} |
38 | 38 |
39 bool operator==(const Key& other) const { | 39 bool operator==(const Key& other) const { |
40 return other.hostname == hostname && | 40 return other.hostname == hostname && |
41 other.address_family == address_family; | 41 other.address_family == address_family; |
42 } | 42 } |
43 | 43 |
44 bool operator<(const Key& other) const { | 44 bool operator<(const Key& other) const { |
45 if (address_family < other.address_family) | 45 if (address_family == other.address_family) |
46 return true; | 46 return hostname < other.hostname; |
47 return hostname < other.hostname; | 47 return address_family < other.address_family; |
48 } | 48 } |
49 | 49 |
50 std::string hostname; | 50 std::string hostname; |
51 AddressFamily address_family; | 51 AddressFamily address_family; |
52 }; | 52 }; |
53 | 53 |
54 typedef std::map<Key, scoped_refptr<Entry> > EntryMap; | 54 typedef std::map<Key, scoped_refptr<Entry> > EntryMap; |
55 | 55 |
56 // Constructs a HostCache whose entries are valid for |cache_duration_ms| | 56 // Constructs a HostCache whose entries are valid for |cache_duration_ms| |
57 // milliseconds. The cache will store up to |max_entries|. | 57 // milliseconds. The cache will store up to |max_entries|. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 // Map from hostname (presumably in lowercase canonicalized format) to | 115 // Map from hostname (presumably in lowercase canonicalized format) to |
116 // a resolved result entry. | 116 // a resolved result entry. |
117 EntryMap entries_; | 117 EntryMap entries_; |
118 | 118 |
119 DISALLOW_COPY_AND_ASSIGN(HostCache); | 119 DISALLOW_COPY_AND_ASSIGN(HostCache); |
120 }; | 120 }; |
121 | 121 |
122 } // namespace net | 122 } // namespace net |
123 | 123 |
124 #endif // NET_BASE_HOST_CACHE_H_ | 124 #endif // NET_BASE_HOST_CACHE_H_ |
OLD | NEW |