Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Side by Side Diff: net/ssl/ssl_client_session_cache.h

Issue 2648323005: memory coordinator: Add MemoryCoordinatorClient::OnPurgeMemory() (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_H_ 5 #ifndef NET_SSL_SSL_CLIENT_SESSION_CACHE_H_
6 #define NET_SSL_SSL_CLIENT_SESSION_CACHE_H_ 6 #define NET_SSL_SSL_CLIENT_SESSION_CACHE_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <time.h> 9 #include <time.h>
10 10
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 struct Entry { 73 struct Entry {
74 Entry(); 74 Entry();
75 Entry(Entry&&); 75 Entry(Entry&&);
76 ~Entry(); 76 ~Entry();
77 77
78 int lookups; 78 int lookups;
79 bssl::UniquePtr<SSL_SESSION> session; 79 bssl::UniquePtr<SSL_SESSION> session;
80 }; 80 };
81 81
82 // base::MemoryCoordinatorClient implementation: 82 // base::MemoryCoordinatorClient implementation:
83 void OnMemoryStateChange(base::MemoryState state) override; 83 void OnPurgeMemory() override;
84 84
85 // Returns true if |entry| is expired as of |now|. 85 // Returns true if |entry| is expired as of |now|.
86 bool IsExpired(SSL_SESSION* session, time_t now); 86 bool IsExpired(SSL_SESSION* session, time_t now);
87 87
88 // Removes all expired sessions from the cache. 88 // Removes all expired sessions from the cache.
89 void FlushExpiredSessions(); 89 void FlushExpiredSessions();
90 90
91 // Clear cache on low memory notifications callback. 91 // Clear cache on low memory notifications callback.
92 void OnMemoryPressure( 92 void OnMemoryPressure(
93 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level); 93 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level);
94 94
95 std::unique_ptr<base::Clock> clock_; 95 std::unique_ptr<base::Clock> clock_;
96 Config config_; 96 Config config_;
97 base::HashingMRUCache<std::string, Entry> cache_; 97 base::HashingMRUCache<std::string, Entry> cache_;
98 size_t lookups_since_flush_; 98 size_t lookups_since_flush_;
99 99
100 // TODO(davidben): After https://crbug.com/458365 is fixed, replace this with 100 // TODO(davidben): After https://crbug.com/458365 is fixed, replace this with
101 // a ThreadChecker. The session cache should be single-threaded like other 101 // a ThreadChecker. The session cache should be single-threaded like other
102 // classes in net. 102 // classes in net.
103 base::Lock lock_; 103 base::Lock lock_;
104 104
105 std::unique_ptr<base::MemoryPressureListener> memory_pressure_listener_; 105 std::unique_ptr<base::MemoryPressureListener> memory_pressure_listener_;
106 106
107 DISALLOW_COPY_AND_ASSIGN(SSLClientSessionCache); 107 DISALLOW_COPY_AND_ASSIGN(SSLClientSessionCache);
108 }; 108 };
109 109
110 } // namespace net 110 } // namespace net
111 111
112 #endif // NET_SSL_SSL_CLIENT_SESSION_CACHE_H_ 112 #endif // NET_SSL_SSL_CLIENT_SESSION_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698