Title: [224664] trunk
Revision
224664
Author
cdu...@apple.com
Date
2017-11-09 22:26:40 -0800 (Thu, 09 Nov 2017)

Log Message

ServiceWorkerRegistration objects may get recycled for different SWServerRegistration objects
https://bugs.webkit.org/show_bug.cgi?id=179517

Reviewed by Brady Eidson.

LayoutTests/imported/w3c:

* web-platform-tests/service-workers/service-worker/ready.https-expected.txt:
The test fails differently. The failure is expected here since we do not implement the
"Try Clear Registration" algorithm. As a result, we do not support resurrecting a
registration with the 'uninstalling' flag set. We always clear uninstalling registrations
on server side for now.

* web-platform-tests/service-workers/service-worker/unregister-then-register.https-expected.txt:
Same reason as above. The second checks calls unregister() for a registration that is "in use"
as expects it to get resurrected when calling register() again. We currently always clear
registrations that are unregistered on server side.

Source/WebCore:

ServiceWorkerRegistration objects could get recycled for different SWServerRegistration objects, leading to
flakiness in the tests. We uses ServiceWorkerRegistrationKey as key in the m_registration map on WebProcess
side. The lifetime of the ServiceWorkerRegistration objects is tied to the lifetime of their JS wrapper.
When a test does a registration for a given scope, then unregisters, then registers again for the same scope,
we would end up creating a new SWServerRegistration object on server side, but possibly reuse the same
ServiceWorkerRegistration object on WebProcess side, if its wrapper has not yet been garbage collected.
This is because the registrations have the same ServiceWorkerRegistrationKey in this case.

To address the issue, we now use the ServiceWorkerRegistrationIdentifier as key in the m_registration
hash map. A SWServerRegistration has a unique ServiceWorkerRegistrationIdentifier on server side.
All its clients ServiceWorkerRegistration also use the same ServiceWorkerRegistrationIdentifier.

Test: http/tests/workers/service/basic-unregister-then-register-again-no-reuse.html

* workers/service/ServiceWorkerContainer.cpp:
(WebCore::ServiceWorkerContainer::getRegistration):
(WebCore::ServiceWorkerContainer::scheduleTaskToUpdateRegistrationState):
(WebCore::ServiceWorkerContainer::scheduleTaskToFireUpdateFoundEvent):
(WebCore::ServiceWorkerContainer::jobResolvedWithRegistration):
(WebCore::ServiceWorkerContainer::addRegistration):
(WebCore::ServiceWorkerContainer::removeRegistration):
* workers/service/ServiceWorkerContainer.h:
* workers/service/ServiceWorkerRegistration.h:
* workers/service/ServiceWorkerRegistrationData.h:
(WebCore::ServiceWorkerRegistrationData::decode):
* workers/service/server/SWClientConnection.cpp:
(WebCore::SWClientConnection::updateRegistrationState):
(WebCore::SWClientConnection::fireUpdateFoundEvent):
* workers/service/server/SWClientConnection.h:
* workers/service/server/SWServer.cpp:
(WebCore::SWServer::Connection::addServiceWorkerRegistrationInServer):
(WebCore::SWServer::Connection::removeServiceWorkerRegistrationInServer):
(WebCore::SWServer::resolveRegistrationJob):
(WebCore::SWServer::addClientServiceWorkerRegistration):
(WebCore::SWServer::removeClientServiceWorkerRegistration):
* workers/service/server/SWServer.h:
* workers/service/server/SWServerRegistration.cpp:
(WebCore::generateServiceWorkerRegistrationIdentifier):
(WebCore::SWServerRegistration::SWServerRegistration):
(WebCore::SWServerRegistration::updateRegistrationState):
(WebCore::SWServerRegistration::fireUpdateFoundEvent):
(WebCore::SWServerRegistration::forEachConnection):
(WebCore::SWServerRegistration::addClientServiceWorkerRegistration):
(WebCore::SWServerRegistration::removeClientServiceWorkerRegistration):
* workers/service/server/SWServerRegistration.h:
(WebCore::SWServerRegistration::identifier const):

Source/WebKit:

* Scripts/webkit/messages.py:
(forward_declarations_and_headers):
* StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
(WebKit::WebSWServerConnection::updateRegistrationStateInClient):
(WebKit::WebSWServerConnection::fireUpdateFoundEvent):
* StorageProcess/ServiceWorker/WebSWServerConnection.h:
* StorageProcess/ServiceWorker/WebSWServerConnection.messages.in:
* WebProcess/Storage/WebSWClientConnection.cpp:
(WebKit::WebSWClientConnection::addServiceWorkerRegistrationInServer):
(WebKit::WebSWClientConnection::removeServiceWorkerRegistrationInServer):
* WebProcess/Storage/WebSWClientConnection.h:
* WebProcess/Storage/WebSWClientConnection.messages.in:

LayoutTests:

Add layout test coverage.

* http/tests/workers/service/basic-unregister-then-register-again-no-reuse-expected.txt: Added.
* http/tests/workers/service/basic-unregister-then-register-again-no-reuse.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (224663 => 224664)


--- trunk/LayoutTests/ChangeLog	2017-11-10 06:06:12 UTC (rev 224663)
+++ trunk/LayoutTests/ChangeLog	2017-11-10 06:26:40 UTC (rev 224664)
@@ -1,5 +1,17 @@
 2017-11-09  Chris Dumez  <cdu...@apple.com>
 
+        ServiceWorkerRegistration objects may get recycled for different SWServerRegistration objects
+        https://bugs.webkit.org/show_bug.cgi?id=179517
+
+        Reviewed by Brady Eidson.
+
+        Add layout test coverage.
+
+        * http/tests/workers/service/basic-unregister-then-register-again-no-reuse-expected.txt: Added.
+        * http/tests/workers/service/basic-unregister-then-register-again-no-reuse.html: Added.
+
+2017-11-09  Chris Dumez  <cdu...@apple.com>
+
         Unreviewed, rebaseline flaky / skipped service worker tests
         https://bugs.webkit.org/show_bug.cgi?id=179521
 

Added: trunk/LayoutTests/http/tests/workers/service/basic-unregister-then-register-again-no-reuse-expected.txt (0 => 224664)


--- trunk/LayoutTests/http/tests/workers/service/basic-unregister-then-register-again-no-reuse-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/basic-unregister-then-register-again-no-reuse-expected.txt	2017-11-10 06:26:40 UTC (rev 224664)
@@ -0,0 +1,7 @@
+PASS: registration1 should not have an installing worker
+PASS: registration1 should not have a waiting worker
+PASS: registration1 should have an active worker
+PASS: registration2 should have an installing worker
+PASS: registration2 should not have a waiting worker
+PASS: registration2 should not have an active worker
+

Added: trunk/LayoutTests/http/tests/workers/service/basic-unregister-then-register-again-no-reuse.html (0 => 224664)


--- trunk/LayoutTests/http/tests/workers/service/basic-unregister-then-register-again-no-reuse.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/basic-unregister-then-register-again-no-reuse.html	2017-11-10 06:26:40 UTC (rev 224664)
@@ -0,0 +1,56 @@
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script>
+
+async function test()
+{
+    try {
+         let registration1 = await navigator.serviceWorker.register("resources/empty.js", { });
+         await waitForState(registration1.installing, "activated");
+         if (registration1.installing)
+             log("FAIL: registration1 should not have an installing worker");
+         else
+             log("PASS: registration1 should not have an installing worker");
+
+         if (registration1.waiting)
+             log("FAIL: registration1 should not have a waiting worker");
+         else
+             log("PASS: registration1 should not have a waiting worker");
+
+         if (registration1.active)
+             log("PASS: registration1 should have an active worker");
+         else
+             log("FAIL: registration1 should have an active worker");
+
+         await registration1.unregister();
+
+         let registration2 = await navigator.serviceWorker.register("resources/empty.js", { });
+         if (registration2.installing)
+             log("PASS: registration2 should have an installing worker");
+         else
+             log("FAIL: registration2 should have an installing worker");
+
+         if (registration2.waiting)
+             log("FAIL: registration2 should not have a waiting worker");
+         else
+             log("PASS: registration2 should not have a waiting worker");
+
+         if (registration2.active)
+             log("FAIL: registration2 should not have an active worker");
+         else
+             log("PASS: registration2 should not have an active worker");
+
+    } catch (e) {
+        log("FAIL: Got exception " + e);
+    }
+
+    finishSWTest();
+}
+
+test();
+</script>
+</body>
+</html>

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (224663 => 224664)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2017-11-10 06:06:12 UTC (rev 224663)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2017-11-10 06:26:40 UTC (rev 224664)
@@ -1,5 +1,24 @@
 2017-11-09  Chris Dumez  <cdu...@apple.com>
 
+        ServiceWorkerRegistration objects may get recycled for different SWServerRegistration objects
+        https://bugs.webkit.org/show_bug.cgi?id=179517
+
+        Reviewed by Brady Eidson.
+
+        * web-platform-tests/service-workers/service-worker/ready.https-expected.txt:
+        The test fails differently. The failure is expected here since we do not implement the
+        "Try Clear Registration" algorithm. As a result, we do not support resurrecting a
+        registration with the 'uninstalling' flag set. We always clear uninstalling registrations
+        on server side for now.
+
+        * web-platform-tests/service-workers/service-worker/unregister-then-register.https-expected.txt:
+        Same reason as above. The second checks calls unregister() for a registration that is "in use"
+        as expects it to get resurrected when calling register() again. We currently always clear
+        registrations that are unregistered on server side.
+
+
+2017-11-09  Chris Dumez  <cdu...@apple.com>
+
         Unreviewed, ebaseline flaky / skipped service worker tests
         https://bugs.webkit.org/show_bug.cgi?id=179521
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/ready.https-expected.txt (224663 => 224664)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/ready.https-expected.txt	2017-11-10 06:06:12 UTC (rev 224663)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/ready.https-expected.txt	2017-11-10 06:26:40 UTC (rev 224664)
@@ -10,5 +10,5 @@
 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"
+FAIL access ready on uninstalling registration that is resurrected assert_equals: existing registration should be resurrected expected object "[object ServiceWorkerRegistration]" but got object "[object ServiceWorkerRegistration]"
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/unregister-then-register.https-expected.txt (224663 => 224664)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/unregister-then-register.https-expected.txt	2017-11-10 06:06:12 UTC (rev 224663)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/unregister-then-register.https-expected.txt	2017-11-10 06:26:40 UTC (rev 224664)
@@ -1,7 +1,7 @@
 
 
-FAIL Unregister then register resolves to a new value assert_unreached: unexpected rejection: assert_not_equals: register should resolve to a new value got disallowed value object "[object ServiceWorkerRegistration]" Reached unreachable code
-PASS Unregister then register resolves to the original value if the registration is in use. 
+PASS Unregister then register resolves to a new value 
+FAIL Unregister then register resolves to the original value if the registration is in use. assert_unreached: unexpected rejection: assert_equals: new registration should resolve to the same registration expected object "[object ServiceWorkerRegistration]" but got object "[object ServiceWorkerRegistration]" Reached unreachable code
 PASS Reloading the last controlled iframe after unregistration should ensure the deletion of the registration 
 FAIL Unregister then register does not affect existing controllee assert_unreached: unexpected rejection: assert_equals: installing version is null expected null but got object "[object ServiceWorker]" Reached unreachable code
 FAIL Unregister then register resurrects the registration assert_unreached: unexpected rejection: assert_not_equals: document should have a controller got disallowed value null Reached unreachable code

Modified: trunk/Source/WebCore/ChangeLog (224663 => 224664)


--- trunk/Source/WebCore/ChangeLog	2017-11-10 06:06:12 UTC (rev 224663)
+++ trunk/Source/WebCore/ChangeLog	2017-11-10 06:26:40 UTC (rev 224664)
@@ -1,3 +1,57 @@
+2017-11-09  Chris Dumez  <cdu...@apple.com>
+
+        ServiceWorkerRegistration objects may get recycled for different SWServerRegistration objects
+        https://bugs.webkit.org/show_bug.cgi?id=179517
+
+        Reviewed by Brady Eidson.
+
+        ServiceWorkerRegistration objects could get recycled for different SWServerRegistration objects, leading to
+        flakiness in the tests. We uses ServiceWorkerRegistrationKey as key in the m_registration map on WebProcess
+        side. The lifetime of the ServiceWorkerRegistration objects is tied to the lifetime of their JS wrapper.
+        When a test does a registration for a given scope, then unregisters, then registers again for the same scope,
+        we would end up creating a new SWServerRegistration object on server side, but possibly reuse the same
+        ServiceWorkerRegistration object on WebProcess side, if its wrapper has not yet been garbage collected.
+        This is because the registrations have the same ServiceWorkerRegistrationKey in this case.
+
+        To address the issue, we now use the ServiceWorkerRegistrationIdentifier as key in the m_registration
+        hash map. A SWServerRegistration has a unique ServiceWorkerRegistrationIdentifier on server side.
+        All its clients ServiceWorkerRegistration also use the same ServiceWorkerRegistrationIdentifier.
+
+        Test: http/tests/workers/service/basic-unregister-then-register-again-no-reuse.html
+
+        * workers/service/ServiceWorkerContainer.cpp:
+        (WebCore::ServiceWorkerContainer::getRegistration):
+        (WebCore::ServiceWorkerContainer::scheduleTaskToUpdateRegistrationState):
+        (WebCore::ServiceWorkerContainer::scheduleTaskToFireUpdateFoundEvent):
+        (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration):
+        (WebCore::ServiceWorkerContainer::addRegistration):
+        (WebCore::ServiceWorkerContainer::removeRegistration):
+        * workers/service/ServiceWorkerContainer.h:
+        * workers/service/ServiceWorkerRegistration.h:
+        * workers/service/ServiceWorkerRegistrationData.h:
+        (WebCore::ServiceWorkerRegistrationData::decode):
+        * workers/service/server/SWClientConnection.cpp:
+        (WebCore::SWClientConnection::updateRegistrationState):
+        (WebCore::SWClientConnection::fireUpdateFoundEvent):
+        * workers/service/server/SWClientConnection.h:
+        * workers/service/server/SWServer.cpp:
+        (WebCore::SWServer::Connection::addServiceWorkerRegistrationInServer):
+        (WebCore::SWServer::Connection::removeServiceWorkerRegistrationInServer):
+        (WebCore::SWServer::resolveRegistrationJob):
+        (WebCore::SWServer::addClientServiceWorkerRegistration):
+        (WebCore::SWServer::removeClientServiceWorkerRegistration):
+        * workers/service/server/SWServer.h:
+        * workers/service/server/SWServerRegistration.cpp:
+        (WebCore::generateServiceWorkerRegistrationIdentifier):
+        (WebCore::SWServerRegistration::SWServerRegistration):
+        (WebCore::SWServerRegistration::updateRegistrationState):
+        (WebCore::SWServerRegistration::fireUpdateFoundEvent):
+        (WebCore::SWServerRegistration::forEachConnection):
+        (WebCore::SWServerRegistration::addClientServiceWorkerRegistration):
+        (WebCore::SWServerRegistration::removeClientServiceWorkerRegistration):
+        * workers/service/server/SWServerRegistration.h:
+        (WebCore::SWServerRegistration::identifier const):
+
 2017-11-09  John Wilander  <wilan...@apple.com>
 
         Ignore HSTS for partitioned, cross-origin subresource requests

Modified: trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp (224663 => 224664)


--- trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp	2017-11-10 06:06:12 UTC (rev 224663)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp	2017-11-10 06:26:40 UTC (rev 224664)
@@ -230,7 +230,7 @@
             return;
         }
 
-        RefPtr<ServiceWorkerRegistration> registration = m_registrations.get(result->key);
+        RefPtr<ServiceWorkerRegistration> registration = m_registrations.get(result->identifier);
         if (!registration) {
             auto& context = *scriptExecutionContext();
             // FIXME: We should probably not be constructing ServiceWorkerRegistration objects here. Instead, we should make
@@ -241,14 +241,14 @@
     });
 }
 
-void ServiceWorkerContainer::scheduleTaskToUpdateRegistrationState(const ServiceWorkerRegistrationKey& key, ServiceWorkerRegistrationState state, const std::optional<ServiceWorkerIdentifier>& serviceWorkerIdentifier)
+void ServiceWorkerContainer::scheduleTaskToUpdateRegistrationState(ServiceWorkerRegistrationIdentifier identifier, ServiceWorkerRegistrationState state, const std::optional<ServiceWorkerIdentifier>& serviceWorkerIdentifier)
 {
     auto* context = scriptExecutionContext();
     if (!context)
         return;
 
-    context->postTask([this, protectedThis = makeRef(*this), key, state, serviceWorkerIdentifier](ScriptExecutionContext&) {
-        if (auto* registration = m_registrations.get(key))
+    context->postTask([this, protectedThis = makeRef(*this), identifier, state, serviceWorkerIdentifier](ScriptExecutionContext&) {
+        if (auto* registration = m_registrations.get(identifier))
             registration->updateStateFromServer(state, serviceWorkerIdentifier);
     });
 }
@@ -273,16 +273,16 @@
     jobDidFinish(job);
 }
 
-void ServiceWorkerContainer::scheduleTaskToFireUpdateFoundEvent(const ServiceWorkerRegistrationKey& key)
+void ServiceWorkerContainer::scheduleTaskToFireUpdateFoundEvent(ServiceWorkerRegistrationIdentifier identifier)
 {
     if (isStopped())
         return;
 
-    scriptExecutionContext()->postTask([this, protectedThis = makeRef(*this), key](ScriptExecutionContext&) {
+    scriptExecutionContext()->postTask([this, protectedThis = makeRef(*this), identifier](ScriptExecutionContext&) {
         if (isStopped())
             return;
 
-        if (auto* registration = m_registrations.get(key))
+        if (auto* registration = m_registrations.get(identifier))
             registration->dispatchEvent(Event::create(eventNames().updatefoundEvent, false, false));
     });
 }
@@ -301,7 +301,7 @@
     }
 
     context->postTask([this, protectedThis = makeRef(*this), job = makeRef(job), data = "" promiseResolvedHandler = WTFMove(promiseResolvedHandler)](ScriptExecutionContext& context) mutable {
-        RefPtr<ServiceWorkerRegistration> registration = m_registrations.get(data.key);
+        RefPtr<ServiceWorkerRegistration> registration = m_registrations.get(data.identifier);
         if (!registration)
             registration = ServiceWorkerRegistration::create(context, *this, WTFMove(data));
 
@@ -395,13 +395,13 @@
 void ServiceWorkerContainer::addRegistration(ServiceWorkerRegistration& registration)
 {
     m_swConnection->addServiceWorkerRegistrationInServer(registration.data().key, registration.identifier());
-    m_registrations.add(registration.data().key, &registration);
+    m_registrations.add(registration.identifier(), &registration);
 }
 
 void ServiceWorkerContainer::removeRegistration(ServiceWorkerRegistration& registration)
 {
     m_swConnection->removeServiceWorkerRegistrationInServer(registration.data().key, registration.identifier());
-    m_registrations.remove(registration.data().key);
+    m_registrations.remove(registration.identifier());
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h (224663 => 224664)


--- trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h	2017-11-10 06:06:12 UTC (rev 224663)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h	2017-11-10 06:26:40 UTC (rev 224664)
@@ -65,8 +65,8 @@
     void updateRegistration(const URL& scopeURL, const URL& scriptURL, WorkerType, Ref<DeferredPromise>&&);
 
     void getRegistration(const String& clientURL, Ref<DeferredPromise>&&);
-    void scheduleTaskToUpdateRegistrationState(const ServiceWorkerRegistrationKey&, ServiceWorkerRegistrationState, const std::optional<ServiceWorkerIdentifier>&);
-    void scheduleTaskToFireUpdateFoundEvent(const ServiceWorkerRegistrationKey&);
+    void scheduleTaskToUpdateRegistrationState(ServiceWorkerRegistrationIdentifier, ServiceWorkerRegistrationState, const std::optional<ServiceWorkerIdentifier>&);
+    void scheduleTaskToFireUpdateFoundEvent(ServiceWorkerRegistrationIdentifier);
 
     using RegistrationsPromise = DOMPromiseDeferred<IDLSequence<IDLInterface<ServiceWorkerRegistration>>>;
     void getRegistrations(RegistrationsPromise&&);
@@ -111,7 +111,7 @@
     HashMap<uint64_t, Ref<ServiceWorkerJob>> m_jobMap;
 
     bool m_isStopped { false };
-    HashMap<ServiceWorkerRegistrationKey, ServiceWorkerRegistration*> m_registrations;
+    HashMap<ServiceWorkerRegistrationIdentifier, ServiceWorkerRegistration*> m_registrations;
 
 #ifndef NDEBUG
     ThreadIdentifier m_creationThread { currentThread() };

Modified: trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.h (224663 => 224664)


--- trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.h	2017-11-10 06:06:12 UTC (rev 224663)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.h	2017-11-10 06:26:40 UTC (rev 224664)
@@ -32,7 +32,6 @@
 #include "JSDOMPromiseDeferred.h"
 #include "SWClientConnection.h"
 #include "ServiceWorkerRegistrationData.h"
-#include <wtf/Identified.h>
 
 namespace WebCore {
 
@@ -40,7 +39,7 @@
 class ServiceWorker;
 class ServiceWorkerContainer;
 
-class ServiceWorkerRegistration final : public RefCounted<ServiceWorkerRegistration>, public EventTargetWithInlineData, public ActiveDOMObject, public ThreadSafeIdentified<ServiceWorkerRegistration> {
+class ServiceWorkerRegistration final : public RefCounted<ServiceWorkerRegistration>, public EventTargetWithInlineData, public ActiveDOMObject {
 public:
     template <typename... Args> static Ref<ServiceWorkerRegistration> create(Args&&... args)
     {
@@ -49,6 +48,8 @@
 
     ~ServiceWorkerRegistration();
 
+    ServiceWorkerRegistrationIdentifier identifier() const { return m_registrationData.identifier; }
+
     ServiceWorker* installing();
     ServiceWorker* waiting();
     ServiceWorker* active();

Modified: trunk/Source/WebCore/workers/service/ServiceWorkerRegistrationData.h (224663 => 224664)


--- trunk/Source/WebCore/workers/service/ServiceWorkerRegistrationData.h	2017-11-10 06:06:12 UTC (rev 224663)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerRegistrationData.h	2017-11-10 06:26:40 UTC (rev 224664)
@@ -29,6 +29,7 @@
 
 #include "ServiceWorkerIdentifier.h"
 #include "ServiceWorkerRegistrationKey.h"
+#include "ServiceWorkerTypes.h"
 
 namespace WebCore {
 
@@ -36,7 +37,7 @@
 
 struct ServiceWorkerRegistrationData {
     ServiceWorkerRegistrationKey key;
-    uint64_t identifier;
+    ServiceWorkerRegistrationIdentifier identifier;
     URL scopeURL;
     URL scriptURL;
     ServiceWorkerUpdateViaCache updateViaCache;
@@ -66,7 +67,7 @@
     if (!key)
         return std::nullopt;
     
-    std::optional<uint64_t> identifier;
+    std::optional<ServiceWorkerRegistrationIdentifier> identifier;
     decoder >> identifier;
     if (!identifier)
         return std::nullopt;

Modified: trunk/Source/WebCore/workers/service/ServiceWorkerTypes.h (224663 => 224664)


--- trunk/Source/WebCore/workers/service/ServiceWorkerTypes.h	2017-11-10 06:06:12 UTC (rev 224663)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerTypes.h	2017-11-10 06:26:40 UTC (rev 224664)
@@ -27,6 +27,8 @@
 
 #if ENABLE(SERVICE_WORKER)
 
+#include <wtf/ObjectIdentifier.h>
+
 namespace WebCore {
 
 enum class ServiceWorkerRegistrationState {
@@ -45,6 +47,9 @@
 
 enum class ShouldNotifyWhenResolved { No, Yes };
 
+enum ServiceWorkerRegistrationIdentifierType { };
+using ServiceWorkerRegistrationIdentifier = ObjectIdentifier<ServiceWorkerRegistrationIdentifierType>;
+
 } // namespace WebCore
 
 #endif // ENABLE(SERVICE_WORKER)

Modified: trunk/Source/WebCore/workers/service/server/SWClientConnection.cpp (224663 => 224664)


--- trunk/Source/WebCore/workers/service/server/SWClientConnection.cpp	2017-11-10 06:06:12 UTC (rev 224663)
+++ trunk/Source/WebCore/workers/service/server/SWClientConnection.cpp	2017-11-10 06:26:40 UTC (rev 224664)
@@ -152,10 +152,10 @@
     }
 }
 
-void SWClientConnection::updateRegistrationState(const ServiceWorkerRegistrationKey& key, ServiceWorkerRegistrationState state, std::optional<ServiceWorkerIdentifier> serviceWorkerIdentifier)
+void SWClientConnection::updateRegistrationState(ServiceWorkerRegistrationIdentifier identifier, ServiceWorkerRegistrationState state, std::optional<ServiceWorkerIdentifier> serviceWorkerIdentifier)
 {
     forEachContainer([&](ServiceWorkerContainer& container) {
-        container.scheduleTaskToUpdateRegistrationState(key, state, serviceWorkerIdentifier);
+        container.scheduleTaskToUpdateRegistrationState(identifier, state, serviceWorkerIdentifier);
     });
 }
 
@@ -165,10 +165,10 @@
         worker->scheduleTaskToUpdateState(state);
 }
 
-void SWClientConnection::fireUpdateFoundEvent(const ServiceWorkerRegistrationKey& key)
+void SWClientConnection::fireUpdateFoundEvent(ServiceWorkerRegistrationIdentifier identifier)
 {
     forEachContainer([&](ServiceWorkerContainer& container) {
-        container.scheduleTaskToFireUpdateFoundEvent(key);
+        container.scheduleTaskToFireUpdateFoundEvent(identifier);
     });
 }
 

Modified: trunk/Source/WebCore/workers/service/server/SWClientConnection.h (224663 => 224664)


--- trunk/Source/WebCore/workers/service/server/SWClientConnection.h	2017-11-10 06:06:12 UTC (rev 224663)
+++ trunk/Source/WebCore/workers/service/server/SWClientConnection.h	2017-11-10 06:26:40 UTC (rev 224664)
@@ -28,6 +28,7 @@
 #if ENABLE(SERVICE_WORKER)
 
 #include "ServiceWorkerJob.h"
+#include "ServiceWorkerTypes.h"
 #include <wtf/HashMap.h>
 #include <wtf/ThreadSafeRefCounted.h>
 
@@ -53,8 +54,8 @@
     using RegistrationCallback = WTF::CompletionHandler<void(std::optional<ServiceWorkerRegistrationData>&&)>;
     virtual void matchRegistration(const SecurityOrigin& topOrigin, const URL& clientURL, RegistrationCallback&&) = 0;
 
-    virtual void addServiceWorkerRegistrationInServer(const ServiceWorkerRegistrationKey&, uint64_t registrationIdentifier) = 0;
-    virtual void removeServiceWorkerRegistrationInServer(const ServiceWorkerRegistrationKey&, uint64_t registrationIdentifier) = 0;
+    virtual void addServiceWorkerRegistrationInServer(const ServiceWorkerRegistrationKey&, ServiceWorkerRegistrationIdentifier) = 0;
+    virtual void removeServiceWorkerRegistrationInServer(const ServiceWorkerRegistrationKey&, ServiceWorkerRegistrationIdentifier) = 0;
 
     void scheduleJob(ServiceWorkerJob&);
     void finishedFetchingScript(ServiceWorkerJob&, const String&);
@@ -74,9 +75,9 @@
     WEBCORE_EXPORT void unregistrationJobResolvedInServer(uint64_t jobIdentifier, bool unregistrationResult);
     WEBCORE_EXPORT void startScriptFetchForServer(uint64_t jobIdentifier);
     WEBCORE_EXPORT void postMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, Ref<SerializedScriptValue>&& message, ServiceWorkerIdentifier source, const String& sourceOrigin);
-    WEBCORE_EXPORT void updateRegistrationState(const ServiceWorkerRegistrationKey&, ServiceWorkerRegistrationState, std::optional<ServiceWorkerIdentifier>);
+    WEBCORE_EXPORT void updateRegistrationState(ServiceWorkerRegistrationIdentifier, ServiceWorkerRegistrationState, std::optional<ServiceWorkerIdentifier>);
     WEBCORE_EXPORT void updateWorkerState(ServiceWorkerIdentifier, ServiceWorkerState);
-    WEBCORE_EXPORT void fireUpdateFoundEvent(const ServiceWorkerRegistrationKey&);
+    WEBCORE_EXPORT void fireUpdateFoundEvent(ServiceWorkerRegistrationIdentifier);
 
 private:
     virtual void scheduleJobInServer(const ServiceWorkerJobData&) = 0;

Modified: trunk/Source/WebCore/workers/service/server/SWServer.cpp (224663 => 224664)


--- trunk/Source/WebCore/workers/service/server/SWServer.cpp	2017-11-10 06:06:12 UTC (rev 224663)
+++ trunk/Source/WebCore/workers/service/server/SWServer.cpp	2017-11-10 06:26:40 UTC (rev 224664)
@@ -122,14 +122,14 @@
     m_server.didResolveRegistrationPromise(*this, key);
 }
 
-void SWServer::Connection::addServiceWorkerRegistrationInServer(const ServiceWorkerRegistrationKey& key, uint64_t clientRegistrationIdentifier)
+void SWServer::Connection::addServiceWorkerRegistrationInServer(const ServiceWorkerRegistrationKey& key, ServiceWorkerRegistrationIdentifier identifier)
 {
-    m_server.addClientServiceWorkerRegistration(*this, key, clientRegistrationIdentifier);
+    m_server.addClientServiceWorkerRegistration(*this, key, identifier);
 }
 
-void SWServer::Connection::removeServiceWorkerRegistrationInServer(const ServiceWorkerRegistrationKey& key, uint64_t clientRegistrationIdentifier)
+void SWServer::Connection::removeServiceWorkerRegistrationInServer(const ServiceWorkerRegistrationKey& key, ServiceWorkerRegistrationIdentifier identifier)
 {
-    m_server.removeClientServiceWorkerRegistration(*this, key, clientRegistrationIdentifier);
+    m_server.removeClientServiceWorkerRegistration(*this, key, identifier);
 }
 
 void SWServer::Connection::scriptContextFailedToStart(const ServiceWorkerRegistrationKey& registrationKey, ServiceWorkerIdentifier identifier, const String& message)
@@ -178,7 +178,7 @@
 
 void SWServer::resolveRegistrationJob(const ServiceWorkerJobData& jobData, const ServiceWorkerRegistrationData& registrationData, ShouldNotifyWhenResolved shouldNotifyWhenResolved)
 {
-    LOG(ServiceWorker, "Resolved ServiceWorker job %" PRIu64 "-%" PRIu64 " in server with registration %" PRIu64, jobData.connectionIdentifier(), jobData.identifier(), registrationData.identifier);
+    LOG(ServiceWorker, "Resolved ServiceWorker job %" PRIu64 "-%" PRIu64 " in server with registration %s", jobData.connectionIdentifier(), jobData.identifier(), registrationData.identifier.loggingString().utf8().data());
     auto* connection = m_connections.get(jobData.connectionIdentifier());
     if (!connection)
         return;
@@ -250,7 +250,7 @@
         jobQueue->didResolveRegistrationPromise(connection);
 }
 
-void SWServer::addClientServiceWorkerRegistration(Connection& connection, const ServiceWorkerRegistrationKey& key, uint64_t registrationIdentifier)
+void SWServer::addClientServiceWorkerRegistration(Connection& connection, const ServiceWorkerRegistrationKey& key, ServiceWorkerRegistrationIdentifier identifier)
 {
     auto* registration = m_registrations.get(key);
     if (!registration) {
@@ -257,11 +257,14 @@
         LOG_ERROR("Request to add client-side ServiceWorkerRegistration to non-existent server-side registration");
         return;
     }
+
+    if (registration->identifier() != identifier)
+        return;
     
-    registration->addClientServiceWorkerRegistration(connection.identifier(), registrationIdentifier);
+    registration->addClientServiceWorkerRegistration(connection.identifier());
 }
 
-void SWServer::removeClientServiceWorkerRegistration(Connection& connection, const ServiceWorkerRegistrationKey& key, uint64_t registrationIdentifier)
+void SWServer::removeClientServiceWorkerRegistration(Connection& connection, const ServiceWorkerRegistrationKey& key, ServiceWorkerRegistrationIdentifier identifier)
 {
     auto* registration = m_registrations.get(key);
     if (!registration) {
@@ -268,8 +271,11 @@
         LOG_ERROR("Request to remove client-side ServiceWorkerRegistration from non-existent server-side registration");
         return;
     }
+
+    if (registration->identifier() != identifier)
+        return;
     
-    registration->removeClientServiceWorkerRegistration(connection.identifier(), registrationIdentifier);
+    registration->removeClientServiceWorkerRegistration(connection.identifier());
 }
 
 Ref<SWServerWorker> SWServer::updateWorker(Connection& connection, const ServiceWorkerRegistrationKey& registrationKey, const URL& url, const String& script, WorkerType type)

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


--- trunk/Source/WebCore/workers/service/server/SWServer.h	2017-11-10 06:06:12 UTC (rev 224663)
+++ trunk/Source/WebCore/workers/service/server/SWServer.h	2017-11-10 06:26:40 UTC (rev 224664)
@@ -66,9 +66,9 @@
         const SWServerRegistration* doRegistrationMatching(const SecurityOriginData& topOrigin, const URL& clientURL) const { return m_server.doRegistrationMatching(topOrigin, clientURL); }
 
         // Messages to the client WebProcess
-        virtual void updateRegistrationStateInClient(const ServiceWorkerRegistrationKey&, ServiceWorkerRegistrationState, std::optional<ServiceWorkerIdentifier>) = 0;
+        virtual void updateRegistrationStateInClient(ServiceWorkerRegistrationIdentifier, ServiceWorkerRegistrationState, std::optional<ServiceWorkerIdentifier>) = 0;
         virtual void updateWorkerStateInClient(ServiceWorkerIdentifier, ServiceWorkerState) = 0;
-        virtual void fireUpdateFoundEvent(const ServiceWorkerRegistrationKey&) = 0;
+        virtual void fireUpdateFoundEvent(ServiceWorkerRegistrationIdentifier) = 0;
 
     protected:
         WEBCORE_EXPORT Connection(SWServer&, uint64_t identifier);
@@ -76,8 +76,8 @@
 
         WEBCORE_EXPORT void scheduleJobInServer(const ServiceWorkerJobData&);
         WEBCORE_EXPORT void finishFetchingScriptInServer(const ServiceWorkerFetchResult&);
-        WEBCORE_EXPORT void addServiceWorkerRegistrationInServer(const ServiceWorkerRegistrationKey&, uint64_t clientRegistrationIdentifier);
-        WEBCORE_EXPORT void removeServiceWorkerRegistrationInServer(const ServiceWorkerRegistrationKey&, uint64_t clientRegistrationIdentifier);
+        WEBCORE_EXPORT void addServiceWorkerRegistrationInServer(const ServiceWorkerRegistrationKey&, ServiceWorkerRegistrationIdentifier);
+        WEBCORE_EXPORT void removeServiceWorkerRegistrationInServer(const ServiceWorkerRegistrationKey&, ServiceWorkerRegistrationIdentifier);
 
     private:
         // Messages to the client WebProcess
@@ -130,8 +130,8 @@
     void didFinishInstall(Connection&, const ServiceWorkerRegistrationKey&, ServiceWorkerIdentifier, bool wasSuccessful);
     void didResolveRegistrationPromise(Connection&, const ServiceWorkerRegistrationKey&);
 
-    void addClientServiceWorkerRegistration(Connection&, const ServiceWorkerRegistrationKey&, uint64_t registrationIdentifier);
-    void removeClientServiceWorkerRegistration(Connection&, const ServiceWorkerRegistrationKey&, uint64_t registrationIdentifier);
+    void addClientServiceWorkerRegistration(Connection&, const ServiceWorkerRegistrationKey&, ServiceWorkerRegistrationIdentifier);
+    void removeClientServiceWorkerRegistration(Connection&, const ServiceWorkerRegistrationKey&, ServiceWorkerRegistrationIdentifier);
 
     WEBCORE_EXPORT const SWServerRegistration* doRegistrationMatching(const SecurityOriginData& topOrigin, const URL& clientURL) const;
 

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


--- trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp	2017-11-10 06:06:12 UTC (rev 224663)
+++ trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp	2017-11-10 06:26:40 UTC (rev 224664)
@@ -35,8 +35,15 @@
 
 namespace WebCore {
 
+static ServiceWorkerRegistrationIdentifier generateServiceWorkerRegistrationIdentifier()
+{
+    static uint64_t identifier = 0;
+    return makeObjectIdentifier<ServiceWorkerRegistrationIdentifierType>(++identifier);
+}
+
 SWServerRegistration::SWServerRegistration(SWServer& server, const ServiceWorkerRegistrationKey& key, ServiceWorkerUpdateViaCache updateViaCache, const URL& scopeURL, const URL& scriptURL)
-    : m_registrationKey(key)
+    : m_identifier(generateServiceWorkerRegistrationIdentifier())
+    , m_registrationKey(key)
     , m_updateViaCache(updateViaCache)
     , m_scopeURL(scopeURL)
     , m_scriptURL(scriptURL)
@@ -80,7 +87,7 @@
         serviceWorkerIdentifier = worker->identifier();
 
     forEachConnection(job, [&](auto& connection) {
-        connection.updateRegistrationStateInClient(m_registrationKey, state, serviceWorkerIdentifier);
+        connection.updateRegistrationStateInClient(identifier(), state, serviceWorkerIdentifier);
     });
 }
 
@@ -98,7 +105,7 @@
 void SWServerRegistration::fireUpdateFoundEvent(const ServiceWorkerJobData& job)
 {
     forEachConnection(job, [&](auto& connection) {
-        connection.fireUpdateFoundEvent(m_registrationKey);
+        connection.fireUpdateFoundEvent(identifier());
     });
 }
 
@@ -106,12 +113,12 @@
 {
     // No matter what, we send the event to the connection that scheduled the job. The client registration
     // may not have gotten a chance to register itself yet.
-    if (!m_clientRegistrationsByConnection.contains(job.connectionIdentifier())) {
+    if (!m_connectionsWithClientRegistrations.contains(job.connectionIdentifier())) {
         if (auto* connection = m_server.getConnection(job.connectionIdentifier()))
             apply(*connection);
     }
 
-    for (auto& connectionIdentifierWithClients : m_clientRegistrationsByConnection.keys()) {
+    for (uint64_t connectionIdentifierWithClients : m_connectionsWithClientRegistrations.values()) {
         if (auto* connection = m_server.getConnection(connectionIdentifierWithClients))
             apply(*connection);
     }
@@ -134,25 +141,14 @@
     return { m_registrationKey, identifier(), m_scopeURL, m_scriptURL, m_updateViaCache, installingID, waitingID, activeID };
 }
 
-void SWServerRegistration::addClientServiceWorkerRegistration(uint64_t connectionIdentifier, uint64_t clientRegistrationIdentifier)
+void SWServerRegistration::addClientServiceWorkerRegistration(uint64_t connectionIdentifier)
 {
-    auto result = m_clientRegistrationsByConnection.ensure(connectionIdentifier, [] {
-        return std::make_unique<HashSet<uint64_t>>();
-    });
-    
-    ASSERT(!result.iterator->value->contains(clientRegistrationIdentifier));
-    result.iterator->value->add(clientRegistrationIdentifier);
+    m_connectionsWithClientRegistrations.add(connectionIdentifier);
 }
 
-void SWServerRegistration::removeClientServiceWorkerRegistration(uint64_t connectionIdentifier, uint64_t clientRegistrationIdentifier)
+void SWServerRegistration::removeClientServiceWorkerRegistration(uint64_t connectionIdentifier)
 {
-    auto iterator = m_clientRegistrationsByConnection.find(connectionIdentifier);
-    if (iterator == m_clientRegistrationsByConnection.end() || !iterator->value)
-        return;
-    
-    iterator->value->remove(clientRegistrationIdentifier);
-    if (iterator->value->isEmpty())
-        m_clientRegistrationsByConnection.remove(iterator);
+    m_connectionsWithClientRegistrations.remove(connectionIdentifier);
 }
 
 } // namespace WebCore

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


--- trunk/Source/WebCore/workers/service/server/SWServerRegistration.h	2017-11-10 06:06:12 UTC (rev 224663)
+++ trunk/Source/WebCore/workers/service/server/SWServerRegistration.h	2017-11-10 06:26:40 UTC (rev 224664)
@@ -29,7 +29,8 @@
 
 #include "SWServer.h"
 #include "ServiceWorkerRegistrationData.h"
-#include <wtf/Identified.h>
+#include "ServiceWorkerTypes.h"
+#include <wtf/HashCountedSet.h>
 
 namespace WebCore {
 
@@ -40,12 +41,13 @@
 struct ExceptionData;
 struct ServiceWorkerFetchResult;
 
-class SWServerRegistration : public ThreadSafeIdentified<SWServerRegistration> {
+class SWServerRegistration {
 public:
     SWServerRegistration(SWServer&, const ServiceWorkerRegistrationKey&, ServiceWorkerUpdateViaCache, const URL& scopeURL, const URL& scriptURL);
     ~SWServerRegistration();
 
     const ServiceWorkerRegistrationKey& key() const { return m_registrationKey; }
+    ServiceWorkerRegistrationIdentifier identifier() const { return m_identifier; }
 
     SWServerWorker* getNewestWorker();
     WEBCORE_EXPORT ServiceWorkerRegistrationData data() const;
@@ -60,8 +62,8 @@
     void updateWorkerState(const ServiceWorkerJobData&, SWServerWorker&, ServiceWorkerState);
     void fireUpdateFoundEvent(const ServiceWorkerJobData&);
 
-    void addClientServiceWorkerRegistration(uint64_t connectionIdentifier, uint64_t clientRegistrationIdentifier);
-    void removeClientServiceWorkerRegistration(uint64_t connectionIdentifier, uint64_t clientRegistrationIdentifier);
+    void addClientServiceWorkerRegistration(uint64_t connectionIdentifier);
+    void removeClientServiceWorkerRegistration(uint64_t connectionIdentifier);
 
     SWServerWorker* installingWorker() const { return m_installingWorker.get(); }
     SWServerWorker* waitingWorker() const { return m_waitingWorker.get(); }
@@ -70,6 +72,7 @@
 private:
     void forEachConnection(const ServiceWorkerJobData&, const WTF::Function<void(SWServer::Connection&)>&);
 
+    ServiceWorkerRegistrationIdentifier m_identifier;
     ServiceWorkerRegistrationKey m_registrationKey;
     ServiceWorkerUpdateViaCache m_updateViaCache;
     URL m_scopeURL;
@@ -82,7 +85,7 @@
 
     double m_lastUpdateTime { 0 };
     
-    HashMap<uint64_t, std::unique_ptr<HashSet<uint64_t>>> m_clientRegistrationsByConnection;
+    HashCountedSet<uint64_t> m_connectionsWithClientRegistrations;
     SWServer& m_server;
 };
 

Modified: trunk/Source/WebKit/ChangeLog (224663 => 224664)


--- trunk/Source/WebKit/ChangeLog	2017-11-10 06:06:12 UTC (rev 224663)
+++ trunk/Source/WebKit/ChangeLog	2017-11-10 06:26:40 UTC (rev 224664)
@@ -1,3 +1,23 @@
+2017-11-09  Chris Dumez  <cdu...@apple.com>
+
+        ServiceWorkerRegistration objects may get recycled for different SWServerRegistration objects
+        https://bugs.webkit.org/show_bug.cgi?id=179517
+
+        Reviewed by Brady Eidson.
+
+        * Scripts/webkit/messages.py:
+        (forward_declarations_and_headers):
+        * StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
+        (WebKit::WebSWServerConnection::updateRegistrationStateInClient):
+        (WebKit::WebSWServerConnection::fireUpdateFoundEvent):
+        * StorageProcess/ServiceWorker/WebSWServerConnection.h:
+        * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in:
+        * WebProcess/Storage/WebSWClientConnection.cpp:
+        (WebKit::WebSWClientConnection::addServiceWorkerRegistrationInServer):
+        (WebKit::WebSWClientConnection::removeServiceWorkerRegistrationInServer):
+        * WebProcess/Storage/WebSWClientConnection.h:
+        * WebProcess/Storage/WebSWClientConnection.messages.in:
+
 2017-11-09  John Wilander  <wilan...@apple.com>
 
         Ignore HSTS for partitioned, cross-origin subresource requests

Modified: trunk/Source/WebKit/Scripts/webkit/messages.py (224663 => 224664)


--- trunk/Source/WebKit/Scripts/webkit/messages.py	2017-11-10 06:06:12 UTC (rev 224663)
+++ trunk/Source/WebKit/Scripts/webkit/messages.py	2017-11-10 06:26:40 UTC (rev 224664)
@@ -187,7 +187,7 @@
         kind = parameter.kind
         type = parameter.type
 
-        if type.find('<') != -1 or type == "WebCore::ServiceWorkerIdentifier":
+        if type.find('<') != -1 or type == "WebCore::ServiceWorkerIdentifier" or type == "WebCore::ServiceWorkerRegistrationIdentifier":
             # Don't forward declare class templates or ServiceWorkerIdentifier.
             headers.update(headers_for_type(type))
             continue
@@ -372,6 +372,7 @@
         'WebCore::PluginInfo': ['<WebCore/PluginData.h>'],
         'WebCore::PolicyAction': ['<WebCore/FrameLoaderTypes.h>'],
         'WebCore::RecentSearch': ['<WebCore/SearchPopupMenu.h>'],
+        'WebCore::ServiceWorkerRegistrationIdentifier': ['<WebCore/ServiceWorkerTypes.h>'],
         'WebCore::ServiceWorkerRegistrationState': ['<WebCore/ServiceWorkerTypes.h>'],
         'WebCore::ServiceWorkerState': ['<WebCore/ServiceWorkerTypes.h>'],
         'WebCore::ShippingContactUpdate': ['<WebCore/ApplePaySessionPaymentRequest.h>'],

Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp (224663 => 224664)


--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp	2017-11-10 06:06:12 UTC (rev 224663)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp	2017-11-10 06:26:40 UTC (rev 224664)
@@ -96,14 +96,14 @@
     send(Messages::WebSWClientConnection::StartScriptFetchForServer(jobIdentifier));
 }
 
-void WebSWServerConnection::updateRegistrationStateInClient(const ServiceWorkerRegistrationKey& key, ServiceWorkerRegistrationState state, std::optional<ServiceWorkerIdentifier> serviceWorkerIdentifier)
+void WebSWServerConnection::updateRegistrationStateInClient(ServiceWorkerRegistrationIdentifier identifier, ServiceWorkerRegistrationState state, std::optional<ServiceWorkerIdentifier> serviceWorkerIdentifier)
 {
-    send(Messages::WebSWClientConnection::UpdateRegistrationState(key, state, serviceWorkerIdentifier));
+    send(Messages::WebSWClientConnection::UpdateRegistrationState(identifier, state, serviceWorkerIdentifier));
 }
 
-void WebSWServerConnection::fireUpdateFoundEvent(const ServiceWorkerRegistrationKey& key)
+void WebSWServerConnection::fireUpdateFoundEvent(ServiceWorkerRegistrationIdentifier identifier)
 {
-    send(Messages::WebSWClientConnection::FireUpdateFoundEvent(key));
+    send(Messages::WebSWClientConnection::FireUpdateFoundEvent(identifier));
 }
 
 void WebSWServerConnection::updateWorkerStateInClient(ServiceWorkerIdentifier worker, ServiceWorkerState state)

Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h (224663 => 224664)


--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h	2017-11-10 06:06:12 UTC (rev 224663)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h	2017-11-10 06:26:40 UTC (rev 224664)
@@ -65,9 +65,9 @@
     void resolveRegistrationJobInClient(uint64_t jobIdentifier, const WebCore::ServiceWorkerRegistrationData&, WebCore::ShouldNotifyWhenResolved) final;
     void resolveUnregistrationJobInClient(uint64_t jobIdentifier, const WebCore::ServiceWorkerRegistrationKey&, bool unregistrationResult) final;
     void startScriptFetchInClient(uint64_t jobIdentifier) final;
-    void updateRegistrationStateInClient(const WebCore::ServiceWorkerRegistrationKey&, WebCore::ServiceWorkerRegistrationState, std::optional<WebCore::ServiceWorkerIdentifier>) final;
+    void updateRegistrationStateInClient(WebCore::ServiceWorkerRegistrationIdentifier, WebCore::ServiceWorkerRegistrationState, std::optional<WebCore::ServiceWorkerIdentifier>) final;
     void updateWorkerStateInClient(WebCore::ServiceWorkerIdentifier, WebCore::ServiceWorkerState) final;
-    void fireUpdateFoundEvent(const WebCore::ServiceWorkerRegistrationKey&) final;
+    void fireUpdateFoundEvent(WebCore::ServiceWorkerRegistrationIdentifier) final;
 
     void startFetch(uint64_t fetchIdentifier, std::optional<WebCore::ServiceWorkerIdentifier>, const WebCore::ResourceRequest&, const WebCore::FetchOptions&);
 

Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in (224663 => 224664)


--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in	2017-11-10 06:06:12 UTC (rev 224663)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in	2017-11-10 06:26:40 UTC (rev 224664)
@@ -26,8 +26,8 @@
     # When possible, these messages can be implemented directly by WebCore::SWClientConnection
     ScheduleJobInServer(struct WebCore::ServiceWorkerJobData jobData)
     FinishFetchingScriptInServer(struct WebCore::ServiceWorkerFetchResult result)
-    AddServiceWorkerRegistrationInServer(WebCore::ServiceWorkerRegistrationKey key, uint64_t registrationIdentifier)
-    RemoveServiceWorkerRegistrationInServer(WebCore::ServiceWorkerRegistrationKey key, uint64_t registrationIdentifier)
+    AddServiceWorkerRegistrationInServer(WebCore::ServiceWorkerRegistrationKey key, WebCore::ServiceWorkerRegistrationIdentifier identifier)
+    RemoveServiceWorkerRegistrationInServer(WebCore::ServiceWorkerRegistrationKey key, WebCore::ServiceWorkerRegistrationIdentifier identifier)
 
     StartFetch(uint64_t identifier, std::optional<WebCore::ServiceWorkerIdentifier> serviceWorkerIdentifier, WebCore::ResourceRequest request, struct WebCore::FetchOptions options)
     PostMessageToServiceWorkerGlobalScope(WebCore::ServiceWorkerIdentifier destinationServiceWorkerIdentifier, IPC::DataReference message, uint64_t sourceScriptExecutionContextIdentifier, String sourceOrigin)

Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp (224663 => 224664)


--- trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp	2017-11-10 06:06:12 UTC (rev 224663)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp	2017-11-10 06:26:40 UTC (rev 224664)
@@ -70,14 +70,14 @@
     send(Messages::WebSWServerConnection::FinishFetchingScriptInServer(result));
 }
 
-void WebSWClientConnection::addServiceWorkerRegistrationInServer(const ServiceWorkerRegistrationKey& key, uint64_t registrationIdentifier)
+void WebSWClientConnection::addServiceWorkerRegistrationInServer(const ServiceWorkerRegistrationKey& key, ServiceWorkerRegistrationIdentifier identifier)
 {
-    send(Messages::WebSWServerConnection::AddServiceWorkerRegistrationInServer(key, registrationIdentifier));
+    send(Messages::WebSWServerConnection::AddServiceWorkerRegistrationInServer(key, identifier));
 }
 
-void WebSWClientConnection::removeServiceWorkerRegistrationInServer(const ServiceWorkerRegistrationKey& key, uint64_t registrationIdentifier)
+void WebSWClientConnection::removeServiceWorkerRegistrationInServer(const ServiceWorkerRegistrationKey& key, ServiceWorkerRegistrationIdentifier identifier)
 {
-    send(Messages::WebSWServerConnection::RemoveServiceWorkerRegistrationInServer(key, registrationIdentifier));
+    send(Messages::WebSWServerConnection::RemoveServiceWorkerRegistrationInServer(key, identifier));
 }
 
 void WebSWClientConnection::postMessageToServiceWorkerGlobalScope(ServiceWorkerIdentifier destinationIdentifier, Ref<SerializedScriptValue>&& scriptValue, ScriptExecutionContext& source)

Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h (224663 => 224664)


--- trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h	2017-11-10 06:06:12 UTC (rev 224663)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h	2017-11-10 06:26:40 UTC (rev 224664)
@@ -54,8 +54,8 @@
 
     uint64_t identifier() const final { return m_identifier; }
 
-    void addServiceWorkerRegistrationInServer(const WebCore::ServiceWorkerRegistrationKey&, uint64_t registrationIdentifier) final;
-    void removeServiceWorkerRegistrationInServer(const WebCore::ServiceWorkerRegistrationKey&, uint64_t registrationIdentifier) final;
+    void addServiceWorkerRegistrationInServer(const WebCore::ServiceWorkerRegistrationKey&, WebCore::ServiceWorkerRegistrationIdentifier) final;
+    void removeServiceWorkerRegistrationInServer(const WebCore::ServiceWorkerRegistrationKey&, WebCore::ServiceWorkerRegistrationIdentifier) final;
 
     void disconnectedFromWebProcess();
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;

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


--- trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.messages.in	2017-11-10 06:06:12 UTC (rev 224663)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.messages.in	2017-11-10 06:26:40 UTC (rev 224664)
@@ -28,9 +28,9 @@
     RegistrationJobResolvedInServer(uint64_t identifier, struct WebCore::ServiceWorkerRegistrationData registration, enum WebCore::ShouldNotifyWhenResolved shouldNotifyWhenResolved)
     UnregistrationJobResolvedInServer(uint64_t identifier, bool unregistrationResult)
     StartScriptFetchForServer(uint64_t jobIdentifier)
-    UpdateRegistrationState(WebCore::ServiceWorkerRegistrationKey key, enum WebCore::ServiceWorkerRegistrationState state, std::optional<WebCore::ServiceWorkerIdentifier> serviceWorkerIdentifier)
+    UpdateRegistrationState(WebCore::ServiceWorkerRegistrationIdentifier identifier, enum WebCore::ServiceWorkerRegistrationState state, std::optional<WebCore::ServiceWorkerIdentifier> serviceWorkerIdentifier)
     UpdateWorkerState(WebCore::ServiceWorkerIdentifier serviceWorkerIdentifier, enum WebCore::ServiceWorkerState state)
-    FireUpdateFoundEvent(WebCore::ServiceWorkerRegistrationKey key)
+    FireUpdateFoundEvent(WebCore::ServiceWorkerRegistrationIdentifier identifier)
 
     SetSWOriginTableSharedMemory(WebKit::SharedMemory::Handle handle)
     PostMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, IPC::DataReference message, WebCore::ServiceWorkerIdentifier sourceServiceWorkerIdentifier, String sourceOrigin)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to