Index: chrome/browser/metrics/metrics_service.cc |
=================================================================== |
--- chrome/browser/metrics/metrics_service.cc (revision 152081) |
+++ chrome/browser/metrics/metrics_service.cc (working copy) |
@@ -185,6 +185,7 @@ |
#include "chrome/common/chrome_notification_types.h" |
#include "chrome/common/chrome_result_codes.h" |
#include "chrome/common/chrome_switches.h" |
+#include "chrome/common/metrics/entropy_provider.h" |
#include "chrome/common/metrics/metrics_log_manager.h" |
#include "chrome/common/net/test_server_locations.h" |
#include "chrome/common/pref_names.h" |
@@ -279,7 +280,7 @@ |
// Generates a new non-identifying entropy source used to seed persistent |
// activities. |
int GenerateLowEntropySource() { |
- return base::RandInt(1, kMaxEntropySize); |
+ return base::RandInt(0, kMaxEntropySize - 1); |
} |
// Converts an exit code into something that can be inserted into our |
@@ -344,7 +345,7 @@ |
return codes; |
} |
-} |
+} // namespace |
// static |
MetricsService::ShutdownCleanliness MetricsService::clean_shutdown_status_ = |
@@ -539,7 +540,11 @@ |
return client_id_; |
} |
-std::string MetricsService::GetEntropySource(bool reporting_will_be_enabled) { |
+scoped_ptr<base::FieldTrial::EntropyProvider> |
+ MetricsService::GetEntropyProvider(bool reporting_will_be_enabled) { |
+ scoped_ptr<base::FieldTrial::EntropyProvider> entropy_provider; |
Ilya Sherman
2012/08/17 17:53:20
Optional nit: I think you can still return the ent
Alexei Svitkine (slow)
2012/08/20 15:57:40
Done.
|
+ const int low_entropy_source = GetLowEntropySource(); |
jar (doing other things)
2012/08/17 19:06:19
nit: move this definition closer to first (and onl
Alexei Svitkine (slow)
2012/08/20 15:57:40
I've inlined this into the two callers.
|
+ |
// For metrics reporting-enabled users, we combine the client ID and low |
// entropy source to get the final entropy source. Otherwise, only use the low |
// entropy source. |
@@ -547,13 +552,18 @@ |
// 1) It makes the entropy source less identifiable for parties that do not |
// know the low entropy source. |
// 2) It makes the final entropy source resettable. |
- std::string low_entropy_source = base::IntToString(GetLowEntropySource()); |
if (reporting_will_be_enabled) { |
entropy_source_returned_ = LAST_ENTROPY_HIGH; |
- return client_id_ + low_entropy_source; |
+ const std::string high_entropy_source = |
+ client_id_ + base::IntToString(low_entropy_source); |
+ entropy_provider.reset(new SHA1EntropyProvider(high_entropy_source)); |
+ } else { |
+ entropy_source_returned_ = LAST_ENTROPY_LOW; |
+ entropy_provider.reset(new PermutedEntropyProvider(GetLowEntropySource(), |
hfung
2012/08/17 17:35:40
GetLowEntropySource() -> low_entropy_source?
Alexei Svitkine (slow)
2012/08/17 17:57:40
Done.
|
+ kMaxEntropySize)); |
} |
- entropy_source_returned_ = LAST_ENTROPY_LOW; |
- return low_entropy_source; |
+ |
+ return entropy_provider.Pass(); |
} |
void MetricsService::ForceClientIdCreation() { |