Index: chrome/browser/metrics/metrics_service.cc |
diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc |
index a313c4514051b636009db4616c10559f98a64ca5..7155c40925380cdcf794a80a7659067afcbe221d 100644 |
--- a/chrome/browser/metrics/metrics_service.cc |
+++ b/chrome/browser/metrics/metrics_service.cc |
@@ -435,6 +435,7 @@ class MetricsMemoryDetails : public MemoryDetails { |
// static |
void MetricsService::RegisterPrefs(PrefRegistrySimple* registry) { |
DCHECK(IsSingleThreaded()); |
+ registry->RegisterBooleanPref(prefs::kMetricsResetIds, false); |
registry->RegisterStringPref(prefs::kMetricsClientID, std::string()); |
registry->RegisterIntegerPref(prefs::kMetricsLowEntropySource, |
kLowEntropySourceNotSet); |
@@ -521,7 +522,8 @@ void MetricsService::DiscardOldStabilityStats(PrefService* local_state) { |
} |
MetricsService::MetricsService() |
- : recording_active_(false), |
+ : metrics_ids_reset_check_performed_(false), |
+ recording_active_(false), |
reporting_active_(false), |
test_mode_active_(false), |
state_(INITIALIZED), |
@@ -633,6 +635,9 @@ MetricsService::CreateEntropyProvider(ReportingState reporting_state) { |
void MetricsService::ForceClientIdCreation() { |
if (!client_id_.empty()) |
return; |
+ |
+ ResetMetricsIDsIfNecessary(); |
+ |
PrefService* pref = g_browser_process->local_state(); |
client_id_ = pref->GetString(prefs::kMetricsClientID); |
if (!client_id_.empty()) |
@@ -1185,6 +1190,26 @@ void MetricsService::GetUptimes(PrefService* pref, |
} |
} |
+void MetricsService::ResetMetricsIDsIfNecessary() { |
+ if (metrics_ids_reset_check_performed_) |
+ return; |
+ |
+ metrics_ids_reset_check_performed_ = true; |
+ |
+ PrefService* local_state = g_browser_process->local_state(); |
+ if (!local_state->GetBoolean(prefs::kMetricsResetIds)) |
+ return; |
+ |
+ UMA_HISTOGRAM_BOOLEAN("UMA.MetricsIDsReset", true); |
+ |
+ DCHECK(client_id_.empty()); |
+ DCHECK_EQ(kLowEntropySourceNotSet, low_entropy_source_); |
+ |
+ local_state->ClearPref(prefs::kMetricsClientID); |
+ local_state->ClearPref(prefs::kMetricsLowEntropySource); |
+ local_state->ClearPref(prefs::kMetricsResetIds); |
+} |
+ |
int MetricsService::GetLowEntropySource() { |
// Note that the default value for the low entropy source and the default pref |
// value are both kLowEntropySourceNotSet, which is used to identify if the |
@@ -1192,6 +1217,8 @@ int MetricsService::GetLowEntropySource() { |
if (low_entropy_source_ != kLowEntropySourceNotSet) |
return low_entropy_source_; |
+ ResetMetricsIDsIfNecessary(); |
+ |
PrefService* local_state = g_browser_process->local_state(); |
const CommandLine* command_line(CommandLine::ForCurrentProcess()); |
// Only try to load the value from prefs if the user did not request a reset. |