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 #ifndef MemoryPurgeController_h | 5 #ifndef MemoryPurgeController_h |
6 #define MemoryPurgeController_h | 6 #define MemoryPurgeController_h |
7 | 7 |
8 #include "platform/PlatformExport.h" | 8 #include "platform/PlatformExport.h" |
9 #include "platform/Timer.h" | 9 #include "platform/Timer.h" |
10 #include "platform/heap/Handle.h" | 10 #include "platform/heap/Handle.h" |
11 #include "wtf/MainThread.h" | 11 #include "wtf/MainThread.h" |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 enum class MemoryPurgeMode { | 15 enum class MemoryPurgeMode { |
| 16 // This is used only for testing. |
| 17 NotSpecified, |
16 // The tab contains the webview went to background | 18 // The tab contains the webview went to background |
17 InactiveTab, | 19 InactiveTab, |
18 // TODO(bashi): Add more modes as needed. | 20 // TODO(bashi): Add more modes as needed. |
19 }; | 21 }; |
20 | 22 |
21 enum class DeviceKind { | 23 enum class DeviceKind { |
22 NotSpecified, | 24 NotSpecified, |
23 LowEnd, | 25 LowEnd, |
24 }; | 26 }; |
25 | 27 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 { | 64 { |
63 // Don't assert m_clients.contains() so that clients can unregister | 65 // Don't assert m_clients.contains() so that clients can unregister |
64 // unconditionally. | 66 // unconditionally. |
65 ASSERT(isMainThread()); | 67 ASSERT(isMainThread()); |
66 m_clients.remove(client); | 68 m_clients.remove(client); |
67 } | 69 } |
68 | 70 |
69 void pageBecameActive(); | 71 void pageBecameActive(); |
70 void pageBecameInactive(); | 72 void pageBecameInactive(); |
71 void pageInactiveTask(Timer<MemoryPurgeController>*); | 73 void pageInactiveTask(Timer<MemoryPurgeController>*); |
| 74 void purgeMemory(MemoryPurgeMode); |
72 | 75 |
73 DECLARE_TRACE(); | 76 DECLARE_TRACE(); |
74 | 77 |
75 private: | 78 private: |
76 MemoryPurgeController(); | 79 MemoryPurgeController(); |
77 | 80 |
78 void purgeMemory(MemoryPurgeMode); | |
79 | |
80 WillBeHeapHashSet<RawPtrWillBeWeakMember<MemoryPurgeClient>> m_clients; | 81 WillBeHeapHashSet<RawPtrWillBeWeakMember<MemoryPurgeClient>> m_clients; |
81 DeviceKind m_deviceKind; | 82 DeviceKind m_deviceKind; |
82 Timer<MemoryPurgeController> m_inactiveTimer; | 83 Timer<MemoryPurgeController> m_inactiveTimer; |
83 }; | 84 }; |
84 | 85 |
85 } // namespace blink | 86 } // namespace blink |
86 | 87 |
87 #endif // MemoryPurgeController_h | 88 #endif // MemoryPurgeController_h |
OLD | NEW |