summaryrefslogtreecommitdiff
path: root/Source/WebKit2/DatabaseProcess
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit2/DatabaseProcess')
-rw-r--r--Source/WebKit2/DatabaseProcess/DatabaseProcess.cpp317
-rw-r--r--Source/WebKit2/DatabaseProcess/DatabaseProcess.h135
-rw-r--r--Source/WebKit2/DatabaseProcess/DatabaseProcess.messages.in41
-rw-r--r--Source/WebKit2/DatabaseProcess/DatabaseToWebProcessConnection.cpp131
-rw-r--r--Source/WebKit2/DatabaseProcess/DatabaseToWebProcessConnection.h76
-rw-r--r--Source/WebKit2/DatabaseProcess/DatabaseToWebProcessConnection.messages.in33
-rw-r--r--Source/WebKit2/DatabaseProcess/EntryPoint/unix/DatabaseProcessMain.cpp34
-rw-r--r--Source/WebKit2/DatabaseProcess/IndexedDB/WebIDBConnectionToClient.cpp371
-rw-r--r--Source/WebKit2/DatabaseProcess/IndexedDB/WebIDBConnectionToClient.h142
-rw-r--r--Source/WebKit2/DatabaseProcess/IndexedDB/WebIDBConnectionToClient.messages.in56
-rw-r--r--Source/WebKit2/DatabaseProcess/gtk/DatabaseProcessMainGtk.cpp43
-rw-r--r--Source/WebKit2/DatabaseProcess/unix/DatabaseProcessMainUnix.h43
12 files changed, 1422 insertions, 0 deletions
diff --git a/Source/WebKit2/DatabaseProcess/DatabaseProcess.cpp b/Source/WebKit2/DatabaseProcess/DatabaseProcess.cpp
new file mode 100644
index 000000000..7e6e24d85
--- /dev/null
+++ b/Source/WebKit2/DatabaseProcess/DatabaseProcess.cpp
@@ -0,0 +1,317 @@
+/*
+ * Copyright (C) 2013, 2014, 2015, 2016 Apple 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:
+ * 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 "DatabaseProcess.h"
+
+#if ENABLE(DATABASE_PROCESS)
+
+#include "DatabaseProcessCreationParameters.h"
+#include "DatabaseProcessMessages.h"
+#include "DatabaseProcessProxyMessages.h"
+#include "DatabaseToWebProcessConnection.h"
+#include "WebCoreArgumentCoders.h"
+#include "WebsiteData.h"
+#include <WebCore/FileSystem.h>
+#include <WebCore/IDBKeyData.h>
+#include <WebCore/NotImplemented.h>
+#include <WebCore/SessionID.h>
+#include <WebCore/TextEncoding.h>
+#include <wtf/CrossThreadTask.h>
+#include <wtf/MainThread.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+DatabaseProcess& DatabaseProcess::singleton()
+{
+ static NeverDestroyed<DatabaseProcess> databaseProcess;
+ return databaseProcess;
+}
+
+DatabaseProcess::DatabaseProcess()
+ : m_queue(WorkQueue::create("com.apple.WebKit.DatabaseProcess"))
+{
+ // Make sure the UTF8Encoding encoding and the text encoding maps have been built on the main thread before a background thread needs it.
+ // FIXME: https://bugs.webkit.org/show_bug.cgi?id=135365 - Need a more explicit way of doing this besides accessing the UTF8Encoding.
+ UTF8Encoding();
+}
+
+DatabaseProcess::~DatabaseProcess()
+{
+}
+
+void DatabaseProcess::initializeConnection(IPC::Connection* connection)
+{
+ ChildProcess::initializeConnection(connection);
+}
+
+bool DatabaseProcess::shouldTerminate()
+{
+ return true;
+}
+
+void DatabaseProcess::didClose(IPC::Connection&)
+{
+ stopRunLoop();
+}
+
+void DatabaseProcess::didReceiveMessage(IPC::Connection& connection, IPC::Decoder& decoder)
+{
+ if (messageReceiverMap().dispatchMessage(connection, decoder))
+ return;
+
+ if (decoder.messageReceiverName() == Messages::DatabaseProcess::messageReceiverName()) {
+ didReceiveDatabaseProcessMessage(connection, decoder);
+ return;
+ }
+}
+
+#if ENABLE(INDEXED_DATABASE)
+IDBServer::IDBServer& DatabaseProcess::idbServer()
+{
+ if (!m_idbServer)
+ m_idbServer = IDBServer::IDBServer::create(indexedDatabaseDirectory(), DatabaseProcess::singleton());
+
+ return *m_idbServer;
+}
+#endif
+
+void DatabaseProcess::initializeDatabaseProcess(const DatabaseProcessCreationParameters& parameters)
+{
+#if ENABLE(INDEXED_DATABASE)
+ // *********
+ // IMPORTANT: Do not change the directory structure for indexed databases on disk without first consulting a reviewer from Apple (<rdar://problem/17454712>)
+ // *********
+
+ m_indexedDatabaseDirectory = parameters.indexedDatabaseDirectory;
+ SandboxExtension::consumePermanently(parameters.indexedDatabaseDirectoryExtensionHandle);
+
+ ensureIndexedDatabaseRelativePathExists(StringImpl::empty());
+#endif
+}
+
+#if ENABLE(INDEXED_DATABASE)
+void DatabaseProcess::ensureIndexedDatabaseRelativePathExists(const String& relativePath)
+{
+ postDatabaseTask(createCrossThreadTask(*this, &DatabaseProcess::ensurePathExists, absoluteIndexedDatabasePathFromDatabaseRelativePath(relativePath)));
+}
+#endif
+
+void DatabaseProcess::ensurePathExists(const String& path)
+{
+ ASSERT(!RunLoop::isMain());
+
+ if (!makeAllDirectories(path))
+ LOG_ERROR("Failed to make all directories for path '%s'", path.utf8().data());
+}
+
+#if ENABLE(INDEXED_DATABASE)
+String DatabaseProcess::absoluteIndexedDatabasePathFromDatabaseRelativePath(const String& relativePath)
+{
+ // FIXME: pathByAppendingComponent() was originally designed to append individual atomic components.
+ // We don't have a function designed to append a multi-component subpath, but we should.
+ return pathByAppendingComponent(m_indexedDatabaseDirectory, relativePath);
+}
+#endif
+
+void DatabaseProcess::postDatabaseTask(CrossThreadTask&& task)
+{
+ ASSERT(RunLoop::isMain());
+
+ LockHolder locker(m_databaseTaskMutex);
+
+ m_databaseTasks.append(WTFMove(task));
+
+ m_queue->dispatch([this] {
+ performNextDatabaseTask();
+ });
+}
+
+void DatabaseProcess::performNextDatabaseTask()
+{
+ ASSERT(!RunLoop::isMain());
+
+ CrossThreadTask task;
+ {
+ LockHolder locker(m_databaseTaskMutex);
+ ASSERT(!m_databaseTasks.isEmpty());
+ task = m_databaseTasks.takeFirst();
+ }
+
+ task.performTask();
+}
+
+void DatabaseProcess::createDatabaseToWebProcessConnection()
+{
+#if 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);
+#elif OS(DARWIN)
+ // Create the listening port.
+ mach_port_t listeningPort;
+ mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &listeningPort);
+
+ // Create a listening connection.
+ auto connection = DatabaseToWebProcessConnection::create(IPC::Connection::Identifier(listeningPort));
+ m_databaseToWebProcessConnections.append(WTFMove(connection));
+
+ IPC::Attachment clientPort(listeningPort, MACH_MSG_TYPE_MAKE_SEND);
+ parentProcessConnection()->send(Messages::DatabaseProcessProxy::DidCreateDatabaseToWebProcessConnection(clientPort), 0);
+#else
+ notImplemented();
+#endif
+}
+
+void DatabaseProcess::fetchWebsiteData(SessionID, OptionSet<WebsiteDataType> websiteDataTypes, uint64_t callbackID)
+{
+#if ENABLE(INDEXED_DATABASE)
+ auto completionHandler = [this, callbackID](const WebsiteData& websiteData) {
+ parentProcessConnection()->send(Messages::DatabaseProcessProxy::DidFetchWebsiteData(callbackID, websiteData), 0);
+ };
+
+ if (websiteDataTypes.contains(WebsiteDataType::IndexedDBDatabases)) {
+ // FIXME: Pick the right database store based on the session ID.
+ postDatabaseTask(CrossThreadTask([this, websiteDataTypes, completionHandler = WTFMove(completionHandler)]() mutable {
+ RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler), securityOrigins = indexedDatabaseOrigins()] {
+ WebsiteData websiteData;
+ for (const auto& securityOrigin : securityOrigins)
+ websiteData.entries.append({ securityOrigin, WebsiteDataType::IndexedDBDatabases, 0 });
+
+ completionHandler(websiteData);
+ });
+ }));
+ }
+#endif
+}
+
+void DatabaseProcess::deleteWebsiteData(WebCore::SessionID, OptionSet<WebsiteDataType> websiteDataTypes, std::chrono::system_clock::time_point modifiedSince, uint64_t callbackID)
+{
+#if ENABLE(INDEXED_DATABASE)
+ auto completionHandler = [this, callbackID]() {
+ parentProcessConnection()->send(Messages::DatabaseProcessProxy::DidDeleteWebsiteData(callbackID), 0);
+ };
+
+ if (websiteDataTypes.contains(WebsiteDataType::IndexedDBDatabases))
+ idbServer().closeAndDeleteDatabasesModifiedSince(modifiedSince, WTFMove(completionHandler));
+#endif
+}
+
+void DatabaseProcess::deleteWebsiteDataForOrigins(WebCore::SessionID, OptionSet<WebsiteDataType> websiteDataTypes, const Vector<SecurityOriginData>& securityOriginDatas, uint64_t callbackID)
+{
+#if ENABLE(INDEXED_DATABASE)
+ auto completionHandler = [this, callbackID]() {
+ parentProcessConnection()->send(Messages::DatabaseProcessProxy::DidDeleteWebsiteDataForOrigins(callbackID), 0);
+ };
+
+ if (websiteDataTypes.contains(WebsiteDataType::IndexedDBDatabases))
+ idbServer().closeAndDeleteDatabasesForOrigins(securityOriginDatas, WTFMove(completionHandler));
+#endif
+}
+
+#if ENABLE(SANDBOX_EXTENSIONS)
+void DatabaseProcess::grantSandboxExtensionsForBlobs(const Vector<String>& paths, const SandboxExtension::HandleArray& handles)
+{
+ ASSERT(paths.size() == handles.size());
+
+ for (size_t i = 0; i < paths.size(); ++i) {
+ auto result = m_blobTemporaryFileSandboxExtensions.add(paths[i], SandboxExtension::create(handles[i]));
+ ASSERT_UNUSED(result, result.isNewEntry);
+ }
+}
+#endif
+
+#if ENABLE(INDEXED_DATABASE)
+void DatabaseProcess::prepareForAccessToTemporaryFile(const String& path)
+{
+ if (auto extension = m_blobTemporaryFileSandboxExtensions.get(path))
+ extension->consume();
+}
+
+void DatabaseProcess::accessToTemporaryFileComplete(const String& path)
+{
+ // We've either hard linked the temporary blob file to the database directory, copied it there,
+ // or the transaction is being aborted.
+ // In any of those cases, we can delete the temporary blob file now.
+ deleteFile(path);
+
+ if (auto extension = m_blobTemporaryFileSandboxExtensions.take(path))
+ extension->revoke();
+}
+
+Vector<WebCore::SecurityOriginData> DatabaseProcess::indexedDatabaseOrigins()
+{
+ if (m_indexedDatabaseDirectory.isEmpty())
+ return { };
+
+ Vector<WebCore::SecurityOriginData> securityOrigins;
+ for (auto& originPath : listDirectory(m_indexedDatabaseDirectory, "*")) {
+ String databaseIdentifier = pathGetFileName(originPath);
+
+ if (auto securityOrigin = SecurityOriginData::fromDatabaseIdentifier(databaseIdentifier))
+ securityOrigins.append(WTFMove(*securityOrigin));
+ }
+
+ return securityOrigins;
+}
+
+#endif
+
+#if ENABLE(SANDBOX_EXTENSIONS)
+void DatabaseProcess::getSandboxExtensionsForBlobFiles(const Vector<String>& filenames, std::function<void (SandboxExtension::HandleArray&&)> completionHandler)
+{
+ static uint64_t lastRequestID;
+
+ uint64_t requestID = ++lastRequestID;
+ m_sandboxExtensionForBlobsCompletionHandlers.set(requestID, completionHandler);
+ parentProcessConnection()->send(Messages::DatabaseProcessProxy::GetSandboxExtensionsForBlobFiles(requestID, filenames), 0);
+}
+
+void DatabaseProcess::didGetSandboxExtensionsForBlobFiles(uint64_t requestID, SandboxExtension::HandleArray&& handles)
+{
+ if (auto handler = m_sandboxExtensionForBlobsCompletionHandlers.take(requestID))
+ handler(WTFMove(handles));
+}
+#endif
+
+#if !PLATFORM(COCOA)
+void DatabaseProcess::initializeProcess(const ChildProcessInitializationParameters&)
+{
+}
+
+void DatabaseProcess::initializeProcessName(const ChildProcessInitializationParameters&)
+{
+}
+
+void DatabaseProcess::initializeSandbox(const ChildProcessInitializationParameters&, SandboxInitializationParameters&)
+{
+}
+#endif
+
+} // namespace WebKit
+
+#endif // ENABLE(DATABASE_PROCESS)
diff --git a/Source/WebKit2/DatabaseProcess/DatabaseProcess.h b/Source/WebKit2/DatabaseProcess/DatabaseProcess.h
new file mode 100644
index 000000000..659e9619f
--- /dev/null
+++ b/Source/WebKit2/DatabaseProcess/DatabaseProcess.h
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2013 Apple 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:
+ * 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.
+ */
+
+#pragma once
+
+#if ENABLE(DATABASE_PROCESS)
+
+#include "ChildProcess.h"
+#include "SandboxExtension.h"
+#include <WebCore/IDBBackingStore.h>
+#include <WebCore/IDBServer.h>
+#include <WebCore/UniqueIDBDatabase.h>
+#include <wtf/CrossThreadTask.h>
+#include <wtf/NeverDestroyed.h>
+
+namespace WebCore {
+class SessionID;
+struct SecurityOriginData;
+}
+
+namespace WebKit {
+
+class DatabaseToWebProcessConnection;
+enum class WebsiteDataType;
+struct DatabaseProcessCreationParameters;
+
+class DatabaseProcess : public ChildProcess
+#if ENABLE(INDEXED_DATABASE)
+ , public WebCore::IDBServer::IDBBackingStoreTemporaryFileHandler
+#endif
+{
+ WTF_MAKE_NONCOPYABLE(DatabaseProcess);
+ friend class NeverDestroyed<DatabaseProcess>;
+public:
+ static DatabaseProcess& singleton();
+ ~DatabaseProcess();
+
+#if ENABLE(INDEXED_DATABASE)
+ const String& indexedDatabaseDirectory() const { return m_indexedDatabaseDirectory; }
+
+ void ensureIndexedDatabaseRelativePathExists(const String&);
+ String absoluteIndexedDatabasePathFromDatabaseRelativePath(const String&);
+
+ WebCore::IDBServer::IDBServer& idbServer();
+#endif
+
+ WorkQueue& queue() { return m_queue.get(); }
+
+ void postDatabaseTask(CrossThreadTask&&);
+
+#if ENABLE(INDEXED_DATABASE)
+ // WebCore::IDBServer::IDBBackingStoreFileHandler
+ void prepareForAccessToTemporaryFile(const String& path) final;
+ void accessToTemporaryFileComplete(const String& path) final;
+#endif
+
+#if ENABLE(SANDBOX_EXTENSIONS)
+ void getSandboxExtensionsForBlobFiles(const Vector<String>& filenames, std::function<void (SandboxExtension::HandleArray&&)> completionHandler);
+#endif
+
+private:
+ DatabaseProcess();
+
+ // ChildProcess
+ void initializeProcess(const ChildProcessInitializationParameters&) override;
+ void initializeProcessName(const ChildProcessInitializationParameters&) override;
+ void initializeSandbox(const ChildProcessInitializationParameters&, SandboxInitializationParameters&) override;
+ void initializeConnection(IPC::Connection*) override;
+ bool shouldTerminate() override;
+
+ // IPC::Connection::Client
+ void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
+ void didClose(IPC::Connection&) override;
+ void didReceiveDatabaseProcessMessage(IPC::Connection&, IPC::Decoder&);
+
+ // Message Handlers
+ void initializeDatabaseProcess(const DatabaseProcessCreationParameters&);
+ void createDatabaseToWebProcessConnection();
+
+ void fetchWebsiteData(WebCore::SessionID, OptionSet<WebsiteDataType> websiteDataTypes, uint64_t callbackID);
+ void deleteWebsiteData(WebCore::SessionID, OptionSet<WebsiteDataType> websiteDataTypes, std::chrono::system_clock::time_point modifiedSince, uint64_t callbackID);
+ void deleteWebsiteDataForOrigins(WebCore::SessionID, OptionSet<WebsiteDataType> websiteDataTypes, const Vector<WebCore::SecurityOriginData>& origins, uint64_t callbackID);
+#if ENABLE(SANDBOX_EXTENSIONS)
+ void grantSandboxExtensionsForBlobs(const Vector<String>& paths, const SandboxExtension::HandleArray&);
+ void didGetSandboxExtensionsForBlobFiles(uint64_t requestID, SandboxExtension::HandleArray&&);
+#endif
+
+#if ENABLE(INDEXED_DATABASE)
+ Vector<WebCore::SecurityOriginData> indexedDatabaseOrigins();
+#endif
+
+ // For execution on work queue thread only
+ void performNextDatabaseTask();
+ void ensurePathExists(const String&);
+
+ Vector<RefPtr<DatabaseToWebProcessConnection>> m_databaseToWebProcessConnections;
+
+ Ref<WorkQueue> m_queue;
+
+#if ENABLE(INDEXED_DATABASE)
+ String m_indexedDatabaseDirectory;
+ RefPtr<WebCore::IDBServer::IDBServer> m_idbServer;
+#endif
+ HashMap<String, RefPtr<SandboxExtension>> m_blobTemporaryFileSandboxExtensions;
+ HashMap<uint64_t, std::function<void (SandboxExtension::HandleArray&&)>> m_sandboxExtensionForBlobsCompletionHandlers;
+
+ Deque<CrossThreadTask> m_databaseTasks;
+ Lock m_databaseTaskMutex;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(DATABASE_PROCESS)
diff --git a/Source/WebKit2/DatabaseProcess/DatabaseProcess.messages.in b/Source/WebKit2/DatabaseProcess/DatabaseProcess.messages.in
new file mode 100644
index 000000000..466823339
--- /dev/null
+++ b/Source/WebKit2/DatabaseProcess/DatabaseProcess.messages.in
@@ -0,0 +1,41 @@
+# Copyright (C) 2013 Apple 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:
+# 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.
+
+#if ENABLE(DATABASE_PROCESS)
+
+messages -> DatabaseProcess LegacyReceiver {
+ # Initializes the DatabaseProcess with the correct parameters
+ InitializeDatabaseProcess(struct WebKit::DatabaseProcessCreationParameters processCreationParameters)
+
+ # Creates a connection for communication with a WebProcess
+ CreateDatabaseToWebProcessConnection()
+
+ FetchWebsiteData(WebCore::SessionID sessionID, OptionSet<WebKit::WebsiteDataType> websiteDataTypes, uint64_t callbackID)
+ DeleteWebsiteData(WebCore::SessionID sessionID, OptionSet<WebKit::WebsiteDataType> websiteDataTypes, std::chrono::system_clock::time_point modifiedSince, uint64_t callbackID)
+ DeleteWebsiteDataForOrigins(WebCore::SessionID sessionID, OptionSet<WebKit::WebsiteDataType> websiteDataTypes, Vector<WebCore::SecurityOriginData> origins, uint64_t callbackID)
+#if ENABLE(SANDBOX_EXTENSIONS)
+ GrantSandboxExtensionsForBlobs(Vector<String> paths, WebKit::SandboxExtension::HandleArray extensions)
+ DidGetSandboxExtensionsForBlobFiles(uint64_t requestID, WebKit::SandboxExtension::HandleArray extensions)
+#endif
+}
+
+#endif // ENABLE(DATABASE_PROCESS)
diff --git a/Source/WebKit2/DatabaseProcess/DatabaseToWebProcessConnection.cpp b/Source/WebKit2/DatabaseProcess/DatabaseToWebProcessConnection.cpp
new file mode 100644
index 000000000..ba426dee3
--- /dev/null
+++ b/Source/WebKit2/DatabaseProcess/DatabaseToWebProcessConnection.cpp
@@ -0,0 +1,131 @@
+/*
+ * Copyright (C) 2013 Apple 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:
+ * 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 "DatabaseToWebProcessConnection.h"
+
+#include "DatabaseToWebProcessConnectionMessages.h"
+#include "Logging.h"
+#include "WebIDBConnectionToClient.h"
+#include "WebIDBConnectionToClientMessages.h"
+#include <wtf/RunLoop.h>
+
+#if ENABLE(DATABASE_PROCESS)
+
+namespace WebKit {
+
+Ref<DatabaseToWebProcessConnection> DatabaseToWebProcessConnection::create(IPC::Connection::Identifier connectionIdentifier)
+{
+ return adoptRef(*new DatabaseToWebProcessConnection(connectionIdentifier));
+}
+
+DatabaseToWebProcessConnection::DatabaseToWebProcessConnection(IPC::Connection::Identifier connectionIdentifier)
+ : m_connection(IPC::Connection::createServerConnection(connectionIdentifier, *this))
+{
+ m_connection->setOnlySendMessagesAsDispatchWhenWaitingForSyncReplyWhenProcessingSuchAMessage(true);
+ m_connection->open();
+}
+
+DatabaseToWebProcessConnection::~DatabaseToWebProcessConnection()
+{
+
+}
+
+void DatabaseToWebProcessConnection::didReceiveMessage(IPC::Connection& connection, IPC::Decoder& decoder)
+{
+ if (decoder.messageReceiverName() == Messages::DatabaseToWebProcessConnection::messageReceiverName()) {
+ didReceiveDatabaseToWebProcessConnectionMessage(connection, decoder);
+ return;
+ }
+
+#if ENABLE(INDEXED_DATABASE)
+ if (decoder.messageReceiverName() == Messages::WebIDBConnectionToClient::messageReceiverName()) {
+ auto iterator = m_webIDBConnections.find(decoder.destinationID());
+ if (iterator != m_webIDBConnections.end())
+ iterator->value->didReceiveMessage(connection, decoder);
+ return;
+ }
+#endif
+
+ ASSERT_NOT_REACHED();
+}
+
+void DatabaseToWebProcessConnection::didReceiveSyncMessage(IPC::Connection& connection, IPC::Decoder& decoder, std::unique_ptr<IPC::Encoder>& replyEncoder)
+{
+ if (decoder.messageReceiverName() == Messages::DatabaseToWebProcessConnection::messageReceiverName()) {
+ didReceiveSyncDatabaseToWebProcessConnectionMessage(connection, decoder, replyEncoder);
+ return;
+ }
+
+ ASSERT_NOT_REACHED();
+}
+
+void DatabaseToWebProcessConnection::didClose(IPC::Connection&)
+{
+#if ENABLE(INDEXED_DATABASE)
+ auto connections = m_webIDBConnections;
+ for (auto& connection : connections.values())
+ connection->disconnectedFromWebProcess();
+
+ m_webIDBConnections.clear();
+#endif
+}
+
+void DatabaseToWebProcessConnection::didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference messageReceiverName, IPC::StringReference messageName)
+{
+
+}
+
+#if ENABLE(INDEXED_DATABASE)
+
+static uint64_t generateConnectionToServerIdentifier()
+{
+ ASSERT(RunLoop::isMain());
+ static uint64_t identifier = 0;
+ return ++identifier;
+}
+
+void DatabaseToWebProcessConnection::establishIDBConnectionToServer(uint64_t& serverConnectionIdentifier)
+{
+ serverConnectionIdentifier = generateConnectionToServerIdentifier();
+ LOG(IndexedDB, "DatabaseToWebProcessConnection::establishIDBConnectionToServer - %" PRIu64, serverConnectionIdentifier);
+ ASSERT(!m_webIDBConnections.contains(serverConnectionIdentifier));
+
+ m_webIDBConnections.set(serverConnectionIdentifier, WebIDBConnectionToClient::create(*this, serverConnectionIdentifier));
+}
+
+void DatabaseToWebProcessConnection::removeIDBConnectionToServer(uint64_t serverConnectionIdentifier)
+{
+ ASSERT(m_webIDBConnections.contains(serverConnectionIdentifier));
+
+ auto connection = m_webIDBConnections.take(serverConnectionIdentifier);
+ connection->disconnectedFromWebProcess();
+}
+#endif
+
+
+} // namespace WebKit
+
+#endif // ENABLE(DATABASE_PROCESS)
diff --git a/Source/WebKit2/DatabaseProcess/DatabaseToWebProcessConnection.h b/Source/WebKit2/DatabaseProcess/DatabaseToWebProcessConnection.h
new file mode 100644
index 000000000..7c30a7fde
--- /dev/null
+++ b/Source/WebKit2/DatabaseProcess/DatabaseToWebProcessConnection.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2013 Apple 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:
+ * 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 DatabaseToWebProcessConnection_h
+#define DatabaseToWebProcessConnection_h
+
+#include "Connection.h"
+#include "MessageSender.h"
+
+#include <wtf/HashMap.h>
+
+#if ENABLE(DATABASE_PROCESS)
+
+namespace WebKit {
+
+class WebIDBConnectionToClient;
+
+class DatabaseToWebProcessConnection : public RefCounted<DatabaseToWebProcessConnection>, public IPC::Connection::Client, public IPC::MessageSender {
+public:
+ static Ref<DatabaseToWebProcessConnection> create(IPC::Connection::Identifier);
+ ~DatabaseToWebProcessConnection();
+
+ IPC::Connection& connection() { return m_connection.get(); }
+
+private:
+ DatabaseToWebProcessConnection(IPC::Connection::Identifier);
+
+ // IPC::Connection::Client
+ void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
+ void didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&) override;
+ void didClose(IPC::Connection&) override;
+ void didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference messageReceiverName, IPC::StringReference messageName) override;
+ void didReceiveDatabaseToWebProcessConnectionMessage(IPC::Connection&, IPC::Decoder&);
+ void didReceiveSyncDatabaseToWebProcessConnectionMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&);
+
+ // IPC::MessageSender
+ IPC::Connection* messageSenderConnection() override { return m_connection.ptr(); }
+ uint64_t messageSenderDestinationID() override { return 0; }
+
+#if ENABLE(INDEXED_DATABASE)
+ // Messages handlers (Modern IDB)
+ void establishIDBConnectionToServer(uint64_t& serverConnectionIdentifier);
+ void removeIDBConnectionToServer(uint64_t serverConnectionIdentifier);
+
+ HashMap<uint64_t, RefPtr<WebIDBConnectionToClient>> m_webIDBConnections;
+#endif // ENABLE(INDEXED_DATABASE)
+
+ Ref<IPC::Connection> m_connection;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(DATABASE_PROCESS)
+#endif // DatabaseToWebProcessConnection_h
diff --git a/Source/WebKit2/DatabaseProcess/DatabaseToWebProcessConnection.messages.in b/Source/WebKit2/DatabaseProcess/DatabaseToWebProcessConnection.messages.in
new file mode 100644
index 000000000..60bec6e42
--- /dev/null
+++ b/Source/WebKit2/DatabaseProcess/DatabaseToWebProcessConnection.messages.in
@@ -0,0 +1,33 @@
+# Copyright (C) 2013 Apple 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:
+# 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.
+
+#if ENABLE(DATABASE_PROCESS)
+
+messages -> DatabaseToWebProcessConnection LegacyReceiver {
+#if ENABLE(INDEXED_DATABASE)
+ # Creates a connection for communication with a WebProcess
+ EstablishIDBConnectionToServer() -> (uint64_t serverConnectionIdentifier)
+ RemoveIDBConnectionToServer(uint64_t serverConnectionIdentifier)
+#endif
+}
+
+#endif // ENABLE(DATABASE_PROCESS)
diff --git a/Source/WebKit2/DatabaseProcess/EntryPoint/unix/DatabaseProcessMain.cpp b/Source/WebKit2/DatabaseProcess/EntryPoint/unix/DatabaseProcessMain.cpp
new file mode 100644
index 000000000..9d8b81838
--- /dev/null
+++ b/Source/WebKit2/DatabaseProcess/EntryPoint/unix/DatabaseProcessMain.cpp
@@ -0,0 +1,34 @@
+/*
+ * 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"
+
+using namespace WebKit;
+
+int main(int argc, char** argv)
+{
+ return DatabaseProcessMainUnix(argc, argv);
+}
diff --git a/Source/WebKit2/DatabaseProcess/IndexedDB/WebIDBConnectionToClient.cpp b/Source/WebKit2/DatabaseProcess/IndexedDB/WebIDBConnectionToClient.cpp
new file mode 100644
index 000000000..274add5ea
--- /dev/null
+++ b/Source/WebKit2/DatabaseProcess/IndexedDB/WebIDBConnectionToClient.cpp
@@ -0,0 +1,371 @@
+/*
+ * Copyright (C) 2016 Apple 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:
+ * 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 "WebIDBConnectionToClient.h"
+
+#if ENABLE(INDEXED_DATABASE)
+
+#include "DataReference.h"
+#include "DatabaseProcess.h"
+#include "WebCoreArgumentCoders.h"
+#include "WebIDBConnectionToServerMessages.h"
+#include "WebIDBResult.h"
+#include <WebCore/IDBError.h>
+#include <WebCore/IDBGetAllRecordsData.h>
+#include <WebCore/IDBGetRecordData.h>
+#include <WebCore/IDBResultData.h>
+#include <WebCore/IDBValue.h>
+#include <WebCore/ThreadSafeDataBuffer.h>
+#include <WebCore/UniqueIDBDatabaseConnection.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+Ref<WebIDBConnectionToClient> WebIDBConnectionToClient::create(DatabaseToWebProcessConnection& connection, uint64_t serverConnectionIdentifier)
+{
+ return adoptRef(*new WebIDBConnectionToClient(connection, serverConnectionIdentifier));
+}
+
+WebIDBConnectionToClient::WebIDBConnectionToClient(DatabaseToWebProcessConnection& connection, uint64_t serverConnectionIdentifier)
+ : m_connection(connection)
+ , m_identifier(serverConnectionIdentifier)
+{
+ relaxAdoptionRequirement();
+ m_connectionToClient = IDBServer::IDBConnectionToClient::create(*this);
+ DatabaseProcess::singleton().idbServer().registerConnection(*m_connectionToClient);
+}
+
+WebIDBConnectionToClient::~WebIDBConnectionToClient()
+{
+}
+
+void WebIDBConnectionToClient::disconnectedFromWebProcess()
+{
+ DatabaseProcess::singleton().idbServer().unregisterConnection(*m_connectionToClient);
+}
+
+IPC::Connection* WebIDBConnectionToClient::messageSenderConnection()
+{
+ return &m_connection->connection();
+}
+
+WebCore::IDBServer::IDBConnectionToClient& WebIDBConnectionToClient::connectionToClient()
+{
+ return *m_connectionToClient;
+}
+
+void WebIDBConnectionToClient::didDeleteDatabase(const WebCore::IDBResultData& resultData)
+{
+ send(Messages::WebIDBConnectionToServer::DidDeleteDatabase(resultData));
+}
+
+void WebIDBConnectionToClient::didOpenDatabase(const WebCore::IDBResultData& resultData)
+{
+ send(Messages::WebIDBConnectionToServer::DidOpenDatabase(resultData));
+}
+
+void WebIDBConnectionToClient::didAbortTransaction(const WebCore::IDBResourceIdentifier& transactionIdentifier, const WebCore::IDBError& error)
+{
+ send(Messages::WebIDBConnectionToServer::DidAbortTransaction(transactionIdentifier, error));
+}
+
+void WebIDBConnectionToClient::didCommitTransaction(const WebCore::IDBResourceIdentifier& transactionIdentifier, const WebCore::IDBError& error)
+{
+ send(Messages::WebIDBConnectionToServer::DidCommitTransaction(transactionIdentifier, error));
+}
+
+void WebIDBConnectionToClient::didCreateObjectStore(const WebCore::IDBResultData& resultData)
+{
+ send(Messages::WebIDBConnectionToServer::DidCreateObjectStore(resultData));
+}
+
+void WebIDBConnectionToClient::didDeleteObjectStore(const WebCore::IDBResultData& resultData)
+{
+ send(Messages::WebIDBConnectionToServer::DidDeleteObjectStore(resultData));
+}
+
+void WebIDBConnectionToClient::didRenameObjectStore(const WebCore::IDBResultData& resultData)
+{
+ send(Messages::WebIDBConnectionToServer::DidRenameObjectStore(resultData));
+}
+
+void WebIDBConnectionToClient::didClearObjectStore(const WebCore::IDBResultData& resultData)
+{
+ send(Messages::WebIDBConnectionToServer::DidClearObjectStore(resultData));
+}
+
+void WebIDBConnectionToClient::didCreateIndex(const WebCore::IDBResultData& resultData)
+{
+ send(Messages::WebIDBConnectionToServer::DidCreateIndex(resultData));
+}
+
+void WebIDBConnectionToClient::didDeleteIndex(const WebCore::IDBResultData& resultData)
+{
+ send(Messages::WebIDBConnectionToServer::DidDeleteIndex(resultData));
+}
+
+void WebIDBConnectionToClient::didRenameIndex(const WebCore::IDBResultData& resultData)
+{
+ send(Messages::WebIDBConnectionToServer::DidRenameIndex(resultData));
+}
+
+void WebIDBConnectionToClient::didPutOrAdd(const WebCore::IDBResultData& resultData)
+{
+ send(Messages::WebIDBConnectionToServer::DidPutOrAdd(resultData));
+}
+
+template<class MessageType> void WebIDBConnectionToClient::handleGetResult(const WebCore::IDBResultData& resultData)
+{
+ if (resultData.type() == IDBResultType::Error) {
+ send(MessageType(resultData));
+ return;
+ }
+
+ if (resultData.type() == IDBResultType::GetAllRecordsSuccess && resultData.getAllResult().type() == IndexedDB::GetAllType::Keys) {
+ send(MessageType(resultData));
+ return;
+ }
+
+ auto blobFilePaths = resultData.type() == IDBResultType::GetAllRecordsSuccess ? resultData.getAllResult().allBlobFilePaths() : resultData.getResult().value().blobFilePaths();
+ if (blobFilePaths.isEmpty()) {
+ send(MessageType(resultData));
+ return;
+ }
+
+#if ENABLE(SANDBOX_EXTENSIONS)
+ RefPtr<WebIDBConnectionToClient> protector(this);
+ DatabaseProcess::singleton().getSandboxExtensionsForBlobFiles(blobFilePaths, [protector, this, resultData](SandboxExtension::HandleArray&& handles) {
+ send(MessageType({ resultData, WTFMove(handles) }));
+ });
+#else
+ send(MessageType(resultData));
+#endif
+}
+
+void WebIDBConnectionToClient::didGetRecord(const WebCore::IDBResultData& resultData)
+{
+ handleGetResult<Messages::WebIDBConnectionToServer::DidGetRecord>(resultData);
+}
+
+void WebIDBConnectionToClient::didGetAllRecords(const WebCore::IDBResultData& resultData)
+{
+ handleGetResult<Messages::WebIDBConnectionToServer::DidGetAllRecords>(resultData);
+}
+
+void WebIDBConnectionToClient::didGetCount(const WebCore::IDBResultData& resultData)
+{
+ send(Messages::WebIDBConnectionToServer::DidGetCount(resultData));
+}
+
+void WebIDBConnectionToClient::didDeleteRecord(const WebCore::IDBResultData& resultData)
+{
+ send(Messages::WebIDBConnectionToServer::DidDeleteRecord(resultData));
+}
+
+void WebIDBConnectionToClient::didOpenCursor(const WebCore::IDBResultData& resultData)
+{
+ handleGetResult<Messages::WebIDBConnectionToServer::DidOpenCursor>(resultData);
+}
+
+void WebIDBConnectionToClient::didIterateCursor(const WebCore::IDBResultData& resultData)
+{
+ handleGetResult<Messages::WebIDBConnectionToServer::DidIterateCursor>(resultData);
+}
+
+void WebIDBConnectionToClient::fireVersionChangeEvent(WebCore::IDBServer::UniqueIDBDatabaseConnection& connection, const WebCore::IDBResourceIdentifier& requestIdentifier, uint64_t requestedVersion)
+{
+ send(Messages::WebIDBConnectionToServer::FireVersionChangeEvent(connection.identifier(), requestIdentifier, requestedVersion));
+}
+
+void WebIDBConnectionToClient::didStartTransaction(const WebCore::IDBResourceIdentifier& transactionIdentifier, const WebCore::IDBError& error)
+{
+ send(Messages::WebIDBConnectionToServer::DidStartTransaction(transactionIdentifier, error));
+}
+
+void WebIDBConnectionToClient::didCloseFromServer(WebCore::IDBServer::UniqueIDBDatabaseConnection& connection, const WebCore::IDBError& error)
+{
+ send(Messages::WebIDBConnectionToServer::DidCloseFromServer(connection.identifier(), error));
+}
+
+void WebIDBConnectionToClient::notifyOpenDBRequestBlocked(const WebCore::IDBResourceIdentifier& requestIdentifier, uint64_t oldVersion, uint64_t newVersion)
+{
+ send(Messages::WebIDBConnectionToServer::NotifyOpenDBRequestBlocked(requestIdentifier, oldVersion, newVersion));
+}
+
+void WebIDBConnectionToClient::didGetAllDatabaseNames(uint64_t callbackID, const Vector<String>& databaseNames)
+{
+ send(Messages::WebIDBConnectionToServer::DidGetAllDatabaseNames(callbackID, databaseNames));
+}
+
+void WebIDBConnectionToClient::deleteDatabase(const IDBRequestData& request)
+{
+ DatabaseProcess::singleton().idbServer().deleteDatabase(request);
+}
+
+void WebIDBConnectionToClient::openDatabase(const IDBRequestData& request)
+{
+ DatabaseProcess::singleton().idbServer().openDatabase(request);
+}
+
+void WebIDBConnectionToClient::abortTransaction(const IDBResourceIdentifier& transactionIdentifier)
+{
+ DatabaseProcess::singleton().idbServer().abortTransaction(transactionIdentifier);
+}
+
+void WebIDBConnectionToClient::commitTransaction(const IDBResourceIdentifier& transactionIdentifier)
+{
+ DatabaseProcess::singleton().idbServer().commitTransaction(transactionIdentifier);
+}
+
+void WebIDBConnectionToClient::didFinishHandlingVersionChangeTransaction(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& transactionIdentifier)
+{
+ DatabaseProcess::singleton().idbServer().didFinishHandlingVersionChangeTransaction(databaseConnectionIdentifier, transactionIdentifier);
+}
+
+void WebIDBConnectionToClient::createObjectStore(const IDBRequestData& request, const IDBObjectStoreInfo& info)
+{
+ DatabaseProcess::singleton().idbServer().createObjectStore(request, info);
+}
+
+void WebIDBConnectionToClient::deleteObjectStore(const IDBRequestData& request, const String& name)
+{
+ DatabaseProcess::singleton().idbServer().deleteObjectStore(request, name);
+}
+
+void WebIDBConnectionToClient::renameObjectStore(const IDBRequestData& request, uint64_t objectStoreIdentifier, const String& newName)
+{
+ DatabaseProcess::singleton().idbServer().renameObjectStore(request, objectStoreIdentifier, newName);
+}
+
+void WebIDBConnectionToClient::clearObjectStore(const IDBRequestData& request, uint64_t objectStoreIdentifier)
+{
+ DatabaseProcess::singleton().idbServer().clearObjectStore(request, objectStoreIdentifier);
+}
+
+void WebIDBConnectionToClient::createIndex(const IDBRequestData& request, const IDBIndexInfo& info)
+{
+ DatabaseProcess::singleton().idbServer().createIndex(request, info);
+}
+
+void WebIDBConnectionToClient::deleteIndex(const IDBRequestData& request, uint64_t objectStoreIdentifier, const String& name)
+{
+ DatabaseProcess::singleton().idbServer().deleteIndex(request, objectStoreIdentifier, name);
+}
+
+void WebIDBConnectionToClient::renameIndex(const IDBRequestData& request, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName)
+{
+ DatabaseProcess::singleton().idbServer().renameIndex(request, objectStoreIdentifier, indexIdentifier, newName);
+}
+
+void WebIDBConnectionToClient::putOrAdd(const IDBRequestData& request, const IDBKeyData& key, const IDBValue& value, unsigned overwriteMode)
+{
+ if (overwriteMode != static_cast<unsigned>(IndexedDB::ObjectStoreOverwriteMode::NoOverwrite)
+ && overwriteMode != static_cast<unsigned>(IndexedDB::ObjectStoreOverwriteMode::Overwrite)
+ && overwriteMode != static_cast<unsigned>(IndexedDB::ObjectStoreOverwriteMode::OverwriteForCursor)) {
+ // FIXME: This message from the WebProcess is corrupt.
+ // The DatabaseProcess should return early at this point, but can we also kill the bad WebProcess?
+ return;
+ }
+
+ IndexedDB::ObjectStoreOverwriteMode mode = static_cast<IndexedDB::ObjectStoreOverwriteMode>(overwriteMode);
+
+ DatabaseProcess::singleton().idbServer().putOrAdd(request, key, value, mode);
+}
+
+void WebIDBConnectionToClient::getRecord(const IDBRequestData& request, const IDBGetRecordData& getRecordData)
+{
+ DatabaseProcess::singleton().idbServer().getRecord(request, getRecordData);
+}
+
+void WebIDBConnectionToClient::getAllRecords(const IDBRequestData& request, const IDBGetAllRecordsData& getAllRecordsData)
+{
+ DatabaseProcess::singleton().idbServer().getAllRecords(request, getAllRecordsData);
+}
+
+void WebIDBConnectionToClient::getCount(const IDBRequestData& request, const IDBKeyRangeData& range)
+{
+ DatabaseProcess::singleton().idbServer().getCount(request, range);
+}
+
+void WebIDBConnectionToClient::deleteRecord(const IDBRequestData& request, const IDBKeyRangeData& range)
+{
+ DatabaseProcess::singleton().idbServer().deleteRecord(request, range);
+}
+
+void WebIDBConnectionToClient::openCursor(const IDBRequestData& request, const IDBCursorInfo& info)
+{
+ DatabaseProcess::singleton().idbServer().openCursor(request, info);
+}
+
+void WebIDBConnectionToClient::iterateCursor(const IDBRequestData& request, const IDBIterateCursorData& data)
+{
+ DatabaseProcess::singleton().idbServer().iterateCursor(request, data);
+}
+
+void WebIDBConnectionToClient::establishTransaction(uint64_t databaseConnectionIdentifier, const IDBTransactionInfo& info)
+{
+ DatabaseProcess::singleton().idbServer().establishTransaction(databaseConnectionIdentifier, info);
+}
+
+void WebIDBConnectionToClient::databaseConnectionPendingClose(uint64_t databaseConnectionIdentifier)
+{
+ DatabaseProcess::singleton().idbServer().databaseConnectionPendingClose(databaseConnectionIdentifier);
+}
+
+void WebIDBConnectionToClient::databaseConnectionClosed(uint64_t databaseConnectionIdentifier)
+{
+ DatabaseProcess::singleton().idbServer().databaseConnectionClosed(databaseConnectionIdentifier);
+}
+
+void WebIDBConnectionToClient::abortOpenAndUpgradeNeeded(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& transactionIdentifier)
+{
+ DatabaseProcess::singleton().idbServer().abortOpenAndUpgradeNeeded(databaseConnectionIdentifier, transactionIdentifier);
+}
+
+void WebIDBConnectionToClient::didFireVersionChangeEvent(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& transactionIdentifier)
+{
+ DatabaseProcess::singleton().idbServer().didFireVersionChangeEvent(databaseConnectionIdentifier, transactionIdentifier);
+}
+
+void WebIDBConnectionToClient::openDBRequestCancelled(const IDBRequestData& requestData)
+{
+ DatabaseProcess::singleton().idbServer().openDBRequestCancelled(requestData);
+}
+
+void WebIDBConnectionToClient::confirmDidCloseFromServer(uint64_t databaseConnectionIdentifier)
+{
+ DatabaseProcess::singleton().idbServer().confirmDidCloseFromServer(databaseConnectionIdentifier);
+}
+
+void WebIDBConnectionToClient::getAllDatabaseNames(uint64_t serverConnectionIdentifier, const WebCore::SecurityOriginData& topOrigin, const WebCore::SecurityOriginData& openingOrigin, uint64_t callbackID)
+{
+ DatabaseProcess::singleton().idbServer().getAllDatabaseNames(serverConnectionIdentifier, topOrigin, openingOrigin, callbackID);
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebKit2/DatabaseProcess/IndexedDB/WebIDBConnectionToClient.h b/Source/WebKit2/DatabaseProcess/IndexedDB/WebIDBConnectionToClient.h
new file mode 100644
index 000000000..11c6cc1c1
--- /dev/null
+++ b/Source/WebKit2/DatabaseProcess/IndexedDB/WebIDBConnectionToClient.h
@@ -0,0 +1,142 @@
+/*
+ * Copyright (C) 2016 Apple 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:
+ * 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.
+ */
+
+#pragma once
+
+#if ENABLE(INDEXED_DATABASE)
+
+#include "DatabaseToWebProcessConnection.h"
+#include "MessageSender.h"
+#include <WebCore/IDBConnectionToClient.h>
+
+namespace WebCore {
+class IDBCursorInfo;
+class IDBIndexInfo;
+class IDBKeyData;
+class IDBObjectStoreInfo;
+class IDBRequestData;
+class IDBTransactionInfo;
+class IDBValue;
+class SerializedScriptValue;
+struct IDBGetAllRecordsData;
+struct IDBGetRecordData;
+struct IDBIterateCursorData;
+struct IDBKeyRangeData;
+struct SecurityOriginData;
+}
+
+namespace WebKit {
+
+class WebIDBConnectionToClient final : public WebCore::IDBServer::IDBConnectionToClientDelegate, public IPC::MessageSender, public RefCounted<WebIDBConnectionToClient> {
+public:
+ static Ref<WebIDBConnectionToClient> create(DatabaseToWebProcessConnection&, uint64_t serverConnectionIdentifier);
+
+ virtual ~WebIDBConnectionToClient();
+
+ WebCore::IDBServer::IDBConnectionToClient& connectionToClient();
+ uint64_t identifier() const final { return m_identifier; }
+ uint64_t messageSenderDestinationID() final { return m_identifier; }
+
+ // IDBConnectionToClientDelegate
+ void didDeleteDatabase(const WebCore::IDBResultData&) final;
+ void didOpenDatabase(const WebCore::IDBResultData&) final;
+ void didAbortTransaction(const WebCore::IDBResourceIdentifier& transactionIdentifier, const WebCore::IDBError&) final;
+ void didCommitTransaction(const WebCore::IDBResourceIdentifier& transactionIdentifier, const WebCore::IDBError&) final;
+ void didCreateObjectStore(const WebCore::IDBResultData&) final;
+ void didDeleteObjectStore(const WebCore::IDBResultData&) final;
+ void didRenameObjectStore(const WebCore::IDBResultData&) final;
+ void didClearObjectStore(const WebCore::IDBResultData&) final;
+ void didCreateIndex(const WebCore::IDBResultData&) final;
+ void didDeleteIndex(const WebCore::IDBResultData&) final;
+ void didRenameIndex(const WebCore::IDBResultData&) final;
+ void didPutOrAdd(const WebCore::IDBResultData&) final;
+ void didGetRecord(const WebCore::IDBResultData&) final;
+ void didGetAllRecords(const WebCore::IDBResultData&) final;
+ void didGetCount(const WebCore::IDBResultData&) final;
+ void didDeleteRecord(const WebCore::IDBResultData&) final;
+ void didOpenCursor(const WebCore::IDBResultData&) final;
+ void didIterateCursor(const WebCore::IDBResultData&) final;
+
+ void fireVersionChangeEvent(WebCore::IDBServer::UniqueIDBDatabaseConnection&, const WebCore::IDBResourceIdentifier& requestIdentifier, uint64_t requestedVersion) final;
+ void didStartTransaction(const WebCore::IDBResourceIdentifier& transactionIdentifier, const WebCore::IDBError&) final;
+ void didCloseFromServer(WebCore::IDBServer::UniqueIDBDatabaseConnection&, const WebCore::IDBError&) final;
+ void notifyOpenDBRequestBlocked(const WebCore::IDBResourceIdentifier& requestIdentifier, uint64_t oldVersion, uint64_t newVersion) final;
+
+ void didGetAllDatabaseNames(uint64_t callbackID, const Vector<String>& databaseNames) final;
+
+ void ref() override { RefCounted<WebIDBConnectionToClient>::ref(); }
+ void deref() override { RefCounted<WebIDBConnectionToClient>::deref(); }
+
+ // Messages received from WebProcess
+ void deleteDatabase(const WebCore::IDBRequestData&);
+ void openDatabase(const WebCore::IDBRequestData&);
+ void abortTransaction(const WebCore::IDBResourceIdentifier&);
+ void commitTransaction(const WebCore::IDBResourceIdentifier&);
+ void didFinishHandlingVersionChangeTransaction(uint64_t databaseConnectionIdentifier, const WebCore::IDBResourceIdentifier&);
+ void createObjectStore(const WebCore::IDBRequestData&, const WebCore::IDBObjectStoreInfo&);
+ void deleteObjectStore(const WebCore::IDBRequestData&, const String& objectStoreName);
+ void renameObjectStore(const WebCore::IDBRequestData&, uint64_t objectStoreIdentifier, const String& newName);
+ void clearObjectStore(const WebCore::IDBRequestData&, uint64_t objectStoreIdentifier);
+ void createIndex(const WebCore::IDBRequestData&, const WebCore::IDBIndexInfo&);
+ void deleteIndex(const WebCore::IDBRequestData&, uint64_t objectStoreIdentifier, const String& indexName);
+ void renameIndex(const WebCore::IDBRequestData&, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName);
+ void putOrAdd(const WebCore::IDBRequestData&, const WebCore::IDBKeyData&, const WebCore::IDBValue&, unsigned overwriteMode);
+ void getRecord(const WebCore::IDBRequestData&, const WebCore::IDBGetRecordData&);
+ void getAllRecords(const WebCore::IDBRequestData&, const WebCore::IDBGetAllRecordsData&);
+ void getCount(const WebCore::IDBRequestData&, const WebCore::IDBKeyRangeData&);
+ void deleteRecord(const WebCore::IDBRequestData&, const WebCore::IDBKeyRangeData&);
+ void openCursor(const WebCore::IDBRequestData&, const WebCore::IDBCursorInfo&);
+ void iterateCursor(const WebCore::IDBRequestData&, const WebCore::IDBIterateCursorData&);
+
+ void establishTransaction(uint64_t databaseConnectionIdentifier, const WebCore::IDBTransactionInfo&);
+ void databaseConnectionPendingClose(uint64_t databaseConnectionIdentifier);
+ void databaseConnectionClosed(uint64_t databaseConnectionIdentifier);
+ void abortOpenAndUpgradeNeeded(uint64_t databaseConnectionIdentifier, const WebCore::IDBResourceIdentifier& transactionIdentifier);
+ void didFireVersionChangeEvent(uint64_t databaseConnectionIdentifier, const WebCore::IDBResourceIdentifier& requestIdentifier);
+ void openDBRequestCancelled(const WebCore::IDBRequestData&);
+ void confirmDidCloseFromServer(uint64_t databaseConnectionIdentifier);
+
+ void getAllDatabaseNames(uint64_t serverConnectionIdentifier, const WebCore::SecurityOriginData& topOrigin, const WebCore::SecurityOriginData& openingOrigin, uint64_t callbackID);
+
+ void disconnectedFromWebProcess();
+
+ void didReceiveMessage(IPC::Connection&, IPC::Decoder&);
+
+private:
+ WebIDBConnectionToClient(DatabaseToWebProcessConnection&, uint64_t serverConnectionIdentifier);
+
+ IPC::Connection* messageSenderConnection() final;
+
+ template<class MessageType> void handleGetResult(const WebCore::IDBResultData&);
+
+ Ref<DatabaseToWebProcessConnection> m_connection;
+
+ uint64_t m_identifier;
+ RefPtr<WebCore::IDBServer::IDBConnectionToClient> m_connectionToClient;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebKit2/DatabaseProcess/IndexedDB/WebIDBConnectionToClient.messages.in b/Source/WebKit2/DatabaseProcess/IndexedDB/WebIDBConnectionToClient.messages.in
new file mode 100644
index 000000000..d5a747b4f
--- /dev/null
+++ b/Source/WebKit2/DatabaseProcess/IndexedDB/WebIDBConnectionToClient.messages.in
@@ -0,0 +1,56 @@
+# Copyright (C) 2016 Apple 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:
+# 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.
+
+#if ENABLE(INDEXED_DATABASE) && ENABLE(DATABASE_PROCESS)
+
+messages -> WebIDBConnectionToClient {
+ DeleteDatabase(WebCore::IDBRequestData requestData)
+ OpenDatabase(WebCore::IDBRequestData requestData);
+ AbortTransaction(WebCore::IDBResourceIdentifier transactionIdentifier);
+ CommitTransaction(WebCore::IDBResourceIdentifier transactionIdentifier);
+ DidFinishHandlingVersionChangeTransaction(uint64_t databaseConnectionIdentifier, WebCore::IDBResourceIdentifier transactionIdentifier);
+ CreateObjectStore(WebCore::IDBRequestData requestData, WebCore::IDBObjectStoreInfo info);
+ DeleteObjectStore(WebCore::IDBRequestData requestData, String objectStoreName);
+ RenameObjectStore(WebCore::IDBRequestData requestData, uint64_t objectStoreIdentifier, String newName);
+ ClearObjectStore(WebCore::IDBRequestData requestData, uint64_t objectStoreIdentifier);
+ CreateIndex(WebCore::IDBRequestData requestData, WebCore::IDBIndexInfo info);
+ DeleteIndex(WebCore::IDBRequestData requestData, uint64_t objectStoreIdentifier, String indexName);
+ RenameIndex(WebCore::IDBRequestData requestData, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, String newName);
+ PutOrAdd(WebCore::IDBRequestData requestData, WebCore::IDBKeyData key, WebCore::IDBValue value, unsigned overwriteMode);
+ GetRecord(WebCore::IDBRequestData requestData, struct WebCore::IDBGetRecordData getRecordData);
+ GetAllRecords(WebCore::IDBRequestData requestData, struct WebCore::IDBGetAllRecordsData getAllRecordsData);
+ GetCount(WebCore::IDBRequestData requestData, struct WebCore::IDBKeyRangeData range);
+ DeleteRecord(WebCore::IDBRequestData requestData, struct WebCore::IDBKeyRangeData range);
+ OpenCursor(WebCore::IDBRequestData requestData, WebCore::IDBCursorInfo info);
+ IterateCursor(WebCore::IDBRequestData requestData, struct WebCore::IDBIterateCursorData data);
+
+ EstablishTransaction(uint64_t databaseConnectionIdentifier, WebCore::IDBTransactionInfo info);
+ DatabaseConnectionPendingClose(uint64_t databaseConnectionIdentifier);
+ DatabaseConnectionClosed(uint64_t databaseConnectionIdentifier);
+ AbortOpenAndUpgradeNeeded(uint64_t databaseConnectionIdentifier, WebCore::IDBResourceIdentifier transactionIdentifier);
+ DidFireVersionChangeEvent(uint64_t databaseConnectionIdentifier, WebCore::IDBResourceIdentifier requestIdentifier);
+ OpenDBRequestCancelled(WebCore::IDBRequestData requestData);
+ ConfirmDidCloseFromServer(uint64_t databaseConnectionIdentifier);
+
+ GetAllDatabaseNames(uint64_t serverConnectionIdentifier, struct WebCore::SecurityOriginData topOrigin, struct WebCore::SecurityOriginData openingOrigin, uint64_t callbackID);
+}
+#endif // ENABLE(INDEXED_DATABASE) && ENABLE(DATABASE_PROCESS)
diff --git a/Source/WebKit2/DatabaseProcess/gtk/DatabaseProcessMainGtk.cpp b/Source/WebKit2/DatabaseProcess/gtk/DatabaseProcessMainGtk.cpp
new file mode 100644
index 000000000..6e30a363e
--- /dev/null
+++ b/Source/WebKit2/DatabaseProcess/gtk/DatabaseProcessMainGtk.cpp
@@ -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.
+ */
+
+#include "config.h"
+#include "DatabaseProcessMainUnix.h"
+
+#if ENABLE(DATABASE_PROCESS)
+
+#include "ChildProcessMain.h"
+#include "DatabaseProcess.h"
+
+namespace WebKit {
+
+int DatabaseProcessMainUnix(int argc, char** argv)
+{
+ return ChildProcessMain<DatabaseProcess, ChildProcessMainBase>(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
index 000000000..3675e8d6c
--- /dev/null
+++ b/Source/WebKit2/DatabaseProcess/unix/DatabaseProcessMainUnix.h
@@ -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