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

Side by Side 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: init 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 unified diff | Download patch
« client/settings_test.cc ('K') | « util/misc/uuid.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Crashpad Authors. All rights reserved. 1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 #if !defined(__STDC_FORMAT_MACROS) 15 #if !defined(__STDC_FORMAT_MACROS)
16 #define __STDC_FORMAT_MACROS 16 #define __STDC_FORMAT_MACROS
17 #endif 17 #endif
18 18
19 #include "util/misc/uuid.h" 19 #include "util/misc/uuid.h"
20 20
21 #include <inttypes.h> 21 #include <inttypes.h>
22 #include <stdio.h> 22 #include <stdio.h>
23 #include <string.h> 23 #include <string.h>
24 24
25 #include "base/basictypes.h" 25 #include "base/basictypes.h"
26 #include "base/logging.h"
26 #include "base/strings/stringprintf.h" 27 #include "base/strings/stringprintf.h"
27 #include "base/strings/utf_string_conversions.h" 28 #include "base/strings/utf_string_conversions.h"
28 #include "base/sys_byteorder.h" 29 #include "base/sys_byteorder.h"
29 #include "util/stdlib/cxx.h" 30 #include "util/stdlib/cxx.h"
30 31
32 #if defined(OS_MACOSX)
33 #include <uuid/uuid.h>
34 #endif // OS_MACOSX
35
31 #if CXX_LIBRARY_VERSION >= 2011 36 #if CXX_LIBRARY_VERSION >= 2011
32 #include <type_traits> 37 #include <type_traits>
33 #endif 38 #endif
34 39
35 namespace crashpad { 40 namespace crashpad {
36 41
37 static_assert(sizeof(UUID) == 16, "UUID must be 16 bytes"); 42 static_assert(sizeof(UUID) == 16, "UUID must be 16 bytes");
38 43
39 #if CXX_LIBRARY_VERSION >= 2011 44 #if CXX_LIBRARY_VERSION >= 2011
40 static_assert(std::is_standard_layout<UUID>::value, 45 static_assert(std::is_standard_layout<UUID>::value,
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 data_5[4], 117 data_5[4],
113 data_5[5]); 118 data_5[5]);
114 } 119 }
115 120
116 #if defined(OS_WIN) 121 #if defined(OS_WIN)
117 base::string16 UUID::ToString16() const { 122 base::string16 UUID::ToString16() const {
118 return base::UTF8ToUTF16(ToString()); 123 return base::UTF8ToUTF16(ToString());
119 } 124 }
120 #endif // OS_WIN 125 #endif // OS_WIN
121 126
127 // static
128 bool UUID::GenerateFromSystem(UUID* into) {
129 #if defined(OS_MACOSX)
130 uuid_t uuid;
131 uuid_generate(uuid);
132 into->InitializeFromBytes(uuid);
133 return true;
134 #elif defined(OS_WIN)
135 ::UUID system_uuid;
136 if (UuidCreate(&system_uuid) != RPC_S_OK) {
137 LOG(ERROR) << "UuidCreate";
138 return false;
139 }
140 into->InitializeFromSystemUUID(&system_uuid);
141 return true;
142 #endif // OS_MACOSX
Robert Sesek 2015/04/01 15:08:26 #else #error "This function needs to be ported" ?
scottmg 2015/04/01 19:32:11 I figured it just wouldn't compile, but sure.
143 }
144
122 } // namespace crashpad 145 } // namespace crashpad
OLDNEW
« client/settings_test.cc ('K') | « util/misc/uuid.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698