diff options
Diffstat (limited to 'chromium/components/variations/service/variations_field_trial_creator.cc')
-rw-r--r-- | chromium/components/variations/service/variations_field_trial_creator.cc | 59 |
1 files changed, 21 insertions, 38 deletions
diff --git a/chromium/components/variations/service/variations_field_trial_creator.cc b/chromium/components/variations/service/variations_field_trial_creator.cc index 7c6a2a7e733..5abe50de8a6 100644 --- a/chromium/components/variations/service/variations_field_trial_creator.cc +++ b/chromium/components/variations/service/variations_field_trial_creator.cc @@ -55,23 +55,6 @@ enum VariationsSeedExpiry { VARIATIONS_SEED_EXPIRY_ENUM_SIZE, }; -// Set of different possible values to report for the -// Variations.LoadPermanentConsistencyCountryResult histogram. Values are -// persisted to logs, and should therefore never be renumbered nor reused. -enum LoadPermanentConsistencyCountryResult { - LOAD_COUNTRY_NO_PREF_NO_SEED = 0, - LOAD_COUNTRY_NO_PREF_HAS_SEED, - LOAD_COUNTRY_INVALID_PREF_NO_SEED, - LOAD_COUNTRY_INVALID_PREF_HAS_SEED, - LOAD_COUNTRY_HAS_PREF_NO_SEED_VERSION_EQ, - LOAD_COUNTRY_HAS_PREF_NO_SEED_VERSION_NEQ, - LOAD_COUNTRY_HAS_BOTH_VERSION_EQ_COUNTRY_EQ, - LOAD_COUNTRY_HAS_BOTH_VERSION_EQ_COUNTRY_NEQ, - LOAD_COUNTRY_HAS_BOTH_VERSION_NEQ_COUNTRY_EQ, - LOAD_COUNTRY_HAS_BOTH_VERSION_NEQ_COUNTRY_NEQ, - LOAD_COUNTRY_MAX, -}; - // Gets current form factor and converts it from enum DeviceFormFactor to enum // Study_FormFactor. Study::FormFactor GetCurrentFormFactor() { @@ -122,26 +105,9 @@ base::Version GetOSVersion() { return ret; } -// Wrapper around channel checking, used to enable channel mocking for -// testing. If a fake channel flag is provided, it will take precedence. -// Otherwise, this will return the current browser channel (which could be -// UNKNOWN). -Study::Channel GetChannelForVariations(version_info::Channel product_channel) { - const std::string forced_channel = - base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( - switches::kFakeVariationsChannel); - if (!forced_channel.empty()) { - if (forced_channel == "stable") - return Study::STABLE; - if (forced_channel == "beta") - return Study::BETA; - if (forced_channel == "dev") - return Study::DEV; - if (forced_channel == "canary") - return Study::CANARY; - DVLOG(1) << "Invalid channel provided: " << forced_channel; - } - +// Just maps one set of enum values to another. Nothing to see here. +Study::Channel ConvertProductChannelToStudyChannel( + version_info::Channel product_channel) { switch (product_channel) { case version_info::Channel::CANARY: return Study::CANARY; @@ -274,7 +240,8 @@ VariationsFieldTrialCreator::GetClientFilterableStateForVersion( state->reference_date = GetReferenceDateForExpiryChecks(local_state()); state->version = version; state->os_version = GetOSVersion(); - state->channel = GetChannelForVariations(client_->GetChannel()); + state->channel = + ConvertProductChannelToStudyChannel(client_->GetChannelForVariations()); state->form_factor = GetCurrentFormFactor(); state->platform = GetPlatform(); state->hardware_class = GetShortHardwareClass(); @@ -303,6 +270,16 @@ std::string VariationsFieldTrialCreator::LoadPermanentConsistencyCountry( if (!override_country.empty()) return override_country; + const std::string permanent_overridden_country = + local_state()->GetString(prefs::kVariationsPermanentOverriddenCountry); + + if (!permanent_overridden_country.empty()) { + base::UmaHistogramEnumeration( + "Variations.LoadPermanentConsistencyCountryResult", + LOAD_COUNTRY_HAS_PERMANENT_OVERRIDDEN_COUNTRY, LOAD_COUNTRY_MAX); + return permanent_overridden_country; + } + const base::ListValue* list_value = local_state()->GetList(prefs::kVariationsPermanentConsistencyCountry); std::string stored_version_string; @@ -376,6 +353,12 @@ void VariationsFieldTrialCreator::StorePermanentCountry( new_list_value); } +void VariationsFieldTrialCreator::StoreVariationsOverriddenCountry( + const std::string& country) { + local_state()->SetString(prefs::kVariationsPermanentOverriddenCountry, + country); +} + void VariationsFieldTrialCreator::OverrideVariationsPlatform( Study::Platform platform_override) { has_platform_override_ = true; |