summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
authorjcampan@google.com <jcampan@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-01 16:17:15 +0000
committerjcampan@google.com <jcampan@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-01 16:17:15 +0000
commitfeb2ebfe608c307d3731943616a3ed6eb53b9ba1 (patch)
tree7efb0a3ddf29e5797feeff5da1406308dffbf30b /chrome/common
parent5f40d2dacb11c879e43521947b23ca6b7da40c4d (diff)
downloadchromium_src-feb2ebfe608c307d3731943616a3ed6eb53b9ba1.zip
chromium_src-feb2ebfe608c307d3731943616a3ed6eb53b9ba1.tar.gz
chromium_src-feb2ebfe608c307d3731943616a3ed6eb53b9ba1.tar.bz2
Using a better seed. Using time() causes the random sequence to start with the same number when run several times consecutively.
BUG=None git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/rand_util.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/chrome/common/rand_util.cc b/chrome/common/rand_util.cc
index 2c1b190..13c586f 100644
--- a/chrome/common/rand_util.cc
+++ b/chrome/common/rand_util.cc
@@ -34,6 +34,7 @@
#include "base/logging.h"
#include "base/thread_local_storage.h"
+#include "base/time.h"
#include "base/win_util.h"
namespace rand_util {
@@ -44,7 +45,9 @@ int g_tls_index = ThreadLocalStorage::Alloc();
int RandInt(int min, int max) {
if (ThreadLocalStorage::Get(g_tls_index) == 0) {
ThreadLocalStorage::Set(g_tls_index, reinterpret_cast<void*>(1));
- srand(static_cast<unsigned int>(time(0)));
+ TimeDelta now = TimeTicks::UnreliableHighResNow() - TimeTicks();
+ unsigned int seed = static_cast<unsigned int>(now.InMicroseconds());
+ srand(seed);
}
// From the rand man page, use this instead of just rand() % max, so that the