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

Side by Side Diff: components/variations/variations_seed_processor.cc

Issue 2463223002: Store field trial parameters in shared memory (Closed)
Patch Set: check that cache has been cleared in test Created 4 years 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 unified diff | Download patch
« no previous file with comments | « base/metrics/field_trial_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/variations/variations_seed_processor.h" 5 #include "components/variations/variations_seed_processor.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 #include <vector> 10 #include <vector>
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 79
80 // Forces the specified |experiment| to be enabled in |study|. 80 // Forces the specified |experiment| to be enabled in |study|.
81 void ForceExperimentState( 81 void ForceExperimentState(
82 const Study& study, 82 const Study& study,
83 const Study_Experiment& experiment, 83 const Study_Experiment& experiment,
84 const VariationsSeedProcessor::UIStringOverrideCallback& override_callback, 84 const VariationsSeedProcessor::UIStringOverrideCallback& override_callback,
85 base::FieldTrial* trial) { 85 base::FieldTrial* trial) {
86 RegisterExperimentParams(study, experiment); 86 RegisterExperimentParams(study, experiment);
87 RegisterVariationIds(experiment, study.name()); 87 RegisterVariationIds(experiment, study.name());
88 if (study.activation_type() == Study_ActivationType_ACTIVATION_AUTO) { 88 if (study.activation_type() == Study_ActivationType_ACTIVATION_AUTO) {
89 // This call must happen after all params have been registered for the
90 // trial. Otherwise, since we look up params by trial and group name, the
91 // params won't be registered under the correct key.
89 trial->group(); 92 trial->group();
90 // UI Strings can only be overridden from ACTIVATION_AUTO experiments. 93 // UI Strings can only be overridden from ACTIVATION_AUTO experiments.
91 ApplyUIStringOverrides(experiment, override_callback); 94 ApplyUIStringOverrides(experiment, override_callback);
92 } 95 }
93 } 96 }
94 97
95 // Registers feature overrides for the chosen experiment in the specified study. 98 // Registers feature overrides for the chosen experiment in the specified study.
96 void RegisterFeatureOverrides(const ProcessedStudy& processed_study, 99 void RegisterFeatureOverrides(const ProcessedStudy& processed_study,
97 base::FieldTrial* trial, 100 base::FieldTrial* trial,
98 base::FeatureList* feature_list) { 101 base::FeatureList* feature_list) {
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 } 306 }
304 307
305 trial->SetForced(); 308 trial->SetForced();
306 if (processed_study.is_expired()) 309 if (processed_study.is_expired())
307 trial->Disable(); 310 trial->Disable();
308 311
309 if (enables_or_disables_features) 312 if (enables_or_disables_features)
310 RegisterFeatureOverrides(processed_study, trial.get(), feature_list); 313 RegisterFeatureOverrides(processed_study, trial.get(), feature_list);
311 314
312 if (study.activation_type() == Study_ActivationType_ACTIVATION_AUTO) { 315 if (study.activation_type() == Study_ActivationType_ACTIVATION_AUTO) {
316 // This call must happen after all params have been registered for the
317 // trial. Otherwise, since we look up params by trial and group name, the
318 // params won't be registered under the correct key.
313 const std::string& group_name = trial->group_name(); 319 const std::string& group_name = trial->group_name();
314 320
315 // Don't try to apply overrides if none of the experiments in this study had 321 // Don't try to apply overrides if none of the experiments in this study had
316 // any. 322 // any.
317 if (!has_overrides) 323 if (!has_overrides)
318 return; 324 return;
319 325
320 // UI Strings can only be overridden from ACTIVATION_AUTO experiments. 326 // UI Strings can only be overridden from ACTIVATION_AUTO experiments.
321 int experiment_index = processed_study.GetExperimentIndexByName(group_name); 327 int experiment_index = processed_study.GetExperimentIndexByName(group_name);
322 328
323 // The field trial was defined from |study|, so the active experiment's name 329 // The field trial was defined from |study|, so the active experiment's name
324 // must be in the |study|. 330 // must be in the |study|.
325 DCHECK_NE(-1, experiment_index); 331 DCHECK_NE(-1, experiment_index);
326 332
327 ApplyUIStringOverrides(study.experiment(experiment_index), 333 ApplyUIStringOverrides(study.experiment(experiment_index),
328 override_callback); 334 override_callback);
329 } 335 }
330 } 336 }
331 337
332 } // namespace variations 338 } // namespace variations
OLDNEW
« no previous file with comments | « base/metrics/field_trial_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698