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" |
(...skipping 24 matching lines...) Expand all Loading... |
35 // has occurred. | 35 // has occurred. |
36 virtual void purgeMemory(MemoryPurgeMode, DeviceKind) = 0; | 36 virtual void purgeMemory(MemoryPurgeMode, DeviceKind) = 0; |
37 | 37 |
38 DECLARE_VIRTUAL_TRACE(); | 38 DECLARE_VIRTUAL_TRACE(); |
39 }; | 39 }; |
40 | 40 |
41 // MemoryPurgeController listens to some events which could be opportunities | 41 // MemoryPurgeController listens to some events which could be opportunities |
42 // for reducing memory consumption and notifies its clients. | 42 // for reducing memory consumption and notifies its clients. |
43 // Since we want to control memory per tab, MemoryPurgeController is owned by | 43 // Since we want to control memory per tab, MemoryPurgeController is owned by |
44 // Page. | 44 // Page. |
45 class PLATFORM_EXPORT MemoryPurgeController final : public NoBaseWillBeGarbageCo
llected<MemoryPurgeController> { | 45 class PLATFORM_EXPORT MemoryPurgeController final : public NoBaseWillBeGarbageCo
llectedFinalized<MemoryPurgeController> { |
46 DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(MemoryPurgeController); | |
47 public: | 46 public: |
48 static PassOwnPtrWillBeRawPtr<MemoryPurgeController> create() | 47 static PassOwnPtrWillBeRawPtr<MemoryPurgeController> create() |
49 { | 48 { |
50 return adoptPtrWillBeNoop(new MemoryPurgeController); | 49 return adoptPtrWillBeNoop(new MemoryPurgeController); |
51 } | 50 } |
| 51 ~MemoryPurgeController(); |
52 | 52 |
53 void registerClient(MemoryPurgeClient* client) | 53 void registerClient(MemoryPurgeClient* client) |
54 { | 54 { |
55 ASSERT(isMainThread()); | 55 ASSERT(isMainThread()); |
56 ASSERT(client); | 56 ASSERT(client); |
57 ASSERT(!m_clients.contains(client)); | 57 ASSERT(!m_clients.contains(client)); |
58 m_clients.add(client); | 58 m_clients.add(client); |
59 } | 59 } |
60 | 60 |
61 void unregisterClient(MemoryPurgeClient* client) | 61 void unregisterClient(MemoryPurgeClient* client) |
(...skipping 15 matching lines...) Expand all Loading... |
77 void purgeMemory(MemoryPurgeMode); | 77 void purgeMemory(MemoryPurgeMode); |
78 | 78 |
79 WillBeHeapHashSet<RawPtrWillBeWeakMember<MemoryPurgeClient>> m_clients; | 79 WillBeHeapHashSet<RawPtrWillBeWeakMember<MemoryPurgeClient>> m_clients; |
80 DeviceKind m_deviceKind; | 80 DeviceKind m_deviceKind; |
81 Timer<MemoryPurgeController> m_inactiveTimer; | 81 Timer<MemoryPurgeController> m_inactiveTimer; |
82 }; | 82 }; |
83 | 83 |
84 } // namespace blink | 84 } // namespace blink |
85 | 85 |
86 #endif // MemoryPurgeController_h | 86 #endif // MemoryPurgeController_h |
OLD | NEW |