| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_SSL_SSL_CLIENT_SESSION_CACHE_OPENSSL_H | 5 #ifndef NET_SSL_SSL_CLIENT_SESSION_CACHE_OPENSSL_H |
| 6 #define NET_SSL_SSL_CLIENT_SESSION_CACHE_OPENSSL_H | 6 #define NET_SSL_SSL_CLIENT_SESSION_CACHE_OPENSSL_H |
| 7 | 7 |
| 8 #include <openssl/ssl.h> | 8 #include <openssl/ssl.h> |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 | 10 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 struct CacheEntry { | 59 struct CacheEntry { |
| 60 CacheEntry(); | 60 CacheEntry(); |
| 61 ~CacheEntry(); | 61 ~CacheEntry(); |
| 62 | 62 |
| 63 ScopedSSL_SESSION session; | 63 ScopedSSL_SESSION session; |
| 64 // The time at which this entry was created. | 64 // The time at which this entry was created. |
| 65 base::Time creation_time; | 65 base::Time creation_time; |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 using CacheEntryMap = | 68 using CacheEntryMap = |
| 69 base::MRUCacheBase<std::string, | 69 base::HashingMRUCache<std::string, scoped_ptr<CacheEntry>>; |
| 70 CacheEntry*, | |
| 71 std::hash<std::string>, | |
| 72 base::MRUCachePointerDeletor<CacheEntry*>, | |
| 73 base::MRUCacheHashMap>; | |
| 74 | 70 |
| 75 // Returns true if |entry| is expired as of |now|. | 71 // Returns true if |entry| is expired as of |now|. |
| 76 bool IsExpired(CacheEntry* entry, const base::Time& now); | 72 bool IsExpired(CacheEntry* entry, const base::Time& now); |
| 77 | 73 |
| 78 // Removes all expired sessions from the cache. | 74 // Removes all expired sessions from the cache. |
| 79 void FlushExpiredSessions(); | 75 void FlushExpiredSessions(); |
| 80 | 76 |
| 81 scoped_ptr<base::Clock> clock_; | 77 scoped_ptr<base::Clock> clock_; |
| 82 Config config_; | 78 Config config_; |
| 83 CacheEntryMap cache_; | 79 CacheEntryMap cache_; |
| 84 size_t lookups_since_flush_; | 80 size_t lookups_since_flush_; |
| 85 | 81 |
| 86 // TODO(davidben): After https://crbug.com/458365 is fixed, replace this with | 82 // TODO(davidben): After https://crbug.com/458365 is fixed, replace this with |
| 87 // a ThreadChecker. The session cache should be single-threaded like other | 83 // a ThreadChecker. The session cache should be single-threaded like other |
| 88 // classes in net. | 84 // classes in net. |
| 89 base::Lock lock_; | 85 base::Lock lock_; |
| 90 | 86 |
| 91 DISALLOW_COPY_AND_ASSIGN(SSLClientSessionCacheOpenSSL); | 87 DISALLOW_COPY_AND_ASSIGN(SSLClientSessionCacheOpenSSL); |
| 92 }; | 88 }; |
| 93 | 89 |
| 94 } // namespace net | 90 } // namespace net |
| 95 | 91 |
| 96 #endif // NET_SSL_SSL_CLIENT_SESSION_CACHE_OPENSSL_H | 92 #endif // NET_SSL_SSL_CLIENT_SESSION_CACHE_OPENSSL_H |
| OLD | NEW |