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

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

Issue 1984003002: Use low entropy for studies that send experiment IDs to Google properties. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months 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
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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 const VariationsSeed& seed, 180 const VariationsSeed& seed,
181 const std::string& locale, 181 const std::string& locale,
182 const base::Time& reference_date, 182 const base::Time& reference_date,
183 const base::Version& version, 183 const base::Version& version,
184 Study_Channel channel, 184 Study_Channel channel,
185 Study_FormFactor form_factor, 185 Study_FormFactor form_factor,
186 const std::string& hardware_class, 186 const std::string& hardware_class,
187 const std::string& session_consistency_country, 187 const std::string& session_consistency_country,
188 const std::string& permanent_consistency_country, 188 const std::string& permanent_consistency_country,
189 const UIStringOverrideCallback& override_callback, 189 const UIStringOverrideCallback& override_callback,
190 const base::FieldTrial::EntropyProvider* low_entropy_provider,
190 base::FeatureList* feature_list) { 191 base::FeatureList* feature_list) {
191 std::vector<ProcessedStudy> filtered_studies; 192 std::vector<ProcessedStudy> filtered_studies;
192 FilterAndValidateStudies(seed, locale, reference_date, version, channel, 193 FilterAndValidateStudies(seed, locale, reference_date, version, channel,
193 form_factor, hardware_class, 194 form_factor, hardware_class,
194 session_consistency_country, 195 session_consistency_country,
195 permanent_consistency_country, &filtered_studies); 196 permanent_consistency_country, &filtered_studies);
196 197
197 for (size_t i = 0; i < filtered_studies.size(); ++i) 198 for (size_t i = 0; i < filtered_studies.size(); ++i)
198 CreateTrialFromStudy(filtered_studies[i], override_callback, feature_list); 199 CreateTrialFromStudy(filtered_studies[i], override_callback,
200 low_entropy_provider, feature_list);
201 }
202
203 // static
204 bool VariationsSeedProcessor::ShouldStudyUseLowEntropy(const Study& study) {
205 for (int i = 0; i < study.experiment_size(); ++i) {
206 const Study_Experiment& experiment = study.experiment(i);
207 if (experiment.has_google_web_experiment_id() ||
208 experiment.has_google_web_trigger_experiment_id() ||
209 experiment.has_google_update_experiment_id() ||
210 experiment.has_chrome_sync_experiment_id()) {
211 return true;
212 }
213 }
214 return false;
199 } 215 }
200 216
201 void VariationsSeedProcessor::CreateTrialFromStudy( 217 void VariationsSeedProcessor::CreateTrialFromStudy(
202 const ProcessedStudy& processed_study, 218 const ProcessedStudy& processed_study,
203 const UIStringOverrideCallback& override_callback, 219 const UIStringOverrideCallback& override_callback,
220 const base::FieldTrial::EntropyProvider* low_entropy_provider,
204 base::FeatureList* feature_list) { 221 base::FeatureList* feature_list) {
205 const Study& study = *processed_study.study(); 222 const Study& study = *processed_study.study();
206 223
207 // Check if any experiments need to be forced due to a command line 224 // Check if any experiments need to be forced due to a command line
208 // flag. Force the first experiment with an existing flag. 225 // flag. Force the first experiment with an existing flag.
209 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 226 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
210 for (int i = 0; i < study.experiment_size(); ++i) { 227 for (int i = 0; i < study.experiment_size(); ++i) {
211 const Study_Experiment& experiment = study.experiment(i); 228 const Study_Experiment& experiment = study.experiment(i);
212 if (ShouldForceExperiment(experiment, *command_line, *feature_list)) { 229 if (ShouldForceExperiment(experiment, *command_line, *feature_list)) {
213 base::FieldTrial* trial = base::FieldTrialList::CreateFieldTrial( 230 base::FieldTrial* trial = base::FieldTrialList::CreateFieldTrial(
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 } 265 }
249 266
250 // The trial is created without specifying an expiration date because the 267 // The trial is created without specifying an expiration date because the
251 // 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,
252 // the expiration check using |reference_date| is done explicitly below. 269 // the expiration check using |reference_date| is done explicitly below.
253 scoped_refptr<base::FieldTrial> trial( 270 scoped_refptr<base::FieldTrial> trial(
254 base::FieldTrialList::FactoryGetFieldTrialWithRandomizationSeed( 271 base::FieldTrialList::FactoryGetFieldTrialWithRandomizationSeed(
255 study.name(), processed_study.total_probability(), 272 study.name(), processed_study.total_probability(),
256 study.default_experiment_name(), 273 study.default_experiment_name(),
257 base::FieldTrialList::kNoExpirationYear, 1, 1, randomization_type, 274 base::FieldTrialList::kNoExpirationYear, 1, 1, randomization_type,
258 randomization_seed, NULL)); 275 randomization_seed, NULL,
276 ShouldStudyUseLowEntropy(study) ? low_entropy_provider : NULL));
259 277
260 bool has_overrides = false; 278 bool has_overrides = false;
261 bool enables_or_disables_features = false; 279 bool enables_or_disables_features = false;
262 for (int i = 0; i < study.experiment_size(); ++i) { 280 for (int i = 0; i < study.experiment_size(); ++i) {
263 const Study_Experiment& experiment = study.experiment(i); 281 const Study_Experiment& experiment = study.experiment(i);
264 RegisterExperimentParams(study, experiment); 282 RegisterExperimentParams(study, experiment);
265 283
266 // Groups with forcing flags have probability 0 and will never be selected. 284 // Groups with forcing flags have probability 0 and will never be selected.
267 // Therefore, there's no need to add them to the field trial. 285 // Therefore, there's no need to add them to the field trial.
268 if (experiment.has_forcing_flag() || 286 if (experiment.has_forcing_flag() ||
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 // The field trial was defined from |study|, so the active experiment's name 322 // The field trial was defined from |study|, so the active experiment's name
305 // must be in the |study|. 323 // must be in the |study|.
306 DCHECK_NE(-1, experiment_index); 324 DCHECK_NE(-1, experiment_index);
307 325
308 ApplyUIStringOverrides(study.experiment(experiment_index), 326 ApplyUIStringOverrides(study.experiment(experiment_index),
309 override_callback); 327 override_callback);
310 } 328 }
311 } 329 }
312 330
313 } // namespace variations 331 } // namespace variations
OLDNEW
« no previous file with comments | « components/variations/variations_seed_processor.h ('k') | components/variations/variations_seed_processor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698