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

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

Issue 1303203002: Add MemoryPurgeController (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef MemoryPurgeController_h
6 #define MemoryPurgeController_h
7
8 #include "wtf/HashSet.h"
9
10 namespace blink {
11
12 enum MemoryPurgeMode {
13 // The tab contains the webview went to background
14 Inactive,
dcheng 2015/08/21 15:04:19 Suggestion: we should prefer enum class for both o
bashi 2015/08/25 02:34:23 Done.
15 // TODO(bashi): Add more modes as needed.
16 };
17
18 enum DeviceKind {
dcheng 2015/08/21 15:04:19 Ditto: NotSpecified is pretty generic.
bashi 2015/08/25 02:34:23 Done.
19 NotSpecified,
20 LowEnd,
21 };
22
23 // TODO(bashi): Make MemoryPurgeEventListener garbage collected.
24 class MemoryPurgeEventListener {
25 public:
26 // MemoryPurgeController invokes this callback when a memory purge event
27 // has occurred.
28 virtual void purgeMemory(MemoryPurgeMode, DeviceKind) = 0;
29 };
30
31 class MemoryPurgeController {
32 public:
33 MemoryPurgeController();
34
35 void addListener(MemoryPurgeEventListener* listener) { m_listeners.add(liste ner); }
36 void removeListener(MemoryPurgeEventListener* listener) { m_listeners.remove (listener); }
37
38 // Called several seconds after the tab went to background.
39 void didBecomeInactive();
40
41 private:
42 void purgeMemory(MemoryPurgeMode);
43
44 HashSet<MemoryPurgeEventListener*> m_listeners;
45 DeviceKind m_deviceKind;
46 };
47
48 } // namespace blink
49
50 #endif // MemoryPurgeController_h
51
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