chromium/components/metrics/demographics/user_demographics.cc

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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;
// TODO(crbug.com/40240008): Make this non-syncable (on Ash only) after full
// rollout of the syncable os priority pref; then delete it locally from Ash
// devices.
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) {}

// Returns the noise offset for the birth year. If not found in |local_state|,
// the offset will be randomly generated within the offset range and cached in
// |local_state|.
int GetBirthYearOffset(PrefService* local_state) {}

// Determines whether the synced user has provided a birth year to Google which
// is eligible, once aggregated and anonymized, to measure usage of Chrome
// features by age groups. See doc of DemographicMetricsProvider in
// demographic_metrics_provider.h for more details.
bool HasEligibleBirthYear(base::Time now, int user_birth_year, int offset) {}

// Gets the synced user's birth year from synced prefs, see doc of
// DemographicMetricsProvider in demographic_metrics_provider.h for more
// details.
std::optional<int> GetUserBirthYear(const base::Value::Dict& demographics) {}

// Gets the synced user's gender from synced prefs, see doc of
// DemographicMetricsProvider in demographic_metrics_provider.h for more
// details.
std::optional<UserDemographicsProto_Gender> GetUserGender(
    const base::Value::Dict& demographics) {}

}  // namespace

// static
UserDemographicsResult UserDemographicsResult::ForValue(
    UserDemographics value) {}

// static
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) {}

}  // namespace metrics