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

Unified Diff: components/variations/service/variations_service.cc

Issue 2924983003: [Variations] Refactor all state used for study filtering into a container struct. (Closed)
Patch Set: A bit more cleanup 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/variations/service/variations_service.h ('k') | components/variations/study_filtering.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/variations/service/variations_service.cc
diff --git a/components/variations/service/variations_service.cc b/components/variations/service/variations_service.cc
index bda0338a32e59d29b7e634314785c35eaca51495..cc2e38d518a97eccaf6e0e7bbe422fdf1f2275bc 100644
--- a/components/variations/service/variations_service.cc
+++ b/components/variations/service/variations_service.cc
@@ -333,22 +333,18 @@ bool VariationsService::CreateTrialsFromSeed(base::FeatureList* feature_list) {
if (!current_version.IsValid())
return false;
- variations::Study_Channel channel =
- GetChannelForVariations(client_->GetChannel());
- UMA_HISTOGRAM_SPARSE_SLOWLY("Variations.UserChannel", channel);
+ std::unique_ptr<ClientFilterableState> client_state =
+ GetClientFilterableStateForVersion(current_version);
+ UMA_HISTOGRAM_SPARSE_SLOWLY("Variations.UserChannel", client_state->channel);
- const std::string latest_country = GetLatestCountry();
std::unique_ptr<const base::FieldTrial::EntropyProvider> low_entropy_provider(
CreateLowEntropyProvider());
// Note that passing |&ui_string_overrider_| via base::Unretained below is
// safe because the callback is executed synchronously. It is not possible
- // to pass UIStringOverrider itself to VariationSeedProcesor as variations
+ // to pass UIStringOverrider itself to VariationSeedProcessor as variations
// components should not depends on //ui/base.
variations::VariationsSeedProcessor().CreateTrialsFromSeed(
- seed, client_->GetApplicationLocale(),
- GetReferenceDateForExpiryChecks(local_state_), current_version, channel,
- GetCurrentFormFactor(), GetHardwareClass(), latest_country,
- LoadPermanentConsistencyCountry(current_version, latest_country),
+ seed, *client_state,
base::Bind(&UIStringOverrider::OverrideUIString,
base::Unretained(&ui_string_overrider_)),
low_entropy_provider.get(), feature_list);
@@ -627,6 +623,24 @@ bool VariationsService::LoadSeed(VariationsSeed* seed) {
return seed_store_.LoadSeed(seed);
}
+std::unique_ptr<ClientFilterableState>
+VariationsService::GetClientFilterableStateForVersion(
+ const base::Version& version) {
+ std::unique_ptr<ClientFilterableState> state =
+ base::MakeUnique<ClientFilterableState>();
+ state->locale = client_->GetApplicationLocale();
+ state->reference_date = GetReferenceDateForExpiryChecks(local_state_);
+ state->version = version;
+ state->channel = GetChannelForVariations(client_->GetChannel());
+ state->form_factor = GetCurrentFormFactor();
+ state->platform = ClientFilterableState::GetCurrentPlatform();
+ state->hardware_class = GetHardwareClass();
+ state->session_consistency_country = GetLatestCountry();
+ state->permanent_consistency_country = LoadPermanentConsistencyCountry(
+ version, state->session_consistency_country);
+ return state;
+}
+
void VariationsService::FetchVariationsSeed() {
DCHECK(thread_checker_.CalledOnValidThread());
@@ -771,14 +785,10 @@ void VariationsService::PerformSimulationWithVersion(
variations::VariationsSeedSimulator seed_simulator(*default_provider,
*low_provider);
- const std::string latest_country = GetLatestCountry();
- const variations::VariationsSeedSimulator::Result result =
- seed_simulator.SimulateSeedStudies(
- *seed, client_->GetApplicationLocale(),
- GetReferenceDateForExpiryChecks(local_state_), version,
- GetChannelForVariations(client_->GetChannel()),
- GetCurrentFormFactor(), GetHardwareClass(), latest_country,
- LoadPermanentConsistencyCountry(version, latest_country));
+ std::unique_ptr<ClientFilterableState> client_state =
+ GetClientFilterableStateForVersion(version);
+ const VariationsSeedSimulator::Result result =
+ seed_simulator.SimulateSeedStudies(*seed, *client_state);
UMA_HISTOGRAM_COUNTS_100("Variations.SimulateSeed.NormalChanges",
result.normal_group_change_count);
« no previous file with comments | « components/variations/service/variations_service.h ('k') | components/variations/study_filtering.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698