Index: chrome/browser/metrics/metrics_service.cc |
=================================================================== |
--- chrome/browser/metrics/metrics_service.cc (revision 207251) |
+++ chrome/browser/metrics/metrics_service.cc (working copy) |
@@ -291,9 +291,9 @@ |
} |
// The argument used to generate a non-identifying entropy source. We want no |
-// more than 13 bits of entropy, so use this max to return a number between 1 |
-// and 2^13 = 8192 as the entropy source. |
-const uint32 kMaxLowEntropySize = (1 << 13); |
+// more than 13 bits of entropy, so use this max to return a number in the range |
+// [0, 7999] as the entropy source (12.97 bits of entropy). |
+const int kMaxLowEntropySize = 8000; |
// Default prefs value for prefs::kMetricsLowEntropySource to indicate that the |
// value has not yet been set. |
@@ -1043,13 +1043,17 @@ |
// Only try to load the value from prefs if the user did not request a reset. |
// Otherwise, skip to generating a new value. |
if (!command_line->HasSwitch(switches::kResetVariationState)) { |
- const int value = local_state->GetInteger(prefs::kMetricsLowEntropySource); |
- if (value != kLowEntropySourceNotSet) { |
- // Ensure the prefs value is in the range [0, kMaxLowEntropySize). Old |
- // versions of the code would generate values in the range of [1, 8192], |
- // so the below line ensures 8192 gets mapped to 0 and also guards against |
- // the case of corrupted values. |
- low_entropy_source_ = value % kMaxLowEntropySize; |
+ 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) { |
+ low_entropy_source_ = value; |
UMA_HISTOGRAM_BOOLEAN("UMA.GeneratedLowEntropySource", false); |
return low_entropy_source_; |
} |