Index: base/chromeos/memory_pressure_observer_chromeos.cc |
diff --git a/base/chromeos/memory_pressure_observer_chromeos.cc b/base/chromeos/memory_pressure_observer_chromeos.cc |
index 4da7d24bfdb75a38bb9be99b5877819b8c5ed3bf..af9b50d3ab138277531c2575747ce1808c87a65f 100644 |
--- a/base/chromeos/memory_pressure_observer_chromeos.cc |
+++ b/base/chromeos/memory_pressure_observer_chromeos.cc |
@@ -24,25 +24,38 @@ const int kModerateMemoryPressureCooldown = |
kModerateMemoryPressureCooldownMs / kMemoryPressureIntervalMs; |
// Threshold constants to emit pressure events. |
-const int kMemoryPressureModerateThresholdPercent = 70; |
-const int kMemoryPressureCriticalThresholdPercent = 90; |
+const int kNormalMemoryPressureModerateThresholdPercent = 60; |
+const int kNormalMemoryPressureCriticalThresholdPercent = 90; |
+const int kAggressiveMemoryPressureModerateThresholdPercent = 35; |
+const int kAggressiveMemoryPressureCriticalThresholdPercent = 70; |
// Converts free percent of memory into a memory pressure value. |
MemoryPressureListener::MemoryPressureLevel GetMemoryPressureLevelFromFillLevel( |
- int memory_fill_level) { |
- if (memory_fill_level < kMemoryPressureModerateThresholdPercent) |
+ int actual_fill_level, int moderate_threshold, int critical_threshold) { |
+ if (actual_fill_level < moderate_threshold) |
return MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE; |
- return memory_fill_level < kMemoryPressureCriticalThresholdPercent ? |
+ return actual_fill_level < critical_threshold ? |
MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE : |
MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL; |
} |
} // namespace |
-MemoryPressureObserverChromeOS::MemoryPressureObserverChromeOS() |
+MemoryPressureObserverChromeOS::MemoryPressureObserverChromeOS( |
+ MemoryPressureThresholds thresholds) |
: current_memory_pressure_level_( |
MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE), |
moderate_pressure_repeat_count_(0), |
+ moderate_pressure_threshold_( |
+ (thresholds == AGGRESSIVE_MODERATE_THRESHOLD || |
Charlie Reis
2015/01/21 17:42:05
Might this be easier to read with helper functions
Mr4D (OOO till 08-26)
2015/01/21 18:52:14
Done.
|
+ thresholds == AGGRESSIVE_THRESHOLDS)? |
+ kAggressiveMemoryPressureModerateThresholdPercent : |
+ kNormalMemoryPressureModerateThresholdPercent), |
+ critical_pressure_threshold_( |
+ (thresholds == AGGRESSIVE_CRITICAL_THRESHOLD || |
+ thresholds == AGGRESSIVE_THRESHOLDS)? |
+ kAggressiveMemoryPressureCriticalThresholdPercent : |
+ kNormalMemoryPressureCriticalThresholdPercent), |
weak_ptr_factory_(this) { |
StartObserving(); |
} |
@@ -74,7 +87,9 @@ void MemoryPressureObserverChromeOS::CheckMemoryPressure() { |
MemoryPressureListener::MemoryPressureLevel old_pressure = |
current_memory_pressure_level_; |
current_memory_pressure_level_ = |
- GetMemoryPressureLevelFromFillLevel(GetUsedMemoryInPercent()); |
+ GetMemoryPressureLevelFromFillLevel(GetUsedMemoryInPercent(), |
+ moderate_pressure_threshold_, |
+ critical_pressure_threshold_); |
// In case there is no memory pressure we do not notify. |
if (current_memory_pressure_level_ == |
MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE) { |