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

Unified Diff: chrome/browser/metrics/metrics_reporting_state.cc

Issue 2222903004: Clear client id prefs when opting out of UMA. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 4 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
Index: chrome/browser/metrics/metrics_reporting_state.cc
diff --git a/chrome/browser/metrics/metrics_reporting_state.cc b/chrome/browser/metrics/metrics_reporting_state.cc
index 7128819d95cc9898164cf69d15f4353598959931..58f34f97938720ed7c1a65cc085d08fb7935b86f 100644
--- a/chrome/browser/metrics/metrics_reporting_state.cc
+++ b/chrome/browser/metrics/metrics_reporting_state.cc
@@ -67,12 +67,24 @@ void SetMetricsReporting(bool to_update_pref,
metrics::prefs::kMetricsReportingEnabled, updated_pref);
#endif // !defined(OS_ANDROID)
- // Uses the current state of whether reporting is enabled to enabled services.
+ // Clear the client id pref when opting out. Note: Mirrors code in
+ // uma_session_stats.cc. TODO(asvitkine): Unify.
+ if (!updated_pref) {
+ // Note: Clearing client id will not affect the running state (e.g. field
+ // trial randomization), as the pref is only read on startup.
+ g_browser_process->local_state()->ClearPref(
+ metrics::prefs::kMetricsClientID);
+ g_browser_process->local_state()->ClearPref(
+ metrics::prefs::kMetricsReportingEnabledTimestamp);
+ }
+
+ // Uses the current state of whether reporting is enabled to enable services.
g_browser_process->GetMetricsServicesManager()->UpdateUploadPermissions(true);
// When a user opts in to the metrics reporting service, the previously
// collected data should be cleared to ensure that nothing is reported before
// a user opts in and all reported data is accurate.
+ // TODO(asvitkine): This logic should be added to uma_session_stats.cc too.
if (updated_pref && metrics)
metrics->ClearSavedStabilityMetrics();
« no previous file with comments | « chrome/browser/android/metrics/uma_session_stats.cc ('k') | chrome/installer/util/google_update_settings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698