Title: [225992] trunk
Revision
225992
Author
cdu...@apple.com
Date
2017-12-15 16:48:04 -0800 (Fri, 15 Dec 2017)

Log Message

Support updating a service worker registration's updateViaCache flag
https://bugs.webkit.org/show_bug.cgi?id=180888

Reviewed by Brady Eidson.

LayoutTests/imported/w3c:

Rebaseline WPT test now that more checks are passing.

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

Source/WebCore:

Support updating a service worker registration's updateViaCache flag to match other browsers:
- https://github.com/w3c/ServiceWorker/issues/1189

No new tests, rebaselined existing test.

* workers/service/SWClientConnection.cpp:
(WebCore::SWClientConnection::setRegistrationUpdateViaCache):
* workers/service/SWClientConnection.h:
* workers/service/ServiceWorkerRegistration.cpp:
(WebCore::ServiceWorkerRegistration::setUpdateViaCache):
* workers/service/ServiceWorkerRegistration.h:
* workers/service/server/SWServer.h:
* workers/service/server/SWServerJobQueue.cpp:
(WebCore::SWServerJobQueue::runRegisterJob):
* workers/service/server/SWServerRegistration.cpp:
(WebCore::SWServerRegistration::setUpdateViaCache):
* workers/service/server/SWServerRegistration.h:

Source/WebKit:

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

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (225991 => 225992)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2017-12-16 00:32:22 UTC (rev 225991)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2017-12-16 00:48:04 UTC (rev 225992)
@@ -1,5 +1,16 @@
 2017-12-15  Chris Dumez  <cdu...@apple.com>
 
+        Support updating a service worker registration's updateViaCache flag
+        https://bugs.webkit.org/show_bug.cgi?id=180888
+
+        Reviewed by Brady Eidson.
+
+        Rebaseline WPT test now that more checks are passing.
+
+        * web-platform-tests/service-workers/service-worker/registration-updateviacache.https-expected.txt:
+
+2017-12-15  Chris Dumez  <cdu...@apple.com>
+
         Unreviewed, rebaseline Service Workers flaky tests.
 
         * web-platform-tests/service-workers/cache-storage/serviceworker/cache-match.https-expected.txt:

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/registration-updateviacache.https-expected.txt (225991 => 225992)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/registration-updateviacache.https-expected.txt	2017-12-16 00:32:22 UTC (rev 225991)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/registration-updateviacache.https-expected.txt	2017-12-16 00:48:04 UTC (rev 225992)
@@ -5,18 +5,18 @@
 PASS register-with-updateViaCache-none 
 PASS register-with-updateViaCache-undefined-then-undefined 
 PASS register-with-updateViaCache-undefined-then-imports 
-FAIL register-with-updateViaCache-undefined-then-all assert_equals: reg.updateViaCache updated expected "all" but got "imports"
-FAIL register-with-updateViaCache-undefined-then-none assert_equals: reg.updateViaCache updated expected "none" but got "imports"
+FAIL register-with-updateViaCache-undefined-then-all assert_equals: No new service worker expected null but got object "[object ServiceWorker]"
+PASS register-with-updateViaCache-undefined-then-none 
 PASS register-with-updateViaCache-imports-then-undefined 
 PASS register-with-updateViaCache-imports-then-imports 
-FAIL register-with-updateViaCache-imports-then-all assert_equals: reg.updateViaCache updated expected "all" but got "imports"
-FAIL register-with-updateViaCache-imports-then-none assert_equals: reg.updateViaCache updated expected "none" but got "imports"
-FAIL register-with-updateViaCache-all-then-undefined assert_equals: reg.updateViaCache updated expected "imports" but got "all"
-FAIL register-with-updateViaCache-all-then-imports assert_equals: reg.updateViaCache updated expected "imports" but got "all"
+FAIL register-with-updateViaCache-imports-then-all assert_equals: No new service worker expected null but got object "[object ServiceWorker]"
+PASS register-with-updateViaCache-imports-then-none 
+PASS register-with-updateViaCache-all-then-undefined 
+PASS register-with-updateViaCache-all-then-imports 
 PASS register-with-updateViaCache-all-then-all 
-FAIL register-with-updateViaCache-all-then-none assert_equals: reg.updateViaCache updated expected "none" but got "all"
-FAIL register-with-updateViaCache-none-then-undefined assert_equals: reg.updateViaCache updated expected "imports" but got "none"
-FAIL register-with-updateViaCache-none-then-imports assert_equals: reg.updateViaCache updated expected "imports" but got "none"
-FAIL register-with-updateViaCache-none-then-all assert_equals: reg.updateViaCache updated expected "all" but got "none"
+PASS register-with-updateViaCache-all-then-none 
+PASS register-with-updateViaCache-none-then-undefined 
+PASS register-with-updateViaCache-none-then-imports 
+FAIL register-with-updateViaCache-none-then-all assert_equals: No new service worker expected null but got object "[object ServiceWorker]"
 PASS register-with-updateViaCache-none-then-none 
 

Modified: trunk/Source/WebCore/ChangeLog (225991 => 225992)


--- trunk/Source/WebCore/ChangeLog	2017-12-16 00:32:22 UTC (rev 225991)
+++ trunk/Source/WebCore/ChangeLog	2017-12-16 00:48:04 UTC (rev 225992)
@@ -1,3 +1,28 @@
+2017-12-15  Chris Dumez  <cdu...@apple.com>
+
+        Support updating a service worker registration's updateViaCache flag
+        https://bugs.webkit.org/show_bug.cgi?id=180888
+
+        Reviewed by Brady Eidson.
+
+        Support updating a service worker registration's updateViaCache flag to match other browsers:
+        - https://github.com/w3c/ServiceWorker/issues/1189
+
+        No new tests, rebaselined existing test.
+
+        * workers/service/SWClientConnection.cpp:
+        (WebCore::SWClientConnection::setRegistrationUpdateViaCache):
+        * workers/service/SWClientConnection.h:
+        * workers/service/ServiceWorkerRegistration.cpp:
+        (WebCore::ServiceWorkerRegistration::setUpdateViaCache):
+        * workers/service/ServiceWorkerRegistration.h:
+        * workers/service/server/SWServer.h:
+        * workers/service/server/SWServerJobQueue.cpp:
+        (WebCore::SWServerJobQueue::runRegisterJob):
+        * workers/service/server/SWServerRegistration.cpp:
+        (WebCore::SWServerRegistration::setUpdateViaCache):
+        * workers/service/server/SWServerRegistration.h:
+
 2017-12-15  Ryan Haddad  <ryanhad...@apple.com>
 
         Unreviewed, rolling out r225941.

Modified: trunk/Source/WebCore/workers/service/SWClientConnection.cpp (225991 => 225992)


--- trunk/Source/WebCore/workers/service/SWClientConnection.cpp	2017-12-16 00:32:22 UTC (rev 225991)
+++ trunk/Source/WebCore/workers/service/SWClientConnection.cpp	2017-12-16 00:48:04 UTC (rev 225992)
@@ -228,6 +228,27 @@
     }
 }
 
+void SWClientConnection::setRegistrationUpdateViaCache(ServiceWorkerRegistrationIdentifier identifier, ServiceWorkerUpdateViaCache updateViaCache)
+{
+    ASSERT(isMainThread());
+
+    SWContextManager::singleton().forEachServiceWorkerThread([identifier, updateViaCache] (auto& workerThread) {
+        workerThread.thread().runLoop().postTask([identifier, updateViaCache](ScriptExecutionContext& context) {
+            if (auto* container = context.serviceWorkerContainer()) {
+                if (auto* registration = container->registration(identifier))
+                    registration->setUpdateViaCache(updateViaCache);
+            }
+        });
+    });
+
+    for (auto* document : Document::allDocuments()) {
+        if (auto* container = document->serviceWorkerContainer()) {
+            if (auto* registration = container->registration(identifier))
+                registration->setUpdateViaCache(updateViaCache);
+        }
+    }
+}
+
 void SWClientConnection::notifyClientsOfControllerChange(const HashSet<DocumentIdentifier>& contextIdentifiers, ServiceWorkerData&& newController)
 {
     ASSERT(isMainThread());

Modified: trunk/Source/WebCore/workers/service/SWClientConnection.h (225991 => 225992)


--- trunk/Source/WebCore/workers/service/SWClientConnection.h	2017-12-16 00:32:22 UTC (rev 225991)
+++ trunk/Source/WebCore/workers/service/SWClientConnection.h	2017-12-16 00:48:04 UTC (rev 225992)
@@ -95,6 +95,7 @@
     WEBCORE_EXPORT void updateWorkerState(ServiceWorkerIdentifier, ServiceWorkerState);
     WEBCORE_EXPORT void fireUpdateFoundEvent(ServiceWorkerRegistrationIdentifier);
     WEBCORE_EXPORT void setRegistrationLastUpdateTime(ServiceWorkerRegistrationIdentifier, WallTime);
+    WEBCORE_EXPORT void setRegistrationUpdateViaCache(ServiceWorkerRegistrationIdentifier, ServiceWorkerUpdateViaCache);
     WEBCORE_EXPORT void notifyClientsOfControllerChange(const HashSet<DocumentIdentifier>& contextIdentifiers, ServiceWorkerData&& newController);
 
     WEBCORE_EXPORT void clearPendingJobs();

Modified: trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.cpp (225991 => 225992)


--- trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.cpp	2017-12-16 00:32:22 UTC (rev 225991)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.cpp	2017-12-16 00:48:04 UTC (rev 225992)
@@ -122,6 +122,11 @@
     m_registrationData.lastUpdateTime = lastUpdateTime;
 }
 
+void ServiceWorkerRegistration::setUpdateViaCache(ServiceWorkerUpdateViaCache updateViaCache)
+{
+    m_registrationData.updateViaCache = updateViaCache;
+}
+
 void ServiceWorkerRegistration::update(Ref<DeferredPromise>&& promise)
 {
     if (m_isStopped) {

Modified: trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.h (225991 => 225992)


--- trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.h	2017-12-16 00:32:22 UTC (rev 225991)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.h	2017-12-16 00:48:04 UTC (rev 225992)
@@ -54,7 +54,9 @@
     ServiceWorker* getNewestWorker();
 
     const String& scope() const;
+
     ServiceWorkerUpdateViaCache updateViaCache() const;
+    void setUpdateViaCache(ServiceWorkerUpdateViaCache);
 
     WallTime lastUpdateTime() const;
     void setLastUpdateTime(WallTime);

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


--- trunk/Source/WebCore/workers/service/server/SWServer.h	2017-12-16 00:32:22 UTC (rev 225991)
+++ trunk/Source/WebCore/workers/service/server/SWServer.h	2017-12-16 00:48:04 UTC (rev 225992)
@@ -83,6 +83,7 @@
         virtual void updateWorkerStateInClient(ServiceWorkerIdentifier, ServiceWorkerState) = 0;
         virtual void fireUpdateFoundEvent(ServiceWorkerRegistrationIdentifier) = 0;
         virtual void setRegistrationLastUpdateTime(ServiceWorkerRegistrationIdentifier, WallTime) = 0;
+        virtual void setRegistrationUpdateViaCache(ServiceWorkerRegistrationIdentifier, ServiceWorkerUpdateViaCache) = 0;
         virtual void notifyClientsOfControllerChange(const HashSet<DocumentIdentifier>& contextIdentifiers, const ServiceWorkerData& newController) = 0;
         virtual void registrationReady(uint64_t registrationReadyRequestIdentifier, ServiceWorkerRegistrationData&&) = 0;
 

Modified: trunk/Source/WebCore/workers/service/server/SWServerJobQueue.cpp (225991 => 225992)


--- trunk/Source/WebCore/workers/service/server/SWServerJobQueue.cpp	2017-12-16 00:32:22 UTC (rev 225991)
+++ trunk/Source/WebCore/workers/service/server/SWServerJobQueue.cpp	2017-12-16 00:48:04 UTC (rev 225992)
@@ -251,6 +251,9 @@
             finishCurrentJob();
             return;
         }
+        // This is not specified yet (https://github.com/w3c/ServiceWorker/issues/1189).
+        if (registration->updateViaCache() != job.registrationOptions.updateViaCache)
+            registration->setUpdateViaCache(job.registrationOptions.updateViaCache);
     } else {
         auto newRegistration = std::make_unique<SWServerRegistration>(m_server, m_registrationKey, job.registrationOptions.updateViaCache, job.scopeURL, job.scriptURL);
         m_server.addRegistration(WTFMove(newRegistration));

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


--- trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp	2017-12-16 00:32:22 UTC (rev 225991)
+++ trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp	2017-12-16 00:48:04 UTC (rev 225992)
@@ -102,6 +102,14 @@
     });
 }
 
+void SWServerRegistration::setUpdateViaCache(ServiceWorkerUpdateViaCache updateViaCache)
+{
+    m_updateViaCache = updateViaCache;
+    forEachConnection([&](auto& connection) {
+        connection.setRegistrationUpdateViaCache(identifier(), updateViaCache);
+    });
+}
+
 void SWServerRegistration::setLastUpdateTime(WallTime time)
 {
     m_lastUpdateTime = time;

Modified: trunk/Source/WebCore/workers/service/server/SWServerRegistration.h (225991 => 225992)


--- trunk/Source/WebCore/workers/service/server/SWServerRegistration.h	2017-12-16 00:32:22 UTC (rev 225991)
+++ trunk/Source/WebCore/workers/service/server/SWServerRegistration.h	2017-12-16 00:48:04 UTC (rev 225992)
@@ -63,6 +63,7 @@
     void setLastUpdateTime(WallTime);
     WallTime lastUpdateTime() const { return m_lastUpdateTime; }
 
+    void setUpdateViaCache(ServiceWorkerUpdateViaCache);
     ServiceWorkerUpdateViaCache updateViaCache() const { return m_updateViaCache; }
 
     void updateRegistrationState(ServiceWorkerRegistrationState, SWServerWorker*);

Modified: trunk/Source/WebKit/ChangeLog (225991 => 225992)


--- trunk/Source/WebKit/ChangeLog	2017-12-16 00:32:22 UTC (rev 225991)
+++ trunk/Source/WebKit/ChangeLog	2017-12-16 00:48:04 UTC (rev 225992)
@@ -1,3 +1,15 @@
+2017-12-15  Chris Dumez  <cdu...@apple.com>
+
+        Support updating a service worker registration's updateViaCache flag
+        https://bugs.webkit.org/show_bug.cgi?id=180888
+
+        Reviewed by Brady Eidson.
+
+        * StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
+        (WebKit::WebSWServerConnection::setRegistrationUpdateViaCache):
+        * StorageProcess/ServiceWorker/WebSWServerConnection.h:
+        * WebProcess/Storage/WebSWClientConnection.messages.in:
+
 2017-12-15  Alex Christensen  <achristen...@webkit.org>
 
         Introduce SPI _WKWebsitePolicies.websiteDataStore

Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp (225991 => 225992)


--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp	2017-12-16 00:32:22 UTC (rev 225991)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp	2017-12-16 00:48:04 UTC (rev 225992)
@@ -111,6 +111,11 @@
     send(Messages::WebSWClientConnection::SetRegistrationLastUpdateTime(identifier, lastUpdateTime));
 }
 
+void WebSWServerConnection::setRegistrationUpdateViaCache(ServiceWorkerRegistrationIdentifier identifier, ServiceWorkerUpdateViaCache updateViaCache)
+{
+    send(Messages::WebSWClientConnection::SetRegistrationUpdateViaCache(identifier, updateViaCache));
+}
+
 void WebSWServerConnection::notifyClientsOfControllerChange(const HashSet<DocumentIdentifier>& contextIdentifiers, const ServiceWorkerData& newController)
 {
     send(Messages::WebSWClientConnection::NotifyClientsOfControllerChange(contextIdentifiers, newController));

Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h (225991 => 225992)


--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h	2017-12-16 00:32:22 UTC (rev 225991)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h	2017-12-16 00:48:04 UTC (rev 225992)
@@ -79,6 +79,7 @@
     void updateWorkerStateInClient(WebCore::ServiceWorkerIdentifier, WebCore::ServiceWorkerState) final;
     void fireUpdateFoundEvent(WebCore::ServiceWorkerRegistrationIdentifier) final;
     void setRegistrationLastUpdateTime(WebCore::ServiceWorkerRegistrationIdentifier, WallTime) final;
+    void setRegistrationUpdateViaCache(WebCore::ServiceWorkerRegistrationIdentifier, WebCore::ServiceWorkerUpdateViaCache) final;
     void notifyClientsOfControllerChange(const HashSet<WebCore::DocumentIdentifier>& contextIdentifiers, const WebCore::ServiceWorkerData& newController);
     void registrationReady(uint64_t registrationReadyRequestIdentifier, WebCore::ServiceWorkerRegistrationData&&) final;
 

Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.messages.in (225991 => 225992)


--- trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.messages.in	2017-12-16 00:32:22 UTC (rev 225991)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.messages.in	2017-12-16 00:48:04 UTC (rev 225992)
@@ -32,6 +32,7 @@
     UpdateWorkerState(WebCore::ServiceWorkerIdentifier serviceWorkerIdentifier, enum WebCore::ServiceWorkerState state)
     FireUpdateFoundEvent(WebCore::ServiceWorkerRegistrationIdentifier identifier)
     SetRegistrationLastUpdateTime(WebCore::ServiceWorkerRegistrationIdentifier identifier, WallTime lastUpdateTime)
+    SetRegistrationUpdateViaCache(WebCore::ServiceWorkerRegistrationIdentifier identifier, enum WebCore::ServiceWorkerUpdateViaCache updateViaCache);
     NotifyClientsOfControllerChange(HashSet<WebCore::DocumentIdentifier> contextIdentifiers, struct WebCore::ServiceWorkerData newController)
 
     SetSWOriginTableIsImported()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to