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

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

Issue 2924983003: [Variations] Refactor all state used for study filtering into a container struct. (Closed)
Patch Set: Update unit tests Created 3 years, 6 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/client_filterable_state.h"
12 #include "components/variations/processed_study.h" 13 #include "components/variations/processed_study.h"
13 #include "components/variations/proto/study.pb.h" 14 #include "components/variations/proto/study.pb.h"
14 #include "components/variations/study_filtering.h" 15 #include "components/variations/study_filtering.h"
15 #include "components/variations/variations_associated_data.h" 16 #include "components/variations/variations_associated_data.h"
16 #include "components/variations/variations_seed_processor.h" 17 #include "components/variations/variations_seed_processor.h"
17 18
18 namespace variations { 19 namespace variations {
19 20
20 namespace { 21 namespace {
21 22
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 const base::FieldTrial::EntropyProvider& default_entropy_provider, 108 const base::FieldTrial::EntropyProvider& default_entropy_provider,
108 const base::FieldTrial::EntropyProvider& low_entropy_provider) 109 const base::FieldTrial::EntropyProvider& low_entropy_provider)
109 : default_entropy_provider_(default_entropy_provider), 110 : default_entropy_provider_(default_entropy_provider),
110 low_entropy_provider_(low_entropy_provider) {} 111 low_entropy_provider_(low_entropy_provider) {}
111 112
112 VariationsSeedSimulator::~VariationsSeedSimulator() { 113 VariationsSeedSimulator::~VariationsSeedSimulator() {
113 } 114 }
114 115
115 VariationsSeedSimulator::Result VariationsSeedSimulator::SimulateSeedStudies( 116 VariationsSeedSimulator::Result VariationsSeedSimulator::SimulateSeedStudies(
116 const VariationsSeed& seed, 117 const VariationsSeed& seed,
117 const std::string& locale, 118 const ClientFilterableState& client_state) {
118 const base::Time& reference_date,
119 const base::Version& version,
120 Study_Channel channel,
121 Study_FormFactor form_factor,
122 const std::string& hardware_class,
123 const std::string& session_consistency_country,
124 const std::string& permanent_consistency_country) {
125 std::vector<ProcessedStudy> filtered_studies; 119 std::vector<ProcessedStudy> filtered_studies;
126 FilterAndValidateStudies(seed, locale, reference_date, version, channel, 120 FilterAndValidateStudies(seed, client_state, &filtered_studies);
127 form_factor, hardware_class,
128 session_consistency_country,
129 permanent_consistency_country, &filtered_studies);
130 121
131 return ComputeDifferences(filtered_studies); 122 return ComputeDifferences(filtered_studies);
132 } 123 }
133 124
134 VariationsSeedSimulator::Result VariationsSeedSimulator::ComputeDifferences( 125 VariationsSeedSimulator::Result VariationsSeedSimulator::ComputeDifferences(
135 const std::vector<ProcessedStudy>& processed_studies) { 126 const std::vector<ProcessedStudy>& processed_studies) {
136 std::map<std::string, std::string> current_state; 127 std::map<std::string, std::string> current_state;
137 GetCurrentTrialState(&current_state); 128 GetCurrentTrialState(&current_state);
138 129
139 Result result; 130 Result result;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 return ConvertExperimentTypeToChangeType(experiment->type()); 247 return ConvertExperimentTypeToChangeType(experiment->type());
257 } 248 }
258 249
259 // Current group exists in the study - check whether its params changed. 250 // Current group exists in the study - check whether its params changed.
260 if (!VariationParamsAreEqual(study, *experiment)) 251 if (!VariationParamsAreEqual(study, *experiment))
261 return ConvertExperimentTypeToChangeType(experiment->type()); 252 return ConvertExperimentTypeToChangeType(experiment->type());
262 return NO_CHANGE; 253 return NO_CHANGE;
263 } 254 }
264 255
265 } // namespace variations 256 } // namespace variations
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698