Add support for ServiceWorkerContainer.prototype.ready
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Dec 2017 20:56:13 +0000 (20:56 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Dec 2017 20:56:13 +0000 (20:56 +0000)
https://bugs.webkit.org/show_bug.cgi?id=180383

Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

Rebaseline WPT test coverage container.ready now that it is passing.

* web-platform-tests/service-workers/service-worker/ready.https-expected.txt:

Source/WebCore:

Add support for ServiceWorkerContainer.prototype.ready:
- https://w3c.github.io/ServiceWorker/#navigator-service-worker-ready

No new tests, rebaselined existing test.

* workers/service/SWClientConnection.h:
* workers/service/ServiceWorkerContainer.cpp:
(WebCore::ServiceWorkerContainer::ServiceWorkerContainer):
(WebCore::ServiceWorkerContainer::ready):
* workers/service/ServiceWorkerContainer.h:
* workers/service/ServiceWorkerRegistrationKey.h:
* workers/service/server/SWServer.cpp:
(WebCore::SWServer::resolveRegistrationReadyRequests):
* workers/service/server/SWServer.h:
* workers/service/server/SWServerRegistration.cpp:
(WebCore::SWServerRegistration::activate):
(WebCore::SWServerRegistration::setIsUninstalling):
* workers/service/server/SWServerRegistration.h:

Source/WebKit:

* StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
(WebKit::WebSWServerConnection::whenRegistrationReady):
(WebKit::WebSWServerConnection::resolveRegistrationReadyRequests):
* StorageProcess/ServiceWorker/WebSWServerConnection.h:
* StorageProcess/ServiceWorker/WebSWServerConnection.messages.in:
* WebProcess/Storage/WebSWClientConnection.cpp:
(WebKit::WebSWClientConnection::matchRegistration):
(WebKit::WebSWClientConnection::whenRegistrationReady):
(WebKit::WebSWClientConnection::registrationReady):
(WebKit::WebSWClientConnection::getRegistrations):
* WebProcess/Storage/WebSWClientConnection.h:
* WebProcess/Storage/WebSWClientConnection.messages.in:

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

18 files changed:
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/ready.https-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/workers/service/SWClientConnection.h
Source/WebCore/workers/service/ServiceWorkerContainer.cpp
Source/WebCore/workers/service/ServiceWorkerContainer.h
Source/WebCore/workers/service/ServiceWorkerRegistrationKey.h
Source/WebCore/workers/service/server/SWServer.cpp
Source/WebCore/workers/service/server/SWServer.h
Source/WebCore/workers/service/server/SWServerRegistration.cpp
Source/WebCore/workers/service/server/SWServerRegistration.h
Source/WebKit/ChangeLog
Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp
Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h
Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in
Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp
Source/WebKit/WebProcess/Storage/WebSWClientConnection.h
Source/WebKit/WebProcess/Storage/WebSWClientConnection.messages.in

index b88efb2..7795346 100644 (file)
@@ -1,3 +1,14 @@
+2017-12-05  Chris Dumez  <cdumez@apple.com>
+
+        Add support for ServiceWorkerContainer.prototype.ready
+        https://bugs.webkit.org/show_bug.cgi?id=180383
+
+        Reviewed by Youenn Fablet.
+
+        Rebaseline WPT test coverage container.ready now that it is passing.
+
+        * web-platform-tests/service-workers/service-worker/ready.https-expected.txt:
+
 2017-12-04  Chris Dumez  <cdumez@apple.com>
 
         Support container.getRegistration() / getRegistrations() inside service workers
index 0489417..f5884c2 100644 (file)
@@ -1,14 +1,11 @@
-CONSOLE MESSAGE: Unhandled Promise Rejection: UnknownError: serviceWorker.ready() is not yet implemented
-
-Harness Error (FAIL), message = serviceWorker.ready() is not yet implemented
 
 PASS ready returns the same Promise object 
 PASS ready returns a Promise object in the context of the related document 
-FAIL ready on a controlled document promise_test: Unhandled rejection with value: object "UnknownError: serviceWorker.ready() is not yet implemented"
-FAIL ready on a potential controlled document promise_test: Unhandled rejection with value: object "UnknownError: serviceWorker.ready() is not yet implemented"
-FAIL ready on an iframe whose parent registers a new service worker promise_test: Unhandled rejection with value: object "UnknownError: serviceWorker.ready() is not yet implemented"
-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 promise_test: Unhandled rejection with value: object "UnknownError: serviceWorker.ready() is not yet implemented"
+PASS ready on a controlled document 
+PASS ready on a potential controlled document 
+PASS ready on an iframe whose parent registers a new service worker 
+PASS ready on an iframe that installs a new service worker 
+PASS ready after a longer matched registration registered 
+PASS access ready after it has been resolved 
+PASS access ready on uninstalling registration that is resurrected 
 
index 6b0f3cd..2741699 100644 (file)
@@ -1,3 +1,29 @@
+2017-12-05  Chris Dumez  <cdumez@apple.com>
+
+        Add support for ServiceWorkerContainer.prototype.ready
+        https://bugs.webkit.org/show_bug.cgi?id=180383
+
+        Reviewed by Youenn Fablet.
+
+        Add support for ServiceWorkerContainer.prototype.ready:
+        - https://w3c.github.io/ServiceWorker/#navigator-service-worker-ready
+
+        No new tests, rebaselined existing test.
+
+        * workers/service/SWClientConnection.h:
+        * workers/service/ServiceWorkerContainer.cpp:
+        (WebCore::ServiceWorkerContainer::ServiceWorkerContainer):
+        (WebCore::ServiceWorkerContainer::ready):
+        * workers/service/ServiceWorkerContainer.h:
+        * workers/service/ServiceWorkerRegistrationKey.h:
+        * workers/service/server/SWServer.cpp:
+        (WebCore::SWServer::resolveRegistrationReadyRequests):
+        * workers/service/server/SWServer.h:
+        * workers/service/server/SWServerRegistration.cpp:
+        (WebCore::SWServerRegistration::activate):
+        (WebCore::SWServerRegistration::setIsUninstalling):
+        * workers/service/server/SWServerRegistration.h:
+
 2017-12-05  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         Modernize WebThread code for further refactoring
index e58b7e6..4714205 100644 (file)
@@ -62,6 +62,9 @@ public:
     using GetRegistrationsCallback = WTF::CompletionHandler<void(Vector<ServiceWorkerRegistrationData>&&)>;
     virtual void getRegistrations(const SecurityOrigin& topOrigin, const URL& clientURL, GetRegistrationsCallback&&) = 0;
 
+    using WhenRegistrationReadyCallback = WTF::Function<void(ServiceWorkerRegistrationData&&)>;
+    virtual void whenRegistrationReady(const SecurityOrigin& topOrigin, const URL& clientURL, WhenRegistrationReadyCallback&&) = 0;
+
     virtual void addServiceWorkerRegistrationInServer(ServiceWorkerRegistrationIdentifier) = 0;
     virtual void removeServiceWorkerRegistrationInServer(ServiceWorkerRegistrationIdentifier) = 0;
 
index 85daf2e..cc24d31 100644 (file)
@@ -57,8 +57,6 @@ ServiceWorkerContainer::ServiceWorkerContainer(ScriptExecutionContext& context,
     , m_navigator(navigator)
 {
     suspendIfNeeded();
-
-    m_readyPromise.reject(Exception { UnknownError, ASCIILiteral("serviceWorker.ready() is not yet implemented") });
 }
 
 ServiceWorkerContainer::~ServiceWorkerContainer()
@@ -78,6 +76,31 @@ void ServiceWorkerContainer::derefEventTarget()
     m_navigator.deref();
 }
 
+auto ServiceWorkerContainer::ready() -> ReadyPromise&
+{
+    if (!m_readyPromise) {
+        m_readyPromise = std::make_unique<ReadyPromise>();
+
+        auto* context = scriptExecutionContext();
+        if (!context)
+            return *m_readyPromise;
+
+        auto contextIdentifier = this->contextIdentifier();
+        callOnMainThread([this, connection = makeRef(ensureSWClientConnection()), topOrigin = context->topOrigin().isolatedCopy(), clientURL = context->url().isolatedCopy(), contextIdentifier]() mutable {
+            connection->whenRegistrationReady(topOrigin, clientURL, [this, contextIdentifier](auto&& registrationData) {
+                ScriptExecutionContext::postTaskTo(contextIdentifier, [this, registrationData = crossThreadCopy(registrationData)](auto&) mutable {
+                    if (m_isStopped)
+                        return;
+
+                    auto registration = ServiceWorkerRegistration::getOrCreate(*scriptExecutionContext(), *this, WTFMove(registrationData));
+                    m_readyPromise->resolve(WTFMove(registration));
+                });
+            });
+        });
+    }
+    return *m_readyPromise;
+}
+
 ServiceWorker* ServiceWorkerContainer::controller() const
 {
     auto* context = scriptExecutionContext();
index 14163f9..7f7ce82 100644 (file)
@@ -56,7 +56,7 @@ public:
     ServiceWorker* controller() const;
 
     using ReadyPromise = DOMPromiseProxy<IDLInterface<ServiceWorkerRegistration>>;
-    ReadyPromise& ready() { return m_readyPromise; }
+    ReadyPromise& ready();
 
     using RegistrationOptions = ServiceWorkerRegistrationOptions;
     void addRegistration(const String& scriptURL, const RegistrationOptions&, Ref<DeferredPromise>&&);
@@ -110,7 +110,7 @@ private:
     void derefEventTarget() final;
     void stop() final;
 
-    ReadyPromise m_readyPromise;
+    std::unique_ptr<ReadyPromise> m_readyPromise;
 
     NavigatorBase& m_navigator;
 
index 429824f..cd3c5be 100644 (file)
@@ -41,7 +41,7 @@ public:
     unsigned hash() const;
 
     bool operator==(const ServiceWorkerRegistrationKey&) const;
-    bool isMatching(const SecurityOriginData& topOrigin, const URL& clientURL) const;
+    WEBCORE_EXPORT bool isMatching(const SecurityOriginData& topOrigin, const URL& clientURL) const;
     bool originIsMatching(const SecurityOriginData& topOrigin, const URL& clientURL) const;
     size_t scopeLength() const { return m_scope.string().length(); }
 
index 2bcb9b5..2959c62 100644 (file)
@@ -644,6 +644,34 @@ void SWServer::unregisterServiceWorkerClient(const ClientOrigin& clientOrigin, S
     m_clientToControllingWorker.remove(workerIterator);
 }
 
+void SWServer::resolveRegistrationReadyRequests(SWServerRegistration& registration)
+{
+    for (auto* connection : m_connections.values())
+        connection->resolveRegistrationReadyRequests(registration);
+}
+
+void SWServer::Connection::whenRegistrationReady(uint64_t registrationReadyRequestIdentifier, const SecurityOriginData& topOrigin, const URL& clientURL)
+{
+    if (auto* registration = doRegistrationMatching(topOrigin, clientURL)) {
+        if (registration->activeWorker()) {
+            registrationReady(registrationReadyRequestIdentifier, registration->data());
+            return;
+        }
+    }
+    m_registrationReadyRequests.append({ topOrigin, clientURL, registrationReadyRequestIdentifier });
+}
+
+void SWServer::Connection::resolveRegistrationReadyRequests(SWServerRegistration& registration)
+{
+    m_registrationReadyRequests.removeAllMatching([&](auto& request) {
+        if (!registration.key().isMatching(request.topOrigin, request.clientURL))
+            return false;
+
+        registrationReady(request.identifier, registration.data());
+        return true;
+    });
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(SERVICE_WORKER)
index 56ac33a..8f38010 100644 (file)
@@ -75,12 +75,14 @@ public:
 
         WEBCORE_EXPORT void didResolveRegistrationPromise(const ServiceWorkerRegistrationKey&);
         const SWServerRegistration* doRegistrationMatching(const SecurityOriginData& topOrigin, const URL& clientURL) const { return m_server.doRegistrationMatching(topOrigin, clientURL); }
+        void resolveRegistrationReadyRequests(SWServerRegistration&);
 
         // Messages to the client WebProcess
         virtual void updateRegistrationStateInClient(ServiceWorkerRegistrationIdentifier, ServiceWorkerRegistrationState, const std::optional<ServiceWorkerData>&) = 0;
         virtual void updateWorkerStateInClient(ServiceWorkerIdentifier, ServiceWorkerState) = 0;
         virtual void fireUpdateFoundEvent(ServiceWorkerRegistrationIdentifier) = 0;
         virtual void notifyClientsOfControllerChange(const HashSet<DocumentIdentifier>& contextIdentifiers, const ServiceWorkerData& newController) = 0;
+        virtual void registrationReady(uint64_t registrationReadyRequestIdentifier, ServiceWorkerRegistrationData&&) = 0;
 
     protected:
         WEBCORE_EXPORT explicit Connection(SWServer&);
@@ -91,6 +93,7 @@ public:
         WEBCORE_EXPORT void addServiceWorkerRegistrationInServer(ServiceWorkerRegistrationIdentifier);
         WEBCORE_EXPORT void removeServiceWorkerRegistrationInServer(ServiceWorkerRegistrationIdentifier);
         WEBCORE_EXPORT void syncTerminateWorker(ServiceWorkerIdentifier);
+        WEBCORE_EXPORT void whenRegistrationReady(uint64_t registrationReadyRequestIdentifier, const SecurityOriginData& topOrigin, const URL& clientURL);
 
     private:
         // Messages to the client WebProcess
@@ -99,8 +102,15 @@ public:
         virtual void resolveUnregistrationJobInClient(const ServiceWorkerJobDataIdentifier&, const ServiceWorkerRegistrationKey&, bool registrationResult) = 0;
         virtual void startScriptFetchInClient(const ServiceWorkerJobDataIdentifier&) = 0;
 
+        struct RegistrationReadyRequest {
+            SecurityOriginData topOrigin;
+            URL clientURL;
+            uint64_t identifier;
+        };
+
         SWServer& m_server;
         Identifier m_identifier;
+        Vector<RegistrationReadyRequest> m_registrationReadyRequests;
     };
 
     WEBCORE_EXPORT explicit SWServer(UniqueRef<SWOriginStore>&&, const String& registrationDatabaseDirectory);
@@ -151,6 +161,7 @@ public:
     WEBCORE_EXPORT bool invokeRunServiceWorker(ServiceWorkerIdentifier);
 
     void setClientActiveWorker(ServiceWorkerClientIdentifier, ServiceWorkerIdentifier);
+    void resolveRegistrationReadyRequests(SWServerRegistration&);
 
 private:
     void registerConnection(Connection&);
index 8ea6fce..f52770f 100644 (file)
@@ -261,6 +261,9 @@ void SWServerRegistration::activate()
     updateWorkerState(*activeWorker(), ServiceWorkerState::Activating);
     // FIXME: For each service worker client whose creation URL matches registration's scope url...
 
+    // The registration now has an active worker so we need to check if there are any ready promises that were waiting for this.
+    m_server.resolveRegistrationReadyRequests(*this);
+
     // For each service worker client who is using registration:
     // - Set client's active worker to registration's active worker.
     for (auto keyValue : m_clientsUsingRegistration) {
@@ -297,6 +300,19 @@ void SWServerRegistration::handleClientUnload()
     tryActivate();
 }
 
+void SWServerRegistration::setIsUninstalling(bool value)
+{
+    if (m_uninstalling == value)
+        return;
+
+    m_uninstalling = value;
+
+    if (!m_uninstalling && activeWorker()) {
+        // Registration with active worker has been resurrected, we need to check if any ready promises were waiting for this.
+        m_server.resolveRegistrationReadyRequests(*this);
+    }
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(SERVICE_WORKER)
index 10e70ae..762749a 100644 (file)
@@ -56,7 +56,7 @@ public:
     WEBCORE_EXPORT ServiceWorkerRegistrationData data() const;
 
     bool isUninstalling() const { return m_uninstalling; }
-    void setIsUninstalling(bool value) { m_uninstalling = value; }
+    void setIsUninstalling(bool);
 
     void setLastUpdateTime(double time) { m_lastUpdateTime = time; }
     ServiceWorkerUpdateViaCache updateViaCache() const { return m_updateViaCache; }
index 83b00a2..322a5cd 100644 (file)
@@ -1,3 +1,23 @@
+2017-12-05  Chris Dumez  <cdumez@apple.com>
+
+        Add support for ServiceWorkerContainer.prototype.ready
+        https://bugs.webkit.org/show_bug.cgi?id=180383
+
+        Reviewed by Youenn Fablet.
+
+        * StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
+        (WebKit::WebSWServerConnection::whenRegistrationReady):
+        (WebKit::WebSWServerConnection::resolveRegistrationReadyRequests):
+        * StorageProcess/ServiceWorker/WebSWServerConnection.h:
+        * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in:
+        * WebProcess/Storage/WebSWClientConnection.cpp:
+        (WebKit::WebSWClientConnection::matchRegistration):
+        (WebKit::WebSWClientConnection::whenRegistrationReady):
+        (WebKit::WebSWClientConnection::registrationReady):
+        (WebKit::WebSWClientConnection::getRegistrations):
+        * WebProcess/Storage/WebSWClientConnection.h:
+        * WebProcess/Storage/WebSWClientConnection.messages.in:
+
 2017-12-05  Youenn Fablet  <youenn@apple.com>
 
         Implement setting of service worker to client in SWServer without going to WebProcess
index f220fa4..4340b7b 100644 (file)
@@ -198,6 +198,11 @@ void WebSWServerConnection::matchRegistration(uint64_t registrationMatchRequestI
     send(Messages::WebSWClientConnection::DidMatchRegistration { registrationMatchRequestIdentifier, std::nullopt });
 }
 
+void WebSWServerConnection::registrationReady(uint64_t registrationReadyRequestIdentifier, ServiceWorkerRegistrationData&& registrationData)
+{
+    send(Messages::WebSWClientConnection::RegistrationReady { registrationReadyRequestIdentifier, WTFMove(registrationData) });
+}
+
 void WebSWServerConnection::getRegistrations(uint64_t registrationMatchRequestIdentifier, const SecurityOriginData& topOrigin, const URL& clientURL)
 {
     auto registrations = server().getRegistrations(topOrigin, clientURL);
index fd00d1a..b650853 100644 (file)
@@ -77,6 +77,7 @@ private:
     void updateWorkerStateInClient(WebCore::ServiceWorkerIdentifier, WebCore::ServiceWorkerState) final;
     void fireUpdateFoundEvent(WebCore::ServiceWorkerRegistrationIdentifier) final;
     void notifyClientsOfControllerChange(const HashSet<WebCore::DocumentIdentifier>& contextIdentifiers, const WebCore::ServiceWorkerData& newController);
+    void registrationReady(uint64_t registrationReadyRequestIdentifier, WebCore::ServiceWorkerRegistrationData&&) final;
 
     void startFetch(uint64_t fetchIdentifier, std::optional<WebCore::ServiceWorkerIdentifier>, const WebCore::ResourceRequest&, const WebCore::FetchOptions&, const IPC::FormDataReference&);
 
@@ -95,11 +96,10 @@ private:
     template<typename U> void sendToContextProcess(U&& message);
 
     PAL::SessionID m_sessionID;
-
     Ref<IPC::Connection> m_contentConnection;
     RefPtr<IPC::Connection> m_contextConnection;
     HashMap<WebCore::DocumentIdentifier, WebCore::ClientOrigin> m_clientOrigins;
-}; // class WebSWServerConnection
+};
 
 } // namespace WebKit
 
index 6c734c8..337d5a2 100644 (file)
@@ -36,6 +36,7 @@ messages -> WebSWServerConnection {
     DidResolveRegistrationPromise(WebCore::ServiceWorkerRegistrationKey key)
 
     MatchRegistration(uint64_t serviceRegistrationMatchRequestIdentifier, struct WebCore::SecurityOriginData topOrigin, WebCore::URL clientURL)
+    WhenRegistrationReady(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, std::optional<WebCore::ServiceWorkerIdentifier> controllingServiceWorkerIdentifier)
     UnregisterServiceWorkerClient(WebCore::DocumentIdentifier identifier)
index bc91f36..66c10eb 100644 (file)
@@ -150,9 +150,23 @@ void WebSWClientConnection::matchRegistration(const SecurityOrigin& topOrigin, c
         return;
     }
 
-    uint64_t requestIdentifier = ++m_previousMatchRegistrationTaskIdentifier;
-    m_ongoingMatchRegistrationTasks.add(requestIdentifier, WTFMove(callback));
-    send(Messages::WebSWServerConnection::MatchRegistration(requestIdentifier, SecurityOriginData::fromSecurityOrigin(topOrigin), clientURL));
+    uint64_t callbackID = ++m_previousCallbackIdentifier;
+    m_ongoingMatchRegistrationTasks.add(callbackID, WTFMove(callback));
+    send(Messages::WebSWServerConnection::MatchRegistration(callbackID, SecurityOriginData::fromSecurityOrigin(topOrigin), clientURL));
+}
+
+void WebSWClientConnection::whenRegistrationReady(const SecurityOrigin& topOrigin, const URL& clientURL, WhenRegistrationReadyCallback&& callback)
+{
+    uint64_t callbackID = ++m_previousCallbackIdentifier;
+    m_ongoingRegistrationReadyTasks.add(callbackID, WTFMove(callback));
+    send(Messages::WebSWServerConnection::WhenRegistrationReady(callbackID, SecurityOriginData::fromSecurityOrigin(topOrigin), clientURL));
+}
+
+void WebSWClientConnection::registrationReady(uint64_t callbackID, WebCore::ServiceWorkerRegistrationData&& registrationData)
+{
+    ASSERT(registrationData.activeWorker);
+    if (auto callback = m_ongoingRegistrationReadyTasks.take(callbackID))
+        callback(WTFMove(registrationData));
 }
 
 void WebSWClientConnection::getRegistrations(const SecurityOrigin& topOrigin, const URL& clientURL, GetRegistrationsCallback&& callback)
@@ -164,9 +178,9 @@ void WebSWClientConnection::getRegistrations(const SecurityOrigin& topOrigin, co
         return;
     }
 
-    uint64_t requestIdentifier = ++m_previousGetRegistrationsTaskIdentifier;
-    m_ongoingGetRegistrationsTasks.add(requestIdentifier, WTFMove(callback));
-    send(Messages::WebSWServerConnection::GetRegistrations(requestIdentifier, SecurityOriginData::fromSecurityOrigin(topOrigin), clientURL));
+    uint64_t callbackID = ++m_previousCallbackIdentifier;
+    m_ongoingGetRegistrationsTasks.add(callbackID, WTFMove(callback));
+    send(Messages::WebSWServerConnection::GetRegistrations(callbackID, SecurityOriginData::fromSecurityOrigin(topOrigin), clientURL));
 }
 
 void WebSWClientConnection::startFetch(const ResourceLoader& loader, uint64_t identifier)
index 5b6e209..ca37d20 100644 (file)
@@ -81,6 +81,8 @@ private:
     void matchRegistration(const WebCore::SecurityOrigin& topOrigin, const WebCore::URL& clientURL, RegistrationCallback&&) final;
     void didMatchRegistration(uint64_t matchRequestIdentifier, std::optional<WebCore::ServiceWorkerRegistrationData>&&);
     void didGetRegistrations(uint64_t matchRequestIdentifier, Vector<WebCore::ServiceWorkerRegistrationData>&&);
+    void whenRegistrationReady(const WebCore::SecurityOrigin& topOrigin, const WebCore::URL& clientURL, WhenRegistrationReadyCallback&&) final;
+    void registrationReady(uint64_t callbackID, WebCore::ServiceWorkerRegistrationData&&);
 
     void getRegistrations(const WebCore::SecurityOrigin& topOrigin, const WebCore::URL& clientURL, GetRegistrationsCallback&&) final;
 
@@ -100,11 +102,10 @@ private:
     Ref<IPC::Connection> m_connection;
     UniqueRef<WebSWOriginTable> m_swOriginTable;
 
-    uint64_t m_previousMatchRegistrationTaskIdentifier { 0 };
+    uint64_t m_previousCallbackIdentifier { 0 };
     HashMap<uint64_t, RegistrationCallback> m_ongoingMatchRegistrationTasks;
-
-    uint64_t m_previousGetRegistrationsTaskIdentifier { 0 };
     HashMap<uint64_t, GetRegistrationsCallback> m_ongoingGetRegistrationsTasks;
+    HashMap<uint64_t, WhenRegistrationReadyCallback> m_ongoingRegistrationReadyTasks;
 
 }; // class WebSWServerConnection
 
index a33081f..10217e2 100644 (file)
@@ -39,6 +39,7 @@ messages -> WebSWClientConnection {
 
     DidMatchRegistration(uint64_t matchRequestIdentifier, std::optional<WebCore::ServiceWorkerRegistrationData> data)
     DidGetRegistrations(uint64_t matchRequestIdentifier, Vector<WebCore::ServiceWorkerRegistrationData> registrations)
+    RegistrationReady(uint64_t registrationReadyRequestIdentifier, struct WebCore::ServiceWorkerRegistrationData data)
 }
 
 #endif // ENABLE(SERVICE_WORKER)