Vitaly Buka | cbed206 | 2015-08-17 12:54:05 -0700 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef BASE_GUID_H_ |
| 6 | #define BASE_GUID_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | |
| 10 | #include "base/base_export.h" |
| 11 | #include "base/basictypes.h" |
Vitaly Buka | 8750b27 | 2015-08-18 18:39:08 -0700 | [diff] [blame] | 12 | #include "base/build/build_config.h" |
Vitaly Buka | cbed206 | 2015-08-17 12:54:05 -0700 | [diff] [blame] | 13 | |
| 14 | namespace base { |
| 15 | |
| 16 | // Generate a 128-bit random GUID of the form: "%08X-%04X-%04X-%04X-%012llX". |
| 17 | // If GUID generation fails an empty string is returned. |
| 18 | // The POSIX implementation uses pseudo random number generation to create |
| 19 | // the GUID. The Windows implementation uses system services. |
Vitaly Buka | 60b8f00 | 2015-08-20 13:47:48 -0700 | [diff] [blame] | 20 | std::string GenerateGUID(); |
Vitaly Buka | cbed206 | 2015-08-17 12:54:05 -0700 | [diff] [blame] | 21 | |
Vitaly Buka | cbed206 | 2015-08-17 12:54:05 -0700 | [diff] [blame] | 22 | #if defined(OS_POSIX) |
| 23 | // For unit testing purposes only. Do not use outside of tests. |
Vitaly Buka | 60b8f00 | 2015-08-20 13:47:48 -0700 | [diff] [blame] | 24 | std::string RandomDataToGUIDString(const uint64 bytes[2]); |
Vitaly Buka | cbed206 | 2015-08-17 12:54:05 -0700 | [diff] [blame] | 25 | #endif |
| 26 | |
| 27 | } // namespace base |
| 28 | |
| 29 | #endif // BASE_GUID_H_ |