| 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_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 <functional> | 8 #include <functional> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/threading/non_thread_safe.h" | 13 #include "base/threading/non_thread_safe.h" |
| 13 #include "base/time.h" | 14 #include "base/time.h" |
| 14 #include "net/base/address_family.h" | 15 #include "net/base/address_family.h" |
| 15 #include "net/base/address_list.h" | 16 #include "net/base/address_list.h" |
| 16 #include "net/base/expiring_cache.h" | 17 #include "net/base/expiring_cache.h" |
| 17 #include "net/base/net_export.h" | 18 #include "net/base/net_export.h" |
| 18 | 19 |
| 19 namespace net { | 20 namespace net { |
| 20 | 21 |
| 21 // Cache used by HostResolver to map hostnames to their resolved result. | 22 // Cache used by HostResolver to map hostnames to their resolved result. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 | 81 |
| 81 // Returns the number of entries in the cache. | 82 // Returns the number of entries in the cache. |
| 82 size_t size() const; | 83 size_t size() const; |
| 83 | 84 |
| 84 // Following are used by net_internals UI. | 85 // Following are used by net_internals UI. |
| 85 size_t max_entries() const; | 86 size_t max_entries() const; |
| 86 | 87 |
| 87 const EntryMap& entries() const; | 88 const EntryMap& entries() const; |
| 88 | 89 |
| 89 // Creates a default cache. | 90 // Creates a default cache. |
| 90 static HostCache* CreateDefaultCache(); | 91 static scoped_ptr<HostCache> CreateDefaultCache(); |
| 91 | 92 |
| 92 private: | 93 private: |
| 93 FRIEND_TEST_ALL_PREFIXES(HostCacheTest, NoCache); | 94 FRIEND_TEST_ALL_PREFIXES(HostCacheTest, NoCache); |
| 94 | 95 |
| 95 // Returns true if this HostCache can contain no entries. | 96 // Returns true if this HostCache can contain no entries. |
| 96 bool caching_is_disabled() const { | 97 bool caching_is_disabled() const { |
| 97 return entries_.max_entries() == 0; | 98 return entries_.max_entries() == 0; |
| 98 } | 99 } |
| 99 | 100 |
| 100 // Map from hostname (presumably in lowercase canonicalized format) to | 101 // Map from hostname (presumably in lowercase canonicalized format) to |
| 101 // a resolved result entry. | 102 // a resolved result entry. |
| 102 EntryMap entries_; | 103 EntryMap entries_; |
| 103 | 104 |
| 104 DISALLOW_COPY_AND_ASSIGN(HostCache); | 105 DISALLOW_COPY_AND_ASSIGN(HostCache); |
| 105 }; | 106 }; |
| 106 | 107 |
| 107 } // namespace net | 108 } // namespace net |
| 108 | 109 |
| 109 #endif // NET_BASE_HOST_CACHE_H_ | 110 #endif // NET_BASE_HOST_CACHE_H_ |
| OLD | NEW |