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 <map> | 7 #include <map> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // Check if any experiments need to be forced due to a command line | 104 // Check if any experiments need to be forced due to a command line |
105 // flag. Force the first experiment with an existing flag. | 105 // flag. Force the first experiment with an existing flag. |
106 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 106 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
107 for (int i = 0; i < study.experiment_size(); ++i) { | 107 for (int i = 0; i < study.experiment_size(); ++i) { |
108 const Study_Experiment& experiment = study.experiment(i); | 108 const Study_Experiment& experiment = study.experiment(i); |
109 if (experiment.has_forcing_flag() && | 109 if (experiment.has_forcing_flag() && |
110 command_line->HasSwitch(experiment.forcing_flag())) { | 110 command_line->HasSwitch(experiment.forcing_flag())) { |
111 scoped_refptr<base::FieldTrial> trial( | 111 scoped_refptr<base::FieldTrial> trial( |
112 base::FieldTrialList::CreateFieldTrial(study.name(), | 112 base::FieldTrialList::CreateFieldTrial(study.name(), |
113 experiment.name())); | 113 experiment.name())); |
| 114 // If |trial| is NULL, then there might already be a trial forced to a |
| 115 // different group (e.g. via --force-fieldtrials). Break out of the loop, |
| 116 // but don't return, so that variation ids and params for the selected |
| 117 // group will still be picked up. |
| 118 if (!trial) |
| 119 break; |
| 120 |
114 RegisterExperimentParams(study, experiment); | 121 RegisterExperimentParams(study, experiment); |
115 RegisterVariationIds(experiment, study.name()); | 122 RegisterVariationIds(experiment, study.name()); |
116 if (study.activation_type() == Study_ActivationType_ACTIVATION_AUTO) { | 123 if (study.activation_type() == Study_ActivationType_ACTIVATION_AUTO) { |
117 trial->group(); | 124 trial->group(); |
118 // UI Strings can only be overridden from ACTIVATION_AUTO experiments. | 125 // UI Strings can only be overridden from ACTIVATION_AUTO experiments. |
119 ApplyUIStringOverrides(experiment, override_callback); | 126 ApplyUIStringOverrides(experiment, override_callback); |
120 } | 127 } |
121 | 128 |
122 DVLOG(1) << "Trial " << study.name() << " forced by flag: " | 129 DVLOG(1) << "Trial " << study.name() << " forced by flag: " |
123 << experiment.forcing_flag(); | 130 << experiment.forcing_flag(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 // The field trial was defined from |study|, so the active experiment's name | 187 // The field trial was defined from |study|, so the active experiment's name |
181 // must be in the |study|. | 188 // must be in the |study|. |
182 DCHECK_NE(-1, experiment_index); | 189 DCHECK_NE(-1, experiment_index); |
183 | 190 |
184 ApplyUIStringOverrides(study.experiment(experiment_index), | 191 ApplyUIStringOverrides(study.experiment(experiment_index), |
185 override_callback); | 192 override_callback); |
186 } | 193 } |
187 } | 194 } |
188 | 195 |
189 } // namespace variations | 196 } // namespace variations |
OLD | NEW |