#include "components/variations/service/limited_entropy_synthetic_trial.h"
#include <cstdint>
#include "base/metrics/histogram_functions.h"
#include "base/rand_util.h"
#include "base/version_info/channel.h"
#include "components/prefs/pref_service.h"
#include "components/variations/pref_names.h"
#include "components/variations/synthetic_trials.h"
namespace variations {
namespace {
#if BUILDFLAG(IS_CHROMEOS)
bool g_trial_is_randomized = false;
#endif
constexpr uint64_t kStableEnabledPercentage = …;
constexpr uint64_t kNonStableEnabledPercentage = …;
uint64_t SelectEnabledPercentage(version_info::Channel channel) { … }
bool IsValidTrialSeed(uint64_t seed) { … }
uint64_t GenerateTrialSeed() { … }
constexpr bool IsValidEnabledPercentage(uint64_t percentage) { … }
std::string_view SelectGroup(PrefService* local_state,
version_info::Channel channel) { … }
}
LimitedEntropySyntheticTrial::LimitedEntropySyntheticTrial(
PrefService* local_state,
version_info::Channel channel)
: … { … }
LimitedEntropySyntheticTrial::LimitedEntropySyntheticTrial(
std::string_view group_name)
: … { … }
LimitedEntropySyntheticTrial::~LimitedEntropySyntheticTrial() = default;
void LimitedEntropySyntheticTrial::RegisterPrefs(PrefRegistrySimple* registry) { … }
#if BUILDFLAG(IS_CHROMEOS)
void LimitedEntropySyntheticTrial::SetSeedFromAsh(PrefService* local_state,
uint64_t seed) {
CHECK(!g_trial_is_randomized);
bool is_valid_seed = IsValidTrialSeed(seed);
base::UmaHistogramBoolean(kIsLimitedEntropySyntheticTrialSeedValidHistogram,
is_valid_seed);
if (is_valid_seed) {
local_state->SetUint64(prefs::kVariationsLimitedEntropySyntheticTrialSeed,
seed);
}
}
uint64_t LimitedEntropySyntheticTrial::GetRandomizationSeed(
PrefService* local_state) {
return local_state->GetUint64(
prefs::kVariationsLimitedEntropySyntheticTrialSeed);
}
#endif
bool LimitedEntropySyntheticTrial::IsEnabled() { … }
std::string_view LimitedEntropySyntheticTrial::GetGroupName() { … }
void LimitedEntropySyntheticTrial::Register(
SyntheticTrialRegistry& synthetic_trial_registry) { … }
}