Index: chrome/browser/metrics/metrics_service.cc |
=================================================================== |
--- chrome/browser/metrics/metrics_service.cc (revision 259917) |
+++ chrome/browser/metrics/metrics_service.cc (working copy) |
@@ -436,9 +436,9 @@ |
void MetricsService::RegisterPrefs(PrefRegistrySimple* registry) { |
DCHECK(IsSingleThreaded()); |
registry->RegisterStringPref(prefs::kMetricsClientID, std::string()); |
+ registry->RegisterInt64Pref(prefs::kMetricsClientIDTimestamp, 0); |
registry->RegisterIntegerPref(prefs::kMetricsLowEntropySource, |
kLowEntropySourceNotSet); |
- registry->RegisterInt64Pref(prefs::kMetricsClientIDTimestamp, 0); |
registry->RegisterInt64Pref(prefs::kStabilityLaunchTimeSec, 0); |
registry->RegisterInt64Pref(prefs::kStabilityLastTimestampSec, 0); |
registry->RegisterStringPref(prefs::kStabilityStatsVersion, std::string()); |
@@ -483,6 +483,11 @@ |
registry->RegisterInt64Pref(prefs::kUninstallLastLaunchTimeSec, 0); |
registry->RegisterInt64Pref(prefs::kUninstallLastObservedRunTimeSec, 0); |
+ // TODO(asvitkine): Remove these once a couple of releases have passed. |
+ registry->RegisterStringPref(prefs::kMetricsOldClientID, std::string()); |
+ registry->RegisterStringPref(prefs::kMetricsOldLowEntropySource, |
+ std::string()); |
+ |
#if defined(OS_ANDROID) |
RegisterPrefsAndroid(registry); |
#endif // defined(OS_ANDROID) |
@@ -641,9 +646,10 @@ |
client_id_ = GenerateClientID(); |
pref->SetString(prefs::kMetricsClientID, client_id_); |
- // Might as well make a note of how long this ID has existed |
- pref->SetString(prefs::kMetricsClientIDTimestamp, |
- base::Int64ToString(Time::Now().ToTimeT())); |
+ // Make a note of when the user opted in to UMA. |
rkaplow
2014/03/28 17:20:26
nit: I find "make a note" still a bit informal con
Alexei Svitkine (slow)
2014/03/28 17:39:15
Agreed. Done.
|
+ if (pref->GetString(prefs::kMetricsOldClientID).empty()) |
+ pref->SetInt64(prefs::kMetricsClientIDTimestamp, Time::Now().ToTimeT()); |
+ pref->ClearPref(prefs::kMetricsOldClientID); |
jwd
2014/03/28 15:47:52
Can you log a boolean histogram when a user migrat
Alexei Svitkine (slow)
2014/03/28 17:39:15
Done.
|
} |
void MetricsService::EnableRecording() { |
@@ -1198,12 +1204,6 @@ |
// Otherwise, skip to generating a new value. |
if (!command_line->HasSwitch(switches::kResetVariationState)) { |
int value = local_state->GetInteger(prefs::kMetricsLowEntropySource); |
- // Old versions of the code would generate values in the range of [1, 8192], |
- // before the range was switched to [0, 8191] and then to [0, 7999]. Map |
- // 8192 to 0, so that the 0th bucket remains uniform, while re-generating |
- // the low entropy source for old values in the [8000, 8191] range. |
- if (value == 8192) |
- value = 0; |
// If the value is outside the [0, kMaxLowEntropySize) range, re-generate |
// it below. |
if (value >= 0 && value < kMaxLowEntropySize) { |
@@ -1216,6 +1216,7 @@ |
UMA_HISTOGRAM_BOOLEAN("UMA.GeneratedLowEntropySource", true); |
low_entropy_source_ = GenerateLowEntropySource(); |
local_state->SetInteger(prefs::kMetricsLowEntropySource, low_entropy_source_); |
+ local_state->ClearPref(prefs::kMetricsOldLowEntropySource); |
metrics::CachingPermutedEntropyProvider::ClearCache(local_state); |
return low_entropy_source_; |