Chromium Code Reviews| 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..a8e9b75885c31b72335c21d08dbd1d2bc99225d4 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,28 @@ bool VariationsService::LoadSeed(VariationsSeed* seed) { |
| return seed_store_.LoadSeed(seed); |
| } |
| +std::unique_ptr<ClientFilterableState> |
| +VariationsService::GetClientFilterableStateForVersion( |
| + const base::Version& version) { |
| + const std::string latest_country = GetLatestCountry(); |
|
Alexei Svitkine (slow)
2017/06/07 15:18:08
Nit: Move closer to where it's used - above line 6
Ilya Sherman
2017/06/07 21:50:08
Done.
|
| + |
| + std::unique_ptr<ClientFilterableState> state = |
| + base::MakeUnique<ClientFilterableState>(); |
| + variations::Study::Channel channel = |
| + GetChannelForVariations(client_->GetChannel()); |
| + state->locale = client_->GetApplicationLocale(); |
| + state->reference_date = GetReferenceDateForExpiryChecks(local_state_); |
| + state->version = version; |
| + state->channel = channel; |
| + state->form_factor = GetCurrentFormFactor(); |
| + state->platform = ClientFilterableState::GetCurrentPlatform(); |
| + state->hardware_class = GetHardwareClass(); |
| + state->session_consistency_country = latest_country; |
| + state->permanent_consistency_country = |
| + LoadPermanentConsistencyCountry(version, latest_country); |
| + return state; |
| +} |
| + |
| void VariationsService::FetchVariationsSeed() { |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| @@ -771,14 +789,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); |