Index: chrome/browser/metrics/metrics_service.cc |
=================================================================== |
--- chrome/browser/metrics/metrics_service.cc (revision 260135) |
+++ 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::kMetricsReportingEnabledTimestamp, 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,10 @@ |
registry->RegisterInt64Pref(prefs::kUninstallLastLaunchTimeSec, 0); |
registry->RegisterInt64Pref(prefs::kUninstallLastObservedRunTimeSec, 0); |
+ // TODO(asvitkine): Remove these once a couple of releases have passed. |
Ilya Sherman
2014/03/28 18:23:06
nit: Please add a specific milestone target to thi
Alexei Svitkine (slow)
2014/03/28 18:40:19
Done. The milestone is on the bug.
|
+ registry->RegisterStringPref(prefs::kMetricsOldClientID, std::string()); |
+ registry->RegisterIntegerPref(prefs::kMetricsOldLowEntropySource, 0); |
+ |
#if defined(OS_ANDROID) |
RegisterPrefsAndroid(registry); |
#endif // defined(OS_ANDROID) |
@@ -641,9 +645,14 @@ |
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())); |
+ // Record the timestamp of when the user opted in to UMA. |
Ilya Sherman
2014/03/28 18:23:06
nit: Move this inside the if branch, since it does
Alexei Svitkine (slow)
2014/03/28 18:40:19
Done.
|
+ if (pref->GetString(prefs::kMetricsOldClientID).empty()) { |
+ pref->SetInt64(prefs::kMetricsReportingEnabledTimestamp, |
+ Time::Now().ToTimeT()); |
+ } else { |
+ UMA_HISTOGRAM_BOOLEAN("UMA.MigratedClientID", true); |
Ilya Sherman
2014/03/28 18:23:06
You don't seem to ever emit a |false| value to thi
Alexei Svitkine (slow)
2014/03/28 18:40:19
This will allow analysis of when users migrated th
Ilya Sherman
2014/03/28 19:22:48
Fair 'nuff.
|
+ } |
+ pref->ClearPref(prefs::kMetricsOldClientID); |
} |
void MetricsService::EnableRecording() { |
@@ -1198,12 +1207,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 +1219,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_; |