Modern IDB: Implement server->client operations in WK2.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Feb 2016 22:42:54 +0000 (22:42 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Feb 2016 22:42:54 +0000 (22:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=154411

Reviewed by Alex Christensen.

No change in behavior yet; Just laying the groundwork.
Source/WebCore:

* Modules/indexeddb/client/IDBConnectionToServer.h:
* Modules/indexeddb/server/IDBServer.h:
* Modules/indexeddb/shared/IDBTransactionInfo.h:
(WebCore::IDBTransactionInfo::encode):
(WebCore::IDBTransactionInfo::decode):

Source/WebKit2:

* DatabaseProcess/IndexedDB/WebIDBConnectionToClient.cpp:
(WebKit::WebIDBConnectionToClient::WebIDBConnectionToClient):
(WebKit::WebIDBConnectionToClient::~WebIDBConnectionToClient):

* WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.cpp:
(WebKit::WebIDBConnectionToServer::didDeleteDatabase):
(WebKit::WebIDBConnectionToServer::didOpenDatabase):
(WebKit::WebIDBConnectionToServer::didAbortTransaction):
(WebKit::WebIDBConnectionToServer::didCommitTransaction):
(WebKit::WebIDBConnectionToServer::didCreateObjectStore):
(WebKit::WebIDBConnectionToServer::didDeleteObjectStore):
(WebKit::WebIDBConnectionToServer::didClearObjectStore):
(WebKit::WebIDBConnectionToServer::didCreateIndex):
(WebKit::WebIDBConnectionToServer::didDeleteIndex):
(WebKit::WebIDBConnectionToServer::didPutOrAdd):
(WebKit::WebIDBConnectionToServer::didGetRecord):
(WebKit::WebIDBConnectionToServer::didGetCount):
(WebKit::WebIDBConnectionToServer::didDeleteRecord):
(WebKit::WebIDBConnectionToServer::didOpenCursor):
(WebKit::WebIDBConnectionToServer::didIterateCursor):
(WebKit::WebIDBConnectionToServer::fireVersionChangeEvent):
(WebKit::WebIDBConnectionToServer::didStartTransaction):
(WebKit::WebIDBConnectionToServer::notifyOpenDBRequestBlocked):
* WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.h:

* WebProcess/Databases/WebToDatabaseProcessConnection.cpp:
(WebKit::WebToDatabaseProcessConnection::didReceiveMessage):

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

Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.h
Source/WebCore/Modules/indexeddb/server/IDBServer.h
Source/WebCore/Modules/indexeddb/shared/IDBTransactionInfo.h
Source/WebKit2/ChangeLog
Source/WebKit2/DatabaseProcess/IndexedDB/WebIDBConnectionToClient.cpp
Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.cpp
Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.h
Source/WebKit2/WebProcess/Databases/WebToDatabaseProcessConnection.cpp

index aa81241..de0156e 100644 (file)
@@ -1,3 +1,18 @@
+2016-02-18  Brady Eidson  <beidson@apple.com>
+
+        Modern IDB: Implement server->client operations in WK2.
+        https://bugs.webkit.org/show_bug.cgi?id=154411
+
+        Reviewed by Alex Christensen.
+
+        No change in behavior yet; Just laying the groundwork.
+    
+        * Modules/indexeddb/client/IDBConnectionToServer.h:
+        * Modules/indexeddb/server/IDBServer.h:
+        * Modules/indexeddb/shared/IDBTransactionInfo.h:
+        (WebCore::IDBTransactionInfo::encode):
+        (WebCore::IDBTransactionInfo::decode):
+
 2016-02-18  Csaba Osztrogon√°c  <ossy@webkit.org>
 
         Fix unused-const-variable warning on non Cocoa platforms
index a6588ce..9229bd5 100644 (file)
@@ -57,57 +57,57 @@ public:
     uint64_t identifier() const;
 
     void deleteDatabase(IDBOpenDBRequest&);
-    void didDeleteDatabase(const IDBResultData&);
+    WEBCORE_EXPORT void didDeleteDatabase(const IDBResultData&);
 
     void openDatabase(IDBOpenDBRequest&);
-    void didOpenDatabase(const IDBResultData&);
+    WEBCORE_EXPORT void didOpenDatabase(const IDBResultData&);
 
     void createObjectStore(TransactionOperation&, const IDBObjectStoreInfo&);
-    void didCreateObjectStore(const IDBResultData&);
+    WEBCORE_EXPORT void didCreateObjectStore(const IDBResultData&);
 
     void deleteObjectStore(TransactionOperation&, const String& objectStoreName);
-    void didDeleteObjectStore(const IDBResultData&);
+    WEBCORE_EXPORT void didDeleteObjectStore(const IDBResultData&);
 
     void clearObjectStore(TransactionOperation&, uint64_t objectStoreIdentifier);
-    void didClearObjectStore(const IDBResultData&);
+    WEBCORE_EXPORT void didClearObjectStore(const IDBResultData&);
 
     void createIndex(TransactionOperation&, const IDBIndexInfo&);
-    void didCreateIndex(const IDBResultData&);
+    WEBCORE_EXPORT void didCreateIndex(const IDBResultData&);
 
     void deleteIndex(TransactionOperation&, uint64_t objectStoreIdentifier, const String& indexName);
-    void didDeleteIndex(const IDBResultData&);
+    WEBCORE_EXPORT void didDeleteIndex(const IDBResultData&);
 
     void putOrAdd(TransactionOperation&, RefPtr<IDBKey>&, RefPtr<SerializedScriptValue>&, const IndexedDB::ObjectStoreOverwriteMode);
-    void didPutOrAdd(const IDBResultData&);
+    WEBCORE_EXPORT void didPutOrAdd(const IDBResultData&);
 
     void getRecord(TransactionOperation&, const IDBKeyRangeData&);
-    void didGetRecord(const IDBResultData&);
+    WEBCORE_EXPORT void didGetRecord(const IDBResultData&);
 
     void getCount(TransactionOperation&, const IDBKeyRangeData&);
-    void didGetCount(const IDBResultData&);
+    WEBCORE_EXPORT void didGetCount(const IDBResultData&);
 
     void deleteRecord(TransactionOperation&, const IDBKeyRangeData&);
-    void didDeleteRecord(const IDBResultData&);
+    WEBCORE_EXPORT void didDeleteRecord(const IDBResultData&);
 
     void openCursor(TransactionOperation&, const IDBCursorInfo&);
-    void didOpenCursor(const IDBResultData&);
+    WEBCORE_EXPORT void didOpenCursor(const IDBResultData&);
 
     void iterateCursor(TransactionOperation&, const IDBKeyData&, unsigned long count);
-    void didIterateCursor(const IDBResultData&);
+    WEBCORE_EXPORT void didIterateCursor(const IDBResultData&);
 
     void commitTransaction(IDBTransaction&);
-    void didCommitTransaction(const IDBResourceIdentifier& transactionIdentifier, const IDBError&);
+    WEBCORE_EXPORT void didCommitTransaction(const IDBResourceIdentifier& transactionIdentifier, const IDBError&);
 
     void didFinishHandlingVersionChangeTransaction(IDBTransaction&);
 
     void abortTransaction(IDBTransaction&);
-    void didAbortTransaction(const IDBResourceIdentifier& transactionIdentifier, const IDBError&);
+    WEBCORE_EXPORT void didAbortTransaction(const IDBResourceIdentifier& transactionIdentifier, const IDBError&);
 
-    void fireVersionChangeEvent(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& requestIdentifier, uint64_t requestedVersion);
+    WEBCORE_EXPORT void fireVersionChangeEvent(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& requestIdentifier, uint64_t requestedVersion);
     void didFireVersionChangeEvent(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& requestIdentifier);
 
-    void didStartTransaction(const IDBResourceIdentifier& transactionIdentifier, const IDBError&);
-    void notifyOpenDBRequestBlocked(const IDBResourceIdentifier& requestIdentifier, uint64_t oldVersion, uint64_t newVersion);
+    WEBCORE_EXPORT void didStartTransaction(const IDBResourceIdentifier& transactionIdentifier, const IDBError&);
+    WEBCORE_EXPORT void notifyOpenDBRequestBlocked(const IDBResourceIdentifier& requestIdentifier, uint64_t oldVersion, uint64_t newVersion);
 
     void establishTransaction(IDBTransaction&);
 
index 25283ca..5d81241 100644 (file)
@@ -53,8 +53,8 @@ public:
     static Ref<IDBServer> create();
     WEBCORE_EXPORT static Ref<IDBServer> create(const String& databaseDirectoryPath);
 
-    void registerConnection(IDBConnectionToClient&);
-    void unregisterConnection(IDBConnectionToClient&);
+    WEBCORE_EXPORT void registerConnection(IDBConnectionToClient&);
+    WEBCORE_EXPORT void unregisterConnection(IDBConnectionToClient&);
 
     // Operations requested by the client.
     WEBCORE_EXPORT void openDatabase(const IDBRequestData&);
index 6dbb836..6ffc7b8 100644 (file)
@@ -85,6 +85,10 @@ void IDBTransactionInfo::encode(Encoder& encoder) const
 {
     encoder << m_identifier << m_newVersion << m_objectStores;
     encoder.encodeEnum(m_mode);
+
+    encoder << !!m_originalDatabaseInfo;
+    if (m_originalDatabaseInfo)
+        encoder << *m_originalDatabaseInfo;
 }
 
 template<class Decoder>
@@ -102,6 +106,17 @@ bool IDBTransactionInfo::decode(Decoder& decoder, IDBTransactionInfo& info)
     if (!decoder.decodeEnum(info.m_mode))
         return false;
 
+    bool hasObject;
+    if (!decoder.decode(hasObject))
+        return false;
+
+    if (hasObject) {
+        std::unique_ptr<IDBDatabaseInfo> object = std::make_unique<IDBDatabaseInfo>();
+        if (!decoder.decode(*object))
+            return false;
+        info.m_originalDatabaseInfo = WTFMove(object);
+    }
+
     return true;
 }
 
index 50e9ffd..586a102 100644 (file)
@@ -1,3 +1,40 @@
+2016-02-18  Brady Eidson  <beidson@apple.com>
+
+        Modern IDB: Implement server->client operations in WK2.
+        https://bugs.webkit.org/show_bug.cgi?id=154411
+
+        Reviewed by Alex Christensen.
+
+        No change in behavior yet; Just laying the groundwork.
+
+        * DatabaseProcess/IndexedDB/WebIDBConnectionToClient.cpp:
+        (WebKit::WebIDBConnectionToClient::WebIDBConnectionToClient):
+        (WebKit::WebIDBConnectionToClient::~WebIDBConnectionToClient):
+
+        * WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.cpp:
+        (WebKit::WebIDBConnectionToServer::didDeleteDatabase):
+        (WebKit::WebIDBConnectionToServer::didOpenDatabase):
+        (WebKit::WebIDBConnectionToServer::didAbortTransaction):
+        (WebKit::WebIDBConnectionToServer::didCommitTransaction):
+        (WebKit::WebIDBConnectionToServer::didCreateObjectStore):
+        (WebKit::WebIDBConnectionToServer::didDeleteObjectStore):
+        (WebKit::WebIDBConnectionToServer::didClearObjectStore):
+        (WebKit::WebIDBConnectionToServer::didCreateIndex):
+        (WebKit::WebIDBConnectionToServer::didDeleteIndex):
+        (WebKit::WebIDBConnectionToServer::didPutOrAdd):
+        (WebKit::WebIDBConnectionToServer::didGetRecord):
+        (WebKit::WebIDBConnectionToServer::didGetCount):
+        (WebKit::WebIDBConnectionToServer::didDeleteRecord):
+        (WebKit::WebIDBConnectionToServer::didOpenCursor):
+        (WebKit::WebIDBConnectionToServer::didIterateCursor):
+        (WebKit::WebIDBConnectionToServer::fireVersionChangeEvent):
+        (WebKit::WebIDBConnectionToServer::didStartTransaction):
+        (WebKit::WebIDBConnectionToServer::notifyOpenDBRequestBlocked):
+        * WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.h:
+        
+        * WebProcess/Databases/WebToDatabaseProcessConnection.cpp:
+        (WebKit::WebToDatabaseProcessConnection::didReceiveMessage):
+
 2016-02-18  Brian Burg  <bburg@apple.com>
 
         RemoteInspector deadlocks if _WKAutomationDelegate creates/registers a target synchronously
index 2ef6ef8..cc0735d 100644 (file)
@@ -48,13 +48,16 @@ Ref<WebIDBConnectionToClient> WebIDBConnectionToClient::create(DatabaseToWebProc
 
 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()
 {
+    DatabaseProcess::singleton().idbServer().unregisterConnection(*m_connectionToClient);
 }
 
 void WebIDBConnectionToClient::disconnectedFromWebProcess()
index 435cb5f..255aa2a 100644 (file)
@@ -189,76 +189,94 @@ void WebIDBConnectionToServer::didFireVersionChangeEvent(uint64_t databaseConnec
     send(Messages::WebIDBConnectionToClient::DidFireVersionChangeEvent(databaseConnectionIdentifier, requestIdentifier));
 }
 
-void WebIDBConnectionToServer::didDeleteDatabase(const IDBResultData&)
+void WebIDBConnectionToServer::didDeleteDatabase(const IDBResultData& result)
 {
+    m_connectionToServer->didDeleteDatabase(result);
 }
 
-void WebIDBConnectionToServer::didOpenDatabase(const IDBResultData&)
+void WebIDBConnectionToServer::didOpenDatabase(const IDBResultData& result)
 {
+    m_connectionToServer->didOpenDatabase(result);
 }
 
-void WebIDBConnectionToServer::didAbortTransaction(const IDBResourceIdentifier&, const IDBError&)
+void WebIDBConnectionToServer::didAbortTransaction(const IDBResourceIdentifier& transactionIdentifier, const IDBError& error)
 {
+    m_connectionToServer->didAbortTransaction(transactionIdentifier, error);
 }
 
-void WebIDBConnectionToServer::didCommitTransaction(const IDBResourceIdentifier&, const IDBError&)
+void WebIDBConnectionToServer::didCommitTransaction(const IDBResourceIdentifier& transactionIdentifier, const IDBError& error)
 {
+    m_connectionToServer->didCommitTransaction(transactionIdentifier, error);
 }
 
-void WebIDBConnectionToServer::didCreateObjectStore(const IDBResultData&)
+void WebIDBConnectionToServer::didCreateObjectStore(const IDBResultData& result)
 {
+    m_connectionToServer->didCreateObjectStore(result);
 }
 
-void WebIDBConnectionToServer::didDeleteObjectStore(const IDBResultData&)
+void WebIDBConnectionToServer::didDeleteObjectStore(const IDBResultData& result)
 {
+    m_connectionToServer->didDeleteObjectStore(result);
 }
 
-void WebIDBConnectionToServer::didClearObjectStore(const IDBResultData&)
+void WebIDBConnectionToServer::didClearObjectStore(const IDBResultData& result)
 {
+    m_connectionToServer->didClearObjectStore(result);
 }
 
-void WebIDBConnectionToServer::didCreateIndex(const IDBResultData&)
+void WebIDBConnectionToServer::didCreateIndex(const IDBResultData& result)
 {
+    m_connectionToServer->didCreateIndex(result);
 }
 
-void WebIDBConnectionToServer::didDeleteIndex(const IDBResultData&)
+void WebIDBConnectionToServer::didDeleteIndex(const IDBResultData& result)
 {
+    m_connectionToServer->didDeleteIndex(result);
 }
 
-void WebIDBConnectionToServer::didPutOrAdd(const IDBResultData&)
+void WebIDBConnectionToServer::didPutOrAdd(const IDBResultData& result)
 {
+    m_connectionToServer->didPutOrAdd(result);
 }
 
-void WebIDBConnectionToServer::didGetRecord(const IDBResultData&)
+void WebIDBConnectionToServer::didGetRecord(const IDBResultData& result)
 {
+    m_connectionToServer->didGetRecord(result);
 }
 
-void WebIDBConnectionToServer::didGetCount(const IDBResultData&)
+void WebIDBConnectionToServer::didGetCount(const IDBResultData& result)
 {
+    m_connectionToServer->didGetCount(result);
 }
 
-void WebIDBConnectionToServer::didDeleteRecord(const IDBResultData&)
+void WebIDBConnectionToServer::didDeleteRecord(const IDBResultData& result)
 {
+    m_connectionToServer->didDeleteRecord(result);
 }
 
-void WebIDBConnectionToServer::didOpenCursor(const IDBResultData&)
+void WebIDBConnectionToServer::didOpenCursor(const IDBResultData& result)
 {
+    m_connectionToServer->didOpenCursor(result);
 }
 
-void WebIDBConnectionToServer::didIterateCursor(const IDBResultData&)
+void WebIDBConnectionToServer::didIterateCursor(const IDBResultData& result)
 {
+    m_connectionToServer->didIterateCursor(result);
 }
 
-void WebIDBConnectionToServer::fireVersionChangeEvent(uint64_t, const WebCore::IDBResourceIdentifier&, uint64_t)
+void WebIDBConnectionToServer::fireVersionChangeEvent(uint64_t uniqueDatabaseConnectionIdentifier, const IDBResourceIdentifier& requestIdentifier, uint64_t requestedVersion)
 {
+    m_connectionToServer->fireVersionChangeEvent(uniqueDatabaseConnectionIdentifier, requestIdentifier, requestedVersion);
 }
 
-void WebIDBConnectionToServer::didStartTransaction(const WebCore::IDBResourceIdentifier&, const WebCore::IDBError&)
+void WebIDBConnectionToServer::didStartTransaction(const IDBResourceIdentifier& transactionIdentifier, const WebCore::IDBError& error)
 {
+    m_connectionToServer->didStartTransaction(transactionIdentifier, error);
 }
 
-void WebIDBConnectionToServer::notifyOpenDBRequestBlocked(const WebCore::IDBResourceIdentifier&, uint64_t, uint64_t)
+void WebIDBConnectionToServer::notifyOpenDBRequestBlocked(const IDBResourceIdentifier& requestIdentifier, uint64_t oldVersion, uint64_t newVersion)
 {
+    m_connectionToServer->notifyOpenDBRequestBlocked(requestIdentifier, oldVersion, newVersion);
 }
 
 } // namespace WebKit
index 0bbda33..35d4e80 100644 (file)
@@ -88,11 +88,12 @@ public:
     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;
-    void didReceiveMessage(IPC::Connection&, IPC::MessageDecoder&);
 
     uint64_t m_identifier;
     bool m_isOpenInServer { false };
index baa4f0e..5eeb371 100644 (file)
@@ -28,6 +28,7 @@
 #include "WebToDatabaseProcessConnection.h"
 
 #include "DatabaseToWebProcessConnectionMessages.h"
+#include "WebIDBConnectionToServerMessages.h"
 #include "WebIDBServerConnection.h"
 #include "WebIDBServerConnectionMessages.h"
 #include "WebProcess.h"
@@ -52,6 +53,13 @@ WebToDatabaseProcessConnection::~WebToDatabaseProcessConnection()
 void WebToDatabaseProcessConnection::didReceiveMessage(IPC::Connection& connection, IPC::MessageDecoder& decoder)
 {
 #if ENABLE(INDEXED_DATABASE)
+    if (decoder.messageReceiverName() == Messages::WebIDBConnectionToServer::messageReceiverName()) {
+        auto iterator = m_webIDBConnections.find(decoder.destinationID());
+        if (iterator != m_webIDBConnections.end())
+            iterator->value->didReceiveMessage(connection, decoder);
+        return;
+    }
+
     if (decoder.messageReceiverName() == Messages::WebIDBServerConnection::messageReceiverName()) {
         HashMap<uint64_t, WebIDBServerConnection*>::iterator connectionIterator = m_webIDBServerConnections.find(decoder.destinationID());
         if (connectionIterator != m_webIDBServerConnections.end())