OLD | NEW |
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 "base/sys_info.h" | 7 #include "base/sys_info.h" |
8 #include "platform/fonts/FontCache.h" | 8 #include "platform/fonts/FontCache.h" |
9 #include "platform/graphics/ImageDecodingStore.h" | 9 #include "platform/graphics/ImageDecodingStore.h" |
10 #include "platform/instrumentation/tracing/TraceEvent.h" | 10 #include "platform/instrumentation/tracing/TraceEvent.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 clearMemory(); | 61 clearMemory(); |
62 WTF::Partitions::decommitFreeableMemory(); | 62 WTF::Partitions::decommitFreeableMemory(); |
63 } | 63 } |
64 | 64 |
65 void MemoryCoordinator::onMemoryStateChange(MemoryState state) { | 65 void MemoryCoordinator::onMemoryStateChange(MemoryState state) { |
66 for (auto& client : m_clients) | 66 for (auto& client : m_clients) |
67 client->onMemoryStateChange(state); | 67 client->onMemoryStateChange(state); |
68 } | 68 } |
69 | 69 |
70 void MemoryCoordinator::onPurgeMemory() { | 70 void MemoryCoordinator::onPurgeMemory() { |
| 71 for (auto& client : m_clients) |
| 72 client->onPurgeMemory(); |
71 // Don't call clearMemory() because font cache invalidation always causes full | 73 // Don't call clearMemory() because font cache invalidation always causes full |
72 // layout. This increases tab switching cost significantly (e.g. | 74 // layout. This increases tab switching cost significantly (e.g. |
73 // en.wikipedia.org/wiki/Wikipedia). So we should not invalidate the font | 75 // en.wikipedia.org/wiki/Wikipedia). So we should not invalidate the font |
74 // cache in purge+throttle. | 76 // cache in purge+throttle. |
75 ImageDecodingStore::instance().clear(); | 77 ImageDecodingStore::instance().clear(); |
76 WTF::Partitions::decommitFreeableMemory(); | 78 WTF::Partitions::decommitFreeableMemory(); |
77 } | 79 } |
78 | 80 |
79 void MemoryCoordinator::clearMemory() { | 81 void MemoryCoordinator::clearMemory() { |
80 // Clear the image cache. | 82 // Clear the image cache. |
81 // TODO(tasak|bashi): Make ImageDecodingStore and FontCache be | 83 // TODO(tasak|bashi): Make ImageDecodingStore and FontCache be |
82 // MemoryCoordinatorClients rather than clearing caches here. | 84 // MemoryCoordinatorClients rather than clearing caches here. |
83 ImageDecodingStore::instance().clear(); | 85 ImageDecodingStore::instance().clear(); |
84 FontCache::fontCache()->invalidate(); | 86 FontCache::fontCache()->invalidate(); |
85 } | 87 } |
86 | 88 |
87 DEFINE_TRACE(MemoryCoordinator) { | 89 DEFINE_TRACE(MemoryCoordinator) { |
88 visitor->trace(m_clients); | 90 visitor->trace(m_clients); |
89 } | 91 } |
90 | 92 |
91 } // namespace blink | 93 } // namespace blink |
OLD | NEW |