blob: 2a4ed4c4b5c13e70c87225760c49f17c15549e89 [file] [log] [blame]
[email protected]7e49ad32012-06-14 14:22:071// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]3469e7e2010-10-14 20:34:592// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]7e49ad32012-06-14 14:22:075#ifndef BASE_GUID_H_
6#define BASE_GUID_H_
[email protected]3469e7e2010-10-14 20:34:597
8#include <string>
9
[email protected]7e49ad32012-06-14 14:22:0710#include "base/base_export.h"
[email protected]3469e7e2010-10-14 20:34:5911#include "base/basictypes.h"
12#include "build/build_config.h"
13
[email protected]7e49ad32012-06-14 14:22:0714namespace base {
[email protected]3469e7e2010-10-14 20:34:5915
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 psuedo random number generation to create
19// the GUID. The Windows implementation uses system services.
[email protected]7e49ad32012-06-14 14:22:0720BASE_EXPORT std::string GenerateGUID();
[email protected]3469e7e2010-10-14 20:34:5921
[email protected]d3d728e92010-10-20 03:24:5522// Returns true if the input string conforms to the GUID format.
[email protected]7e49ad32012-06-14 14:22:0723BASE_EXPORT bool IsValidGUID(const std::string& guid);
[email protected]d3d728e92010-10-20 03:24:5524
[email protected]3469e7e2010-10-14 20:34:5925#if defined(OS_POSIX)
26// For unit testing purposes only. Do not use outside of tests.
[email protected]7e49ad32012-06-14 14:22:0727BASE_EXPORT std::string RandomDataToGUIDString(const uint64 bytes[2]);
[email protected]3469e7e2010-10-14 20:34:5928#endif
29
[email protected]4461e9ad2013-09-27 08:52:2930} // namespace base
[email protected]3469e7e2010-10-14 20:34:5931
[email protected]7e49ad32012-06-14 14:22:0732#endif // BASE_GUID_H_