diff options
Diffstat (limited to 'third_party/chromium/base/guid.h')
-rw-r--r-- | third_party/chromium/base/guid.h | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/third_party/chromium/base/guid.h b/third_party/chromium/base/guid.h index 1bb9ab2..e6f4508 100644 --- a/third_party/chromium/base/guid.h +++ b/third_party/chromium/base/guid.h @@ -10,20 +10,33 @@ #include <string> #include "base/base_export.h" +#include "base/strings/string_piece.h" #include "build/build_config.h" namespace base { -// Generate a 128-bit random GUID of the form: "%08X-%04X-%04X-%04X-%012llX". +// Generate a 128-bit (pseudo) random GUID in the form of version 4 as described +// in RFC 4122, section 4.4. +// The format of GUID version 4 must be xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx, +// where y is one of [8, 9, A, B]. +// The hexadecimal values "a" through "f" are output as lower case characters. // If GUID generation fails an empty string is returned. -// The POSIX implementation uses pseudo random number generation to create -// the GUID. The Windows implementation uses system services. std::string GenerateGUID(); -#if defined(OS_POSIX) +// Returns true if the input string conforms to the version 4 GUID format. +// Note that this does NOT check if the hexadecimal values "a" through "f" +// are in lower case characters, as Version 4 RFC says onput they're +// case insensitive. (Use IsValidGUIDOutputString for checking if the +// given string is valid output string) +bool IsValidGUID(const base::StringPiece& guid); + +// Returns true if the input string is valid version 4 GUID output string. +// This also checks if the hexadecimal values "a" through "f" are in lower +// case characters. +bool IsValidGUIDOutputString(const base::StringPiece& guid); + // For unit testing purposes only. Do not use outside of tests. std::string RandomDataToGUIDString(const uint64_t bytes[2]); -#endif } // namespace base |