WebSWServerConnection should register/unregister itself with the StorageProcess
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Nov 2017 17:51:46 +0000 (17:51 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Nov 2017 17:51:46 +0000 (17:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=179965

Reviewed by Darin Adler.

WebSWServerConnection should register/unregister itself with the StorageProcess instead of relying
on StorageToWebProcessConnection to do so on its behalf. This is less error-prone.

* StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
(WebKit::WebSWServerConnection::WebSWServerConnection):
(WebKit::WebSWServerConnection::~WebSWServerConnection):
* StorageProcess/StorageToWebProcessConnection.cpp:
(WebKit::StorageToWebProcessConnection::~StorageToWebProcessConnection):
(WebKit::StorageToWebProcessConnection::establishSWServerConnection):
(WebKit::StorageToWebProcessConnection::removeSWServerConnection):

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

Source/WebKit/ChangeLog
Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp
Source/WebKit/StorageProcess/StorageToWebProcessConnection.cpp

index c9d7284..b03cb9f 100644 (file)
@@ -1,3 +1,21 @@
+2017-11-23  Chris Dumez  <cdumez@apple.com>
+
+        WebSWServerConnection should register/unregister itself with the StorageProcess
+        https://bugs.webkit.org/show_bug.cgi?id=179965
+
+        Reviewed by Darin Adler.
+
+        WebSWServerConnection should register/unregister itself with the StorageProcess instead of relying
+        on StorageToWebProcessConnection to do so on its behalf. This is less error-prone.
+
+        * StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
+        (WebKit::WebSWServerConnection::WebSWServerConnection):
+        (WebKit::WebSWServerConnection::~WebSWServerConnection):
+        * StorageProcess/StorageToWebProcessConnection.cpp:
+        (WebKit::StorageToWebProcessConnection::~StorageToWebProcessConnection):
+        (WebKit::StorageToWebProcessConnection::establishSWServerConnection):
+        (WebKit::StorageToWebProcessConnection::removeSWServerConnection):
+
 2017-11-23  Darin Adler  <darin@apple.com>
 
         Reduce WTF::String operations that do unnecessary Unicode operations instead of ASCII
index 9019388..4b58fa3 100644 (file)
@@ -61,10 +61,12 @@ WebSWServerConnection::WebSWServerConnection(SWServer& server, IPC::Connection&
     , m_sessionID(sessionID)
     , m_contentConnection(connection)
 {
+    StorageProcess::singleton().registerSWServerConnection(*this);
 }
 
 WebSWServerConnection::~WebSWServerConnection()
 {
+    StorageProcess::singleton().unregisterSWServerConnection(*this);
 }
 
 void WebSWServerConnection::disconnectedFromWebProcess()
index 5d746b4..13a77db 100644 (file)
@@ -60,11 +60,6 @@ StorageToWebProcessConnection::StorageToWebProcessConnection(IPC::Connection::Id
 StorageToWebProcessConnection::~StorageToWebProcessConnection()
 {
     m_connection->invalidate();
-
-#if ENABLE(SERVICE_WORKER)
-    for (auto& connection : m_swConnections.values())
-        StorageProcess::singleton().unregisterSWServerConnection(*connection);
-#endif
 }
 
 void StorageToWebProcessConnection::didReceiveMessage(IPC::Connection& connection, IPC::Decoder& decoder)
@@ -149,9 +144,7 @@ void StorageToWebProcessConnection::establishSWServerConnection(SessionID sessio
     ASSERT(!m_swConnections.contains(serverConnectionIdentifier));
 
     auto addResult = m_swConnections.add(serverConnectionIdentifier, WTFMove(connection));
-    ASSERT(addResult.isNewEntry);
-
-    StorageProcess::singleton().registerSWServerConnection(*(addResult.iterator->value));
+    ASSERT_UNUSED(addResult, addResult.isNewEntry);
 
     if (!StorageProcess::singleton().globalServerToContextConnection())
         StorageProcess::singleton().createServerToContextConnection();
@@ -162,7 +155,6 @@ void StorageToWebProcessConnection::removeSWServerConnection(WebCore::SWServer::
     ASSERT(m_swConnections.contains(serverConnectionIdentifier));
 
     auto connection = m_swConnections.take(serverConnectionIdentifier);
-    StorageProcess::singleton().unregisterSWServerConnection(*connection);
     connection->disconnectedFromWebProcess();
 }