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

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: undo changes for IsMetricsReportingUserChangable. Checks for andrioid added 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 // TODO(gayane): Eliminate use of ScopedAllowIO. crbug.com/413783
223 base::ThreadRestrictions::ScopedAllowIO allow_io;
224
221 ClientInfo client_info; 225 ClientInfo client_info;
222 client_info.client_id = client_id_; 226 client_info.client_id = client_id_;
223 client_info.installation_date = local_state_->GetInt64(prefs::kInstallDate); 227 client_info.installation_date = local_state_->GetInt64(prefs::kInstallDate);
224 client_info.reporting_enabled_date = 228 client_info.reporting_enabled_date =
225 local_state_->GetInt64(prefs::kMetricsReportingEnabledTimestamp); 229 local_state_->GetInt64(prefs::kMetricsReportingEnabledTimestamp);
226 store_client_info_.Run(client_info); 230 store_client_info_.Run(client_info);
227 } 231 }
228 232
229 scoped_ptr<ClientInfo> MetricsStateManager::LoadClientInfoAndMaybeMigrate() { 233 scoped_ptr<ClientInfo> MetricsStateManager::LoadClientInfoAndMaybeMigrate() {
230 scoped_ptr<metrics::ClientInfo> client_info = load_client_info_.Run(); 234 scoped_ptr<metrics::ClientInfo> client_info = load_client_info_.Run();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 306
303 local_state_->ClearPref(prefs::kMetricsClientID); 307 local_state_->ClearPref(prefs::kMetricsClientID);
304 local_state_->ClearPref(prefs::kMetricsLowEntropySource); 308 local_state_->ClearPref(prefs::kMetricsLowEntropySource);
305 local_state_->ClearPref(prefs::kMetricsResetIds); 309 local_state_->ClearPref(prefs::kMetricsResetIds);
306 310
307 // Also clear the backed up client info. 311 // Also clear the backed up client info.
308 store_client_info_.Run(ClientInfo()); 312 store_client_info_.Run(ClientInfo());
309 } 313 }
310 314
311 } // namespace metrics 315 } // namespace metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698