OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_DNS_HOST_CACHE_H_ | 5 #ifndef NET_DNS_HOST_CACHE_H_ |
6 #define NET_DNS_HOST_CACHE_H_ | 6 #define NET_DNS_HOST_CACHE_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <functional> | 10 #include <functional> |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 base::TimeTicks now, | 160 base::TimeTicks now, |
161 base::TimeDelta ttl); | 161 base::TimeDelta ttl); |
162 | 162 |
163 // Marks all entries as stale on account of a network change. | 163 // Marks all entries as stale on account of a network change. |
164 void OnNetworkChange(); | 164 void OnNetworkChange(); |
165 | 165 |
166 void set_eviction_callback(const EvictionCallback& callback) { | 166 void set_eviction_callback(const EvictionCallback& callback) { |
167 eviction_callback_ = callback; | 167 eviction_callback_ = callback; |
168 } | 168 } |
169 | 169 |
170 void set_persistence_delegate(PersistenceDelegate* delegate) { | 170 void set_persistence_delegate(PersistenceDelegate* delegate); |
171 delegate_ = delegate; | |
172 } | |
173 | 171 |
174 // Empties the cache. | 172 // Empties the cache. |
175 void clear(); | 173 void clear(); |
176 | 174 |
177 // Clears hosts matching |host_filter| from the cache. | 175 // Clears hosts matching |host_filter| from the cache. |
178 void ClearForHosts( | 176 void ClearForHosts( |
179 const base::Callback<bool(const std::string&)>& host_filter); | 177 const base::Callback<bool(const std::string&)>& host_filter); |
180 | 178 |
181 // Returns the contents of the cache represented as a base::ListValue for | 179 // Fills the provided base::ListValue with the contents of the cache for |
182 // serialization. | 180 // serialization. |entry_list| must be non-null and will be cleared before |
183 std::unique_ptr<base::ListValue> GetAsListValue(bool include_staleness) const; | 181 // adding the cache contents. |
| 182 void GetAsListValue(base::ListValue* entry_list, |
| 183 bool include_staleness) const; |
184 // Takes a base::ListValue representing cache entries and stores them in the | 184 // Takes a base::ListValue representing cache entries and stores them in the |
185 // cache, skipping any that already have entries. Returns true on success, | 185 // cache, skipping any that already have entries. Returns true on success, |
186 // false on failure. | 186 // false on failure. |
187 bool RestoreFromListValue(const base::ListValue& old_cache); | 187 bool RestoreFromListValue(const base::ListValue& old_cache); |
188 | 188 |
189 // Returns the number of entries in the cache. | 189 // Returns the number of entries in the cache. |
190 size_t size() const; | 190 size_t size() const; |
191 | 191 |
192 // Following are used by net_internals UI. | 192 // Following are used by net_internals UI. |
193 size_t max_entries() const; | 193 size_t max_entries() const; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 PersistenceDelegate* delegate_; | 236 PersistenceDelegate* delegate_; |
237 | 237 |
238 THREAD_CHECKER(thread_checker_); | 238 THREAD_CHECKER(thread_checker_); |
239 | 239 |
240 DISALLOW_COPY_AND_ASSIGN(HostCache); | 240 DISALLOW_COPY_AND_ASSIGN(HostCache); |
241 }; | 241 }; |
242 | 242 |
243 } // namespace net | 243 } // namespace net |
244 | 244 |
245 #endif // NET_DNS_HOST_CACHE_H_ | 245 #endif // NET_DNS_HOST_CACHE_H_ |
OLD | NEW |