1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
// Copyright 2025 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/regional_capabilities/regional_capabilities_metrics.h"
#include "base/metrics/histogram_functions.h"
#include "components/country_codes/country_codes.h"
namespace regional_capabilities {
namespace {
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
//
// LINT.IfChange(CountryMatchingStatus)
enum class CountryMatchingStatus {
kCountryMissing = 1,
kVariationsCountryMissing = 2,
kMatchesVariationsLatest = 3,
kDoesNotMatchVariationsLatest = 4,
kMaxValue = kDoesNotMatchVariationsLatest,
};
// LINT.ThenChange(/tools/metrics/histograms/metadata/regional_capabilities/enums.xml:CountryMatchingStatus)
CountryMatchingStatus ComputeCountryMatchingStatus(
country_codes::CountryId country_id,
country_codes::CountryId variations_latest_country) {
if (!country_id.IsValid()) {
return CountryMatchingStatus::kCountryMissing;
}
if (!variations_latest_country.IsValid()) {
return CountryMatchingStatus::kVariationsCountryMissing;
}
if (country_id == variations_latest_country) {
return CountryMatchingStatus::kMatchesVariationsLatest;
}
return CountryMatchingStatus::kDoesNotMatchVariationsLatest;
}
} // namespace
void RecordLoadedCountrySource(LoadedCountrySource source) {
base::UmaHistogramEnumeration("RegionalCapabilities.LoadedCountrySource",
source);
}
void RecordVariationsCountryMatching(
country_codes::CountryId variations_latest_country,
country_codes::CountryId persisted_profile_country,
country_codes::CountryId current_device_country,
bool is_device_country_from_fallback) {
base::UmaHistogramEnumeration(
"RegionalCapabilities.PersistedCountryMatching",
ComputeCountryMatchingStatus(persisted_profile_country,
variations_latest_country));
base::UmaHistogramEnumeration(
is_device_country_from_fallback
? "RegionalCapabilities.FallbackCountryMatching"
: "RegionalCapabilities.FetchedCountryMatching",
ComputeCountryMatchingStatus(current_device_country,
variations_latest_country));
}
} // namespace regional_capabilities
|