| 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 18 matching lines...) Expand all Loading... |
| 29 // has occurred. | 29 // has occurred. |
| 30 virtual void purgeMemory(DeviceKind) = 0; | 30 virtual void purgeMemory(DeviceKind) = 0; |
| 31 | 31 |
| 32 DECLARE_VIRTUAL_TRACE(); | 32 DECLARE_VIRTUAL_TRACE(); |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 // MemoryPurgeController listens to some events which could be opportunities | 35 // MemoryPurgeController listens to some events which could be opportunities |
| 36 // for reducing memory consumption and notifies its clients. | 36 // for reducing memory consumption and notifies its clients. |
| 37 // Since we want to control memory per tab, MemoryPurgeController is owned by | 37 // Since we want to control memory per tab, MemoryPurgeController is owned by |
| 38 // Page. | 38 // Page. |
| 39 class PLATFORM_EXPORT MemoryPurgeController final : public GarbageCollectedFinal
ized<MemoryPurgeController> { | 39 class PLATFORM_EXPORT MemoryPurgeController final : public GarbageCollected<Memo
ryPurgeController> { |
| 40 WTF_MAKE_NONCOPYABLE(MemoryPurgeController); | 40 WTF_MAKE_NONCOPYABLE(MemoryPurgeController); |
| 41 public: | 41 public: |
| 42 static void onMemoryPressure(WebMemoryPressureLevel); | 42 static void onMemoryPressure(WebMemoryPressureLevel); |
| 43 | 43 |
| 44 static RawPtr<MemoryPurgeController> create() | 44 static MemoryPurgeController* create() |
| 45 { | 45 { |
| 46 return new MemoryPurgeController; | 46 return new MemoryPurgeController; |
| 47 } | 47 } |
| 48 ~MemoryPurgeController(); | |
| 49 | 48 |
| 50 void registerClient(MemoryPurgeClient* client) | 49 void registerClient(MemoryPurgeClient* client) |
| 51 { | 50 { |
| 52 ASSERT(isMainThread()); | 51 ASSERT(isMainThread()); |
| 53 ASSERT(client); | 52 ASSERT(client); |
| 54 ASSERT(!m_clients.contains(client)); | 53 ASSERT(!m_clients.contains(client)); |
| 55 m_clients.add(client); | 54 m_clients.add(client); |
| 56 } | 55 } |
| 57 | 56 |
| 58 void unregisterClient(MemoryPurgeClient* client) | 57 void unregisterClient(MemoryPurgeClient* client) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 70 private: | 69 private: |
| 71 MemoryPurgeController(); | 70 MemoryPurgeController(); |
| 72 | 71 |
| 73 HeapHashSet<WeakMember<MemoryPurgeClient>> m_clients; | 72 HeapHashSet<WeakMember<MemoryPurgeClient>> m_clients; |
| 74 DeviceKind m_deviceKind; | 73 DeviceKind m_deviceKind; |
| 75 }; | 74 }; |
| 76 | 75 |
| 77 } // namespace blink | 76 } // namespace blink |
| 78 | 77 |
| 79 #endif // MemoryPurgeController_h | 78 #endif // MemoryPurgeController_h |
| OLD | NEW |