self.importScripts() should obey updateViaCache inside service workers
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Dec 2017 23:59:40 +0000 (23:59 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Dec 2017 23:59:40 +0000 (23:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=180826

Reviewed by Youenn Fablet.

Source/WebCore:

self.importScripts() should obey updateViaCache inside service workers, as per:
- https://html.spec.whatwg.org/multipage/workers.html#dom-workerglobalscope-importscripts

Tests: http/tests/workers/service/registration-updateViaCache-all-importScripts.html
       http/tests/workers/service/registration-updateViaCache-imports-importScripts.html
       http/tests/workers/service/registration-updateViaCache-none-importScripts.html

* workers/WorkerGlobalScope.cpp:
(WebCore::WorkerGlobalScope::importScripts):
* workers/WorkerScriptLoader.cpp:
(WebCore::WorkerScriptLoader::loadSynchronously):
* workers/WorkerScriptLoader.h:
* workers/service/SWClientConnection.cpp:
(WebCore::SWClientConnection::setRegistrationLastUpdateTime):
* workers/service/SWClientConnection.h:
* workers/service/ServiceWorkerRegistration.cpp:
(WebCore::ServiceWorkerRegistration::lastUpdateTime const):
(WebCore::ServiceWorkerRegistration::setLastUpdateTime):
* workers/service/ServiceWorkerRegistration.h:
* workers/service/server/SWServer.h:
* workers/service/server/SWServerRegistration.cpp:
(WebCore::SWServerRegistration::setLastUpdateTime):
* workers/service/server/SWServerRegistration.h:

Source/WebKit:

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

LayoutTests:

Add layout test coverage.

* http/tests/workers/service/registration-updateViaCache-all-importScripts-expected.txt: Added.
* http/tests/workers/service/registration-updateViaCache-all-importScripts.html: Added.
* http/tests/workers/service/registration-updateViaCache-imports-importScripts-expected.txt: Added.
* http/tests/workers/service/registration-updateViaCache-imports-importScripts.html: Added.
* http/tests/workers/service/registration-updateViaCache-none-importScripts-expected.txt: Added.
* http/tests/workers/service/registration-updateViaCache-none-importScripts.html: Added.
* http/tests/workers/service/resources/import-cacheable-script-worker.js: Added.

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

24 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/workers/service/registration-updateViaCache-all-importScripts-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/workers/service/registration-updateViaCache-all-importScripts.html [new file with mode: 0644]
LayoutTests/http/tests/workers/service/registration-updateViaCache-imports-importScripts-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/workers/service/registration-updateViaCache-imports-importScripts.html [new file with mode: 0644]
LayoutTests/http/tests/workers/service/registration-updateViaCache-none-importScripts-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/workers/service/registration-updateViaCache-none-importScripts.html [new file with mode: 0644]
LayoutTests/http/tests/workers/service/resources/import-cacheable-script-worker.js [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/workers/WorkerGlobalScope.cpp
Source/WebCore/workers/WorkerScriptLoader.cpp
Source/WebCore/workers/WorkerScriptLoader.h
Source/WebCore/workers/service/SWClientConnection.cpp
Source/WebCore/workers/service/SWClientConnection.h
Source/WebCore/workers/service/ServiceWorkerRegistration.cpp
Source/WebCore/workers/service/ServiceWorkerRegistration.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/WebProcess/Storage/WebSWClientConnection.messages.in

index ef704a0..039937a 100644 (file)
@@ -1,3 +1,20 @@
+2017-12-14  Chris Dumez  <cdumez@apple.com>
+
+        self.importScripts() should obey updateViaCache inside service workers
+        https://bugs.webkit.org/show_bug.cgi?id=180826
+
+        Reviewed by Youenn Fablet.
+
+        Add layout test coverage.
+
+        * http/tests/workers/service/registration-updateViaCache-all-importScripts-expected.txt: Added.
+        * http/tests/workers/service/registration-updateViaCache-all-importScripts.html: Added.
+        * http/tests/workers/service/registration-updateViaCache-imports-importScripts-expected.txt: Added.
+        * http/tests/workers/service/registration-updateViaCache-imports-importScripts.html: Added.
+        * http/tests/workers/service/registration-updateViaCache-none-importScripts-expected.txt: Added.
+        * http/tests/workers/service/registration-updateViaCache-none-importScripts.html: Added.
+        * http/tests/workers/service/resources/import-cacheable-script-worker.js: Added.
+
 2017-12-14  John Wilander  <wilander@apple.com>
 
         Storage Access API: Implement frame-specific access in the document.cookie layer
diff --git a/LayoutTests/http/tests/workers/service/registration-updateViaCache-all-importScripts-expected.txt b/LayoutTests/http/tests/workers/service/registration-updateViaCache-all-importScripts-expected.txt
new file mode 100644 (file)
index 0000000..e3500b2
--- /dev/null
@@ -0,0 +1,2 @@
+PASS: importScripts() loaded the script came from the network cache
+
diff --git a/LayoutTests/http/tests/workers/service/registration-updateViaCache-all-importScripts.html b/LayoutTests/http/tests/workers/service/registration-updateViaCache-all-importScripts.html
new file mode 100644 (file)
index 0000000..83bad06
--- /dev/null
@@ -0,0 +1,43 @@
+<html>
+<head>
+<script src="resources/sw-test-pre.js"></script>
+</head>
+<body>
+<script>
+
+function getRandomIdFromWorker(worker)
+{
+    worker.postMessage("getRandomId");
+    return new Promise(function(resolve) {
+      navigator.serviceWorker.addEventListener('message', function(e) {
+            resolve(e.data);
+        });
+    });
+}
+
+async function test()
+{
+    try {
+        let registration = await navigator.serviceWorker.register("resources/import-cacheable-script-worker.js", { updateViaCache: "all" });
+        let worker1 = registration.installing;
+        await waitForState(worker1, "activated");
+        let randomId1 = await getRandomIdFromWorker(worker1);
+
+        await registration.update();
+        let worker2 = registration.installing;
+        await waitForState(worker2, "activated");
+        let randomId2 = await getRandomIdFromWorker(worker2);
+
+        if (randomId1 === randomId2)
+            log("PASS: importScripts() loaded the script came from the network cache");
+        else
+            log("FAIL: importScripts() did not load the script from the network cache");
+    } catch(e) {
+        log("Got exception: " + e);
+    }
+    finishSWTest();
+}
+test();
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/workers/service/registration-updateViaCache-imports-importScripts-expected.txt b/LayoutTests/http/tests/workers/service/registration-updateViaCache-imports-importScripts-expected.txt
new file mode 100644 (file)
index 0000000..e3500b2
--- /dev/null
@@ -0,0 +1,2 @@
+PASS: importScripts() loaded the script came from the network cache
+
diff --git a/LayoutTests/http/tests/workers/service/registration-updateViaCache-imports-importScripts.html b/LayoutTests/http/tests/workers/service/registration-updateViaCache-imports-importScripts.html
new file mode 100644 (file)
index 0000000..5a66054
--- /dev/null
@@ -0,0 +1,43 @@
+<html>
+<head>
+<script src="resources/sw-test-pre.js"></script>
+</head>
+<body>
+<script>
+
+function getRandomIdFromWorker(worker)
+{
+    worker.postMessage("getRandomId");
+    return new Promise(function(resolve) {
+      navigator.serviceWorker.addEventListener('message', function(e) {
+            resolve(e.data);
+        });
+    });
+}
+
+async function test()
+{
+    try {
+        let registration = await navigator.serviceWorker.register("resources/import-cacheable-script-worker.js", { updateViaCache: "imports" });
+        let worker1 = registration.installing;
+        await waitForState(worker1, "activated");
+        let randomId1 = await getRandomIdFromWorker(worker1);
+
+        await registration.update();
+        let worker2 = registration.installing;
+        await waitForState(worker2, "activated");
+        let randomId2 = await getRandomIdFromWorker(worker2);
+
+        if (randomId1 === randomId2)
+            log("PASS: importScripts() loaded the script came from the network cache");
+        else
+            log("FAIL: importScripts() did not load the script from the network cache");
+    } catch(e) {
+        log("Got exception: " + e);
+    }
+    finishSWTest();
+}
+test();
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/workers/service/registration-updateViaCache-none-importScripts-expected.txt b/LayoutTests/http/tests/workers/service/registration-updateViaCache-none-importScripts-expected.txt
new file mode 100644 (file)
index 0000000..6ed7500
--- /dev/null
@@ -0,0 +1,2 @@
+PASS: importScripts() did not load the script from the network cache
+
diff --git a/LayoutTests/http/tests/workers/service/registration-updateViaCache-none-importScripts.html b/LayoutTests/http/tests/workers/service/registration-updateViaCache-none-importScripts.html
new file mode 100644 (file)
index 0000000..b6329e7
--- /dev/null
@@ -0,0 +1,43 @@
+<html>
+<head>
+<script src="resources/sw-test-pre.js"></script>
+</head>
+<body>
+<script>
+
+function getRandomIdFromWorker(worker)
+{
+    worker.postMessage("getRandomId");
+    return new Promise(function(resolve) {
+      navigator.serviceWorker.addEventListener('message', function(e) {
+            resolve(e.data);
+        });
+    });
+}
+
+async function test()
+{
+    try {
+        let registration = await navigator.serviceWorker.register("resources/import-cacheable-script-worker.js", { updateViaCache: "none" });
+        let worker1 = registration.installing;
+        await waitForState(worker1, "activated");
+        let randomId1 = await getRandomIdFromWorker(worker1);
+
+        await registration.update();
+        let worker2 = registration.installing;
+        await waitForState(worker2, "activated");
+        let randomId2 = await getRandomIdFromWorker(worker2);
+
+        if (randomId1 === randomId2)
+            log("FAIL: importScripts() loaded the script came from the network cache");
+        else
+            log("PASS: importScripts() did not load the script from the network cache");
+    } catch(e) {
+        log("Got exception: " + e);
+    }
+    finishSWTest();
+}
+test();
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/workers/service/resources/import-cacheable-script-worker.js b/LayoutTests/http/tests/workers/service/resources/import-cacheable-script-worker.js
new file mode 100644 (file)
index 0000000..8ee372a
--- /dev/null
@@ -0,0 +1,2 @@
+importScripts("cacheable-script-worker.php");
+
index 8fe5b1c..76630a0 100644 (file)
@@ -1,3 +1,34 @@
+2017-12-14  Chris Dumez  <cdumez@apple.com>
+
+        self.importScripts() should obey updateViaCache inside service workers
+        https://bugs.webkit.org/show_bug.cgi?id=180826
+
+        Reviewed by Youenn Fablet.
+
+        self.importScripts() should obey updateViaCache inside service workers, as per:
+        - https://html.spec.whatwg.org/multipage/workers.html#dom-workerglobalscope-importscripts
+
+        Tests: http/tests/workers/service/registration-updateViaCache-all-importScripts.html
+               http/tests/workers/service/registration-updateViaCache-imports-importScripts.html
+               http/tests/workers/service/registration-updateViaCache-none-importScripts.html
+
+        * workers/WorkerGlobalScope.cpp:
+        (WebCore::WorkerGlobalScope::importScripts):
+        * workers/WorkerScriptLoader.cpp:
+        (WebCore::WorkerScriptLoader::loadSynchronously):
+        * workers/WorkerScriptLoader.h:
+        * workers/service/SWClientConnection.cpp:
+        (WebCore::SWClientConnection::setRegistrationLastUpdateTime):
+        * workers/service/SWClientConnection.h:
+        * workers/service/ServiceWorkerRegistration.cpp:
+        (WebCore::ServiceWorkerRegistration::lastUpdateTime const):
+        (WebCore::ServiceWorkerRegistration::setLastUpdateTime):
+        * workers/service/ServiceWorkerRegistration.h:
+        * workers/service/server/SWServer.h:
+        * workers/service/server/SWServerRegistration.cpp:
+        (WebCore::SWServerRegistration::setLastUpdateTime):
+        * workers/service/server/SWServerRegistration.h:
+
 2017-12-14  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         Drop Thread::tryCreate
index a7a4dd8..8a66647 100644 (file)
@@ -38,6 +38,7 @@
 #include "ScriptSourceCode.h"
 #include "SecurityOrigin.h"
 #include "SecurityOriginPolicy.h"
+#include "ServiceWorkerGlobalScope.h"
 #include "SocketProvider.h"
 #include "WorkerInspectorController.h"
 #include "WorkerLoaderProxy.h"
@@ -261,6 +262,20 @@ ExceptionOr<void> WorkerGlobalScope::importScripts(const Vector<String>& urls)
         completedURLs.uncheckedAppend(WTFMove(url));
     }
 
+    FetchOptions::Cache cachePolicy = FetchOptions::Cache::Default;
+
+#if ENABLE(SERVICE_WORKER)
+    if (is<ServiceWorkerGlobalScope>(*this)) {
+        // FIXME: Fully implement https://w3c.github.io/ServiceWorker/#importscripts.
+        auto& serviceWorkerGlobalScope = downcast<ServiceWorkerGlobalScope>(*this);
+        auto& registration = serviceWorkerGlobalScope.registration();
+        if (registration.updateViaCache() == ServiceWorkerUpdateViaCache::None
+            || (registration.lastUpdateTime() && (WallTime::now() - registration.lastUpdateTime()) > 86400_s)) {
+            cachePolicy = FetchOptions::Cache::NoCache;
+        }
+    }
+#endif
+
     for (auto& url : completedURLs) {
         // FIXME: Convert this to check the isolated world's Content Security Policy once webkit.org/b/104520 is solved.
         bool shouldBypassMainWorldContentSecurityPolicy = this->shouldBypassMainWorldContentSecurityPolicy();
@@ -268,7 +283,7 @@ ExceptionOr<void> WorkerGlobalScope::importScripts(const Vector<String>& urls)
             return Exception { NetworkError };
 
         auto scriptLoader = WorkerScriptLoader::create();
-        scriptLoader->loadSynchronously(this, url, FetchOptions::Mode::NoCors, shouldBypassMainWorldContentSecurityPolicy ? ContentSecurityPolicyEnforcement::DoNotEnforce : ContentSecurityPolicyEnforcement::EnforceScriptSrcDirective, resourceRequestIdentifier());
+        scriptLoader->loadSynchronously(this, url, FetchOptions::Mode::NoCors, cachePolicy, shouldBypassMainWorldContentSecurityPolicy ? ContentSecurityPolicyEnforcement::DoNotEnforce : ContentSecurityPolicyEnforcement::EnforceScriptSrcDirective, resourceRequestIdentifier());
 
         // If the fetching attempt failed, throw a NetworkError exception and abort all these steps.
         if (scriptLoader->failed())
index 855bd86..4da13fb 100644 (file)
@@ -43,7 +43,7 @@ WorkerScriptLoader::WorkerScriptLoader() = default;
 
 WorkerScriptLoader::~WorkerScriptLoader() = default;
 
-void WorkerScriptLoader::loadSynchronously(ScriptExecutionContext* scriptExecutionContext, const URL& url, FetchOptions::Mode mode, ContentSecurityPolicyEnforcement contentSecurityPolicyEnforcement, const String& initiatorIdentifier)
+void WorkerScriptLoader::loadSynchronously(ScriptExecutionContext* scriptExecutionContext, const URL& url, FetchOptions::Mode mode, FetchOptions::Cache cachePolicy, ContentSecurityPolicyEnforcement contentSecurityPolicyEnforcement, const String& initiatorIdentifier)
 {
     ASSERT(scriptExecutionContext);
     auto& workerGlobalScope = downcast<WorkerGlobalScope>(*scriptExecutionContext);
@@ -62,6 +62,7 @@ void WorkerScriptLoader::loadSynchronously(ScriptExecutionContext* scriptExecuti
     ThreadableLoaderOptions options;
     options.credentials = FetchOptions::Credentials::Include;
     options.mode = mode;
+    options.cache = cachePolicy;
     options.sendLoadCallbacks = SendCallbacks;
     options.contentSecurityPolicyEnforcement = contentSecurityPolicyEnforcement;
 #if ENABLE(SERVICE_WORKER)
index c81f86c..19c8674 100644 (file)
@@ -52,7 +52,7 @@ public:
         return adoptRef(*new WorkerScriptLoader);
     }
 
-    void loadSynchronously(ScriptExecutionContext*, const URL&, FetchOptions::Mode, ContentSecurityPolicyEnforcement, const String& initiatorIdentifier);
+    void loadSynchronously(ScriptExecutionContext*, const URL&, FetchOptions::Mode, FetchOptions::Cache, ContentSecurityPolicyEnforcement, const String& initiatorIdentifier);
     void loadAsynchronously(ScriptExecutionContext*, const URL&, FetchOptions::Mode, FetchOptions::Cache, ContentSecurityPolicyEnforcement, const String& initiatorIdentifier, WorkerScriptLoaderClient*);
 
     void notifyError();
index 8f6e5a5..62094d9 100644 (file)
@@ -207,6 +207,27 @@ void SWClientConnection::fireUpdateFoundEvent(ServiceWorkerRegistrationIdentifie
     }
 }
 
+void SWClientConnection::setRegistrationLastUpdateTime(ServiceWorkerRegistrationIdentifier identifier, WallTime lastUpdateTime)
+{
+    ASSERT(isMainThread());
+
+    SWContextManager::singleton().forEachServiceWorkerThread([identifier, lastUpdateTime] (auto& workerThread) {
+        workerThread.thread().runLoop().postTask([identifier, lastUpdateTime](ScriptExecutionContext& context) {
+            if (auto* container = context.serviceWorkerContainer()) {
+                if (auto* registration = container->registration(identifier))
+                    registration->setLastUpdateTime(lastUpdateTime);
+            }
+        });
+    });
+
+    for (auto* document : Document::allDocuments()) {
+        if (auto* container = document->serviceWorkerContainer()) {
+            if (auto* registration = container->registration(identifier))
+                registration->setLastUpdateTime(lastUpdateTime);
+        }
+    }
+}
+
 void SWClientConnection::notifyClientsOfControllerChange(const HashSet<DocumentIdentifier>& contextIdentifiers, ServiceWorkerData&& newController)
 {
     ASSERT(isMainThread());
index 1c511f2..d60a81b 100644 (file)
@@ -94,6 +94,7 @@ protected:
     WEBCORE_EXPORT void updateRegistrationState(ServiceWorkerRegistrationIdentifier, ServiceWorkerRegistrationState, const std::optional<ServiceWorkerData>&);
     WEBCORE_EXPORT void updateWorkerState(ServiceWorkerIdentifier, ServiceWorkerState);
     WEBCORE_EXPORT void fireUpdateFoundEvent(ServiceWorkerRegistrationIdentifier);
+    WEBCORE_EXPORT void setRegistrationLastUpdateTime(ServiceWorkerRegistrationIdentifier, WallTime);
     WEBCORE_EXPORT void notifyClientsOfControllerChange(const HashSet<DocumentIdentifier>& contextIdentifiers, ServiceWorkerData&& newController);
 
     WEBCORE_EXPORT void clearPendingJobs();
index cfab0fc..0e9ffbc 100644 (file)
@@ -112,6 +112,16 @@ ServiceWorkerUpdateViaCache ServiceWorkerRegistration::updateViaCache() const
     return m_registrationData.updateViaCache;
 }
 
+WallTime ServiceWorkerRegistration::lastUpdateTime() const
+{
+    return m_registrationData.lastUpdateTime;
+}
+
+void ServiceWorkerRegistration::setLastUpdateTime(WallTime lastUpdateTime)
+{
+    m_registrationData.lastUpdateTime = lastUpdateTime;
+}
+
 void ServiceWorkerRegistration::update(Ref<DeferredPromise>&& promise)
 {
     if (m_isStopped) {
index 56e101d..6a1b184 100644 (file)
@@ -56,6 +56,9 @@ public:
     const String& scope() const;
     ServiceWorkerUpdateViaCache updateViaCache() const;
 
+    WallTime lastUpdateTime() const;
+    void setLastUpdateTime(WallTime);
+
     void update(Ref<DeferredPromise>&&);
     void unregister(Ref<DeferredPromise>&&);
 
index 2ca63e5..94f9fa0 100644 (file)
@@ -116,7 +116,9 @@ void SWServer::addRegistrationFromStore(ServiceWorkerContextData&& data)
     // Pages should not have been able to make a new registration to this key while the import was still taking place.
     ASSERT(!m_registrations.contains(data.registration.key));
 
-    addRegistration(std::make_unique<SWServerRegistration>(*this, data.registration.key, data.registration.updateViaCache, data.registration.scopeURL, data.scriptURL));
+    auto registration = std::make_unique<SWServerRegistration>(*this, data.registration.key, data.registration.updateViaCache, data.registration.scopeURL, data.scriptURL);
+    registration->setLastUpdateTime(data.registration.lastUpdateTime);
+    addRegistration(WTFMove(registration));
     tryInstallContextData(WTFMove(data));
 }
 
index 4e7c8c3..c46aae4 100644 (file)
@@ -82,6 +82,7 @@ public:
         virtual void updateRegistrationStateInClient(ServiceWorkerRegistrationIdentifier, ServiceWorkerRegistrationState, const std::optional<ServiceWorkerData>&) = 0;
         virtual void updateWorkerStateInClient(ServiceWorkerIdentifier, ServiceWorkerState) = 0;
         virtual void fireUpdateFoundEvent(ServiceWorkerRegistrationIdentifier) = 0;
+        virtual void setRegistrationLastUpdateTime(ServiceWorkerRegistrationIdentifier, WallTime) = 0;
         virtual void notifyClientsOfControllerChange(const HashSet<DocumentIdentifier>& contextIdentifiers, const ServiceWorkerData& newController) = 0;
         virtual void registrationReady(uint64_t registrationReadyRequestIdentifier, ServiceWorkerRegistrationData&&) = 0;
 
index a5354e5..fa16aff 100644 (file)
@@ -102,6 +102,14 @@ void SWServerRegistration::updateWorkerState(SWServerWorker& worker, ServiceWork
     });
 }
 
+void SWServerRegistration::setLastUpdateTime(WallTime time)
+{
+    m_lastUpdateTime = time;
+    forEachConnection([&](auto& connection) {
+        connection.setRegistrationLastUpdateTime(identifier(), time);
+    });
+}
+
 void SWServerRegistration::fireUpdateFoundEvent()
 {
     forEachConnection([&](auto& connection) {
index fb75698..7e62633 100644 (file)
@@ -60,7 +60,7 @@ public:
     bool isUninstalling() const { return m_uninstalling; }
     void setIsUninstalling(bool);
 
-    void setLastUpdateTime(WallTime time) { m_lastUpdateTime = time; }
+    void setLastUpdateTime(WallTime);
     WallTime lastUpdateTime() const { return m_lastUpdateTime; }
 
     ServiceWorkerUpdateViaCache updateViaCache() const { return m_updateViaCache; }
index 79426ce..86beb9c 100644 (file)
@@ -1,3 +1,15 @@
+2017-12-14  Chris Dumez  <cdumez@apple.com>
+
+        self.importScripts() should obey updateViaCache inside service workers
+        https://bugs.webkit.org/show_bug.cgi?id=180826
+
+        Reviewed by Youenn Fablet.
+
+        * StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
+        (WebKit::WebSWServerConnection::setRegistrationLastUpdateTime):
+        * StorageProcess/ServiceWorker/WebSWServerConnection.h:
+        * WebProcess/Storage/WebSWClientConnection.messages.in:
+
 2017-12-14  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         Drop Thread::tryCreate
index 2b8d065..53d9471 100644 (file)
@@ -106,6 +106,11 @@ void WebSWServerConnection::fireUpdateFoundEvent(ServiceWorkerRegistrationIdenti
     send(Messages::WebSWClientConnection::FireUpdateFoundEvent(identifier));
 }
 
+void WebSWServerConnection::setRegistrationLastUpdateTime(ServiceWorkerRegistrationIdentifier identifier, WallTime lastUpdateTime)
+{
+    send(Messages::WebSWClientConnection::SetRegistrationLastUpdateTime(identifier, lastUpdateTime));
+}
+
 void WebSWServerConnection::notifyClientsOfControllerChange(const HashSet<DocumentIdentifier>& contextIdentifiers, const ServiceWorkerData& newController)
 {
     send(Messages::WebSWClientConnection::NotifyClientsOfControllerChange(contextIdentifiers, newController));
index 072941b..807a2de 100644 (file)
@@ -78,6 +78,7 @@ private:
     void updateRegistrationStateInClient(WebCore::ServiceWorkerRegistrationIdentifier, WebCore::ServiceWorkerRegistrationState, const std::optional<WebCore::ServiceWorkerData>&) final;
     void updateWorkerStateInClient(WebCore::ServiceWorkerIdentifier, WebCore::ServiceWorkerState) final;
     void fireUpdateFoundEvent(WebCore::ServiceWorkerRegistrationIdentifier) final;
+    void setRegistrationLastUpdateTime(WebCore::ServiceWorkerRegistrationIdentifier, WallTime) final;
     void notifyClientsOfControllerChange(const HashSet<WebCore::DocumentIdentifier>& contextIdentifiers, const WebCore::ServiceWorkerData& newController);
     void registrationReady(uint64_t registrationReadyRequestIdentifier, WebCore::ServiceWorkerRegistrationData&&) final;
 
index 339158f..e2f7aac 100644 (file)
@@ -31,6 +31,7 @@ messages -> WebSWClientConnection {
     UpdateRegistrationState(WebCore::ServiceWorkerRegistrationIdentifier identifier, enum WebCore::ServiceWorkerRegistrationState state, std::optional<WebCore::ServiceWorkerData> serviceWorkerIdentifier)
     UpdateWorkerState(WebCore::ServiceWorkerIdentifier serviceWorkerIdentifier, enum WebCore::ServiceWorkerState state)
     FireUpdateFoundEvent(WebCore::ServiceWorkerRegistrationIdentifier identifier)
+    SetRegistrationLastUpdateTime(WebCore::ServiceWorkerRegistrationIdentifier identifier, WallTime lastUpdateTime)
     NotifyClientsOfControllerChange(HashSet<WebCore::DocumentIdentifier> contextIdentifiers, struct WebCore::ServiceWorkerData newController)
 
     SetSWOriginTableIsImported()