OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MOJO_EDK_SYSTEM_UNIQUE_IDENTIFIER_H_ | 5 #ifndef MOJO_EDK_SYSTEM_UNIQUE_IDENTIFIER_H_ |
6 #define MOJO_EDK_SYSTEM_UNIQUE_IDENTIFIER_H_ | 6 #define MOJO_EDK_SYSTEM_UNIQUE_IDENTIFIER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string.h> | 9 #include <string.h> |
10 | 10 |
11 #include <functional> | 11 #include <functional> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "base/containers/hash_tables.h" // For |base::HashInts64()|. | 14 #include "base/containers/hash_tables.h" // For |base::HashInts64()|. |
15 #include "mojo/edk/system/system_impl_export.h" | |
16 #include "mojo/public/cpp/system/macros.h" | 15 #include "mojo/public/cpp/system/macros.h" |
17 | 16 |
18 namespace mojo { | 17 namespace mojo { |
19 namespace system { | 18 namespace system { |
20 | 19 |
21 class UniqueIdentifier; | 20 class UniqueIdentifier; |
22 | 21 |
23 } // namespace system | 22 } // namespace system |
24 } // namespace mojo | 23 } // namespace mojo |
25 | 24 |
(...skipping 10 matching lines...) Expand all Loading... |
36 namespace embedder { | 35 namespace embedder { |
37 | 36 |
38 class PlatformSupport; | 37 class PlatformSupport; |
39 | 38 |
40 } // namespace embedder | 39 } // namespace embedder |
41 | 40 |
42 namespace system { | 41 namespace system { |
43 | 42 |
44 // |UniqueIdentifier| is a POD class whose value is used to uniquely identify | 43 // |UniqueIdentifier| is a POD class whose value is used to uniquely identify |
45 // things. | 44 // things. |
46 class MOJO_SYSTEM_IMPL_EXPORT UniqueIdentifier { | 45 class UniqueIdentifier { |
47 public: | 46 public: |
48 // This generates a new identifier. Uniqueness is "guaranteed" (i.e., | 47 // This generates a new identifier. Uniqueness is "guaranteed" (i.e., |
49 // probabilistically) for identifiers. | 48 // probabilistically) for identifiers. |
50 static UniqueIdentifier Generate(embedder::PlatformSupport* platform_support); | 49 static UniqueIdentifier Generate(embedder::PlatformSupport* platform_support); |
51 | 50 |
52 // This reconstitutes an identifier from its representation as a string | 51 // This reconstitutes an identifier from its representation as a string |
53 // (generated by |ToString()|, below). On success, |*success| is set to true; | 52 // (generated by |ToString()|, below). On success, |*success| is set to true; |
54 // on failure, it is set to false (and the return value is undefined). | 53 // on failure, it is set to false (and the return value is undefined). |
55 static UniqueIdentifier FromString(const std::string& s, bool* success); | 54 static UniqueIdentifier FromString(const std::string& s, bool* success); |
56 | 55 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 return base::HashInts64( | 97 return base::HashInts64( |
99 *reinterpret_cast<uint64_t*>(unique_identifier.data_), | 98 *reinterpret_cast<uint64_t*>(unique_identifier.data_), |
100 *reinterpret_cast<uint64_t*>(unique_identifier.data_ + | 99 *reinterpret_cast<uint64_t*>(unique_identifier.data_ + |
101 sizeof(uint64_t))); | 100 sizeof(uint64_t))); |
102 } | 101 } |
103 }; | 102 }; |
104 | 103 |
105 } // namespace std | 104 } // namespace std |
106 | 105 |
107 #endif // MOJO_EDK_SYSTEM_UNIQUE_IDENTIFIER_H_ | 106 #endif // MOJO_EDK_SYSTEM_UNIQUE_IDENTIFIER_H_ |
OLD | NEW |