| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 Entry(int error, const AddressList& addresses); | 72 Entry(int error, const AddressList& addresses); |
| 73 ~Entry(); | 73 ~Entry(); |
| 74 | 74 |
| 75 int error() const { return error_; } | 75 int error() const { return error_; } |
| 76 const AddressList& addresses() const { return addresses_; } | 76 const AddressList& addresses() const { return addresses_; } |
| 77 bool has_ttl() const { return ttl_ >= base::TimeDelta(); } | 77 bool has_ttl() const { return ttl_ >= base::TimeDelta(); } |
| 78 base::TimeDelta ttl() const { return ttl_; } | 78 base::TimeDelta ttl() const { return ttl_; } |
| 79 | 79 |
| 80 base::TimeTicks expires() const { return expires_; } | 80 base::TimeTicks expires() const { return expires_; } |
| 81 | 81 |
| 82 // Public for the net-internals UI. |
| 83 int network_changes() const { return network_changes_; } |
| 84 |
| 82 private: | 85 private: |
| 83 friend class HostCache; | 86 friend class HostCache; |
| 84 | 87 |
| 85 Entry(const Entry& entry, | 88 Entry(const Entry& entry, |
| 86 base::TimeTicks now, | 89 base::TimeTicks now, |
| 87 base::TimeDelta ttl, | 90 base::TimeDelta ttl, |
| 88 int network_changes); | 91 int network_changes); |
| 89 | 92 |
| 90 int network_changes() const { return network_changes_; } | |
| 91 int total_hits() const { return total_hits_; } | 93 int total_hits() const { return total_hits_; } |
| 92 int stale_hits() const { return stale_hits_; } | 94 int stale_hits() const { return stale_hits_; } |
| 93 | 95 |
| 94 bool IsStale(base::TimeTicks now, int network_changes) const; | 96 bool IsStale(base::TimeTicks now, int network_changes) const; |
| 95 void CountHit(bool hit_is_stale); | 97 void CountHit(bool hit_is_stale); |
| 96 void GetStaleness(base::TimeTicks now, | 98 void GetStaleness(base::TimeTicks now, |
| 97 int network_changes, | 99 int network_changes, |
| 98 EntryStaleness* out) const; | 100 EntryStaleness* out) const; |
| 99 | 101 |
| 100 // The resolve results for this entry. | 102 // The resolve results for this entry. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 153 |
| 152 // Clears hosts matching |host_filter| from the cache. | 154 // Clears hosts matching |host_filter| from the cache. |
| 153 void ClearForHosts( | 155 void ClearForHosts( |
| 154 const base::Callback<bool(const std::string&)>& host_filter); | 156 const base::Callback<bool(const std::string&)>& host_filter); |
| 155 | 157 |
| 156 // Returns the number of entries in the cache. | 158 // Returns the number of entries in the cache. |
| 157 size_t size() const; | 159 size_t size() const; |
| 158 | 160 |
| 159 // Following are used by net_internals UI. | 161 // Following are used by net_internals UI. |
| 160 size_t max_entries() const; | 162 size_t max_entries() const; |
| 161 | 163 int network_changes() const { return network_changes_; } |
| 162 const EntryMap& entries() const { return entries_; } | 164 const EntryMap& entries() const { return entries_; } |
| 163 | 165 |
| 164 // Creates a default cache. | 166 // Creates a default cache. |
| 165 static std::unique_ptr<HostCache> CreateDefaultCache(); | 167 static std::unique_ptr<HostCache> CreateDefaultCache(); |
| 166 | 168 |
| 167 private: | 169 private: |
| 168 FRIEND_TEST_ALL_PREFIXES(HostCacheTest, NoCache); | 170 FRIEND_TEST_ALL_PREFIXES(HostCacheTest, NoCache); |
| 169 | 171 |
| 170 enum SetOutcome : int; | 172 enum SetOutcome : int; |
| 171 enum LookupOutcome : int; | 173 enum LookupOutcome : int; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 196 size_t max_entries_; | 198 size_t max_entries_; |
| 197 int network_changes_; | 199 int network_changes_; |
| 198 EvictionCallback eviction_callback_; | 200 EvictionCallback eviction_callback_; |
| 199 | 201 |
| 200 DISALLOW_COPY_AND_ASSIGN(HostCache); | 202 DISALLOW_COPY_AND_ASSIGN(HostCache); |
| 201 }; | 203 }; |
| 202 | 204 |
| 203 } // namespace net | 205 } // namespace net |
| 204 | 206 |
| 205 #endif // NET_DNS_HOST_CACHE_H_ | 207 #endif // NET_DNS_HOST_CACHE_H_ |
| OLD | NEW |