Chromium Code Reviews| 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..369e273f65a9a142e50d5d7e1b266f3eb9defbc5 100644 |
| --- a/chrome/browser/metrics/metrics_service.cc |
| +++ b/chrome/browser/metrics/metrics_service.cc |
| @@ -439,6 +439,7 @@ void MetricsService::RegisterPrefs(PrefRegistrySimple* registry) { |
| registry->RegisterIntegerPref(prefs::kMetricsLowEntropySource, |
| kLowEntropySourceNotSet); |
| registry->RegisterInt64Pref(prefs::kMetricsClientIDTimestamp, 0); |
| + registry->RegisterBooleanPref(prefs::kMetricsResetIds, false); |
|
Alexei Svitkine (slow)
2014/03/28 19:02:50
Nit: Maybe move this at the top of the list, so th
jwd
2014/03/28 19:43:15
Done.
|
| registry->RegisterInt64Pref(prefs::kStabilityLaunchTimeSec, 0); |
| registry->RegisterInt64Pref(prefs::kStabilityLastTimestampSec, 0); |
| registry->RegisterStringPref(prefs::kStabilityStatsVersion, std::string()); |
| @@ -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,24 @@ 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; |
| + |
| + 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 +1215,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. |