#include "components/metrics/demographics/user_demographics.h"
#include <optional>
#include <utility>
#include "base/check.h"
#include "base/rand_util.h"
#include "base/values.h"
#include "build/build_config.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h"
namespace metrics {
#if !BUILDFLAG(IS_CHROMEOS_ASH)
constexpr auto kSyncDemographicsPrefFlags = …;
#else
constexpr auto kSyncOsDemographicsPrefFlags =
user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PRIORITY_PREF;
constexpr auto kSyncDemographicsPrefFlags =
user_prefs::PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF;
#endif
constexpr auto kUserDemographicsBirthYearOffsetPrefFlags = …;
constexpr auto kDeprecatedDemographicsBirthYearOffsetPrefFlags = …;
namespace {
const base::Value::Dict& GetDemographicsDict(PrefService* profile_prefs) { … }
void MigrateBirthYearOffset(PrefService* to_local_state,
PrefService* from_profile_prefs) { … }
int GetBirthYearOffset(PrefService* local_state) { … }
bool HasEligibleBirthYear(base::Time now, int user_birth_year, int offset) { … }
std::optional<int> GetUserBirthYear(const base::Value::Dict& demographics) { … }
std::optional<UserDemographicsProto_Gender> GetUserGender(
const base::Value::Dict& demographics) { … }
}
UserDemographicsResult UserDemographicsResult::ForValue(
UserDemographics value) { … }
UserDemographicsResult UserDemographicsResult::ForStatus(
UserDemographicsStatus status) { … }
bool UserDemographicsResult::IsSuccess() const { … }
UserDemographicsStatus UserDemographicsResult::status() const { … }
const UserDemographics& UserDemographicsResult::value() const { … }
UserDemographicsResult::UserDemographicsResult(UserDemographics value,
UserDemographicsStatus status)
: … { … }
void RegisterDemographicsLocalStatePrefs(PrefRegistrySimple* registry) { … }
void RegisterDemographicsProfilePrefs(PrefRegistrySimple* registry) { … }
void ClearDemographicsPrefs(PrefService* profile_prefs) { … }
UserDemographicsResult GetUserNoisedBirthYearAndGenderFromPrefs(
base::Time now,
PrefService* local_state,
PrefService* profile_prefs) { … }
}