Chromium Code Reviews| 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 5691eb8b4ed1dbd626e85ef1ea617886396eeafd..641aa40d2d5ec704fd087b59c2f3b06545f1ed75 100644 |
| --- a/base/chromeos/memory_pressure_observer_chromeos.cc |
| +++ b/base/chromeos/memory_pressure_observer_chromeos.cc |
| @@ -4,7 +4,10 @@ |
| #include "base/chromeos/memory_pressure_observer_chromeos.h" |
| +#include "chromeos/chromeos_switches.h" |
| +#include "base/command_line.h" |
| #include "base/message_loop/message_loop.h" |
| +#include "base/metrics/field_trial.h" |
| #include "base/metrics/histogram_macros.h" |
| #include "base/process/process_metrics.h" |
| #include "base/time/time.h" |
| @@ -208,4 +211,33 @@ int MemoryPressureObserverChromeOS::GetUsedMemoryInPercent() { |
| return percentage; |
| } |
| +// static function |
| +MemoryPressureObserverChromeOS::MemoryPressureThresholds |
| +MemoryPressureObserverChromeOS::GetMemoryPressureThresholds() { |
|
Mr4D (OOO till 08-26)
2015/02/06 03:56:35
This should remain in chromeos_switches.cc. Having
|
| + const std::string option = |
| + base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| + chromeos::switches::kMemoryPressureThresholds); |
| + if (option == chromeos::switches::kConservativeThreshold) |
| + return MemoryPressureObserverChromeOS::THRESHOLD_CONSERVATIVE; |
| + if (option == chromeos::switches::kAggressiveCacheDiscardThreshold) |
| + return MemoryPressureObserverChromeOS::THRESHOLD_AGGRESSIVE_CACHE_DISCARD; |
| + if (option == chromeos::switches::kAggressiveTabDiscardThreshold) |
| + return MemoryPressureObserverChromeOS::THRESHOLD_AGGRESSIVE_TAB_DISCARD; |
| + if (option == chromeos::switches::kAggressiveThreshold) |
| + return MemoryPressureObserverChromeOS::THRESHOLD_AGGRESSIVE; |
| + |
| + const std::string group_name = base::FieldTrialList::FindFullName( |
| + chromeos::switches::kMemoryPressureThresholds); |
| + if (group_name == chromeos::switches::kConservativeThreshold) |
| + return MemoryPressureObserverChromeOS::THRESHOLD_CONSERVATIVE; |
| + if (group_name == chromeos::switches::kAggressiveCacheDiscardThreshold) |
| + return MemoryPressureObserverChromeOS::THRESHOLD_AGGRESSIVE_CACHE_DISCARD; |
| + if (group_name == chromeos::switches::kAggressiveTabDiscardThreshold) |
| + return MemoryPressureObserverChromeOS::THRESHOLD_AGGRESSIVE_TAB_DISCARD; |
| + if (group_name == chromeos::switches::kAggressiveThreshold) |
| + return MemoryPressureObserverChromeOS::THRESHOLD_AGGRESSIVE; |
| + |
| + return MemoryPressureObserverChromeOS::THRESHOLD_DEFAULT; |
| +} |
| + |
| } // namespace base |