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

Unified Diff: third_party/WebKit/Source/platform/MemoryCoordinator.cpp

Issue 2402643002: Make RenderThreadImpl a client of memory coordinator (Closed)
Patch Set: Address on haraken's review Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/MemoryCoordinator.cpp
diff --git a/third_party/WebKit/Source/platform/MemoryCoordinator.cpp b/third_party/WebKit/Source/platform/MemoryCoordinator.cpp
index 170232e7fb3dd5c50a4023178830e75651f262d5..e447f077d49fbb344439728d0ac0e72c7b710a4e 100644
--- a/third_party/WebKit/Source/platform/MemoryCoordinator.cpp
+++ b/third_party/WebKit/Source/platform/MemoryCoordinator.cpp
@@ -42,16 +42,27 @@ void MemoryCoordinator::onMemoryPressure(WebMemoryPressureLevel level) {
TRACE_EVENT0("blink", "MemoryCoordinator::onMemoryPressure");
for (auto& client : m_clients)
client->onMemoryPressure(level);
- if (level == WebMemoryPressureLevelCritical) {
- // Clear the image cache.
- // TODO(tasak|bashi): Make ImageDecodingStore and FontCache be
- // MemoryCoordinatorClients rather than clearing caches here.
- ImageDecodingStore::instance().clear();
- FontCache::fontCache()->invalidate();
- }
+ if (level == WebMemoryPressureLevelCritical)
+ clearMemory();
WTF::Partitions::decommitFreeableMemory();
}
+void MemoryCoordinator::onMemoryStateChange(MemoryState state) {
+ for (auto& client : m_clients)
+ client->onMemoryStateChange(state);
+ if (state == MemoryState::SUSPENDED)
+ clearMemory();
+ WTF::Partitions::decommitFreeableMemory();
+}
+
+void MemoryCoordinator::clearMemory() {
+ // Clear the image cache.
+ // TODO(tasak|bashi): Make ImageDecodingStore and FontCache be
+ // MemoryCoordinatorClients rather than clearing caches here.
+ ImageDecodingStore::instance().clear();
+ FontCache::fontCache()->invalidate();
+}
+
DEFINE_TRACE(MemoryCoordinator) {
visitor->trace(m_clients);
}

Powered by Google App Engine
This is Rietveld 408576698