Index: util/misc/uuid.cc |
diff --git a/util/misc/uuid.cc b/util/misc/uuid.cc |
index 904efcd339838d7b8a9d0e2f456ccfc49d5ffe6e..111a8b4082fbc3355b54925e80f5b9272600b5f1 100644 |
--- a/util/misc/uuid.cc |
+++ b/util/misc/uuid.cc |
@@ -23,11 +23,16 @@ |
#include <string.h> |
#include "base/basictypes.h" |
+#include "base/logging.h" |
#include "base/strings/stringprintf.h" |
#include "base/strings/utf_string_conversions.h" |
#include "base/sys_byteorder.h" |
#include "util/stdlib/cxx.h" |
+#if defined(OS_MACOSX) |
+#include <uuid/uuid.h> |
+#endif // OS_MACOSX |
+ |
#if CXX_LIBRARY_VERSION >= 2011 |
#include <type_traits> |
#endif |
@@ -119,4 +124,24 @@ base::string16 UUID::ToString16() const { |
} |
#endif // OS_WIN |
+// static |
+bool UUID::GenerateFromSystem(UUID* into) { |
+#if defined(OS_MACOSX) |
+ uuid_t uuid; |
+ uuid_generate(uuid); |
+ into->InitializeFromBytes(uuid); |
+ return true; |
+#elif defined(OS_WIN) |
+ ::UUID system_uuid; |
+ if (UuidCreate(&system_uuid) != RPC_S_OK) { |
+ LOG(ERROR) << "UuidCreate"; |
+ return false; |
+ } |
+ into->InitializeFromSystemUUID(&system_uuid); |
+ return true; |
+#else |
+#error Port. |
+#endif // OS_MACOSX |
+} |
+ |
} // namespace crashpad |