Skip to content
Permalink
Browse files
Modern IDB: Implement client->server operations in WK2.
https://bugs.webkit.org/show_bug.cgi?id=154400

Reviewed by Alex Christensen.

No change in behavior yet; Just laying the groundwork.

Source/WebCore:

* Modules/indexeddb/server/IDBServer.h:
* Modules/indexeddb/server/UniqueIDBDatabase.h:
* Modules/indexeddb/shared/IDBIndexInfo.h:
* Modules/indexeddb/shared/IDBObjectStoreInfo.h:

Source/WebKit2:

* DatabaseProcess/DatabaseProcess.cpp:
(WebKit::DatabaseProcess::idbServer):
* DatabaseProcess/DatabaseProcess.h:

* DatabaseProcess/DatabaseToWebProcessConnection.cpp:
(WebKit::DatabaseToWebProcessConnection::didReceiveMessage):
* DatabaseProcess/IndexedDB/DatabaseProcessIDBConnection.h:

* DatabaseProcess/IndexedDB/WebIDBConnectionToClient.cpp:
(WebKit::WebIDBConnectionToClient::deleteDatabase):
(WebKit::WebIDBConnectionToClient::openDatabase):
(WebKit::WebIDBConnectionToClient::abortTransaction):
(WebKit::WebIDBConnectionToClient::commitTransaction):
(WebKit::WebIDBConnectionToClient::didFinishHandlingVersionChangeTransaction):
(WebKit::WebIDBConnectionToClient::createObjectStore):
(WebKit::WebIDBConnectionToClient::deleteObjectStore):
(WebKit::WebIDBConnectionToClient::clearObjectStore):
(WebKit::WebIDBConnectionToClient::createIndex):
(WebKit::WebIDBConnectionToClient::deleteIndex):
(WebKit::WebIDBConnectionToClient::putOrAdd):
(WebKit::WebIDBConnectionToClient::getRecord):
(WebKit::WebIDBConnectionToClient::getCount):
(WebKit::WebIDBConnectionToClient::deleteRecord):
(WebKit::WebIDBConnectionToClient::openCursor):
(WebKit::WebIDBConnectionToClient::iterateCursor):
(WebKit::WebIDBConnectionToClient::establishTransaction):
(WebKit::WebIDBConnectionToClient::databaseConnectionClosed):
(WebKit::WebIDBConnectionToClient::abortOpenAndUpgradeNeeded):
(WebKit::WebIDBConnectionToClient::didFireVersionChangeEvent):
* DatabaseProcess/IndexedDB/WebIDBConnectionToClient.h:
* DatabaseProcess/IndexedDB/WebIDBConnectionToClient.messages.in:


Canonical link: https://commits.webkit.org/172525@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196771 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
beidson committed Feb 18, 2016
1 parent 62f0f8b commit be30f5e6d75c904277af98c368edea148a4a52c4
Showing 14 changed files with 163 additions and 51 deletions.
@@ -1,3 +1,17 @@
2016-02-18 Brady Eidson <beidson@apple.com>

Modern IDB: Implement client->server operations in WK2.
https://bugs.webkit.org/show_bug.cgi?id=154400

Reviewed by Alex Christensen.

No change in behavior yet; Just laying the groundwork.

* Modules/indexeddb/server/IDBServer.h:
* Modules/indexeddb/server/UniqueIDBDatabase.h:
* Modules/indexeddb/shared/IDBIndexInfo.h:
* Modules/indexeddb/shared/IDBObjectStoreInfo.h:

2016-02-18 Chris Dumez <cdumez@apple.com>

[Unforgeable] operations should not be writable as per Web IDL
@@ -51,33 +51,33 @@ namespace IDBServer {
class IDBServer : public RefCounted<IDBServer> {
public:
static Ref<IDBServer> create();
static Ref<IDBServer> create(const String& databaseDirectoryPath);
WEBCORE_EXPORT static Ref<IDBServer> create(const String& databaseDirectoryPath);

void registerConnection(IDBConnectionToClient&);
void unregisterConnection(IDBConnectionToClient&);

// Operations requested by the client.
void openDatabase(const IDBRequestData&);
void deleteDatabase(const IDBRequestData&);
void abortTransaction(const IDBResourceIdentifier&);
void commitTransaction(const IDBResourceIdentifier&);
void didFinishHandlingVersionChangeTransaction(const IDBResourceIdentifier&);
void createObjectStore(const IDBRequestData&, const IDBObjectStoreInfo&);
void deleteObjectStore(const IDBRequestData&, const String& objectStoreName);
void clearObjectStore(const IDBRequestData&, uint64_t objectStoreIdentifier);
void createIndex(const IDBRequestData&, const IDBIndexInfo&);
void deleteIndex(const IDBRequestData&, uint64_t objectStoreIdentifier, const String& indexName);
void putOrAdd(const IDBRequestData&, const IDBKeyData&, const ThreadSafeDataBuffer& valueData, IndexedDB::ObjectStoreOverwriteMode);
void getRecord(const IDBRequestData&, const IDBKeyRangeData&);
void getCount(const IDBRequestData&, const IDBKeyRangeData&);
void deleteRecord(const IDBRequestData&, const IDBKeyRangeData&);
void openCursor(const IDBRequestData&, const IDBCursorInfo&);
void iterateCursor(const IDBRequestData&, const IDBKeyData&, unsigned long count);

void establishTransaction(uint64_t databaseConnectionIdentifier, const IDBTransactionInfo&);
void databaseConnectionClosed(uint64_t databaseConnectionIdentifier);
void abortOpenAndUpgradeNeeded(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& transactionIdentifier);
void didFireVersionChangeEvent(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& requestIdentifier);
WEBCORE_EXPORT void openDatabase(const IDBRequestData&);
WEBCORE_EXPORT void deleteDatabase(const IDBRequestData&);
WEBCORE_EXPORT void abortTransaction(const IDBResourceIdentifier&);
WEBCORE_EXPORT void commitTransaction(const IDBResourceIdentifier&);
WEBCORE_EXPORT void didFinishHandlingVersionChangeTransaction(const IDBResourceIdentifier&);
WEBCORE_EXPORT void createObjectStore(const IDBRequestData&, const IDBObjectStoreInfo&);
WEBCORE_EXPORT void deleteObjectStore(const IDBRequestData&, const String& objectStoreName);
WEBCORE_EXPORT void clearObjectStore(const IDBRequestData&, uint64_t objectStoreIdentifier);
WEBCORE_EXPORT void createIndex(const IDBRequestData&, const IDBIndexInfo&);
WEBCORE_EXPORT void deleteIndex(const IDBRequestData&, uint64_t objectStoreIdentifier, const String& indexName);
WEBCORE_EXPORT void putOrAdd(const IDBRequestData&, const IDBKeyData&, const ThreadSafeDataBuffer& valueData, IndexedDB::ObjectStoreOverwriteMode);
WEBCORE_EXPORT void getRecord(const IDBRequestData&, const IDBKeyRangeData&);
WEBCORE_EXPORT void getCount(const IDBRequestData&, const IDBKeyRangeData&);
WEBCORE_EXPORT void deleteRecord(const IDBRequestData&, const IDBKeyRangeData&);
WEBCORE_EXPORT void openCursor(const IDBRequestData&, const IDBCursorInfo&);
WEBCORE_EXPORT void iterateCursor(const IDBRequestData&, const IDBKeyData&, unsigned long count);

WEBCORE_EXPORT void establishTransaction(uint64_t databaseConnectionIdentifier, const IDBTransactionInfo&);
WEBCORE_EXPORT void databaseConnectionClosed(uint64_t databaseConnectionIdentifier);
WEBCORE_EXPORT void abortOpenAndUpgradeNeeded(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& transactionIdentifier);
WEBCORE_EXPORT void didFireVersionChangeEvent(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& requestIdentifier);

void postDatabaseTask(std::unique_ptr<CrossThreadTask>&&);
void postDatabaseTaskReply(std::unique_ptr<CrossThreadTask>&&);
@@ -72,7 +72,7 @@ class UniqueIDBDatabase : public ThreadSafeRefCounted<UniqueIDBDatabase> {
return adoptRef(*new UniqueIDBDatabase(server, identifier));
}

~UniqueIDBDatabase();
WEBCORE_EXPORT ~UniqueIDBDatabase();

void openDatabaseConnection(IDBConnectionToClient&, const IDBRequestData&);

@@ -35,7 +35,7 @@ namespace WebCore {

class IDBIndexInfo {
public:
IDBIndexInfo();
WEBCORE_EXPORT IDBIndexInfo();
IDBIndexInfo(uint64_t identifier, uint64_t objectStoreIdentifier, const String& name, const IDBKeyPath&, bool unique, bool multiEntry);

IDBIndexInfo isolatedCopy() const;
@@ -39,7 +39,7 @@ class IDBKeyPath;

class IDBObjectStoreInfo {
public:
IDBObjectStoreInfo();
WEBCORE_EXPORT IDBObjectStoreInfo();
IDBObjectStoreInfo(uint64_t identifier, const String& name, const IDBKeyPath&, bool autoIncrement);

uint64_t identifier() const { return m_identifier; }
@@ -1,3 +1,44 @@
2016-02-18 Brady Eidson <beidson@apple.com>

Modern IDB: Implement client->server operations in WK2.
https://bugs.webkit.org/show_bug.cgi?id=154400

Reviewed by Alex Christensen.

No change in behavior yet; Just laying the groundwork.

* DatabaseProcess/DatabaseProcess.cpp:
(WebKit::DatabaseProcess::idbServer):
* DatabaseProcess/DatabaseProcess.h:

* DatabaseProcess/DatabaseToWebProcessConnection.cpp:
(WebKit::DatabaseToWebProcessConnection::didReceiveMessage):
* DatabaseProcess/IndexedDB/DatabaseProcessIDBConnection.h:

* DatabaseProcess/IndexedDB/WebIDBConnectionToClient.cpp:
(WebKit::WebIDBConnectionToClient::deleteDatabase):
(WebKit::WebIDBConnectionToClient::openDatabase):
(WebKit::WebIDBConnectionToClient::abortTransaction):
(WebKit::WebIDBConnectionToClient::commitTransaction):
(WebKit::WebIDBConnectionToClient::didFinishHandlingVersionChangeTransaction):
(WebKit::WebIDBConnectionToClient::createObjectStore):
(WebKit::WebIDBConnectionToClient::deleteObjectStore):
(WebKit::WebIDBConnectionToClient::clearObjectStore):
(WebKit::WebIDBConnectionToClient::createIndex):
(WebKit::WebIDBConnectionToClient::deleteIndex):
(WebKit::WebIDBConnectionToClient::putOrAdd):
(WebKit::WebIDBConnectionToClient::getRecord):
(WebKit::WebIDBConnectionToClient::getCount):
(WebKit::WebIDBConnectionToClient::deleteRecord):
(WebKit::WebIDBConnectionToClient::openCursor):
(WebKit::WebIDBConnectionToClient::iterateCursor):
(WebKit::WebIDBConnectionToClient::establishTransaction):
(WebKit::WebIDBConnectionToClient::databaseConnectionClosed):
(WebKit::WebIDBConnectionToClient::abortOpenAndUpgradeNeeded):
(WebKit::WebIDBConnectionToClient::didFireVersionChangeEvent):
* DatabaseProcess/IndexedDB/WebIDBConnectionToClient.h:
* DatabaseProcess/IndexedDB/WebIDBConnectionToClient.messages.in:

2016-02-18 ChangSeok Oh <changseok.oh@collabora.com>

[GTK][Threaded Compositor] The web inspector doesn't work when using the threaded compositor
@@ -115,6 +115,14 @@ void DatabaseProcess::removeLegacyUniqueIDBDatabase(const LegacyUniqueIDBDatabas

m_idbDatabases.remove(identifier);
}

IDBServer::IDBServer& DatabaseProcess::idbServer()
{
if (!m_idbServer)
m_idbServer = IDBServer::IDBServer::create(indexedDatabaseDirectory());

return *m_idbServer;
}
#endif

void DatabaseProcess::initializeDatabaseProcess(const DatabaseProcessCreationParameters& parameters)
@@ -29,7 +29,10 @@
#if ENABLE(DATABASE_PROCESS)

#include "ChildProcess.h"
#include "LegacyUniqueIDBDatabase.h"
#include "LegacyUniqueIDBDatabaseIdentifier.h"
#include <WebCore/IDBServer.h>
#include <WebCore/UniqueIDBDatabase.h>
#include <wtf/NeverDestroyed.h>

namespace WebCore {
@@ -41,7 +44,6 @@ struct SecurityOriginData;
namespace WebKit {

class DatabaseToWebProcessConnection;
class LegacyUniqueIDBDatabase;

struct DatabaseProcessCreationParameters;

@@ -60,6 +62,8 @@ class DatabaseProcess : public ChildProcess {

void ensureIndexedDatabaseRelativePathExists(const String&);
String absoluteIndexedDatabasePathFromDatabaseRelativePath(const String&);

WebCore::IDBServer::IDBServer& idbServer();
#endif

WorkQueue& queue() { return m_queue.get(); }
@@ -110,6 +114,8 @@ class DatabaseProcess : public ChildProcess {
String m_indexedDatabaseDirectory;

HashMap<LegacyUniqueIDBDatabaseIdentifier, RefPtr<LegacyUniqueIDBDatabase>> m_idbDatabases;

RefPtr<WebCore::IDBServer::IDBServer> m_idbServer;
#endif

Deque<std::unique_ptr<WebCore::CrossThreadTask>> m_databaseTasks;
@@ -31,6 +31,7 @@
#include "DatabaseToWebProcessConnectionMessages.h"
#include "Logging.h"
#include "WebIDBConnectionToClient.h"
#include "WebIDBConnectionToClientMessages.h"
#include <wtf/RunLoop.h>

#if ENABLE(DATABASE_PROCESS)
@@ -62,6 +63,13 @@ void DatabaseToWebProcessConnection::didReceiveMessage(IPC::Connection& connecti
}

#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;
}

if (decoder.messageReceiverName() == Messages::DatabaseProcessIDBConnection::messageReceiverName()) {
IDBConnectionMap::iterator backendIterator = m_idbConnections.find(decoder.destinationID());
if (backendIterator != m_idbConnections.end())
@@ -32,8 +32,8 @@
#include "DatabaseProcess.h"
#include "DatabaseToWebProcessConnection.h"
#include "IDBIdentifier.h"
#include "Logging.h"
#include "LegacyUniqueIDBDatabase.h"
#include "Logging.h"
#include "WebCoreArgumentCoders.h"
#include "WebIDBServerConnectionMessages.h"
#include <WebCore/IDBDatabaseMetadata.h>
@@ -31,6 +31,7 @@
#if ENABLE(INDEXED_DATABASE) && ENABLE(DATABASE_PROCESS)

#include "DatabaseProcessIDBConnectionMessages.h"
#include "LegacyUniqueIDBDatabase.h"
#include "LegacyUniqueIDBDatabaseIdentifier.h"
#include <WebCore/SecurityOriginData.h>
#include <wtf/text/WTFString.h>
@@ -43,7 +44,6 @@ struct IDBKeyRangeData;
namespace WebKit {

class DatabaseToWebProcessConnection;
class LegacyUniqueIDBDatabase;

class DatabaseProcessIDBConnection : public RefCounted<DatabaseProcessIDBConnection>, public IPC::MessageSender {
public:
@@ -28,10 +28,13 @@

#if ENABLE(INDEXED_DATABASE)

#include "DataReference.h"
#include "DatabaseProcess.h"
#include "WebCoreArgumentCoders.h"
#include "WebIDBConnectionToServerMessages.h"
#include <WebCore/IDBError.h>
#include <WebCore/IDBResultData.h>
#include <WebCore/ThreadSafeDataBuffer.h>
#include <WebCore/UniqueIDBDatabaseConnection.h>

using namespace WebCore;
@@ -158,84 +161,115 @@ void WebIDBConnectionToClient::notifyOpenDBRequestBlocked(const WebCore::IDBReso
send(Messages::WebIDBConnectionToServer::NotifyOpenDBRequestBlocked(requestIdentifier, oldVersion, newVersion));
}

void WebIDBConnectionToClient::deleteDatabase(const IDBRequestData&)
void WebIDBConnectionToClient::deleteDatabase(const IDBRequestData& request)
{
DatabaseProcess::singleton().idbServer().deleteDatabase(request);
}

void WebIDBConnectionToClient::openDatabase(const IDBRequestData&)
void WebIDBConnectionToClient::openDatabase(const IDBRequestData& request)
{
DatabaseProcess::singleton().idbServer().openDatabase(request);
}

void WebIDBConnectionToClient::abortTransaction(const IDBResourceIdentifier&)
void WebIDBConnectionToClient::abortTransaction(const IDBResourceIdentifier& transactionIdentifier)
{
DatabaseProcess::singleton().idbServer().abortTransaction(transactionIdentifier);
}

void WebIDBConnectionToClient::commitTransaction(const IDBResourceIdentifier&)
void WebIDBConnectionToClient::commitTransaction(const IDBResourceIdentifier& transactionIdentifier)
{
DatabaseProcess::singleton().idbServer().commitTransaction(transactionIdentifier);
}

void WebIDBConnectionToClient::didFinishHandlingVersionChangeTransaction(const IDBResourceIdentifier&)
void WebIDBConnectionToClient::didFinishHandlingVersionChangeTransaction(const IDBResourceIdentifier& transactionIdentifier)
{
DatabaseProcess::singleton().idbServer().didFinishHandlingVersionChangeTransaction(transactionIdentifier);
}

void WebIDBConnectionToClient::createObjectStore(const IDBRequestData&, const IDBObjectStoreInfo&)
void WebIDBConnectionToClient::createObjectStore(const IDBRequestData& request, const IDBObjectStoreInfo& info)
{
DatabaseProcess::singleton().idbServer().createObjectStore(request, info);
}

void WebIDBConnectionToClient::deleteObjectStore(const IDBRequestData&, const String&)
void WebIDBConnectionToClient::deleteObjectStore(const IDBRequestData& request, const String& name)
{
DatabaseProcess::singleton().idbServer().deleteObjectStore(request, name);
}

void WebIDBConnectionToClient::clearObjectStore(const IDBRequestData&, uint64_t)
void WebIDBConnectionToClient::clearObjectStore(const IDBRequestData& request, uint64_t objectStoreIdentifier)
{
DatabaseProcess::singleton().idbServer().clearObjectStore(request, objectStoreIdentifier);
}

void WebIDBConnectionToClient::createIndex(const IDBRequestData&, const IDBIndexInfo&)
void WebIDBConnectionToClient::createIndex(const IDBRequestData& request, const IDBIndexInfo& info)
{
DatabaseProcess::singleton().idbServer().createIndex(request, info);
}

void WebIDBConnectionToClient::deleteIndex(const IDBRequestData&, uint64_t, const String&)
void WebIDBConnectionToClient::deleteIndex(const IDBRequestData& request, uint64_t objectStoreIdentifier, const String& name)
{
DatabaseProcess::singleton().idbServer().deleteIndex(request, objectStoreIdentifier, name);
}

void WebIDBConnectionToClient::putOrAdd(const IDBRequestData&, const IDBKeyData&, const IPC::DataReference&, bool)
void WebIDBConnectionToClient::putOrAdd(const IDBRequestData& request, const IDBKeyData& key, const IPC::DataReference& data, 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);
auto buffer = ThreadSafeDataBuffer::copyVector(data.vector());

DatabaseProcess::singleton().idbServer().putOrAdd(request, key, buffer, mode);
}

void WebIDBConnectionToClient::getRecord(const IDBRequestData&, const IDBKeyRangeData&)
void WebIDBConnectionToClient::getRecord(const IDBRequestData& request, const IDBKeyRangeData& range)
{
DatabaseProcess::singleton().idbServer().getRecord(request, range);
}

void WebIDBConnectionToClient::getCount(const IDBRequestData&, const IDBKeyRangeData&)
void WebIDBConnectionToClient::getCount(const IDBRequestData& request, const IDBKeyRangeData& range)
{
DatabaseProcess::singleton().idbServer().getCount(request, range);
}

void WebIDBConnectionToClient::deleteRecord(const IDBRequestData&, const IDBKeyRangeData&)
void WebIDBConnectionToClient::deleteRecord(const IDBRequestData& request, const IDBKeyRangeData& range)
{
DatabaseProcess::singleton().idbServer().deleteRecord(request, range);
}

void WebIDBConnectionToClient::openCursor(const IDBRequestData&, const IDBCursorInfo&)
void WebIDBConnectionToClient::openCursor(const IDBRequestData& request, const IDBCursorInfo& info)
{
DatabaseProcess::singleton().idbServer().openCursor(request, info);
}

void WebIDBConnectionToClient::iterateCursor(const IDBRequestData&, const IDBKeyData&, unsigned long)
void WebIDBConnectionToClient::iterateCursor(const IDBRequestData& request, const IDBKeyData& key, unsigned long count)
{
DatabaseProcess::singleton().idbServer().iterateCursor(request, key, count);
}

void WebIDBConnectionToClient::establishTransaction(uint64_t, const IDBTransactionInfo&)
void WebIDBConnectionToClient::establishTransaction(uint64_t databaseConnectionIdentifier, const IDBTransactionInfo& info)
{
DatabaseProcess::singleton().idbServer().establishTransaction(databaseConnectionIdentifier, info);
}

void WebIDBConnectionToClient::databaseConnectionClosed(uint64_t)
void WebIDBConnectionToClient::databaseConnectionClosed(uint64_t databaseConnectionIdentifier)
{
DatabaseProcess::singleton().idbServer().databaseConnectionClosed(databaseConnectionIdentifier);
}

void WebIDBConnectionToClient::abortOpenAndUpgradeNeeded(uint64_t, const IDBResourceIdentifier&)
void WebIDBConnectionToClient::abortOpenAndUpgradeNeeded(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& transactionIdentifier)
{
DatabaseProcess::singleton().idbServer().abortOpenAndUpgradeNeeded(databaseConnectionIdentifier, transactionIdentifier);
}

void WebIDBConnectionToClient::didFireVersionChangeEvent(uint64_t, const IDBResourceIdentifier&)
void WebIDBConnectionToClient::didFireVersionChangeEvent(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& transactionIdentifier)
{
DatabaseProcess::singleton().idbServer().didFireVersionChangeEvent(databaseConnectionIdentifier, transactionIdentifier);
}

} // namespace WebKit

0 comments on commit be30f5e

Please sign in to comment.