Index: net/ssl/ssl_client_session_cache.cc |
diff --git a/net/ssl/ssl_client_session_cache.cc b/net/ssl/ssl_client_session_cache.cc |
index 28a33da15ce6d64dc4d5dbca21faf87daf60d551..f1aa1d0e612a4a25fa3394acbe4b13fdefc473da 100644 |
--- a/net/ssl/ssl_client_session_cache.cc |
+++ b/net/ssl/ssl_client_session_cache.cc |
@@ -6,6 +6,7 @@ |
#include <utility> |
+#include "base/memory/memory_coordinator_client_registry.h" |
#include "base/time/clock.h" |
#include "base/time/default_clock.h" |
@@ -18,10 +19,12 @@ SSLClientSessionCache::SSLClientSessionCache(const Config& config) |
lookups_since_flush_(0) { |
memory_pressure_listener_.reset(new base::MemoryPressureListener(base::Bind( |
&SSLClientSessionCache::OnMemoryPressure, base::Unretained(this)))); |
+ base::MemoryCoordinatorClientRegistry::GetInstance()->Register(this); |
} |
SSLClientSessionCache::~SSLClientSessionCache() { |
Flush(); |
+ base::MemoryCoordinatorClientRegistry::GetInstance()->Unregister(this); |
} |
size_t SSLClientSessionCache::size() const { |
@@ -112,4 +115,22 @@ void SSLClientSessionCache::OnMemoryPressure( |
} |
} |
+void SSLClientSessionCache::OnMemoryStateChange(base::MemoryState state) { |
+ // TODO(hajimehoshi): When the state changes, adjust the sizes of the caches |
+ // to reduce the limits. SSLClientSessionCache doesn't have the ability to |
+ // limit at present. |
+ switch (state) { |
+ case base::MemoryState::NORMAL: |
+ break; |
+ case base::MemoryState::THROTTLED: |
+ Flush(); |
+ break; |
+ case base::MemoryState::SUSPENDED: |
+ // Note: Not supported at present. Fall through. |
+ case base::MemoryState::UNKNOWN: |
+ NOTREACHED(); |
+ break; |
+ } |
+} |
+ |
} // namespace net |