summaryrefslogtreecommitdiffstats
path: root/chrome/common/guid.h
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-15 23:38:25 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-15 23:38:25 +0000
commit3eb0d8f7bea3e4e54836fa506f4034bcbd3ef4c2 (patch)
treebb7afc78bd7ebb9fea5ed3ed459880511501fb2a /chrome/common/guid.h
parent9a7ed36f8ad5d33725064021464180a808a3a5d2 (diff)
downloadchromium_src-3eb0d8f7bea3e4e54836fa506f4034bcbd3ef4c2.zip
chromium_src-3eb0d8f7bea3e4e54836fa506f4034bcbd3ef4c2.tar.gz
chromium_src-3eb0d8f7bea3e4e54836fa506f4034bcbd3ef4c2.tar.bz2
Move GUID utils to src/chrome/common.
BUG=None TEST=compiles,unittests Review URL: http://codereview.chromium.org/5849001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69347 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/guid.h')
-rw-r--r--chrome/common/guid.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/chrome/common/guid.h b/chrome/common/guid.h
new file mode 100644
index 0000000..9121c9e
--- /dev/null
+++ b/chrome/common/guid.h
@@ -0,0 +1,32 @@
+// Copyright (c) 2010 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 CHROME_COMMON_GUID_H_
+#define CHROME_COMMON_GUID_H_
+#pragma once
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "build/build_config.h"
+
+namespace guid {
+
+// 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.
+std::string GenerateGUID();
+
+// Returns true if the input string conforms to the GUID format.
+bool IsValidGUID(const std::string& guid);
+
+#if defined(OS_POSIX)
+// For unit testing purposes only. Do not use outside of tests.
+std::string RandomDataToGUIDString(const uint64 bytes[2]);
+#endif
+
+} // namespace guid
+
+#endif // CHROME_COMMON_GUID_H_