Give Document a strongly typed identifier instead of a uint64_t
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 Nov 2017 19:51:13 +0000 (19:51 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 Nov 2017 19:51:13 +0000 (19:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=180041

Reviewed by Youenn Fablet.

Give Document a strongly typed identifier instead of a uint64_t, for clarity.

Source/WebCore:

* WebCore.xcodeproj/project.pbxproj:
* dom/Document.cpp:
(WebCore::m_identifier):
* dom/Document.h:
(WebCore::Document::identifier const):
* dom/DocumentIdentifier.h: Copied from Source/WebCore/workers/service/ServiceWorkerClientIdentifier.h.
* workers/service/ServiceWorkerClientIdentifier.h:
(WebCore::ServiceWorkerClientIdentifier::toString const):
(WebCore::ServiceWorkerClientIdentifier::encode const):
(WebCore::ServiceWorkerClientIdentifier::decode):
* workers/service/server/SWClientConnection.cpp:
(WebCore::SWClientConnection::postMessageToServiceWorkerClient):
(WebCore::SWClientConnection::notifyClientsOfControllerChange):
* workers/service/server/SWClientConnection.h:
* workers/service/server/SWServer.cpp:
(WebCore::SWServer::Connection::serviceWorkerStartedControllingClient):
(WebCore::SWServer::Connection::serviceWorkerStoppedControllingClient):
(WebCore::SWServer::serviceWorkerStartedControllingClient):
(WebCore::SWServer::serviceWorkerStoppedControllingClient):
* workers/service/server/SWServer.h:
* workers/service/server/SWServerRegistration.cpp:
(WebCore::SWServerRegistration::addClientUsingRegistration):
(WebCore::SWServerRegistration::removeClientUsingRegistration):
* workers/service/server/SWServerRegistration.h:

Source/WebKit:

* Platform/IPC/ArgumentCoders.h:
* Scripts/webkit/messages.py:
(forward_declarations_and_headers):
* StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
(WebKit::WebSWServerConnection::notifyClientsOfControllerChange):
(WebKit::WebSWServerConnection::postMessageToServiceWorkerGlobalScope):
(WebKit::WebSWServerConnection::postMessageToServiceWorkerClient):
* StorageProcess/ServiceWorker/WebSWServerConnection.h:
* StorageProcess/ServiceWorker/WebSWServerConnection.messages.in:
* StorageProcess/StorageProcess.cpp:
(WebKit::StorageProcess::postMessageToServiceWorkerClient):
* WebProcess/Storage/WebSWClientConnection.cpp:
(WebKit::WebSWClientConnection::postMessageToServiceWorkerGlobalScope):
(WebKit::WebSWClientConnection::serviceWorkerStartedControllingClient):
(WebKit::WebSWClientConnection::serviceWorkerStoppedControllingClient):
(WebKit::WebSWClientConnection::postMessageToServiceWorkerClient):
* WebProcess/Storage/WebSWClientConnection.h:
* WebProcess/Storage/WebSWClientConnection.messages.in:

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

22 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/dom/DocumentIdentifier.h [new file with mode: 0644]
Source/WebCore/workers/service/ServiceWorkerClientIdentifier.h
Source/WebCore/workers/service/server/SWClientConnection.cpp
Source/WebCore/workers/service/server/SWClientConnection.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/Platform/IPC/ArgumentCoders.h
Source/WebKit/Scripts/webkit/messages.py
Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp
Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h
Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in
Source/WebKit/StorageProcess/StorageProcess.cpp
Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp
Source/WebKit/WebProcess/Storage/WebSWClientConnection.h
Source/WebKit/WebProcess/Storage/WebSWClientConnection.messages.in

index fa038c2..c09843e 100644 (file)
@@ -1,3 +1,37 @@
+2017-11-27  Chris Dumez  <cdumez@apple.com>
+
+        Give Document a strongly typed identifier instead of a uint64_t
+        https://bugs.webkit.org/show_bug.cgi?id=180041
+
+        Reviewed by Youenn Fablet.
+
+        Give Document a strongly typed identifier instead of a uint64_t, for clarity.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * dom/Document.cpp:
+        (WebCore::m_identifier):
+        * dom/Document.h:
+        (WebCore::Document::identifier const):
+        * dom/DocumentIdentifier.h: Copied from Source/WebCore/workers/service/ServiceWorkerClientIdentifier.h.
+        * workers/service/ServiceWorkerClientIdentifier.h:
+        (WebCore::ServiceWorkerClientIdentifier::toString const):
+        (WebCore::ServiceWorkerClientIdentifier::encode const):
+        (WebCore::ServiceWorkerClientIdentifier::decode):
+        * workers/service/server/SWClientConnection.cpp:
+        (WebCore::SWClientConnection::postMessageToServiceWorkerClient):
+        (WebCore::SWClientConnection::notifyClientsOfControllerChange):
+        * workers/service/server/SWClientConnection.h:
+        * workers/service/server/SWServer.cpp:
+        (WebCore::SWServer::Connection::serviceWorkerStartedControllingClient):
+        (WebCore::SWServer::Connection::serviceWorkerStoppedControllingClient):
+        (WebCore::SWServer::serviceWorkerStartedControllingClient):
+        (WebCore::SWServer::serviceWorkerStoppedControllingClient):
+        * workers/service/server/SWServer.h:
+        * workers/service/server/SWServerRegistration.cpp:
+        (WebCore::SWServerRegistration::addClientUsingRegistration):
+        (WebCore::SWServerRegistration::removeClientUsingRegistration):
+        * workers/service/server/SWServerRegistration.h:
+
 2017-11-27  Simon Fraser  <simon.fraser@apple.com>
 
         Optimize FEDisplacementMap
index a1596d3..7ae3423 100644 (file)
                46DBB6501AB8C96F00D9A813 /* PowerObserverMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 46DBB64E1AB8C96F00D9A813 /* PowerObserverMac.h */; };
                46DFF4981DC2603100B80B48 /* ShadowRootMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 46DFF4961DC2601300B80B48 /* ShadowRootMode.h */; settings = {ATTRIBUTES = (Private, ); }; };
                46DFF49C1DC2620B00B80B48 /* JSShadowRootMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 46DFF49A1DC261F900B80B48 /* JSShadowRootMode.h */; };
+               46E1666E1FCC86A200C9710B /* DocumentIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 46E1666C1FCC868700C9710B /* DocumentIdentifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
                46E791491F97E01A00199739 /* JSVisibilityState.h in Headers */ = {isa = PBXBuildFile; fileRef = 46E791461F97E01700199739 /* JSVisibilityState.h */; };
                46EB37CA1F97CCD200B65523 /* JSServiceWorkerClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 46EB37C31F97CCCB00B65523 /* JSServiceWorkerClient.h */; };
                46EB37CC1F97CCD200B65523 /* JSServiceWorkerClients.h in Headers */ = {isa = PBXBuildFile; fileRef = 46EB37C51F97CCCB00B65523 /* JSServiceWorkerClients.h */; };
                7728694E14F8882500F484DC /* EXTTextureFilterAnisotropic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7728694B14F8882500F484DC /* EXTTextureFilterAnisotropic.cpp */; };
                7728694F14F8882500F484DC /* EXTTextureFilterAnisotropic.h in Headers */ = {isa = PBXBuildFile; fileRef = 7728694C14F8882500F484DC /* EXTTextureFilterAnisotropic.h */; };
                7728698414FD9ADA00F484DC /* JSEXTTextureFilterAnisotropic.h in Headers */ = {isa = PBXBuildFile; fileRef = 7728698214FD9ADA00F484DC /* JSEXTTextureFilterAnisotropic.h */; };
-               7779BD951F312D0100C21417 /* VisualViewport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7779BD941F3117B700C21417 /* VisualViewport.cpp */; };
                7779BD961F32246A00C21417 /* JSVisualViewport.h in Headers */ = {isa = PBXBuildFile; fileRef = 7779BD921F2FDBF700C21417 /* JSVisualViewport.h */; };
-               7779BD971F32246D00C21417 /* JSVisualViewport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7779BD911F2FDBCE00C21417 /* JSVisualViewport.cpp */; };
                77A17A7112F28182004E02F6 /* OESVertexArrayObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 77A17A6E12F28182004E02F6 /* OESVertexArrayObject.cpp */; };
                77A17A7212F28182004E02F6 /* OESVertexArrayObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 77A17A6F12F28182004E02F6 /* OESVertexArrayObject.h */; };
                77A17A7712F28642004E02F6 /* WebGLVertexArrayObjectOES.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 77A17A7412F28642004E02F6 /* WebGLVertexArrayObjectOES.cpp */; };
                46DFF4991DC261F900B80B48 /* JSShadowRootMode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSShadowRootMode.cpp; sourceTree = "<group>"; };
                46DFF49A1DC261F900B80B48 /* JSShadowRootMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSShadowRootMode.h; sourceTree = "<group>"; };
                46E016AD1F72D61E00282B2C /* DOMHighResTimeStamp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMHighResTimeStamp.h; sourceTree = "<group>"; };
+               46E1666C1FCC868700C9710B /* DocumentIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentIdentifier.h; sourceTree = "<group>"; };
                46E791451F97E01700199739 /* JSVisibilityState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSVisibilityState.cpp; sourceTree = "<group>"; };
                46E791461F97E01700199739 /* JSVisibilityState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSVisibilityState.h; sourceTree = "<group>"; };
                46EB37C21F97CCCB00B65523 /* JSServiceWorkerClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSServiceWorkerClient.cpp; sourceTree = "<group>"; };
                                A8185F3709765765005826D9 /* DocumentFragment.cpp */,
                                A8185F3509765765005826D9 /* DocumentFragment.h */,
                                1A494ED50A123F1A00FDAFC1 /* DocumentFragment.idl */,
+                               46E1666C1FCC868700C9710B /* DocumentIdentifier.h */,
                                ED2BA83B09A24B91006C0AC4 /* DocumentMarker.h */,
                                CE057FA31220731100A476D5 /* DocumentMarkerController.cpp */,
                                CE057FA41220731100A476D5 /* DocumentMarkerController.h */,
                                A8185F4009765766005826D9 /* Document.h in Headers */,
                                A3BB59F41457A40D00AC56FE /* DocumentEventQueue.h in Headers */,
                                A8185F3D09765766005826D9 /* DocumentFragment.h in Headers */,
+                               46E1666E1FCC86A200C9710B /* DocumentIdentifier.h in Headers */,
                                656D37360ADBA5DE00A4554D /* DocumentLoader.h in Headers */,
                                ED2BA83C09A24B91006C0AC4 /* DocumentMarker.h in Headers */,
                                CE057FA61220731100A476D5 /* DocumentMarkerController.h in Headers */,
index 0ec8645..e296ed2 100644 (file)
@@ -437,12 +437,6 @@ static void printNavigationErrorMessage(Frame* frame, const URL& activeURL, cons
 
 uint64_t Document::s_globalTreeVersion = 0;
 
-static uint64_t generateDocumentIdentifier()
-{
-    static uint64_t identifier = 0;
-    return ++identifier;
-}
-
 auto Document::allDocumentsMap() -> DocumentsMap&
 {
     static NeverDestroyed<DocumentsMap> documents;
@@ -512,7 +506,7 @@ Document::Document(Frame* frame, const URL& url, unsigned documentClasses, unsig
     , m_isSynthesized(constructionFlags & Synthesized)
     , m_isNonRenderedPlaceholder(constructionFlags & NonRenderedPlaceholder)
     , m_orientationNotifier(currentOrientation(frame))
-    , m_identifier(generateDocumentIdentifier())
+    , m_identifier(generateObjectIdentifier<DocumentIdentifierType>())
 {
     auto addResult = allDocumentsMap().add(m_identifier, this);
     ASSERT_UNUSED(addResult, addResult.isNewEntry);
index d8975bc..21a977f 100644 (file)
@@ -30,6 +30,7 @@
 #include "Color.h"
 #include "ContainerNode.h"
 #include "DocumentEventQueue.h"
+#include "DocumentIdentifier.h"
 #include "DocumentTiming.h"
 #include "FocusDirection.h"
 #include "FontSelectorClient.h"
@@ -56,6 +57,7 @@
 #include <wtf/Forward.h>
 #include <wtf/HashCountedSet.h>
 #include <wtf/HashSet.h>
+#include <wtf/ObjectIdentifier.h>
 #include <wtf/WeakPtr.h>
 #include <wtf/text/AtomicStringHash.h>
 
@@ -352,9 +354,9 @@ public:
 
     void removedLastRef();
 
-    uint64_t identifier() const { return m_identifier; }
+    DocumentIdentifier identifier() const { return m_identifier; }
 
-    using DocumentsMap = HashMap<uint64_t, Document*>;
+    using DocumentsMap = HashMap<DocumentIdentifier, Document*>;
     WEBCORE_EXPORT static DocumentsMap::ValuesIteratorRange allDocuments();
     WEBCORE_EXPORT static DocumentsMap& allDocumentsMap();
 
@@ -1857,7 +1859,7 @@ private:
     bool m_grantStorageAccessOverride { false };
 
     RefPtr<DocumentTimeline> m_timeline;
-    uint64_t m_identifier;
+    DocumentIdentifier m_identifier;
 };
 
 Element* eventTargetElementForDocument(Document*);
diff --git a/Source/WebCore/dom/DocumentIdentifier.h b/Source/WebCore/dom/DocumentIdentifier.h
new file mode 100644 (file)
index 0000000..9c93b15
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/ObjectIdentifier.h>
+
+namespace WebCore {
+
+enum DocumentIdentifierType { };
+using DocumentIdentifier = ObjectIdentifier<DocumentIdentifierType>;
+
+}
index 64e5e87..6c204f1 100644 (file)
@@ -27,6 +27,7 @@
 
 #if ENABLE(SERVICE_WORKER)
 
+#include "DocumentIdentifier.h"
 #include "ServiceWorkerTypes.h"
 #include <wtf/text/WTFString.h>
 
@@ -34,9 +35,9 @@ namespace WebCore {
 
 struct ServiceWorkerClientIdentifier {
     SWServerConnectionIdentifier serverConnectionIdentifier;
-    uint64_t scriptExecutionContextIdentifier;
+    DocumentIdentifier contextIdentifier;
 
-    String toString() const { return String::number(serverConnectionIdentifier.toUInt64()) + "-" +  String::number(scriptExecutionContextIdentifier); }
+    String toString() const { return String::number(serverConnectionIdentifier.toUInt64()) + "-" +  String::number(contextIdentifier.toUInt64()); }
 
     template<class Encoder> void encode(Encoder&) const;
     template<class Decoder> static std::optional<ServiceWorkerClientIdentifier> decode(Decoder&);
@@ -45,7 +46,7 @@ struct ServiceWorkerClientIdentifier {
 template<class Encoder>
 void ServiceWorkerClientIdentifier::encode(Encoder& encoder) const
 {
-    encoder << serverConnectionIdentifier << scriptExecutionContextIdentifier;
+    encoder << serverConnectionIdentifier << contextIdentifier;
 }
 
 template<class Decoder>
@@ -56,12 +57,12 @@ std::optional<ServiceWorkerClientIdentifier> ServiceWorkerClientIdentifier::deco
     if (!serverConnectionIdentifier)
         return std::nullopt;
 
-    std::optional<uint64_t> scriptExecutionContextIdentifier;
-    decoder >> scriptExecutionContextIdentifier;
-    if (!scriptExecutionContextIdentifier)
+    std::optional<DocumentIdentifier> contextIdentifier;
+    decoder >> contextIdentifier;
+    if (!contextIdentifier)
         return std::nullopt;
 
-    return { { WTFMove(*serverConnectionIdentifier), WTFMove(*scriptExecutionContextIdentifier) } };
+    return { { WTFMove(*serverConnectionIdentifier), WTFMove(*contextIdentifier) } };
 }
 
 } // namespace WebCore
index d43742c..e860403 100644 (file)
@@ -118,10 +118,10 @@ void SWClientConnection::startScriptFetchForServer(const ServiceWorkerJobDataIde
     job->startScriptFetch();
 }
 
-void SWClientConnection::postMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, Ref<SerializedScriptValue>&& message, ServiceWorkerData&& sourceData, const String& sourceOrigin)
+void SWClientConnection::postMessageToServiceWorkerClient(DocumentIdentifier destinationContextIdentifier, Ref<SerializedScriptValue>&& message, ServiceWorkerData&& sourceData, const String& sourceOrigin)
 {
-    // FIXME: destinationScriptExecutionContextIdentifier can only identify a Document at the moment.
-    auto* destinationDocument = Document::allDocumentsMap().get(destinationScriptExecutionContextIdentifier);
+    // FIXME: destinationContextIdentifier can only identify a Document at the moment.
+    auto* destinationDocument = Document::allDocumentsMap().get(destinationContextIdentifier);
     if (!destinationDocument)
         return;
 
@@ -165,11 +165,11 @@ void SWClientConnection::fireUpdateFoundEvent(ServiceWorkerRegistrationIdentifie
     });
 }
 
-void SWClientConnection::notifyClientsOfControllerChange(const HashSet<uint64_t>& scriptExecutionContexts, ServiceWorkerData&& newController)
+void SWClientConnection::notifyClientsOfControllerChange(const HashSet<DocumentIdentifier>& contextIdentifiers, ServiceWorkerData&& newController)
 {
-    ASSERT(!scriptExecutionContexts.isEmpty());
+    ASSERT(!contextIdentifiers.isEmpty());
 
-    for (auto& clientIdentifier : scriptExecutionContexts) {
+    for (auto& clientIdentifier : contextIdentifiers) {
         // FIXME: Support worker contexts.
         auto* client = Document::allDocumentsMap().get(clientIdentifier);
         if (!client)
index 3b811cd..ee76aa7 100644 (file)
@@ -27,6 +27,7 @@
 
 #if ENABLE(SERVICE_WORKER)
 
+#include "DocumentIdentifier.h"
 #include "ServiceWorkerJob.h"
 #include "ServiceWorkerTypes.h"
 #include <wtf/HashMap.h>
@@ -68,12 +69,12 @@ public:
 
     virtual void didResolveRegistrationPromise(const ServiceWorkerRegistrationKey&) = 0;
 
-    virtual void postMessageToServiceWorkerGlobalScope(ServiceWorkerIdentifier destinationIdentifier, Ref<SerializedScriptValue>&&, uint64_t sourceContextIdentifier, ServiceWorkerClientData&& source) = 0;
+    virtual void postMessageToServiceWorkerGlobalScope(ServiceWorkerIdentifier destinationIdentifier, Ref<SerializedScriptValue>&&, DocumentIdentifier sourceContextIdentifier, ServiceWorkerClientData&& source) = 0;
     virtual SWServerConnectionIdentifier serverConnectionIdentifier() const = 0;
     virtual bool mayHaveServiceWorkerRegisteredForOrigin(const SecurityOrigin&) const = 0;
 
-    virtual void serviceWorkerStartedControllingClient(ServiceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier) = 0;
-    virtual void serviceWorkerStoppedControllingClient(ServiceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier) = 0;
+    virtual void serviceWorkerStartedControllingClient(ServiceWorkerIdentifier, DocumentIdentifier) = 0;
+    virtual void serviceWorkerStoppedControllingClient(ServiceWorkerIdentifier, DocumentIdentifier) = 0;
 
 protected:
     WEBCORE_EXPORT SWClientConnection();
@@ -82,11 +83,11 @@ protected:
     WEBCORE_EXPORT void registrationJobResolvedInServer(const ServiceWorkerJobDataIdentifier&, ServiceWorkerRegistrationData&&, ShouldNotifyWhenResolved);
     WEBCORE_EXPORT void unregistrationJobResolvedInServer(const ServiceWorkerJobDataIdentifier&, bool unregistrationResult);
     WEBCORE_EXPORT void startScriptFetchForServer(const ServiceWorkerJobDataIdentifier&);
-    WEBCORE_EXPORT void postMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, Ref<SerializedScriptValue>&& message, ServiceWorkerData&& source, const String& sourceOrigin);
+    WEBCORE_EXPORT void postMessageToServiceWorkerClient(DocumentIdentifier destinationContextIdentifier, Ref<SerializedScriptValue>&& message, ServiceWorkerData&& source, const String& sourceOrigin);
     WEBCORE_EXPORT void updateRegistrationState(ServiceWorkerRegistrationIdentifier, ServiceWorkerRegistrationState, const std::optional<ServiceWorkerData>&);
     WEBCORE_EXPORT void updateWorkerState(ServiceWorkerIdentifier, ServiceWorkerState);
     WEBCORE_EXPORT void fireUpdateFoundEvent(ServiceWorkerRegistrationIdentifier);
-    WEBCORE_EXPORT void notifyClientsOfControllerChange(const HashSet<uint64_t>& scriptExecutionContexts, ServiceWorkerData&& newController);
+    WEBCORE_EXPORT void notifyClientsOfControllerChange(const HashSet<DocumentIdentifier>& contextIdentifiers, ServiceWorkerData&& newController);
 
 private:
     virtual void scheduleJobInServer(const ServiceWorkerJobData&) = 0;
index ec3a608..6994389 100644 (file)
@@ -170,14 +170,14 @@ void SWServer::Connection::removeServiceWorkerRegistrationInServer(const Service
     m_server.removeClientServiceWorkerRegistration(*this, key, identifier);
 }
 
-void SWServer::Connection::serviceWorkerStartedControllingClient(ServiceWorkerIdentifier serviceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier)
+void SWServer::Connection::serviceWorkerStartedControllingClient(ServiceWorkerIdentifier serviceWorkerIdentifier, DocumentIdentifier contextIdentifier)
 {
-    m_server.serviceWorkerStartedControllingClient(*this, serviceWorkerIdentifier, scriptExecutionContextIdentifier);
+    m_server.serviceWorkerStartedControllingClient(*this, serviceWorkerIdentifier, contextIdentifier);
 }
 
-void SWServer::Connection::serviceWorkerStoppedControllingClient(ServiceWorkerIdentifier serviceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier)
+void SWServer::Connection::serviceWorkerStoppedControllingClient(ServiceWorkerIdentifier serviceWorkerIdentifier, DocumentIdentifier contextIdentifier)
 {
-    m_server.serviceWorkerStoppedControllingClient(*this, serviceWorkerIdentifier, scriptExecutionContextIdentifier);
+    m_server.serviceWorkerStoppedControllingClient(*this, serviceWorkerIdentifier, contextIdentifier);
 }
 
 SWServer::SWServer(UniqueRef<SWOriginStore>&& originStore)
@@ -324,7 +324,7 @@ void SWServer::removeClientServiceWorkerRegistration(Connection& connection, con
     registration->removeClientServiceWorkerRegistration(connection.identifier());
 }
 
-void SWServer::serviceWorkerStartedControllingClient(Connection& connection, ServiceWorkerIdentifier serviceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier)
+void SWServer::serviceWorkerStartedControllingClient(Connection& connection, ServiceWorkerIdentifier serviceWorkerIdentifier, DocumentIdentifier contextIdentifier)
 {
     auto* serviceWorker = m_workersByID.get(serviceWorkerIdentifier);
     if (!serviceWorker)
@@ -334,10 +334,10 @@ void SWServer::serviceWorkerStartedControllingClient(Connection& connection, Ser
     if (!registration)
         return;
 
-    registration->addClientUsingRegistration({ connection.identifier(), scriptExecutionContextIdentifier });
+    registration->addClientUsingRegistration({ connection.identifier(), contextIdentifier });
 }
 
-void SWServer::serviceWorkerStoppedControllingClient(Connection& connection, ServiceWorkerIdentifier serviceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier)
+void SWServer::serviceWorkerStoppedControllingClient(Connection& connection, ServiceWorkerIdentifier serviceWorkerIdentifier, DocumentIdentifier contextIdentifier)
 {
     auto* serviceWorker = m_workersByID.get(serviceWorkerIdentifier);
     if (!serviceWorker)
@@ -347,7 +347,7 @@ void SWServer::serviceWorkerStoppedControllingClient(Connection& connection, Ser
     if (!registration)
         return;
 
-    registration->removeClientUsingRegistration({ connection.identifier(), scriptExecutionContextIdentifier });
+    registration->removeClientUsingRegistration({ connection.identifier(), contextIdentifier });
 }
 
 void SWServer::updateWorker(Connection&, const ServiceWorkerJobDataIdentifier& jobDataIdentifier, const ServiceWorkerRegistrationKey& registrationKey, const URL& url, const String& script, WorkerType type)
index 0bb0c56..d58dabb 100644 (file)
@@ -27,6 +27,7 @@
 
 #if ENABLE(SERVICE_WORKER)
 
+#include "DocumentIdentifier.h"
 #include "SWServerWorker.h"
 #include "ServiceWorkerIdentifier.h"
 #include "ServiceWorkerJob.h"
@@ -73,7 +74,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 notifyClientsOfControllerChange(const HashSet<uint64_t>& scriptExecutionContexts, const ServiceWorkerData& newController) = 0;
+        virtual void notifyClientsOfControllerChange(const HashSet<DocumentIdentifier>& contextIdentifiers, const ServiceWorkerData& newController) = 0;
 
     protected:
         WEBCORE_EXPORT explicit Connection(SWServer&);
@@ -83,8 +84,8 @@ public:
         WEBCORE_EXPORT void finishFetchingScriptInServer(const ServiceWorkerFetchResult&);
         WEBCORE_EXPORT void addServiceWorkerRegistrationInServer(const ServiceWorkerRegistrationKey&, ServiceWorkerRegistrationIdentifier);
         WEBCORE_EXPORT void removeServiceWorkerRegistrationInServer(const ServiceWorkerRegistrationKey&, ServiceWorkerRegistrationIdentifier);
-        WEBCORE_EXPORT void serviceWorkerStartedControllingClient(ServiceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier);
-        WEBCORE_EXPORT void serviceWorkerStoppedControllingClient(ServiceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier);
+        WEBCORE_EXPORT void serviceWorkerStartedControllingClient(ServiceWorkerIdentifier, DocumentIdentifier);
+        WEBCORE_EXPORT void serviceWorkerStoppedControllingClient(ServiceWorkerIdentifier, DocumentIdentifier);
 
     private:
         // Messages to the client WebProcess
@@ -150,8 +151,8 @@ private:
 
     void addClientServiceWorkerRegistration(Connection&, const ServiceWorkerRegistrationKey&, ServiceWorkerRegistrationIdentifier);
     void removeClientServiceWorkerRegistration(Connection&, const ServiceWorkerRegistrationKey&, ServiceWorkerRegistrationIdentifier);
-    void serviceWorkerStartedControllingClient(Connection&, ServiceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier);
-    void serviceWorkerStoppedControllingClient(Connection&, ServiceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier);
+    void serviceWorkerStartedControllingClient(Connection&, ServiceWorkerIdentifier, DocumentIdentifier);
+    void serviceWorkerStoppedControllingClient(Connection&, ServiceWorkerIdentifier, DocumentIdentifier);
 
     WEBCORE_EXPORT const SWServerRegistration* doRegistrationMatching(const SecurityOriginData& topOrigin, const URL& clientURL) const;
 
index 89056d4..2eccf58 100644 (file)
@@ -147,8 +147,8 @@ void SWServerRegistration::removeClientServiceWorkerRegistration(SWServerConnect
 void SWServerRegistration::addClientUsingRegistration(const ServiceWorkerClientIdentifier& clientIdentifier)
 {
     auto addResult = m_clientsUsingRegistration.ensure(clientIdentifier.serverConnectionIdentifier, [] {
-        return HashSet<uint64_t> { };
-    }).iterator->value.add(clientIdentifier.scriptExecutionContextIdentifier);
+        return HashSet<DocumentIdentifier> { };
+    }).iterator->value.add(clientIdentifier.contextIdentifier);
     ASSERT_UNUSED(addResult, addResult.isNewEntry);
 }
 
@@ -156,7 +156,7 @@ void SWServerRegistration::removeClientUsingRegistration(const ServiceWorkerClie
 {
     auto iterator = m_clientsUsingRegistration.find(clientIdentifier.serverConnectionIdentifier);
     ASSERT(iterator != m_clientsUsingRegistration.end());
-    bool wasRemoved = iterator->value.remove(clientIdentifier.scriptExecutionContextIdentifier);
+    bool wasRemoved = iterator->value.remove(clientIdentifier.contextIdentifier);
     ASSERT_UNUSED(wasRemoved, wasRemoved);
 
     if (iterator->value.isEmpty())
index 1b8b505..31f6aee 100644 (file)
@@ -100,7 +100,7 @@ private:
     SWServer& m_server;
 
     MonotonicTime m_creationTime;
-    HashMap<SWServerConnectionIdentifier, HashSet<uint64_t /* scriptExecutionContextIdentifier */>> m_clientsUsingRegistration;
+    HashMap<SWServerConnectionIdentifier, HashSet<DocumentIdentifier>> m_clientsUsingRegistration;
 };
 
 } // namespace WebCore
index b017c30..77a8d08 100644 (file)
@@ -1,3 +1,31 @@
+2017-11-27  Chris Dumez  <cdumez@apple.com>
+
+        Give Document a strongly typed identifier instead of a uint64_t
+        https://bugs.webkit.org/show_bug.cgi?id=180041
+
+        Reviewed by Youenn Fablet.
+
+        Give Document a strongly typed identifier instead of a uint64_t, for clarity.
+
+        * Platform/IPC/ArgumentCoders.h:
+        * Scripts/webkit/messages.py:
+        (forward_declarations_and_headers):
+        * StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
+        (WebKit::WebSWServerConnection::notifyClientsOfControllerChange):
+        (WebKit::WebSWServerConnection::postMessageToServiceWorkerGlobalScope):
+        (WebKit::WebSWServerConnection::postMessageToServiceWorkerClient):
+        * StorageProcess/ServiceWorker/WebSWServerConnection.h:
+        * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in:
+        * StorageProcess/StorageProcess.cpp:
+        (WebKit::StorageProcess::postMessageToServiceWorkerClient):
+        * WebProcess/Storage/WebSWClientConnection.cpp:
+        (WebKit::WebSWClientConnection::postMessageToServiceWorkerGlobalScope):
+        (WebKit::WebSWClientConnection::serviceWorkerStartedControllingClient):
+        (WebKit::WebSWClientConnection::serviceWorkerStoppedControllingClient):
+        (WebKit::WebSWClientConnection::postMessageToServiceWorkerClient):
+        * WebProcess/Storage/WebSWClientConnection.h:
+        * WebProcess/Storage/WebSWClientConnection.messages.in:
+
 2017-11-27  Yacine Bandou  <yacine.bandou_ext@softathome.com>
 
         [GTK][WPE] Add "enable-encrypted-media" property to WebKitWebSettings
index 61b8eb7..8357eab 100644 (file)
@@ -424,11 +424,12 @@ template<typename KeyArg, typename HashArg, typename KeyTraitsArg> struct Argume
 
         HashSetType tempHashSet;
         for (uint64_t i = 0; i < hashSetSize; ++i) {
-            KeyArg key;
-            if (!decoder.decode(key))
+            std::optional<KeyArg> key;
+            decoder >> key;
+            if (!key)
                 return false;
 
-            if (!tempHashSet.add(key).isNewEntry) {
+            if (!tempHashSet.add(*key).isNewEntry) {
                 // The hash map already has the specified key, bail.
                 decoder.markInvalid();
                 return false;
index b33686b..f16afbb 100644 (file)
@@ -184,6 +184,7 @@ def forward_declarations_and_headers(receiver):
             types_by_namespace['IPC'].update([('class', 'Connection')])
 
     no_forward_declaration_types = frozenset([
+        'WebCore::DocumentIdentifier',
         'WebCore::ServiceWorkerIdentifier',
         'WebCore::ServiceWorkerRegistrationIdentifier',
         'WebCore::SWServerConnectionIdentifier',
index 4b58fa3..8be32c0 100644 (file)
@@ -104,9 +104,9 @@ void WebSWServerConnection::fireUpdateFoundEvent(ServiceWorkerRegistrationIdenti
     send(Messages::WebSWClientConnection::FireUpdateFoundEvent(identifier));
 }
 
-void WebSWServerConnection::notifyClientsOfControllerChange(const HashSet<uint64_t>& scriptExecutionContexts, const ServiceWorkerData& newController)
+void WebSWServerConnection::notifyClientsOfControllerChange(const HashSet<DocumentIdentifier>& contextIdentifiers, const ServiceWorkerData& newController)
 {
-    send(Messages::WebSWClientConnection::NotifyClientsOfControllerChange(scriptExecutionContexts, newController));
+    send(Messages::WebSWClientConnection::NotifyClientsOfControllerChange(contextIdentifiers, newController));
 }
 
 void WebSWServerConnection::updateWorkerStateInClient(ServiceWorkerIdentifier worker, ServiceWorkerState state)
@@ -119,7 +119,7 @@ void WebSWServerConnection::startFetch(uint64_t fetchIdentifier, std::optional<S
     sendToContextProcess(Messages::WebSWContextManagerConnection::StartFetch { identifier(), fetchIdentifier, serviceWorkerIdentifier, request, options, formData });
 }
 
-void WebSWServerConnection::postMessageToServiceWorkerGlobalScope(ServiceWorkerIdentifier destinationServiceWorkerIdentifier, const IPC::DataReference& message, uint64_t sourceContextIdentifier, ServiceWorkerClientData&& sourceData)
+void WebSWServerConnection::postMessageToServiceWorkerGlobalScope(ServiceWorkerIdentifier destinationServiceWorkerIdentifier, const IPC::DataReference& message, DocumentIdentifier sourceContextIdentifier, ServiceWorkerClientData&& sourceData)
 {
     ServiceWorkerClientIdentifier sourceIdentifier { identifier(), sourceContextIdentifier };
     sendToContextProcess(Messages::WebSWContextManagerConnection::PostMessageToServiceWorkerGlobalScope { destinationServiceWorkerIdentifier, message, sourceIdentifier, WTFMove(sourceData) });
@@ -155,13 +155,13 @@ void WebSWServerConnection::didNotHandleFetch(uint64_t fetchIdentifier)
     m_contentConnection->send(Messages::ServiceWorkerClientFetch::DidNotHandle { }, fetchIdentifier);
 }
 
-void WebSWServerConnection::postMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, const IPC::DataReference& message, ServiceWorkerIdentifier sourceIdentifier, const String& sourceOrigin)
+void WebSWServerConnection::postMessageToServiceWorkerClient(DocumentIdentifier destinationContextIdentifier, const IPC::DataReference& message, ServiceWorkerIdentifier sourceIdentifier, const String& sourceOrigin)
 {
     auto* sourceServiceWorker = server().workerByID(sourceIdentifier);
     if (!sourceServiceWorker)
         return;
 
-    send(Messages::WebSWClientConnection::PostMessageToServiceWorkerClient { destinationScriptExecutionContextIdentifier, message, sourceServiceWorker->data(), sourceOrigin });
+    send(Messages::WebSWClientConnection::PostMessageToServiceWorkerClient { destinationContextIdentifier, message, sourceServiceWorker->data(), sourceOrigin });
 }
 
 void WebSWServerConnection::matchRegistration(uint64_t registrationMatchRequestIdentifier, const SecurityOriginData& topOrigin, const URL& clientURL)
index f042317..0fbebcd 100644 (file)
@@ -62,7 +62,7 @@ public:
     void didFailFetch(uint64_t fetchIdentifier);
     void didNotHandleFetch(uint64_t fetchIdentifier);
 
-    void postMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, const IPC::DataReference& message, WebCore::ServiceWorkerIdentifier sourceServiceWorkerIdentifier, const String& sourceOrigin);
+    void postMessageToServiceWorkerClient(WebCore::DocumentIdentifier destinationContextIdentifier, const IPC::DataReference& message, WebCore::ServiceWorkerIdentifier sourceServiceWorkerIdentifier, const String& sourceOrigin);
 
 private:
     // Implement SWServer::Connection (Messages to the client WebProcess)
@@ -73,11 +73,11 @@ 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 notifyClientsOfControllerChange(const HashSet<uint64_t>& scriptExecutionContexts, const WebCore::ServiceWorkerData& newController);
+    void notifyClientsOfControllerChange(const HashSet<WebCore::DocumentIdentifier>& contextIdentifiers, const WebCore::ServiceWorkerData& newController);
 
     void startFetch(uint64_t fetchIdentifier, std::optional<WebCore::ServiceWorkerIdentifier>, const WebCore::ResourceRequest&, const WebCore::FetchOptions&, const IPC::FormDataReference&);
 
-    void postMessageToServiceWorkerGlobalScope(WebCore::ServiceWorkerIdentifier destinationIdentifier, const IPC::DataReference& message, uint64_t sourceContextIdentifier, WebCore::ServiceWorkerClientData&& source);
+    void postMessageToServiceWorkerGlobalScope(WebCore::ServiceWorkerIdentifier destinationIdentifier, const IPC::DataReference& message, WebCore::DocumentIdentifier sourceContextIdentifier, WebCore::ServiceWorkerClientData&& source);
 
     void matchRegistration(uint64_t registrationMatchRequestIdentifier, const WebCore::SecurityOriginData& topOrigin, const WebCore::URL& clientURL);
     void getRegistrations(uint64_t registrationMatchRequestIdentifier, const WebCore::SecurityOriginData& topOrigin, const WebCore::URL& clientURL);
index 127dd7a..ab99494 100644 (file)
@@ -28,11 +28,11 @@ messages -> WebSWServerConnection {
     FinishFetchingScriptInServer(struct WebCore::ServiceWorkerFetchResult result)
     AddServiceWorkerRegistrationInServer(WebCore::ServiceWorkerRegistrationKey key, WebCore::ServiceWorkerRegistrationIdentifier identifier)
     RemoveServiceWorkerRegistrationInServer(WebCore::ServiceWorkerRegistrationKey key, WebCore::ServiceWorkerRegistrationIdentifier identifier)
-    ServiceWorkerStartedControllingClient(WebCore::ServiceWorkerIdentifier serviceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier)
-    ServiceWorkerStoppedControllingClient(WebCore::ServiceWorkerIdentifier serviceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier)
+    ServiceWorkerStartedControllingClient(WebCore::ServiceWorkerIdentifier serviceWorkerIdentifier, WebCore::DocumentIdentifier contextIdentifier)
+    ServiceWorkerStoppedControllingClient(WebCore::ServiceWorkerIdentifier serviceWorkerIdentifier, WebCore::DocumentIdentifier contextIdentifier)
 
     StartFetch(uint64_t identifier, std::optional<WebCore::ServiceWorkerIdentifier> serviceWorkerIdentifier, WebCore::ResourceRequest request, struct WebCore::FetchOptions options, IPC::FormDataReference requestBody)
-    PostMessageToServiceWorkerGlobalScope(WebCore::ServiceWorkerIdentifier destinationServiceWorkerIdentifier, IPC::DataReference message, uint64_t sourceContextIdentifier, struct WebCore::ServiceWorkerClientData source)
+    PostMessageToServiceWorkerGlobalScope(WebCore::ServiceWorkerIdentifier destinationServiceWorkerIdentifier, IPC::DataReference message, WebCore::DocumentIdentifier sourceContextIdentifier, struct WebCore::ServiceWorkerClientData source)
 
     DidResolveRegistrationPromise(WebCore::ServiceWorkerRegistrationKey key)
 
index 8f6a988..17e0e74 100644 (file)
@@ -449,7 +449,7 @@ void StorageProcess::didFinishFetch(SWServerConnectionIdentifier serverConnectio
 void StorageProcess::postMessageToServiceWorkerClient(const ServiceWorkerClientIdentifier& destinationIdentifier, const IPC::DataReference& message, ServiceWorkerIdentifier sourceIdentifier, const String& sourceOrigin)
 {
     if (auto* connection = m_swServerConnections.get(destinationIdentifier.serverConnectionIdentifier))
-        connection->postMessageToServiceWorkerClient(destinationIdentifier.scriptExecutionContextIdentifier, message, sourceIdentifier, sourceOrigin);
+        connection->postMessageToServiceWorkerClient(destinationIdentifier.contextIdentifier, message, sourceIdentifier, sourceOrigin);
 }
 
 void StorageProcess::registerSWServerConnection(WebSWServerConnection& connection)
index c847654..000b7ed 100644 (file)
@@ -82,19 +82,19 @@ void WebSWClientConnection::removeServiceWorkerRegistrationInServer(const Servic
     send(Messages::WebSWServerConnection::RemoveServiceWorkerRegistrationInServer(key, identifier));
 }
 
-void WebSWClientConnection::postMessageToServiceWorkerGlobalScope(ServiceWorkerIdentifier destinationIdentifier, Ref<SerializedScriptValue>&& scriptValue, uint64_t sourceContextIdentifier, ServiceWorkerClientData&& source)
+void WebSWClientConnection::postMessageToServiceWorkerGlobalScope(ServiceWorkerIdentifier destinationIdentifier, Ref<SerializedScriptValue>&& scriptValue, DocumentIdentifier sourceContextIdentifier, ServiceWorkerClientData&& source)
 {
     send(Messages::WebSWServerConnection::PostMessageToServiceWorkerGlobalScope(destinationIdentifier, IPC::DataReference { scriptValue->data() }, sourceContextIdentifier, WTFMove(source)));
 }
 
-void WebSWClientConnection::serviceWorkerStartedControllingClient(ServiceWorkerIdentifier serviceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier)
+void WebSWClientConnection::serviceWorkerStartedControllingClient(ServiceWorkerIdentifier serviceWorkerIdentifier, DocumentIdentifier contextIdentifier)
 {
-    send(Messages::WebSWServerConnection::ServiceWorkerStartedControllingClient(serviceWorkerIdentifier, scriptExecutionContextIdentifier));
+    send(Messages::WebSWServerConnection::ServiceWorkerStartedControllingClient(serviceWorkerIdentifier, contextIdentifier));
 }
 
-void WebSWClientConnection::serviceWorkerStoppedControllingClient(ServiceWorkerIdentifier serviceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier)
+void WebSWClientConnection::serviceWorkerStoppedControllingClient(ServiceWorkerIdentifier serviceWorkerIdentifier, DocumentIdentifier contextIdentifier)
 {
-    send(Messages::WebSWServerConnection::ServiceWorkerStoppedControllingClient(serviceWorkerIdentifier, scriptExecutionContextIdentifier));
+    send(Messages::WebSWServerConnection::ServiceWorkerStoppedControllingClient(serviceWorkerIdentifier, contextIdentifier));
 }
 
 void WebSWClientConnection::didResolveRegistrationPromise(const ServiceWorkerRegistrationKey& key)
@@ -164,9 +164,9 @@ Ref<ServiceWorkerClientFetch> WebSWClientConnection::startFetch(WebServiceWorker
     return ServiceWorkerClientFetch::create(provider, WTFMove(loader), identifier, m_connection.get(), WTFMove(callback));
 }
 
-void WebSWClientConnection::postMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, const IPC::DataReference& message, ServiceWorkerData&& source, const String& sourceOrigin)
+void WebSWClientConnection::postMessageToServiceWorkerClient(DocumentIdentifier destinationContextIdentifier, const IPC::DataReference& message, ServiceWorkerData&& source, const String& sourceOrigin)
 {
-    SWClientConnection::postMessageToServiceWorkerClient(destinationScriptExecutionContextIdentifier, SerializedScriptValue::adopt(message.vector()), WTFMove(source), sourceOrigin);
+    SWClientConnection::postMessageToServiceWorkerClient(destinationContextIdentifier, SerializedScriptValue::adopt(message.vector()), WTFMove(source), sourceOrigin);
 }
 
 } // namespace WebKit
index aba3c72..282e54e 100644 (file)
@@ -63,14 +63,14 @@ public:
     bool mayHaveServiceWorkerRegisteredForOrigin(const WebCore::SecurityOrigin&) const final;
     Ref<ServiceWorkerClientFetch> startFetch(WebServiceWorkerProvider&, Ref<WebCore::ResourceLoader>&&, uint64_t identifier, ServiceWorkerClientFetch::Callback&&);
 
-    void postMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, const IPC::DataReference& message, WebCore::ServiceWorkerData&& source, const String& sourceOrigin);
+    void postMessageToServiceWorkerClient(WebCore::DocumentIdentifier destinationContextIdentifier, const IPC::DataReference& message, WebCore::ServiceWorkerData&& source, const String& sourceOrigin);
 
 private:
     void scheduleJobInServer(const WebCore::ServiceWorkerJobData&) final;
     void finishFetchingScriptInServer(const WebCore::ServiceWorkerFetchResult&) final;
-    void postMessageToServiceWorkerGlobalScope(WebCore::ServiceWorkerIdentifier destinationIdentifier, Ref<WebCore::SerializedScriptValue>&&, uint64_t sourceContextIdentifier, WebCore::ServiceWorkerClientData&& source) final;
-    void serviceWorkerStartedControllingClient(WebCore::ServiceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier) final;
-    void serviceWorkerStoppedControllingClient(WebCore::ServiceWorkerIdentifier, uint64_t scriptExecutionContextIdentifier) final;
+    void postMessageToServiceWorkerGlobalScope(WebCore::ServiceWorkerIdentifier destinationIdentifier, Ref<WebCore::SerializedScriptValue>&&, WebCore::DocumentIdentifier sourceContextIdentifier, WebCore::ServiceWorkerClientData&& source) final;
+    void serviceWorkerStartedControllingClient(WebCore::ServiceWorkerIdentifier, WebCore::DocumentIdentifier) final;
+    void serviceWorkerStoppedControllingClient(WebCore::ServiceWorkerIdentifier, WebCore::DocumentIdentifier) final;
 
     void matchRegistration(const WebCore::SecurityOrigin& topOrigin, const WebCore::URL& clientURL, RegistrationCallback&&) final;
     void didMatchRegistration(uint64_t matchRequestIdentifier, std::optional<WebCore::ServiceWorkerRegistrationData>&&);
index 40a72f7..a33081f 100644 (file)
@@ -31,11 +31,11 @@ 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)
-    NotifyClientsOfControllerChange(HashSet<uint64_t> scriptExecutionContexts, struct WebCore::ServiceWorkerData newController)
+    NotifyClientsOfControllerChange(HashSet<WebCore::DocumentIdentifier> contextIdentifiers, struct WebCore::ServiceWorkerData newController)
 
     InitializeSWOriginTableAsEmpty()
     SetSWOriginTableSharedMemory(WebKit::SharedMemory::Handle handle)
-    PostMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, IPC::DataReference message, struct WebCore::ServiceWorkerData source, String sourceOrigin)
+    PostMessageToServiceWorkerClient(WebCore::DocumentIdentifier destinationContextIdentifier, IPC::DataReference message, struct WebCore::ServiceWorkerData source, String sourceOrigin)
 
     DidMatchRegistration(uint64_t matchRequestIdentifier, std::optional<WebCore::ServiceWorkerRegistrationData> data)
     DidGetRegistrations(uint64_t matchRequestIdentifier, Vector<WebCore::ServiceWorkerRegistrationData> registrations)