Chromium Code Reviews| 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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 268 // expiration check in field_trial.cc is based on the build date. Instead, | 268 // expiration check in field_trial.cc is based on the build date. Instead, |
| 269 // the expiration check using |reference_date| is done explicitly below. | 269 // the expiration check using |reference_date| is done explicitly below. |
| 270 scoped_refptr<base::FieldTrial> trial( | 270 scoped_refptr<base::FieldTrial> trial( |
| 271 base::FieldTrialList::FactoryGetFieldTrialWithRandomizationSeed( | 271 base::FieldTrialList::FactoryGetFieldTrialWithRandomizationSeed( |
| 272 study.name(), processed_study.total_probability(), | 272 study.name(), processed_study.total_probability(), |
| 273 study.default_experiment_name(), | 273 study.default_experiment_name(), |
| 274 base::FieldTrialList::kNoExpirationYear, 1, 1, randomization_type, | 274 base::FieldTrialList::kNoExpirationYear, 1, 1, randomization_type, |
| 275 randomization_seed, NULL, | 275 randomization_seed, NULL, |
| 276 ShouldStudyUseLowEntropy(study) ? low_entropy_provider : NULL)); | 276 ShouldStudyUseLowEntropy(study) ? low_entropy_provider : NULL)); |
| 277 | 277 |
| 278 // If the trial previously existed (created from command-line flags or from | |
| 279 // about:flags), the factory returns the existing trial keeping its selected | |
| 280 // group intact. If this selected group does not exist in this | |
| 281 // |processed_study|, we have nothing to do here any more. | |
| 282 const std::string& group_name = trial->group_name(); | |
|
Alexei Svitkine (slow)
2016/06/30 21:50:59
Nit: Just inline this into the call below.
jkrcal
2016/07/01 10:40:54
Done.
| |
| 283 int experiment_index = processed_study.GetExperimentIndexByName(group_name); | |
| 284 if (experiment_index == -1) return; | |
|
Alexei Svitkine (slow)
2016/06/30 21:50:59
Nit: Put return on next line.
jkrcal
2016/07/01 10:40:54
Done.
| |
| 285 | |
| 278 bool has_overrides = false; | 286 bool has_overrides = false; |
| 279 bool enables_or_disables_features = false; | 287 bool enables_or_disables_features = false; |
| 280 for (int i = 0; i < study.experiment_size(); ++i) { | 288 for (int i = 0; i < study.experiment_size(); ++i) { |
| 281 const Study_Experiment& experiment = study.experiment(i); | 289 const Study_Experiment& experiment = study.experiment(i); |
| 282 RegisterExperimentParams(study, experiment); | 290 RegisterExperimentParams(study, experiment); |
| 283 | 291 |
| 284 // Groups with forcing flags have probability 0 and will never be selected. | 292 // Groups with forcing flags have probability 0 and will never be selected. |
| 285 // Therefore, there's no need to add them to the field trial. | 293 // Therefore, there's no need to add them to the field trial. |
| 286 if (experiment.has_forcing_flag() || | 294 if (experiment.has_forcing_flag() || |
| 287 experiment.feature_association().has_forcing_feature_on() || | 295 experiment.feature_association().has_forcing_feature_on() || |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 302 } | 310 } |
| 303 | 311 |
| 304 trial->SetForced(); | 312 trial->SetForced(); |
| 305 if (processed_study.is_expired()) | 313 if (processed_study.is_expired()) |
| 306 trial->Disable(); | 314 trial->Disable(); |
| 307 | 315 |
| 308 if (enables_or_disables_features) | 316 if (enables_or_disables_features) |
| 309 RegisterFeatureOverrides(processed_study, trial.get(), feature_list); | 317 RegisterFeatureOverrides(processed_study, trial.get(), feature_list); |
| 310 | 318 |
| 311 if (study.activation_type() == Study_ActivationType_ACTIVATION_AUTO) { | 319 if (study.activation_type() == Study_ActivationType_ACTIVATION_AUTO) { |
| 312 const std::string& group_name = trial->group_name(); | |
| 313 | |
| 314 // Don't try to apply overrides if none of the experiments in this study had | 320 // Don't try to apply overrides if none of the experiments in this study had |
| 315 // any. | 321 // any. |
| 316 if (!has_overrides) | 322 if (!has_overrides) |
| 317 return; | 323 return; |
| 318 | 324 |
| 319 // UI Strings can only be overridden from ACTIVATION_AUTO experiments. | |
| 320 int experiment_index = processed_study.GetExperimentIndexByName(group_name); | |
| 321 | |
| 322 // The field trial was defined from |study|, so the active experiment's name | |
| 323 // must be in the |study|. | |
| 324 DCHECK_NE(-1, experiment_index); | |
| 325 | |
| 326 ApplyUIStringOverrides(study.experiment(experiment_index), | 325 ApplyUIStringOverrides(study.experiment(experiment_index), |
| 327 override_callback); | 326 override_callback); |
| 328 } | 327 } |
| 329 } | 328 } |
| 330 | 329 |
| 331 } // namespace variations | 330 } // namespace variations |
| OLD | NEW |