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

Side by Side Diff: components/variations/variations_seed_simulator.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_simulator.h" 5 #include "components/variations/variations_seed_simulator.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 10
11 #include "base/metrics/field_trial.h" 11 #include "base/metrics/field_trial.h"
12 #include "components/variations/processed_study.h" 12 #include "components/variations/processed_study.h"
13 #include "components/variations/proto/study.pb.h" 13 #include "components/variations/proto/study.pb.h"
14 #include "components/variations/study_filtering.h" 14 #include "components/variations/study_filtering.h"
15 #include "components/variations/variations_associated_data.h" 15 #include "components/variations/variations_associated_data.h"
16 #include "components/variations/variations_seed_processor.h"
16 17
17 namespace variations { 18 namespace variations {
18 19
19 namespace { 20 namespace {
20 21
21 // Fills in |current_state| with the current process' active field trials, as a 22 // Fills in |current_state| with the current process' active field trials, as a
22 // map of trial names to group names. 23 // map of trial names to group names.
23 void GetCurrentTrialState(std::map<std::string, std::string>* current_state) { 24 void GetCurrentTrialState(std::map<std::string, std::string>* current_state) {
24 base::FieldTrial::ActiveGroups trial_groups; 25 base::FieldTrial::ActiveGroups trial_groups;
25 base::FieldTrialList::GetActiveFieldTrialGroups(&trial_groups); 26 base::FieldTrialList::GetActiveFieldTrialGroups(&trial_groups);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 VariationsSeedSimulator::Result::Result() 97 VariationsSeedSimulator::Result::Result()
97 : normal_group_change_count(0), 98 : normal_group_change_count(0),
98 kill_best_effort_group_change_count(0), 99 kill_best_effort_group_change_count(0),
99 kill_critical_group_change_count(0) { 100 kill_critical_group_change_count(0) {
100 } 101 }
101 102
102 VariationsSeedSimulator::Result::~Result() { 103 VariationsSeedSimulator::Result::~Result() {
103 } 104 }
104 105
105 VariationsSeedSimulator::VariationsSeedSimulator( 106 VariationsSeedSimulator::VariationsSeedSimulator(
106 const base::FieldTrial::EntropyProvider& entropy_provider) 107 const base::FieldTrial::EntropyProvider& default_entropy_provider,
107 : entropy_provider_(entropy_provider) { 108 const base::FieldTrial::EntropyProvider& low_entropy_provider)
108 } 109 : default_entropy_provider_(default_entropy_provider),
110 low_entropy_provider_(low_entropy_provider) {}
109 111
110 VariationsSeedSimulator::~VariationsSeedSimulator() { 112 VariationsSeedSimulator::~VariationsSeedSimulator() {
111 } 113 }
112 114
113 VariationsSeedSimulator::Result VariationsSeedSimulator::SimulateSeedStudies( 115 VariationsSeedSimulator::Result VariationsSeedSimulator::SimulateSeedStudies(
114 const VariationsSeed& seed, 116 const VariationsSeed& seed,
115 const std::string& locale, 117 const std::string& locale,
116 const base::Time& reference_date, 118 const base::Time& reference_date,
117 const base::Version& version, 119 const base::Version& version,
118 Study_Channel channel, 120 Study_Channel channel,
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 return CHANGED; 204 return CHANGED;
203 } 205 }
204 206
205 VariationsSeedSimulator::ChangeType 207 VariationsSeedSimulator::ChangeType
206 VariationsSeedSimulator::PermanentStudyGroupChanged( 208 VariationsSeedSimulator::PermanentStudyGroupChanged(
207 const ProcessedStudy& processed_study, 209 const ProcessedStudy& processed_study,
208 const std::string& selected_group) { 210 const std::string& selected_group) {
209 const Study& study = *processed_study.study(); 211 const Study& study = *processed_study.study();
210 DCHECK_EQ(Study_Consistency_PERMANENT, study.consistency()); 212 DCHECK_EQ(Study_Consistency_PERMANENT, study.consistency());
211 213
212 const std::string simulated_group = SimulateGroupAssignment(entropy_provider_, 214 const base::FieldTrial::EntropyProvider& entropy_provider =
213 processed_study); 215 VariationsSeedProcessor::ShouldStudyUseLowEntropy(study)
216 ? low_entropy_provider_
217 : default_entropy_provider_;
218
219 const std::string simulated_group =
220 SimulateGroupAssignment(entropy_provider, processed_study);
214 const Study_Experiment* experiment = FindExperiment(study, selected_group); 221 const Study_Experiment* experiment = FindExperiment(study, selected_group);
215 if (simulated_group != selected_group) { 222 if (simulated_group != selected_group) {
216 if (experiment) 223 if (experiment)
217 return ConvertExperimentTypeToChangeType(experiment->type()); 224 return ConvertExperimentTypeToChangeType(experiment->type());
218 return CHANGED; 225 return CHANGED;
219 } 226 }
220 227
221 // Current group exists in the study - check whether its params changed. 228 // Current group exists in the study - check whether its params changed.
222 DCHECK(experiment); 229 DCHECK(experiment);
223 if (!VariationParamsAreEqual(study, *experiment)) 230 if (!VariationParamsAreEqual(study, *experiment))
(...skipping 25 matching lines...) Expand all
249 return ConvertExperimentTypeToChangeType(experiment->type()); 256 return ConvertExperimentTypeToChangeType(experiment->type());
250 } 257 }
251 258
252 // Current group exists in the study - check whether its params changed. 259 // Current group exists in the study - check whether its params changed.
253 if (!VariationParamsAreEqual(study, *experiment)) 260 if (!VariationParamsAreEqual(study, *experiment))
254 return ConvertExperimentTypeToChangeType(experiment->type()); 261 return ConvertExperimentTypeToChangeType(experiment->type());
255 return NO_CHANGE; 262 return NO_CHANGE;
256 } 263 }
257 264
258 } // namespace variations 265 } // namespace variations
OLDNEW
« no previous file with comments | « components/variations/variations_seed_simulator.h ('k') | components/variations/variations_seed_simulator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698