| 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> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <tuple> | 13 #include <tuple> |
| 14 | 14 |
| 15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/threading/non_thread_safe.h" | 17 #include "base/threading/thread_checker.h" |
| 18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 19 #include "net/base/address_family.h" | 19 #include "net/base/address_family.h" |
| 20 #include "net/base/address_list.h" | 20 #include "net/base/address_list.h" |
| 21 #include "net/base/expiring_cache.h" | 21 #include "net/base/expiring_cache.h" |
| 22 #include "net/base/net_export.h" | 22 #include "net/base/net_export.h" |
| 23 #include "net/dns/dns_util.h" | 23 #include "net/dns/dns_util.h" |
| 24 | 24 |
| 25 namespace net { | 25 namespace net { |
| 26 | 26 |
| 27 // Cache used by HostResolver to map hostnames to their resolved result. | 27 // Cache used by HostResolver to map hostnames to their resolved result. |
| 28 class NET_EXPORT HostCache : NON_EXPORTED_BASE(public base::NonThreadSafe) { | 28 class NET_EXPORT HostCache { |
| 29 public: | 29 public: |
| 30 struct Key { | 30 struct Key { |
| 31 Key(const std::string& hostname, AddressFamily address_family, | 31 Key(const std::string& hostname, AddressFamily address_family, |
| 32 HostResolverFlags host_resolver_flags) | 32 HostResolverFlags host_resolver_flags) |
| 33 : hostname(hostname), | 33 : hostname(hostname), |
| 34 address_family(address_family), | 34 address_family(address_family), |
| 35 host_resolver_flags(host_resolver_flags) {} | 35 host_resolver_flags(host_resolver_flags) {} |
| 36 | 36 |
| 37 bool operator<(const Key& other) const { | 37 bool operator<(const Key& other) const { |
| 38 // The order of comparisons of |Key| fields is arbitrary, thus | 38 // The order of comparisons of |Key| fields is arbitrary, thus |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 | 192 |
| 193 void EvictOneEntry(base::TimeTicks now); | 193 void EvictOneEntry(base::TimeTicks now); |
| 194 | 194 |
| 195 // Map from hostname (presumably in lowercase canonicalized format) to | 195 // Map from hostname (presumably in lowercase canonicalized format) to |
| 196 // a resolved result entry. | 196 // a resolved result entry. |
| 197 EntryMap entries_; | 197 EntryMap entries_; |
| 198 size_t max_entries_; | 198 size_t max_entries_; |
| 199 int network_changes_; | 199 int network_changes_; |
| 200 EvictionCallback eviction_callback_; | 200 EvictionCallback eviction_callback_; |
| 201 | 201 |
| 202 THREAD_CHECKER(thread_checker_); |
| 203 |
| 202 DISALLOW_COPY_AND_ASSIGN(HostCache); | 204 DISALLOW_COPY_AND_ASSIGN(HostCache); |
| 203 }; | 205 }; |
| 204 | 206 |
| 205 } // namespace net | 207 } // namespace net |
| 206 | 208 |
| 207 #endif // NET_DNS_HOST_CACHE_H_ | 209 #endif // NET_DNS_HOST_CACHE_H_ |
| OLD | NEW |