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

Unified Diff: components/metrics/metrics_state_manager.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
« no previous file with comments | « components/metrics/metrics_pref_names.cc ('k') | no next file » | 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 b470e3db1e6cbc1a8a473b6628a16a74b6d2adff..ae0754e8ea1134b9e8ddcacca676ccb0c7772394 100644
--- a/components/metrics/metrics_state_manager.cc
+++ b/components/metrics/metrics_state_manager.cc
@@ -83,10 +83,15 @@ bool MetricsStateManager::IsMetricsReportingEnabled() {
}
void MetricsStateManager::ForceClientIdCreation() {
- if (!client_id_.empty())
- return;
+ {
+ std::string client_id_from_prefs =
+ local_state_->GetString(prefs::kMetricsClientID);
+ // If client id in prefs matches the cached copy, return early.
+ if (!client_id_from_prefs.empty() && client_id_from_prefs == client_id_)
+ return;
+ client_id_.swap(client_id_from_prefs);
+ }
- client_id_ = local_state_->GetString(prefs::kMetricsClientID);
if (!client_id_.empty()) {
// It is technically sufficient to only save a backup of the client id when
// it is initially generated below, but since the backup was only introduced
« no previous file with comments | « components/metrics/metrics_pref_names.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698