summaryrefslogtreecommitdiff
path: root/Source/WebKit2/WebProcess/Databases
diff options
context:
space:
mode:
authorKonstantin Tokarev <annulen@yandex.ru>2016-08-25 19:20:41 +0300
committerKonstantin Tokarev <annulen@yandex.ru>2017-02-02 12:30:55 +0000
commit6882a04fb36642862b11efe514251d32070c3d65 (patch)
treeb7959826000b061fd5ccc7512035c7478742f7b0 /Source/WebKit2/WebProcess/Databases
parentab6df191029eeeb0b0f16f127d553265659f739e (diff)
downloadqtwebkit-6882a04fb36642862b11efe514251d32070c3d65.tar.gz
Imported QtWebKit TP3 (git b57bc6801f1876c3220d5a4bfea33d620d477443)
Change-Id: I3b1d8a2808782c9f34d50240000e20cb38d3680f Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
Diffstat (limited to 'Source/WebKit2/WebProcess/Databases')
-rw-r--r--Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.cpp275
-rw-r--r--Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.h106
-rw-r--r--Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.messages.in48
-rw-r--r--Source/WebKit2/WebProcess/Databases/WebDatabaseProvider.cpp88
-rw-r--r--Source/WebKit2/WebProcess/Databases/WebDatabaseProvider.h56
-rw-r--r--Source/WebKit2/WebProcess/Databases/WebToDatabaseProcessConnection.cpp90
-rw-r--r--Source/WebKit2/WebProcess/Databases/WebToDatabaseProcessConnection.h83
7 files changed, 746 insertions, 0 deletions
diff --git a/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.cpp b/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.cpp
new file mode 100644
index 000000000..6f69011f4
--- /dev/null
+++ b/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.cpp
@@ -0,0 +1,275 @@
+/*
+ * 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 "WebIDBConnectionToServer.h"
+
+#if ENABLE(INDEXED_DATABASE)
+
+#include "DataReference.h"
+#include "DatabaseToWebProcessConnectionMessages.h"
+#include "WebIDBConnectionToClientMessages.h"
+#include "WebProcess.h"
+#include "WebToDatabaseProcessConnection.h"
+#include <WebCore/IDBConnectionToServer.h>
+#include <WebCore/IDBCursorInfo.h>
+#include <WebCore/IDBError.h>
+#include <WebCore/IDBIndexInfo.h>
+#include <WebCore/IDBKeyRangeData.h>
+#include <WebCore/IDBObjectStoreInfo.h>
+#include <WebCore/IDBOpenDBRequestImpl.h>
+#include <WebCore/IDBRequestData.h>
+#include <WebCore/IDBResourceIdentifier.h>
+#include <WebCore/IDBResultData.h>
+#include <WebCore/IDBTransactionInfo.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+Ref<WebIDBConnectionToServer> WebIDBConnectionToServer::create()
+{
+ return adoptRef(*new WebIDBConnectionToServer);
+}
+
+WebIDBConnectionToServer::WebIDBConnectionToServer()
+{
+ relaxAdoptionRequirement();
+ m_connectionToServer = IDBClient::IDBConnectionToServer::create(*this);
+
+ m_isOpenInServer = sendSync(Messages::DatabaseToWebProcessConnection::EstablishIDBConnectionToServer(), m_identifier);
+}
+
+WebIDBConnectionToServer::~WebIDBConnectionToServer()
+{
+ if (m_isOpenInServer)
+ send(Messages::DatabaseToWebProcessConnection::RemoveIDBConnectionToServer(m_identifier));
+}
+
+IPC::Connection* WebIDBConnectionToServer::messageSenderConnection()
+{
+ return WebProcess::singleton().webToDatabaseProcessConnection()->connection();
+}
+
+IDBClient::IDBConnectionToServer& WebIDBConnectionToServer::coreConnectionToServer()
+{
+ return *m_connectionToServer;
+}
+
+void WebIDBConnectionToServer::deleteDatabase(IDBRequestData& requestData)
+{
+ send(Messages::WebIDBConnectionToClient::DeleteDatabase(requestData));
+}
+
+void WebIDBConnectionToServer::openDatabase(IDBRequestData& requestData)
+{
+ send(Messages::WebIDBConnectionToClient::OpenDatabase(requestData));
+}
+
+void WebIDBConnectionToServer::abortTransaction(IDBResourceIdentifier& transactionIdentifier)
+{
+ send(Messages::WebIDBConnectionToClient::AbortTransaction(transactionIdentifier));
+}
+
+void WebIDBConnectionToServer::commitTransaction(IDBResourceIdentifier& transactionIdentifier)
+{
+ send(Messages::WebIDBConnectionToClient::CommitTransaction(transactionIdentifier));
+}
+
+void WebIDBConnectionToServer::didFinishHandlingVersionChangeTransaction(IDBResourceIdentifier& transactionIdentifier)
+{
+ send(Messages::WebIDBConnectionToClient::DidFinishHandlingVersionChangeTransaction(transactionIdentifier));
+}
+
+void WebIDBConnectionToServer::createObjectStore(const IDBRequestData& requestData, const IDBObjectStoreInfo& info)
+{
+ send(Messages::WebIDBConnectionToClient::CreateObjectStore(requestData, info));
+}
+
+void WebIDBConnectionToServer::deleteObjectStore(const IDBRequestData& requestData, const String& objectStoreName)
+{
+ send(Messages::WebIDBConnectionToClient::DeleteObjectStore(requestData, objectStoreName));
+}
+
+void WebIDBConnectionToServer::clearObjectStore(const IDBRequestData& requestData, uint64_t objectStoreIdentifier)
+{
+ send(Messages::WebIDBConnectionToClient::ClearObjectStore(requestData, objectStoreIdentifier));
+}
+
+void WebIDBConnectionToServer::createIndex(const IDBRequestData& requestData, const IDBIndexInfo& info)
+{
+ send(Messages::WebIDBConnectionToClient::CreateIndex(requestData, info));
+}
+
+void WebIDBConnectionToServer::deleteIndex(const IDBRequestData& requestData, uint64_t objectStoreIdentifier, const String& indexName)
+{
+ send(Messages::WebIDBConnectionToClient::DeleteIndex(requestData, objectStoreIdentifier, indexName));
+}
+
+void WebIDBConnectionToServer::putOrAdd(const IDBRequestData& requestData, IDBKey* key, SerializedScriptValue& value, const IndexedDB::ObjectStoreOverwriteMode mode)
+{
+ IDBKeyData keyData(key);
+ IPC::DataReference valueData(value.data());
+ send(Messages::WebIDBConnectionToClient::PutOrAdd(requestData, keyData, valueData, static_cast<unsigned>(mode)));
+}
+
+void WebIDBConnectionToServer::getRecord(const IDBRequestData& requestData, const IDBKeyRangeData& range)
+{
+ send(Messages::WebIDBConnectionToClient::GetRecord(requestData, range));
+}
+
+void WebIDBConnectionToServer::getCount(const IDBRequestData& requestData, const IDBKeyRangeData& range)
+{
+ send(Messages::WebIDBConnectionToClient::GetCount(requestData, range));
+}
+
+void WebIDBConnectionToServer::deleteRecord(const IDBRequestData& requestData, const IDBKeyRangeData& range)
+{
+ send(Messages::WebIDBConnectionToClient::DeleteRecord(requestData, range));
+}
+
+void WebIDBConnectionToServer::openCursor(const IDBRequestData& requestData, const IDBCursorInfo& info)
+{
+ send(Messages::WebIDBConnectionToClient::OpenCursor(requestData, info));
+}
+
+void WebIDBConnectionToServer::iterateCursor(const IDBRequestData& requestData, const IDBKeyData& key, unsigned long count)
+{
+ send(Messages::WebIDBConnectionToClient::IterateCursor(requestData, key, count));
+}
+
+void WebIDBConnectionToServer::establishTransaction(uint64_t databaseConnectionIdentifier, const IDBTransactionInfo& info)
+{
+ send(Messages::WebIDBConnectionToClient::EstablishTransaction(databaseConnectionIdentifier, info));
+}
+
+void WebIDBConnectionToServer::databaseConnectionClosed(uint64_t databaseConnectionIdentifier)
+{
+ send(Messages::WebIDBConnectionToClient::DatabaseConnectionClosed(databaseConnectionIdentifier));
+}
+
+void WebIDBConnectionToServer::abortOpenAndUpgradeNeeded(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& transactionIdentifier)
+{
+ send(Messages::WebIDBConnectionToClient::AbortOpenAndUpgradeNeeded(databaseConnectionIdentifier, transactionIdentifier));
+}
+
+void WebIDBConnectionToServer::didFireVersionChangeEvent(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& requestIdentifier)
+{
+ send(Messages::WebIDBConnectionToClient::DidFireVersionChangeEvent(databaseConnectionIdentifier, requestIdentifier));
+}
+
+void WebIDBConnectionToServer::didDeleteDatabase(const IDBResultData& result)
+{
+ m_connectionToServer->didDeleteDatabase(result);
+}
+
+void WebIDBConnectionToServer::didOpenDatabase(const IDBResultData& result)
+{
+ m_connectionToServer->didOpenDatabase(result);
+}
+
+void WebIDBConnectionToServer::didAbortTransaction(const IDBResourceIdentifier& transactionIdentifier, const IDBError& error)
+{
+ m_connectionToServer->didAbortTransaction(transactionIdentifier, error);
+}
+
+void WebIDBConnectionToServer::didCommitTransaction(const IDBResourceIdentifier& transactionIdentifier, const IDBError& error)
+{
+ m_connectionToServer->didCommitTransaction(transactionIdentifier, error);
+}
+
+void WebIDBConnectionToServer::didCreateObjectStore(const IDBResultData& result)
+{
+ m_connectionToServer->didCreateObjectStore(result);
+}
+
+void WebIDBConnectionToServer::didDeleteObjectStore(const IDBResultData& result)
+{
+ m_connectionToServer->didDeleteObjectStore(result);
+}
+
+void WebIDBConnectionToServer::didClearObjectStore(const IDBResultData& result)
+{
+ m_connectionToServer->didClearObjectStore(result);
+}
+
+void WebIDBConnectionToServer::didCreateIndex(const IDBResultData& result)
+{
+ m_connectionToServer->didCreateIndex(result);
+}
+
+void WebIDBConnectionToServer::didDeleteIndex(const IDBResultData& result)
+{
+ m_connectionToServer->didDeleteIndex(result);
+}
+
+void WebIDBConnectionToServer::didPutOrAdd(const IDBResultData& result)
+{
+ m_connectionToServer->didPutOrAdd(result);
+}
+
+void WebIDBConnectionToServer::didGetRecord(const IDBResultData& result)
+{
+ m_connectionToServer->didGetRecord(result);
+}
+
+void WebIDBConnectionToServer::didGetCount(const IDBResultData& result)
+{
+ m_connectionToServer->didGetCount(result);
+}
+
+void WebIDBConnectionToServer::didDeleteRecord(const IDBResultData& result)
+{
+ m_connectionToServer->didDeleteRecord(result);
+}
+
+void WebIDBConnectionToServer::didOpenCursor(const IDBResultData& result)
+{
+ m_connectionToServer->didOpenCursor(result);
+}
+
+void WebIDBConnectionToServer::didIterateCursor(const IDBResultData& result)
+{
+ m_connectionToServer->didIterateCursor(result);
+}
+
+void WebIDBConnectionToServer::fireVersionChangeEvent(uint64_t uniqueDatabaseConnectionIdentifier, const IDBResourceIdentifier& requestIdentifier, uint64_t requestedVersion)
+{
+ m_connectionToServer->fireVersionChangeEvent(uniqueDatabaseConnectionIdentifier, requestIdentifier, requestedVersion);
+}
+
+void WebIDBConnectionToServer::didStartTransaction(const IDBResourceIdentifier& transactionIdentifier, const WebCore::IDBError& error)
+{
+ m_connectionToServer->didStartTransaction(transactionIdentifier, error);
+}
+
+void WebIDBConnectionToServer::notifyOpenDBRequestBlocked(const IDBResourceIdentifier& requestIdentifier, uint64_t oldVersion, uint64_t newVersion)
+{
+ m_connectionToServer->notifyOpenDBRequestBlocked(requestIdentifier, oldVersion, newVersion);
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.h b/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.h
new file mode 100644
index 000000000..35d4e8096
--- /dev/null
+++ b/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.h
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+
+#ifndef WebIDBConnectionToServer_h
+#define WebIDBConnectionToServer_h
+
+#if ENABLE(INDEXED_DATABASE)
+
+#include "MessageSender.h"
+#include <WebCore/IDBConnectionToServer.h>
+
+namespace WebKit {
+
+class WebIDBConnectionToServer final : public WebCore::IDBClient::IDBConnectionToServerDelegate, public IPC::MessageSender, public RefCounted<WebIDBConnectionToServer> {
+public:
+ static Ref<WebIDBConnectionToServer> create();
+
+ virtual ~WebIDBConnectionToServer();
+
+ WebCore::IDBClient::IDBConnectionToServer& coreConnectionToServer();
+ virtual uint64_t identifier() const override final { return m_identifier; }
+ virtual uint64_t messageSenderDestinationID() override final { return m_identifier; }
+
+ // IDBConnectionToServerDelegate
+ virtual void deleteDatabase(WebCore::IDBRequestData&) override final;
+ virtual void openDatabase(WebCore::IDBRequestData&) override final;
+ virtual void abortTransaction(WebCore::IDBResourceIdentifier&) override final;
+ virtual void commitTransaction(WebCore::IDBResourceIdentifier&) override final;
+ virtual void didFinishHandlingVersionChangeTransaction(WebCore::IDBResourceIdentifier&) override final;
+ virtual void createObjectStore(const WebCore::IDBRequestData&, const WebCore::IDBObjectStoreInfo&) override final;
+ virtual void deleteObjectStore(const WebCore::IDBRequestData&, const String& objectStoreName) override final;
+ virtual void clearObjectStore(const WebCore::IDBRequestData&, uint64_t objectStoreIdentifier) override final;
+ virtual void createIndex(const WebCore::IDBRequestData&, const WebCore::IDBIndexInfo&) override final;
+ virtual void deleteIndex(const WebCore::IDBRequestData&, uint64_t objectStoreIdentifier, const String& indexName) override final;
+ virtual void putOrAdd(const WebCore::IDBRequestData&, WebCore::IDBKey*, WebCore::SerializedScriptValue&, const WebCore::IndexedDB::ObjectStoreOverwriteMode) override final;
+ virtual void getRecord(const WebCore::IDBRequestData&, const WebCore::IDBKeyRangeData&) override final;
+ virtual void getCount(const WebCore::IDBRequestData&, const WebCore::IDBKeyRangeData&) override final;
+ virtual void deleteRecord(const WebCore::IDBRequestData&, const WebCore::IDBKeyRangeData&) override final;
+ virtual void openCursor(const WebCore::IDBRequestData&, const WebCore::IDBCursorInfo&) override final;
+ virtual void iterateCursor(const WebCore::IDBRequestData&, const WebCore::IDBKeyData&, unsigned long count) override final;
+ virtual void establishTransaction(uint64_t databaseConnectionIdentifier, const WebCore::IDBTransactionInfo&) override final;
+ virtual void databaseConnectionClosed(uint64_t databaseConnectionIdentifier) override final;
+ virtual void abortOpenAndUpgradeNeeded(uint64_t databaseConnectionIdentifier, const WebCore::IDBResourceIdentifier& transactionIdentifier) override final;
+ virtual void didFireVersionChangeEvent(uint64_t databaseConnectionIdentifier, const WebCore::IDBResourceIdentifier& requestIdentifier) override final;
+
+ virtual void ref() override { RefCounted<WebIDBConnectionToServer>::ref(); }
+ virtual void deref() override { RefCounted<WebIDBConnectionToServer>::deref(); }
+
+ // Messages received from DatabaseProcess
+ void didDeleteDatabase(const WebCore::IDBResultData&);
+ void didOpenDatabase(const WebCore::IDBResultData&);
+ void didAbortTransaction(const WebCore::IDBResourceIdentifier& transactionIdentifier, const WebCore::IDBError&);
+ void didCommitTransaction(const WebCore::IDBResourceIdentifier& transactionIdentifier, const WebCore::IDBError&);
+ void didCreateObjectStore(const WebCore::IDBResultData&);
+ void didDeleteObjectStore(const WebCore::IDBResultData&);
+ void didClearObjectStore(const WebCore::IDBResultData&);
+ void didCreateIndex(const WebCore::IDBResultData&);
+ void didDeleteIndex(const WebCore::IDBResultData&);
+ void didPutOrAdd(const WebCore::IDBResultData&);
+ void didGetRecord(const WebCore::IDBResultData&);
+ void didGetCount(const WebCore::IDBResultData&);
+ void didDeleteRecord(const WebCore::IDBResultData&);
+ void didOpenCursor(const WebCore::IDBResultData&);
+ void didIterateCursor(const WebCore::IDBResultData&);
+ void fireVersionChangeEvent(uint64_t uniqueDatabaseConnectionIdentifier, const WebCore::IDBResourceIdentifier& requestIdentifier, uint64_t requestedVersion);
+ void didStartTransaction(const WebCore::IDBResourceIdentifier& transactionIdentifier, const WebCore::IDBError&);
+ void notifyOpenDBRequestBlocked(const WebCore::IDBResourceIdentifier& requestIdentifier, uint64_t oldVersion, uint64_t newVersion);
+
+ void didReceiveMessage(IPC::Connection&, IPC::MessageDecoder&);
+
+private:
+ WebIDBConnectionToServer();
+
+ virtual IPC::Connection* messageSenderConnection() override final;
+
+ uint64_t m_identifier;
+ bool m_isOpenInServer { false };
+ RefPtr<WebCore::IDBClient::IDBConnectionToServer> m_connectionToServer;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(INDEXED_DATABASE)
+#endif // WebIDBConnectionToServer_h
diff --git a/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.messages.in b/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.messages.in
new file mode 100644
index 000000000..83e3f8086
--- /dev/null
+++ b/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.messages.in
@@ -0,0 +1,48 @@
+# 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 -> WebIDBConnectionToServer {
+ DidDeleteDatabase(WebCore::IDBResultData result)
+ DidOpenDatabase(WebCore::IDBResultData result)
+ DidAbortTransaction(WebCore::IDBResourceIdentifier transactionIdentifier, WebCore::IDBError error)
+ DidCommitTransaction(WebCore::IDBResourceIdentifier transactionIdentifier, WebCore::IDBError error)
+ DidCreateObjectStore(WebCore::IDBResultData result)
+ DidDeleteObjectStore(WebCore::IDBResultData result)
+ DidClearObjectStore(WebCore::IDBResultData result)
+ DidCreateIndex(WebCore::IDBResultData result)
+ DidDeleteIndex(WebCore::IDBResultData result)
+ DidPutOrAdd(WebCore::IDBResultData result)
+ DidGetRecord(WebCore::IDBResultData result)
+ DidGetCount(WebCore::IDBResultData result)
+ DidDeleteRecord(WebCore::IDBResultData result)
+ DidOpenCursor(WebCore::IDBResultData result)
+ DidIterateCursor(WebCore::IDBResultData result)
+
+ FireVersionChangeEvent(uint64_t databaseConnectionIdentifier, WebCore::IDBResourceIdentifier requestIdentifier, uint64_t requestedVersion)
+ DidStartTransaction(WebCore::IDBResourceIdentifier transactionIdentifier, WebCore::IDBError error)
+ NotifyOpenDBRequestBlocked(WebCore::IDBResourceIdentifier requestIdentifier, uint64_t oldVersion, uint64_t newVersion)
+
+}
+
+#endif // ENABLE(INDEXED_DATABASE) && ENABLE(DATABASE_PROCESS)
diff --git a/Source/WebKit2/WebProcess/Databases/WebDatabaseProvider.cpp b/Source/WebKit2/WebProcess/Databases/WebDatabaseProvider.cpp
new file mode 100644
index 000000000..ae5591b6c
--- /dev/null
+++ b/Source/WebKit2/WebProcess/Databases/WebDatabaseProvider.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2015 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 "WebDatabaseProvider.h"
+
+#include "WebProcess.h"
+#include "WebToDatabaseProcessConnection.h"
+#include <WebCore/SessionID.h>
+#include <wtf/HashMap.h>
+#include <wtf/NeverDestroyed.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static HashMap<uint64_t, WebDatabaseProvider*>& databaseProviders()
+{
+ static NeverDestroyed<HashMap<uint64_t, WebDatabaseProvider*>> databaseProviders;
+
+ return databaseProviders;
+}
+
+Ref<WebDatabaseProvider> WebDatabaseProvider::getOrCreate(uint64_t identifier)
+{
+ auto& slot = databaseProviders().add(identifier, nullptr).iterator->value;
+ if (slot)
+ return *slot;
+
+ Ref<WebDatabaseProvider> databaseProvider = adoptRef(*new WebDatabaseProvider(identifier));
+ slot = databaseProvider.ptr();
+
+ return databaseProvider;
+}
+
+WebDatabaseProvider::WebDatabaseProvider(uint64_t identifier)
+ : m_identifier(identifier)
+{
+}
+
+WebDatabaseProvider::~WebDatabaseProvider()
+{
+ ASSERT(databaseProviders().contains(m_identifier));
+
+ databaseProviders().remove(m_identifier);
+}
+
+#if ENABLE(INDEXED_DATABASE)
+
+WebCore::IDBClient::IDBConnectionToServer& WebDatabaseProvider::idbConnectionToServerForSession(const WebCore::SessionID& sessionID)
+{
+ if (sessionID.isEphemeral()) {
+ auto result = m_idbEphemeralConnectionMap.add(sessionID.sessionID(), nullptr);
+ if (result.isNewEntry)
+ result.iterator->value = WebCore::InProcessIDBServer::create();
+
+ return result.iterator->value->connectionToServer();
+ }
+
+ ASSERT(WebProcess::singleton().webToDatabaseProcessConnection());
+ return WebProcess::singleton().webToDatabaseProcessConnection()->idbConnectionToServerForSession(sessionID).coreConnectionToServer();
+}
+
+#endif
+
+}
diff --git a/Source/WebKit2/WebProcess/Databases/WebDatabaseProvider.h b/Source/WebKit2/WebProcess/Databases/WebDatabaseProvider.h
new file mode 100644
index 000000000..fe9ffaceb
--- /dev/null
+++ b/Source/WebKit2/WebProcess/Databases/WebDatabaseProvider.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2015 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 WebDatabaseProvider_h
+#define WebDatabaseProvider_h
+
+#include <WebCore/DatabaseProvider.h>
+#include <WebCore/InProcessIDBServer.h>
+#include <wtf/HashMap.h>
+
+namespace WebKit {
+
+class WebDatabaseProvider final : public WebCore::DatabaseProvider {
+public:
+ static Ref<WebDatabaseProvider> getOrCreate(uint64_t identifier);
+ virtual ~WebDatabaseProvider();
+
+#if ENABLE(INDEXED_DATABASE)
+ virtual WebCore::IDBClient::IDBConnectionToServer& idbConnectionToServerForSession(const WebCore::SessionID&) override final;
+#endif
+
+private:
+ explicit WebDatabaseProvider(uint64_t identifier);
+
+#if ENABLE(INDEXED_DATABASE)
+ HashMap<uint64_t, RefPtr<WebCore::InProcessIDBServer>> m_idbEphemeralConnectionMap;
+#endif
+
+ const uint64_t m_identifier;
+};
+
+}
+
+#endif // WebDatabaseProvider_h
diff --git a/Source/WebKit2/WebProcess/Databases/WebToDatabaseProcessConnection.cpp b/Source/WebKit2/WebProcess/Databases/WebToDatabaseProcessConnection.cpp
new file mode 100644
index 000000000..fd51fdcde
--- /dev/null
+++ b/Source/WebKit2/WebProcess/Databases/WebToDatabaseProcessConnection.cpp
@@ -0,0 +1,90 @@
+/*
+ * 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. ``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
+ * 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 "WebToDatabaseProcessConnection.h"
+
+#include "DatabaseToWebProcessConnectionMessages.h"
+#include "WebIDBConnectionToServerMessages.h"
+#include "WebProcess.h"
+#include <wtf/RunLoop.h>
+
+#if ENABLE(DATABASE_PROCESS)
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebToDatabaseProcessConnection::WebToDatabaseProcessConnection(IPC::Connection::Identifier connectionIdentifier)
+{
+ m_connection = IPC::Connection::createClientConnection(connectionIdentifier, *this);
+ m_connection->open();
+}
+
+WebToDatabaseProcessConnection::~WebToDatabaseProcessConnection()
+{
+}
+
+void WebToDatabaseProcessConnection::didReceiveMessage(IPC::Connection& connection, IPC::MessageDecoder& decoder)
+{
+#if ENABLE(INDEXED_DATABASE)
+ if (decoder.messageReceiverName() == Messages::WebIDBConnectionToServer::messageReceiverName()) {
+ auto iterator = m_webIDBConnectionsByIdentifier.find(decoder.destinationID());
+ if (iterator != m_webIDBConnectionsByIdentifier.end())
+ iterator->value->didReceiveMessage(connection, decoder);
+ return;
+ }
+#endif
+
+ ASSERT_NOT_REACHED();
+}
+
+void WebToDatabaseProcessConnection::didClose(IPC::Connection& connection)
+{
+ WebProcess::singleton().webToDatabaseProcessConnectionClosed(this);
+}
+
+void WebToDatabaseProcessConnection::didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference messageReceiverName, IPC::StringReference messageName)
+{
+}
+
+#if ENABLE(INDEXED_DATABASE)
+WebIDBConnectionToServer& WebToDatabaseProcessConnection::idbConnectionToServerForSession(const SessionID& sessionID)
+{
+ auto result = m_webIDBConnectionsBySession.add(sessionID, nullptr);
+ if (result.isNewEntry) {
+ result.iterator->value = WebIDBConnectionToServer::create();
+ ASSERT(!m_webIDBConnectionsByIdentifier.contains(result.iterator->value->identifier()));
+ m_webIDBConnectionsByIdentifier.set(result.iterator->value->identifier(), result.iterator->value);
+ }
+
+ return *result.iterator->value;
+}
+#endif
+
+} // namespace WebKit
+
+#endif // ENABLE(DATABASE_PROCESS)
diff --git a/Source/WebKit2/WebProcess/Databases/WebToDatabaseProcessConnection.h b/Source/WebKit2/WebProcess/Databases/WebToDatabaseProcessConnection.h
new file mode 100644
index 000000000..9edf49842
--- /dev/null
+++ b/Source/WebKit2/WebProcess/Databases/WebToDatabaseProcessConnection.h
@@ -0,0 +1,83 @@
+/*
+ * 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. ``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
+ * 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 WebToDatabaseProcessConnection_h
+#define WebToDatabaseProcessConnection_h
+
+#include "Connection.h"
+#include "MessageSender.h"
+#include "WebIDBConnectionToServer.h"
+#include <WebCore/SessionID.h>
+#include <wtf/RefCounted.h>
+
+#if ENABLE(DATABASE_PROCESS)
+
+namespace WebCore {
+class SessionID;
+}
+
+namespace WebKit {
+
+class WebToDatabaseProcessConnection : public RefCounted<WebToDatabaseProcessConnection>, public IPC::Connection::Client, public IPC::MessageSender {
+public:
+ static Ref<WebToDatabaseProcessConnection> create(IPC::Connection::Identifier connectionIdentifier)
+ {
+ return adoptRef(*new WebToDatabaseProcessConnection(connectionIdentifier));
+ }
+ ~WebToDatabaseProcessConnection();
+
+ IPC::Connection* connection() const { return m_connection.get(); }
+
+#if ENABLE(INDEXED_DATABASE)
+ WebIDBConnectionToServer& idbConnectionToServerForSession(const WebCore::SessionID&);
+#endif
+
+private:
+ WebToDatabaseProcessConnection(IPC::Connection::Identifier);
+
+ // IPC::Connection::Client
+ virtual void didReceiveMessage(IPC::Connection&, IPC::MessageDecoder&) override;
+ virtual void didClose(IPC::Connection&) override;
+ virtual void didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference messageReceiverName, IPC::StringReference messageName) override;
+ virtual IPC::ProcessType localProcessType() override { return IPC::ProcessType::Web; }
+ virtual IPC::ProcessType remoteProcessType() override { return IPC::ProcessType::Database; }
+
+ // IPC::MessageSender
+ virtual IPC::Connection* messageSenderConnection() override { return m_connection.get(); }
+ virtual uint64_t messageSenderDestinationID() override { return 0; }
+
+ RefPtr<IPC::Connection> m_connection;
+
+#if ENABLE(INDEXED_DATABASE)
+ HashMap<WebCore::SessionID, RefPtr<WebIDBConnectionToServer>> m_webIDBConnectionsBySession;
+ HashMap<uint64_t, RefPtr<WebIDBConnectionToServer>> m_webIDBConnectionsByIdentifier;
+#endif
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(DATABASE_PROCESS)
+#endif // WebToDatabaseProcessConnection_h