Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1403)

Unified Diff: chrome/browser/metrics/metrics_service.cc

Issue 3800001: Factoring GUID generation from metrics to base (Closed)
Patch Set: Adding unit tests. Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/metrics/metrics_service.h ('k') | chrome/browser/metrics/metrics_service_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/metrics/metrics_service.cc
diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc
index b6d4c3f6d755597045c227ebe926df84278a433a..e4c9a128240ce974ca5048d73ae4f337f06a1444 100644
--- a/chrome/browser/metrics/metrics_service.cc
+++ b/chrome/browser/metrics/metrics_service.cc
@@ -158,15 +158,11 @@
#include "chrome/browser/metrics/metrics_service.h"
-#if defined(OS_WIN)
-#include <windows.h>
-#include <objbase.h>
-#endif
-
#include "base/base64.h"
#include "base/command_line.h"
#include "base/histogram.h"
#include "base/md5.h"
+#include "base/rand_util.h"
#include "base/string_number_conversions.h"
#include "base/thread.h"
#include "base/utf_string_conversions.h"
@@ -192,10 +188,6 @@
#include "webkit/glue/plugins/webplugininfo.h"
#include "libxml/xmlwriter.h"
-#if !defined(OS_WIN)
-#include "base/rand_util.h"
-#endif
-
// TODO(port): port browser_distribution.h.
#if !defined(OS_POSIX)
#include "chrome/installer/util/browser_distribution.h"
@@ -816,38 +808,9 @@ void MetricsService::OnInitTaskComplete(
}
std::string MetricsService::GenerateClientID() {
-#if defined(OS_WIN)
- const int kGUIDSize = 39;
-
- GUID guid;
- HRESULT guid_result = CoCreateGuid(&guid);
- DCHECK(SUCCEEDED(guid_result));
-
- std::wstring guid_string;
- int result = StringFromGUID2(guid,
- WriteInto(&guid_string, kGUIDSize), kGUIDSize);
- DCHECK(result == kGUIDSize);
-
- return WideToUTF8(guid_string.substr(1, guid_string.length() - 2));
-#else
- uint64 sixteen_bytes[2] = { base::RandUint64(), base::RandUint64() };
- return RandomBytesToGUIDString(sixteen_bytes);
-#endif
+ return base::GenerateGUID();
}
-#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("%08X-%04X-%04X-%04X-%012llX",
- static_cast<unsigned int>(bytes[0] >> 32),
- static_cast<unsigned int>((bytes[0] >> 16) & 0x0000ffff),
- static_cast<unsigned int>(bytes[0] & 0x0000ffff),
- static_cast<unsigned int>(bytes[1] >> 48),
- bytes[1] & 0x0000ffffffffffffULL);
-}
-#endif
-
//------------------------------------------------------------------------------
// State save methods
« no previous file with comments | « chrome/browser/metrics/metrics_service.h ('k') | chrome/browser/metrics/metrics_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698