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

Unified Diff: util/misc/uuid.cc

Issue 999953002: Use LockFile/UnlockFile for Settings to port to Windows (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@lock-fileio-2
Patch Set: Tag inside, no info spam Created 5 years, 8 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 | « util/misc/uuid.h ('k') | util/misc/uuid_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: util/misc/uuid.cc
diff --git a/util/misc/uuid.cc b/util/misc/uuid.cc
index 904efcd339838d7b8a9d0e2f456ccfc49d5ffe6e..ca7b22b1fffed0494e2a1efca1ff50f4e91627c5 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
@@ -44,6 +49,10 @@ static_assert(std::is_standard_layout<UUID>::value,
UUID::UUID() : data_1(0), data_2(0), data_3(0), data_4(), data_5() {
}
+UUID::UUID(InitializeWithNewTag) {
+ CHECK(InitializeWithNew());
+}
+
UUID::UUID(const uint8_t* bytes) {
InitializeFromBytes(bytes);
}
@@ -88,6 +97,25 @@ bool UUID::InitializeFromString(const base::StringPiece& string) {
return true;
}
+bool UUID::InitializeWithNew() {
+#if defined(OS_MACOSX)
+ uuid_t uuid;
+ uuid_generate(uuid);
+ InitializeFromBytes(uuid);
+ return true;
+#elif defined(OS_WIN)
+ ::UUID system_uuid;
+ if (UuidCreate(&system_uuid) != RPC_S_OK) {
+ LOG(ERROR) << "UuidCreate";
+ return false;
+ }
+ InitializeFromSystemUUID(&system_uuid);
+ return true;
+#else
+#error Port.
+#endif // OS_MACOSX
+}
+
#if defined(OS_WIN)
void UUID::InitializeFromSystemUUID(const ::UUID* system_uuid) {
static_assert(sizeof(::UUID) == sizeof(UUID),
« no previous file with comments | « util/misc/uuid.h ('k') | util/misc/uuid_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698