summaryrefslogtreecommitdiffstats
path: root/chrome/browser/metrics/metrics_service.cc
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-08 20:54:13 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-08 20:54:13 +0000
commit06aaac23ed35f7f34ab523172fc31322a88f1e38 (patch)
tree65ac6bd34e39cb5dbbdb800ba611e7e254ce4dae /chrome/browser/metrics/metrics_service.cc
parent837be4ad6a8e740fe45e19e2d1699d21f83f7ea4 (diff)
downloadchromium_src-06aaac23ed35f7f34ab523172fc31322a88f1e38.zip
chromium_src-06aaac23ed35f7f34ab523172fc31322a88f1e38.tar.gz
chromium_src-06aaac23ed35f7f34ab523172fc31322a88f1e38.tar.bz2
http://codereview.chromium.org/147084
Implements unique client ID generation for Posix. Client ID generation happens once-per-install of Chromium (...well, this is mostly true, at least). On Windows, the code currently uses some system library code that generates a GUID. We don't ACTUALLY need a GUID, something that's quite random and in the same format will work. Since we don't want to add a dependency on libuuid for POSIX, I created a less-random-but-still-good-enough version. BUG=15418 TEST=none Review URL: http://codereview.chromium.org/149343 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20184 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/metrics/metrics_service.cc')
-rw-r--r--chrome/browser/metrics/metrics_service.cc22
1 files changed, 18 insertions, 4 deletions
diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc
index 30e1628..aaffb64 100644
--- a/chrome/browser/metrics/metrics_service.cc
+++ b/chrome/browser/metrics/metrics_service.cc
@@ -166,6 +166,7 @@
#include "base/histogram.h"
#include "base/path_service.h"
#include "base/platform_thread.h"
+#include "base/rand_util.h"
#include "base/string_util.h"
#include "base/task.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
@@ -762,16 +763,29 @@ std::string MetricsService::GenerateClientID() {
DCHECK(result == kGUIDSize);
return WideToUTF8(guid_string.substr(1, guid_string.length() - 2));
+#elif defined(LINUX2)
+ uint64 sixteen_bytes[2] = { base::RandUint64(), base::RandUint64() };
+ return RandomBytesToGUIDString(sixteen_bytes);
#else
- // TODO(port): Implement for Mac and linux.
- // Rather than actually implementing a random source, might this be a good
- // time to implement http://code.google.com/p/chromium/issues/detail?id=2278
- // ? I think so!
+ // TODO(cmasone): enable the above for all OS_POSIX platforms once the
+ // first-run dialog text is all up to date.
NOTIMPLEMENTED();
return std::string();
#endif
}
+#if defined(OS_POSIX)
+// TODO(cmasone): Once we're comfortable this works, migrate Windows code to
+// use this as well.
+std::string MetricsService::RandomBytesToGUIDString(const uint64 bytes[2]) {
+ return StringPrintf("%08llX-%04llX-%04llX-%04llX-%012llX",
+ bytes[0] >> 32,
+ (bytes[0] >> 16) & 0x0000ffff,
+ bytes[0] & 0x0000ffff,
+ bytes[1] >> 48,
+ bytes[1] & 0x0000ffffffffffffULL);
+}
+#endif
//------------------------------------------------------------------------------
// State save methods