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

Side by Side Diff: components/metrics/metrics_state_manager.cc

Issue 506663003: Consolidates accessing and setting the UMA pref to be within metrics code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix and rollback unnecessary changes Created 6 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/metrics/metrics_state_manager.h" 5 #include "components/metrics/metrics_state_manager.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/guid.h" 8 #include "base/guid.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/metrics/sparse_histogram.h" 10 #include "base/metrics/sparse_histogram.h"
11 #include "base/prefs/pref_registry_simple.h" 11 #include "base/prefs/pref_registry_simple.h"
12 #include "base/prefs/pref_service.h" 12 #include "base/prefs/pref_service.h"
13 #include "base/rand_util.h" 13 #include "base/rand_util.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/threading/thread_restrictions.h"
15 #include "base/time/time.h" 16 #include "base/time/time.h"
16 #include "components/metrics/cloned_install_detector.h" 17 #include "components/metrics/cloned_install_detector.h"
17 #include "components/metrics/machine_id_provider.h" 18 #include "components/metrics/machine_id_provider.h"
18 #include "components/metrics/metrics_pref_names.h" 19 #include "components/metrics/metrics_pref_names.h"
19 #include "components/metrics/metrics_switches.h" 20 #include "components/metrics/metrics_switches.h"
20 #include "components/variations/caching_permuted_entropy_provider.h" 21 #include "components/variations/caching_permuted_entropy_provider.h"
21 22
22 namespace metrics { 23 namespace metrics {
23 24
24 namespace { 25 namespace {
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 ClonedInstallDetector::RegisterPrefs(registry); 212 ClonedInstallDetector::RegisterPrefs(registry);
212 CachingPermutedEntropyProvider::RegisterPrefs(registry); 213 CachingPermutedEntropyProvider::RegisterPrefs(registry);
213 214
214 // TODO(asvitkine): Remove these once a couple of releases have passed. 215 // TODO(asvitkine): Remove these once a couple of releases have passed.
215 // http://crbug.com/357704 216 // http://crbug.com/357704
216 registry->RegisterStringPref(prefs::kMetricsOldClientID, std::string()); 217 registry->RegisterStringPref(prefs::kMetricsOldClientID, std::string());
217 registry->RegisterIntegerPref(prefs::kMetricsOldLowEntropySource, 0); 218 registry->RegisterIntegerPref(prefs::kMetricsOldLowEntropySource, 0);
218 } 219 }
219 220
220 void MetricsStateManager::BackUpCurrentClientInfo() { 221 void MetricsStateManager::BackUpCurrentClientInfo() {
222 base::ThreadRestrictions::ScopedAllowIO allow_io;
stevenjb 2014/09/11 20:31:44 We really shouldn't be using this in production co
Alexei Svitkine (slow) 2014/09/11 20:39:43 Right. Previously we had this statement in metrics
stevenjb 2014/09/11 20:47:19 OK, that's fine, but please add a TODO: with the c
gayane -on leave until 09-2017 2014/09/12 17:44:51 Done.
223
221 ClientInfo client_info; 224 ClientInfo client_info;
222 client_info.client_id = client_id_; 225 client_info.client_id = client_id_;
223 client_info.installation_date = local_state_->GetInt64(prefs::kInstallDate); 226 client_info.installation_date = local_state_->GetInt64(prefs::kInstallDate);
224 client_info.reporting_enabled_date = 227 client_info.reporting_enabled_date =
225 local_state_->GetInt64(prefs::kMetricsReportingEnabledTimestamp); 228 local_state_->GetInt64(prefs::kMetricsReportingEnabledTimestamp);
226 store_client_info_.Run(client_info); 229 store_client_info_.Run(client_info);
227 } 230 }
228 231
229 scoped_ptr<ClientInfo> MetricsStateManager::LoadClientInfoAndMaybeMigrate() { 232 scoped_ptr<ClientInfo> MetricsStateManager::LoadClientInfoAndMaybeMigrate() {
230 scoped_ptr<metrics::ClientInfo> client_info = load_client_info_.Run(); 233 scoped_ptr<metrics::ClientInfo> client_info = load_client_info_.Run();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 305
303 local_state_->ClearPref(prefs::kMetricsClientID); 306 local_state_->ClearPref(prefs::kMetricsClientID);
304 local_state_->ClearPref(prefs::kMetricsLowEntropySource); 307 local_state_->ClearPref(prefs::kMetricsLowEntropySource);
305 local_state_->ClearPref(prefs::kMetricsResetIds); 308 local_state_->ClearPref(prefs::kMetricsResetIds);
306 309
307 // Also clear the backed up client info. 310 // Also clear the backed up client info.
308 store_client_info_.Run(ClientInfo()); 311 store_client_info_.Run(ClientInfo());
309 } 312 }
310 313
311 } // namespace metrics 314 } // namespace metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698