diff options
author | marja@chromium.org <marja@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-14 14:22:07 +0000 |
---|---|---|
committer | marja@chromium.org <marja@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-14 14:22:07 +0000 |
commit | 7e49ad360632304e1890082e1605b2239956afdb (patch) | |
tree | 1e3451b1a1af73cc5996c218a2888e35f1337709 /base/guid.h | |
parent | facd6e7bd32c811fa8be9a065505f465396cd92e (diff) | |
download | chromium_src-7e49ad360632304e1890082e1605b2239956afdb.zip chromium_src-7e49ad360632304e1890082e1605b2239956afdb.tar.gz chromium_src-7e49ad360632304e1890082e1605b2239956afdb.tar.bz2 |
Move guid generation from chrome/common/ to base/.
It will be needed in webkit/dom_storage/.
BUG=NONE
TEST=Existing tests.
Review URL: https://chromiumcodereview.appspot.com/10540003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142142 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/guid.h')
-rw-r--r-- | base/guid.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/base/guid.h b/base/guid.h new file mode 100644 index 0000000..20f7706 --- /dev/null +++ b/base/guid.h @@ -0,0 +1,33 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef BASE_GUID_H_ +#define BASE_GUID_H_ +#pragma once + +#include <string> + +#include "base/base_export.h" +#include "base/basictypes.h" +#include "build/build_config.h" + +namespace base { + +// Generate a 128-bit random GUID of the form: "%08X-%04X-%04X-%04X-%012llX". +// If GUID generation fails an empty string is returned. +// The POSIX implementation uses psuedo random number generation to create +// the GUID. The Windows implementation uses system services. +BASE_EXPORT std::string GenerateGUID(); + +// Returns true if the input string conforms to the GUID format. +BASE_EXPORT bool IsValidGUID(const std::string& guid); + +#if defined(OS_POSIX) +// For unit testing purposes only. Do not use outside of tests. +BASE_EXPORT std::string RandomDataToGUIDString(const uint64 bytes[2]); +#endif + +} // namespace guid + +#endif // BASE_GUID_H_ |