Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(706)

Unified Diff: components/metrics/metrics_state_manager.cc

Issue 1984003002: Use low entropy for studies that send experiment IDs to Google properties. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/metrics/metrics_state_manager.h ('k') | components/metrics/metrics_state_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/metrics/metrics_state_manager.cc
diff --git a/components/metrics/metrics_state_manager.cc b/components/metrics/metrics_state_manager.cc
index 0f2904e5ff036be29b872b38c05fb888402f7ee8..cf1b4a126abd6af56515dfd07f84d84c1fbf01bf 100644
--- a/components/metrics/metrics_state_manager.cc
+++ b/components/metrics/metrics_state_manager.cc
@@ -43,6 +43,12 @@ int GenerateLowEntropySource() {
return base::RandInt(0, kMaxLowEntropySize - 1);
}
+// Records the given |low_entorpy_source_value| in a histogram.
+void LogLowEntropyValue(int low_entropy_source_value) {
+ UMA_HISTOGRAM_SPARSE_SLOWLY("UMA.LowEntropySourceValue",
+ low_entropy_source_value);
+}
+
} // namespace
// static
@@ -148,18 +154,17 @@ void MetricsStateManager::CheckForClonedInstall(
}
std::unique_ptr<const base::FieldTrial::EntropyProvider>
-MetricsStateManager::CreateEntropyProvider() {
- // For metrics reporting-enabled users, we combine the client ID and low
- // entropy source to get the final entropy source. Otherwise, only use the low
- // entropy source.
- // This has two useful properties:
- // 1) It makes the entropy source less identifiable for parties that do not
- // know the low entropy source.
- // 2) It makes the final entropy source resettable.
- const int low_entropy_source_value = GetLowEntropySource();
- UMA_HISTOGRAM_SPARSE_SLOWLY("UMA.LowEntropySourceValue",
- low_entropy_source_value);
+MetricsStateManager::CreateDefaultEntropyProvider() {
if (enabled_state_provider_->IsConsentGiven()) {
+ // For metrics reporting-enabled users, we combine the client ID and low
+ // entropy source to get the final entropy source. Otherwise, only use the
+ // low entropy source.
+ // This has two useful properties:
+ // 1) It makes the entropy source less identifiable for parties that do not
+ // know the low entropy source.
+ // 2) It makes the final entropy source resettable.
+ const int low_entropy_source_value = GetLowEntropySource();
+
UpdateEntropySourceReturnedValue(ENTROPY_SOURCE_HIGH);
const std::string high_entropy_source =
client_id_ + base::IntToString(low_entropy_source_value);
@@ -168,6 +173,13 @@ MetricsStateManager::CreateEntropyProvider() {
}
UpdateEntropySourceReturnedValue(ENTROPY_SOURCE_LOW);
+ return CreateLowEntropyProvider();
+}
+
+std::unique_ptr<const base::FieldTrial::EntropyProvider>
+MetricsStateManager::CreateLowEntropyProvider() {
+ const int low_entropy_source_value = GetLowEntropySource();
+
#if defined(OS_ANDROID) || defined(OS_IOS)
return std::unique_ptr<const base::FieldTrial::EntropyProvider>(
new CachingPermutedEntropyProvider(local_state_, low_entropy_source_value,
@@ -198,8 +210,6 @@ std::unique_ptr<MetricsStateManager> MetricsStateManager::Create(
// static
void MetricsStateManager::RegisterPrefs(PrefRegistrySimple* registry) {
registry->RegisterBooleanPref(prefs::kMetricsResetIds, false);
- // registry->RegisterIntegerPref(prefs::kMetricsDefaultOptIn,
- // DEFAULT_UNKNOWN);
registry->RegisterStringPref(prefs::kMetricsClientID, std::string());
registry->RegisterInt64Pref(prefs::kMetricsReportingEnabledTimestamp, 0);
registry->RegisterIntegerPref(prefs::kMetricsLowEntropySource,
@@ -274,11 +284,13 @@ void MetricsStateManager::UpdateLowEntropySource() {
// it below.
if (value >= 0 && value < kMaxLowEntropySize) {
low_entropy_source_ = value;
+ LogLowEntropyValue(low_entropy_source_);
return;
}
}
low_entropy_source_ = GenerateLowEntropySource();
+ LogLowEntropyValue(low_entropy_source_);
local_state_->SetInteger(prefs::kMetricsLowEntropySource,
low_entropy_source_);
CachingPermutedEntropyProvider::ClearCache(local_state_);
« no previous file with comments | « components/metrics/metrics_state_manager.h ('k') | components/metrics/metrics_state_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698