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

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

Issue 1161133004: Delete code corresponding to old UMA prefs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moar comments. Created 5 years, 6 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
« no previous file with comments | « components/metrics/metrics_pref_names.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // Flush the backup back to persistent storage in case we re-generated 117 // Flush the backup back to persistent storage in case we re-generated
118 // missing data above. 118 // missing data above.
119 BackUpCurrentClientInfo(); 119 BackUpCurrentClientInfo();
120 return; 120 return;
121 } 121 }
122 122
123 // Failing attempts at getting an existing client ID, generate a new one. 123 // Failing attempts at getting an existing client ID, generate a new one.
124 client_id_ = base::GenerateGUID(); 124 client_id_ = base::GenerateGUID();
125 local_state_->SetString(prefs::kMetricsClientID, client_id_); 125 local_state_->SetString(prefs::kMetricsClientID, client_id_);
126 126
127 if (local_state_->GetString(prefs::kMetricsOldClientID).empty()) { 127 // Record the timestamp of when the user opted in to UMA.
128 // Record the timestamp of when the user opted in to UMA. 128 local_state_->SetInt64(prefs::kMetricsReportingEnabledTimestamp,
129 local_state_->SetInt64(prefs::kMetricsReportingEnabledTimestamp, 129 base::Time::Now().ToTimeT());
130 base::Time::Now().ToTimeT());
131 } else {
132 UMA_HISTOGRAM_BOOLEAN("UMA.ClientIdMigrated", true);
133 }
134 local_state_->ClearPref(prefs::kMetricsOldClientID);
135 130
136 BackUpCurrentClientInfo(); 131 BackUpCurrentClientInfo();
137 } 132 }
138 133
139 void MetricsStateManager::CheckForClonedInstall( 134 void MetricsStateManager::CheckForClonedInstall(
140 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { 135 scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
141 DCHECK(!cloned_install_detector_); 136 DCHECK(!cloned_install_detector_);
142 137
143 MachineIdProvider* provider = MachineIdProvider::CreateInstance(); 138 MachineIdProvider* provider = MachineIdProvider::CreateInstance();
144 if (!provider) 139 if (!provider)
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 // static 196 // static
202 void MetricsStateManager::RegisterPrefs(PrefRegistrySimple* registry) { 197 void MetricsStateManager::RegisterPrefs(PrefRegistrySimple* registry) {
203 registry->RegisterBooleanPref(prefs::kMetricsResetIds, false); 198 registry->RegisterBooleanPref(prefs::kMetricsResetIds, false);
204 registry->RegisterStringPref(prefs::kMetricsClientID, std::string()); 199 registry->RegisterStringPref(prefs::kMetricsClientID, std::string());
205 registry->RegisterInt64Pref(prefs::kMetricsReportingEnabledTimestamp, 0); 200 registry->RegisterInt64Pref(prefs::kMetricsReportingEnabledTimestamp, 0);
206 registry->RegisterIntegerPref(prefs::kMetricsLowEntropySource, 201 registry->RegisterIntegerPref(prefs::kMetricsLowEntropySource,
207 kLowEntropySourceNotSet); 202 kLowEntropySourceNotSet);
208 203
209 ClonedInstallDetector::RegisterPrefs(registry); 204 ClonedInstallDetector::RegisterPrefs(registry);
210 CachingPermutedEntropyProvider::RegisterPrefs(registry); 205 CachingPermutedEntropyProvider::RegisterPrefs(registry);
211
212 // TODO(asvitkine): Remove these once a couple of releases have passed.
213 // http://crbug.com/357704
214 registry->RegisterStringPref(prefs::kMetricsOldClientID, std::string());
215 registry->RegisterIntegerPref(prefs::kMetricsOldLowEntropySource, 0);
216 } 206 }
217 207
218 void MetricsStateManager::BackUpCurrentClientInfo() { 208 void MetricsStateManager::BackUpCurrentClientInfo() {
219 ClientInfo client_info; 209 ClientInfo client_info;
220 client_info.client_id = client_id_; 210 client_info.client_id = client_id_;
221 client_info.installation_date = local_state_->GetInt64(prefs::kInstallDate); 211 client_info.installation_date = local_state_->GetInt64(prefs::kInstallDate);
222 client_info.reporting_enabled_date = 212 client_info.reporting_enabled_date =
223 local_state_->GetInt64(prefs::kMetricsReportingEnabledTimestamp); 213 local_state_->GetInt64(prefs::kMetricsReportingEnabledTimestamp);
224 store_client_info_.Run(client_info); 214 store_client_info_.Run(client_info);
225 } 215 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 low_entropy_source_ = value; 266 low_entropy_source_ = value;
277 UMA_HISTOGRAM_BOOLEAN("UMA.GeneratedLowEntropySource", false); 267 UMA_HISTOGRAM_BOOLEAN("UMA.GeneratedLowEntropySource", false);
278 return low_entropy_source_; 268 return low_entropy_source_;
279 } 269 }
280 } 270 }
281 271
282 UMA_HISTOGRAM_BOOLEAN("UMA.GeneratedLowEntropySource", true); 272 UMA_HISTOGRAM_BOOLEAN("UMA.GeneratedLowEntropySource", true);
283 low_entropy_source_ = GenerateLowEntropySource(); 273 low_entropy_source_ = GenerateLowEntropySource();
284 local_state_->SetInteger(prefs::kMetricsLowEntropySource, 274 local_state_->SetInteger(prefs::kMetricsLowEntropySource,
285 low_entropy_source_); 275 low_entropy_source_);
286 local_state_->ClearPref(prefs::kMetricsOldLowEntropySource);
287 CachingPermutedEntropyProvider::ClearCache(local_state_); 276 CachingPermutedEntropyProvider::ClearCache(local_state_);
288 277
289 return low_entropy_source_; 278 return low_entropy_source_;
290 } 279 }
291 280
292 void MetricsStateManager::UpdateEntropySourceReturnedValue( 281 void MetricsStateManager::UpdateEntropySourceReturnedValue(
293 EntropySourceType type) { 282 EntropySourceType type) {
294 if (entropy_source_returned_ != ENTROPY_SOURCE_NONE) 283 if (entropy_source_returned_ != ENTROPY_SOURCE_NONE)
295 return; 284 return;
296 285
(...skipping 13 matching lines...) Expand all
310 299
311 local_state_->ClearPref(prefs::kMetricsClientID); 300 local_state_->ClearPref(prefs::kMetricsClientID);
312 local_state_->ClearPref(prefs::kMetricsLowEntropySource); 301 local_state_->ClearPref(prefs::kMetricsLowEntropySource);
313 local_state_->ClearPref(prefs::kMetricsResetIds); 302 local_state_->ClearPref(prefs::kMetricsResetIds);
314 303
315 // Also clear the backed up client info. 304 // Also clear the backed up client info.
316 store_client_info_.Run(ClientInfo()); 305 store_client_info_.Run(ClientInfo());
317 } 306 }
318 307
319 } // namespace metrics 308 } // namespace metrics
OLDNEW
« no previous file with comments | « components/metrics/metrics_pref_names.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698