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

Side by Side Diff: content/browser/memory/memory_pressure_controller.h

Issue 1362233003: Add architecture for simulating memory pressure notifications in all processes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 CONTENT_BROWSER_MEMORY_MEMORY_PRESSURE_CONTROLLER_H_ 5 #ifndef CONTENT_BROWSER_MEMORY_MEMORY_PRESSURE_CONTROLLER_H_
6 #define CONTENT_BROWSER_MEMORY_MEMORY_PRESSURE_CONTROLLER_H_ 6 #define CONTENT_BROWSER_MEMORY_MEMORY_PRESSURE_CONTROLLER_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/memory/memory_pressure_listener.h"
11 #include "base/memory/singleton.h" 12 #include "base/memory/singleton.h"
12 #include "content/common/content_export.h" 13 #include "content/common/content_export.h"
13 14
14 namespace content { 15 namespace content {
15 16
16 class MemoryMessageFilter; 17 class MemoryMessageFilter;
17 18
19 using MemoryPressureLevel = base::MemoryPressureListener::MemoryPressureLevel;
20 using MemoryMessageFilterSet = std::set<scoped_refptr<MemoryMessageFilter>>;
Primiano Tucci (use gerrit) 2015/09/28 12:47:32 ditto here. ALso, this is now duplicating the alia
petrcermak 2015/09/28 15:39:32 Done.
21
18 class CONTENT_EXPORT MemoryPressureController { 22 class CONTENT_EXPORT MemoryPressureController {
19 public: 23 public:
20 // These methods must be called on the IO thread. 24 // These methods must be called on the IO thread.
21 void OnMemoryMessageFilterAdded(MemoryMessageFilter* filter); 25 void OnMemoryMessageFilterAdded(MemoryMessageFilter* filter);
22 void OnMemoryMessageFilterRemoved(MemoryMessageFilter* filter); 26 void OnMemoryMessageFilterRemoved(MemoryMessageFilter* filter);
23 27
24 // This method can be called from any thread. 28 // These methods can be called from any thread.
25 void SetPressureNotificationsSuppressedInAllProcesses(bool suppressed); 29 void SetPressureNotificationsSuppressedInAllProcesses(bool suppressed);
30 void SimulatePressureNotificationInAllProcesses(MemoryPressureLevel level);
26 31
27 // This method can be called from any thread. 32 // This method can be called from any thread.
28 static MemoryPressureController* GetInstance(); 33 static MemoryPressureController* GetInstance();
29 34
30 protected: 35 protected:
31 virtual ~MemoryPressureController(); 36 virtual ~MemoryPressureController();
32 37
33 private: 38 private:
34 friend struct base::DefaultSingletonTraits<MemoryPressureController>; 39 friend struct base::DefaultSingletonTraits<MemoryPressureController>;
35 40
36 MemoryPressureController(); 41 MemoryPressureController();
37 42
38 // Set of all memory message filters in the browser process. Always accessed 43 // Set of all memory message filters in the browser process. Always accessed
39 // on the IO thread. 44 // on the IO thread.
40 typedef std::set<scoped_refptr<MemoryMessageFilter>> MemoryMessageFilterSet;
41 MemoryMessageFilterSet memory_message_filters_; 45 MemoryMessageFilterSet memory_message_filters_;
42 46
43 DISALLOW_COPY_AND_ASSIGN(MemoryPressureController); 47 DISALLOW_COPY_AND_ASSIGN(MemoryPressureController);
44 }; 48 };
45 49
46 } // namespace content 50 } // namespace content
47 51
48 #endif // CONTENT_BROWSER_MEMORY_MEMORY_PRESSURE_CONTROLLER_H_ 52 #endif // CONTENT_BROWSER_MEMORY_MEMORY_PRESSURE_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698