[GTK] Add initial database process support
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Jan 2015 14:30:21 +0000 (14:30 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Jan 2015 14:30:21 +0000 (14:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=139491

Reviewed by Sergio Villar Senin.

.:

* Source/cmake/OptionsGTK.cmake: Set WebKit2_DatabaseProcess_OUTPUT_NAME.

Source/WebCore:

* platform/sql/SQLiteFileSystem.cpp:
(WebCore::SQLiteFileSystem::openDatabase): Use
WebCore::fileSystemRepresentation() for the database filename,
otherwise sqlite3_open() fails when the filename contains "%2E".

Source/WebKit2:

Add initial support for DatabaseProcess, disabled by default for
now.

* CMakeLists.txt: Add required files to compilation.
* DatabaseProcess/DatabaseProcess.cpp:
(WebKit::DatabaseProcess::createDatabaseToWebProcessConnection):
Add the unix domain sockets implementation.
* DatabaseProcess/EntryPoint/unix/DatabaseProcessMain.cpp: Added.
(main):
* DatabaseProcess/gtk/DatabaseProcessMainGtk.cpp: Added.
(WebKit::DatabaseProcessMainUnix):
* DatabaseProcess/unix/DatabaseProcessMainUnix.h: Added.
* PlatformGTK.cmake: Add required files to compilation.
* Shared/ProcessExecutablePath.h:
* Shared/gtk/KeyedDecoder.cpp: Added.
(WebKit::KeyedDecoder::KeyedDecoder):
(WebKit::KeyedDecoder::~KeyedDecoder):
(WebKit::KeyedDecoder::buildDictionaryFromGVariant):
(WebKit::KeyedDecoder::decodeBytes):
(WebKit::KeyedDecoder::decodeBool):
(WebKit::KeyedDecoder::decodeUInt32):
(WebKit::KeyedDecoder::decodeInt32):
(WebKit::KeyedDecoder::decodeInt64):
(WebKit::KeyedDecoder::decodeFloat):
(WebKit::KeyedDecoder::decodeDouble):
(WebKit::KeyedDecoder::decodeString):
(WebKit::KeyedDecoder::beginObject):
(WebKit::KeyedDecoder::endObject):
(WebKit::KeyedDecoder::beginArray):
(WebKit::KeyedDecoder::beginArrayElement):
(WebKit::KeyedDecoder::endArrayElement):
(WebKit::KeyedDecoder::endArray):
* Shared/gtk/KeyedDecoder.h: Added.
* Shared/gtk/KeyedEncoder.cpp: Added.
(WebKit::KeyedEncoder::KeyedEncoder):
(WebKit::KeyedEncoder::~KeyedEncoder):
(WebKit::KeyedEncoder::encodeBytes):
(WebKit::KeyedEncoder::encodeBool):
(WebKit::KeyedEncoder::encodeUInt32):
(WebKit::KeyedEncoder::encodeInt32):
(WebKit::KeyedEncoder::encodeInt64):
(WebKit::KeyedEncoder::encodeFloat):
(WebKit::KeyedEncoder::encodeDouble):
(WebKit::KeyedEncoder::encodeString):
(WebKit::KeyedEncoder::beginObject):
(WebKit::KeyedEncoder::endObject):
(WebKit::KeyedEncoder::beginArray):
(WebKit::KeyedEncoder::beginArrayElement):
(WebKit::KeyedEncoder::endArrayElement):
(WebKit::KeyedEncoder::endArray):
(WebKit::KeyedEncoder::finishEncoding):
* Shared/gtk/KeyedEncoder.h: Added.
* Shared/gtk/ProcessExecutablePathGtk.cpp:
(WebKit::executablePathOfDatabaseProcess):
* UIProcess/Databases/DatabaseProcessProxy.cpp:
(WebKit::DatabaseProcessProxy::didCreateDatabaseToWebProcessConnection):
Add the unix domain sockets implementation.
* UIProcess/Launcher/gtk/ProcessLauncherGtk.cpp:
(WebKit::ProcessLauncher::launchProcess): Handle the
DatabaseProcess too.
* UIProcess/gtk/WebContextGtk.cpp:
(WebKit::WebContext::platformDefaultIndexedDBDatabaseDirectory):
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::ensureWebToDatabaseProcessConnection): Add
the unix domain sockets implementation.

Source/WTF:

Add support for using GRefPtr with GVariantBuilder.

* wtf/gobject/GRefPtr.cpp:
(WTF::refGPtr):
(WTF::derefGPtr):
* wtf/gobject/GRefPtr.h:
* wtf/gobject/GTypedefs.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@179007 268f45cc-cd09-0410-ab3c-d52691b4dbfc

27 files changed:
ChangeLog
Source/WTF/ChangeLog
Source/WTF/wtf/gobject/GRefPtr.cpp
Source/WTF/wtf/gobject/GRefPtr.h
Source/WTF/wtf/gobject/GTypedefs.h
Source/WebCore/ChangeLog
Source/WebCore/platform/sql/SQLiteFileSystem.cpp
Source/WebKit2/CMakeLists.txt
Source/WebKit2/ChangeLog
Source/WebKit2/DatabaseProcess/DatabaseProcess.cpp
Source/WebKit2/DatabaseProcess/EntryPoint/unix/DatabaseProcessMain.cpp [new file with mode: 0644]
Source/WebKit2/DatabaseProcess/IndexedDB/DatabaseProcessIDBConnection.cpp
Source/WebKit2/DatabaseProcess/gtk/DatabaseProcessMainGtk.cpp [new file with mode: 0644]
Source/WebKit2/DatabaseProcess/unix/DatabaseProcessMainUnix.h [new file with mode: 0644]
Source/WebKit2/PlatformGTK.cmake
Source/WebKit2/Shared/ProcessExecutablePath.h
Source/WebKit2/Shared/gtk/KeyedDecoder.cpp [new file with mode: 0644]
Source/WebKit2/Shared/gtk/KeyedDecoder.h [new file with mode: 0644]
Source/WebKit2/Shared/gtk/KeyedEncoder.cpp [new file with mode: 0644]
Source/WebKit2/Shared/gtk/KeyedEncoder.h [new file with mode: 0644]
Source/WebKit2/Shared/gtk/ProcessExecutablePathGtk.cpp
Source/WebKit2/UIProcess/Databases/DatabaseProcessProxy.cpp
Source/WebKit2/UIProcess/Databases/gtk/DatabaseProcessProxyGtk.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/Launcher/gtk/ProcessLauncherGtk.cpp
Source/WebKit2/UIProcess/gtk/WebProcessPoolGtk.cpp
Source/WebKit2/WebProcess/WebProcess.cpp
Source/cmake/OptionsGTK.cmake

index 2422f0b..bd25abf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2015-01-23  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GTK] Add initial database process support
+        https://bugs.webkit.org/show_bug.cgi?id=139491
+
+        Reviewed by Sergio Villar Senin.
+
+        * Source/cmake/OptionsGTK.cmake: Set WebKit2_DatabaseProcess_OUTPUT_NAME.
+
 2015-01-22  Ryosuke Niwa  <rniwa@webkit.org>
 
         Add a build flag for ES6 class syntax
index 1ad3010..e3dfdd2 100644 (file)
@@ -1,3 +1,18 @@
+2015-01-23  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GTK] Add initial database process support
+        https://bugs.webkit.org/show_bug.cgi?id=139491
+
+        Reviewed by Sergio Villar Senin.
+
+        Add support for using GRefPtr with GVariantBuilder.
+
+        * wtf/gobject/GRefPtr.cpp:
+        (WTF::refGPtr):
+        (WTF::derefGPtr):
+        * wtf/gobject/GRefPtr.h:
+        * wtf/gobject/GTypedefs.h:
+
 2015-01-22  Ryosuke Niwa  <rniwa@webkit.org>
 
         Add a build flag for ES6 class syntax
index 13de166..eeade73 100644 (file)
@@ -89,6 +89,19 @@ template <> void derefGPtr(GVariant* ptr)
     g_variant_unref(ptr);
 }
 
+template <> GVariantBuilder* refGPtr(GVariantBuilder* ptr)
+{
+    if (ptr)
+        g_variant_builder_ref(ptr);
+    return ptr;
+}
+
+template <> void derefGPtr(GVariantBuilder* ptr)
+{
+    if (ptr)
+        g_variant_builder_unref(ptr);
+}
+
 template <> GSource* refGPtr(GSource* ptr)
 {
     if (ptr)
index 216c145..bee6975 100644 (file)
@@ -225,6 +225,8 @@ template <> WTF_EXPORT_PRIVATE GMainLoop* refGPtr(GMainLoop* ptr);
 template <> WTF_EXPORT_PRIVATE void derefGPtr(GMainLoop* ptr);
 template <> WTF_EXPORT_PRIVATE GVariant* refGPtr(GVariant* ptr);
 template <> WTF_EXPORT_PRIVATE void derefGPtr(GVariant* ptr);
+template <> WTF_EXPORT_PRIVATE GVariantBuilder* refGPtr(GVariantBuilder* ptr);
+template <> WTF_EXPORT_PRIVATE void derefGPtr(GVariantBuilder* ptr);
 template <> WTF_EXPORT_PRIVATE GSource* refGPtr(GSource* ptr);
 template <> WTF_EXPORT_PRIVATE void derefGPtr(GSource* ptr);
 template <> WTF_EXPORT_PRIVATE GPtrArray* refGPtr(GPtrArray*);
index 9990792..32298d5 100644 (file)
@@ -60,6 +60,7 @@ typedef struct _GSocketClient GSocketClient;
 typedef struct _GSocketConnection GSocketConnection;
 typedef struct _GSource GSource;
 typedef struct _GVariant GVariant;
+typedef struct _GVariantBuilder GVariantBuilder;
 typedef union _GdkEvent GdkEvent;
 typedef struct _GTimer GTimer;
 typedef struct _GKeyFile GKeyFile;
index d8ade7a..37e4381 100644 (file)
@@ -1,3 +1,15 @@
+2015-01-23  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GTK] Add initial database process support
+        https://bugs.webkit.org/show_bug.cgi?id=139491
+
+        Reviewed by Sergio Villar Senin.
+
+        * platform/sql/SQLiteFileSystem.cpp:
+        (WebCore::SQLiteFileSystem::openDatabase): Use
+        WebCore::fileSystemRepresentation() for the database filename,
+        otherwise sqlite3_open() fails when the filename contains "%2E".
+
 2015-01-23  Byeongha Cho  <byeongha.cho@samsung.com>
 
         Initialization for some member variable of FontPlatformData
index e8cfb0e..3bc050c 100644 (file)
@@ -50,7 +50,7 @@ SQLiteFileSystem::SQLiteFileSystem()
 
 int SQLiteFileSystem::openDatabase(const String& filename, sqlite3** database, bool)
 {
-    return sqlite3_open(filename.utf8().data(), database);
+    return sqlite3_open(fileSystemRepresentation(filename).data(), database);
 }
 
 String SQLiteFileSystem::getFileNameForNewDatabase(const String& dbDir, const String&,
index 4356d32..c0c65ed 100644 (file)
@@ -1,6 +1,9 @@
 set(WebKit2_INCLUDE_DIRECTORIES
     "${JAVASCRIPTCORE_DIR}/llint"
     "${WEBKIT2_DIR}"
+    "${WEBKIT2_DIR}/DatabaseProcess"
+    "${WEBKIT2_DIR}/DatabaseProcess/IndexedDB"
+    "${WEBKIT2_DIR}/DatabaseProcess/IndexedDB/sqlite"
     "${WEBKIT2_DIR}/NetworkProcess"
     "${WEBKIT2_DIR}/NetworkProcess/FileAPI"
     "${WEBKIT2_DIR}/NetworkProcess/cache"
@@ -12,6 +15,7 @@ set(WebKit2_INCLUDE_DIRECTORIES
     "${WEBKIT2_DIR}/Shared/API/c"
     "${WEBKIT2_DIR}/Shared/Authentication"
     "${WEBKIT2_DIR}/Shared/CoreIPCSupport"
+    "${WEBKIT2_DIR}/Shared/Databases"
     "${WEBKIT2_DIR}/Shared/Databases/IndexedDB"
     "${WEBKIT2_DIR}/Shared/Downloads"
     "${WEBKIT2_DIR}/Shared/FileAPI"
@@ -26,6 +30,7 @@ set(WebKit2_INCLUDE_DIRECTORIES
     "${WEBKIT2_DIR}/UIProcess/API/C"
     "${WEBKIT2_DIR}/UIProcess/API/cpp"
     "${WEBKIT2_DIR}/UIProcess/Authentication"
+    "${WEBKIT2_DIR}/UIProcess/Databases"
     "${WEBKIT2_DIR}/UIProcess/Downloads"
     "${WEBKIT2_DIR}/UIProcess/InspectorServer"
     "${WEBKIT2_DIR}/UIProcess/Launcher"
@@ -149,6 +154,16 @@ if (WTF_USE_3D_GRAPHICS)
 endif ()
 
 set(WebKit2_SOURCES
+    DatabaseProcess/DatabaseToWebProcessConnection.cpp
+    DatabaseProcess/DatabaseProcess.cpp
+    DatabaseProcess/IndexedDB/DatabaseProcessIDBConnection.cpp
+    DatabaseProcess/IndexedDB/IDBSerialization.cpp
+    DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp
+    DatabaseProcess/IndexedDB/UniqueIDBDatabaseIdentifier.cpp
+    DatabaseProcess/IndexedDB/sqlite/SQLiteIDBCursor.cpp
+    DatabaseProcess/IndexedDB/sqlite/SQLiteIDBTransaction.cpp
+    DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp
+
     NetworkProcess/NetworkConnectionToWebProcess.cpp
     NetworkProcess/NetworkProcess.cpp
     NetworkProcess/NetworkProcessPlatformStrategies.cpp
@@ -197,6 +212,7 @@ set(WebKit2_SOURCES
     Shared/API/APIURLResponse.cpp
 
     Shared/ActivityAssertion.cpp
+    Shared/AsyncRequest.cpp
     Shared/BlobDataFileReferenceWithSandboxExtension.cpp
     Shared/CacheModel.cpp
     Shared/ChildProcess.cpp
@@ -227,6 +243,7 @@ set(WebKit2_SOURCES
     Shared/WebContextMenuItem.cpp
     Shared/WebContextMenuItemData.cpp
     Shared/WebCoreArgumentCoders.cpp
+    Shared/WebCrossThreadCopier.cpp
     Shared/WebEvent.cpp
     Shared/WebEventConversion.cpp
     Shared/WebGeolocationPosition.cpp
@@ -276,6 +293,9 @@ set(WebKit2_SOURCES
 
     Shared/Authentication/AuthenticationManager.cpp
 
+    Shared/Databases/DatabaseProcessCreationParameters.cpp
+    Shared/Databases/IndexedDB/IDBUtilities.cpp
+
     Shared/Downloads/Download.cpp
     Shared/Downloads/DownloadAuthenticationClient.cpp
     Shared/Downloads/DownloadManager.cpp
@@ -416,6 +436,8 @@ set(WebKit2_SOURCES
     UIProcess/Authentication/WebCredential.cpp
     UIProcess/Authentication/WebProtectionSpace.cpp
 
+    UIProcess/Databases/DatabaseProcessProxy.cpp
+
     UIProcess/Downloads/DownloadProxy.cpp
     UIProcess/Downloads/DownloadProxyMap.cpp
 
@@ -459,6 +481,8 @@ set(WebKit2_SOURCES
 
     WebProcess/Databases/WebDatabaseProvider.cpp
     WebProcess/Databases/IndexedDB/WebIDBFactoryBackend.cpp
+    WebProcess/Databases/IndexedDB/WebIDBServerConnection.cpp
+    WebProcess/Databases/WebToDatabaseProcessConnection.cpp
 
     WebProcess/FileAPI/BlobRegistryProxy.cpp
 
@@ -586,6 +610,10 @@ set(WebKit2_SOURCES
 )
 
 set(WebKit2_MESSAGES_IN_FILES
+    DatabaseProcess/DatabaseToWebProcessConnection.messages.in
+    DatabaseProcess/DatabaseProcess.messages.in
+    DatabaseProcess/IndexedDB/DatabaseProcessIDBConnection.messages.in
+
     NetworkProcess/NetworkConnectionToWebProcess.messages.in
     NetworkProcess/NetworkProcess.messages.in
     NetworkProcess/NetworkResourceLoader.messages.in
@@ -621,6 +649,8 @@ set(WebKit2_MESSAGES_IN_FILES
     UIProcess/WebResourceCacheManagerProxy.messages.in
     UIProcess/WebVibrationProxy.messages.in
 
+    UIProcess/Databases/DatabaseProcessProxy.messages.in
+
     UIProcess/Downloads/DownloadProxy.messages.in
 
     UIProcess/Network/NetworkProcessProxy.messages.in
@@ -641,6 +671,8 @@ set(WebKit2_MESSAGES_IN_FILES
 
     WebProcess/Cookies/WebCookieManager.messages.in
 
+    WebProcess/Databases/IndexedDB/WebIDBServerConnection.messages.in
+
     WebProcess/FullScreen/WebFullScreenManager.messages.in
 
     WebProcess/Geolocation/WebGeolocationManager.messages.in
@@ -685,6 +717,10 @@ set(NetworkProcess_LIBRARIES
     WebKit2
 )
 
+set(DatabaseProcess_LIBRARIES
+  WebKit2
+)
+
 set(WebKit2_LIBRARIES
     JavaScriptCore
     WebCore
@@ -767,6 +803,19 @@ if (ENABLE_PLUGIN_PROCESS)
     endif ()
 endif ()
 
+if (ENABLE_DATABASE_PROCESS)
+    add_definitions(-DENABLE_DATABASE_PROCESS=1)
+    add_executable(DatabaseProcess ${DatabaseProcess_SOURCES})
+    add_webkit2_prefix_header(DatabaseProcess)
+    target_link_libraries(DatabaseProcess ${DatabaseProcess_LIBRARIES})
+    set_target_properties(DatabaseProcess PROPERTIES FOLDER "WebKit")
+    install(TARGETS DatabaseProcess DESTINATION "${LIBEXEC_INSTALL_DIR}")
+
+    if (WebKit2_DatabaseProcess_OUTPUT_NAME)
+        set_target_properties(DatabaseProcess PROPERTIES OUTPUT_NAME ${WebKit2_DatabaseProcess_OUTPUT_NAME})
+    endif ()
+endif ()
+
 POPULATE_LIBRARY_VERSION(WEBKIT2)
 set_target_properties(WebKit2 PROPERTIES VERSION ${WEBKIT2_VERSION} SOVERSION ${WEBKIT2_VERSION_MAJOR})
 
index 3fa6597..4236177 100644 (file)
@@ -1,3 +1,76 @@
+2015-01-23  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GTK] Add initial database process support
+        https://bugs.webkit.org/show_bug.cgi?id=139491
+
+        Reviewed by Sergio Villar Senin.
+
+        Add initial support for DatabaseProcess, disabled by default for
+        now.
+
+        * CMakeLists.txt: Add required files to compilation.
+        * DatabaseProcess/DatabaseProcess.cpp:
+        (WebKit::DatabaseProcess::createDatabaseToWebProcessConnection):
+        Add the unix domain sockets implementation.
+        * DatabaseProcess/EntryPoint/unix/DatabaseProcessMain.cpp: Added.
+        (main):
+        * DatabaseProcess/gtk/DatabaseProcessMainGtk.cpp: Added.
+        (WebKit::DatabaseProcessMainUnix):
+        * DatabaseProcess/unix/DatabaseProcessMainUnix.h: Added.
+        * PlatformGTK.cmake: Add required files to compilation.
+        * Shared/ProcessExecutablePath.h:
+        * Shared/gtk/KeyedDecoder.cpp: Added.
+        (WebKit::KeyedDecoder::KeyedDecoder):
+        (WebKit::KeyedDecoder::~KeyedDecoder):
+        (WebKit::KeyedDecoder::buildDictionaryFromGVariant):
+        (WebKit::KeyedDecoder::decodeBytes):
+        (WebKit::KeyedDecoder::decodeBool):
+        (WebKit::KeyedDecoder::decodeUInt32):
+        (WebKit::KeyedDecoder::decodeInt32):
+        (WebKit::KeyedDecoder::decodeInt64):
+        (WebKit::KeyedDecoder::decodeFloat):
+        (WebKit::KeyedDecoder::decodeDouble):
+        (WebKit::KeyedDecoder::decodeString):
+        (WebKit::KeyedDecoder::beginObject):
+        (WebKit::KeyedDecoder::endObject):
+        (WebKit::KeyedDecoder::beginArray):
+        (WebKit::KeyedDecoder::beginArrayElement):
+        (WebKit::KeyedDecoder::endArrayElement):
+        (WebKit::KeyedDecoder::endArray):
+        * Shared/gtk/KeyedDecoder.h: Added.
+        * Shared/gtk/KeyedEncoder.cpp: Added.
+        (WebKit::KeyedEncoder::KeyedEncoder):
+        (WebKit::KeyedEncoder::~KeyedEncoder):
+        (WebKit::KeyedEncoder::encodeBytes):
+        (WebKit::KeyedEncoder::encodeBool):
+        (WebKit::KeyedEncoder::encodeUInt32):
+        (WebKit::KeyedEncoder::encodeInt32):
+        (WebKit::KeyedEncoder::encodeInt64):
+        (WebKit::KeyedEncoder::encodeFloat):
+        (WebKit::KeyedEncoder::encodeDouble):
+        (WebKit::KeyedEncoder::encodeString):
+        (WebKit::KeyedEncoder::beginObject):
+        (WebKit::KeyedEncoder::endObject):
+        (WebKit::KeyedEncoder::beginArray):
+        (WebKit::KeyedEncoder::beginArrayElement):
+        (WebKit::KeyedEncoder::endArrayElement):
+        (WebKit::KeyedEncoder::endArray):
+        (WebKit::KeyedEncoder::finishEncoding):
+        * Shared/gtk/KeyedEncoder.h: Added.
+        * Shared/gtk/ProcessExecutablePathGtk.cpp:
+        (WebKit::executablePathOfDatabaseProcess):
+        * UIProcess/Databases/DatabaseProcessProxy.cpp:
+        (WebKit::DatabaseProcessProxy::didCreateDatabaseToWebProcessConnection):
+        Add the unix domain sockets implementation.
+        * UIProcess/Launcher/gtk/ProcessLauncherGtk.cpp:
+        (WebKit::ProcessLauncher::launchProcess): Handle the
+        DatabaseProcess too.
+        * UIProcess/gtk/WebContextGtk.cpp:
+        (WebKit::WebContext::platformDefaultIndexedDBDatabaseDirectory):
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::ensureWebToDatabaseProcessConnection): Add
+        the unix domain sockets implementation.
+
 2015-01-22  Benjamin Poulain  <bpoulain@apple.com>
 
         [iOS][WK2] Ignore synthetic click initiated on a previous page
index 190a523..85a9000 100644 (file)
@@ -39,6 +39,7 @@
 #include "WebOriginDataManagerMessages.h"
 #include "WebOriginDataManagerProxyMessages.h"
 #include <WebCore/FileSystem.h>
+#include <WebCore/NotImplemented.h>
 #include <WebCore/TextEncoding.h>
 #include <wtf/MainThread.h>
 
@@ -188,6 +189,10 @@ void DatabaseProcess::createDatabaseToWebProcessConnection()
 
     IPC::Attachment clientPort(listeningPort, MACH_MSG_TYPE_MAKE_SEND);
     parentProcessConnection()->send(Messages::DatabaseProcessProxy::DidCreateDatabaseToWebProcessConnection(clientPort), 0);
+#elif USE(UNIX_DOMAIN_SOCKETS)
+    IPC::Connection::SocketPair socketPair = IPC::Connection::createPlatformConnection();
+    m_databaseToWebProcessConnections.append(DatabaseToWebProcessConnection::create(socketPair.server));
+    parentProcessConnection()->send(Messages::DatabaseProcessProxy::DidCreateDatabaseToWebProcessConnection(IPC::Attachment(socketPair.client)), 0);
 #else
     notImplemented();
 #endif
diff --git a/Source/WebKit2/DatabaseProcess/EntryPoint/unix/DatabaseProcessMain.cpp b/Source/WebKit2/DatabaseProcess/EntryPoint/unix/DatabaseProcessMain.cpp
new file mode 100644 (file)
index 0000000..1d5522b
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2015 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "DatabaseProcessMainUnix.h"
+
+using namespace WebKit;
+
+int main(int argc, char** argv)
+{
+    return DatabaseProcessMainUnix(argc, argv);
+}
index 7d7336a..8bd06b3 100644 (file)
@@ -37,6 +37,8 @@
 #include "WebCoreArgumentCoders.h"
 #include "WebIDBServerConnectionMessages.h"
 #include <WebCore/IDBDatabaseMetadata.h>
+#include <WebCore/IDBIndexMetadata.h>
+#include <WebCore/IDBObjectStoreMetadata.h>
 #include <WebCore/IDBServerConnection.h>
 #include <WebCore/IndexedDB.h>
 
diff --git a/Source/WebKit2/DatabaseProcess/gtk/DatabaseProcessMainGtk.cpp b/Source/WebKit2/DatabaseProcess/gtk/DatabaseProcessMainGtk.cpp
new file mode 100644 (file)
index 0000000..178c9f2
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2015 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "DatabaseProcessMainUnix.h"
+
+#if ENABLE(DATABASE_PROCESS)
+
+#include "ChildProcessMain.h"
+#include "DatabaseProcess.h"
+#include <gtk/gtk.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class DatabaseProcessMain final: public ChildProcessMainBase {
+public:
+    bool platformInitialize() override
+    {
+        gtk_init(nullptr, nullptr);
+        return true;
+    }
+};
+
+int DatabaseProcessMainUnix(int argc, char** argv)
+{
+    return ChildProcessMain<DatabaseProcess, DatabaseProcessMain>(argc, argv);
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(DATABASE_PROCESS)
diff --git a/Source/WebKit2/DatabaseProcess/unix/DatabaseProcessMainUnix.h b/Source/WebKit2/DatabaseProcess/unix/DatabaseProcessMainUnix.h
new file mode 100644 (file)
index 0000000..3675e8d
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2015 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 DatabaseProcessMainUnix_h
+#define DatabaseProcessMainUnix_h
+
+#if ENABLE(DATABASE_PROCESS)
+
+#include <WebKit/WKBase.h>
+
+namespace WebKit {
+
+extern "C" {
+WK_EXPORT int DatabaseProcessMainUnix(int argc, char** argv);
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(DATABASE_PROCESS)
+
+#endif // DatabaseProcessMainUnix_h
index babe27d..4b448f2 100644 (file)
@@ -15,6 +15,8 @@ add_definitions(-DLIBDIR="${LIB_INSTALL_DIR}")
 set(WebKit2_USE_PREFIX_HEADER ON)
 
 list(APPEND WebKit2_SOURCES
+    DatabaseProcess/gtk/DatabaseProcessMainGtk.cpp
+
     NetworkProcess/cache/NetworkCacheStorageSoup.cpp
 
     NetworkProcess/gtk/NetworkProcessMainGtk.cpp
@@ -50,6 +52,8 @@ list(APPEND WebKit2_SOURCES
     Shared/cairo/ShareableBitmapCairo.cpp
 
     Shared/gtk/ArgumentCodersGtk.cpp
+    Shared/gtk/KeyedEncoder.cpp
+    Shared/gtk/KeyedDecoder.cpp
     Shared/gtk/NativeWebKeyboardEventGtk.cpp
     Shared/gtk/NativeWebMouseEventGtk.cpp
     Shared/gtk/NativeWebTouchEventGtk.cpp
@@ -72,6 +76,8 @@ list(APPEND WebKit2_SOURCES
 
     Shared/unix/ChildProcessMain.cpp
 
+    UIProcess/Databases/gtk/DatabaseProcessProxyGtk.cpp
+
     UIProcess/DefaultUndoController.cpp
     UIProcess/DrawingAreaProxyImpl.cpp
 
@@ -431,6 +437,7 @@ list(APPEND WebKit2_INCLUDE_DIRECTORIES
     "${WEBCORE_DIR}/platform/graphics/opentype"
     "${WEBCORE_DIR}/platform/network/soup"
     "${WEBCORE_DIR}/platform/text/enchant"
+    "${WEBKIT2_DIR}/DatabaseProcess/unix"
     "${WEBKIT2_DIR}/NetworkProcess/gtk"
     "${WEBKIT2_DIR}/NetworkProcess/unix"
     "${WEBKIT2_DIR}/Shared/API/c/gtk"
@@ -488,6 +495,10 @@ list(APPEND NetworkProcess_SOURCES
     NetworkProcess/EntryPoint/unix/NetworkProcessMain.cpp
 )
 
+list(APPEND DatabaseProcess_SOURCES
+    DatabaseProcess/EntryPoint/unix/DatabaseProcessMain.cpp
+)
+
 file(WRITE ${CMAKE_BINARY_DIR}/test_atomic.cpp
      "#include <atomic>\n"
      "int main() { std::atomic<int64_t> i(0); i++; return 0; }\n")
@@ -950,6 +961,7 @@ add_custom_command(
             ${WebKit2_SOURCES}
             ${WebProcess_SOURCES}
             ${NetworkProcess_SOURCES}
+            ${DatabaseProcess_SOURCES}
             ${PluginProcessGTK2_SOURCES}
             ${PluginProcess_SOURCES}
             ${WebKit2_HEADERS}
index d78ebcd..4ffd11b 100644 (file)
@@ -35,7 +35,9 @@ String executablePathOfPluginProcess();
 #if ENABLE(NETWORK_PROCESS)
 String executablePathOfNetworkProcess();
 #endif
-
+#if ENABLE(DATABASE_PROCESS)
+String executablePathOfDatabaseProcess();
+#endif
 }
 
 #endif
diff --git a/Source/WebKit2/Shared/gtk/KeyedDecoder.cpp b/Source/WebKit2/Shared/gtk/KeyedDecoder.cpp
new file mode 100644 (file)
index 0000000..3d20d90
--- /dev/null
@@ -0,0 +1,168 @@
+/*
+ * Copyright (C) 2015 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "KeyedDecoder.h"
+
+#include <wtf/text/CString.h>
+
+namespace WebKit {
+
+KeyedDecoder::KeyedDecoder(const uint8_t* data, size_t size)
+{
+    GRefPtr<GBytes> bytes = adoptGRef(g_bytes_new(data, size));
+    GRefPtr<GVariant> variant = g_variant_new_from_bytes(G_VARIANT_TYPE("a{sv}"), bytes.get(), TRUE);
+    m_dictionaryStack.append(dictionaryFromGVariant(variant.get()));
+}
+
+KeyedDecoder::~KeyedDecoder()
+{
+    ASSERT(m_dictionaryStack.size() == 1);
+    ASSERT(m_arrayStack.isEmpty());
+    ASSERT(m_arrayIndexStack.isEmpty());
+}
+
+HashMap<String, GRefPtr<GVariant>> KeyedDecoder::dictionaryFromGVariant(GVariant* variant)
+{
+    HashMap<String, GRefPtr<GVariant>> dictionary;
+    GVariantIter iter;
+    g_variant_iter_init(&iter, variant);
+    const char* key;
+    GVariant* value;
+    while (g_variant_iter_loop(&iter, "{&sv}", &key, &value))
+        dictionary.set(String::fromUTF8(key), value);
+    return WTF::move(dictionary);
+}
+
+bool KeyedDecoder::decodeBytes(const String& key, const uint8_t*& bytes, size_t& size)
+{
+    GRefPtr<GVariant> value = m_dictionaryStack.last().get(key);
+    if (!value)
+        return false;
+
+    size = g_variant_get_size(value.get());
+    bytes = static_cast<const uint8_t*>(g_variant_get_data(value.get()));
+    return true;
+}
+
+template<typename T, typename F>
+bool KeyedDecoder::decodeSimpleValue(const String& key, T& result, F getFunction)
+{
+    GRefPtr<GVariant> value = m_dictionaryStack.last().get(key);
+    if (!value)
+        return false;
+
+    result = getFunction(value.get());
+    return true;
+}
+
+bool KeyedDecoder::decodeBool(const String& key, bool& result)
+{
+    return decodeSimpleValue(key, result, g_variant_get_boolean);
+}
+
+bool KeyedDecoder::decodeUInt32(const String& key, uint32_t& result)
+{
+    return decodeSimpleValue(key, result, g_variant_get_uint32);
+}
+
+bool KeyedDecoder::decodeInt32(const String& key, int32_t& result)
+{
+    return decodeSimpleValue(key, result, g_variant_get_int32);
+}
+
+bool KeyedDecoder::decodeInt64(const String& key, int64_t& result)
+{
+    return decodeSimpleValue(key, result, g_variant_get_int64);
+}
+
+bool KeyedDecoder::decodeFloat(const String& key, float& result)
+{
+    return decodeSimpleValue(key, result, g_variant_get_double);
+}
+
+bool KeyedDecoder::decodeDouble(const String& key, double& result)
+{
+    return decodeSimpleValue(key, result, g_variant_get_double);
+}
+
+bool KeyedDecoder::decodeString(const String& key, String& result)
+{
+    GRefPtr<GVariant> value = m_dictionaryStack.last().get(key);
+    if (!value)
+        return false;
+
+    result = String::fromUTF8(g_variant_get_string(value.get(), nullptr));
+    return true;
+}
+
+bool KeyedDecoder::beginObject(const String& key)
+{
+    GRefPtr<GVariant> value = m_dictionaryStack.last().get(key);
+    if (!value)
+        return false;
+
+    m_dictionaryStack.append(dictionaryFromGVariant(value.get()));
+    return true;
+}
+
+void KeyedDecoder::endObject()
+{
+    m_dictionaryStack.removeLast();
+}
+
+bool KeyedDecoder::beginArray(const String& key)
+{
+    GRefPtr<GVariant> value = m_dictionaryStack.last().get(key);
+    if (!value)
+        return false;
+
+    m_arrayStack.append(value.get());
+    m_arrayIndexStack.append(0);
+    return true;
+}
+
+bool KeyedDecoder::beginArrayElement()
+{
+    if (m_arrayIndexStack.last() >= g_variant_n_children(m_arrayStack.last()))
+        return false;
+
+    GRefPtr<GVariant> variant = adoptGRef(g_variant_get_child_value(m_arrayStack.last(), m_arrayIndexStack.last()++));
+    m_dictionaryStack.append(dictionaryFromGVariant(variant.get()));
+    return true;
+}
+
+void KeyedDecoder::endArrayElement()
+{
+    m_dictionaryStack.removeLast();
+}
+
+void KeyedDecoder::endArray()
+{
+    m_arrayStack.removeLast();
+    m_arrayIndexStack.removeLast();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/Shared/gtk/KeyedDecoder.h b/Source/WebKit2/Shared/gtk/KeyedDecoder.h
new file mode 100644 (file)
index 0000000..083a7ac
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2015 Igaia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 KeyedDecoder_h
+#define KeyedDecoder_h
+
+#include <WebCore/KeyedCoding.h>
+#include <glib.h>
+#include <wtf/HashMap.h>
+#include <wtf/gobject/GRefPtr.h>
+#include <wtf/text/StringHash.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebKit {
+
+class KeyedDecoder final : public WebCore::KeyedDecoder {
+public:
+    KeyedDecoder(const uint8_t* data, size_t);
+    virtual ~KeyedDecoder() override;
+
+private:
+    virtual bool decodeBytes(const String& key, const uint8_t*&, size_t&) override;
+    virtual bool decodeBool(const String& key, bool&) override;
+    virtual bool decodeUInt32(const String& key, uint32_t&) override;
+    virtual bool decodeInt32(const String& key, int32_t&) override;
+    virtual bool decodeInt64(const String& key, int64_t&) override;
+    virtual bool decodeFloat(const String& key, float&) override;
+    virtual bool decodeDouble(const String& key, double&) override;
+    virtual bool decodeString(const String& key, String&) override;
+
+    virtual bool beginObject(const String& key) override;
+    virtual void endObject() override;
+
+    virtual bool beginArray(const String& key) override;
+    virtual bool beginArrayElement() override;
+    virtual void endArrayElement() override;
+    virtual void endArray() override;
+
+    template<typename T, typename F> bool decodeSimpleValue(const String& key, T& result, F getFunction);
+    HashMap<String, GRefPtr<GVariant>> dictionaryFromGVariant(GVariant*);
+
+    Vector<HashMap<String, GRefPtr<GVariant>>> m_dictionaryStack;
+    Vector<GVariant*, 16> m_arrayStack;
+    Vector<unsigned> m_arrayIndexStack;
+};
+
+} // namespace WebKit
+
+#endif // KeyedDecoder_h
diff --git a/Source/WebKit2/Shared/gtk/KeyedEncoder.cpp b/Source/WebKit2/Shared/gtk/KeyedEncoder.cpp
new file mode 100644 (file)
index 0000000..fcdfd8d
--- /dev/null
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2015 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "KeyedEncoder.h"
+
+#include <WebCore/SharedBuffer.h>
+#include <wtf/text/CString.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+KeyedEncoder::KeyedEncoder()
+{
+    g_variant_builder_init(&m_variantBuilder, G_VARIANT_TYPE("a{sv}"));
+    m_variantBuilderStack.append(&m_variantBuilder);
+}
+
+KeyedEncoder::~KeyedEncoder()
+{
+    ASSERT(m_variantBuilderStack.size() == 1);
+    ASSERT(m_variantBuilderStack.last() == &m_variantBuilder);
+    ASSERT(m_arrayStack.isEmpty());
+    ASSERT(m_objectStack.isEmpty());
+}
+
+void KeyedEncoder::encodeBytes(const String& key, const uint8_t* bytes, size_t size)
+{
+    GRefPtr<GBytes> gBytes = adoptGRef(g_bytes_new_static(bytes, size));
+    g_variant_builder_add(m_variantBuilderStack.last(), "{sv}", key.utf8().data(), g_variant_new_from_bytes(G_VARIANT_TYPE("ay"), gBytes.get(), TRUE));
+}
+
+void KeyedEncoder::encodeBool(const String& key, bool value)
+{
+    g_variant_builder_add(m_variantBuilderStack.last(), "{sv}", key.utf8().data(), g_variant_new_boolean(value));
+}
+
+void KeyedEncoder::encodeUInt32(const String& key, uint32_t value)
+{
+    g_variant_builder_add(m_variantBuilderStack.last(), "{sv}", key.utf8().data(), g_variant_new_uint32(value));
+}
+
+void KeyedEncoder::encodeInt32(const String& key, int32_t value)
+{
+    g_variant_builder_add(m_variantBuilderStack.last(), "{sv}", key.utf8().data(), g_variant_new_int32(value));
+}
+
+void KeyedEncoder::encodeInt64(const String& key, int64_t value)
+{
+    g_variant_builder_add(m_variantBuilderStack.last(), "{sv}", key.utf8().data(), g_variant_new_int64(value));
+}
+
+void KeyedEncoder::encodeFloat(const String& key, float value)
+{
+    encodeDouble(key, value);
+}
+
+void KeyedEncoder::encodeDouble(const String& key, double value)
+{
+    g_variant_builder_add(m_variantBuilderStack.last(), "{sv}", key.utf8().data(), g_variant_new_double(value));
+}
+
+void KeyedEncoder::encodeString(const String& key, const String& value)
+{
+    g_variant_builder_add(m_variantBuilderStack.last(), "{sv}", key.utf8().data(), g_variant_new_string(value.utf8().data()));
+}
+
+void KeyedEncoder::beginObject(const String& key)
+{
+    GRefPtr<GVariantBuilder> builder = adoptGRef(g_variant_builder_new(G_VARIANT_TYPE("aa{sv}")));
+    m_objectStack.append(std::make_pair(key, builder));
+    m_variantBuilderStack.append(builder.get());
+}
+
+void KeyedEncoder::endObject()
+{
+    GVariantBuilder* builder = m_variantBuilderStack.takeLast();
+    g_variant_builder_add(m_variantBuilderStack.last(), "{sv}", m_objectStack.last().first.utf8().data(), g_variant_builder_end(builder));
+    m_objectStack.removeLast();
+}
+
+void KeyedEncoder::beginArray(const String& key)
+{
+    m_arrayStack.append(std::make_pair(key, adoptGRef(g_variant_builder_new(G_VARIANT_TYPE("aa{sv}")))));
+}
+
+void KeyedEncoder::beginArrayElement()
+{
+    m_variantBuilderStack.append(g_variant_builder_new(G_VARIANT_TYPE("a{sv}")));
+}
+
+void KeyedEncoder::endArrayElement()
+{
+    GRefPtr<GVariantBuilder> variantBuilder = adoptGRef(m_variantBuilderStack.takeLast());
+    g_variant_builder_add_value(m_arrayStack.last().second.get(), g_variant_builder_end(variantBuilder.get()));
+}
+
+void KeyedEncoder::endArray()
+{
+    g_variant_builder_add(m_variantBuilderStack.last(), "{sv}", m_arrayStack.last().first.utf8().data(), g_variant_builder_end(m_arrayStack.last().second.get()));
+    m_arrayStack.removeLast();
+}
+
+PassRefPtr<SharedBuffer> KeyedEncoder::finishEncoding()
+{
+    g_assert(m_variantBuilderStack.last() == &m_variantBuilder);
+    GRefPtr<GVariant> variant = g_variant_builder_end(&m_variantBuilder);
+    GRefPtr<GBytes> data = g_variant_get_data_as_bytes(variant.get());
+    return SharedBuffer::create(static_cast<const unsigned char*>(g_bytes_get_data(data.get(), nullptr)), static_cast<unsigned>(g_bytes_get_size(data.get())));
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/Shared/gtk/KeyedEncoder.h b/Source/WebKit2/Shared/gtk/KeyedEncoder.h
new file mode 100644 (file)
index 0000000..7ea33fd
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2015 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 KeyedEncoder_h
+#define KeyedEncoder_h
+
+#include <WebCore/KeyedCoding.h>
+#include <glib.h>
+#include <wtf/Vector.h>
+#include <wtf/gobject/GRefPtr.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebKit {
+
+class KeyedEncoder final : public WebCore::KeyedEncoder {
+public:
+    KeyedEncoder();
+    ~KeyedEncoder();
+
+    virtual PassRefPtr<WebCore::SharedBuffer> finishEncoding() override;
+
+private:
+    virtual void encodeBytes(const String& key, const uint8_t*, size_t) override;
+    virtual void encodeBool(const String& key, bool) override;
+    virtual void encodeUInt32(const String& key, uint32_t) override;
+    virtual void encodeInt32(const String& key, int32_t) override;
+    virtual void encodeInt64(const String& key, int64_t) override;
+    virtual void encodeFloat(const String& key, float) override;
+    virtual void encodeDouble(const String& key, double) override;
+    virtual void encodeString(const String& key, const String&) override;
+
+    virtual void beginObject(const String& key) override;
+    virtual void endObject() override;
+
+    virtual void beginArray(const String& key) override;
+    virtual void beginArrayElement() override;
+    virtual void endArrayElement() override;
+    virtual void endArray() override;
+
+    GVariantBuilder m_variantBuilder;
+    Vector<GVariantBuilder*, 16> m_variantBuilderStack;
+    Vector<std::pair<String, GRefPtr<GVariantBuilder>>, 16> m_arrayStack;
+    Vector<std::pair<String, GRefPtr<GVariantBuilder>>, 16> m_objectStack;
+};
+
+} // namespace WebKit
+
+#endif // KeyedEncoder_h
index e757cc2..5b5b947 100644 (file)
@@ -79,4 +79,11 @@ String executablePathOfNetworkProcess()
 }
 #endif
 
+#if ENABLE(DATABASE_PROCESS)
+String executablePathOfDatabaseProcess()
+{
+    return findWebKitProcess("WebKitDatabaseProcess");
+}
+#endif
+
 } // namespace WebKit
index 7475847..b6319d8 100644 (file)
@@ -31,6 +31,7 @@
 #include "WebOriginDataManagerProxy.h"
 #include "WebOriginDataManagerProxyMessages.h"
 #include "WebProcessPool.h"
+#include <WebCore/NotImplemented.h>
 
 #if ENABLE(DATABASE_PROCESS)
 
@@ -117,6 +118,8 @@ void DatabaseProcessProxy::didCreateDatabaseToWebProcessConnection(const IPC::At
 
 #if OS(DARWIN)
     reply->send(IPC::Attachment(connectionIdentifier.port(), MACH_MSG_TYPE_MOVE_SEND));
+#elif USE(UNIX_DOMAIN_SOCKETS)
+    reply->send(connectionIdentifier);
 #else
     notImplemented();
 #endif
diff --git a/Source/WebKit2/UIProcess/Databases/gtk/DatabaseProcessProxyGtk.cpp b/Source/WebKit2/UIProcess/Databases/gtk/DatabaseProcessProxyGtk.cpp
new file mode 100644 (file)
index 0000000..3b4e6ca
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2015 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "DatabaseProcessProxy.h"
+
+#if ENABLE(DATABASE_PROCESS)
+
+namespace WebKit {
+
+void DatabaseProcessProxy::platformGetLaunchOptions(ProcessLauncher::LaunchOptions&)
+{
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(DATABASE_PROCESS)
index 60aab1f..000d544 100644 (file)
@@ -79,6 +79,11 @@ void ProcessLauncher::launchProcess()
         executablePath = executablePathOfNetworkProcess();
         break;
 #endif
+#if ENABLE(DATABASE_PROCESS)
+    case DatabaseProcess:
+        executablePath = executablePathOfDatabaseProcess();
+        break;
+#endif
     default:
         ASSERT_NOT_REACHED();
         return;
index 1f852ad..5ca5ee8 100644 (file)
@@ -120,8 +120,8 @@ String WebProcessPool::legacyPlatformDefaultWebSQLDatabaseDirectory()
 
 String WebProcessPool::legacyPlatformDefaultIndexedDBDatabaseDirectory()
 {
-    notImplemented();
-    return String();
+    GUniquePtr<gchar> indexedDBDatabaseDirectory(g_build_filename(g_get_user_data_dir(), "webkitgtk", "databases", "indexeddb", nullptr));
+    return WebCore::filenameToString(indexedDBDatabaseDirectory.get());
 }
 
 String WebProcessPool::platformDefaultIconDatabasePath() const
index b0e07e0..c7c187e 100644 (file)
@@ -1038,11 +1038,13 @@ void WebProcess::ensureWebToDatabaseProcessConnection()
 
 #if OS(DARWIN)
     IPC::Connection::Identifier connectionIdentifier(encodedConnectionIdentifier.port());
-    if (IPC::Connection::identifierIsNull(connectionIdentifier))
-        return;
+#elif USE(UNIX_DOMAIN_SOCKETS)
+    IPC::Connection::Identifier connectionIdentifier = encodedConnectionIdentifier.releaseFileDescriptor();
 #else
     ASSERT_NOT_REACHED();
 #endif
+    if (IPC::Connection::identifierIsNull(connectionIdentifier))
+        return;
     m_webToDatabaseProcessConnection = WebToDatabaseProcessConnection::create(connectionIdentifier);
 }
 
index 4cee4db..9f85c87 100644 (file)
@@ -219,6 +219,7 @@ set(WebKit2_OUTPUT_NAME webkit2gtk-${WEBKITGTK_API_VERSION})
 set(WebKit2_WebProcess_OUTPUT_NAME WebKitWebProcess)
 set(WebKit2_NetworkProcess_OUTPUT_NAME WebKitNetworkProcess)
 set(WebKit2_PluginProcess_OUTPUT_NAME WebKitPluginProcess)
+set(WebKit2_DatabaseProcess_OUTPUT_NAME WebKitDatabaseProcess)
 
 add_definitions(-DBUILDING_GTK__=1)
 add_definitions(-DGETTEXT_PACKAGE="WebKit2GTK-${WEBKITGTK_API_VERSION}")