[Service Worker] Implement "Try Clear Registration" algorithm
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Nov 2017 00:59:10 +0000 (00:59 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Nov 2017 00:59:10 +0000 (00:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=179791

Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

Rebaseline several WPT tests that are now passing or failing later.

* web-platform-tests/service-workers/service-worker/clients-matchall-client-types.https-expected.txt:
* web-platform-tests/service-workers/service-worker/getregistrations.https-expected.txt:
* web-platform-tests/service-workers/service-worker/ready.https-expected.txt:
* web-platform-tests/service-workers/service-worker/unregister-then-register-new-script.https-expected.txt:
* web-platform-tests/service-workers/service-worker/unregister-then-register.https-expected.txt:

Source/WebCore:

Implement "Try Clear Registration" algorithm:
- https://w3c.github.io/ServiceWorker/#try-clear-registration-algorithm

In particular, a SWServerRegistration now knows if it is "in use" by a given
service worker client (i.e. The registration's active service worker is
controlling the service worker client). See:
- https://w3c.github.io/ServiceWorker/#selection (last paragraph)

No new tests, rebaselined existing tests.

* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::setActiveServiceWorker):
* workers/service/server/SWClientConnection.h:
* workers/service/server/SWServer.cpp:
(WebCore::SWServer::Connection::serviceWorkerStartedControllingClient):
(WebCore::SWServer::Connection::serviceWorkerStoppedControllingClient):
(WebCore::SWServer::serviceWorkerStartedControllingClient):
(WebCore::SWServer::serviceWorkerStoppedControllingClient):
* workers/service/server/SWServer.h:
* workers/service/server/SWServerJobQueue.cpp:
(WebCore::SWServerJobQueue::tryClearRegistration):
* workers/service/server/SWServerRegistration.h:
(WebCore::SWServerRegistration::hasClientsUsingRegistration const):
(WebCore::SWServerRegistration::addClientUsingRegistration):
(WebCore::SWServerRegistration::removeClientUsingRegistration):

Source/WebKit:

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

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

21 files changed:
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/fetch/api/abort/serviceworker-intercepted.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/clients-matchall-client-types.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/controller-on-disconnect.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/getregistrations.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/ready.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/unregister-then-register-new-script.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/unregister-then-register.https-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/ScriptExecutionContext.cpp
Source/WebCore/workers/service/server/SWClientConnection.h
Source/WebCore/workers/service/server/SWServer.cpp
Source/WebCore/workers/service/server/SWServer.h
Source/WebCore/workers/service/server/SWServerJobQueue.cpp
Source/WebCore/workers/service/server/SWServerRegistration.cpp
Source/WebCore/workers/service/server/SWServerRegistration.h
Source/WebKit/ChangeLog
Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in
Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp
Source/WebKit/WebProcess/Storage/WebSWClientConnection.h

index 13a9c70..1aeeea9 100644 (file)
@@ -1,5 +1,20 @@
 2017-11-16  Chris Dumez  <cdumez@apple.com>
 
+        [Service Worker] Implement "Try Clear Registration" algorithm
+        https://bugs.webkit.org/show_bug.cgi?id=179791
+
+        Reviewed by Youenn Fablet.
+
+        Rebaseline several WPT tests that are now passing or failing later.
+
+        * web-platform-tests/service-workers/service-worker/clients-matchall-client-types.https-expected.txt:
+        * web-platform-tests/service-workers/service-worker/getregistrations.https-expected.txt:
+        * web-platform-tests/service-workers/service-worker/ready.https-expected.txt:
+        * web-platform-tests/service-workers/service-worker/unregister-then-register-new-script.https-expected.txt:
+        * web-platform-tests/service-workers/service-worker/unregister-then-register.https-expected.txt:
+
+2017-11-16  Chris Dumez  <cdumez@apple.com>
+
         Unreviewed, rebaseline skipped and flaky service workers tests.
 
         * web-platform-tests/service-workers/service-worker/ServiceWorkerGlobalScope/extendable-message-event.https-expected.txt:
index e61a3d3..114cf8a 100644 (file)
@@ -1,10 +1,9 @@
 
-
 FAIL Already aborted request does not land in service worker assert_unreached: Should have rejected: undefined Reached unreachable code
-FAIL response.arrayBuffer() rejects if already aborted assert_unreached: Should have rejected: undefined Reached unreachable code
-FAIL response.blob() rejects if already aborted assert_unreached: Should have rejected: undefined Reached unreachable code
-FAIL response.formData() rejects if already aborted assert_throws: function "function () { throw e }" threw object "NotSupportedError: The operation is not supported." that is not a DOMException AbortError: property "code" is equal to 9, expected 20
-FAIL response.json() rejects if already aborted assert_unreached: Should have rejected: undefined Reached unreachable code
-FAIL response.text() rejects if already aborted assert_unreached: Should have rejected: undefined Reached unreachable code
-FAIL Stream errors once aborted. assert_unreached: Should have rejected: undefined Reached unreachable code
+FAIL response.arrayBuffer() rejects if already aborted promise_test: Unhandled rejection with value: object "Error: wait_for_state must be passed a ServiceWorker"
+FAIL response.blob() rejects if already aborted promise_test: Unhandled rejection with value: object "Error: wait_for_state must be passed a ServiceWorker"
+FAIL response.formData() rejects if already aborted promise_test: Unhandled rejection with value: object "Error: wait_for_state must be passed a ServiceWorker"
+FAIL response.json() rejects if already aborted promise_test: Unhandled rejection with value: object "Error: wait_for_state must be passed a ServiceWorker"
+FAIL response.text() rejects if already aborted promise_test: Unhandled rejection with value: object "Error: wait_for_state must be passed a ServiceWorker"
+FAIL Stream errors once aborted. promise_test: Unhandled rejection with value: object "Error: wait_for_state must be passed a ServiceWorker"
 
index cdec7b1..ad73452 100644 (file)
@@ -1,5 +1,5 @@
 
 
 FAIL Verify matchAll() with window client type assert_unreached: unexpected rejection: Passing MessagePort objects to postMessage is not yet supported Reached unreachable code
-FAIL Verify matchAll() with {window, sharedworker, worker} client types promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: SharedWorker"
+FAIL Verify matchAll() with {window, sharedworker, worker} client types promise_test: Unhandled rejection with value: object "Error: wait_for_state must be passed a ServiceWorker"
 
index dfae850..f4b5340 100644 (file)
@@ -3,6 +3,6 @@ PASS registrations are not returned following unregister
 PASS Register then getRegistrations 
 PASS Register multiple times then getRegistrations 
 PASS Register then Unregister then getRegistrations 
-FAIL Register then Unregister with controlled frame then getRegistrations assert_equals: expected "activated" but got "redundant"
+PASS Register then Unregister with controlled frame then getRegistrations 
 PASS getRegistrations promise resolves only with same origin registrations. 
 
index a55170e..0489417 100644 (file)
@@ -10,5 +10,5 @@ FAIL ready on an iframe whose parent registers a new service worker promise_test
 FAIL ready on an iframe that installs a new service worker promise_test: Unhandled rejection with value: object "UnknownError: serviceWorker.ready() is not yet implemented"
 FAIL ready after a longer matched registration registered promise_test: Unhandled rejection with value: object "UnknownError: serviceWorker.ready() is not yet implemented"
 FAIL access ready after it has been resolved promise_test: Unhandled rejection with value: object "UnknownError: serviceWorker.ready() is not yet implemented"
-FAIL access ready on uninstalling registration that is resurrected assert_equals: existing registration should be resurrected expected object "[object ServiceWorkerRegistration]" but got object "[object ServiceWorkerRegistration]"
+FAIL access ready on uninstalling registration that is resurrected promise_test: Unhandled rejection with value: object "UnknownError: serviceWorker.ready() is not yet implemented"
 
index c995e9a..3b9ee89 100644 (file)
@@ -1,6 +1,6 @@
 
 
-FAIL Registering a new script URL while an unregistered registration is in use assert_unreached: unexpected rejection: null is not an object (evaluating 'registration.installing.scriptURL') Reached unreachable code
+PASS Registering a new script URL while an unregistered registration is in use 
 FAIL Registering a new script URL that 404s does not resurrect an unregistered registration assert_unreached: unexpected rejection: assert_unreached: register should reject the promise Reached unreachable code Reached unreachable code
-PASS Registering a new script URL that fails to install does not resurrect an unregistered registration 
+FAIL Registering a new script URL that fails to install does not resurrect an unregistered registration assert_unreached: unexpected rejection: assert_equals: document should not load with a controller expected null but got object "[object ServiceWorker]" Reached unreachable code
 
index c278c9e..5e6c2be 100644 (file)
@@ -1,8 +1,8 @@
 
 
 PASS Unregister then register resolves to a new value 
-FAIL Unregister then register resolves to the original value if the registration is in use. assert_unreached: unexpected rejection: assert_equals: new registration should resolve to the same registration expected object "[object ServiceWorkerRegistration]" but got object "[object ServiceWorkerRegistration]" Reached unreachable code
+PASS Unregister then register resolves to the original value if the registration is in use. 
 PASS Reloading the last controlled iframe after unregistration should ensure the deletion of the registration 
-FAIL Unregister then register does not affect existing controllee assert_unreached: unexpected rejection: assert_equals: installing version is null expected null but got object "[object ServiceWorker]" Reached unreachable code
+PASS Unregister then register does not affect existing controllee 
 PASS Unregister then register resurrects the registration 
 
index 500fbe7..5ea691e 100644 (file)
@@ -1,3 +1,36 @@
+2017-11-16  Chris Dumez  <cdumez@apple.com>
+
+        [Service Worker] Implement "Try Clear Registration" algorithm
+        https://bugs.webkit.org/show_bug.cgi?id=179791
+
+        Reviewed by Youenn Fablet.
+
+        Implement "Try Clear Registration" algorithm:
+        - https://w3c.github.io/ServiceWorker/#try-clear-registration-algorithm
+
+        In particular, a SWServerRegistration now knows if it is "in use" by a given
+        service worker client (i.e. The registration's active service worker is
+        controlling the service worker client). See:
+        - https://w3c.github.io/ServiceWorker/#selection (last paragraph)
+
+        No new tests, rebaselined existing tests.
+
+        * dom/ScriptExecutionContext.cpp:
+        (WebCore::ScriptExecutionContext::setActiveServiceWorker):
+        * workers/service/server/SWClientConnection.h:
+        * workers/service/server/SWServer.cpp:
+        (WebCore::SWServer::Connection::serviceWorkerStartedControllingClient):
+        (WebCore::SWServer::Connection::serviceWorkerStoppedControllingClient):
+        (WebCore::SWServer::serviceWorkerStartedControllingClient):
+        (WebCore::SWServer::serviceWorkerStoppedControllingClient):
+        * workers/service/server/SWServer.h:
+        * workers/service/server/SWServerJobQueue.cpp:
+        (WebCore::SWServerJobQueue::tryClearRegistration):
+        * workers/service/server/SWServerRegistration.h:
+        (WebCore::SWServerRegistration::hasClientsUsingRegistration const):
+        (WebCore::SWServerRegistration::addClientUsingRegistration):
+        (WebCore::SWServerRegistration::removeClientUsingRegistration):
+
 2017-11-16  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         REGRESSION(r224179): layer flush now requires sync IPC to compute undo/redo availability in EditorState
index a886462..c856db6 100644 (file)
@@ -2331,6 +2331,10 @@ void Document::prepareForDestruction()
     if (m_frame)
         m_frame->animation().detachFromDocument(this);
 
+#if ENABLE(SERVICE_WORKER)
+    setActiveServiceWorker(nullptr);
+#endif
+
 #if ENABLE(IOS_TOUCH_EVENTS)
     clearTouchEventHandlersAndListeners();
 #endif
index 78d1cc1..c0c1ae5 100644 (file)
 #include "PublicURLManager.h"
 #include "RejectedPromiseTracker.h"
 #include "ResourceRequest.h"
+#include "SWClientConnection.h"
 #include "ScriptState.h"
 #include "ServiceWorker.h"
+#include "ServiceWorkerProvider.h"
 #include "Settings.h"
 #include "WorkerGlobalScope.h"
 #include "WorkerNavigator.h"
@@ -115,6 +117,10 @@ ScriptExecutionContext::~ScriptExecutionContext()
     m_inScriptExecutionContextDestructor = true;
 #endif
 
+#if ENABLE(SERVICE_WORKER)
+    setActiveServiceWorker(nullptr);
+#endif
+
     while (auto* destructionObserver = m_destructionObservers.takeAny())
         destructionObserver->contextDestroyed();
 
@@ -537,7 +543,21 @@ ServiceWorker* ScriptExecutionContext::activeServiceWorker() const
 
 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(), downcast<Document>(*this).identifier());
+
     m_activeServiceWorker = WTFMove(serviceWorker);
+
+    if (m_activeServiceWorker)
+        connection.serviceWorkerStartedControllingClient(m_activeServiceWorker->identifier(), downcast<Document>(*this).identifier());
 }
 
 ServiceWorkerContainer* ScriptExecutionContext::serviceWorkerContainer()
index cb03d01..a9e9d90 100644 (file)
@@ -72,6 +72,9 @@ public:
     virtual uint64_t identifier() const = 0;
     virtual bool mayHaveServiceWorkerRegisteredForOrigin(const SecurityOrigin&) const = 0;
 
+    virtual void serviceWorkerStartedControllingClient(ServiceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier) = 0;
+    virtual void serviceWorkerStoppedControllingClient(ServiceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier) = 0;
+
 protected:
     WEBCORE_EXPORT SWClientConnection();
 
index 4ec19c2..8f005ad 100644 (file)
@@ -170,6 +170,16 @@ void SWServer::Connection::removeServiceWorkerRegistrationInServer(const Service
     m_server.removeClientServiceWorkerRegistration(*this, key, identifier);
 }
 
+void SWServer::Connection::serviceWorkerStartedControllingClient(ServiceWorkerIdentifier serviceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier)
+{
+    m_server.serviceWorkerStartedControllingClient(*this, serviceWorkerIdentifier, scriptExecutionContextIdentifier);
+}
+
+void SWServer::Connection::serviceWorkerStoppedControllingClient(ServiceWorkerIdentifier serviceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier)
+{
+    m_server.serviceWorkerStoppedControllingClient(*this, serviceWorkerIdentifier, scriptExecutionContextIdentifier);
+}
+
 SWServer::SWServer(UniqueRef<SWOriginStore>&& originStore)
     : m_originStore(WTFMove(originStore))
 {
@@ -314,6 +324,32 @@ void SWServer::removeClientServiceWorkerRegistration(Connection& connection, con
     registration->removeClientServiceWorkerRegistration(connection.identifier());
 }
 
+void SWServer::serviceWorkerStartedControllingClient(Connection& connection, ServiceWorkerIdentifier serviceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier)
+{
+    auto* serviceWorker = m_workersByID.get(serviceWorkerIdentifier);
+    if (!serviceWorker)
+        return;
+
+    auto* registration = m_registrations.get(serviceWorker->registrationKey());
+    if (!registration)
+        return;
+
+    registration->addClientUsingRegistration({ connection.identifier(), scriptExecutionContextIdentifier });
+}
+
+void SWServer::serviceWorkerStoppedControllingClient(Connection& connection, ServiceWorkerIdentifier serviceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier)
+{
+    auto* serviceWorker = m_workersByID.get(serviceWorkerIdentifier);
+    if (!serviceWorker)
+        return;
+
+    auto* registration = m_registrations.get(serviceWorker->registrationKey());
+    if (!registration)
+        return;
+
+    registration->removeClientUsingRegistration({ connection.identifier(), scriptExecutionContextIdentifier });
+}
+
 void SWServer::updateWorker(Connection&, const ServiceWorkerRegistrationKey& registrationKey, const URL& url, const String& script, WorkerType type)
 {
     auto serviceWorkerIdentifier = generateServiceWorkerIdentifier();
@@ -435,6 +471,9 @@ void SWServer::unregisterConnection(Connection& connection)
 {
     ASSERT(m_connections.get(connection.identifier()) == &connection);
     m_connections.remove(connection.identifier());
+
+    for (auto& registration : m_registrations.values())
+        registration->unregisterServerConnection(connection.identifier());
 }
 
 const SWServerRegistration* SWServer::doRegistrationMatching(const SecurityOriginData& topOrigin, const URL& clientURL) const
index 9784d74..2f8b02a 100644 (file)
@@ -79,6 +79,8 @@ public:
         WEBCORE_EXPORT void finishFetchingScriptInServer(const ServiceWorkerFetchResult&);
         WEBCORE_EXPORT void addServiceWorkerRegistrationInServer(const ServiceWorkerRegistrationKey&, ServiceWorkerRegistrationIdentifier);
         WEBCORE_EXPORT void removeServiceWorkerRegistrationInServer(const ServiceWorkerRegistrationKey&, ServiceWorkerRegistrationIdentifier);
+        WEBCORE_EXPORT void serviceWorkerStartedControllingClient(ServiceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier);
+        WEBCORE_EXPORT void serviceWorkerStoppedControllingClient(ServiceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier);
 
     private:
         // Messages to the client WebProcess
@@ -143,6 +145,8 @@ private:
 
     void addClientServiceWorkerRegistration(Connection&, const ServiceWorkerRegistrationKey&, ServiceWorkerRegistrationIdentifier);
     void removeClientServiceWorkerRegistration(Connection&, const ServiceWorkerRegistrationKey&, ServiceWorkerRegistrationIdentifier);
+    void serviceWorkerStartedControllingClient(Connection&, ServiceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier);
+    void serviceWorkerStoppedControllingClient(Connection&, ServiceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier);
 
     WEBCORE_EXPORT const SWServerRegistration* doRegistrationMatching(const SecurityOriginData& topOrigin, const URL& clientURL) const;
 
index b1e2791..16aa9f3 100644 (file)
@@ -339,7 +339,8 @@ void SWServerJobQueue::runUnregisterJob(const ServiceWorkerJobData& job)
 // https://w3c.github.io/ServiceWorker/#try-clear-registration-algorithm
 void SWServerJobQueue::tryClearRegistration(SWServerRegistration& registration)
 {
-    // FIXME: Make sure that the registration has no service worker client.
+    if (registration.hasClientsUsingRegistration())
+        return;
 
     if (registration.installingWorker() && registration.installingWorker()->hasPendingEvents())
         return;
index 0c15ace..998c90b 100644 (file)
@@ -144,6 +144,31 @@ void SWServerRegistration::removeClientServiceWorkerRegistration(uint64_t connec
     m_connectionsWithClientRegistrations.remove(connectionIdentifier);
 }
 
+void SWServerRegistration::addClientUsingRegistration(const ServiceWorkerClientIdentifier& clientIdentifier)
+{
+    auto addResult = m_clientsUsingRegistration.ensure(clientIdentifier.serverConnectionIdentifier, [] {
+        return HashSet<uint64_t> { };
+    }).iterator->value.add(clientIdentifier.scriptExecutionContextIdentifier);
+    ASSERT_UNUSED(addResult, addResult.isNewEntry);
+}
+
+void SWServerRegistration::removeClientUsingRegistration(const ServiceWorkerClientIdentifier& clientIdentifier)
+{
+    auto iterator = m_clientsUsingRegistration.find(clientIdentifier.serverConnectionIdentifier);
+    ASSERT(iterator != m_clientsUsingRegistration.end());
+    bool wasRemoved = iterator->value.remove(clientIdentifier.scriptExecutionContextIdentifier);
+    ASSERT_UNUSED(wasRemoved, wasRemoved);
+
+    if (iterator->value.isEmpty())
+        m_clientsUsingRegistration.remove(iterator);
+}
+
+void SWServerRegistration::unregisterServerConnection(uint64_t serverConnectionIdentifier)
+{
+    m_connectionsWithClientRegistrations.removeAll(serverConnectionIdentifier);
+    m_clientsUsingRegistration.remove(serverConnectionIdentifier);
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(SERVICE_WORKER)
index fe0e65a..c2312d8 100644 (file)
@@ -28,6 +28,7 @@
 #if ENABLE(SERVICE_WORKER)
 
 #include "SWServer.h"
+#include "ServiceWorkerClientIdentifier.h"
 #include "ServiceWorkerRegistrationData.h"
 #include "ServiceWorkerTypes.h"
 #include <wtf/HashCountedSet.h>
@@ -72,6 +73,11 @@ public:
 
     MonotonicTime creationTime() const { return m_creationTime; }
 
+    bool hasClientsUsingRegistration() const { return !m_clientsUsingRegistration.isEmpty(); }
+    void addClientUsingRegistration(const ServiceWorkerClientIdentifier&);
+    void removeClientUsingRegistration(const ServiceWorkerClientIdentifier&);
+    void unregisterServerConnection(uint64_t serverConnectionIdentifier);
+
 private:
     void forEachConnection(const WTF::Function<void(SWServer::Connection&)>&);
 
@@ -88,10 +94,11 @@ private:
 
     double m_lastUpdateTime { 0 };
     
-    HashCountedSet<uint64_t> m_connectionsWithClientRegistrations;
+    HashCountedSet<uint64_t /* serverConnectionIdentifier */> m_connectionsWithClientRegistrations;
     SWServer& m_server;
 
     MonotonicTime m_creationTime;
+    HashMap<uint64_t /* serverConnectionIdentifier */, HashSet<uint64_t /* scriptExecutionContextIdentifier */>> m_clientsUsingRegistration;
 };
 
 } // namespace WebCore
index 8218362..0b4bda2 100644 (file)
@@ -1,3 +1,16 @@
+2017-11-16  Chris Dumez  <cdumez@apple.com>
+
+        [Service Worker] Implement "Try Clear Registration" algorithm
+        https://bugs.webkit.org/show_bug.cgi?id=179791
+
+        Reviewed by Youenn Fablet.
+
+        * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in:
+        * WebProcess/Storage/WebSWClientConnection.cpp:
+        (WebKit::WebSWClientConnection::serviceWorkerStartedControllingClient):
+        (WebKit::WebSWClientConnection::serviceWorkerStoppedControllingClient):
+        * WebProcess/Storage/WebSWClientConnection.h:
+
 2017-11-16  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         REGRESSION(r224179): layer flush now requires sync IPC to compute undo/redo availability in EditorState
index 0a8a48e..a881186 100644 (file)
@@ -28,6 +28,8 @@ messages -> WebSWServerConnection {
     FinishFetchingScriptInServer(struct WebCore::ServiceWorkerFetchResult result)
     AddServiceWorkerRegistrationInServer(WebCore::ServiceWorkerRegistrationKey key, WebCore::ServiceWorkerRegistrationIdentifier identifier)
     RemoveServiceWorkerRegistrationInServer(WebCore::ServiceWorkerRegistrationKey key, WebCore::ServiceWorkerRegistrationIdentifier identifier)
+    ServiceWorkerStartedControllingClient(WebCore::ServiceWorkerIdentifier serviceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier)
+    ServiceWorkerStoppedControllingClient(WebCore::ServiceWorkerIdentifier serviceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier)
 
     StartFetch(uint64_t identifier, std::optional<WebCore::ServiceWorkerIdentifier> serviceWorkerIdentifier, WebCore::ResourceRequest request, struct WebCore::FetchOptions options)
     PostMessageToServiceWorkerGlobalScope(WebCore::ServiceWorkerIdentifier destinationServiceWorkerIdentifier, IPC::DataReference message, struct WebCore::ServiceWorkerClientData source)
index 43c5769..71b3b00 100644 (file)
@@ -86,6 +86,16 @@ void WebSWClientConnection::postMessageToServiceWorkerGlobalScope(ServiceWorkerI
     send(Messages::WebSWServerConnection::PostMessageToServiceWorkerGlobalScope(destinationIdentifier, IPC::DataReference { scriptValue->data() }, WTFMove(source)));
 }
 
+void WebSWClientConnection::serviceWorkerStartedControllingClient(ServiceWorkerIdentifier serviceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier)
+{
+    send(Messages::WebSWServerConnection::ServiceWorkerStartedControllingClient(serviceWorkerIdentifier, scriptExecutionContextIdentifier));
+}
+
+void WebSWClientConnection::serviceWorkerStoppedControllingClient(ServiceWorkerIdentifier serviceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier)
+{
+    send(Messages::WebSWServerConnection::ServiceWorkerStoppedControllingClient(serviceWorkerIdentifier, scriptExecutionContextIdentifier));
+}
+
 void WebSWClientConnection::didResolveRegistrationPromise(const ServiceWorkerRegistrationKey& key)
 {
     send(Messages::WebSWServerConnection::DidResolveRegistrationPromise(key));
index bbd0efd..b4075a2 100644 (file)
@@ -69,6 +69,8 @@ private:
     void scheduleJobInServer(const WebCore::ServiceWorkerJobData&) final;
     void finishFetchingScriptInServer(const WebCore::ServiceWorkerFetchResult&) final;
     void postMessageToServiceWorkerGlobalScope(WebCore::ServiceWorkerIdentifier destinationIdentifier, Ref<WebCore::SerializedScriptValue>&&, WebCore::ServiceWorkerClientData&& source) final;
+    void serviceWorkerStartedControllingClient(WebCore::ServiceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier) final;
+    void serviceWorkerStoppedControllingClient(WebCore::ServiceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier) final;
 
     void matchRegistration(const WebCore::SecurityOrigin& topOrigin, const WebCore::URL& clientURL, RegistrationCallback&&) final;
     void didMatchRegistration(uint64_t matchRequestIdentifier, std::optional<WebCore::ServiceWorkerRegistrationData>&&);