Chromium Code Reviews| Index: base/chromeos/memory_pressure_observer_chromeos.h |
| diff --git a/base/chromeos/memory_pressure_observer_chromeos.h b/base/chromeos/memory_pressure_observer_chromeos.h |
| index 445119efb73853c1f712dab8c85ad190ddb86f6b..846b2bacfb34c05aba4a7378f80403038560be7b 100644 |
| --- a/base/chromeos/memory_pressure_observer_chromeos.h |
| +++ b/base/chromeos/memory_pressure_observer_chromeos.h |
| @@ -6,8 +6,10 @@ |
| #define BASE_CHROMEOS_MEMORY_PRESSURE_OBSERVER_CHROMEOS_H_ |
| #include "base/base_export.h" |
| +#include "base/gtest_prod_util.h" |
|
James Cook
2015/01/05 18:41:19
Are you using this?
Mr4D (OOO till 08-26)
2015/01/06 22:22:06
With your requested change I need it again. :)
|
| #include "base/macros.h" |
| #include "base/memory/memory_pressure_listener.h" |
| +#include "base/memory/weak_ptr.h" |
| #include "base/timer/timer.h" |
| namespace base { |
| @@ -21,15 +23,22 @@ namespace base { |
| // |
| class BASE_EXPORT MemoryPressureObserverChromeOS { |
| public: |
| + using GetUsedMemoryInPercentCallback = int (*)(); |
| + |
| MemoryPressureObserverChromeOS(); |
| - ~MemoryPressureObserverChromeOS(); |
| + virtual ~MemoryPressureObserverChromeOS(); |
| + |
| + // Redo the memory pressure calculation soon and call again if a critical |
| + // memory pressure prevails. Note that this call will trigger an asynchronous |
| + // action which gives the system time to release memory back into the pool. |
| + void ScheduleEarlyCheck(); |
| // Get the current memory pressure level. |
| base::MemoryPressureListener::MemoryPressureLevel GetCurrentPressureLevel() { |
| return current_memory_pressure_level_; |
| } |
| - private: |
| + protected: |
|
James Cook
2015/01/05 18:41:19
If you decide to FRIEND_TEST this could be private
Mr4D (OOO till 08-26)
2015/01/06 22:22:06
Done.
|
| // Starts observing the memory fill level. |
| // Calls to StartObserving should always be matched with calls to |
| // StopObserving. |
| @@ -39,10 +48,15 @@ class BASE_EXPORT MemoryPressureObserverChromeOS { |
| // May be safely called if StartObserving has not been called. |
| void StopObserving(); |
| - // The function which gets periodically be called to check any changes in the |
| - // memory pressure. |
| + // The function which gets periodically called to check any changes in the |
| + // memory pressure. It will report pressure changes as well as continuous |
| + // critical pressure levels. |
| void CheckMemoryPressure(); |
| + // Get the memory pressure in percent. |
|
James Cook
2015/01/05 18:41:19
Note "virtual for testing" if that's the only reas
Mr4D (OOO till 08-26)
2015/01/06 22:22:06
Done.
|
| + virtual int GetUsedMemoryInPercent(); |
| + |
| + private: |
| // The current memory pressure. |
| base::MemoryPressureListener::MemoryPressureLevel |
| current_memory_pressure_level_; |
| @@ -51,6 +65,12 @@ class BASE_EXPORT MemoryPressureObserverChromeOS { |
| // replaced by a kernel triggered event system (see crbug.com/381196). |
| base::RepeatingTimer<MemoryPressureObserverChromeOS> timer_; |
| + // To slow down the amount of moderate pressure event calls, this counter |
| + // gets used to count the number of events since the last event occured. |
| + int moderate_pressure_repeat_count_; |
| + |
| + base::WeakPtrFactory<MemoryPressureObserverChromeOS> weak_ptr_factory_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(MemoryPressureObserverChromeOS); |
| }; |