Chromium Code Reviews| Index: components/variations/entropy_provider.cc |
| diff --git a/components/variations/entropy_provider.cc b/components/variations/entropy_provider.cc |
| index d07277f7add2dae785bf671f364596e7f4155f10..abb4fdb4c9a1576f3bfcd29861a4b46044a86ecd 100644 |
| --- a/components/variations/entropy_provider.cc |
| +++ b/components/variations/entropy_provider.cc |
| @@ -11,6 +11,7 @@ |
| #include "base/logging.h" |
| #include "base/rand_util.h" |
| #include "base/sha1.h" |
| +#include "base/strings/string_number_conversions.h" |
| #include "base/sys_byteorder.h" |
| #include "components/variations/metrics_util.h" |
| @@ -87,7 +88,10 @@ double SHA1EntropyProvider::GetEntropyForTrial( |
| // it has been observed that this method does not result in a uniform |
| // distribution given the same |trial_name|. When using such a low entropy |
| // source, PermutedEntropyProvider should be used instead. |
| - std::string input(entropy_source_ + trial_name); |
| + std::string randomization_string = |
| + randomization_seed == 0 ? trial_name |
| + : base::UintToString(randomization_seed); |
| + std::string input(entropy_source_ + randomization_string); |
|
Alexei Svitkine (slow)
2016/11/16 06:36:48
Nit: How about avoiding the extra string copy?
e.
jwd
2016/11/16 16:15:45
Done.
|
| unsigned char sha1_hash[base::kSHA1Length]; |
| base::SHA1HashBytes(reinterpret_cast<const unsigned char*>(input.c_str()), |
| input.size(), |