OLD | NEW |
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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 return false; | 214 return false; |
215 } | 215 } |
216 | 216 |
217 void VariationsSeedProcessor::CreateTrialFromStudy( | 217 void VariationsSeedProcessor::CreateTrialFromStudy( |
218 const ProcessedStudy& processed_study, | 218 const ProcessedStudy& processed_study, |
219 const UIStringOverrideCallback& override_callback, | 219 const UIStringOverrideCallback& override_callback, |
220 const base::FieldTrial::EntropyProvider* low_entropy_provider, | 220 const base::FieldTrial::EntropyProvider* low_entropy_provider, |
221 base::FeatureList* feature_list) { | 221 base::FeatureList* feature_list) { |
222 const Study& study = *processed_study.study(); | 222 const Study& study = *processed_study.study(); |
223 | 223 |
| 224 // If the trial already exists, check if the selected group exists in the |
| 225 // |processed_study|. If not, there is nothing to do here. |
| 226 base::FieldTrial* existing_trial = base::FieldTrialList::Find(study.name()); |
| 227 if (existing_trial) { |
| 228 int experiment_index = processed_study.GetExperimentIndexByName( |
| 229 existing_trial->GetGroupNameWithoutActivation()); |
| 230 if (experiment_index == -1) |
| 231 return; |
| 232 } |
| 233 |
224 // Check if any experiments need to be forced due to a command line | 234 // Check if any experiments need to be forced due to a command line |
225 // flag. Force the first experiment with an existing flag. | 235 // flag. Force the first experiment with an existing flag. |
226 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 236 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
227 for (int i = 0; i < study.experiment_size(); ++i) { | 237 for (int i = 0; i < study.experiment_size(); ++i) { |
228 const Study_Experiment& experiment = study.experiment(i); | 238 const Study_Experiment& experiment = study.experiment(i); |
229 if (ShouldForceExperiment(experiment, *command_line, *feature_list)) { | 239 if (ShouldForceExperiment(experiment, *command_line, *feature_list)) { |
230 base::FieldTrial* trial = base::FieldTrialList::CreateFieldTrial( | 240 base::FieldTrial* trial = base::FieldTrialList::CreateFieldTrial( |
231 study.name(), experiment.name()); | 241 study.name(), experiment.name()); |
232 // If |trial| is null, then there might already be a trial forced to a | 242 // If |trial| is null, then there might already be a trial forced to a |
233 // different group (e.g. via --force-fieldtrials). Break out of the loop, | 243 // different group (e.g. via --force-fieldtrials). Break out of the loop, |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 // The field trial was defined from |study|, so the active experiment's name | 332 // The field trial was defined from |study|, so the active experiment's name |
323 // must be in the |study|. | 333 // must be in the |study|. |
324 DCHECK_NE(-1, experiment_index); | 334 DCHECK_NE(-1, experiment_index); |
325 | 335 |
326 ApplyUIStringOverrides(study.experiment(experiment_index), | 336 ApplyUIStringOverrides(study.experiment(experiment_index), |
327 override_callback); | 337 override_callback); |
328 } | 338 } |
329 } | 339 } |
330 | 340 |
331 } // namespace variations | 341 } // namespace variations |
OLD | NEW |