Chromium Code Reviews| Index: chrome/browser/memory/chrome_memory_coordinator_delegate.cc |
| diff --git a/chrome/browser/memory/chrome_memory_coordinator_delegate.cc b/chrome/browser/memory/chrome_memory_coordinator_delegate.cc |
| index 672b203569a5a65f9071cc5d4eb783f726a64b80..f9677a55a4d11dc93b0a4fbb7b9bd40cb5309013 100644 |
| --- a/chrome/browser/memory/chrome_memory_coordinator_delegate.cc |
| +++ b/chrome/browser/memory/chrome_memory_coordinator_delegate.cc |
| @@ -5,11 +5,45 @@ |
| #include "chrome/browser/memory/chrome_memory_coordinator_delegate.h" |
| #include "base/memory/ptr_util.h" |
| +#include "base/strings/string_number_conversions.h" |
| #include "chrome/browser/browser_process.h" |
| #include "chrome/browser/memory/tab_manager.h" |
| +#include "components/variations/variations_associated_data.h" |
| namespace memory { |
| +namespace { |
| + |
| +void SetIntVariationParameter( |
| + const std::map<std::string, std::string> variations, |
| + const char* name, |
| + int* target) { |
| + const auto& iter = variations.find(name); |
| + if (iter == variations.end()) |
| + return; |
| + int value; |
| + if (!iter->second.empty() && base::StringToInt(iter->second, &value)) { |
| + DCHECK(value > 0); |
| + *target = value; |
| + } |
| +} |
| + |
| +void SetSecondsVariationParameter( |
| + const std::map<std::string, std::string> variations, |
| + const char* name, |
| + base::TimeDelta* target) { |
| + const auto& iter = variations.find(name); |
| + if (iter == variations.end()) |
| + return; |
| + int value; |
| + if (!iter->second.empty() && base::StringToInt(iter->second, &value)) { |
| + DCHECK(value > 0); |
| + *target = base::TimeDelta::FromSeconds(value); |
| + } |
| +} |
| + |
| +} // namespace |
| + |
| // static |
| std::unique_ptr<content::MemoryCoordinatorDelegate> |
| ChromeMemoryCoordinatorDelegate::Create() { |
| @@ -31,4 +65,26 @@ bool ChromeMemoryCoordinatorDelegate::CanSuspendBackgroundedRenderer( |
| #endif |
| } |
| +void ChromeMemoryCoordinatorDelegate::OverrideParameters( |
| + content::MemoryCoordinatorV0Params* params) { |
| + // Override default parameters with variations. |
| + static constexpr char kMemoryCoordinatorV0Trial[] = "MemoryCoordinatorV0"; |
|
bashi
2016/11/18 20:07:27
I added "V0" suffix because we might want to do di
|
| + std::map<std::string, std::string> variations; |
| + variations::GetVariationParams(kMemoryCoordinatorV0Trial, &variations); |
| + SetIntVariationParameter(variations, "expected_renderer_size", |
| + ¶ms->expected_renderer_size); |
| + SetIntVariationParameter(variations, "new_renderers_until_throttled", |
| + ¶ms->new_renderers_until_throttled); |
| + SetIntVariationParameter(variations, "new_renderers_until_suspended", |
| + ¶ms->new_renderers_until_suspended); |
| + SetIntVariationParameter(variations, "new_renderers_back_to_normal", |
| + ¶ms->new_renderers_back_to_normal); |
| + SetIntVariationParameter(variations, "new_renderers_back_to_throttled", |
| + ¶ms->new_renderers_back_to_throttled); |
| + SetSecondsVariationParameter(variations, "minimum_transition_period", |
| + ¶ms->minimum_transition_period); |
| + SetSecondsVariationParameter(variations, "monitoring_interval", |
| + ¶ms->monitoring_interval); |
| +} |
| + |
| } // namespace memory |