| 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_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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 current_memory_pressure_level_; | 94 current_memory_pressure_level_; |
| 95 | 95 |
| 96 // A periodic timer to check for resource pressure changes. This will get | 96 // A periodic timer to check for resource pressure changes. This will get |
| 97 // replaced by a kernel triggered event system (see crbug.com/381196). | 97 // replaced by a kernel triggered event system (see crbug.com/381196). |
| 98 base::RepeatingTimer timer_; | 98 base::RepeatingTimer timer_; |
| 99 | 99 |
| 100 // To slow down the amount of moderate pressure event calls, this counter | 100 // To slow down the amount of moderate pressure event calls, this counter |
| 101 // gets used to count the number of events since the last event occured. | 101 // gets used to count the number of events since the last event occured. |
| 102 int moderate_pressure_repeat_count_; | 102 int moderate_pressure_repeat_count_; |
| 103 | 103 |
| 104 // The "Memory.PressureLevel" statistic is recorded every |
| 105 // 5 seconds, but the timer to report "ChromeOS.MemoryPressureLevel" |
| 106 // fires every second. This counter is used to allow reporting |
| 107 // "Memory.PressureLevel" correctly without adding another |
| 108 // timer. |
| 109 int seconds_since_reporting_; |
| 110 |
| 104 // The thresholds for moderate and critical pressure. | 111 // The thresholds for moderate and critical pressure. |
| 105 const int moderate_pressure_threshold_percent_; | 112 const int moderate_pressure_threshold_percent_; |
| 106 const int critical_pressure_threshold_percent_; | 113 const int critical_pressure_threshold_percent_; |
| 107 | 114 |
| 108 // File descriptor used to detect low memory condition. | 115 // File descriptor used to detect low memory condition. |
| 109 ScopedFD low_mem_file_; | 116 ScopedFD low_mem_file_; |
| 110 | 117 |
| 111 DispatchCallback dispatch_callback_; | 118 DispatchCallback dispatch_callback_; |
| 112 | 119 |
| 113 base::WeakPtrFactory<MemoryPressureMonitor> weak_ptr_factory_; | 120 base::WeakPtrFactory<MemoryPressureMonitor> weak_ptr_factory_; |
| 114 | 121 |
| 115 DISALLOW_COPY_AND_ASSIGN(MemoryPressureMonitor); | 122 DISALLOW_COPY_AND_ASSIGN(MemoryPressureMonitor); |
| 116 }; | 123 }; |
| 117 | 124 |
| 118 } // namespace chromeos | 125 } // namespace chromeos |
| 119 } // namespace base | 126 } // namespace base |
| 120 | 127 |
| 121 #endif // BASE_MEMORY_MEMORY_PRESSURE_MONITOR_CHROMEOS_H_ | 128 #endif // BASE_MEMORY_MEMORY_PRESSURE_MONITOR_CHROMEOS_H_ |
| OLD | NEW |