WebIDBConnectionToClient does not need to be RefCounted or a SessionID
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 22 Sep 2019 05:16:23 +0000 (05:16 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 22 Sep 2019 05:16:23 +0000 (05:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=202089

Reviewed by Alex Christensen.

Source/WebCore:

Drop some dead code.

* Modules/indexeddb/server/IDBConnectionToClientDelegate.h:

Source/WebKit:

WebIDBConnectionToClient does not need to be RefCounted, the ref() / deref() virtual function
it implemented from its interface were dead code. We now stop subclassing RefCounted and have
the NetworkConnectionToWebProcess fully own the WebIDBConnectionToClient. Instead of the
WebIDBConnectionToClient having 3 data members for the NetworkProcess, the sessionID and the IPC
connection, use a single data member to its NetworkConnectionToWebProcess parent. It can get
everything it needs from its parent.

* NetworkProcess/IndexedDB/WebIDBConnectionToClient.cpp:
(WebKit::WebIDBConnectionToClient::WebIDBConnectionToClient):
(WebKit::WebIDBConnectionToClient::idbServer):
(WebKit::WebIDBConnectionToClient::disconnectedFromWebProcess):
(WebKit::WebIDBConnectionToClient::messageSenderConnection const):
(WebKit::WebIDBConnectionToClient::connectionToClient):
(WebKit::WebIDBConnectionToClient::deleteDatabase):
(WebKit::WebIDBConnectionToClient::openDatabase):
(WebKit::WebIDBConnectionToClient::abortTransaction):
(WebKit::WebIDBConnectionToClient::commitTransaction):
(WebKit::WebIDBConnectionToClient::didFinishHandlingVersionChangeTransaction):
(WebKit::WebIDBConnectionToClient::createObjectStore):
(WebKit::WebIDBConnectionToClient::deleteObjectStore):
(WebKit::WebIDBConnectionToClient::renameObjectStore):
(WebKit::WebIDBConnectionToClient::clearObjectStore):
(WebKit::WebIDBConnectionToClient::createIndex):
(WebKit::WebIDBConnectionToClient::deleteIndex):
(WebKit::WebIDBConnectionToClient::renameIndex):
(WebKit::WebIDBConnectionToClient::putOrAdd):
(WebKit::WebIDBConnectionToClient::getRecord):
(WebKit::WebIDBConnectionToClient::getAllRecords):
(WebKit::WebIDBConnectionToClient::getCount):
(WebKit::WebIDBConnectionToClient::deleteRecord):
(WebKit::WebIDBConnectionToClient::openCursor):
(WebKit::WebIDBConnectionToClient::iterateCursor):
(WebKit::WebIDBConnectionToClient::establishTransaction):
(WebKit::WebIDBConnectionToClient::databaseConnectionPendingClose):
(WebKit::WebIDBConnectionToClient::databaseConnectionClosed):
(WebKit::WebIDBConnectionToClient::abortOpenAndUpgradeNeeded):
(WebKit::WebIDBConnectionToClient::didFireVersionChangeEvent):
(WebKit::WebIDBConnectionToClient::openDBRequestCancelled):
(WebKit::WebIDBConnectionToClient::confirmDidCloseFromServer):
(WebKit::WebIDBConnectionToClient::getAllDatabaseNames):
* NetworkProcess/IndexedDB/WebIDBConnectionToClient.h:
* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::establishIDBConnectionToServer):
* NetworkProcess/NetworkConnectionToWebProcess.h:

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

Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/server/IDBConnectionToClientDelegate.h
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/IndexedDB/WebIDBConnectionToClient.cpp
Source/WebKit/NetworkProcess/IndexedDB/WebIDBConnectionToClient.h
Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp
Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h

index ad8e6ae..70c54d5 100644 (file)
@@ -1,5 +1,16 @@
 2019-09-21  Chris Dumez  <cdumez@apple.com>
 
+        WebIDBConnectionToClient does not need to be RefCounted or a SessionID
+        https://bugs.webkit.org/show_bug.cgi?id=202089
+
+        Reviewed by Alex Christensen.
+
+        Drop some dead code.
+
+        * Modules/indexeddb/server/IDBConnectionToClientDelegate.h:
+
+2019-09-21  Chris Dumez  <cdumez@apple.com>
+
         [CURL] CurlRequest does not need a sessionID
         https://bugs.webkit.org/show_bug.cgi?id=202086
 
index 83c6fca..2702ea2 100644 (file)
@@ -72,9 +72,6 @@ public:
     virtual void notifyOpenDBRequestBlocked(const IDBResourceIdentifier& requestIdentifier, uint64_t oldVersion, uint64_t newVersion) = 0;
 
     virtual void didGetAllDatabaseNames(uint64_t callbackID, const Vector<String>& databaseNames) = 0;
-
-    virtual void ref() = 0;
-    virtual void deref() = 0;
 };
 
 } // namespace IDBServer
index 02ef9bc..32ea721 100644 (file)
@@ -1,5 +1,57 @@
 2019-09-21  Chris Dumez  <cdumez@apple.com>
 
+        WebIDBConnectionToClient does not need to be RefCounted or a SessionID
+        https://bugs.webkit.org/show_bug.cgi?id=202089
+
+        Reviewed by Alex Christensen.
+
+        WebIDBConnectionToClient does not need to be RefCounted, the ref() / deref() virtual function
+        it implemented from its interface were dead code. We now stop subclassing RefCounted and have
+        the NetworkConnectionToWebProcess fully own the WebIDBConnectionToClient. Instead of the
+        WebIDBConnectionToClient having 3 data members for the NetworkProcess, the sessionID and the IPC
+        connection, use a single data member to its NetworkConnectionToWebProcess parent. It can get
+        everything it needs from its parent.
+
+        * NetworkProcess/IndexedDB/WebIDBConnectionToClient.cpp:
+        (WebKit::WebIDBConnectionToClient::WebIDBConnectionToClient):
+        (WebKit::WebIDBConnectionToClient::idbServer):
+        (WebKit::WebIDBConnectionToClient::disconnectedFromWebProcess):
+        (WebKit::WebIDBConnectionToClient::messageSenderConnection const):
+        (WebKit::WebIDBConnectionToClient::connectionToClient):
+        (WebKit::WebIDBConnectionToClient::deleteDatabase):
+        (WebKit::WebIDBConnectionToClient::openDatabase):
+        (WebKit::WebIDBConnectionToClient::abortTransaction):
+        (WebKit::WebIDBConnectionToClient::commitTransaction):
+        (WebKit::WebIDBConnectionToClient::didFinishHandlingVersionChangeTransaction):
+        (WebKit::WebIDBConnectionToClient::createObjectStore):
+        (WebKit::WebIDBConnectionToClient::deleteObjectStore):
+        (WebKit::WebIDBConnectionToClient::renameObjectStore):
+        (WebKit::WebIDBConnectionToClient::clearObjectStore):
+        (WebKit::WebIDBConnectionToClient::createIndex):
+        (WebKit::WebIDBConnectionToClient::deleteIndex):
+        (WebKit::WebIDBConnectionToClient::renameIndex):
+        (WebKit::WebIDBConnectionToClient::putOrAdd):
+        (WebKit::WebIDBConnectionToClient::getRecord):
+        (WebKit::WebIDBConnectionToClient::getAllRecords):
+        (WebKit::WebIDBConnectionToClient::getCount):
+        (WebKit::WebIDBConnectionToClient::deleteRecord):
+        (WebKit::WebIDBConnectionToClient::openCursor):
+        (WebKit::WebIDBConnectionToClient::iterateCursor):
+        (WebKit::WebIDBConnectionToClient::establishTransaction):
+        (WebKit::WebIDBConnectionToClient::databaseConnectionPendingClose):
+        (WebKit::WebIDBConnectionToClient::databaseConnectionClosed):
+        (WebKit::WebIDBConnectionToClient::abortOpenAndUpgradeNeeded):
+        (WebKit::WebIDBConnectionToClient::didFireVersionChangeEvent):
+        (WebKit::WebIDBConnectionToClient::openDBRequestCancelled):
+        (WebKit::WebIDBConnectionToClient::confirmDidCloseFromServer):
+        (WebKit::WebIDBConnectionToClient::getAllDatabaseNames):
+        * NetworkProcess/IndexedDB/WebIDBConnectionToClient.h:
+        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+        (WebKit::NetworkConnectionToWebProcess::establishIDBConnectionToServer):
+        * NetworkProcess/NetworkConnectionToWebProcess.h:
+
+2019-09-21  Chris Dumez  <cdumez@apple.com>
+
         Regression(iOS 13) web views do not deal properly with their window's UIScene changing
         https://bugs.webkit.org/show_bug.cgi?id=202070
         <rdar://problem/55580699>
index 46692fe..0c812df 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 namespace WebKit {
 using namespace WebCore;
 
-Ref<WebIDBConnectionToClient> WebIDBConnectionToClient::create(NetworkProcess& networkProcess, IPC::Connection& connection, ProcessIdentifier serverConnectionIdentifier, PAL::SessionID sessionID)
-{
-    return adoptRef(*new WebIDBConnectionToClient(networkProcess, connection, serverConnectionIdentifier, sessionID));
-}
-
-WebIDBConnectionToClient::WebIDBConnectionToClient(NetworkProcess& networkProcess, IPC::Connection& connection, ProcessIdentifier serverConnectionIdentifier, PAL::SessionID sessionID)
+WebIDBConnectionToClient::WebIDBConnectionToClient(NetworkConnectionToWebProcess& connection, WebCore::IDBConnectionIdentifier serverConnectionIdentifier)
     : m_connection(connection)
-    , m_networkProcess(networkProcess)
     , m_identifier(serverConnectionIdentifier)
-    , m_sessionID(sessionID)
+    , m_connectionToClient(IDBServer::IDBConnectionToClient::create(*this))
 {
-    relaxAdoptionRequirement();
-    m_connectionToClient = IDBServer::IDBConnectionToClient::create(*this);
-    networkProcess.idbServer(m_sessionID).registerConnection(*m_connectionToClient);
+    idbServer().registerConnection(m_connectionToClient);
 }
 
 WebIDBConnectionToClient::~WebIDBConnectionToClient()
 {
 }
 
+IDBServer::IDBServer& WebIDBConnectionToClient::idbServer()
+{
+    return m_connection.networkProcess().idbServer(m_connection.sessionID());
+}
+
 void WebIDBConnectionToClient::disconnectedFromWebProcess()
 {
-    m_networkProcess->idbServer(m_sessionID).unregisterConnection(*m_connectionToClient);
+    idbServer().unregisterConnection(m_connectionToClient);
 }
 
 IPC::Connection* WebIDBConnectionToClient::messageSenderConnection() const
 {
-    return m_connection.ptr();
+    return &m_connection.connection();
 }
 
 WebCore::IDBServer::IDBConnectionToClient& WebIDBConnectionToClient::connectionToClient()
 {
-    return *m_connectionToClient;
+    return m_connectionToClient;
 }
 
 void WebIDBConnectionToClient::didDeleteDatabase(const WebCore::IDBResultData& resultData)
@@ -217,137 +214,137 @@ void WebIDBConnectionToClient::didGetAllDatabaseNames(uint64_t callbackID, const
 
 void WebIDBConnectionToClient::deleteDatabase(const IDBRequestData& request)
 {
-    m_networkProcess->idbServer(m_sessionID).deleteDatabase(request);
+    idbServer().deleteDatabase(request);
 }
 
 void WebIDBConnectionToClient::openDatabase(const IDBRequestData& request)
 {
-    m_networkProcess->idbServer(m_sessionID).openDatabase(request);
+    idbServer().openDatabase(request);
 }
 
 void WebIDBConnectionToClient::abortTransaction(const IDBResourceIdentifier& transactionIdentifier)
 {
-    m_networkProcess->idbServer(m_sessionID).abortTransaction(transactionIdentifier);
+    idbServer().abortTransaction(transactionIdentifier);
 }
 
 void WebIDBConnectionToClient::commitTransaction(const IDBResourceIdentifier& transactionIdentifier)
 {
-    m_networkProcess->idbServer(m_sessionID).commitTransaction(transactionIdentifier);
+    idbServer().commitTransaction(transactionIdentifier);
 }
 
 void WebIDBConnectionToClient::didFinishHandlingVersionChangeTransaction(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& transactionIdentifier)
 {
-    m_networkProcess->idbServer(m_sessionID).didFinishHandlingVersionChangeTransaction(databaseConnectionIdentifier, transactionIdentifier);
+    idbServer().didFinishHandlingVersionChangeTransaction(databaseConnectionIdentifier, transactionIdentifier);
 }
 
 void WebIDBConnectionToClient::createObjectStore(const IDBRequestData& request, const IDBObjectStoreInfo& info)
 {
-    m_networkProcess->idbServer(m_sessionID).createObjectStore(request, info);
+    idbServer().createObjectStore(request, info);
 }
 
 void WebIDBConnectionToClient::deleteObjectStore(const IDBRequestData& request, const String& name)
 {
-    m_networkProcess->idbServer(m_sessionID).deleteObjectStore(request, name);
+    idbServer().deleteObjectStore(request, name);
 }
 
 void WebIDBConnectionToClient::renameObjectStore(const IDBRequestData& request, uint64_t objectStoreIdentifier, const String& newName)
 {
-    m_networkProcess->idbServer(m_sessionID).renameObjectStore(request, objectStoreIdentifier, newName);
+    idbServer().renameObjectStore(request, objectStoreIdentifier, newName);
 }
 
 void WebIDBConnectionToClient::clearObjectStore(const IDBRequestData& request, uint64_t objectStoreIdentifier)
 {
-    m_networkProcess->idbServer(m_sessionID).clearObjectStore(request, objectStoreIdentifier);
+    idbServer().clearObjectStore(request, objectStoreIdentifier);
 }
 
 void WebIDBConnectionToClient::createIndex(const IDBRequestData& request, const IDBIndexInfo& info)
 {
-    m_networkProcess->idbServer(m_sessionID).createIndex(request, info);
+    idbServer().createIndex(request, info);
 }
 
 void WebIDBConnectionToClient::deleteIndex(const IDBRequestData& request, uint64_t objectStoreIdentifier, const String& name)
 {
-    m_networkProcess->idbServer(m_sessionID).deleteIndex(request, objectStoreIdentifier, name);
+    idbServer().deleteIndex(request, objectStoreIdentifier, name);
 }
 
 void WebIDBConnectionToClient::renameIndex(const IDBRequestData& request, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName)
 {
-    m_networkProcess->idbServer(m_sessionID).renameIndex(request, objectStoreIdentifier, indexIdentifier, newName);
+    idbServer().renameIndex(request, objectStoreIdentifier, indexIdentifier, newName);
 }
 
 void WebIDBConnectionToClient::putOrAdd(const IDBRequestData& request, const IDBKeyData& key, const IDBValue& value, IndexedDB::ObjectStoreOverwriteMode mode)
 {
-    m_networkProcess->idbServer(m_sessionID).putOrAdd(request, key, value, mode);
+    idbServer().putOrAdd(request, key, value, mode);
 }
 
 void WebIDBConnectionToClient::getRecord(const IDBRequestData& request, const IDBGetRecordData& getRecordData)
 {
-    m_networkProcess->idbServer(m_sessionID).getRecord(request, getRecordData);
+    idbServer().getRecord(request, getRecordData);
 }
 
 void WebIDBConnectionToClient::getAllRecords(const IDBRequestData& request, const IDBGetAllRecordsData& getAllRecordsData)
 {
-    m_networkProcess->idbServer(m_sessionID).getAllRecords(request, getAllRecordsData);
+    idbServer().getAllRecords(request, getAllRecordsData);
 }
 
 void WebIDBConnectionToClient::getCount(const IDBRequestData& request, const IDBKeyRangeData& range)
 {
-    m_networkProcess->idbServer(m_sessionID).getCount(request, range);
+    idbServer().getCount(request, range);
 }
 
 void WebIDBConnectionToClient::deleteRecord(const IDBRequestData& request, const IDBKeyRangeData& range)
 {
-    m_networkProcess->idbServer(m_sessionID).deleteRecord(request, range);
+    idbServer().deleteRecord(request, range);
 }
 
 void WebIDBConnectionToClient::openCursor(const IDBRequestData& request, const IDBCursorInfo& info)
 {
-    m_networkProcess->idbServer(m_sessionID).openCursor(request, info);
+    idbServer().openCursor(request, info);
 }
 
 void WebIDBConnectionToClient::iterateCursor(const IDBRequestData& request, const IDBIterateCursorData& data)
 {
-    m_networkProcess->idbServer(m_sessionID).iterateCursor(request, data);
+    idbServer().iterateCursor(request, data);
 }
 
 void WebIDBConnectionToClient::establishTransaction(uint64_t databaseConnectionIdentifier, const IDBTransactionInfo& info)
 {
-    m_networkProcess->idbServer(m_sessionID).establishTransaction(databaseConnectionIdentifier, info);
+    idbServer().establishTransaction(databaseConnectionIdentifier, info);
 }
 
 void WebIDBConnectionToClient::databaseConnectionPendingClose(uint64_t databaseConnectionIdentifier)
 {
-    m_networkProcess->idbServer(m_sessionID).databaseConnectionPendingClose(databaseConnectionIdentifier);
+    idbServer().databaseConnectionPendingClose(databaseConnectionIdentifier);
 }
 
 void WebIDBConnectionToClient::databaseConnectionClosed(uint64_t databaseConnectionIdentifier)
 {
-    m_networkProcess->idbServer(m_sessionID).databaseConnectionClosed(databaseConnectionIdentifier);
+    idbServer().databaseConnectionClosed(databaseConnectionIdentifier);
 }
 
 void WebIDBConnectionToClient::abortOpenAndUpgradeNeeded(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& transactionIdentifier)
 {
-    m_networkProcess->idbServer(m_sessionID).abortOpenAndUpgradeNeeded(databaseConnectionIdentifier, transactionIdentifier);
+    idbServer().abortOpenAndUpgradeNeeded(databaseConnectionIdentifier, transactionIdentifier);
 }
 
 void WebIDBConnectionToClient::didFireVersionChangeEvent(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& transactionIdentifier)
 {
-    m_networkProcess->idbServer(m_sessionID).didFireVersionChangeEvent(databaseConnectionIdentifier, transactionIdentifier);
+    idbServer().didFireVersionChangeEvent(databaseConnectionIdentifier, transactionIdentifier);
 }
 
 void WebIDBConnectionToClient::openDBRequestCancelled(const IDBRequestData& requestData)
 {
-    m_networkProcess->idbServer(m_sessionID).openDBRequestCancelled(requestData);
+    idbServer().openDBRequestCancelled(requestData);
 }
 
 void WebIDBConnectionToClient::confirmDidCloseFromServer(uint64_t databaseConnectionIdentifier)
 {
-    m_networkProcess->idbServer(m_sessionID).confirmDidCloseFromServer(databaseConnectionIdentifier);
+    idbServer().confirmDidCloseFromServer(databaseConnectionIdentifier);
 }
 
 void WebIDBConnectionToClient::getAllDatabaseNames(const WebCore::SecurityOriginData& topOrigin, const WebCore::SecurityOriginData& openingOrigin, uint64_t callbackID)
 {
-    m_networkProcess->idbServer(m_sessionID).getAllDatabaseNames(identifier(), topOrigin, openingOrigin, callbackID);
+    idbServer().getAllDatabaseNames(identifier(), topOrigin, openingOrigin, callbackID);
 }
 
 } // namespace WebKit
index dc732d8..aa01a30 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -48,30 +48,30 @@ struct IDBGetRecordData;
 struct IDBIterateCursorData;
 struct IDBKeyRangeData;
 struct SecurityOriginData;
+
+namespace IDBServer {
+class IDBServer;
+}
 }
 
 namespace WebKit {
 
 class NetworkProcess;
 
-class WebIDBConnectionToClient final : public WebCore::IDBServer::IDBConnectionToClientDelegate, public IPC::MessageSender, public RefCounted<WebIDBConnectionToClient> {
+class WebIDBConnectionToClient final : public WebCore::IDBServer::IDBConnectionToClientDelegate, public IPC::MessageSender {
+    WTF_MAKE_FAST_ALLOCATED;
 public:
-    static Ref<WebIDBConnectionToClient> create(NetworkProcess&, IPC::Connection&, WebCore::IDBConnectionIdentifier, PAL::SessionID);
+    WebIDBConnectionToClient(NetworkConnectionToWebProcess&, WebCore::IDBConnectionIdentifier);
 
     virtual ~WebIDBConnectionToClient();
 
     WebCore::IDBServer::IDBConnectionToClient& connectionToClient();
     WebCore::IDBConnectionIdentifier identifier() const final { return m_identifier; }
 
-    void ref() override { RefCounted<WebIDBConnectionToClient>::ref(); }
-    void deref() override { RefCounted<WebIDBConnectionToClient>::deref(); }
-
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&);
     void disconnectedFromWebProcess();
 
 private:
-    WebIDBConnectionToClient(NetworkProcess&, IPC::Connection&, WebCore::ProcessIdentifier, PAL::SessionID);
-
     IPC::Connection* messageSenderConnection() const final;
     uint64_t messageSenderDestinationID() const final { return 0; }
 
@@ -135,12 +135,11 @@ private:
 
     template<class MessageType> void handleGetResult(const WebCore::IDBResultData&);
 
-    Ref<IPC::Connection> m_connection;
-    Ref<NetworkProcess> m_networkProcess;
+    WebCore::IDBServer::IDBServer& idbServer();
 
+    NetworkConnectionToWebProcess& m_connection;
     WebCore::IDBConnectionIdentifier m_identifier;
-    PAL::SessionID m_sessionID;
-    RefPtr<WebCore::IDBServer::IDBConnectionToClient> m_connectionToClient;
+    Ref<WebCore::IDBServer::IDBConnectionToClient> m_connectionToClient;
 };
 
 } // namespace WebKit
index ffe9c4a..082190d 100644 (file)
@@ -848,7 +848,7 @@ void NetworkConnectionToWebProcess::establishIDBConnectionToServer()
     LOG(IndexedDB, "NetworkConnectionToWebProcess::establishIDBConnectionToServer - %" PRIu64, m_sessionID.toUInt64());
     ASSERT(!m_webIDBConnection);
     
-    m_webIDBConnection = WebIDBConnectionToClient::create(m_networkProcess, m_connection.get(), m_webProcessIdentifier, m_sessionID);
+    m_webIDBConnection = makeUnique<WebIDBConnectionToClient>(*this, m_webProcessIdentifier);
 }
 #endif
     
index 7cfd83d..97dc24b 100644 (file)
@@ -321,7 +321,7 @@ private:
     RefPtr<CacheStorageEngineConnection> m_cacheStorageConnection;
 
 #if ENABLE(INDEXED_DATABASE)
-    RefPtr<WebIDBConnectionToClient> m_webIDBConnection;
+    std::unique_ptr<WebIDBConnectionToClient> m_webIDBConnection;
 #endif
 
 #if ENABLE(SERVICE_WORKER)