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

Side by Side Diff: base/memory/memory_pressure_monitor_chromeos.h

Issue 2097753002: Make memory pressure notifier configurable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment Created 4 years, 5 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 BASE_MEMORY_MEMORY_PRESSURE_MONITOR_CHROMEOS_H_ 5 #ifndef BASE_MEMORY_MEMORY_PRESSURE_MONITOR_CHROMEOS_H_
6 #define BASE_MEMORY_MEMORY_PRESSURE_MONITOR_CHROMEOS_H_ 6 #define BASE_MEMORY_MEMORY_PRESSURE_MONITOR_CHROMEOS_H_
7 7
8 #include "base/base_export.h" 8 #include "base/base_export.h"
9 #include "base/files/scoped_file.h" 9 #include "base/files/scoped_file.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 // Redo the memory pressure calculation soon and call again if a critical 55 // Redo the memory pressure calculation soon and call again if a critical
56 // memory pressure prevails. Note that this call will trigger an asynchronous 56 // memory pressure prevails. Note that this call will trigger an asynchronous
57 // action which gives the system time to release memory back into the pool. 57 // action which gives the system time to release memory back into the pool.
58 void ScheduleEarlyCheck(); 58 void ScheduleEarlyCheck();
59 59
60 // Get the current memory pressure level. 60 // Get the current memory pressure level.
61 MemoryPressureListener::MemoryPressureLevel GetCurrentPressureLevel() const 61 MemoryPressureListener::MemoryPressureLevel GetCurrentPressureLevel() const
62 override; 62 override;
63 63
64 void SetDispatchCallback(DispatchCallback callback) override;
danakj 2016/07/08 00:03:53 nit: normally all overrides for a class are groupe
bashi 2016/07/08 00:13:05 Acknowledged.
65
64 // Returns a type-casted version of the current memory pressure monitor. A 66 // Returns a type-casted version of the current memory pressure monitor. A
65 // simple wrapper to base::MemoryPressureMonitor::Get. 67 // simple wrapper to base::MemoryPressureMonitor::Get.
66 static MemoryPressureMonitor* Get(); 68 static MemoryPressureMonitor* Get();
67 69
68 private: 70 private:
69 friend TestMemoryPressureMonitor; 71 friend TestMemoryPressureMonitor;
70 // Starts observing the memory fill level. 72 // Starts observing the memory fill level.
71 // Calls to StartObserving should always be matched with calls to 73 // Calls to StartObserving should always be matched with calls to
72 // StopObserving. 74 // StopObserving.
73 void StartObserving(); 75 void StartObserving();
(...skipping 26 matching lines...) Expand all
100 // gets used to count the number of events since the last event occured. 102 // gets used to count the number of events since the last event occured.
101 int moderate_pressure_repeat_count_; 103 int moderate_pressure_repeat_count_;
102 104
103 // The thresholds for moderate and critical pressure. 105 // The thresholds for moderate and critical pressure.
104 const int moderate_pressure_threshold_percent_; 106 const int moderate_pressure_threshold_percent_;
105 const int critical_pressure_threshold_percent_; 107 const int critical_pressure_threshold_percent_;
106 108
107 // File descriptor used to detect low memory condition. 109 // File descriptor used to detect low memory condition.
108 ScopedFD low_mem_file_; 110 ScopedFD low_mem_file_;
109 111
112 DispatchCallback dispatch_callback_ =
113 &MemoryPressureListener::NotifyMemoryPressure;
114
110 base::WeakPtrFactory<MemoryPressureMonitor> weak_ptr_factory_; 115 base::WeakPtrFactory<MemoryPressureMonitor> weak_ptr_factory_;
111 116
112 DISALLOW_COPY_AND_ASSIGN(MemoryPressureMonitor); 117 DISALLOW_COPY_AND_ASSIGN(MemoryPressureMonitor);
113 }; 118 };
114 119
115 } // namespace chromeos 120 } // namespace chromeos
116 } // namespace base 121 } // namespace base
117 122
118 #endif // BASE_MEMORY_MEMORY_PRESSURE_MONITOR_CHROMEOS_H_ 123 #endif // BASE_MEMORY_MEMORY_PRESSURE_MONITOR_CHROMEOS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698