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

Side by Side 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 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 #include "platform/MemoryCoordinator.h" 5 #include "platform/MemoryCoordinator.h"
6 6
7 #include "platform/fonts/FontCache.h" 7 #include "platform/fonts/FontCache.h"
8 #include "platform/graphics/ImageDecodingStore.h" 8 #include "platform/graphics/ImageDecodingStore.h"
9 #include "platform/tracing/TraceEvent.h" 9 #include "platform/tracing/TraceEvent.h"
10 #include "wtf/allocator/Partitions.h" 10 #include "wtf/allocator/Partitions.h"
(...skipping 24 matching lines...) Expand all
35 void MemoryCoordinator::prepareToSuspend() { 35 void MemoryCoordinator::prepareToSuspend() {
36 for (auto& client : m_clients) 36 for (auto& client : m_clients)
37 client->prepareToSuspend(); 37 client->prepareToSuspend();
38 WTF::Partitions::decommitFreeableMemory(); 38 WTF::Partitions::decommitFreeableMemory();
39 } 39 }
40 40
41 void MemoryCoordinator::onMemoryPressure(WebMemoryPressureLevel level) { 41 void MemoryCoordinator::onMemoryPressure(WebMemoryPressureLevel level) {
42 TRACE_EVENT0("blink", "MemoryCoordinator::onMemoryPressure"); 42 TRACE_EVENT0("blink", "MemoryCoordinator::onMemoryPressure");
43 for (auto& client : m_clients) 43 for (auto& client : m_clients)
44 client->onMemoryPressure(level); 44 client->onMemoryPressure(level);
45 if (level == WebMemoryPressureLevelCritical) { 45 if (level == WebMemoryPressureLevelCritical)
46 // Clear the image cache. 46 clearMemory();
47 // TODO(tasak|bashi): Make ImageDecodingStore and FontCache be
48 // MemoryCoordinatorClients rather than clearing caches here.
49 ImageDecodingStore::instance().clear();
50 FontCache::fontCache()->invalidate();
51 }
52 WTF::Partitions::decommitFreeableMemory(); 47 WTF::Partitions::decommitFreeableMemory();
53 } 48 }
54 49
50 void MemoryCoordinator::onMemoryStateChange(MemoryState state) {
51 for (auto& client : m_clients)
52 client->onMemoryStateChange(state);
53 if (state == MemoryState::SUSPENDED)
54 clearMemory();
55 WTF::Partitions::decommitFreeableMemory();
56 }
57
58 void MemoryCoordinator::clearMemory() {
59 // Clear the image cache.
60 // TODO(tasak|bashi): Make ImageDecodingStore and FontCache be
61 // MemoryCoordinatorClients rather than clearing caches here.
62 ImageDecodingStore::instance().clear();
63 FontCache::fontCache()->invalidate();
64 }
65
55 DEFINE_TRACE(MemoryCoordinator) { 66 DEFINE_TRACE(MemoryCoordinator) {
56 visitor->trace(m_clients); 67 visitor->trace(m_clients);
57 } 68 }
58 69
59 } // namespace blink 70 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698