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

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

Issue 1335373003: Have a Page's MemoryPurgeController be a separate allocation also. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/page/Page.cpp ('k') | Source/platform/MemoryPurgeController.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/heap/Handle.h" 9 #include "platform/heap/Handle.h"
10 #include "wtf/MainThread.h" 10 #include "wtf/MainThread.h"
(...skipping 23 matching lines...) Expand all
34 // has occurred. 34 // has occurred.
35 virtual void purgeMemory(MemoryPurgeMode, DeviceKind) = 0; 35 virtual void purgeMemory(MemoryPurgeMode, DeviceKind) = 0;
36 36
37 DECLARE_TRACE(); 37 DECLARE_TRACE();
38 }; 38 };
39 39
40 // MemoryPurgeController listens to some events which could be opportunities 40 // MemoryPurgeController listens to some events which could be opportunities
41 // for reducing memory consumption and notifies its clients. 41 // for reducing memory consumption and notifies its clients.
42 // Since we want to control memory per tab, MemoryPurgeController is owned by 42 // Since we want to control memory per tab, MemoryPurgeController is owned by
43 // Page. 43 // Page.
44 class PLATFORM_EXPORT MemoryPurgeController { 44 class PLATFORM_EXPORT MemoryPurgeController final : public NoBaseWillBeGarbageCo llected<MemoryPurgeController> {
45 DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(MemoryPurgeController);
45 public: 46 public:
46 MemoryPurgeController(); 47 static PassOwnPtrWillBeRawPtr<MemoryPurgeController> create()
48 {
49 return adoptPtrWillBeNoop(new MemoryPurgeController);
50 }
47 51
48 void registerClient(MemoryPurgeClient* client) 52 void registerClient(MemoryPurgeClient* client)
49 { 53 {
50 ASSERT(isMainThread()); 54 ASSERT(isMainThread());
51 ASSERT(client); 55 ASSERT(client);
52 ASSERT(!m_clients.contains(client)); 56 ASSERT(!m_clients.contains(client));
53 m_clients.add(client); 57 m_clients.add(client);
54 } 58 }
55 59
56 void unregisterClient(MemoryPurgeClient* client) 60 void unregisterClient(MemoryPurgeClient* client)
57 { 61 {
58 ASSERT(isMainThread()); 62 ASSERT(isMainThread());
59 ASSERT(m_clients.contains(client)); 63 ASSERT(m_clients.contains(client));
60 m_clients.remove(client); 64 m_clients.remove(client);
61 } 65 }
62 66
63 DECLARE_TRACE(); 67 DECLARE_TRACE();
64 68
65 private: 69 private:
70 MemoryPurgeController();
71
66 void purgeMemory(MemoryPurgeMode); 72 void purgeMemory(MemoryPurgeMode);
67 73
68 WillBeHeapHashSet<RawPtrWillBeWeakMember<MemoryPurgeClient>> m_clients; 74 WillBeHeapHashSet<RawPtrWillBeWeakMember<MemoryPurgeClient>> m_clients;
69 DeviceKind m_deviceKind; 75 DeviceKind m_deviceKind;
70 }; 76 };
71 77
72 } // namespace blink 78 } // namespace blink
73 79
74 #endif // MemoryPurgeController_h 80 #endif // MemoryPurgeController_h
OLDNEW
« no previous file with comments | « Source/core/page/Page.cpp ('k') | Source/platform/MemoryPurgeController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698