| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <functional> |
| 9 #include <string> | 10 #include <string> |
| 10 | 11 |
| 11 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.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 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 47 if (host_resolver_flags != other.host_resolver_flags) | 48 if (host_resolver_flags != other.host_resolver_flags) |
| 48 return host_resolver_flags < other.host_resolver_flags; | 49 return host_resolver_flags < other.host_resolver_flags; |
| 49 return hostname < other.hostname; | 50 return hostname < other.hostname; |
| 50 } | 51 } |
| 51 | 52 |
| 52 std::string hostname; | 53 std::string hostname; |
| 53 AddressFamily address_family; | 54 AddressFamily address_family; |
| 54 HostResolverFlags host_resolver_flags; | 55 HostResolverFlags host_resolver_flags; |
| 55 }; | 56 }; |
| 56 | 57 |
| 57 typedef ExpiringCache<Key, Entry> EntryMap; | 58 typedef ExpiringCache<Key, Entry, base::TimeTicks, |
| 59 std::less<base::TimeTicks> > EntryMap; |
| 58 | 60 |
| 59 // Constructs a HostCache that stores up to |max_entries|. | 61 // Constructs a HostCache that stores up to |max_entries|. |
| 60 explicit HostCache(size_t max_entries); | 62 explicit HostCache(size_t max_entries); |
| 61 | 63 |
| 62 ~HostCache(); | 64 ~HostCache(); |
| 63 | 65 |
| 64 // Returns a pointer to the entry for |key|, which is valid at time | 66 // Returns a pointer to the entry for |key|, which is valid at time |
| 65 // |now|. If there is no such entry, returns NULL. | 67 // |now|. If there is no such entry, returns NULL. |
| 66 const Entry* Lookup(const Key& key, base::TimeTicks now); | 68 const Entry* Lookup(const Key& key, base::TimeTicks now); |
| 67 | 69 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // Map from hostname (presumably in lowercase canonicalized format) to | 101 // Map from hostname (presumably in lowercase canonicalized format) to |
| 100 // a resolved result entry. | 102 // a resolved result entry. |
| 101 EntryMap entries_; | 103 EntryMap entries_; |
| 102 | 104 |
| 103 DISALLOW_COPY_AND_ASSIGN(HostCache); | 105 DISALLOW_COPY_AND_ASSIGN(HostCache); |
| 104 }; | 106 }; |
| 105 | 107 |
| 106 } // namespace net | 108 } // namespace net |
| 107 | 109 |
| 108 #endif // NET_BASE_HOST_CACHE_H_ | 110 #endif // NET_BASE_HOST_CACHE_H_ |
| OLD | NEW |