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

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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 if (experiment.feature_association().has_forcing_feature_off()) { 161 if (experiment.feature_association().has_forcing_feature_off()) {
162 return feature_list.IsFeatureOverriddenFromCommandLine( 162 return feature_list.IsFeatureOverriddenFromCommandLine(
163 experiment.feature_association().forcing_feature_off(), 163 experiment.feature_association().forcing_feature_off(),
164 base::FeatureList::OVERRIDE_DISABLE_FEATURE); 164 base::FeatureList::OVERRIDE_DISABLE_FEATURE);
165 } 165 }
166 if (experiment.has_forcing_flag()) 166 if (experiment.has_forcing_flag())
167 return command_line.HasSwitch(experiment.forcing_flag()); 167 return command_line.HasSwitch(experiment.forcing_flag());
168 return false; 168 return false;
169 } 169 }
170 170
171 bool ShouldStudyUseLowEntropy(const Study& study) {
172 for (int i = 0; i < study.experiment_size(); ++i) {
173 const Study_Experiment& experiment = study.experiment(i);
174 if (experiment.has_google_web_experiment_id() ||
175 experiment.has_google_web_trigger_experiment_id() ||
176 experiment.has_google_update_experiment_id() ||
177 experiment.has_chrome_sync_experiment_id()) {
178 return true;
179 }
180 }
181 return false;
182 }
183
171 } // namespace 184 } // namespace
172 185
173 VariationsSeedProcessor::VariationsSeedProcessor() { 186 VariationsSeedProcessor::VariationsSeedProcessor() {
174 } 187 }
175 188
176 VariationsSeedProcessor::~VariationsSeedProcessor() { 189 VariationsSeedProcessor::~VariationsSeedProcessor() {
177 } 190 }
178 191
179 void VariationsSeedProcessor::CreateTrialsFromSeed( 192 void VariationsSeedProcessor::CreateTrialsFromSeed(
180 const VariationsSeed& seed, 193 const VariationsSeed& seed,
181 const std::string& locale, 194 const std::string& locale,
182 const base::Time& reference_date, 195 const base::Time& reference_date,
183 const base::Version& version, 196 const base::Version& version,
184 Study_Channel channel, 197 Study_Channel channel,
185 Study_FormFactor form_factor, 198 Study_FormFactor form_factor,
186 const std::string& hardware_class, 199 const std::string& hardware_class,
187 const std::string& session_consistency_country, 200 const std::string& session_consistency_country,
188 const std::string& permanent_consistency_country, 201 const std::string& permanent_consistency_country,
189 const UIStringOverrideCallback& override_callback, 202 const UIStringOverrideCallback& override_callback,
190 base::FeatureList* feature_list) { 203 base::FeatureList* feature_list,
204 const base::FieldTrial::EntropyProvider* low_entropy_provider) {
191 std::vector<ProcessedStudy> filtered_studies; 205 std::vector<ProcessedStudy> filtered_studies;
192 FilterAndValidateStudies(seed, locale, reference_date, version, channel, 206 FilterAndValidateStudies(seed, locale, reference_date, version, channel,
193 form_factor, hardware_class, 207 form_factor, hardware_class,
194 session_consistency_country, 208 session_consistency_country,
195 permanent_consistency_country, &filtered_studies); 209 permanent_consistency_country, &filtered_studies);
196 210
197 for (size_t i = 0; i < filtered_studies.size(); ++i) 211 for (size_t i = 0; i < filtered_studies.size(); ++i)
198 CreateTrialFromStudy(filtered_studies[i], override_callback, feature_list); 212 CreateTrialFromStudy(filtered_studies[i], override_callback, feature_list,
213 low_entropy_provider);
199 } 214 }
200 215
201 void VariationsSeedProcessor::CreateTrialFromStudy( 216 void VariationsSeedProcessor::CreateTrialFromStudy(
202 const ProcessedStudy& processed_study, 217 const ProcessedStudy& processed_study,
203 const UIStringOverrideCallback& override_callback, 218 const UIStringOverrideCallback& override_callback,
204 base::FeatureList* feature_list) { 219 base::FeatureList* feature_list,
220 const base::FieldTrial::EntropyProvider* low_entropy_provider) {
205 const Study& study = *processed_study.study(); 221 const Study& study = *processed_study.study();
206 222
207 // Check if any experiments need to be forced due to a command line 223 // Check if any experiments need to be forced due to a command line
208 // flag. Force the first experiment with an existing flag. 224 // flag. Force the first experiment with an existing flag.
209 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 225 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
210 for (int i = 0; i < study.experiment_size(); ++i) { 226 for (int i = 0; i < study.experiment_size(); ++i) {
211 const Study_Experiment& experiment = study.experiment(i); 227 const Study_Experiment& experiment = study.experiment(i);
212 if (ShouldForceExperiment(experiment, *command_line, *feature_list)) { 228 if (ShouldForceExperiment(experiment, *command_line, *feature_list)) {
213 base::FieldTrial* trial = base::FieldTrialList::CreateFieldTrial( 229 base::FieldTrial* trial = base::FieldTrialList::CreateFieldTrial(
214 study.name(), experiment.name()); 230 study.name(), experiment.name());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 } 264 }
249 265
250 // The trial is created without specifying an expiration date because the 266 // 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, 267 // expiration check in field_trial.cc is based on the build date. Instead,
252 // the expiration check using |reference_date| is done explicitly below. 268 // the expiration check using |reference_date| is done explicitly below.
253 scoped_refptr<base::FieldTrial> trial( 269 scoped_refptr<base::FieldTrial> trial(
254 base::FieldTrialList::FactoryGetFieldTrialWithRandomizationSeed( 270 base::FieldTrialList::FactoryGetFieldTrialWithRandomizationSeed(
255 study.name(), processed_study.total_probability(), 271 study.name(), processed_study.total_probability(),
256 study.default_experiment_name(), 272 study.default_experiment_name(),
257 base::FieldTrialList::kNoExpirationYear, 1, 1, randomization_type, 273 base::FieldTrialList::kNoExpirationYear, 1, 1, randomization_type,
258 randomization_seed, NULL)); 274 randomization_seed, NULL,
275 ShouldStudyUseLowEntropy(study) ? low_entropy_provider : NULL));
259 276
260 bool has_overrides = false; 277 bool has_overrides = false;
261 bool enables_or_disables_features = false; 278 bool enables_or_disables_features = false;
262 for (int i = 0; i < study.experiment_size(); ++i) { 279 for (int i = 0; i < study.experiment_size(); ++i) {
263 const Study_Experiment& experiment = study.experiment(i); 280 const Study_Experiment& experiment = study.experiment(i);
264 RegisterExperimentParams(study, experiment); 281 RegisterExperimentParams(study, experiment);
265 282
266 // Groups with forcing flags have probability 0 and will never be selected. 283 // 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. 284 // Therefore, there's no need to add them to the field trial.
268 if (experiment.has_forcing_flag() || 285 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 321 // The field trial was defined from |study|, so the active experiment's name
305 // must be in the |study|. 322 // must be in the |study|.
306 DCHECK_NE(-1, experiment_index); 323 DCHECK_NE(-1, experiment_index);
307 324
308 ApplyUIStringOverrides(study.experiment(experiment_index), 325 ApplyUIStringOverrides(study.experiment(experiment_index),
309 override_callback); 326 override_callback);
310 } 327 }
311 } 328 }
312 329
313 } // namespace variations 330 } // namespace variations
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698