michael@0: // Copyright (c) 2012 The Chromium Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: michael@0: #ifndef BASE_GUID_H_ michael@0: #define BASE_GUID_H_ michael@0: michael@0: #include michael@0: michael@0: #include "base/base_export.h" michael@0: #include "base/basictypes.h" michael@0: #include "build/build_config.h" michael@0: michael@0: namespace base { michael@0: michael@0: // Generate a 128-bit random GUID of the form: "%08X-%04X-%04X-%04X-%012llX". michael@0: // If GUID generation fails an empty string is returned. michael@0: // The POSIX implementation uses psuedo random number generation to create michael@0: // the GUID. The Windows implementation uses system services. michael@0: BASE_EXPORT std::string GenerateGUID(); michael@0: michael@0: // Returns true if the input string conforms to the GUID format. michael@0: BASE_EXPORT bool IsValidGUID(const std::string& guid); michael@0: michael@0: #if defined(OS_POSIX) michael@0: // For unit testing purposes only. Do not use outside of tests. michael@0: BASE_EXPORT std::string RandomDataToGUIDString(const uint64 bytes[2]); michael@0: #endif michael@0: michael@0: } // namespace guid michael@0: michael@0: #endif // BASE_GUID_H_