| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "platform/MemoryPurgeController.h" | |
| 6 | |
| 7 #include "base/sys_info.h" | |
| 8 #include "platform/TraceEvent.h" | |
| 9 #include "platform/graphics/ImageDecodingStore.h" | |
| 10 #include "public/platform/Platform.h" | |
| 11 #include "wtf/allocator/Partitions.h" | |
| 12 | |
| 13 namespace blink { | |
| 14 | |
| 15 void MemoryPurgeController::onMemoryPressure(WebMemoryPressureLevel level) | |
| 16 { | |
| 17 if (level == WebMemoryPressureLevelCritical) { | |
| 18 // Clear the image cache. | |
| 19 ImageDecodingStore::instance().clear(); | |
| 20 } | |
| 21 } | |
| 22 | |
| 23 DEFINE_TRACE(MemoryPurgeClient) | |
| 24 { | |
| 25 } | |
| 26 | |
| 27 MemoryPurgeController::MemoryPurgeController() | |
| 28 : m_deviceKind(base::SysInfo::IsLowEndDevice() ? DeviceKind::LowEnd : Device
Kind::NotSpecified) | |
| 29 { | |
| 30 } | |
| 31 | |
| 32 void MemoryPurgeController::purgeMemory() | |
| 33 { | |
| 34 // TODO(bashi): Add UMA | |
| 35 TRACE_EVENT0("blink", "MemoryPurgeController::purgeMemory"); | |
| 36 for (auto& client : m_clients) | |
| 37 client->purgeMemory(m_deviceKind); | |
| 38 WTF::Partitions::decommitFreeableMemory(); | |
| 39 } | |
| 40 | |
| 41 DEFINE_TRACE(MemoryPurgeController) | |
| 42 { | |
| 43 visitor->trace(m_clients); | |
| 44 } | |
| 45 | |
| 46 } // namespace blink | |
| OLD | NEW |