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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 72 |
73 // Overwrites or creates an entry for |key|. Returns the pointer to the | 73 // Overwrites or creates an entry for |key|. Returns the pointer to the |
74 // entry, or NULL on failure (fails if caching is disabled). | 74 // entry, or NULL on failure (fails if caching is disabled). |
75 // (|error|, |addrlist|) is the value to set, and |now| is the current | 75 // (|error|, |addrlist|) is the value to set, and |now| is the current |
76 // timestamp. | 76 // timestamp. |
77 Entry* Set(const Key& key, | 77 Entry* Set(const Key& key, |
78 int error, | 78 int error, |
79 const AddressList addrlist, | 79 const AddressList addrlist, |
80 base::TimeTicks now); | 80 base::TimeTicks now); |
81 | 81 |
| 82 // Empties the cache. |
| 83 void clear() { |
| 84 entries_.clear(); |
| 85 } |
| 86 |
82 // Returns true if this HostCache can contain no entries. | 87 // Returns true if this HostCache can contain no entries. |
83 bool caching_is_disabled() const { | 88 bool caching_is_disabled() const { |
84 return max_entries_ == 0; | 89 return max_entries_ == 0; |
85 } | 90 } |
86 | 91 |
87 // Returns the number of entries in the cache. | 92 // Returns the number of entries in the cache. |
88 size_t size() const { | 93 size_t size() const { |
89 return entries_.size(); | 94 return entries_.size(); |
90 } | 95 } |
91 | 96 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 // Map from hostname (presumably in lowercase canonicalized format) to | 132 // Map from hostname (presumably in lowercase canonicalized format) to |
128 // a resolved result entry. | 133 // a resolved result entry. |
129 EntryMap entries_; | 134 EntryMap entries_; |
130 | 135 |
131 DISALLOW_COPY_AND_ASSIGN(HostCache); | 136 DISALLOW_COPY_AND_ASSIGN(HostCache); |
132 }; | 137 }; |
133 | 138 |
134 } // namespace net | 139 } // namespace net |
135 | 140 |
136 #endif // NET_BASE_HOST_CACHE_H_ | 141 #endif // NET_BASE_HOST_CACHE_H_ |
OLD | NEW |