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

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

Issue 2097753002: Make memory pressure notifier configurable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix win 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
« no previous file with comments | « base/memory/memory_pressure_monitor_mac.cc ('k') | base/memory/memory_pressure_monitor_win.cc » ('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 BASE_MEMORY_MEMORY_PRESSURE_MONITOR_WIN_H_ 5 #ifndef BASE_MEMORY_MEMORY_PRESSURE_MONITOR_WIN_H_
6 #define BASE_MEMORY_MEMORY_PRESSURE_MONITOR_WIN_H_ 6 #define BASE_MEMORY_MEMORY_PRESSURE_MONITOR_WIN_H_
7 7
8 #include "base/base_export.h" 8 #include "base/base_export.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/memory_pressure_listener.h" 10 #include "base/memory/memory_pressure_listener.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 MemoryPressureMonitor(int moderate_threshold_mb, int critical_threshold_mb); 56 MemoryPressureMonitor(int moderate_threshold_mb, int critical_threshold_mb);
57 57
58 ~MemoryPressureMonitor() override; 58 ~MemoryPressureMonitor() override;
59 59
60 // Schedules a memory pressure check to run soon. This must be called on the 60 // Schedules a memory pressure check to run soon. This must be called on the
61 // same thread where the monitor was instantiated. 61 // same thread where the monitor was instantiated.
62 void CheckMemoryPressureSoon(); 62 void CheckMemoryPressureSoon();
63 63
64 // Get the current memory pressure level. This can be called from any thread. 64 // Get the current memory pressure level. This can be called from any thread.
65 MemoryPressureLevel GetCurrentPressureLevel() const override; 65 MemoryPressureLevel GetCurrentPressureLevel() const override;
66 void SetDispatchCallback(const DispatchCallback& callback) override;
66 67
67 // Returns the moderate pressure level free memory threshold, in MB. 68 // Returns the moderate pressure level free memory threshold, in MB.
68 int moderate_threshold_mb() const { return moderate_threshold_mb_; } 69 int moderate_threshold_mb() const { return moderate_threshold_mb_; }
69 70
70 // Returns the critical pressure level free memory threshold, in MB. 71 // Returns the critical pressure level free memory threshold, in MB.
71 int critical_threshold_mb() const { return critical_threshold_mb_; } 72 int critical_threshold_mb() const { return critical_threshold_mb_; }
72 73
73 protected: 74 protected:
74 // Internals are exposed for unittests. 75 // Internals are exposed for unittests.
75 76
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 126
126 // To slow down the amount of moderate pressure event calls, this gets used to 127 // To slow down the amount of moderate pressure event calls, this gets used to
127 // count the number of events since the last event occured. This is used by 128 // count the number of events since the last event occured. This is used by
128 // |CheckMemoryPressure| to apply hysteresis on the raw results of 129 // |CheckMemoryPressure| to apply hysteresis on the raw results of
129 // |CalculateCurrentPressureLevel|. 130 // |CalculateCurrentPressureLevel|.
130 int moderate_pressure_repeat_count_; 131 int moderate_pressure_repeat_count_;
131 132
132 // Ensures that this object is used from a single thread. 133 // Ensures that this object is used from a single thread.
133 base::ThreadChecker thread_checker_; 134 base::ThreadChecker thread_checker_;
134 135
136 DispatchCallback dispatch_callback_;
137
135 // Weak pointer factory to ourself used for scheduling calls to 138 // Weak pointer factory to ourself used for scheduling calls to
136 // CheckMemoryPressure/CheckMemoryPressureAndRecordStatistics via |timer_|. 139 // CheckMemoryPressure/CheckMemoryPressureAndRecordStatistics via |timer_|.
137 base::WeakPtrFactory<MemoryPressureMonitor> weak_ptr_factory_; 140 base::WeakPtrFactory<MemoryPressureMonitor> weak_ptr_factory_;
138 141
139 DISALLOW_COPY_AND_ASSIGN(MemoryPressureMonitor); 142 DISALLOW_COPY_AND_ASSIGN(MemoryPressureMonitor);
140 }; 143 };
141 144
142 } // namespace win 145 } // namespace win
143 } // namespace base 146 } // namespace base
144 147
145 #endif // BASE_MEMORY_MEMORY_PRESSURE_MONITOR_WIN_H_ 148 #endif // BASE_MEMORY_MEMORY_PRESSURE_MONITOR_WIN_H_
OLDNEW
« no previous file with comments | « base/memory/memory_pressure_monitor_mac.cc ('k') | base/memory/memory_pressure_monitor_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698