Use a single identifier type to identify Service Workers
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Nov 2017 16:37:04 +0000 (16:37 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Nov 2017 16:37:04 +0000 (16:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=179192

Reviewed by Brady Eidson.

Source/WebCore:

Use a single identifier type to identify Service Workers. We had both a String
identifier and a uint64_t identifier for each service worker. We now consistently
use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a
uint64_t.

* WebCore.xcodeproj/project.pbxproj:
* loader/ResourceLoaderOptions.h:
* loader/cache/CachedResourceRequest.cpp:
(WebCore::CachedResourceRequest::setSelectedServiceWorkerIdentifierIfNeeded):
* loader/cache/CachedResourceRequest.h:
* workers/service/ServiceWorker.cpp:
(WebCore::ServiceWorker::ServiceWorker):
* workers/service/ServiceWorker.h:
* workers/service/ServiceWorkerClient.cpp:
(WebCore::ServiceWorkerClient::postMessage):
* workers/service/ServiceWorkerContainer.cpp:
(WebCore::ServiceWorkerContainer::jobResolvedWithRegistration):
* workers/service/ServiceWorkerContextData.cpp:
(WebCore::ServiceWorkerContextData::isolatedCopy const):
* workers/service/ServiceWorkerContextData.h:
(WebCore::ServiceWorkerContextData::encode const):
(WebCore::ServiceWorkerContextData::decode):
* workers/service/ServiceWorkerIdentifier.h: Copied from Source/WebCore/workers/service/ServiceWorkerContextData.cpp.
* workers/service/ServiceWorkerRegistrationData.h:
(WebCore::ServiceWorkerRegistrationData::decode):
* workers/service/context/SWContextManager.cpp:
(WebCore::SWContextManager::serviceWorkerThreadProxy const):
(WebCore::SWContextManager::postMessageToServiceWorkerGlobalScope):
* workers/service/context/SWContextManager.h:
* workers/service/context/ServiceWorkerThread.cpp:
(WebCore::ServiceWorkerThread::ServiceWorkerThread):
* workers/service/context/ServiceWorkerThread.h:
(WebCore::ServiceWorkerThread::identifier const):
* workers/service/context/ServiceWorkerThreadProxy.h:
* workers/service/server/SWClientConnection.cpp:
(WebCore::SWClientConnection::postMessageToServiceWorkerClient):
* workers/service/server/SWClientConnection.h:
* workers/service/server/SWServer.cpp:
(WebCore::generateServiceWorkerIdentifier):
(WebCore::SWServer::Connection::scriptContextFailedToStart):
(WebCore::SWServer::Connection::scriptContextStarted):
(WebCore::SWServer::scriptContextFailedToStart):
(WebCore::SWServer::scriptContextStarted):
(WebCore::SWServer::updateWorker):
* workers/service/server/SWServer.h:
* workers/service/server/SWServerJobQueue.cpp:
(WebCore::SWServerJobQueue::scriptContextFailedToStart):
(WebCore::SWServerJobQueue::scriptContextStarted):
* workers/service/server/SWServerJobQueue.h:
* workers/service/server/SWServerRegistration.h:
(WebCore::SWServerRegistration::setActiveServiceWorkerIdentifier):
* workers/service/server/SWServerWorker.cpp:
(WebCore::SWServerWorker::SWServerWorker):
* workers/service/server/SWServerWorker.h:
(WebCore::SWServerWorker::create):
(WebCore::SWServerWorker::identifier const):

Source/WebKit:

Use a single identifier type to identify Service Workers. We had both a String
identifier and a uint64_t identifier for each service worker. We now consistently
use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a
uint64_t.

* Scripts/webkit/messages.py:
(forward_declarations_and_headers):
(forward_declarations_and_headers.templates):
* StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
(WebKit::WebSWServerConnection::startFetch):
(WebKit::WebSWServerConnection::postMessageToServiceWorkerGlobalScope):
(WebKit::WebSWServerConnection::postMessageToServiceWorkerClient):
* StorageProcess/ServiceWorker/WebSWServerConnection.h:
* StorageProcess/ServiceWorker/WebSWServerConnection.messages.in:
* StorageProcess/StorageProcess.cpp:
(WebKit::StorageProcess::serviceWorkerContextFailedToStart):
(WebKit::StorageProcess::serviceWorkerContextStarted):
(WebKit::StorageProcess::postMessageToServiceWorkerClient):
* StorageProcess/StorageProcess.h:
* StorageProcess/StorageProcess.messages.in:
* WebProcess/Storage/WebSWClientConnection.cpp:
(WebKit::WebSWClientConnection::postMessageToServiceWorkerGlobalScope):
(WebKit::WebSWClientConnection::postMessageToServiceWorkerClient):
* WebProcess/Storage/WebSWClientConnection.h:
* WebProcess/Storage/WebSWClientConnection.messages.in:
* WebProcess/Storage/WebSWContextManagerConnection.cpp:
(WebKit::WebSWContextManagerConnection::updateServiceWorker):
(WebKit::WebSWContextManagerConnection::serviceWorkerStartedWithMessage):
(WebKit::WebSWContextManagerConnection::startFetch):
(WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerGlobalScope):
(WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerClient):
* WebProcess/Storage/WebSWContextManagerConnection.h:
* WebProcess/Storage/WebSWContextManagerConnection.messages.in:

Source/WTF:

Introduce class for strongly typed identifiers. This avoids mixing up
different types of identifiers.

* WTF.xcodeproj/project.pbxproj:
* wtf/ObjectIdentifier.h: Added.
(WTF::ObjectIdentifier::encode const):
(WTF::ObjectIdentifier::decode):
(WTF::ObjectIdentifier::operator== const):
(WTF::ObjectIdentifier::operator!= const):
(WTF::ObjectIdentifier::ObjectIdentifier):
(WTF::makeObjectIdentifier):
(WTF::ObjectIdentifierHash::hash):
(WTF::ObjectIdentifierHash::equal):
(WTF::HashTraits<ObjectIdentifier<T>>::emptyValue):
(WTF::HashTraits<ObjectIdentifier<T>>::constructDeletedValue):
(WTF::HashTraits<ObjectIdentifier<T>>::isDeletedValue):

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

47 files changed:
Source/WTF/ChangeLog
Source/WTF/WTF.xcodeproj/project.pbxproj
Source/WTF/wtf/ObjectIdentifier.h [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/loader/ResourceLoaderOptions.h
Source/WebCore/loader/cache/CachedResourceRequest.cpp
Source/WebCore/loader/cache/CachedResourceRequest.h
Source/WebCore/workers/service/ServiceWorker.cpp
Source/WebCore/workers/service/ServiceWorker.h
Source/WebCore/workers/service/ServiceWorkerClient.cpp
Source/WebCore/workers/service/ServiceWorkerContainer.cpp
Source/WebCore/workers/service/ServiceWorkerContextData.cpp
Source/WebCore/workers/service/ServiceWorkerContextData.h
Source/WebCore/workers/service/ServiceWorkerIdentifier.h [new file with mode: 0644]
Source/WebCore/workers/service/ServiceWorkerRegistration.cpp
Source/WebCore/workers/service/ServiceWorkerRegistration.h
Source/WebCore/workers/service/ServiceWorkerRegistrationData.h
Source/WebCore/workers/service/context/SWContextManager.cpp
Source/WebCore/workers/service/context/SWContextManager.h
Source/WebCore/workers/service/context/ServiceWorkerThread.cpp
Source/WebCore/workers/service/context/ServiceWorkerThread.h
Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.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/SWServerJobQueue.cpp
Source/WebCore/workers/service/server/SWServerJobQueue.h
Source/WebCore/workers/service/server/SWServerRegistration.cpp
Source/WebCore/workers/service/server/SWServerRegistration.h
Source/WebCore/workers/service/server/SWServerWorker.cpp
Source/WebCore/workers/service/server/SWServerWorker.h
Source/WebKit/ChangeLog
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/StorageProcess/StorageProcess.h
Source/WebKit/StorageProcess/StorageProcess.messages.in
Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp
Source/WebKit/WebProcess/Storage/WebSWClientConnection.h
Source/WebKit/WebProcess/Storage/WebSWClientConnection.messages.in
Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp
Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h
Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.messages.in

index 7b82d79..206157a 100644 (file)
@@ -1,3 +1,27 @@
+2017-11-03  Chris Dumez  <cdumez@apple.com>
+
+        Use a single identifier type to identify Service Workers
+        https://bugs.webkit.org/show_bug.cgi?id=179192
+
+        Reviewed by Brady Eidson.
+
+        Introduce class for strongly typed identifiers. This avoids mixing up
+        different types of identifiers.
+
+        * WTF.xcodeproj/project.pbxproj:
+        * wtf/ObjectIdentifier.h: Added.
+        (WTF::ObjectIdentifier::encode const):
+        (WTF::ObjectIdentifier::decode):
+        (WTF::ObjectIdentifier::operator== const):
+        (WTF::ObjectIdentifier::operator!= const):
+        (WTF::ObjectIdentifier::ObjectIdentifier):
+        (WTF::makeObjectIdentifier):
+        (WTF::ObjectIdentifierHash::hash):
+        (WTF::ObjectIdentifierHash::equal):
+        (WTF::HashTraits<ObjectIdentifier<T>>::emptyValue):
+        (WTF::HashTraits<ObjectIdentifier<T>>::constructDeletedValue):
+        (WTF::HashTraits<ObjectIdentifier<T>>::isDeletedValue):
+
 2017-11-02  Ryan Haddad  <ryanhaddad@apple.com>
 
         Unreviewed, rolling out r224353.
index 997ec31..9b881ac 100644 (file)
                7E29C33D15FFD79B00516D61 /* ObjcRuntimeExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjcRuntimeExtras.h; sourceTree = "<group>"; };
                8134013615B092FD001FF0B8 /* Base64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Base64.cpp; sourceTree = "<group>"; };
                8134013715B092FD001FF0B8 /* Base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Base64.h; sourceTree = "<group>"; };
+               83A8AC3D1FABBE94002064AC /* ObjectIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectIdentifier.h; sourceTree = "<group>"; };
                83F2BADE1CF9524E003E99C3 /* Function.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Function.h; sourceTree = "<group>"; };
                83FBA93119DF459700F30ADB /* TypeCasts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TypeCasts.h; sourceTree = "<group>"; };
                86F46F5F1A2840EE00CCBF22 /* RefCounter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RefCounter.h; sourceTree = "<group>"; };
                                A8A472D5151A825B004123FF /* NumberOfCores.cpp */,
                                A8A472D6151A825B004123FF /* NumberOfCores.h */,
                                7E29C33D15FFD79B00516D61 /* ObjcRuntimeExtras.h */,
+                               83A8AC3D1FABBE94002064AC /* ObjectIdentifier.h */,
                                1AFDE6521953B23D00C48FFA /* Optional.h */,
                                1A4656181C7FC68E00F5920F /* OptionSet.h */,
                                0F9495831C571CC900413A48 /* OrderMaker.h */,
diff --git a/Source/WTF/wtf/ObjectIdentifier.h b/Source/WTF/wtf/ObjectIdentifier.h
new file mode 100644 (file)
index 0000000..09f901c
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * 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/HashTraits.h>
+
+namespace WTF {
+
+template<typename T> class ObjectIdentifier {
+public:
+    ObjectIdentifier() = default;
+
+    ObjectIdentifier(HashTableDeletedValueType) : m_identifier(hashTableDeletedValue()) { }
+    bool isHashTableDeletedValue() const { return m_identifier == hashTableDeletedValue(); }
+
+    template<typename Encoder> void encode(Encoder& encoder) const
+    {
+        ASSERT(isValidIdentifier(m_identifier));
+        encoder << m_identifier;
+    }
+    template<typename Decoder> static std::optional<ObjectIdentifier> decode(Decoder& decoder)
+    {
+        std::optional<uint64_t> identifier;
+        decoder >> identifier;
+        if (!identifier)
+            return std::nullopt;
+        ASSERT(isValidIdentifier(*identifier));
+        return ObjectIdentifier { *identifier };
+    }
+
+    bool operator==(const ObjectIdentifier& other) const
+    {
+        return m_identifier == other.m_identifier;
+    }
+
+    bool operator!=(const ObjectIdentifier& other) const
+    {
+        return m_identifier != other.m_identifier;
+    }
+
+private:
+    template<typename U> friend ObjectIdentifier<U> makeObjectIdentifier(uint64_t);
+    friend struct HashTraits<ObjectIdentifier>;
+    template<typename U> friend struct ObjectIdentifierHash;
+
+    static uint64_t hashTableDeletedValue() { return std::numeric_limits<uint64_t>::max(); }
+    static bool isValidIdentifier(uint64_t identifier) { return identifier && identifier != hashTableDeletedValue(); }
+
+    explicit ObjectIdentifier(uint64_t identifier)
+        : m_identifier(identifier)
+    {
+    }
+
+    uint64_t m_identifier { 0 };
+};
+
+template<typename T> inline ObjectIdentifier<T> makeObjectIdentifier(uint64_t identifier)
+{
+    ASSERT(ObjectIdentifier<T>::isValidIdentifier(identifier));
+    return ObjectIdentifier<T> { identifier };
+}
+
+template<typename T> struct ObjectIdentifierHash {
+    static unsigned hash(const ObjectIdentifier<T>& identifier) { return intHash(identifier.m_identifier); }
+    static bool equal(const ObjectIdentifier<T>& a, const ObjectIdentifier<T>& b) { return a == b; }
+    static const bool safeToCompareToEmptyOrDeleted = true;
+};
+
+template<typename T> struct HashTraits<ObjectIdentifier<T>> : SimpleClassHashTraits<ObjectIdentifier<T>> { };
+
+template<typename T> struct DefaultHash<ObjectIdentifier<T>> {
+    typedef ObjectIdentifierHash<T> Hash;
+};
+
+} // namespace WTF
+
+using WTF::ObjectIdentifier;
+using WTF::makeObjectIdentifier;
index ddf860c..0407e9b 100644 (file)
@@ -1,3 +1,67 @@
+2017-11-03  Chris Dumez  <cdumez@apple.com>
+
+        Use a single identifier type to identify Service Workers
+        https://bugs.webkit.org/show_bug.cgi?id=179192
+
+        Reviewed by Brady Eidson.
+
+        Use a single identifier type to identify Service Workers. We had both a String
+        identifier and a uint64_t identifier for each service worker. We now consistently
+        use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a
+        uint64_t.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * loader/ResourceLoaderOptions.h:
+        * loader/cache/CachedResourceRequest.cpp:
+        (WebCore::CachedResourceRequest::setSelectedServiceWorkerIdentifierIfNeeded):
+        * loader/cache/CachedResourceRequest.h:
+        * workers/service/ServiceWorker.cpp:
+        (WebCore::ServiceWorker::ServiceWorker):
+        * workers/service/ServiceWorker.h:
+        * workers/service/ServiceWorkerClient.cpp:
+        (WebCore::ServiceWorkerClient::postMessage):
+        * workers/service/ServiceWorkerContainer.cpp:
+        (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration):
+        * workers/service/ServiceWorkerContextData.cpp:
+        (WebCore::ServiceWorkerContextData::isolatedCopy const):
+        * workers/service/ServiceWorkerContextData.h:
+        (WebCore::ServiceWorkerContextData::encode const):
+        (WebCore::ServiceWorkerContextData::decode):
+        * workers/service/ServiceWorkerIdentifier.h: Copied from Source/WebCore/workers/service/ServiceWorkerContextData.cpp.
+        * workers/service/ServiceWorkerRegistrationData.h:
+        (WebCore::ServiceWorkerRegistrationData::decode):
+        * workers/service/context/SWContextManager.cpp:
+        (WebCore::SWContextManager::serviceWorkerThreadProxy const):
+        (WebCore::SWContextManager::postMessageToServiceWorkerGlobalScope):
+        * workers/service/context/SWContextManager.h:
+        * workers/service/context/ServiceWorkerThread.cpp:
+        (WebCore::ServiceWorkerThread::ServiceWorkerThread):
+        * workers/service/context/ServiceWorkerThread.h:
+        (WebCore::ServiceWorkerThread::identifier const):
+        * workers/service/context/ServiceWorkerThreadProxy.h:
+        * workers/service/server/SWClientConnection.cpp:
+        (WebCore::SWClientConnection::postMessageToServiceWorkerClient):
+        * workers/service/server/SWClientConnection.h:
+        * workers/service/server/SWServer.cpp:
+        (WebCore::generateServiceWorkerIdentifier):
+        (WebCore::SWServer::Connection::scriptContextFailedToStart):
+        (WebCore::SWServer::Connection::scriptContextStarted):
+        (WebCore::SWServer::scriptContextFailedToStart):
+        (WebCore::SWServer::scriptContextStarted):
+        (WebCore::SWServer::updateWorker):
+        * workers/service/server/SWServer.h:
+        * workers/service/server/SWServerJobQueue.cpp:
+        (WebCore::SWServerJobQueue::scriptContextFailedToStart):
+        (WebCore::SWServerJobQueue::scriptContextStarted):
+        * workers/service/server/SWServerJobQueue.h:
+        * workers/service/server/SWServerRegistration.h:
+        (WebCore::SWServerRegistration::setActiveServiceWorkerIdentifier):
+        * workers/service/server/SWServerWorker.cpp:
+        (WebCore::SWServerWorker::SWServerWorker):
+        * workers/service/server/SWServerWorker.h:
+        (WebCore::SWServerWorker::create):
+        (WebCore::SWServerWorker::identifier const):
+
 2017-11-02  Andy Estes  <aestes@apple.com>
 
         [Payment Request] show() should only be called with user activation
index b85632e..28f0e7d 100644 (file)
                839947101F50B6FA00E9D86B /* JSDOMFileSystem.h in Headers */ = {isa = PBXBuildFile; fileRef = 8399470E1F50B6F300E9D86B /* JSDOMFileSystem.h */; };
                839A2F2E1E204A710039057E /* WebGLStateTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = 839A2F2C1E204A6D0039057E /* WebGLStateTracker.h */; settings = {ATTRIBUTES = (Private, ); }; };
                839AAFED1A0C0C8D00605F99 /* HTMLWBRElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 839AAFEB1A0C0C8D00605F99 /* HTMLWBRElement.h */; };
+               83A8AC401FABBFE5002064AC /* ServiceWorkerIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 83A8AC3E1FABBFD1002064AC /* ServiceWorkerIdentifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
                83B2D1751B8BCD6A00A02E47 /* NativeNodeFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 83E959E11B8BC22B004D9385 /* NativeNodeFilter.h */; settings = {ATTRIBUTES = (Private, ); }; };
                83B74EF61F3E0BF200996BC7 /* KeepaliveRequestTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = 83B74EF31F3E0BD700996BC7 /* KeepaliveRequestTracker.h */; settings = {ATTRIBUTES = (Private, ); }; };
                83B9687B19F8AB83004EF7AF /* StyleBuilderConverter.h in Headers */ = {isa = PBXBuildFile; fileRef = 83B9687919F8AB83004EF7AF /* StyleBuilderConverter.h */; };
                839AAFEA1A0C0C8D00605F99 /* HTMLWBRElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLWBRElement.cpp; sourceTree = "<group>"; };
                839AAFEB1A0C0C8D00605F99 /* HTMLWBRElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLWBRElement.h; sourceTree = "<group>"; };
                83A4A9F81CE7FD7E00709B00 /* JSXMLDocumentCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSXMLDocumentCustom.cpp; sourceTree = "<group>"; };
+               83A8AC3E1FABBFD1002064AC /* ServiceWorkerIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ServiceWorkerIdentifier.h; sourceTree = "<group>"; };
                83B250091FA1181C00BC02D9 /* JSServiceWorkerClientType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSServiceWorkerClientType.h; sourceTree = "<group>"; };
                83B2500B1FA1181D00BC02D9 /* JSServiceWorkerClientType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSServiceWorkerClientType.cpp; sourceTree = "<group>"; };
                83B5DA451FA9079300B59DF4 /* JSNavigatorCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSNavigatorCustom.cpp; sourceTree = "<group>"; };
                                51F175551F3EBC0C00C74950 /* ServiceWorkerGlobalScope.cpp */,
                                51F175541F3EBC0C00C74950 /* ServiceWorkerGlobalScope.h */,
                                51F175531F3EBC0C00C74950 /* ServiceWorkerGlobalScope.idl */,
+                               83A8AC3E1FABBFD1002064AC /* ServiceWorkerIdentifier.h */,
                                51F175521F3EBC0C00C74950 /* ServiceWorkerJob.cpp */,
                                51F175511F3EBC0C00C74950 /* ServiceWorkerJob.h */,
                                51F175501F3EBC0C00C74950 /* ServiceWorkerJobClient.h */,
                                419ACF921F97E7DA009F1A83 /* ServiceWorkerFetch.h in Headers */,
                                517A535D1F5899FE00DCDC0A /* ServiceWorkerFetchResult.h in Headers */,
                                51F175611F3EBC8300C74950 /* ServiceWorkerGlobalScope.h in Headers */,
+                               83A8AC401FABBFE5002064AC /* ServiceWorkerIdentifier.h in Headers */,
                                A52B34961FA3E290008B6246 /* ServiceWorkerInspectorProxy.h in Headers */,
                                51F175631F3EBC8300C74950 /* ServiceWorkerJob.h in Headers */,
                                51F175641F3EBC8300C74950 /* ServiceWorkerJobClient.h in Headers */,
index 6574b37..1f01a7f 100644 (file)
@@ -31,6 +31,7 @@
 #pragma once
 
 #include "FetchOptions.h"
+#include "ServiceWorkerIdentifier.h"
 #include "StoredCredentialsPolicy.h"
 #include <wtf/Vector.h>
 #include <wtf/text/WTFString.h>
@@ -136,7 +137,9 @@ struct ResourceLoaderOptions : public FetchOptions {
     SameOriginDataURLFlag sameOriginDataURLFlag { SameOriginDataURLFlag::Unset };
     InitiatorContext initiatorContext { InitiatorContext::Document };
     ServiceWorkersMode serviceWorkersMode { ServiceWorkersMode::All };
-    uint64_t serviceWorkerIdentifier { 0 };
+#if ENABLE(SERVICE_WORKER)
+    std::optional<ServiceWorkerIdentifier> serviceWorkerIdentifier;
+#endif
 
     ClientCredentialPolicy clientCredentialPolicy { ClientCredentialPolicy::CannotAskClientForCredentials };
     unsigned maxRedirectCount { 20 };
index cb8f9de..905e104 100644 (file)
@@ -274,7 +274,7 @@ void CachedResourceRequest::setDestinationIfNotSet(FetchOptions::Destination des
 }
 
 #if ENABLE(SERVICE_WORKER)
-void CachedResourceRequest::setSelectedServiceWorkerIdentifierIfNeeded(uint64_t serviceWorkerIdentifier)
+void CachedResourceRequest::setSelectedServiceWorkerIdentifierIfNeeded(ServiceWorkerIdentifier identifier)
 {
     if (isNonSubresourceRequest(m_options.destination))
         return;
@@ -286,7 +286,7 @@ void CachedResourceRequest::setSelectedServiceWorkerIdentifierIfNeeded(uint64_t
     if (m_options.serviceWorkerIdentifier)
         return;
 
-    m_options.serviceWorkerIdentifier = serviceWorkerIdentifier;
+    m_options.serviceWorkerIdentifier = identifier;
 }
 #endif
 
index 9269c31..7d04640 100644 (file)
@@ -31,6 +31,7 @@
 #include "ResourceLoaderOptions.h"
 #include "ResourceRequest.h"
 #include "SecurityOrigin.h"
+#include "ServiceWorkerIdentifier.h"
 #include <wtf/RefPtr.h>
 #include <wtf/text/AtomicString.h>
 
@@ -96,7 +97,7 @@ public:
     static String splitFragmentIdentifierFromRequestURL(ResourceRequest&);
 
 #if ENABLE(SERVICE_WORKER)
-    void setSelectedServiceWorkerIdentifierIfNeeded(uint64_t serviceWorkerIdentifier);
+    void setSelectedServiceWorkerIdentifierIfNeeded(ServiceWorkerIdentifier);
 #endif
 
 private:
index 0e3ebc8..bbbd39f 100644 (file)
@@ -38,9 +38,9 @@
 
 namespace WebCore {
 
-ServiceWorker::ServiceWorker(ScriptExecutionContext& context, uint64_t serviceWorkerIdentifier, const URL& scriptURL)
+ServiceWorker::ServiceWorker(ScriptExecutionContext& context, ServiceWorkerIdentifier identifier, const URL& scriptURL)
     : ContextDestructionObserver(&context)
-    , m_identifier(serviceWorkerIdentifier)
+    , m_identifier(identifier)
     , m_scriptURL(scriptURL)
 {
 }
index e70b045..8eede9b 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "ContextDestructionObserver.h"
 #include "EventTarget.h"
+#include "ServiceWorkerIdentifier.h"
 #include "URL.h"
 #include <heap/Strong.h>
 #include <wtf/RefCounted.h>
@@ -43,9 +44,9 @@ class Frame;
 
 class ServiceWorker final : public RefCounted<ServiceWorker>, public EventTargetWithInlineData, public ContextDestructionObserver {
 public:
-    static Ref<ServiceWorker> create(ScriptExecutionContext& context, uint64_t serviceWorkerIdentifier, const URL& scriptURL)
+    static Ref<ServiceWorker> create(ScriptExecutionContext& context, ServiceWorkerIdentifier identifier, const URL& scriptURL)
     {
-        return adoptRef(*new ServiceWorker(context, serviceWorkerIdentifier, scriptURL));
+        return adoptRef(*new ServiceWorker(context, identifier, scriptURL));
     }
 
     virtual ~ServiceWorker() = default;
@@ -65,20 +66,20 @@ public:
 
     ExceptionOr<void> postMessage(ScriptExecutionContext&, JSC::JSValue message, Vector<JSC::Strong<JSC::JSObject>>&&);
 
-    uint64_t identifier() const { return m_identifier; }
+    ServiceWorkerIdentifier identifier() const { return m_identifier; }
 
     using RefCounted::ref;
     using RefCounted::deref;
 
 private:
-    ServiceWorker(ScriptExecutionContext&, uint64_t serviceWorkerIdentifier, const URL& scriptURL);
+    ServiceWorker(ScriptExecutionContext&, ServiceWorkerIdentifier, const URL& scriptURL);
 
     virtual EventTargetInterface eventTargetInterface() const;
     virtual ScriptExecutionContext* scriptExecutionContext() const;
     void refEventTarget() final { ref(); }
     void derefEventTarget() final { deref(); }
 
-    uint64_t m_identifier;
+    ServiceWorkerIdentifier m_identifier;
     URL m_scriptURL;
     State m_state { State::Installing };
 };
index 67de30c..02ab224 100644 (file)
@@ -83,7 +83,7 @@ ExceptionOr<void> ServiceWorkerClient::postMessage(ScriptExecutionContext& conte
     if (channels && !channels->isEmpty())
         return Exception { NotSupportedError, ASCIILiteral("Passing MessagePort objects to postMessage is not yet supported") };
 
-    uint64_t sourceIdentifier = downcast<ServiceWorkerGlobalScope>(context).thread().identifier();
+    auto sourceIdentifier = downcast<ServiceWorkerGlobalScope>(context).thread().identifier();
     callOnMainThread([message = message.releaseReturnValue(), destinationIdentifier = m_identifier, sourceIdentifier, sourceOrigin = context.origin().isolatedCopy()] () mutable {
         if (auto* connection = SWContextManager::singleton().connection())
             connection->postMessageToServiceWorkerClient(destinationIdentifier, WTFMove(message), sourceIdentifier, sourceOrigin);
index 646b345..4a1a1b5 100644 (file)
@@ -244,8 +244,9 @@ void ServiceWorkerContainer::jobResolvedWithRegistration(ServiceWorkerJob& job,
 
     // FIXME: Implement proper selection of service workers.
     auto* activeServiceWorker = context->activeServiceWorker();
-    if (!activeServiceWorker || activeServiceWorker->identifier() != data.activeServiceWorkerIdentifier) {
-        context->setActiveServiceWorker(ServiceWorker::create(*context, data.activeServiceWorkerIdentifier, data.scriptURL));
+    ASSERT(data.activeServiceWorkerIdentifier);
+    if (!activeServiceWorker || activeServiceWorker->identifier() != *data.activeServiceWorkerIdentifier) {
+        context->setActiveServiceWorker(ServiceWorker::create(*context, *data.activeServiceWorkerIdentifier, data.scriptURL));
         activeServiceWorker = context->activeServiceWorker();
     }
 
index 3cd2d3f..4d33501 100644 (file)
@@ -32,7 +32,7 @@ namespace WebCore {
 
 ServiceWorkerContextData ServiceWorkerContextData::isolatedCopy() const
 {
-    return { registrationKey.isolatedCopy(), workerID.isolatedCopy(), script.isolatedCopy(), scriptURL.isolatedCopy() };
+    return { registrationKey.isolatedCopy(), serviceWorkerIdentifier, script.isolatedCopy(), scriptURL.isolatedCopy() };
 }
 
 } // namespace WebCore
index a8713b3..08c31bc 100644 (file)
@@ -25,6 +25,7 @@
 
 #pragma once
 
+#include "ServiceWorkerIdentifier.h"
 #include "ServiceWorkerRegistrationKey.h"
 #include "URL.h"
 
@@ -34,7 +35,7 @@ namespace WebCore {
 
 struct ServiceWorkerContextData {
     ServiceWorkerRegistrationKey registrationKey;
-    String workerID;
+    ServiceWorkerIdentifier serviceWorkerIdentifier;
     String script;
     URL scriptURL;
     
@@ -47,7 +48,7 @@ struct ServiceWorkerContextData {
 template<class Encoder>
 void ServiceWorkerContextData::encode(Encoder& encoder) const
 {
-    encoder << registrationKey << workerID << script << scriptURL;
+    encoder << registrationKey << serviceWorkerIdentifier << script << scriptURL;
 }
 
 template<class Decoder>
@@ -57,8 +58,8 @@ std::optional<ServiceWorkerContextData> ServiceWorkerContextData::decode(Decoder
     if (!registrationKey)
         return std::nullopt;
 
-    String workerID;
-    if (!decoder.decode(workerID))
+    auto serviceWorkerIdentifier = ServiceWorkerIdentifier::decode(decoder);
+    if (!serviceWorkerIdentifier)
         return std::nullopt;
 
     String script;
@@ -69,7 +70,7 @@ std::optional<ServiceWorkerContextData> ServiceWorkerContextData::decode(Decoder
     if (!decoder.decode(scriptURL))
         return std::nullopt;
 
-    return {{ WTFMove(*registrationKey), WTFMove(workerID), WTFMove(script), WTFMove(scriptURL) }};
+    return {{ WTFMove(*registrationKey), WTFMove(*serviceWorkerIdentifier), WTFMove(script), WTFMove(scriptURL) }};
 }
 
 } // namespace WebCore
diff --git a/Source/WebCore/workers/service/ServiceWorkerIdentifier.h b/Source/WebCore/workers/service/ServiceWorkerIdentifier.h
new file mode 100644 (file)
index 0000000..5473f0d
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * 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
+
+#if ENABLE(SERVICE_WORKER)
+
+#include <wtf/ObjectIdentifier.h>
+
+namespace WebCore {
+
+enum ServiceWorkerIdentifierType { };
+using ServiceWorkerIdentifier = ObjectIdentifier<ServiceWorkerIdentifierType>;
+
+} // namespace WebCore
+
+#endif // ENABLE(SERVICE_WORKER)
index ab1a9c2..6a04e7b 100644 (file)
@@ -106,11 +106,11 @@ void ServiceWorkerRegistration::unregister(Ref<DeferredPromise>&& promise)
     container->removeRegistration(m_registrationData.scopeURL, WTFMove(promise));
 }
 
-void ServiceWorkerRegistration::updateStateFromServer(ServiceWorkerRegistrationState state, const String& workerID)
+void ServiceWorkerRegistration::updateStateFromServer(ServiceWorkerRegistrationState state, std::optional<ServiceWorkerIdentifier> serviceWorkerIdentifier)
 {
     // FIXME: Implement here along with "Update Worker State" algorithm
     UNUSED_PARAM(state);
-    UNUSED_PARAM(workerID);
+    UNUSED_PARAM(serviceWorkerIdentifier);
 }
 
 EventTargetInterface ServiceWorkerRegistration::eventTargetInterface() const
index 0e5ba7d..2cd0da6 100644 (file)
@@ -63,7 +63,7 @@ public:
     
     const ServiceWorkerRegistrationData& data() const { return m_registrationData; }
 
-    void updateStateFromServer(ServiceWorkerRegistrationState, const String& workerID);
+    void updateStateFromServer(ServiceWorkerRegistrationState, std::optional<ServiceWorkerIdentifier>);
 
 private:
     ServiceWorkerRegistration(ScriptExecutionContext&, SWClientConnection&, ServiceWorkerRegistrationData&&, Ref<ServiceWorker>&&);
index dc55f66..2e84d7e 100644 (file)
@@ -27,6 +27,7 @@
 
 #if ENABLE(SERVICE_WORKER)
 
+#include "ServiceWorkerIdentifier.h"
 #include "ServiceWorkerRegistrationKey.h"
 
 namespace WebCore {
@@ -36,7 +37,7 @@ enum class ServiceWorkerUpdateViaCache;
 struct ServiceWorkerRegistrationData {
     ServiceWorkerRegistrationKey key;
     uint64_t identifier;
-    uint64_t activeServiceWorkerIdentifier; // FIXME: This should not be part of registrationData.
+    std::optional<ServiceWorkerIdentifier> activeServiceWorkerIdentifier; // FIXME: This should not be part of registrationData.
     URL scopeURL;
     URL scriptURL;
     ServiceWorkerUpdateViaCache updateViaCache;
@@ -67,7 +68,8 @@ std::optional<ServiceWorkerRegistrationData> ServiceWorkerRegistrationData::deco
     if (!identifier)
         return std::nullopt;
 
-    std::optional<uint64_t> activeServiceWorkerIdentifier;
+
+    std::optional<std::optional<ServiceWorkerIdentifier>> activeServiceWorkerIdentifier;
     decoder >> activeServiceWorkerIdentifier;
     if (!activeServiceWorkerIdentifier)
         return std::nullopt;
index 2d19e28..009b034 100644 (file)
@@ -59,14 +59,14 @@ void SWContextManager::registerServiceWorkerThreadForUpdate(Ref<ServiceWorkerThr
     });
 }
 
-ServiceWorkerThreadProxy* SWContextManager::serviceWorkerThreadProxy(uint64_t serviceWorkerIdentifier) const
+ServiceWorkerThreadProxy* SWContextManager::serviceWorkerThreadProxy(ServiceWorkerIdentifier identifier) const
 {
-    return m_workerMap.get(serviceWorkerIdentifier);
+    return m_workerMap.get(identifier);
 }
 
-void SWContextManager::postMessageToServiceWorkerGlobalScope(uint64_t destinationServiceWorkerIdentifier, Ref<SerializedScriptValue>&& message, const ServiceWorkerClientIdentifier& sourceIdentifier, const String& sourceOrigin)
+void SWContextManager::postMessageToServiceWorkerGlobalScope(ServiceWorkerIdentifier destination, Ref<SerializedScriptValue>&& message, const ServiceWorkerClientIdentifier& sourceIdentifier, const String& sourceOrigin)
 {
-    auto* serviceWorker = m_workerMap.get(destinationServiceWorkerIdentifier);
+    auto* serviceWorker = m_workerMap.get(destination);
     if (!serviceWorker)
         return;
 
index 960f47d..cdc6815 100644 (file)
@@ -28,6 +28,7 @@
 #if ENABLE(SERVICE_WORKER)
 
 #include "ExceptionOr.h"
+#include "ServiceWorkerIdentifier.h"
 #include "ServiceWorkerThreadProxy.h"
 #include <wtf/HashMap.h>
 
@@ -44,21 +45,21 @@ public:
     public:
         virtual ~Connection() { }
 
-        virtual void postMessageToServiceWorkerClient(const ServiceWorkerClientIdentifier& destinationIdentifier, Ref<SerializedScriptValue>&& message, uint64_t sourceServiceWorkerIdentifier, const String& sourceOrigin) = 0;
-        virtual void serviceWorkerStartedWithMessage(uint64_t serviceWorkerIdentifier, const String& exceptionMessage) = 0;
+        virtual void postMessageToServiceWorkerClient(const ServiceWorkerClientIdentifier& destinationIdentifier, Ref<SerializedScriptValue>&& message, ServiceWorkerIdentifier source, const String& sourceOrigin) = 0;
+        virtual void serviceWorkerStartedWithMessage(ServiceWorkerIdentifier, const String& exceptionMessage) = 0;
     };
 
     WEBCORE_EXPORT void setConnection(std::unique_ptr<Connection>&&);
     WEBCORE_EXPORT Connection* connection() const;
 
     WEBCORE_EXPORT void registerServiceWorkerThreadForUpdate(Ref<ServiceWorkerThreadProxy>&&);
-    WEBCORE_EXPORT ServiceWorkerThreadProxy* serviceWorkerThreadProxy(uint64_t) const;
-    WEBCORE_EXPORT void postMessageToServiceWorkerGlobalScope(uint64_t destinationServiceWorkerIdentifier, Ref<SerializedScriptValue>&& message, const ServiceWorkerClientIdentifier& sourceIdentifier, const String& sourceOrigin);
+    WEBCORE_EXPORT ServiceWorkerThreadProxy* serviceWorkerThreadProxy(ServiceWorkerIdentifier) const;
+    WEBCORE_EXPORT void postMessageToServiceWorkerGlobalScope(ServiceWorkerIdentifier destination, Ref<SerializedScriptValue>&& message, const ServiceWorkerClientIdentifier& sourceIdentifier, const String& sourceOrigin);
 
 private:
     SWContextManager() = default;
 
-    HashMap<uint64_t, RefPtr<ServiceWorkerThreadProxy>> m_workerMap;
+    HashMap<ServiceWorkerIdentifier, RefPtr<ServiceWorkerThreadProxy>> m_workerMap;
     std::unique_ptr<Connection> m_connection;
 };
 
index 63ffdee..e00bbbe 100644 (file)
@@ -38,6 +38,7 @@
 #include "WorkerDebuggerProxy.h"
 #include "WorkerLoaderProxy.h"
 #include "WorkerObjectProxy.h"
+#include <inspector/IdentifiersFactory.h>
 #include <pal/SessionID.h>
 #include <runtime/RuntimeFlags.h>
 #include <wtf/NeverDestroyed.h>
@@ -71,7 +72,7 @@ private:
 // FIXME: Use valid runtime flags
 
 ServiceWorkerThread::ServiceWorkerThread(uint64_t serverConnectionIdentifier, const ServiceWorkerContextData& data, PAL::SessionID, WorkerLoaderProxy& loaderProxy, WorkerDebuggerProxy& debuggerProxy)
-    : WorkerThread(data.scriptURL, data.workerID, ASCIILiteral("WorkerUserAgent"), /* isOnline */ false, data.script, loaderProxy, debuggerProxy, DummyServiceWorkerThreadProxy::shared(), WorkerThreadStartMode::Normal, ContentSecurityPolicyResponseHeaders { }, false, SecurityOrigin::create(data.scriptURL).get(), MonotonicTime::now(), nullptr, nullptr, JSC::RuntimeFlags::createAllEnabled(), SessionID::defaultSessionID())
+    : WorkerThread(data.scriptURL, "serviceworker:" + Inspector::IdentifiersFactory::createIdentifier(), ASCIILiteral("WorkerUserAgent"), /* isOnline */ false, data.script, loaderProxy, debuggerProxy, DummyServiceWorkerThreadProxy::shared(), WorkerThreadStartMode::Normal, ContentSecurityPolicyResponseHeaders { }, false, SecurityOrigin::create(data.scriptURL).get(), MonotonicTime::now(), nullptr, nullptr, JSC::RuntimeFlags::createAllEnabled(), SessionID::defaultSessionID())
     , m_serverConnectionIdentifier(serverConnectionIdentifier)
     , m_data(data.isolatedCopy())
     , m_workerObjectProxy(DummyServiceWorkerThreadProxy::shared())
index 22349b2..59bab76 100644 (file)
@@ -29,8 +29,8 @@
 
 #include "ServiceWorkerContextData.h"
 #include "ServiceWorkerFetch.h"
+#include "ServiceWorkerIdentifier.h"
 #include "WorkerThread.h"
-#include <wtf/Identified.h>
 
 namespace WebCore {
 
@@ -44,7 +44,7 @@ struct ServiceWorkerContextData;
 
 using MessagePortChannelArray = Vector<std::unique_ptr<MessagePortChannel>, 1>;
 
-class ServiceWorkerThread : public WorkerThread, public ThreadSafeIdentified<ServiceWorkerThread> {
+class ServiceWorkerThread : public WorkerThread {
 public:
     template<typename... Args> static Ref<ServiceWorkerThread> create(Args&&... args)
     {
@@ -60,6 +60,8 @@ public:
     uint64_t serverConnectionIdentifier() const { return m_serverConnectionIdentifier; }
     const ServiceWorkerContextData& contextData() const { return m_data; }
 
+    ServiceWorkerIdentifier identifier() const { return m_data.serviceWorkerIdentifier; }
+
 protected:
     Ref<WorkerGlobalScope> createWorkerGlobalScope(const URL&, const String& identifier, const String& userAgent, bool isOnline, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, PAL::SessionID) final;
     void runEventLoop() override;
index 68b73a4..410b0ea 100644 (file)
@@ -31,6 +31,7 @@
 #include "Document.h"
 #include "Page.h"
 #include "ServiceWorkerDebuggable.h"
+#include "ServiceWorkerIdentifier.h"
 #include "ServiceWorkerInspectorProxy.h"
 #include "ServiceWorkerThread.h"
 #include "WorkerDebuggerProxy.h"
@@ -48,7 +49,7 @@ class ServiceWorkerThreadProxy final : public ThreadSafeRefCounted<ServiceWorker
 public:
     WEBCORE_EXPORT static Ref<ServiceWorkerThreadProxy> create(PageConfiguration&&, uint64_t serverConnectionIdentifier, const ServiceWorkerContextData&, PAL::SessionID, CacheStorageProvider&);
 
-    uint64_t identifier() const { return m_serviceWorkerThread->identifier(); }
+    ServiceWorkerIdentifier identifier() const { return m_serviceWorkerThread->identifier(); }
     ServiceWorkerThread& thread() { return m_serviceWorkerThread.get(); }
     ServiceWorkerInspectorProxy& inspectorProxy() { return m_inspectorProxy; }
 
index 97f051c..70462af 100644 (file)
@@ -139,7 +139,7 @@ void SWClientConnection::startScriptFetchForServer(uint64_t jobIdentifier)
     job->startScriptFetch();
 }
 
-void SWClientConnection::postMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, Ref<SerializedScriptValue>&& message, uint64_t sourceServiceWorkerIdentifier, const String& sourceOrigin)
+void SWClientConnection::postMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, Ref<SerializedScriptValue>&& message, ServiceWorkerIdentifier sourceIdentifier, const String& sourceOrigin)
 {
     // FIXME: destinationScriptExecutionContextIdentifier can only identify a Document at the moment.
     auto* destinationDocument = Document::allDocumentsMap().get(destinationScriptExecutionContextIdentifier);
@@ -152,11 +152,11 @@ void SWClientConnection::postMessageToServiceWorkerClient(uint64_t destinationSc
 
     std::optional<MessageEventSource> source;
     auto* activeServiceWorker = destinationDocument->activeServiceWorker();
-    if (activeServiceWorker && activeServiceWorker->identifier() == sourceServiceWorkerIdentifier)
+    if (activeServiceWorker && activeServiceWorker->identifier() == sourceIdentifier)
         source = MessageEventSource { RefPtr<ServiceWorker> { activeServiceWorker } };
     else {
         // FIXME: Pass in valid scriptURL.
-        source = MessageEventSource { RefPtr<ServiceWorker> { ServiceWorker::create(*destinationDocument, sourceServiceWorkerIdentifier, URL()) } };
+        source = MessageEventSource { RefPtr<ServiceWorker> { ServiceWorker::create(*destinationDocument, sourceIdentifier, URL()) } };
     }
 
     // FIXME: We should pass in ports.
@@ -164,14 +164,14 @@ void SWClientConnection::postMessageToServiceWorkerClient(uint64_t destinationSc
     container->dispatchEvent(messageEvent);
 }
 
-void SWClientConnection::updateRegistrationState(const ServiceWorkerRegistrationKey& key, ServiceWorkerRegistrationState state, const String& workerID)
+void SWClientConnection::updateRegistrationState(const ServiceWorkerRegistrationKey& key, ServiceWorkerRegistrationState state, std::optional<ServiceWorkerIdentifier> serviceWorkerIdentifier)
 {
     auto* registrations = m_registrations.get(key);
     if (!registrations)
         return;
     
     for (auto& registration : *registrations)
-        registration->updateStateFromServer(state, workerID);
+        registration->updateStateFromServer(state, serviceWorkerIdentifier);
 }
 
 } // namespace WebCore
index 987c6b7..7909f59 100644 (file)
@@ -53,7 +53,7 @@ public:
     void addServiceWorkerRegistration(ServiceWorkerRegistration&);
     void removeServiceWorkerRegistration(ServiceWorkerRegistration&);
 
-    virtual void postMessageToServiceWorkerGlobalScope(uint64_t destinationServiceWorkerIdentifier, Ref<SerializedScriptValue>&&, ScriptExecutionContext& source) = 0;
+    virtual void postMessageToServiceWorkerGlobalScope(ServiceWorkerIdentifier destinationIdentifier, Ref<SerializedScriptValue>&&, ScriptExecutionContext& source) = 0;
     virtual uint64_t identifier() const = 0;
     virtual bool hasServiceWorkerRegisteredForOrigin(const SecurityOrigin&) const = 0;
 
@@ -64,8 +64,8 @@ protected:
     WEBCORE_EXPORT void registrationJobResolvedInServer(uint64_t jobIdentifier, ServiceWorkerRegistrationData&&);
     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, uint64_t sourceServiceWorkerIdentifier, const String& sourceOrigin);
-    WEBCORE_EXPORT void updateRegistrationState(const ServiceWorkerRegistrationKey&, ServiceWorkerRegistrationState, const String& workerID);
+    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>);
 
 private:
     virtual void scheduleJobInServer(const ServiceWorkerJobData&) = 0;
index 1c0c35d..36d1bd3 100644 (file)
 #include "ServiceWorkerContextData.h"
 #include "ServiceWorkerFetchResult.h"
 #include "ServiceWorkerJobData.h"
-#include <wtf/UUID.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
+static ServiceWorkerIdentifier generateServiceWorkerIdentifier()
+{
+    static uint64_t identifier = 0;
+    return makeObjectIdentifier<ServiceWorkerIdentifierType>(++identifier);
+}
+
 SWServer::Connection::Connection(SWServer& server, uint64_t identifier)
     : Identified(identifier)
     , m_server(server)
@@ -109,14 +114,14 @@ void SWServer::Connection::removeServiceWorkerRegistrationInServer(const Service
     m_server.removeClientServiceWorkerRegistration(*this, key, clientRegistrationIdentifier);
 }
 
-void SWServer::Connection::scriptContextFailedToStart(const ServiceWorkerRegistrationKey& registrationKey, const String& workerID, const String& message)
+void SWServer::Connection::scriptContextFailedToStart(const ServiceWorkerRegistrationKey& registrationKey, ServiceWorkerIdentifier identifier, const String& message)
 {
-    m_server.scriptContextFailedToStart(*this, registrationKey, workerID, message);
+    m_server.scriptContextFailedToStart(*this, registrationKey, identifier, message);
 }
 
-void SWServer::Connection::scriptContextStarted(const ServiceWorkerRegistrationKey& registrationKey, uint64_t serviceWorkerIdentifier, const String& workerID)
+void SWServer::Connection::scriptContextStarted(const ServiceWorkerRegistrationKey& registrationKey, ServiceWorkerIdentifier identifier)
 {
-    m_server.scriptContextStarted(*this, registrationKey, serviceWorkerIdentifier, workerID);
+    m_server.scriptContextStarted(*this, registrationKey, identifier);
 }
 
 SWServer::SWServer()
@@ -195,20 +200,20 @@ void SWServer::scriptFetchFinished(Connection& connection, const ServiceWorkerFe
     jobQueue->scriptFetchFinished(connection, result);
 }
 
-void SWServer::scriptContextFailedToStart(Connection& connection, const ServiceWorkerRegistrationKey& registrationKey, const String& workerID, const String& message)
+void SWServer::scriptContextFailedToStart(Connection& connection, const ServiceWorkerRegistrationKey& registrationKey, ServiceWorkerIdentifier identifier, const String& message)
 {
     ASSERT(m_connections.contains(connection.identifier()));
     
     if (auto* jobQueue = m_jobQueues.get(registrationKey))
-        jobQueue->scriptContextFailedToStart(connection, workerID, message);
+        jobQueue->scriptContextFailedToStart(connection, identifier, message);
 }
 
-void SWServer::scriptContextStarted(Connection& connection, const ServiceWorkerRegistrationKey& registrationKey, uint64_t serviceWorkerIdentifier, const String& workerID)
+void SWServer::scriptContextStarted(Connection& connection, const ServiceWorkerRegistrationKey& registrationKey, ServiceWorkerIdentifier identifier)
 {
     ASSERT(m_connections.contains(connection.identifier()));
 
     if (auto* jobQueue = m_jobQueues.get(registrationKey))
-        jobQueue->scriptContextStarted(connection, serviceWorkerIdentifier, workerID);
+        jobQueue->scriptContextStarted(connection, identifier);
 }
 
 void SWServer::addClientServiceWorkerRegistration(Connection& connection, const ServiceWorkerRegistrationKey& key, uint64_t registrationIdentifier)
@@ -235,12 +240,12 @@ void SWServer::removeClientServiceWorkerRegistration(Connection& connection, con
 
 Ref<SWServerWorker> SWServer::updateWorker(Connection& connection, const ServiceWorkerRegistrationKey& registrationKey, const URL& url, const String& script, WorkerType type)
 {
-    String workerID = createCanonicalUUIDString();
+    auto serviceWorkerIdentifier = generateServiceWorkerIdentifier();
     
-    auto result = m_workersByID.add(workerID, SWServerWorker::create(registrationKey, url, script, type, workerID));
+    auto result = m_workersByID.add(serviceWorkerIdentifier, SWServerWorker::create(registrationKey, url, script, type, serviceWorkerIdentifier));
     ASSERT(result.isNewEntry);
     
-    connection.updateServiceWorkerContext({ registrationKey, workerID, script, url });
+    connection.updateServiceWorkerContext({ registrationKey, serviceWorkerIdentifier, script, url });
     
     return result.iterator->value.get();
 }
index e8023c3..2851017 100644 (file)
@@ -27,6 +27,7 @@
 
 #if ENABLE(SERVICE_WORKER)
 
+#include "ServiceWorkerIdentifier.h"
 #include "ServiceWorkerJob.h"
 #include "ServiceWorkerRegistrationKey.h"
 #include <wtf/CrossThreadQueue.h>
@@ -56,11 +57,11 @@ public:
     public:
         WEBCORE_EXPORT virtual ~Connection();
 
-        WEBCORE_EXPORT void scriptContextFailedToStart(const ServiceWorkerRegistrationKey&, const String& workerID, const String& message);
-        WEBCORE_EXPORT void scriptContextStarted(const ServiceWorkerRegistrationKey&, uint64_t serviceWorkerIdentifier, const String& workerID);
+        WEBCORE_EXPORT void scriptContextFailedToStart(const ServiceWorkerRegistrationKey&, ServiceWorkerIdentifier, const String& message);
+        WEBCORE_EXPORT void scriptContextStarted(const ServiceWorkerRegistrationKey&, ServiceWorkerIdentifier);
         
         // Messages to the client WebProcess
-        virtual void updateRegistrationStateInClient(const ServiceWorkerRegistrationKey&, ServiceWorkerRegistrationState, const String& serviceWorkerID) = 0;
+        virtual void updateRegistrationStateInClient(const ServiceWorkerRegistrationKey&, ServiceWorkerRegistrationState, std::optional<ServiceWorkerIdentifier>) = 0;
 
     protected:
         WEBCORE_EXPORT Connection(SWServer&, uint64_t identifier);
@@ -112,8 +113,8 @@ private:
     void handleTaskRepliesOnMainThread();
 
     void scriptFetchFinished(Connection&, const ServiceWorkerFetchResult&);
-    void scriptContextFailedToStart(Connection&, const ServiceWorkerRegistrationKey&, const String& workerID, const String& message);
-    void scriptContextStarted(Connection&, const ServiceWorkerRegistrationKey&, uint64_t serviceWorkerIdentifier, const String& workerID);
+    void scriptContextFailedToStart(Connection&, const ServiceWorkerRegistrationKey&, ServiceWorkerIdentifier, const String& message);
+    void scriptContextStarted(Connection&, const ServiceWorkerRegistrationKey&, ServiceWorkerIdentifier);
 
     void addClientServiceWorkerRegistration(Connection&, const ServiceWorkerRegistrationKey&, uint64_t registrationIdentifier);
     void removeClientServiceWorkerRegistration(Connection&, const ServiceWorkerRegistrationKey&, uint64_t registrationIdentifier);
@@ -122,7 +123,7 @@ private:
     HashMap<ServiceWorkerRegistrationKey, std::unique_ptr<SWServerRegistration>> m_registrations;
     HashMap<ServiceWorkerRegistrationKey, std::unique_ptr<SWServerJobQueue>> m_jobQueues;
 
-    HashMap<String, Ref<SWServerWorker>> m_workersByID;
+    HashMap<ServiceWorkerIdentifier, Ref<SWServerWorker>> m_workersByID;
 
     RefPtr<Thread> m_taskThread;
     Lock m_taskThreadLock;
index 17f081f..0cceee7 100644 (file)
@@ -76,24 +76,22 @@ void SWServerJobQueue::scriptFetchFinished(SWServer::Connection& connection, con
     m_server.updateWorker(connection, m_registrationKey, job.scriptURL, result.script, WorkerType::Classic);
 }
 
-void SWServerJobQueue::scriptContextFailedToStart(SWServer::Connection&, const String& workerID, const String& message)
+void SWServerJobQueue::scriptContextFailedToStart(SWServer::Connection&, ServiceWorkerIdentifier identifier, const String& message)
 {
     // FIXME: Install has failed. Run the install failed substeps
     // Run the Update Worker State algorithm passing registration’s installing worker and redundant as the arguments.
     // Run the Update Registration State algorithm passing registration, "installing" and null as the arguments.
     // If newestWorker is null, invoke Clear Registration algorithm passing registration as its argument.
 
-    UNUSED_PARAM(workerID);
+    UNUSED_PARAM(identifier);
     UNUSED_PARAM(message);
 }
 
-void SWServerJobQueue::scriptContextStarted(SWServer::Connection&, uint64_t serviceWorkerIdentifier, const String& workerID)
+void SWServerJobQueue::scriptContextStarted(SWServer::Connection&, ServiceWorkerIdentifier identifier)
 {
-    UNUSED_PARAM(workerID);
-
     auto* registration = m_server.getRegistration(m_registrationKey);
     ASSERT(registration);
-    registration->setActiveServiceWorkerIdentifier(serviceWorkerIdentifier);
+    registration->setActiveServiceWorkerIdentifier(identifier);
 
     m_server.resolveRegistrationJob(firstJob(), registration->data());
     finishCurrentJob();
index d7346f0..6df8038 100644 (file)
@@ -48,8 +48,8 @@ public:
     void runNextJob();
 
     void scriptFetchFinished(SWServer::Connection&, const ServiceWorkerFetchResult&);
-    void scriptContextFailedToStart(SWServer::Connection&, const String& workerID, const String& message);
-    void scriptContextStarted(SWServer::Connection&, uint64_t serviceWorkerIdentifier, const String& workerID);
+    void scriptContextFailedToStart(SWServer::Connection&, ServiceWorkerIdentifier, const String& message);
+    void scriptContextStarted(SWServer::Connection&, ServiceWorkerIdentifier);
 
 private:
     void jobTimerFired();
index 5e53b5e..8cbe4af 100644 (file)
@@ -73,13 +73,13 @@ void SWServerRegistration::updateRegistrationState(ServiceWorkerRegistrationStat
         break;
     };
 
-    String workerID;
+    std::optional<ServiceWorkerIdentifier> serviceWorkerIdentifier;
     if (worker)
-        workerID = worker->workerID();
+        serviceWorkerIdentifier = worker->identifier();
 
     for (auto& connectionIdentifierWithClients : m_clientRegistrationsByConnection.keys()) {
         if (auto* connection = m_server.getConnection(connectionIdentifierWithClients))
-            connection->updateRegistrationStateInClient(m_registrationKey, state, workerID);
+            connection->updateRegistrationStateInClient(m_registrationKey, state, serviceWorkerIdentifier);
     }
 }
 
index 5b35df8..c302b2e 100644 (file)
@@ -55,7 +55,7 @@ public:
     void setLastUpdateTime(double time) { m_lastUpdateTime = time; }
     ServiceWorkerUpdateViaCache updateViaCache() const { return m_updateViaCache; }
 
-    void setActiveServiceWorkerIdentifier(uint64_t identifier) { m_activeServiceWorkerIdentifier = identifier; }
+    void setActiveServiceWorkerIdentifier(ServiceWorkerIdentifier identifier) { m_activeServiceWorkerIdentifier = identifier; }
 
     void updateRegistrationState(ServiceWorkerRegistrationState, SWServerWorker*);
 
@@ -73,7 +73,7 @@ private:
     RefPtr<SWServerWorker> m_waitingWorker;
     RefPtr<SWServerWorker> m_activeWorker;
 
-    uint64_t m_activeServiceWorkerIdentifier { 0 };
+    std::optional<ServiceWorkerIdentifier> m_activeServiceWorkerIdentifier;
 
     double m_lastUpdateTime { 0 };
     
index 6d27313..01b087d 100644 (file)
 
 namespace WebCore {
 
-SWServerWorker::SWServerWorker(const ServiceWorkerRegistrationKey& registrationKey, const URL& url, const String& script, WorkerType type, const String& workerID)
+SWServerWorker::SWServerWorker(const ServiceWorkerRegistrationKey& registrationKey, const URL& url, const String& script, WorkerType type, ServiceWorkerIdentifier identifier)
     : m_registrationKey(registrationKey)
     , m_scriptURL(url)
     , m_script(script)
-    , m_workerID(workerID)
+    , m_identifier(identifier)
     , m_type(type)
 {
 }
index 13e3a29..f8a5548 100644 (file)
@@ -27,6 +27,7 @@
 
 #if ENABLE(SERVICE_WORKER)
 
+#include "ServiceWorkerIdentifier.h"
 #include "ServiceWorkerRegistrationKey.h"
 #include "URL.h"
 #include <wtf/ThreadSafeRefCounted.h>
@@ -37,9 +38,9 @@ enum class WorkerType;
 
 class SWServerWorker : public ThreadSafeRefCounted<SWServerWorker> {
 public:
-    static Ref<SWServerWorker> create(const ServiceWorkerRegistrationKey& registrationKey, const URL& url, const String& script, WorkerType type, const String& workerID)
+    static Ref<SWServerWorker> create(const ServiceWorkerRegistrationKey& registrationKey, const URL& url, const String& script, WorkerType type, ServiceWorkerIdentifier identifier)
     {
-        return adoptRef(*new SWServerWorker(registrationKey, url, script, type, workerID));
+        return adoptRef(*new SWServerWorker(registrationKey, url, script, type, identifier));
     }
     
     SWServerWorker(const SWServerWorker&) = delete;
@@ -48,15 +49,15 @@ public:
     const URL& scriptURL() const { return m_scriptURL; }
     const String& script() const { return m_script; }
     WorkerType type() const { return m_type; }
-    const String& workerID() const { return m_workerID; }
+    ServiceWorkerIdentifier identifier() const { return m_identifier; }
     
 private:
-    SWServerWorker(const ServiceWorkerRegistrationKey&, const URL&, const String& script, WorkerType, const String& workerID);
+    SWServerWorker(const ServiceWorkerRegistrationKey&, const URL&, const String& script, WorkerType, ServiceWorkerIdentifier);
 
     ServiceWorkerRegistrationKey m_registrationKey;
     URL m_scriptURL;
     String m_script;
-    String m_workerID;
+    ServiceWorkerIdentifier m_identifier;
     WorkerType m_type;
 };
 
index c58d2ab..0d891f9 100644 (file)
@@ -1,3 +1,44 @@
+2017-11-03  Chris Dumez  <cdumez@apple.com>
+
+        Use a single identifier type to identify Service Workers
+        https://bugs.webkit.org/show_bug.cgi?id=179192
+
+        Reviewed by Brady Eidson.
+
+        Use a single identifier type to identify Service Workers. We had both a String
+        identifier and a uint64_t identifier for each service worker. We now consistently
+        use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a
+        uint64_t.
+
+        * Scripts/webkit/messages.py:
+        (forward_declarations_and_headers):
+        (forward_declarations_and_headers.templates):
+        * StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
+        (WebKit::WebSWServerConnection::startFetch):
+        (WebKit::WebSWServerConnection::postMessageToServiceWorkerGlobalScope):
+        (WebKit::WebSWServerConnection::postMessageToServiceWorkerClient):
+        * StorageProcess/ServiceWorker/WebSWServerConnection.h:
+        * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in:
+        * StorageProcess/StorageProcess.cpp:
+        (WebKit::StorageProcess::serviceWorkerContextFailedToStart):
+        (WebKit::StorageProcess::serviceWorkerContextStarted):
+        (WebKit::StorageProcess::postMessageToServiceWorkerClient):
+        * StorageProcess/StorageProcess.h:
+        * StorageProcess/StorageProcess.messages.in:
+        * WebProcess/Storage/WebSWClientConnection.cpp:
+        (WebKit::WebSWClientConnection::postMessageToServiceWorkerGlobalScope):
+        (WebKit::WebSWClientConnection::postMessageToServiceWorkerClient):
+        * WebProcess/Storage/WebSWClientConnection.h:
+        * WebProcess/Storage/WebSWClientConnection.messages.in:
+        * WebProcess/Storage/WebSWContextManagerConnection.cpp:
+        (WebKit::WebSWContextManagerConnection::updateServiceWorker):
+        (WebKit::WebSWContextManagerConnection::serviceWorkerStartedWithMessage):
+        (WebKit::WebSWContextManagerConnection::startFetch):
+        (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerGlobalScope):
+        (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerClient):
+        * WebProcess/Storage/WebSWContextManagerConnection.h:
+        * WebProcess/Storage/WebSWContextManagerConnection.messages.in:
+
 2017-11-03  Antti Koivisto  <antti@apple.com>
 
         Enable display:contents by default as experimental feature
index 2804995..8a65d05 100644 (file)
@@ -187,8 +187,8 @@ def forward_declarations_and_headers(receiver):
         kind = parameter.kind
         type = parameter.type
 
-        if type.find('<') != -1:
-            # Don't forward declare class templates.
+        if type.find('<') != -1 or type == "WebCore::ServiceWorkerIdentifier":
+            # Don't forward declare class templates or ServiceWorkerIdentifier.
             headers.update(headers_for_type(type))
             continue
 
index 5184116..f8a9d0d 100644 (file)
@@ -96,9 +96,9 @@ void WebSWServerConnection::startScriptFetchInClient(uint64_t jobIdentifier)
     send(Messages::WebSWClientConnection::StartScriptFetchForServer(jobIdentifier));
 }
 
-void WebSWServerConnection::updateRegistrationStateInClient(const ServiceWorkerRegistrationKey& key, ServiceWorkerRegistrationState state, const String& workerID)
+void WebSWServerConnection::updateRegistrationStateInClient(const ServiceWorkerRegistrationKey& key, ServiceWorkerRegistrationState state, std::optional<ServiceWorkerIdentifier> serviceWorkerIdentifier)
 {
-    send(Messages::WebSWClientConnection::UpdateRegistrationState(key, state, workerID));
+    send(Messages::WebSWClientConnection::UpdateRegistrationState(key, state, serviceWorkerIdentifier));
 }
 
 void WebSWServerConnection::updateServiceWorkerContext(const ServiceWorkerContextData& data)
@@ -109,12 +109,12 @@ void WebSWServerConnection::updateServiceWorkerContext(const ServiceWorkerContex
     m_pendingContextDatas.append(data);
 }
 
-void WebSWServerConnection::startFetch(uint64_t fetchIdentifier, uint64_t serviceWorkerIdentifier, const ResourceRequest& request, const FetchOptions& options)
+void WebSWServerConnection::startFetch(uint64_t fetchIdentifier, std::optional<ServiceWorkerIdentifier> serviceWorkerIdentifier, const ResourceRequest& request, const FetchOptions& options)
 {
     sendToContextProcess(Messages::WebSWContextManagerConnection::StartFetch(identifier(), fetchIdentifier, serviceWorkerIdentifier, request, options));
 }
 
-void WebSWServerConnection::postMessageToServiceWorkerGlobalScope(uint64_t destinationServiceWorkerIdentifier, const IPC::DataReference& message, uint64_t sourceScriptExecutionContextIdentifier, const String& sourceOrigin)
+void WebSWServerConnection::postMessageToServiceWorkerGlobalScope(ServiceWorkerIdentifier destinationServiceWorkerIdentifier, const IPC::DataReference& message, uint64_t sourceScriptExecutionContextIdentifier, const String& sourceOrigin)
 {
     ServiceWorkerClientIdentifier sourceIdentifier { identifier(), sourceScriptExecutionContextIdentifier };
     sendToContextProcess(Messages::WebSWContextManagerConnection::PostMessageToServiceWorkerGlobalScope { destinationServiceWorkerIdentifier, message, sourceIdentifier, sourceOrigin });
@@ -145,7 +145,7 @@ void WebSWServerConnection::didNotHandleFetch(uint64_t fetchIdentifier)
     m_contentConnection->send(Messages::ServiceWorkerClientFetch::DidNotHandle { }, fetchIdentifier);
 }
 
-void WebSWServerConnection::postMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, const IPC::DataReference& message, uint64_t sourceServiceWorkerIdentifier, const String& sourceOrigin)
+void WebSWServerConnection::postMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, const IPC::DataReference& message, ServiceWorkerIdentifier sourceServiceWorkerIdentifier, const String& sourceOrigin)
 {
     send(Messages::WebSWClientConnection::PostMessageToServiceWorkerClient { destinationScriptExecutionContextIdentifier, message, sourceServiceWorkerIdentifier, sourceOrigin });
 }
index 5f393dc..15d8caf 100644 (file)
@@ -57,7 +57,7 @@ public:
     void didFailFetch(uint64_t fetchIdentifier);
     void didNotHandleFetch(uint64_t fetchIdentifier);
 
-    void postMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, const IPC::DataReference& message, uint64_t sourceServiceWorkerIdentifier, const String& sourceOrigin);
+    void postMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, const IPC::DataReference& message, WebCore::ServiceWorkerIdentifier sourceServiceWorkerIdentifier, const String& sourceOrigin);
 
 private:
     // Implement SWServer::Connection (Messages to the client WebProcess)
@@ -65,11 +65,11 @@ private:
     void resolveRegistrationJobInClient(uint64_t jobIdentifier, const WebCore::ServiceWorkerRegistrationData&) 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, const String& serviceWorkerID) final;
+    void updateRegistrationStateInClient(const WebCore::ServiceWorkerRegistrationKey&, WebCore::ServiceWorkerRegistrationState, std::optional<WebCore::ServiceWorkerIdentifier>) final;
 
-    void startFetch(uint64_t fetchIdentifier, uint64_t serviceWorkerIdentifier, const WebCore::ResourceRequest&, const WebCore::FetchOptions&);
+    void startFetch(uint64_t fetchIdentifier, std::optional<WebCore::ServiceWorkerIdentifier>, const WebCore::ResourceRequest&, const WebCore::FetchOptions&);
 
-    void postMessageToServiceWorkerGlobalScope(uint64_t destinationServiceWorkerIdentifier, const IPC::DataReference& message, uint64_t sourceScriptExecutionContextIdentifier, const String& sourceOrigin);
+    void postMessageToServiceWorkerGlobalScope(WebCore::ServiceWorkerIdentifier destinationIdentifier, const IPC::DataReference& message, uint64_t sourceScriptExecutionContextIdentifier, const String& sourceOrigin);
 
     // Messages to the SW context WebProcess
     void updateServiceWorkerContext(const WebCore::ServiceWorkerContextData&) final;
index e658bcf..1b136be 100644 (file)
@@ -29,8 +29,8 @@ messages -> WebSWServerConnection {
     AddServiceWorkerRegistrationInServer(struct WebCore::ServiceWorkerRegistrationKey key, uint64_t registrationIdentifier)
     RemoveServiceWorkerRegistrationInServer(struct WebCore::ServiceWorkerRegistrationKey key, uint64_t registrationIdentifier)
 
-    StartFetch(uint64_t identifier, uint64_t serviceWorkerIdentifier, WebCore::ResourceRequest request, struct WebCore::FetchOptions options)
-    PostMessageToServiceWorkerGlobalScope(uint64_t destinationServiceWorkerIdentifier, IPC::DataReference message, uint64_t sourceScriptExecutionContextIdentifier, String sourceOrigin)
+    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)
 }
 
 #endif // ENABLE(SERVICE_WORKER)
index 7b46564..407ebe6 100644 (file)
@@ -394,16 +394,16 @@ void StorageProcess::didGetWorkerContextProcessConnection(IPC::Attachment&& enco
         connection->workerContextProcessConnectionCreated();
 }
 
-void StorageProcess::serviceWorkerContextFailedToStart(uint64_t serverConnectionIdentifier, const ServiceWorkerRegistrationKey& registrationKey, const String& workerID, const String& message)
+void StorageProcess::serviceWorkerContextFailedToStart(uint64_t serverConnectionIdentifier, const ServiceWorkerRegistrationKey& registrationKey, ServiceWorkerIdentifier serviceWorkerIdentifier, const String& message)
 {
     if (auto* connection = m_swServerConnections.get(serverConnectionIdentifier))
-        connection->scriptContextFailedToStart(registrationKey, workerID, message);
+        connection->scriptContextFailedToStart(registrationKey, serviceWorkerIdentifier, message);
 }
 
-void StorageProcess::serviceWorkerContextStarted(uint64_t serverConnectionIdentifier, const ServiceWorkerRegistrationKey& registrationKey, uint64_t identifier, const String& workerID)
+void StorageProcess::serviceWorkerContextStarted(uint64_t serverConnectionIdentifier, const ServiceWorkerRegistrationKey& registrationKey, ServiceWorkerIdentifier serviceWorkerIdentifier)
 {
     if (auto* connection = m_swServerConnections.get(serverConnectionIdentifier))
-        connection->scriptContextStarted(registrationKey, identifier, workerID);
+        connection->scriptContextStarted(registrationKey, serviceWorkerIdentifier);
 }
 
 void StorageProcess::didFailFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier)
@@ -436,10 +436,10 @@ void StorageProcess::didFinishFetch(uint64_t serverConnectionIdentifier, uint64_
         connection->didFinishFetch(fetchIdentifier);
 }
 
-void StorageProcess::postMessageToServiceWorkerClient(const ServiceWorkerClientIdentifier& destinationIdentifier, const IPC::DataReference& message, uint64_t sourceServiceWorkerIdentifier, const String& sourceOrigin)
+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, sourceServiceWorkerIdentifier, sourceOrigin);
+        connection->postMessageToServiceWorkerClient(destinationIdentifier.scriptExecutionContextIdentifier, message, sourceIdentifier, sourceOrigin);
 }
 
 void StorageProcess::registerSWServerConnection(WebSWServerConnection& connection)
index ec5e08c..d8f6325 100644 (file)
@@ -29,6 +29,7 @@
 #include "SandboxExtension.h"
 #include <WebCore/IDBBackingStore.h>
 #include <WebCore/IDBServer.h>
+#include <WebCore/ServiceWorkerIdentifier.h>
 #include <WebCore/UniqueIDBDatabase.h>
 #include <pal/SessionID.h>
 #include <wtf/CrossThreadTask.h>
@@ -118,8 +119,8 @@ private:
 #endif
 #if ENABLE(SERVICE_WORKER)
     void didGetWorkerContextProcessConnection(IPC::Attachment&& encodedConnectionIdentifier);
-    void serviceWorkerContextFailedToStart(uint64_t serverConnectionIdentifier, const WebCore::ServiceWorkerRegistrationKey&, const String& workerID, const String& message);
-    void serviceWorkerContextStarted(uint64_t serverConnectionIdentifier, const WebCore::ServiceWorkerRegistrationKey&, uint64_t identifier, const String& workerID);
+    void serviceWorkerContextFailedToStart(uint64_t serverConnectionIdentifier, const WebCore::ServiceWorkerRegistrationKey&, WebCore::ServiceWorkerIdentifier, const String& message);
+    void serviceWorkerContextStarted(uint64_t serverConnectionIdentifier, const WebCore::ServiceWorkerRegistrationKey&, WebCore::ServiceWorkerIdentifier);
 
     void didReceiveFetchResponse(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, const WebCore::ResourceResponse&);
     void didReceiveFetchData(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, const IPC::DataReference&, int64_t encodedDataLength);
@@ -127,7 +128,7 @@ private:
     void didFailFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier);
     void didNotHandleFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier);
 
-    void postMessageToServiceWorkerClient(const WebCore::ServiceWorkerClientIdentifier& destinationIdentifier, const IPC::DataReference& message, uint64_t sourceServiceWorkerIdentifier, const String& sourceOrigin);
+    void postMessageToServiceWorkerClient(const WebCore::ServiceWorkerClientIdentifier& destinationIdentifier, const IPC::DataReference& message, WebCore::ServiceWorkerIdentifier sourceIdentifier, const String& sourceOrigin);
 #endif
 #if ENABLE(INDEXED_DATABASE)
     Vector<WebCore::SecurityOriginData> indexedDatabaseOrigins(const String& path);
index ab08fcd..4750300 100644 (file)
@@ -38,14 +38,14 @@ messages -> StorageProcess LegacyReceiver {
 #if ENABLE(SERVICE_WORKER)
     DidGetWorkerContextProcessConnection(IPC::Attachment connectionHandle)
 
-    ServiceWorkerContextFailedToStart(uint64_t serverConnectionIdentifier, struct WebCore::ServiceWorkerRegistrationKey registrationKey, String workerID, String message)
-    ServiceWorkerContextStarted(uint64_t serverConnectionIdentifier, struct WebCore::ServiceWorkerRegistrationKey registrationKey, uint64_t identifier, String workerID)
+    ServiceWorkerContextFailedToStart(uint64_t serverConnectionIdentifier, struct WebCore::ServiceWorkerRegistrationKey registrationKey, WebCore::ServiceWorkerIdentifier serviceWorkerIdentifier, String message)
+    ServiceWorkerContextStarted(uint64_t serverConnectionIdentifier, struct WebCore::ServiceWorkerRegistrationKey registrationKey, WebCore::ServiceWorkerIdentifier serviceWorkerIdentifier)
 
     DidNotHandleFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier)
     DidFailFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier)
     DidReceiveFetchResponse(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, WebCore::ResourceResponse response)
     DidReceiveFetchData(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, IPC::DataReference data, int64_t encodedDataLength)
     DidFinishFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier)
-    PostMessageToServiceWorkerClient(struct WebCore::ServiceWorkerClientIdentifier destinationIdentifier, IPC::DataReference message, uint64_t sourceServiceWorkerIdentifier, String sourceOrigin)
+    PostMessageToServiceWorkerClient(struct WebCore::ServiceWorkerClientIdentifier destinationIdentifier, IPC::DataReference message, WebCore::ServiceWorkerIdentifier sourceIdentifier, String sourceOrigin)
 #endif
 }
index 4785060..bcaab97 100644 (file)
@@ -79,13 +79,13 @@ void WebSWClientConnection::removeServiceWorkerRegistrationInServer(const Servic
     send(Messages::WebSWServerConnection::RemoveServiceWorkerRegistrationInServer(key, registrationIdentifier));
 }
 
-void WebSWClientConnection::postMessageToServiceWorkerGlobalScope(uint64_t destinationServiceWorkerIdentifier, Ref<SerializedScriptValue>&& scriptValue, ScriptExecutionContext& source)
+void WebSWClientConnection::postMessageToServiceWorkerGlobalScope(ServiceWorkerIdentifier destinationIdentifier, Ref<SerializedScriptValue>&& scriptValue, ScriptExecutionContext& source)
 {
     // FIXME: Add support for posting messages from workers.
     if (!is<Document>(source))
         return;
 
-    send(Messages::WebSWServerConnection::PostMessageToServiceWorkerGlobalScope(destinationServiceWorkerIdentifier, IPC::DataReference { scriptValue->data() }, downcast<Document>(source).identifier(), source.origin()));
+    send(Messages::WebSWServerConnection::PostMessageToServiceWorkerGlobalScope(destinationIdentifier, IPC::DataReference { scriptValue->data() }, downcast<Document>(source).identifier(), source.origin()));
 }
 
 bool WebSWClientConnection::hasServiceWorkerRegisteredForOrigin(const SecurityOrigin& origin) const
@@ -107,9 +107,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, uint64_t sourceServiceWorkerIdentifier, const String& sourceOrigin)
+void WebSWClientConnection::postMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, const IPC::DataReference& message, ServiceWorkerIdentifier sourceIdentifier, const String& sourceOrigin)
 {
-    SWClientConnection::postMessageToServiceWorkerClient(destinationScriptExecutionContextIdentifier, SerializedScriptValue::adopt(message.vector()), sourceServiceWorkerIdentifier, sourceOrigin);
+    SWClientConnection::postMessageToServiceWorkerClient(destinationScriptExecutionContextIdentifier, SerializedScriptValue::adopt(message.vector()), sourceIdentifier, sourceOrigin);
 }
 
 } // namespace WebKit
index 57a7121..d770d25 100644 (file)
@@ -58,7 +58,7 @@ public:
     void finishFetchingScriptInServer(const WebCore::ServiceWorkerFetchResult&) final;
     void addServiceWorkerRegistrationInServer(const WebCore::ServiceWorkerRegistrationKey&, uint64_t registrationIdentifier) final;
     void removeServiceWorkerRegistrationInServer(const WebCore::ServiceWorkerRegistrationKey&, uint64_t registrationIdentifier) final;
-    void postMessageToServiceWorkerGlobalScope(uint64_t destinationServiceWorkerIdentifier, Ref<WebCore::SerializedScriptValue>&&, WebCore::ScriptExecutionContext& source) final;
+    void postMessageToServiceWorkerGlobalScope(WebCore::ServiceWorkerIdentifier destinationIdentifier, Ref<WebCore::SerializedScriptValue>&&, WebCore::ScriptExecutionContext& source) final;
 
     void disconnectedFromWebProcess();
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
@@ -66,7 +66,7 @@ public:
     bool hasServiceWorkerRegisteredForOrigin(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, uint64_t sourceServiceWorkerIdentifier, const String& sourceOrigin);
+    void postMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, const IPC::DataReference& message, WebCore::ServiceWorkerIdentifier sourceIdentifier, const String& sourceOrigin);
 
 private:
     void scheduleStorageJob(const WebCore::ServiceWorkerJobData&);
index d76c3ae..012f362 100644 (file)
@@ -28,10 +28,10 @@ messages -> WebSWClientConnection {
     RegistrationJobResolvedInServer(uint64_t identifier, struct WebCore::ServiceWorkerRegistrationData registration)
     UnregistrationJobResolvedInServer(uint64_t identifier, bool unregistrationResult)
     StartScriptFetchForServer(uint64_t jobIdentifier)
-    UpdateRegistrationState(struct WebCore::ServiceWorkerRegistrationKey key, enum WebCore::ServiceWorkerRegistrationState state, String workerID)
+    UpdateRegistrationState(struct WebCore::ServiceWorkerRegistrationKey key, enum WebCore::ServiceWorkerRegistrationState state, std::optional<WebCore::ServiceWorkerIdentifier> serviceWorkerIdentifier)
 
     SetSWOriginTableSharedMemory(WebKit::SharedMemory::Handle handle)
-    PostMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, IPC::DataReference message, uint64_t sourceServiceWorkerIdentifier, String sourceOrigin)
+    PostMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, IPC::DataReference message, WebCore::ServiceWorkerIdentifier sourceServiceWorkerIdentifier, String sourceOrigin)
 }
 
 #endif // ENABLE(SERVICE_WORKER)
index d719aa5..78fc9a0 100644 (file)
@@ -116,10 +116,10 @@ void WebSWContextManagerConnection::updateServiceWorker(uint64_t serverConnectio
     auto serviceWorkerThreadProxy = ServiceWorkerThreadProxy::create(WTFMove(pageConfiguration), serverConnectionIdentifier, data, sessionID, WebProcess::singleton().cacheStorageProvider());
     SWContextManager::singleton().registerServiceWorkerThreadForUpdate(WTFMove(serviceWorkerThreadProxy));
 
-    LOG(ServiceWorker, "Context process PID: %i created worker thread %s\n", getpid(), data.workerID.utf8().data());
+    LOG(ServiceWorker, "Context process PID: %i created worker thread\n", getpid());
 }
 
-void WebSWContextManagerConnection::serviceWorkerStartedWithMessage(uint64_t serviceWorkerIdentifier, const String& exceptionMessage)
+void WebSWContextManagerConnection::serviceWorkerStartedWithMessage(ServiceWorkerIdentifier serviceWorkerIdentifier, const String& exceptionMessage)
 {
     auto* threadProxy = SWContextManager::singleton().serviceWorkerThreadProxy(serviceWorkerIdentifier);
     ASSERT(threadProxy);
@@ -127,14 +127,14 @@ void WebSWContextManagerConnection::serviceWorkerStartedWithMessage(uint64_t ser
     auto& data = threadProxy->thread().contextData();
     
     if (exceptionMessage.isEmpty())
-        m_connectionToStorageProcess->send(Messages::StorageProcess::ServiceWorkerContextStarted(threadProxy->thread().serverConnectionIdentifier(), data.registrationKey, serviceWorkerIdentifier, data.workerID), 0);
+        m_connectionToStorageProcess->send(Messages::StorageProcess::ServiceWorkerContextStarted(threadProxy->thread().serverConnectionIdentifier(), data.registrationKey, serviceWorkerIdentifier), 0);
     else
-        m_connectionToStorageProcess->send(Messages::StorageProcess::ServiceWorkerContextFailedToStart(threadProxy->thread().serverConnectionIdentifier(), data.registrationKey, data.workerID, exceptionMessage), 0);
+        m_connectionToStorageProcess->send(Messages::StorageProcess::ServiceWorkerContextFailedToStart(threadProxy->thread().serverConnectionIdentifier(), data.registrationKey, serviceWorkerIdentifier, exceptionMessage), 0);
 }
 
-void WebSWContextManagerConnection::startFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, uint64_t serviceWorkerIdentifier, ResourceRequest&& request, FetchOptions&& options)
+void WebSWContextManagerConnection::startFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, std::optional<ServiceWorkerIdentifier> serviceWorkerIdentifier, ResourceRequest&& request, FetchOptions&& options)
 {
-    auto* serviceWorkerThreadProxy = SWContextManager::singleton().serviceWorkerThreadProxy(serviceWorkerIdentifier);
+    auto* serviceWorkerThreadProxy = serviceWorkerIdentifier ? SWContextManager::singleton().serviceWorkerThreadProxy(*serviceWorkerIdentifier) : nullptr;
     if (!serviceWorkerThreadProxy) {
         m_connectionToStorageProcess->send(Messages::StorageProcess::DidNotHandleFetch(serverConnectionIdentifier, fetchIdentifier), 0);
         return;
@@ -144,14 +144,14 @@ void WebSWContextManagerConnection::startFetch(uint64_t serverConnectionIdentifi
     serviceWorkerThreadProxy->thread().postFetchTask(WTFMove(client), WTFMove(request), WTFMove(options));
 }
 
-void WebSWContextManagerConnection::postMessageToServiceWorkerGlobalScope(uint64_t destinationServiceWorkerIdentifier, const IPC::DataReference& message, const ServiceWorkerClientIdentifier& sourceIdentifier, const String& sourceOrigin)
+void WebSWContextManagerConnection::postMessageToServiceWorkerGlobalScope(ServiceWorkerIdentifier destinationIdentifier, const IPC::DataReference& message, const ServiceWorkerClientIdentifier& sourceIdentifier, const String& sourceOrigin)
 {
-    SWContextManager::singleton().postMessageToServiceWorkerGlobalScope(destinationServiceWorkerIdentifier, SerializedScriptValue::adopt(message.vector()), sourceIdentifier, sourceOrigin);
+    SWContextManager::singleton().postMessageToServiceWorkerGlobalScope(destinationIdentifier, SerializedScriptValue::adopt(message.vector()), sourceIdentifier, sourceOrigin);
 }
 
-void WebSWContextManagerConnection::postMessageToServiceWorkerClient(const ServiceWorkerClientIdentifier& destinationIdentifier, Ref<SerializedScriptValue>&& message, uint64_t sourceServiceWorkerIdentifier, const String& sourceOrigin)
+void WebSWContextManagerConnection::postMessageToServiceWorkerClient(const ServiceWorkerClientIdentifier& destinationIdentifier, Ref<SerializedScriptValue>&& message, ServiceWorkerIdentifier sourceIdentifier, const String& sourceOrigin)
 {
-    m_connectionToStorageProcess->send(Messages::StorageProcess::PostMessageToServiceWorkerClient(destinationIdentifier, IPC::DataReference { message->data() }, sourceServiceWorkerIdentifier, sourceOrigin), 0);
+    m_connectionToStorageProcess->send(Messages::StorageProcess::PostMessageToServiceWorkerClient(destinationIdentifier, IPC::DataReference { message->data() }, sourceIdentifier, sourceOrigin), 0);
 }
 
 } // namespace WebCore
index 2310d93..8825998 100644 (file)
@@ -51,13 +51,13 @@ private:
     void updatePreferences(const WebPreferencesStore&);
 
     // WebCore::SWContextManager::Connection.
-    void postMessageToServiceWorkerClient(const WebCore::ServiceWorkerClientIdentifier& destinationIdentifier, Ref<WebCore::SerializedScriptValue>&& message, uint64_t sourceServiceWorkerIdentifier, const String& sourceOrigin) final;
+    void postMessageToServiceWorkerClient(const WebCore::ServiceWorkerClientIdentifier& destinationIdentifier, Ref<WebCore::SerializedScriptValue>&& message, WebCore::ServiceWorkerIdentifier sourceIdentifier, const String& sourceOrigin) final;
 
     // IPC messages.
-    void serviceWorkerStartedWithMessage(uint64_t serviceWorkerIdentifier, const String& exceptionMessage) final;
+    void serviceWorkerStartedWithMessage(WebCore::ServiceWorkerIdentifier, const String& exceptionMessage) final;
     void updateServiceWorker(uint64_t serverConnectionIdentifier, const WebCore::ServiceWorkerContextData&);
-    void startFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, uint64_t serviceWorkerIdentifier, WebCore::ResourceRequest&&, WebCore::FetchOptions&&);
-    void postMessageToServiceWorkerGlobalScope(uint64_t destinationServiceWorkerIdentifier, const IPC::DataReference& message, const WebCore::ServiceWorkerClientIdentifier& sourceIdentifier, const String& sourceOrigin);
+    void startFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, std::optional<WebCore::ServiceWorkerIdentifier>, WebCore::ResourceRequest&&, WebCore::FetchOptions&&);
+    void postMessageToServiceWorkerGlobalScope(WebCore::ServiceWorkerIdentifier destinationIdentifier, const IPC::DataReference& message, const WebCore::ServiceWorkerClientIdentifier& sourceIdentifier, const String& sourceOrigin);
 
     Ref<IPC::Connection> m_connectionToStorageProcess;
     uint64_t m_pageID { 0 };
index e032cd7..67c3575 100644 (file)
@@ -24,8 +24,8 @@
 
 messages -> WebSWContextManagerConnection {
     UpdateServiceWorker(uint64_t serverConnectionIdentifier, struct WebCore::ServiceWorkerContextData contextData)
-    StartFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, uint64_t serviceWorkerIdentifier, WebCore::ResourceRequest request, struct WebCore::FetchOptions options)
-    PostMessageToServiceWorkerGlobalScope(uint64_t destinationServiceWorkerIdentifier, IPC::DataReference message, struct WebCore::ServiceWorkerClientIdentifier sourceIdentifier, String sourceOrigin)
+    StartFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, std::optional<WebCore::ServiceWorkerIdentifier> serviceWorkerIdentifier, WebCore::ResourceRequest request, struct WebCore::FetchOptions options)
+    PostMessageToServiceWorkerGlobalScope(WebCore::ServiceWorkerIdentifier destinationIdentifier, IPC::DataReference message, struct WebCore::ServiceWorkerClientIdentifier sourceIdentifier, String sourceOrigin)
 }
 
 #endif