Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 COMPONENTS_MEMORY_PRESSURE_DIRECT_MEMORY_PRESSURE_CALCULATOR_WIN_H_ | 5 #ifndef COMPONENTS_MEMORY_PRESSURE_DIRECT_MEMORY_PRESSURE_CALCULATOR_LINUX_H_ |
| 6 #define COMPONENTS_MEMORY_PRESSURE_DIRECT_MEMORY_PRESSURE_CALCULATOR_WIN_H_ | 6 #define COMPONENTS_MEMORY_PRESSURE_DIRECT_MEMORY_PRESSURE_CALCULATOR_LINUX_H_ |
| 7 | 7 |
| 8 #include "components/memory_pressure/memory_pressure_calculator.h" | 8 #include "components/memory_pressure/memory_pressure_calculator.h" |
| 9 | 9 |
| 10 #include "base/files/scoped_file.h" | |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/weak_ptr.h" | |
| 11 #include "base/process/process_metrics.h" | 13 #include "base/process/process_metrics.h" |
| 12 #include "build/build_config.h" | 14 #include "base/timer/timer.h" |
| 13 | 15 |
| 14 namespace memory_pressure { | 16 namespace memory_pressure { |
| 15 | 17 |
| 16 #if defined(MEMORY_PRESSURE_IS_POLLING) | |
|
chrisha
2016/01/20 20:55:43
The linux calculator is also polling, so this keep
Georges Khalil
2016/01/21 14:47:44
That ifdef is useless, it will always be true, sin
| |
| 17 | |
| 18 // OS-specific implementation of MemoryPressureCalculator. This is only defined | 18 // OS-specific implementation of MemoryPressureCalculator. This is only defined |
| 19 // and used on platforms that do not have native memory pressure signals | 19 // and used on platforms that do not have native memory pressure signals |
| 20 // (ChromeOS, Linux, Windows). OSes that do have native signals simply hook into | 20 // (ChromeOS, Linux, Windows). OSes that do have native signals simply hook into |
| 21 // the appropriate subsystem (Android, Mac OS X). | 21 // the appropriate subsystem (Android, Mac OS X). |
| 22 class DirectMemoryPressureCalculator : public MemoryPressureCalculator { | 22 class DirectMemoryPressureCalculator : public MemoryPressureCalculator { |
| 23 public: | 23 public: |
| 24 // Exposed for unittesting. See .cc file for detailed discussion of these | 24 // Exposed for unittesting. See .cc file for detailed discussion of these |
| 25 // constants. | 25 // constants. |
| 26 static const int kLargeMemoryThresholdMb; | 26 static const int kDefaultModerateThresholdPc; |
| 27 static const int kSmallMemoryDefaultModerateThresholdMb; | 27 static const int kDefaultCriticalThresholdPc; |
| 28 static const int kSmallMemoryDefaultCriticalThresholdMb; | |
| 29 static const int kLargeMemoryDefaultModerateThresholdMb; | |
| 30 static const int kLargeMemoryDefaultCriticalThresholdMb; | |
| 31 | 28 |
| 32 // Default constructor. Will choose thresholds automatically based on the | 29 // Default constructor. Will choose thresholds automatically based on the |
| 33 // actual amount of system memory installed. | 30 // actual amount of system memory installed. |
| 34 DirectMemoryPressureCalculator(); | 31 DirectMemoryPressureCalculator(); |
| 35 | 32 |
| 36 // Constructor with explicit memory thresholds. These represent the amount of | 33 // Constructor with explicit memory thresholds. These represent the amount of |
| 37 // free memory below which the applicable memory pressure state applies. | 34 // free memory below which the applicable memory pressure state applies. |
| 38 DirectMemoryPressureCalculator(int moderate_threshold_mb, | 35 DirectMemoryPressureCalculator(int moderate_threshold_mb, |
| 39 int critical_threshold_mb); | 36 int critical_threshold_mb); |
| 40 | 37 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 59 | 56 |
| 60 // Threshold amounts of available memory that trigger pressure levels. See | 57 // Threshold amounts of available memory that trigger pressure levels. See |
| 61 // memory_pressure_monitor_win.cc for a discussion of reasonable values for | 58 // memory_pressure_monitor_win.cc for a discussion of reasonable values for |
| 62 // these. | 59 // these. |
| 63 int moderate_threshold_mb_; | 60 int moderate_threshold_mb_; |
| 64 int critical_threshold_mb_; | 61 int critical_threshold_mb_; |
| 65 | 62 |
| 66 DISALLOW_COPY_AND_ASSIGN(DirectMemoryPressureCalculator); | 63 DISALLOW_COPY_AND_ASSIGN(DirectMemoryPressureCalculator); |
| 67 }; | 64 }; |
| 68 | 65 |
| 69 #endif // defined(MEMORY_PRESSURE_IS_POLLING) | |
| 70 | |
| 71 } // namespace memory_pressure | 66 } // namespace memory_pressure |
| 72 | 67 |
| 73 #endif // COMPONENTS_MEMORY_PRESSURE_DIRECT_MEMORY_PRESSURE_CALCULATOR_WIN_H_ | 68 #endif // COMPONENTS_MEMORY_PRESSURE_DIRECT_MEMORY_PRESSURE_CALCULATOR_LINUX_H_ |
| OLD | NEW |