OLD | NEW |
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_CHROMEOS_MEMORY_PRESSURE_OBSERVER_CHROMEOS_H_ | 5 #ifndef BASE_CHROMEOS_MEMORY_PRESSURE_OBSERVER_CHROMEOS_H_ |
6 #define BASE_CHROMEOS_MEMORY_PRESSURE_OBSERVER_CHROMEOS_H_ | 6 #define BASE_CHROMEOS_MEMORY_PRESSURE_OBSERVER_CHROMEOS_H_ |
7 | 7 |
8 #include "base/base_export.h" | 8 #include "base/base_export.h" |
9 #include "base/gtest_prod_util.h" | 9 #include "base/gtest_prod_util.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 69 |
70 // Stop observing the memory fill level. | 70 // Stop observing the memory fill level. |
71 // May be safely called if StartObserving has not been called. | 71 // May be safely called if StartObserving has not been called. |
72 void StopObserving(); | 72 void StopObserving(); |
73 | 73 |
74 // The function which gets periodically called to check any changes in the | 74 // The function which gets periodically called to check any changes in the |
75 // memory pressure. It will report pressure changes as well as continuous | 75 // memory pressure. It will report pressure changes as well as continuous |
76 // critical pressure levels. | 76 // critical pressure levels. |
77 void CheckMemoryPressure(); | 77 void CheckMemoryPressure(); |
78 | 78 |
| 79 // The function periodically checks the memory pressure changes and records |
| 80 // the UMA histogram statistics for the current memory pressure level. |
| 81 void CheckMemoryPressureAndRecordStatistics(); |
| 82 |
79 // Get the memory pressure in percent (virtual for testing). | 83 // Get the memory pressure in percent (virtual for testing). |
80 virtual int GetUsedMemoryInPercent(); | 84 virtual int GetUsedMemoryInPercent(); |
81 | 85 |
82 // The current memory pressure. | 86 // The current memory pressure. |
83 base::MemoryPressureListener::MemoryPressureLevel | 87 base::MemoryPressureListener::MemoryPressureLevel |
84 current_memory_pressure_level_; | 88 current_memory_pressure_level_; |
85 | 89 |
86 // A periodic timer to check for resource pressure changes. This will get | 90 // A periodic timer to check for resource pressure changes. This will get |
87 // replaced by a kernel triggered event system (see crbug.com/381196). | 91 // replaced by a kernel triggered event system (see crbug.com/381196). |
88 base::RepeatingTimer<MemoryPressureObserverChromeOS> timer_; | 92 base::RepeatingTimer<MemoryPressureObserverChromeOS> timer_; |
89 | 93 |
90 // To slow down the amount of moderate pressure event calls, this counter | 94 // To slow down the amount of moderate pressure event calls, this counter |
91 // gets used to count the number of events since the last event occured. | 95 // gets used to count the number of events since the last event occured. |
92 int moderate_pressure_repeat_count_; | 96 int moderate_pressure_repeat_count_; |
93 | 97 |
94 // The thresholds for moderate and critical pressure. | 98 // The thresholds for moderate and critical pressure. |
95 const int moderate_pressure_threshold_percent_; | 99 const int moderate_pressure_threshold_percent_; |
96 const int critical_pressure_threshold_percent_; | 100 const int critical_pressure_threshold_percent_; |
97 | 101 |
98 base::WeakPtrFactory<MemoryPressureObserverChromeOS> weak_ptr_factory_; | 102 base::WeakPtrFactory<MemoryPressureObserverChromeOS> weak_ptr_factory_; |
99 | 103 |
100 DISALLOW_COPY_AND_ASSIGN(MemoryPressureObserverChromeOS); | 104 DISALLOW_COPY_AND_ASSIGN(MemoryPressureObserverChromeOS); |
101 }; | 105 }; |
102 | 106 |
103 } // namespace base | 107 } // namespace base |
104 | 108 |
105 #endif // BASE_CHROMEOS_MEMORY_PRESSURE_OBSERVER_CHROMEOS_H_ | 109 #endif // BASE_CHROMEOS_MEMORY_PRESSURE_OBSERVER_CHROMEOS_H_ |
OLD | NEW |