Chromium Code Reviews| Index: chromeos/chromeos_switches.cc |
| diff --git a/chromeos/chromeos_switches.cc b/chromeos/chromeos_switches.cc |
| index 6ac7d2e345844d6598483c3b419c99e3294e5d26..e603cfe125bcd8d519022abafbca2864ab42b4f0 100644 |
| --- a/chromeos/chromeos_switches.cc |
| +++ b/chromeos/chromeos_switches.cc |
| @@ -5,6 +5,7 @@ |
| #include "chromeos/chromeos_switches.h" |
| #include "base/command_line.h" |
| +#include "base/metrics/field_trial.h" |
| // TODO(rsorokin): alphabetize all of these switches so they |
| // match the order from the .h file |
| @@ -224,6 +225,10 @@ const char kLoginUser[] = "login-user"; |
| // The memory pressure thresholds selection which is used to decide when a |
| // memory pressure event needs to get fired. |
| const char kMemoryPressureThresholds[] = "memory-pressure-thresholds"; |
| +const char kConservativeThreshold[] = "conservative"; |
| +const char kAggressiveCacheDiscardThreshold[] = "aggressive-cache-discard"; |
| +const char kAggressiveTabDiscardThreshold[] = "aggressive-tab-discard"; |
| +const char kAggressiveThreshold[] = "aggressive"; |
| // Enables natural scroll by default. |
| const char kNaturalScrollDefault[] = "enable-natural-scroll-default"; |
| @@ -313,25 +318,34 @@ bool WakeOnWifiEnabled() { |
| base::MemoryPressureObserverChromeOS::MemoryPressureThresholds |
| GetMemoryPressureThresholds() { |
| - if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| - kMemoryPressureThresholds)) { |
|
Mr4D (OOO till 08-26)
2015/02/09 00:54:54
The field trial code should go into the case that
|
| - return base::MemoryPressureObserverChromeOS::THRESHOLD_DEFAULT; |
| - } |
| const std::string option = |
| base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| kMemoryPressureThresholds); |
| - if (option == "1") { |
| + if (option == kConservativeThreshold) |
| return base::MemoryPressureObserverChromeOS::THRESHOLD_CONSERVATIVE; |
| - } |
| - if (option == "2") { |
| + if (option == kAggressiveCacheDiscardThreshold) |
| return base::MemoryPressureObserverChromeOS:: |
| THRESHOLD_AGGRESSIVE_CACHE_DISCARD; |
| - } |
| - if (option == "3") { |
| + if (option == kAggressiveTabDiscardThreshold) |
| return base::MemoryPressureObserverChromeOS:: |
| THRESHOLD_AGGRESSIVE_TAB_DISCARD; |
| - } |
| - return base::MemoryPressureObserverChromeOS::THRESHOLD_AGGRESSIVE; |
| + if (option == kAggressiveThreshold) |
| + return base::MemoryPressureObserverChromeOS::THRESHOLD_AGGRESSIVE; |
| + |
| + const std::string group_name = |
| + base::FieldTrialList::FindFullName(kMemoryPressureThresholds); |
| + if (group_name == kConservativeThreshold) |
| + return base::MemoryPressureObserverChromeOS::THRESHOLD_CONSERVATIVE; |
| + if (group_name == kAggressiveCacheDiscardThreshold) |
| + return base::MemoryPressureObserverChromeOS:: |
| + THRESHOLD_AGGRESSIVE_CACHE_DISCARD; |
| + if (group_name == kAggressiveTabDiscardThreshold) |
| + return base::MemoryPressureObserverChromeOS:: |
| + THRESHOLD_AGGRESSIVE_TAB_DISCARD; |
| + if (group_name == kAggressiveThreshold) |
| + return base::MemoryPressureObserverChromeOS::THRESHOLD_AGGRESSIVE; |
| + |
| + return base::MemoryPressureObserverChromeOS::THRESHOLD_DEFAULT; |
| } |
| } // namespace switches |