Title: [225526] trunk/Source
Revision
225526
Author
commit-qu...@webkit.org
Date
2017-12-05 10:42:05 -0800 (Tue, 05 Dec 2017)

Log Message

Implement setting of service worker to client in SWServer without going to WebProcess
https://bugs.webkit.org/show_bug.cgi?id=180382

Patch by Youenn Fablet <you...@apple.com> on 2017-12-05
Reviewed by Chris Dumez.

Source/WebCore:

No change of behavior.

This patch removes the notification of active worker setting from ScriptExecution/WebProcess up to SWServer/StorageProcess.
Instead, active worker setting is fully done/controlled in SWServer.
Whenever there is a change, SWServer notifies WebProcess and ScriptExecutionContext gets updated accordingly.

* dom/Document.cpp:
(WebCore::Document::setServiceWorkerConnection):
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::setActiveServiceWorker):
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::commitData):
* workers/service/SWClientConnection.h:
* workers/service/server/SWServer.cpp:
(WebCore::SWServer::setClientActiveWorker):
(WebCore::SWServer::registerServiceWorkerClient):
(WebCore::SWServer::registrationFromServiceWorkerIdentifier):
(WebCore::SWServer::unregisterServiceWorkerClient):
(WebCore::SWServer::Connection::serviceWorkerStartedControllingClient): Deleted.
(WebCore::SWServer::Connection::serviceWorkerStoppedControllingClient): Deleted.
(WebCore::SWServer::serviceWorkerStartedControllingClient): Deleted.
(WebCore::SWServer::serviceWorkerStoppedControllingClient): Deleted.
* workers/service/server/SWServer.h:
* workers/service/server/SWServerRegistration.cpp:
(WebCore::SWServerRegistration::activate):

Source/WebKit:

* StorageProcess/ServiceWorker/WebSWServerConnection.messages.in:
* StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
(WebKit::WebSWServerConnection::registerServiceWorkerClient):
* StorageProcess/ServiceWorker/WebSWServerConnection.h:
* StorageProcess/ServiceWorker/WebSWServerConnection.messages.in:
* WebProcess/Storage/WebSWClientConnection.cpp:
(WebKit::WebSWClientConnection::registerServiceWorkerClient):
(WebKit::WebSWClientConnection::serviceWorkerStartedControllingClient): Deleted.
(WebKit::WebSWClientConnection::serviceWorkerStoppedControllingClient): Deleted.
* WebProcess/Storage/WebSWClientConnection.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (225525 => 225526)


--- trunk/Source/WebCore/ChangeLog	2017-12-05 17:58:07 UTC (rev 225525)
+++ trunk/Source/WebCore/ChangeLog	2017-12-05 18:42:05 UTC (rev 225526)
@@ -1,3 +1,36 @@
+2017-12-05  Youenn Fablet  <you...@apple.com>
+
+        Implement setting of service worker to client in SWServer without going to WebProcess
+        https://bugs.webkit.org/show_bug.cgi?id=180382
+
+        Reviewed by Chris Dumez.
+
+        No change of behavior.
+
+        This patch removes the notification of active worker setting from ScriptExecution/WebProcess up to SWServer/StorageProcess.
+        Instead, active worker setting is fully done/controlled in SWServer.
+        Whenever there is a change, SWServer notifies WebProcess and ScriptExecutionContext gets updated accordingly.
+
+        * dom/Document.cpp:
+        (WebCore::Document::setServiceWorkerConnection):
+        * dom/ScriptExecutionContext.cpp:
+        (WebCore::ScriptExecutionContext::setActiveServiceWorker):
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::commitData):
+        * workers/service/SWClientConnection.h:
+        * workers/service/server/SWServer.cpp:
+        (WebCore::SWServer::setClientActiveWorker):
+        (WebCore::SWServer::registerServiceWorkerClient):
+        (WebCore::SWServer::registrationFromServiceWorkerIdentifier):
+        (WebCore::SWServer::unregisterServiceWorkerClient):
+        (WebCore::SWServer::Connection::serviceWorkerStartedControllingClient): Deleted.
+        (WebCore::SWServer::Connection::serviceWorkerStoppedControllingClient): Deleted.
+        (WebCore::SWServer::serviceWorkerStartedControllingClient): Deleted.
+        (WebCore::SWServer::serviceWorkerStoppedControllingClient): Deleted.
+        * workers/service/server/SWServer.h:
+        * workers/service/server/SWServerRegistration.cpp:
+        (WebCore::SWServerRegistration::activate):
+
 2017-12-01  Filip Pizlo  <fpi...@apple.com>
 
         GC constraint solving should be parallel

Modified: trunk/Source/WebCore/dom/Document.cpp (225525 => 225526)


--- trunk/Source/WebCore/dom/Document.cpp	2017-12-05 17:58:07 UTC (rev 225525)
+++ trunk/Source/WebCore/dom/Document.cpp	2017-12-05 18:42:05 UTC (rev 225526)
@@ -7597,8 +7597,11 @@
 
     m_serviceWorkerConnection = serviceWorkerConnection;
 
-    if (m_serviceWorkerConnection)
-        m_serviceWorkerConnection->registerServiceWorkerClient(topOrigin(), identifier(), ServiceWorkerClientData::from(*this));
+    if (!m_serviceWorkerConnection)
+        return;
+
+    auto controllingServiceWorkerIdentifier = activeServiceWorker() ? std::make_optional<ServiceWorkerIdentifier>(activeServiceWorker()->identifier()) : std::nullopt;
+    m_serviceWorkerConnection->registerServiceWorkerClient(topOrigin(), identifier(), ServiceWorkerClientData::from(*this), controllingServiceWorkerIdentifier);
 }
 #endif
 

Modified: trunk/Source/WebCore/dom/ScriptExecutionContext.cpp (225525 => 225526)


--- trunk/Source/WebCore/dom/ScriptExecutionContext.cpp	2017-12-05 17:58:07 UTC (rev 225525)
+++ trunk/Source/WebCore/dom/ScriptExecutionContext.cpp	2017-12-05 18:42:05 UTC (rev 225526)
@@ -545,21 +545,7 @@
 
 void ScriptExecutionContext::setActiveServiceWorker(RefPtr<ServiceWorker>&& serviceWorker)
 {
-    // Add support for workers.
-    if (!is<Document>(*this))
-        return;
-
-    if (m_activeServiceWorker == serviceWorker)
-        return;
-
-    auto& connection = ServiceWorkerProvider::singleton().serviceWorkerConnectionForSession(sessionID());
-    if (m_activeServiceWorker)
-        connection.serviceWorkerStoppedControllingClient(m_activeServiceWorker->identifier(), m_activeServiceWorker->registrationIdentifier(), downcast<Document>(*this).identifier());
-
     m_activeServiceWorker = WTFMove(serviceWorker);
-
-    if (m_activeServiceWorker)
-        connection.serviceWorkerStartedControllingClient(m_activeServiceWorker->identifier(), m_activeServiceWorker->registrationIdentifier(), downcast<Document>(*this).identifier());
 }
 
 void ScriptExecutionContext::registerServiceWorker(ServiceWorker& serviceWorker)

Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (225525 => 225526)


--- trunk/Source/WebCore/loader/DocumentLoader.cpp	2017-12-05 17:58:07 UTC (rev 225525)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp	2017-12-05 18:42:05 UTC (rev 225526)
@@ -874,11 +874,11 @@
         if (RuntimeEnabledFeatures::sharedFeatures().serviceWorkerEnabled()) {
             // FIXME: We should probably register the client as soon as we do the related navigation fetch.
             // We can probably implement this when supporting FetchEvent.reservedClientId.
-            m_frame->document()->setServiceWorkerConnection(&ServiceWorkerProvider::singleton().serviceWorkerConnectionForSession(m_frame->page()->sessionID()));
             if (m_serviceWorkerRegistrationData && m_serviceWorkerRegistrationData->activeWorker) {
                 m_frame->document()->setActiveServiceWorker(ServiceWorker::getOrCreate(*m_frame->document(), WTFMove(m_serviceWorkerRegistrationData->activeWorker.value())));
                 m_serviceWorkerRegistrationData = { };
             }
+            m_frame->document()->setServiceWorkerConnection(&ServiceWorkerProvider::singleton().serviceWorkerConnectionForSession(m_frame->page()->sessionID()));
         }
 #endif
         // Call receivedFirstData() exactly once per load. We should only reach this point multiple times

Modified: trunk/Source/WebCore/workers/service/SWClientConnection.h (225525 => 225526)


--- trunk/Source/WebCore/workers/service/SWClientConnection.h	2017-12-05 17:58:07 UTC (rev 225525)
+++ trunk/Source/WebCore/workers/service/SWClientConnection.h	2017-12-05 18:42:05 UTC (rev 225526)
@@ -78,10 +78,7 @@
     virtual bool mayHaveServiceWorkerRegisteredForOrigin(const SecurityOrigin&) const = 0;
     virtual void syncTerminateWorker(ServiceWorkerIdentifier) = 0;
 
-    virtual void serviceWorkerStartedControllingClient(ServiceWorkerIdentifier, ServiceWorkerRegistrationIdentifier, DocumentIdentifier) = 0;
-    virtual void serviceWorkerStoppedControllingClient(ServiceWorkerIdentifier, ServiceWorkerRegistrationIdentifier, DocumentIdentifier) = 0;
-
-    virtual void registerServiceWorkerClient(const SecurityOrigin& topOrigin, DocumentIdentifier, const ServiceWorkerClientData&) = 0;
+    virtual void registerServiceWorkerClient(const SecurityOrigin& topOrigin, DocumentIdentifier, const ServiceWorkerClientData&, const std::optional<ServiceWorkerIdentifier>&) = 0;
     virtual void unregisterServiceWorkerClient(DocumentIdentifier) = 0;
 
 protected:

Modified: trunk/Source/WebCore/workers/service/server/SWServer.cpp (225525 => 225526)


--- trunk/Source/WebCore/workers/service/server/SWServer.cpp	2017-12-05 17:58:07 UTC (rev 225525)
+++ trunk/Source/WebCore/workers/service/server/SWServer.cpp	2017-12-05 18:42:05 UTC (rev 225526)
@@ -188,16 +188,6 @@
     m_server.removeClientServiceWorkerRegistration(*this, identifier);
 }
 
-void SWServer::Connection::serviceWorkerStartedControllingClient(ServiceWorkerIdentifier serviceWorkerIdentifier, ServiceWorkerRegistrationIdentifier registrationIdentifier, DocumentIdentifier contextIdentifier)
-{
-    m_server.serviceWorkerStartedControllingClient(*this, serviceWorkerIdentifier, registrationIdentifier, contextIdentifier);
-}
-
-void SWServer::Connection::serviceWorkerStoppedControllingClient(ServiceWorkerIdentifier serviceWorkerIdentifier, ServiceWorkerRegistrationIdentifier registrationIdentifier, DocumentIdentifier contextIdentifier)
-{
-    m_server.serviceWorkerStoppedControllingClient(*this, serviceWorkerIdentifier, registrationIdentifier, contextIdentifier);
-}
-
 void SWServer::Connection::syncTerminateWorker(ServiceWorkerIdentifier identifier)
 {
     if (auto* worker = m_server.workerByID(identifier))
@@ -384,33 +374,6 @@
     registration->removeClientServiceWorkerRegistration(connection.identifier());
 }
 
-void SWServer::serviceWorkerStartedControllingClient(Connection& connection, ServiceWorkerIdentifier serviceWorkerIdentifier, ServiceWorkerRegistrationIdentifier registrationIdentifier, DocumentIdentifier contextIdentifier)
-{
-    auto* registration = m_registrationsByID.get(registrationIdentifier);
-    if (!registration)
-        return;
-
-    ServiceWorkerClientIdentifier clientIdentifier { connection.identifier(), contextIdentifier };
-    registration->addClientUsingRegistration(clientIdentifier);
-
-    auto result = m_clientToControllingWorker.add(clientIdentifier, serviceWorkerIdentifier);
-    ASSERT_UNUSED(result, result.isNewEntry);
-}
-
-void SWServer::serviceWorkerStoppedControllingClient(Connection& connection, ServiceWorkerIdentifier serviceWorkerIdentifier, ServiceWorkerRegistrationIdentifier registrationIdentifier, DocumentIdentifier contextIdentifier)
-{
-    UNUSED_PARAM(serviceWorkerIdentifier);
-    auto* registration = m_registrationsByID.get(registrationIdentifier);
-    if (!registration)
-        return;
-
-    ServiceWorkerClientIdentifier clientIdentifier { connection.identifier(), contextIdentifier };
-    registration->removeClientUsingRegistration(clientIdentifier);
-
-    auto result = m_clientToControllingWorker.take(clientIdentifier);
-    ASSERT_UNUSED(result, result == serviceWorkerIdentifier);
-}
-
 void SWServer::updateWorker(Connection&, const ServiceWorkerJobDataIdentifier& jobDataIdentifier, SWServerRegistration& registration, const URL& url, const String& script, WorkerType type)
 {
     auto serviceWorkerIdentifier = generateServiceWorkerIdentifier();
@@ -616,39 +579,69 @@
     return (selectedRegistration && !selectedRegistration->isUninstalling()) ? selectedRegistration : nullptr;
 }
 
-void SWServer::registerServiceWorkerClient(ClientOrigin&& clientOrigin, ServiceWorkerClientIdentifier identifier, ServiceWorkerClientData&& data)
+void SWServer::setClientActiveWorker(ServiceWorkerClientIdentifier clientIdentifier, ServiceWorkerIdentifier serviceWorkerIdentifier)
 {
+    m_clientToControllingWorker.set(clientIdentifier, serviceWorkerIdentifier);
+}
+
+SWServerRegistration* SWServer::registrationFromServiceWorkerIdentifier(ServiceWorkerIdentifier identifier)
+{
+    auto iterator = m_runningOrTerminatingWorkers.find(identifier);
+    if (iterator == m_runningOrTerminatingWorkers.end())
+        return nullptr;
+
+    return m_registrations.get(iterator->value->registrationKey());
+}
+
+void SWServer::registerServiceWorkerClient(ClientOrigin&& clientOrigin, ServiceWorkerClientIdentifier clientIdentifier, ServiceWorkerClientData&& data, const std::optional<ServiceWorkerIdentifier>& controllingServiceWorkerIdentifier)
+{
     auto& clientsData = m_clients.ensure(WTFMove(clientOrigin), [] {
         return Clients { };
     }).iterator->value;
 
-    clientsData.clients.append(ServiceWorkerClientInformation { identifier, WTFMove(data) });
+    clientsData.clients.append(ServiceWorkerClientInformation { clientIdentifier, WTFMove(data) });
     if (clientsData.terminateServiceWorkersTimer)
         clientsData.terminateServiceWorkersTimer = nullptr;
+
+    if (!controllingServiceWorkerIdentifier)
+        return;
+
+    if (auto* controllingRegistration = registrationFromServiceWorkerIdentifier(*controllingServiceWorkerIdentifier)) {
+        controllingRegistration->addClientUsingRegistration(clientIdentifier);
+        auto result = m_clientToControllingWorker.add(clientIdentifier, *controllingServiceWorkerIdentifier);
+        ASSERT_UNUSED(result, result.isNewEntry);
+    }
 }
 
-void SWServer::unregisterServiceWorkerClient(const ClientOrigin& clientOrigin, ServiceWorkerClientIdentifier identifier)
+void SWServer::unregisterServiceWorkerClient(const ClientOrigin& clientOrigin, ServiceWorkerClientIdentifier clientIdentifier)
 {
-    auto iterator = m_clients.find(clientOrigin);
-    ASSERT(iterator != m_clients.end());
+    auto clientIterator = m_clients.find(clientOrigin);
+    ASSERT(clientIterator != m_clients.end());
 
-    auto& clients = iterator->value.clients;
-    clients.removeFirstMatching([&] (const auto& item) {
-        return identifier == item.identifier;
+    auto& clients = clientIterator->value.clients;
+    clients.removeFirstMatching([&] (const auto& client) {
+        return clientIdentifier == client.identifier;
     });
+    if (clients.isEmpty()) {
+        ASSERT(!clientIterator->value.terminateServiceWorkersTimer);
+        clientIterator->value.terminateServiceWorkersTimer = std::make_unique<Timer>([clientOrigin, this] {
+            for (auto& worker : m_runningOrTerminatingWorkers.values()) {
+                if (worker->origin() == clientOrigin)
+                    terminateWorker(worker);
+            }
+            m_clients.remove(clientOrigin);
+        });
+        clientIterator->value.terminateServiceWorkersTimer->startOneShot(terminationDelay);
+    }
 
-    if (!clients.isEmpty() || m_runningOrTerminatingWorkers.isEmpty())
+    auto workerIterator = m_clientToControllingWorker.find(clientIdentifier);
+    if (workerIterator == m_clientToControllingWorker.end())
         return;
 
-    ASSERT(!iterator->value.terminateServiceWorkersTimer);
-    iterator->value.terminateServiceWorkersTimer = std::make_unique<Timer>([clientOrigin, this] {
-        for (auto& worker : m_runningOrTerminatingWorkers.values()) {
-            if (worker->origin() == clientOrigin)
-                terminateWorker(worker);
-        }
-        m_clients.remove(clientOrigin);
-    });
-    iterator->value.terminateServiceWorkersTimer->startOneShot(terminationDelay);
+    if (auto* controllingRegistration = registrationFromServiceWorkerIdentifier(workerIterator->value))
+        controllingRegistration->removeClientUsingRegistration(clientIdentifier);
+
+    m_clientToControllingWorker.remove(workerIterator);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/workers/service/server/SWServer.h (225525 => 225526)


--- trunk/Source/WebCore/workers/service/server/SWServer.h	2017-12-05 17:58:07 UTC (rev 225525)
+++ trunk/Source/WebCore/workers/service/server/SWServer.h	2017-12-05 18:42:05 UTC (rev 225526)
@@ -90,8 +90,6 @@
         WEBCORE_EXPORT void finishFetchingScriptInServer(const ServiceWorkerFetchResult&);
         WEBCORE_EXPORT void addServiceWorkerRegistrationInServer(ServiceWorkerRegistrationIdentifier);
         WEBCORE_EXPORT void removeServiceWorkerRegistrationInServer(ServiceWorkerRegistrationIdentifier);
-        WEBCORE_EXPORT void serviceWorkerStartedControllingClient(ServiceWorkerIdentifier, ServiceWorkerRegistrationIdentifier, DocumentIdentifier);
-        WEBCORE_EXPORT void serviceWorkerStoppedControllingClient(ServiceWorkerIdentifier, ServiceWorkerRegistrationIdentifier, DocumentIdentifier);
         WEBCORE_EXPORT void syncTerminateWorker(ServiceWorkerIdentifier);
 
     private:
@@ -147,11 +145,13 @@
     
     WEBCORE_EXPORT static HashSet<SWServer*>& allServers();
 
-    WEBCORE_EXPORT void registerServiceWorkerClient(ClientOrigin&&, ServiceWorkerClientIdentifier, ServiceWorkerClientData&&);
+    WEBCORE_EXPORT void registerServiceWorkerClient(ClientOrigin&&, ServiceWorkerClientIdentifier, ServiceWorkerClientData&&, const std::optional<ServiceWorkerIdentifier>& controllingServiceWorkerIdentifier);
     WEBCORE_EXPORT void unregisterServiceWorkerClient(const ClientOrigin&, ServiceWorkerClientIdentifier);
 
     WEBCORE_EXPORT bool invokeRunServiceWorker(ServiceWorkerIdentifier);
 
+    void setClientActiveWorker(ServiceWorkerClientIdentifier, ServiceWorkerIdentifier);
+
 private:
     void registerConnection(Connection&);
     void unregisterConnection(Connection&);
@@ -165,13 +165,13 @@
 
     void addClientServiceWorkerRegistration(Connection&, ServiceWorkerRegistrationIdentifier);
     void removeClientServiceWorkerRegistration(Connection&, ServiceWorkerRegistrationIdentifier);
-    void serviceWorkerStartedControllingClient(Connection&, ServiceWorkerIdentifier, ServiceWorkerRegistrationIdentifier, DocumentIdentifier);
-    void serviceWorkerStoppedControllingClient(Connection&, ServiceWorkerIdentifier, ServiceWorkerRegistrationIdentifier, DocumentIdentifier);
 
     WEBCORE_EXPORT const SWServerRegistration* doRegistrationMatching(const SecurityOriginData& topOrigin, const URL& clientURL) const;
 
     void installContextData(const ServiceWorkerContextData&);
 
+    SWServerRegistration* registrationFromServiceWorkerIdentifier(ServiceWorkerIdentifier);
+
     enum TerminationMode {
         Synchronous,
         Asynchronous,

Modified: trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp (225525 => 225526)


--- trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp	2017-12-05 17:58:07 UTC (rev 225525)
+++ trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp	2017-12-05 18:42:05 UTC (rev 225526)
@@ -259,10 +259,14 @@
     updateRegistrationState(ServiceWorkerRegistrationState::Waiting, nullptr);
     // Run the Update Worker State algorithm passing registration's active worker and activating as the arguments.
     updateWorkerState(*activeWorker(), ServiceWorkerState::Activating);
-    // FIXME: For each service worker client client whose creation URL matches registration's scope url...
+    // FIXME: For each service worker client whose creation URL matches registration's scope url...
 
-    // For each service worker client client who is using registration:
+    // For each service worker client who is using registration:
     // - Set client's active worker to registration's active worker.
+    for (auto keyValue : m_clientsUsingRegistration) {
+        for (auto& clientIdentifier : keyValue.value)
+            m_server.setClientActiveWorker(ServiceWorkerClientIdentifier { keyValue.key, clientIdentifier }, activeWorker()->identifier());
+    }
     // - Invoke Notify Controller Change algorithm with client as the argument.
     notifyClientsOfControllerChange();
 

Modified: trunk/Source/WebKit/ChangeLog (225525 => 225526)


--- trunk/Source/WebKit/ChangeLog	2017-12-05 17:58:07 UTC (rev 225525)
+++ trunk/Source/WebKit/ChangeLog	2017-12-05 18:42:05 UTC (rev 225526)
@@ -1,3 +1,21 @@
+2017-12-05  Youenn Fablet  <you...@apple.com>
+
+        Implement setting of service worker to client in SWServer without going to WebProcess
+        https://bugs.webkit.org/show_bug.cgi?id=180382
+
+        Reviewed by Chris Dumez.
+
+        * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in:
+        * StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
+        (WebKit::WebSWServerConnection::registerServiceWorkerClient):
+        * StorageProcess/ServiceWorker/WebSWServerConnection.h:
+        * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in:
+        * WebProcess/Storage/WebSWClientConnection.cpp:
+        (WebKit::WebSWClientConnection::registerServiceWorkerClient):
+        (WebKit::WebSWClientConnection::serviceWorkerStartedControllingClient): Deleted.
+        (WebKit::WebSWClientConnection::serviceWorkerStoppedControllingClient): Deleted.
+        * WebProcess/Storage/WebSWClientConnection.h:
+
 2017-12-04  Chris Dumez  <cdu...@apple.com>
 
         Support container.getRegistration() / getRegistrations() inside service workers

Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp (225525 => 225526)


--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp	2017-12-05 17:58:07 UTC (rev 225525)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp	2017-12-05 18:42:05 UTC (rev 225526)
@@ -204,11 +204,11 @@
     send(Messages::WebSWClientConnection::DidGetRegistrations { registrationMatchRequestIdentifier, registrations });
 }
 
-void WebSWServerConnection::registerServiceWorkerClient(SecurityOriginData&& topOrigin, DocumentIdentifier contextIdentifier, ServiceWorkerClientData&& data)
+void WebSWServerConnection::registerServiceWorkerClient(SecurityOriginData&& topOrigin, DocumentIdentifier contextIdentifier, ServiceWorkerClientData&& data, const std::optional<ServiceWorkerIdentifier>& controllingServiceWorkerIdentifier)
 {
     auto clientOrigin = ClientOrigin { WTFMove(topOrigin), SecurityOriginData::fromSecurityOrigin(SecurityOrigin::create(data.url)) };
     m_clientOrigins.add(contextIdentifier, clientOrigin);
-    server().registerServiceWorkerClient(WTFMove(clientOrigin), ServiceWorkerClientIdentifier { this->identifier(), contextIdentifier } , WTFMove(data));
+    server().registerServiceWorkerClient(WTFMove(clientOrigin), ServiceWorkerClientIdentifier { this->identifier(), contextIdentifier } , WTFMove(data), controllingServiceWorkerIdentifier);
 }
 
 void WebSWServerConnection::unregisterServiceWorkerClient(DocumentIdentifier contextIdentifier)

Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h (225525 => 225526)


--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h	2017-12-05 17:58:07 UTC (rev 225525)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h	2017-12-05 18:42:05 UTC (rev 225526)
@@ -86,7 +86,7 @@
     void matchRegistration(uint64_t registrationMatchRequestIdentifier, const WebCore::SecurityOriginData& topOrigin, const WebCore::URL& clientURL);
     void getRegistrations(uint64_t registrationMatchRequestIdentifier, const WebCore::SecurityOriginData& topOrigin, const WebCore::URL& clientURL);
 
-    void registerServiceWorkerClient(WebCore::SecurityOriginData&& topOrigin, WebCore::DocumentIdentifier, WebCore::ServiceWorkerClientData&&);
+    void registerServiceWorkerClient(WebCore::SecurityOriginData&& topOrigin, WebCore::DocumentIdentifier, WebCore::ServiceWorkerClientData&&, const std::optional<WebCore::ServiceWorkerIdentifier>&);
     void unregisterServiceWorkerClient(WebCore::DocumentIdentifier);
 
     IPC::Connection* messageSenderConnection() final { return m_contentConnection.ptr(); }

Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in (225525 => 225526)


--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in	2017-12-05 17:58:07 UTC (rev 225525)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in	2017-12-05 18:42:05 UTC (rev 225526)
@@ -28,8 +28,6 @@
     FinishFetchingScriptInServer(struct WebCore::ServiceWorkerFetchResult result)
     AddServiceWorkerRegistrationInServer(WebCore::ServiceWorkerRegistrationIdentifier identifier)
     RemoveServiceWorkerRegistrationInServer(WebCore::ServiceWorkerRegistrationIdentifier identifier)
-    ServiceWorkerStartedControllingClient(WebCore::ServiceWorkerIdentifier serviceWorkerIdentifier, WebCore::ServiceWorkerRegistrationIdentifier registrationIdentifier, WebCore::DocumentIdentifier contextIdentifier)
-    ServiceWorkerStoppedControllingClient(WebCore::ServiceWorkerIdentifier serviceWorkerIdentifier, WebCore::ServiceWorkerRegistrationIdentifier registrationIdentifier, WebCore::DocumentIdentifier contextIdentifier)
 
     StartFetch(uint64_t identifier, std::optional<WebCore::ServiceWorkerIdentifier> serviceWorkerIdentifier, WebCore::ResourceRequest request, struct WebCore::FetchOptions options, IPC::FormDataReference requestBody)
     PostMessageToServiceWorkerFromClient(WebCore::ServiceWorkerIdentifier destinationServiceWorkerIdentifier, IPC::DataReference message, struct WebCore::ServiceWorkerClientIdentifier sourceIdentifier, struct WebCore::ServiceWorkerClientData sourceData)
@@ -39,7 +37,7 @@
 
     MatchRegistration(uint64_t serviceRegistrationMatchRequestIdentifier, struct WebCore::SecurityOriginData topOrigin, WebCore::URL clientURL)
     GetRegistrations(uint64_t serviceRegistrationMatchRequestIdentifier, struct WebCore::SecurityOriginData topOrigin, WebCore::URL clientURL)
-    RegisterServiceWorkerClient(struct WebCore::SecurityOriginData topOrigin, WebCore::DocumentIdentifier identifier, struct WebCore::ServiceWorkerClientData data)
+    RegisterServiceWorkerClient(struct WebCore::SecurityOriginData topOrigin, WebCore::DocumentIdentifier identifier, struct WebCore::ServiceWorkerClientData data, std::optional<WebCore::ServiceWorkerIdentifier> controllingServiceWorkerIdentifier)
     UnregisterServiceWorkerClient(WebCore::DocumentIdentifier identifier)
 
     SyncTerminateWorker(WebCore::ServiceWorkerIdentifier workerIdentifier) -> ()

Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp (225525 => 225526)


--- trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp	2017-12-05 17:58:07 UTC (rev 225525)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp	2017-12-05 18:42:05 UTC (rev 225526)
@@ -92,21 +92,11 @@
     send(Messages::WebSWServerConnection::PostMessageToServiceWorkerFromServiceWorker(destinationIdentifier, IPC::DataReference { scriptValue->data() }, sourceWorkerIdentifier));
 }
 
-void WebSWClientConnection::serviceWorkerStartedControllingClient(ServiceWorkerIdentifier serviceWorkerIdentifier, ServiceWorkerRegistrationIdentifier registrationIdentifier, DocumentIdentifier contextIdentifier)
+void WebSWClientConnection::registerServiceWorkerClient(const SecurityOrigin& topOrigin, WebCore::DocumentIdentifier contextIdentifier, const WebCore::ServiceWorkerClientData& data, const std::optional<WebCore::ServiceWorkerIdentifier>& controllingServiceWorkerIdentifier)
 {
-    send(Messages::WebSWServerConnection::ServiceWorkerStartedControllingClient(serviceWorkerIdentifier, registrationIdentifier, contextIdentifier));
+    send(Messages::WebSWServerConnection::RegisterServiceWorkerClient { SecurityOriginData::fromSecurityOrigin(topOrigin), contextIdentifier, data, controllingServiceWorkerIdentifier });
 }
 
-void WebSWClientConnection::serviceWorkerStoppedControllingClient(ServiceWorkerIdentifier serviceWorkerIdentifier, ServiceWorkerRegistrationIdentifier registrationIdentifier, DocumentIdentifier contextIdentifier)
-{
-    send(Messages::WebSWServerConnection::ServiceWorkerStoppedControllingClient(serviceWorkerIdentifier, registrationIdentifier, contextIdentifier));
-}
-
-void WebSWClientConnection::registerServiceWorkerClient(const SecurityOrigin& topOrigin, WebCore::DocumentIdentifier contextIdentifier, const WebCore::ServiceWorkerClientData& data)
-{
-    send(Messages::WebSWServerConnection::RegisterServiceWorkerClient { SecurityOriginData::fromSecurityOrigin(topOrigin), contextIdentifier, data });
-}
-
 void WebSWClientConnection::unregisterServiceWorkerClient(WebCore::DocumentIdentifier contextIdentifier)
 {
     send(Messages::WebSWServerConnection::UnregisterServiceWorkerClient { contextIdentifier });

Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h (225525 => 225526)


--- trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h	2017-12-05 17:58:07 UTC (rev 225525)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h	2017-12-05 18:42:05 UTC (rev 225526)
@@ -75,9 +75,7 @@
     void finishFetchingScriptInServer(const WebCore::ServiceWorkerFetchResult&) final;
     void postMessageToServiceWorker(WebCore::ServiceWorkerIdentifier destinationIdentifier, Ref<WebCore::SerializedScriptValue>&&, WebCore::ServiceWorkerClientIdentifier sourceIdentifier, WebCore::ServiceWorkerClientData&& source) final;
     void postMessageToServiceWorker(WebCore::ServiceWorkerIdentifier destinationIdentifier, Ref<WebCore::SerializedScriptValue>&&, WebCore::ServiceWorkerIdentifier sourceWorkerIdentifier) final;
-    void serviceWorkerStartedControllingClient(WebCore::ServiceWorkerIdentifier, WebCore::ServiceWorkerRegistrationIdentifier, WebCore::DocumentIdentifier) final;
-    void serviceWorkerStoppedControllingClient(WebCore::ServiceWorkerIdentifier, WebCore::ServiceWorkerRegistrationIdentifier, WebCore::DocumentIdentifier) final;
-    void registerServiceWorkerClient(const WebCore::SecurityOrigin& topOrigin, WebCore::DocumentIdentifier, const WebCore::ServiceWorkerClientData&) final;
+    void registerServiceWorkerClient(const WebCore::SecurityOrigin& topOrigin, WebCore::DocumentIdentifier, const WebCore::ServiceWorkerClientData&, const std::optional<WebCore::ServiceWorkerIdentifier>&) final;
     void unregisterServiceWorkerClient(WebCore::DocumentIdentifier) final;
 
     void matchRegistration(const WebCore::SecurityOrigin& topOrigin, const WebCore::URL& clientURL, RegistrationCallback&&) final;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to