Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1704)

Unified Diff: chromeos/chromeos_switches.cc

Issue 897413002: Add a finch experiment for different memory pressure management strategies in ChromeOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address code reivew's comments. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/chromeos_switches.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « chromeos/chromeos_switches.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698