Skip to content
Permalink
Browse files
Add support to create UUID string.
https://bugs.webkit.org/show_bug.cgi?id=36472

Reviewed by Dmitry Titov.

* GNUmakefile.am:
* WebCore.gypi:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* platform/UUID.cpp: Added.
(WebCore::createCanonicalUUIDString):
* platform/UUID.h: Added.

Canonical link: https://commits.webkit.org/48162@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@56869 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
jianli-chromium committed Mar 31, 2010
1 parent 02063af commit 66a4de04a200a6031714a04319c7c43b4fd8dbab
Showing 8 changed files with 160 additions and 0 deletions.
@@ -1,3 +1,19 @@
2010-03-31 Jian Li <jianli@chromium.org>

Reviewed by Dmitry Titov.

Add support to create UUID string.
https://bugs.webkit.org/show_bug.cgi?id=36472

* GNUmakefile.am:
* WebCore.gypi:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* platform/UUID.cpp: Added.
(WebCore::createCanonicalUUIDString):
* platform/UUID.h: Added.

2010-03-31 Darin Adler <darin@apple.com>

* rendering/RenderThemeChromiumWin.h: Fix inconsistent line endings.
@@ -1554,6 +1554,8 @@ webcore_sources += \
WebCore/platform/Timer.cpp \
WebCore/platform/Timer.h \
WebCore/platform/TreeShared.h \
WebCore/platform/UUID.cpp \
WebCore/platform/UUID.h \
WebCore/platform/Widget.cpp \
WebCore/platform/Widget.h \
WebCore/platform/WindowsKeyboardCodes.h \
@@ -2897,6 +2897,8 @@
'platform/Timer.cpp',
'platform/Timer.h',
'platform/TreeShared.h',
'platform/UUID.cpp',
'platform/UUID.h',
'platform/Widget.cpp',
'platform/Widget.h',
'platform/WindowsKeyboardCodes.h',
@@ -894,6 +894,7 @@ SOURCES += \
platform/ThreadTimers.cpp \
platform/Timer.cpp \
platform/text/UnicodeRange.cpp \
platform/UUID.cpp \
platform/Widget.cpp \
plugins/PluginDatabase.cpp \
plugins/PluginDebug.cpp \
@@ -22140,6 +22140,14 @@
RelativePath="..\platform\TreeShared.h"
>
</File>
<File
RelativePath="..\platform\UUID.cpp"
>
</File>
<File
RelativePath="..\platform\UUID.h"
>
</File>
<File
RelativePath="..\platform\Widget.cpp"
>
@@ -605,6 +605,8 @@
2E2D99EA10E2BC3800496337 /* DOMBlobInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E2D99E910E2BC3800496337 /* DOMBlobInternal.h */; };
2E2D99EB10E2BD3900496337 /* DOMBlob.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 2E2D99E510E2BC1C00496337 /* DOMBlob.h */; };
2E2D99EC10E2BD3900496337 /* DOMBlobInternal.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 2E2D99E910E2BC3800496337 /* DOMBlobInternal.h */; };
2E3BBF071162DA1100B9409A /* UUID.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2E3BBF051162DA1100B9409A /* UUID.cpp */; };
2E3BBF081162DA1100B9409A /* UUID.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E3BBF061162DA1100B9409A /* UUID.h */; };
2E4346440F546A8200B0F1BA /* GenericWorkerTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E4346320F546A8200B0F1BA /* GenericWorkerTask.h */; };
2E4346450F546A8200B0F1BA /* Worker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2E4346330F546A8200B0F1BA /* Worker.cpp */; };
2E4346460F546A8200B0F1BA /* Worker.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E4346340F546A8200B0F1BA /* Worker.h */; };
@@ -5994,6 +5996,8 @@
2E2D99E510E2BC1C00496337 /* DOMBlob.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMBlob.h; sourceTree = "<group>"; };
2E2D99E610E2BC1C00496337 /* DOMBlob.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMBlob.mm; sourceTree = "<group>"; };
2E2D99E910E2BC3800496337 /* DOMBlobInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMBlobInternal.h; sourceTree = "<group>"; };
2E3BBF051162DA1100B9409A /* UUID.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UUID.cpp; sourceTree = "<group>"; };
2E3BBF061162DA1100B9409A /* UUID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UUID.h; sourceTree = "<group>"; };
2E4346320F546A8200B0F1BA /* GenericWorkerTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GenericWorkerTask.h; path = workers/GenericWorkerTask.h; sourceTree = "<group>"; };
2E4346330F546A8200B0F1BA /* Worker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Worker.cpp; path = workers/Worker.cpp; sourceTree = "<group>"; };
2E4346340F546A8200B0F1BA /* Worker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Worker.h; path = workers/Worker.h; sourceTree = "<group>"; };
@@ -15416,6 +15420,8 @@
93309EA1099EB78C0056E581 /* Timer.cpp */,
9305B24C098F1B6B00C28855 /* Timer.h */,
1419D2C40CEA6F6100FF507A /* TreeShared.h */,
2E3BBF051162DA1100B9409A /* UUID.cpp */,
2E3BBF061162DA1100B9409A /* UUID.h */,
9380F47109A11AB4001FDB34 /* Widget.cpp */,
9380F47209A11AB4001FDB34 /* Widget.h */,
E1E1BEFF115FF6FB006F52CA /* WindowsKeyboardCodes.h */,
@@ -18761,6 +18767,7 @@
E4778B80115A581A00B5D372 /* JSCustomEvent.h in Headers */,
E1E1BF00115FF6FB006F52CA /* WindowsKeyboardCodes.h in Headers */,
8499A515115FB33000F566E3 /* RenderSVGResourceMarker.h in Headers */,
2E3BBF081162DA1100B9409A /* UUID.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -20974,6 +20981,7 @@
62CD32591157E57C0063B0A7 /* CustomEvent.cpp in Sources */,
E4778B7F115A581A00B5D372 /* JSCustomEvent.cpp in Sources */,
8499A514115FB33000F566E3 /* RenderSVGResourceMarker.cpp in Sources */,
2E3BBF071162DA1100B9409A /* UUID.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -0,0 +1,78 @@
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "config.h"
#include "UUID.h"

#include "NotImplemented.h"

#if OS(WINDOWS)
#include <objbase.h>
#elif OS(DARWIN)
#include <CoreFoundation/CoreFoundation.h>
#elif OS(LINUX)
#include <stdio.h>
#endif

namespace WebCore {

String createCanonicalUUIDString()
{
#if OS(WINDOWS)
GUID uuid = { 0 };
HRESULT hr = CoCreateGuid(&uuid);
if (FAILED(hr))
return String();
wchar_t uuidStr[40];
int num = StringFromGUID2(uuid, reinterpret_cast<LPOLESTR>(uuidStr), ARRAYSIZE(uuidStr));
ASSERT(num == 39);
return String(uuidStr + 1, num - 3).lower(); // remove opening and closing bracket and make it lower.
#elif OS(DARWIN)
CFUUIDRef uuid = CFUUIDCreate(0);
CFStringRef uuidStrRef = CFUUIDCreateString(0, uuid);
String uuidStr(uuidStrRef);
CFRelease(uuidStrRef);
CFRelease(uuid);
return uuidStr.lower(); // make it lower.
#elif OS(LINUX)
FILE* fptr = fopen("/proc/sys/kernel/random/uuid", "r");
if (!fptr)
return String();
char uuidStr[37] = {0};
fgets(uuidStr, sizeof(uuidStr) - 1, fptr);
fclose(fptr);
return String(uuidStr).lower(); // make it lower.
#else
notImplemented();
return String();
#endif
}

}
@@ -0,0 +1,45 @@
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef UUID_h
#define UUID_h

#include "PlatformString.h"

namespace WebCore {

// Creates a UUID that consists of 32 hexadecimal digits and returns its canonical form.
// The canonical form is displayed in 5 groups separated by hyphens, in the form 8-4-4-4-12 for a total of 36 characters.
// The hexadecimal values "a" through "f" are output as lower case characters.
String createCanonicalUUIDString();

}

#endif

0 comments on commit 66a4de0

Please sign in to comment.