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..de14af3637287e555e8d65b0a6c77f8e79de57e4 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); |
| 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_(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_) |
| + return; |
| + |
| + metrics_ids_reset_ = true; |
| + |
| + PrefService* local_state = g_browser_process->local_state(); |
| + if (!local_state->GetBoolean(prefs::kMetricsResetIds)) |
| + return; |
| + |
| + DCHECK(client_id_.empty()); |
| + DCHECK(low_entropy_source_ == kLowEntropySourceNotSet); |
|
Alexei Svitkine (slow)
2014/03/28 17:20:26
Nit: DCHECK_EQ and put kLowEntropySourceNotSet on
jwd
2014/03/28 18:59:21
Done.
|
| + |
| + 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. |
| @@ -1862,6 +1887,7 @@ void MetricsService::RegisterSyntheticFieldTrial( |
| } |
| void MetricsService::CheckForClonedInstall() { |
| + DVLOG(2) << "\n\nChecking for cloned installs\n\n"; |
| DCHECK(!cloned_install_detector_); |
| metrics::MachineIdProvider* provider = |