| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 // Following are used by net_internals UI. | 104 // Following are used by net_internals UI. |
| 105 size_t max_entries() const; | 105 size_t max_entries() const; |
| 106 | 106 |
| 107 base::TimeDelta success_entry_ttl() const; | 107 base::TimeDelta success_entry_ttl() const; |
| 108 | 108 |
| 109 base::TimeDelta failure_entry_ttl() const; | 109 base::TimeDelta failure_entry_ttl() const; |
| 110 | 110 |
| 111 // Note that this map may contain expired entries. | 111 // Note that this map may contain expired entries. |
| 112 const EntryMap& entries() const; | 112 const EntryMap& entries() const; |
| 113 | 113 |
| 114 // Creates a default cache. |
| 115 static HostCache* CreateDefaultCache(); |
| 116 |
| 114 private: | 117 private: |
| 115 FRIEND_TEST_ALL_PREFIXES(HostCacheTest, Compact); | 118 FRIEND_TEST_ALL_PREFIXES(HostCacheTest, Compact); |
| 116 FRIEND_TEST_ALL_PREFIXES(HostCacheTest, NoCache); | 119 FRIEND_TEST_ALL_PREFIXES(HostCacheTest, NoCache); |
| 117 | 120 |
| 118 // Returns true if this cache entry's result is valid at time |now|. | 121 // Returns true if this cache entry's result is valid at time |now|. |
| 119 static bool CanUseEntry(const Entry* entry, const base::TimeTicks now); | 122 static bool CanUseEntry(const Entry* entry, const base::TimeTicks now); |
| 120 | 123 |
| 121 // Prunes entries from the cache to bring it below max entry bound. Entries | 124 // Prunes entries from the cache to bring it below max entry bound. Entries |
| 122 // matching |pinned_entry| will NOT be pruned. | 125 // matching |pinned_entry| will NOT be pruned. |
| 123 void Compact(base::TimeTicks now, const Entry* pinned_entry); | 126 void Compact(base::TimeTicks now, const Entry* pinned_entry); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 137 // Map from hostname (presumably in lowercase canonicalized format) to | 140 // Map from hostname (presumably in lowercase canonicalized format) to |
| 138 // a resolved result entry. | 141 // a resolved result entry. |
| 139 EntryMap entries_; | 142 EntryMap entries_; |
| 140 | 143 |
| 141 DISALLOW_COPY_AND_ASSIGN(HostCache); | 144 DISALLOW_COPY_AND_ASSIGN(HostCache); |
| 142 }; | 145 }; |
| 143 | 146 |
| 144 } // namespace net | 147 } // namespace net |
| 145 | 148 |
| 146 #endif // NET_BASE_HOST_CACHE_H_ | 149 #endif // NET_BASE_HOST_CACHE_H_ |
| OLD | NEW |