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

Side by Side Diff: util/misc/uuid.h

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: . 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
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,
(...skipping 11 matching lines...) Expand all
22 #include "base/strings/string16.h" 22 #include "base/strings/string16.h"
23 #include "base/strings/string_piece.h" 23 #include "base/strings/string_piece.h"
24 #include "build/build_config.h" 24 #include "build/build_config.h"
25 25
26 #if defined(OS_WIN) 26 #if defined(OS_WIN)
27 #include <rpc.h> 27 #include <rpc.h>
28 #endif 28 #endif
29 29
30 namespace crashpad { 30 namespace crashpad {
31 31
32 enum class InitializeWithNewTag {
Mark Mentovai 2015/04/20 20:45:08 Move into struct UUID?
scottmg 2015/04/20 21:11:28 Done.
33 };
34
32 //! \brief A universally unique identifier (%UUID). 35 //! \brief A universally unique identifier (%UUID).
33 //! 36 //!
34 //! An alternate term for %UUID is “globally unique identifier” (GUID), used 37 //! An alternate term for %UUID is “globally unique identifier” (GUID), used
35 //! primarily by Microsoft. 38 //! primarily by Microsoft.
36 //! 39 //!
37 //! A %UUID is a unique 128-bit number specified by RFC 4122. 40 //! A %UUID is a unique 128-bit number specified by RFC 4122.
38 //! 41 //!
39 //! This is a standard-layout structure. 42 //! This is a standard-layout structure.
40 struct UUID { 43 struct UUID {
41 //! \brief Initializes the %UUID to zero. 44 //! \brief Initializes the %UUID to zero.
42 UUID(); 45 UUID();
43 46
47 //! \brief Initializes the %UUID using a standard system facility to generate
48 //! the value.
49 //!
50 //! CHECKs on failure with a message logged.
51 explicit UUID(InitializeWithNewTag);
52
44 //! \copydoc InitializeFromBytes() 53 //! \copydoc InitializeFromBytes()
45 explicit UUID(const uint8_t* bytes); 54 explicit UUID(const uint8_t* bytes);
46 55
47 bool operator==(const UUID& that) const; 56 bool operator==(const UUID& that) const;
48 bool operator!=(const UUID& that) const { return !operator==(that); } 57 bool operator!=(const UUID& that) const { return !operator==(that); }
49 58
50 //! \brief Initializes the %UUID from a sequence of bytes. 59 //! \brief Initializes the %UUID from a sequence of bytes.
51 //! 60 //!
52 //! \a bytes is taken as a %UUID laid out in big-endian format in memory. On 61 //! \a bytes is taken as a %UUID laid out in big-endian format in memory. On
53 //! little-endian machines, appropriate byte-swapping will be performed to 62 //! little-endian machines, appropriate byte-swapping will be performed to
54 //! initialize an object’s data members. 63 //! initialize an object’s data members.
55 //! 64 //!
56 //! \param[in] bytes A buffer of exactly 16 bytes that will be assigned to the 65 //! \param[in] bytes A buffer of exactly 16 bytes that will be assigned to the
57 //! %UUID. 66 //! %UUID.
58 void InitializeFromBytes(const uint8_t* bytes); 67 void InitializeFromBytes(const uint8_t* bytes);
59 68
60 //! \brief Initializes the %UUID from a RFC 4122 §3 formatted string. 69 //! \brief Initializes the %UUID from a RFC 4122 §3 formatted string.
61 //! 70 //!
62 //! \param[in] string A string of the form 71 //! \param[in] string A string of the form
63 //! `"00112233-4455-6677-8899-aabbccddeeff"`. 72 //! `"00112233-4455-6677-8899-aabbccddeeff"`.
64 //! 73 //!
65 //! \return `true` if the string was formatted correctly and the object has 74 //! \return `true` if the string was formatted correctly and the object has
66 //! been initialized with the data. `false` if the string could not be 75 //! been initialized with the data. `false` if the string could not be
67 //! parsed, with the object state untouched. 76 //! parsed, with the object state untouched.
68 bool InitializeFromString(const base::StringPiece& string); 77 bool InitializeFromString(const base::StringPiece& string);
69 78
79 //! \brief Initializes the %UUID using a standard system facility to generate
80 //! the value.
81 //!
82 //! \return `true` if the %UUID was initialized correctly, `false` otherwise
83 //! with a message logged.
84 bool InitializeWithNew();
85
70 #if defined(OS_WIN) || DOXYGEN 86 #if defined(OS_WIN) || DOXYGEN
71 //! \brief Initializes the %UUID from a system `UUID` or `GUID` structure. 87 //! \brief Initializes the %UUID from a system `UUID` or `GUID` structure.
72 //! 88 //!
73 //! \param[in] system_uuid A system `UUID` or `GUID` structure. 89 //! \param[in] system_uuid A system `UUID` or `GUID` structure.
74 void InitializeFromSystemUUID(const ::UUID* system_uuid); 90 void InitializeFromSystemUUID(const ::UUID* system_uuid);
75 #endif // OS_WIN 91 #endif // OS_WIN
76 92
77 //! \brief Formats the %UUID per RFC 4122 §3. 93 //! \brief Formats the %UUID per RFC 4122 §3.
78 //! 94 //!
79 //! \return A string of the form `"00112233-4455-6677-8899-aabbccddeeff"`. 95 //! \return A string of the form `"00112233-4455-6677-8899-aabbccddeeff"`.
80 std::string ToString() const; 96 std::string ToString() const;
81 97
82 #if defined(OS_WIN) || DOXYGEN 98 #if defined(OS_WIN) || DOXYGEN
83 //! \brief The same as ToString, but returned as a string16. 99 //! \brief The same as ToString, but returned as a string16.
84 base::string16 ToString16() const; 100 base::string16 ToString16() const;
85 #endif // OS_WIN 101 #endif // OS_WIN
86 102
87 // These fields are laid out according to RFC 4122 §4.1.2. 103 // These fields are laid out according to RFC 4122 §4.1.2.
88 uint32_t data_1; 104 uint32_t data_1;
89 uint16_t data_2; 105 uint16_t data_2;
90 uint16_t data_3; 106 uint16_t data_3;
91 uint8_t data_4[2]; 107 uint8_t data_4[2];
92 uint8_t data_5[6]; 108 uint8_t data_5[6];
93 }; 109 };
94 110
95 } // namespace crashpad 111 } // namespace crashpad
96 112
97 #endif // CRASHPAD_UTIL_MISC_UUID_H_ 113 #endif // CRASHPAD_UTIL_MISC_UUID_H_
OLDNEW
« client/settings.cc ('K') | « util/file/file_io_win.cc ('k') | util/misc/uuid.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698