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

Unified Diff: base/chromeos/memory_pressure_observer_chromeos.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: 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
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

Powered by Google App Engine
This is Rietveld 408576698