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

Unified Diff: chrome/browser/profile_resetter/automatic_profile_resetter.cc

Issue 61883005: Improved performance of fetching variation parameters in AutomaticProfileResetter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed compiler warnings about unused code. Created 7 years, 1 month 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/profile_resetter/automatic_profile_resetter.cc
diff --git a/chrome/browser/profile_resetter/automatic_profile_resetter.cc b/chrome/browser/profile_resetter/automatic_profile_resetter.cc
index d5dcf39e41ca468078e2badd8aa4a6c806277971..7e33fe75ad39305faa2c489ed0973ccaa5a7cccb 100644
--- a/chrome/browser/profile_resetter/automatic_profile_resetter.cc
+++ b/chrome/browser/profile_resetter/automatic_profile_resetter.cc
@@ -57,8 +57,10 @@ namespace {
const char kAutomaticProfileResetStudyName[] = "AutomaticProfileReset";
const char kAutomaticProfileResetStudyDryRunGroupName[] = "DryRun";
const char kAutomaticProfileResetStudyEnabledGroupName[] = "Enabled";
+#if defined(GOOGLE_CHROME_BUILD)
const char kAutomaticProfileResetStudyProgramParameterName[] = "program";
const char kAutomaticProfileResetStudyHashSeedParameterName[] = "hash_seed";
+#endif
// How long to wait after start-up before unleashing the evaluation flow.
const int64 kEvaluationFlowDelayInSeconds = 55;
@@ -133,18 +135,25 @@ bool ShouldPerformLiveRun() {
kAutomaticProfileResetStudyEnabledGroupName, true);
}
-// Returns whether or not the currently active experiment group prescribes the
-// program and hash seed to use instead of the baked-in ones.
-bool DoesExperimentOverrideProgramAndHashSeed() {
+// If the currently active experiment group prescribes a |program| and
+// |hash_seed| to use instead of the baked-in ones, retrieves those and returns
+// true. Otherwise, returns false.
+bool GetProgramAndHashSeedOverridesFromExperiment(std::string* program,
+ std::string* hash_seed) {
+ DCHECK(program);
+ DCHECK(hash_seed);
#if defined(GOOGLE_CHROME_BUILD)
std::map<std::string, std::string> params;
chrome_variations::GetVariationParams(kAutomaticProfileResetStudyName,
&params);
- return params.count(kAutomaticProfileResetStudyProgramParameterName) &&
- params.count(kAutomaticProfileResetStudyHashSeedParameterName);
-#else
- return false;
+ if (params.count(kAutomaticProfileResetStudyProgramParameterName) &&
+ params.count(kAutomaticProfileResetStudyHashSeedParameterName)) {
+ program->swap(params[kAutomaticProfileResetStudyProgramParameterName]);
+ hash_seed->swap(params[kAutomaticProfileResetStudyHashSeedParameterName]);
+ return true;
+ }
#endif
+ return false;
}
// Deep-copies all preferences in |source| to a sub-tree named |value_tree_key|
@@ -209,24 +218,19 @@ void AutomaticProfileResetter::Initialize() {
return;
}
- ui::ResourceBundle& resources(ui::ResourceBundle::GetSharedInstance());
- if (DoesExperimentOverrideProgramAndHashSeed()) {
- program_ = chrome_variations::GetVariationParamValue(
- kAutomaticProfileResetStudyName,
- kAutomaticProfileResetStudyProgramParameterName);
- hash_seed_ = chrome_variations::GetVariationParamValue(
- kAutomaticProfileResetStudyName,
- kAutomaticProfileResetStudyHashSeedParameterName);
- } else if (ShouldPerformLiveRun()) {
- program_ = resources.GetRawDataResource(
- IDR_AUTOMATIC_PROFILE_RESET_RULES).as_string();
- hash_seed_ = resources.GetRawDataResource(
- IDR_AUTOMATIC_PROFILE_RESET_HASH_SEED).as_string();
- } else { // ShouldPerformDryRun()
- program_ = resources.GetRawDataResource(
- IDR_AUTOMATIC_PROFILE_RESET_RULES_DRY).as_string();
- hash_seed_ = resources.GetRawDataResource(
- IDR_AUTOMATIC_PROFILE_RESET_HASH_SEED_DRY).as_string();
+ if (!GetProgramAndHashSeedOverridesFromExperiment(&program_, &hash_seed_)) {
+ ui::ResourceBundle& resources(ui::ResourceBundle::GetSharedInstance());
+ if (ShouldPerformLiveRun()) {
+ program_ = resources.GetRawDataResource(
+ IDR_AUTOMATIC_PROFILE_RESET_RULES).as_string();
+ hash_seed_ = resources.GetRawDataResource(
+ IDR_AUTOMATIC_PROFILE_RESET_HASH_SEED).as_string();
+ } else { // ShouldPerformDryRun()
+ program_ = resources.GetRawDataResource(
+ IDR_AUTOMATIC_PROFILE_RESET_RULES_DRY).as_string();
+ hash_seed_ = resources.GetRawDataResource(
+ IDR_AUTOMATIC_PROFILE_RESET_HASH_SEED_DRY).as_string();
+ }
}
delegate_.reset(new AutomaticProfileResetterDelegateImpl(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698