Chromium Code Reviews| Index: net/ssl/ssl_client_session_cache.h |
| diff --git a/net/ssl/ssl_client_session_cache.h b/net/ssl/ssl_client_session_cache.h |
| index 4a82010badda3722a6d318ff74951016a155bfc2..684913fa2295d1f958aa54f80b4fb8cddd0b8dd4 100644 |
| --- a/net/ssl/ssl_client_session_cache.h |
| +++ b/net/ssl/ssl_client_session_cache.h |
| @@ -46,8 +46,15 @@ class NET_EXPORT SSLClientSessionCache : public base::MemoryCoordinatorClient { |
| size_t size() const; |
| // Returns the session associated with |cache_key| and moves it to the front |
| - // of the MRU list. Returns nullptr if there is none. |
| - bssl::UniquePtr<SSL_SESSION> Lookup(const std::string& cache_key); |
| + // of the MRU list. Returns nullptr if there is none. If |count| is non-null, |
| + // |*count| will contain the number of times this session has been looked up |
| + // (including this call). |
| + bssl::UniquePtr<SSL_SESSION> Lookup(const std::string& cache_key, |
| + size_t* count); |
|
davidben
2017/01/19 21:56:12
size_t => int to match
nharper
2017/01/19 22:09:07
Done.
|
| + |
| + // Resets the count returned by Lookup to 0 for the session associated with |
| + // |cache_key|. |
| + void ResetLookupCount(const std::string& cache_key); |
| // Inserts |session| into the cache at |cache_key|. If there is an existing |
| // one, it is released. Every |expiration_check_count| calls, the cache is |
| @@ -64,6 +71,15 @@ class NET_EXPORT SSLClientSessionCache : public base::MemoryCoordinatorClient { |
| void DumpMemoryStats(base::trace_event::ProcessMemoryDump* pmd); |
| private: |
| + struct Entry { |
| + Entry(); |
| + Entry(Entry&&); |
| + ~Entry(); |
| + |
| + int lookups; |
| + bssl::UniquePtr<SSL_SESSION> session; |
| + }; |
| + |
| // base::MemoryCoordinatorClient implementation: |
| void OnMemoryStateChange(base::MemoryState state) override; |
| @@ -79,7 +95,7 @@ class NET_EXPORT SSLClientSessionCache : public base::MemoryCoordinatorClient { |
| std::unique_ptr<base::Clock> clock_; |
| Config config_; |
| - base::HashingMRUCache<std::string, bssl::UniquePtr<SSL_SESSION>> cache_; |
| + base::HashingMRUCache<std::string, Entry> cache_; |
| size_t lookups_since_flush_; |
| // TODO(davidben): After https://crbug.com/458365 is fixed, replace this with |