Title: [225460] trunk
Revision
225460
Author
[email protected]
Date
2017-12-03 12:32:57 -0800 (Sun, 03 Dec 2017)

Log Message

Implement self.skipWaiting() inside service workers
https://bugs.webkit.org/show_bug.cgi?id=180329

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Rebaseline WPT tests that are now passing.

* web-platform-tests/service-workers/service-worker/ServiceWorkerGlobalScope/update.https-expected.txt:
* web-platform-tests/service-workers/service-worker/claim-with-redirect.https-expected.txt:
* web-platform-tests/service-workers/service-worker/postmessage-from-waiting-serviceworker.https-expected.txt:
* web-platform-tests/service-workers/service-worker/skip-waiting-without-client.https-expected.txt:

Source/WebCore:

Implement self.skipWaiting() inside service workers:
- https://w3c.github.io/ServiceWorker/#service-worker-global-scope-skipwaiting

Also fixes a bug where tryActivate() was calling activate() even though the
registration's active worker was "in use":
- https://w3c.github.io/ServiceWorker/#try-activate-algorithm

No new tests, rebaselined existing tests.

* workers/service/ServiceWorkerGlobalScope.cpp:
(WebCore::ServiceWorkerGlobalScope::skipWaiting):
* workers/service/context/SWContextManager.h:
* workers/service/server/SWServerRegistration.cpp:
(WebCore::SWServerRegistration::tryActivate):
* workers/service/server/SWServerToContextConnection.cpp:
(WebCore::SWServerToContextConnection::skipWaiting):
* workers/service/server/SWServerToContextConnection.h:
* workers/service/server/SWServerWorker.cpp:
(WebCore::SWServerWorker::skipWaiting):
* workers/service/server/SWServerWorker.h:
(WebCore::SWServerWorker::isSkipWaitingFlagSet const):

Source/WebKit:

* StorageProcess/ServiceWorker/WebSWServerToContextConnection.cpp:
(WebKit::WebSWServerToContextConnection::didFinishSkipWaiting):
* StorageProcess/ServiceWorker/WebSWServerToContextConnection.h:
* StorageProcess/ServiceWorker/WebSWServerToContextConnection.messages.in:
* WebProcess/Storage/WebSWContextManagerConnection.cpp:
(WebKit::WebSWContextManagerConnection::skipWaiting):
(WebKit::WebSWContextManagerConnection::didFinishSkipWaiting):
* WebProcess/Storage/WebSWContextManagerConnection.h:
* WebProcess/Storage/WebSWContextManagerConnection.messages.in:

LayoutTests:

* http/tests/workers/service/resources/service-worker-fetch-worker.js:
add self.skipWaiting() now that we properly wait when the registation's
active worker is in use. This is needed because this worker script is
used by http/tests/workers/service/controller-change.html. The
'controllerchange' event is only fired if an active worker is being
replaced while in use due to the waiting worker calling skipWaiting().

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (225459 => 225460)


--- trunk/LayoutTests/ChangeLog	2017-12-03 09:08:42 UTC (rev 225459)
+++ trunk/LayoutTests/ChangeLog	2017-12-03 20:32:57 UTC (rev 225460)
@@ -1,3 +1,17 @@
+2017-12-03  Chris Dumez  <[email protected]>
+
+        Implement self.skipWaiting() inside service workers
+        https://bugs.webkit.org/show_bug.cgi?id=180329
+
+        Reviewed by Darin Adler.
+
+        * http/tests/workers/service/resources/service-worker-fetch-worker.js:
+        add self.skipWaiting() now that we properly wait when the registation's
+        active worker is in use. This is needed because this worker script is
+        used by http/tests/workers/service/controller-change.html. The
+        'controllerchange' event is only fired if an active worker is being
+        replaced while in use due to the waiting worker calling skipWaiting().
+
 2017-12-02  Chris Dumez  <[email protected]>
 
         Support container.register() / registration.unregister() /  inside service workers

Modified: trunk/LayoutTests/http/tests/workers/service/resources/service-worker-fetch-worker.js (225459 => 225460)


--- trunk/LayoutTests/http/tests/workers/service/resources/service-worker-fetch-worker.js	2017-12-03 09:08:42 UTC (rev 225459)
+++ trunk/LayoutTests/http/tests/workers/service/resources/service-worker-fetch-worker.js	2017-12-03 20:32:57 UTC (rev 225460)
@@ -1,4 +1,7 @@
 var status = "no status";
+
+self.skipWaiting();
+
 self.addEventListener("fetch", (event) => {
     if (event.request.url.indexOf("status") !== -1) {
         event.respondWith(new Response(null, {status: 200, statusText: status}));

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (225459 => 225460)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2017-12-03 09:08:42 UTC (rev 225459)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2017-12-03 20:32:57 UTC (rev 225460)
@@ -1,3 +1,17 @@
+2017-12-03  Chris Dumez  <[email protected]>
+
+        Implement self.skipWaiting() inside service workers
+        https://bugs.webkit.org/show_bug.cgi?id=180329
+
+        Reviewed by Darin Adler.
+
+        Rebaseline WPT tests that are now passing.
+
+        * web-platform-tests/service-workers/service-worker/ServiceWorkerGlobalScope/update.https-expected.txt:
+        * web-platform-tests/service-workers/service-worker/claim-with-redirect.https-expected.txt:
+        * web-platform-tests/service-workers/service-worker/postmessage-from-waiting-serviceworker.https-expected.txt:
+        * web-platform-tests/service-workers/service-worker/skip-waiting-without-client.https-expected.txt:
+
 2017-12-02  Chris Dumez  <[email protected]>
 
         Support container.register() / registration.unregister() /  inside service workers

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/ServiceWorkerGlobalScope/update.https-expected.txt (225459 => 225460)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/ServiceWorkerGlobalScope/update.https-expected.txt	2017-12-03 09:08:42 UTC (rev 225459)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/ServiceWorkerGlobalScope/update.https-expected.txt	2017-12-03 20:32:57 UTC (rev 225460)
@@ -1,4 +1,3 @@
 
+PASS Update a registration on ServiceWorkerGlobalScope 
 
-FAIL Update a registration on ServiceWorkerGlobalScope assert_equals: events seen by the worker expected "updatefound,activate,fetch,message,updatefound,fetch" but got "updatefound,activate,fetch"
-

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/claim-with-redirect.https-expected.txt (225459 => 225460)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/claim-with-redirect.https-expected.txt	2017-12-03 09:08:42 UTC (rev 225459)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/claim-with-redirect.https-expected.txt	2017-12-03 20:32:57 UTC (rev 225460)
@@ -1,5 +1,4 @@
-CONSOLE MESSAGE: line 27: Unhandled Promise Rejection: TypeError: undefined is not an object (evaluating 'r.update')
   
 
-FAIL Claim works after redirection to another origin assert_equals: expected (string) "updated" but got (undefined) undefined
+PASS Claim works after redirection to another origin 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/postmessage-from-waiting-serviceworker.https-expected.txt (225459 => 225460)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/postmessage-from-waiting-serviceworker.https-expected.txt	2017-12-03 09:08:42 UTC (rev 225459)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/postmessage-from-waiting-serviceworker.https-expected.txt	2017-12-03 20:32:57 UTC (rev 225460)
@@ -1,4 +1,3 @@
 
+PASS Client.postMessage() from waiting serviceworker. 
 
-FAIL Client.postMessage() from waiting serviceworker. assert_unreached: unexpected rejection: assert_equals: message event source should be correct expected null but got object "[object ServiceWorker]" Reached unreachable code
-

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/skip-waiting-without-client.https-expected.txt (225459 => 225460)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/skip-waiting-without-client.https-expected.txt	2017-12-03 09:08:42 UTC (rev 225459)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/skip-waiting-without-client.https-expected.txt	2017-12-03 20:32:57 UTC (rev 225460)
@@ -1,4 +1,4 @@
 
 PASS Test single skipWaiting() when no client attached 
-FAIL skipWaiting promise_test: Unhandled rejection with value: object "NotSupportedError: self.skipWaiting() is not yet supported"
+PASS skipWaiting 
 

Modified: trunk/Source/WebCore/ChangeLog (225459 => 225460)


--- trunk/Source/WebCore/ChangeLog	2017-12-03 09:08:42 UTC (rev 225459)
+++ trunk/Source/WebCore/ChangeLog	2017-12-03 20:32:57 UTC (rev 225460)
@@ -1,3 +1,32 @@
+2017-12-03  Chris Dumez  <[email protected]>
+
+        Implement self.skipWaiting() inside service workers
+        https://bugs.webkit.org/show_bug.cgi?id=180329
+
+        Reviewed by Darin Adler.
+
+        Implement self.skipWaiting() inside service workers:
+        - https://w3c.github.io/ServiceWorker/#service-worker-global-scope-skipwaiting
+
+        Also fixes a bug where tryActivate() was calling activate() even though the
+        registration's active worker was "in use":
+        - https://w3c.github.io/ServiceWorker/#try-activate-algorithm
+
+        No new tests, rebaselined existing tests.
+
+        * workers/service/ServiceWorkerGlobalScope.cpp:
+        (WebCore::ServiceWorkerGlobalScope::skipWaiting):
+        * workers/service/context/SWContextManager.h:
+        * workers/service/server/SWServerRegistration.cpp:
+        (WebCore::SWServerRegistration::tryActivate):
+        * workers/service/server/SWServerToContextConnection.cpp:
+        (WebCore::SWServerToContextConnection::skipWaiting):
+        * workers/service/server/SWServerToContextConnection.h:
+        * workers/service/server/SWServerWorker.cpp:
+        (WebCore::SWServerWorker::skipWaiting):
+        * workers/service/server/SWServerWorker.h:
+        (WebCore::SWServerWorker::isSkipWaitingFlagSet const):
+
 2017-12-03  Carlos Garcia Campos  <[email protected]>
 
         [GStreamer] GstPad leaked in WebKitTextCombiner

Modified: trunk/Source/WebCore/workers/service/ServiceWorkerGlobalScope.cpp (225459 => 225460)


--- trunk/Source/WebCore/workers/service/ServiceWorkerGlobalScope.cpp	2017-12-03 09:08:42 UTC (rev 225459)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerGlobalScope.cpp	2017-12-03 20:32:57 UTC (rev 225460)
@@ -50,8 +50,15 @@
 
 void ServiceWorkerGlobalScope::skipWaiting(Ref<DeferredPromise>&& promise)
 {
-    // FIXME: Implement this.
-    promise->reject(Exception { NotSupportedError, ASCIILiteral("self.skipWaiting() is not yet supported") });
+    callOnMainThread([this, protectedThis = makeRef(*this), threadIdentifier = thread().identifier(), promise = WTFMove(promise)]() mutable {
+        if (auto* connection = SWContextManager::singleton().connection()) {
+            connection->skipWaiting(threadIdentifier, [this, protectedThis = WTFMove(protectedThis), promise = WTFMove(promise)]() mutable {
+                thread().runLoop().postTask([promise = WTFMove(promise), protectedThis = WTFMove(protectedThis)](auto&) {
+                    promise->resolve();
+                });
+            });
+        }
+    });
 }
 
 EventTargetInterface ServiceWorkerGlobalScope::eventTargetInterface() const

Modified: trunk/Source/WebCore/workers/service/context/SWContextManager.h (225459 => 225460)


--- trunk/Source/WebCore/workers/service/context/SWContextManager.h	2017-12-03 09:08:42 UTC (rev 225459)
+++ trunk/Source/WebCore/workers/service/context/SWContextManager.h	2017-12-03 20:32:57 UTC (rev 225460)
@@ -54,6 +54,7 @@
         virtual void didFinishActivation(ServiceWorkerIdentifier) = 0;
         virtual void setServiceWorkerHasPendingEvents(ServiceWorkerIdentifier, bool) = 0;
         virtual void workerTerminated(ServiceWorkerIdentifier) = 0;
+        virtual void skipWaiting(ServiceWorkerIdentifier, WTF::Function<void()>&& callback) = 0;
 
         using FindClientByIdentifierCallback = WTF::CompletionHandler<void(ExceptionOr<std::optional<ServiceWorkerClientData>>&&)>;
         virtual void findClientByIdentifier(ServiceWorkerIdentifier, ServiceWorkerClientIdentifier, FindClientByIdentifierCallback&&) = 0;

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


--- trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp	2017-12-03 09:08:42 UTC (rev 225459)
+++ trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp	2017-12-03 20:32:57 UTC (rev 225460)
@@ -232,9 +232,8 @@
     // Invoke Activate with registration if either of the following is true:
     // - registration's active worker is null.
     // - The result of running Service Worker Has No Pending Events with registration's active worker is true,
-    //   and no service worker client is using registration
-    // FIXME: Check for the skip waiting flag.
-    if (!activeWorker() || !activeWorker()->hasPendingEvents())
+    //   and no service worker client is using registration or registration's waiting worker's skip waiting flag is set.
+    if (!activeWorker() || (!activeWorker()->hasPendingEvents() && (!hasClientsUsingRegistration() || waitingWorker()->isSkipWaitingFlagSet())))
         activate();
 }
 

Modified: trunk/Source/WebCore/workers/service/server/SWServerToContextConnection.cpp (225459 => 225460)


--- trunk/Source/WebCore/workers/service/server/SWServerToContextConnection.cpp	2017-12-03 09:08:42 UTC (rev 225459)
+++ trunk/Source/WebCore/workers/service/server/SWServerToContextConnection.cpp	2017-12-03 20:32:57 UTC (rev 225460)
@@ -123,6 +123,14 @@
     }
 }
 
+void SWServerToContextConnection::skipWaiting(ServiceWorkerIdentifier serviceWorkerIdentifier, uint64_t callbackID)
+{
+    if (auto* worker = SWServerWorker::existingWorkerForIdentifier(serviceWorkerIdentifier))
+        worker->skipWaiting();
+
+    didFinishSkipWaiting(callbackID);
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(SERVICE_WORKER)

Modified: trunk/Source/WebCore/workers/service/server/SWServerToContextConnection.h (225459 => 225460)


--- trunk/Source/WebCore/workers/service/server/SWServerToContextConnection.h	2017-12-03 09:08:42 UTC (rev 225459)
+++ trunk/Source/WebCore/workers/service/server/SWServerToContextConnection.h	2017-12-03 20:32:57 UTC (rev 225460)
@@ -55,6 +55,7 @@
     virtual void syncTerminateWorker(ServiceWorkerIdentifier) = 0;
     virtual void findClientByIdentifierCompleted(uint64_t requestIdentifier, const std::optional<ServiceWorkerClientData>&, bool hasSecurityError) = 0;
     virtual void matchAllCompleted(uint64_t requestIdentifier, const Vector<ServiceWorkerClientInformation>&) = 0;
+    virtual void didFinishSkipWaiting(uint64_t callbackID) = 0;
 
     // Messages back from the SW host process
     WEBCORE_EXPORT void scriptContextFailedToStart(const std::optional<ServiceWorkerJobDataIdentifier>&, ServiceWorkerIdentifier, const String& message);
@@ -62,6 +63,7 @@
     WEBCORE_EXPORT void didFinishInstall(const std::optional<ServiceWorkerJobDataIdentifier>&, ServiceWorkerIdentifier, bool wasSuccessful);
     WEBCORE_EXPORT void didFinishActivation(ServiceWorkerIdentifier);
     WEBCORE_EXPORT void setServiceWorkerHasPendingEvents(ServiceWorkerIdentifier, bool hasPendingEvents);
+    WEBCORE_EXPORT void skipWaiting(ServiceWorkerIdentifier, uint64_t callbackID);
     WEBCORE_EXPORT void workerTerminated(ServiceWorkerIdentifier);
     WEBCORE_EXPORT void findClientByIdentifier(uint64_t clientIdRequestIdentifier, ServiceWorkerIdentifier, ServiceWorkerClientIdentifier);
     WEBCORE_EXPORT void matchAll(uint64_t requestIdentifier, ServiceWorkerIdentifier, const ServiceWorkerClientQueryOptions&);

Modified: trunk/Source/WebCore/workers/service/server/SWServerWorker.cpp (225459 => 225460)


--- trunk/Source/WebCore/workers/service/server/SWServerWorker.cpp	2017-12-03 09:08:42 UTC (rev 225459)
+++ trunk/Source/WebCore/workers/service/server/SWServerWorker.cpp	2017-12-03 20:32:57 UTC (rev 225460)
@@ -116,6 +116,15 @@
     return m_server.matchAll(*this, options, WTFMove(callback));
 }
 
+void SWServerWorker::skipWaiting()
+{
+    m_isSkipWaitingFlagSet = true;
+
+    auto* registration = m_server.getRegistration(m_registrationKey);
+    ASSERT(registration);
+    registration->tryActivate();
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(SERVICE_WORKER)

Modified: trunk/Source/WebCore/workers/service/server/SWServerWorker.h (225459 => 225460)


--- trunk/Source/WebCore/workers/service/server/SWServerWorker.h	2017-12-03 09:08:42 UTC (rev 225459)
+++ trunk/Source/WebCore/workers/service/server/SWServerWorker.h	2017-12-03 20:32:57 UTC (rev 225460)
@@ -91,6 +91,9 @@
     std::optional<ServiceWorkerClientData> findClientByIdentifier(ServiceWorkerClientIdentifier);
     void matchAll(const ServiceWorkerClientQueryOptions&, ServiceWorkerClientsMatchAllCallback&&);
 
+    void skipWaiting();
+    bool isSkipWaitingFlagSet() const { return m_isSkipWaitingFlagSet; }
+
     WEBCORE_EXPORT static SWServerWorker* existingWorkerForIdentifier(ServiceWorkerIdentifier);
 
     const ServiceWorkerData& data() const { return m_data; }
@@ -108,6 +111,7 @@
     bool m_hasPendingEvents { false };
     State m_state { State::NotRunning };
     mutable std::optional<ClientOrigin> m_origin;
+    bool m_isSkipWaitingFlagSet { false };
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebKit/ChangeLog (225459 => 225460)


--- trunk/Source/WebKit/ChangeLog	2017-12-03 09:08:42 UTC (rev 225459)
+++ trunk/Source/WebKit/ChangeLog	2017-12-03 20:32:57 UTC (rev 225460)
@@ -1,3 +1,20 @@
+2017-12-03  Chris Dumez  <[email protected]>
+
+        Implement self.skipWaiting() inside service workers
+        https://bugs.webkit.org/show_bug.cgi?id=180329
+
+        Reviewed by Darin Adler.
+
+        * StorageProcess/ServiceWorker/WebSWServerToContextConnection.cpp:
+        (WebKit::WebSWServerToContextConnection::didFinishSkipWaiting):
+        * StorageProcess/ServiceWorker/WebSWServerToContextConnection.h:
+        * StorageProcess/ServiceWorker/WebSWServerToContextConnection.messages.in:
+        * WebProcess/Storage/WebSWContextManagerConnection.cpp:
+        (WebKit::WebSWContextManagerConnection::skipWaiting):
+        (WebKit::WebSWContextManagerConnection::didFinishSkipWaiting):
+        * WebProcess/Storage/WebSWContextManagerConnection.h:
+        * WebProcess/Storage/WebSWContextManagerConnection.messages.in:
+
 2017-12-02  Youenn Fablet  <[email protected]>
 
         Implement https://w3c.github.io/ServiceWorker/#clients-getall

Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerToContextConnection.cpp (225459 => 225460)


--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerToContextConnection.cpp	2017-12-03 09:08:42 UTC (rev 225459)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerToContextConnection.cpp	2017-12-03 20:32:57 UTC (rev 225460)
@@ -91,6 +91,11 @@
     send(Messages::WebSWContextManagerConnection::MatchAllCompleted { requestIdentifier, clientsData });
 }
 
+void WebSWServerToContextConnection::didFinishSkipWaiting(uint64_t callbackID)
+{
+    send(Messages::WebSWContextManagerConnection::DidFinishSkipWaiting { callbackID });
+}
+
 } // namespace WebKit
 
 #endif // ENABLE(SERVICE_WORKER)

Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerToContextConnection.h (225459 => 225460)


--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerToContextConnection.h	2017-12-03 09:08:42 UTC (rev 225459)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerToContextConnection.h	2017-12-03 20:32:57 UTC (rev 225460)
@@ -62,6 +62,7 @@
     void syncTerminateWorker(WebCore::ServiceWorkerIdentifier) final;
     void findClientByIdentifierCompleted(uint64_t requestIdentifier, const std::optional<WebCore::ServiceWorkerClientData>&, bool hasSecurityError) final;
     void matchAllCompleted(uint64_t requestIdentifier, const Vector<WebCore::ServiceWorkerClientInformation>&) final;
+    void didFinishSkipWaiting(uint64_t callbackID) final;
 
     Ref<IPC::Connection> m_ipcConnection;
     

Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerToContextConnection.messages.in (225459 => 225460)


--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerToContextConnection.messages.in	2017-12-03 09:08:42 UTC (rev 225459)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerToContextConnection.messages.in	2017-12-03 20:32:57 UTC (rev 225460)
@@ -30,6 +30,7 @@
     DidFinishInstall(std::optional<WebCore::ServiceWorkerJobDataIdentifier> jobDataIdentifier, WebCore::ServiceWorkerIdentifier serviceWorkerIdentifier, bool wasSuccessful);
     DidFinishActivation(WebCore::ServiceWorkerIdentifier identifier);
     SetServiceWorkerHasPendingEvents(WebCore::ServiceWorkerIdentifier identifier, bool hasPendingEvents);
+    SkipWaiting(WebCore::ServiceWorkerIdentifier identifier, uint64_t callbackID)
     WorkerTerminated(WebCore::ServiceWorkerIdentifier identifier);
     FindClientByIdentifier(uint64_t requestIdentifier, WebCore::ServiceWorkerIdentifier serviceWorkerIdentifier, struct WebCore::ServiceWorkerClientIdentifier clientIdentifier);
     MatchAll(uint64_t matchAllRequestIdentifier, WebCore::ServiceWorkerIdentifier serviceWorkerIdentifier, struct WebCore::ServiceWorkerClientQueryOptions options);

Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp (225459 => 225460)


--- trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp	2017-12-03 09:08:42 UTC (rev 225459)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp	2017-12-03 20:32:57 UTC (rev 225460)
@@ -197,6 +197,13 @@
     m_connectionToStorageProcess->send(Messages::WebSWServerToContextConnection::SetServiceWorkerHasPendingEvents(serviceWorkerIdentifier, hasPendingEvents), 0);
 }
 
+void WebSWContextManagerConnection::skipWaiting(ServiceWorkerIdentifier serviceWorkerIdentifier, WTF::Function<void()>&& callback)
+{
+    auto callbackID = ++m_previousRequestIdentifier;
+    m_skipWaitingRequests.add(callbackID, WTFMove(callback));
+    m_connectionToStorageProcess->send(Messages::WebSWServerToContextConnection::SkipWaiting(serviceWorkerIdentifier, callbackID), 0);
+}
+
 void WebSWContextManagerConnection::workerTerminated(ServiceWorkerIdentifier serviceWorkerIdentifier)
 {
     m_connectionToStorageProcess->send(Messages::WebSWServerToContextConnection::WorkerTerminated(serviceWorkerIdentifier), 0);
@@ -233,6 +240,12 @@
         callback(WTFMove(clientsData));
 }
 
+void WebSWContextManagerConnection::didFinishSkipWaiting(uint64_t callbackID)
+{
+    if (auto callback = m_skipWaitingRequests.take(callbackID))
+        callback();
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(SERVICE_WORKER)

Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h (225459 => 225460)


--- trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h	2017-12-03 09:08:42 UTC (rev 225459)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h	2017-12-03 20:32:57 UTC (rev 225460)
@@ -66,6 +66,7 @@
     void workerTerminated(WebCore::ServiceWorkerIdentifier) final;
     void findClientByIdentifier(WebCore::ServiceWorkerIdentifier, WebCore::ServiceWorkerClientIdentifier, FindClientByIdentifierCallback&&) final;
     void matchAll(WebCore::ServiceWorkerIdentifier, const WebCore::ServiceWorkerClientQueryOptions&, WebCore::ServiceWorkerClientsMatchAllCallback&&) final;
+    void skipWaiting(WebCore::ServiceWorkerIdentifier, WTF::Function<void()>&& callback) final;
 
     // IPC messages.
     void serviceWorkerStartedWithMessage(std::optional<WebCore::ServiceWorkerJobDataIdentifier>, WebCore::ServiceWorkerIdentifier, const String& exceptionMessage) final;
@@ -78,6 +79,7 @@
     void syncTerminateWorker(WebCore::ServiceWorkerIdentifier, Ref<Messages::WebSWContextManagerConnection::SyncTerminateWorker::DelayedReply>&&);
     void findClientByIdentifierCompleted(uint64_t requestIdentifier, std::optional<WebCore::ServiceWorkerClientData>&&, bool hasSecurityError);
     void matchAllCompleted(uint64_t matchAllRequestIdentifier, Vector<WebCore::ServiceWorkerClientInformation>&&);
+    void didFinishSkipWaiting(uint64_t callbackID);
 
     Ref<IPC::Connection> m_connectionToStorageProcess;
     uint64_t m_pageID { 0 };
@@ -85,6 +87,7 @@
 
     HashMap<uint64_t, FindClientByIdentifierCallback> m_findClientByIdentifierRequests;
     HashMap<uint64_t, WebCore::ServiceWorkerClientsMatchAllCallback> m_matchAllRequests;
+    HashMap<uint64_t, WTF::Function<void()>> m_skipWaitingRequests;
     uint64_t m_previousRequestIdentifier { 0 };
 };
 

Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.messages.in (225459 => 225460)


--- trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.messages.in	2017-12-03 09:08:42 UTC (rev 225459)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.messages.in	2017-12-03 20:32:57 UTC (rev 225460)
@@ -32,6 +32,7 @@
     SyncTerminateWorker(WebCore::ServiceWorkerIdentifier identifier) -> () Delayed
     FindClientByIdentifierCompleted(uint64_t clientIdRequestIdentifier, std::optional<WebCore::ServiceWorkerClientData> data, bool hasSecurityError)
     MatchAllCompleted(uint64_t matchAllRequestIdentifier, Vector<WebCore::ServiceWorkerClientInformation> clientsData)
+    DidFinishSkipWaiting(uint64_t callbackID)
 }
 
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to