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> |
11 | 11 |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/feature_list.h" | 13 #include "base/feature_list.h" |
14 #include "base/metrics/field_trial.h" | 14 #include "base/metrics/field_trial.h" |
15 #include "base/metrics/histogram_macros.h" | 15 #include "base/metrics/histogram_macros.h" |
16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
17 #include "components/variations/client_filterable_state.h" | |
17 #include "components/variations/processed_study.h" | 18 #include "components/variations/processed_study.h" |
18 #include "components/variations/study_filtering.h" | 19 #include "components/variations/study_filtering.h" |
19 #include "components/variations/variations_associated_data.h" | 20 #include "components/variations/variations_associated_data.h" |
20 | 21 |
21 namespace variations { | 22 namespace variations { |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
25 // Associates the variations params of |experiment|, if present. | 26 // Associates the variations params of |experiment|, if present. |
26 void RegisterExperimentParams(const Study& study, | 27 void RegisterExperimentParams(const Study& study, |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
168 } // namespace | 169 } // namespace |
169 | 170 |
170 VariationsSeedProcessor::VariationsSeedProcessor() { | 171 VariationsSeedProcessor::VariationsSeedProcessor() { |
171 } | 172 } |
172 | 173 |
173 VariationsSeedProcessor::~VariationsSeedProcessor() { | 174 VariationsSeedProcessor::~VariationsSeedProcessor() { |
174 } | 175 } |
175 | 176 |
176 void VariationsSeedProcessor::CreateTrialsFromSeed( | 177 void VariationsSeedProcessor::CreateTrialsFromSeed( |
177 const VariationsSeed& seed, | 178 const VariationsSeed& seed, |
178 const std::string& locale, | 179 const ClientFilterableState& client_state, |
179 const base::Time& reference_date, | |
180 const base::Version& version, | |
181 Study_Channel channel, | |
182 Study_FormFactor form_factor, | |
183 const std::string& hardware_class, | |
184 const std::string& session_consistency_country, | |
185 const std::string& permanent_consistency_country, | |
186 const UIStringOverrideCallback& override_callback, | 180 const UIStringOverrideCallback& override_callback, |
187 const base::FieldTrial::EntropyProvider* low_entropy_provider, | 181 const base::FieldTrial::EntropyProvider* low_entropy_provider, |
188 base::FeatureList* feature_list) { | 182 base::FeatureList* feature_list) { |
189 std::vector<ProcessedStudy> filtered_studies; | 183 std::vector<ProcessedStudy> filtered_studies; |
190 FilterAndValidateStudies(seed, locale, reference_date, version, channel, | 184 FilterAndValidateStudies(seed, client_state, &filtered_studies); |
191 form_factor, hardware_class, | |
192 session_consistency_country, | |
193 permanent_consistency_country, &filtered_studies); | |
194 | 185 |
195 for (size_t i = 0; i < filtered_studies.size(); ++i) | 186 for (size_t i = 0; i < filtered_studies.size(); ++i) { |
Alexei Svitkine (slow)
2017/06/07 15:18:08
Nit: Change to C++11 for loop syntax if you're tou
Ilya Sherman
2017/06/07 21:50:08
Done.
| |
196 CreateTrialFromStudy(filtered_studies[i], override_callback, | 187 CreateTrialFromStudy(filtered_studies[i], override_callback, |
197 low_entropy_provider, feature_list); | 188 low_entropy_provider, feature_list); |
189 } | |
198 } | 190 } |
199 | 191 |
200 // static | 192 // static |
201 bool VariationsSeedProcessor::ShouldStudyUseLowEntropy(const Study& study) { | 193 bool VariationsSeedProcessor::ShouldStudyUseLowEntropy(const Study& study) { |
202 for (int i = 0; i < study.experiment_size(); ++i) { | 194 for (int i = 0; i < study.experiment_size(); ++i) { |
203 const Study_Experiment& experiment = study.experiment(i); | 195 const Study_Experiment& experiment = study.experiment(i); |
204 if (experiment.has_google_web_experiment_id() || | 196 if (experiment.has_google_web_experiment_id() || |
205 experiment.has_google_web_trigger_experiment_id() || | 197 experiment.has_google_web_trigger_experiment_id() || |
206 experiment.has_chrome_sync_experiment_id()) { | 198 experiment.has_chrome_sync_experiment_id()) { |
207 return true; | 199 return true; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
331 // Although not normally expected, but could happen in exception cases, see | 323 // Although not normally expected, but could happen in exception cases, see |
332 // tests: ExpiredStudy_NoDefaultGroup, ExistingFieldTrial_ExpiredByConfig | 324 // tests: ExpiredStudy_NoDefaultGroup, ExistingFieldTrial_ExpiredByConfig |
333 if (experiment_index != -1) { | 325 if (experiment_index != -1) { |
334 ApplyUIStringOverrides(study.experiment(experiment_index), | 326 ApplyUIStringOverrides(study.experiment(experiment_index), |
335 override_callback); | 327 override_callback); |
336 } | 328 } |
337 } | 329 } |
338 } | 330 } |
339 | 331 |
340 } // namespace variations | 332 } // namespace variations |
OLD | NEW |