Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1069)

Side by Side Diff: third_party/WebKit/Source/platform/MemoryPurgeController.h

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "public/platform/WebMemoryPressureLevel.h" 11 #include "public/platform/WebMemoryPressureLevel.h"
12 12
13 namespace blink { 13 namespace blink {
14 14
15 enum class DeviceKind { 15 enum class DeviceKind {
16 NotSpecified, 16 NotSpecified,
17 LowEnd, 17 LowEnd,
18 }; 18 };
19 19
20 // Classes which have discardable/reducible memory can implement this 20 // Classes which have discardable/reducible memory can implement this
21 // interface to be informed when they should reduce memory consumption. 21 // interface to be informed when they should reduce memory consumption.
22 // MemoryPurgeController assumes that subclasses of MemoryPurgeClient are 22 // MemoryPurgeController assumes that subclasses of MemoryPurgeClient are
23 // WillBes. 23 // WillBes.
24 class PLATFORM_EXPORT MemoryPurgeClient : public WillBeGarbageCollectedMixin { 24 class PLATFORM_EXPORT MemoryPurgeClient : public GarbageCollectedMixin {
25 public: 25 public:
26 virtual ~MemoryPurgeClient() { } 26 virtual ~MemoryPurgeClient() { }
27 27
28 // MemoryPurgeController invokes this callback when a memory purge event 28 // MemoryPurgeController invokes this callback when a memory purge event
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 NoBaseWillBeGarbageCo llectedFinalized<MemoryPurgeController> { 39 class PLATFORM_EXPORT MemoryPurgeController final : public GarbageCollectedFinal ized<MemoryPurgeController> {
40 USING_FAST_MALLOC_WILL_BE_REMOVED(MemoryPurgeController);
41 WTF_MAKE_NONCOPYABLE(MemoryPurgeController); 40 WTF_MAKE_NONCOPYABLE(MemoryPurgeController);
42 public: 41 public:
43 static void onMemoryPressure(WebMemoryPressureLevel); 42 static void onMemoryPressure(WebMemoryPressureLevel);
44 43
45 static PassOwnPtrWillBeRawPtr<MemoryPurgeController> create() 44 static RawPtr<MemoryPurgeController> create()
46 { 45 {
47 return adoptPtrWillBeNoop(new MemoryPurgeController); 46 return adoptPtrWillBeNoop(new MemoryPurgeController);
48 } 47 }
49 ~MemoryPurgeController(); 48 ~MemoryPurgeController();
50 49
51 void registerClient(MemoryPurgeClient* client) 50 void registerClient(MemoryPurgeClient* client)
52 { 51 {
53 ASSERT(isMainThread()); 52 ASSERT(isMainThread());
54 ASSERT(client); 53 ASSERT(client);
55 ASSERT(!m_clients.contains(client)); 54 ASSERT(!m_clients.contains(client));
56 m_clients.add(client); 55 m_clients.add(client);
57 } 56 }
58 57
59 void unregisterClient(MemoryPurgeClient* client) 58 void unregisterClient(MemoryPurgeClient* client)
60 { 59 {
61 // Don't assert m_clients.contains() so that clients can unregister 60 // Don't assert m_clients.contains() so that clients can unregister
62 // unconditionally. 61 // unconditionally.
63 ASSERT(isMainThread()); 62 ASSERT(isMainThread());
64 m_clients.remove(client); 63 m_clients.remove(client);
65 } 64 }
66 65
67 void purgeMemory(); 66 void purgeMemory();
68 67
69 DECLARE_TRACE(); 68 DECLARE_TRACE();
70 69
71 private: 70 private:
72 MemoryPurgeController(); 71 MemoryPurgeController();
73 72
74 WillBeHeapHashSet<RawPtrWillBeWeakMember<MemoryPurgeClient>> m_clients; 73 HeapHashSet<WeakMember<MemoryPurgeClient>> m_clients;
75 DeviceKind m_deviceKind; 74 DeviceKind m_deviceKind;
76 }; 75 };
77 76
78 } // namespace blink 77 } // namespace blink
79 78
80 #endif // MemoryPurgeController_h 79 #endif // MemoryPurgeController_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/LifecycleObserver.h ('k') | third_party/WebKit/Source/platform/PopupMenu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698