Title: [284129] trunk/Source/WebKit
Revision
284129
Author
[email protected]
Date
2021-10-13 15:16:36 -0700 (Wed, 13 Oct 2021)

Log Message

Prepare adattributiond Connection and IPC code for reuse with webpushd
https://bugs.webkit.org/show_bug.cgi?id=231680

Patch by Alex Christensen <[email protected]> on 2021-10-13
Reviewed by Brady Eidson.

I move Connection, Encoder, and Decoder out of namespace PCM and into namespace Daemon and keep the PCM parts in PCM::Connection.
I remove an unnecessary memory copy by using a Span instead of a Vector for decoding.
I make ConnectionToMachService a template to be used with a different communication protocol for communicating with webpushd.

* NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementConnection.cpp:
(WebKit::PCM::Connection::Connection):
(WebKit::PCM::ConnectionToMachService::ConnectionToMachService): Deleted.
(WebKit::PCM::ConnectionToMachService::send const): Deleted.
(WebKit::PCM::ConnectionToMachService::sendWithReply const): Deleted.
* NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementConnection.h:
(WebKit::PCM::Connection::Connection): Deleted.
(WebKit::PCM::Connection::get const): Deleted.
* NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerInterface.cpp:
(WebKit::PCM::MessageInfo::toStringForTesting::encodeReply):
(WebKit::PCM::handlePCMMessage):
(WebKit::PCM::handlePCMMessageSetDebugModeIsEnabled):
(WebKit::PCM::handlePCMMessageWithReply):
(WebKit::PCM::decodeMessageAndSendToManager):
* NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerInterface.h:
* NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerProxy.cpp:
(WebKit::PCM::ManagerProxy::sendMessage const):
(WebKit::PCM::ReplyCaller<>::callReply):
(WebKit::PCM::ReplyCaller<String>::callReply):
(WebKit::PCM::ManagerProxy::sendMessageWithReply const):
* NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerProxy.h:
* NetworkProcess/PrivateClickMeasurement/cocoa/PrivateClickMeasurementConnectionCocoa.mm:
(WebKit::PCM::Connection::newConnectionWasInitialized const):
(WebKit::PCM::Connection::connectionReceivedEvent const):
(WebKit::PCM::Connection::dictionaryFromMessage const):
(WebKit::PCM::ConnectionToMachService::initializeConnectionIfNeeded const): Deleted.
(WebKit::PCM::ConnectionToMachService::sendDebugModeIsEnabledMessageIfNecessary const): Deleted.
(WebKit::PCM::ConnectionToMachService::checkForDebugMessageBroadcast const): Deleted.
(WebKit::PCM::dictionaryFromMessage): Deleted.
(WebKit::PCM::Connection::send const): Deleted.
(WebKit::PCM::Connection::sendWithReply const): Deleted.
(WebKit::PCM::ConnectionToMachService::send const): Deleted.
(WebKit::PCM::ConnectionToMachService::sendWithReply const): Deleted.
* Platform/IPC/ArgumentCoders.cpp:
* Platform/IPC/DaemonConnection.cpp: Copied from Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementEncoder.cpp.
(WebKit::Daemon::ConnectionToMachService<Traits>::send const):
(WebKit::Daemon::ConnectionToMachService<Traits>::sendWithReply const):
* Platform/IPC/DaemonConnection.h: Copied from Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementConnection.h.
(WebKit::Daemon::Connection::Connection):
(WebKit::Daemon::Connection::get const):
(WebKit::Daemon::ConnectionToMachService::ConnectionToMachService):
* Platform/IPC/DaemonDecoder.cpp: Renamed from Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDecoder.cpp.
* Platform/IPC/DaemonDecoder.h: Renamed from Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDecoder.h.
(WebKit::Daemon::Decoder::Decoder):
* Platform/IPC/DaemonEncoder.cpp: Renamed from Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementEncoder.cpp.
* Platform/IPC/DaemonEncoder.h: Renamed from Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementEncoder.h.
* Platform/IPC/cocoa/DaemonConnectionCocoa.mm: Copied from Source/WebKit/NetworkProcess/PrivateClickMeasurement/cocoa/PrivateClickMeasurementConnectionCocoa.mm.
(WebKit::Daemon::Connection::send const):
(WebKit::Daemon::Connection::sendWithReply const):
(WebKit::Daemon::ConnectionToMachService<Traits>::initializeConnectionIfNeeded const):
(WebKit::Daemon::ConnectionToMachService<Traits>::send const):
(WebKit::Daemon::ConnectionToMachService<Traits>::sendWithReply const):
* Shared/EntryPointUtilities/Cocoa/Daemon/PCMDaemonConnectionSet.h:
* Shared/EntryPointUtilities/Cocoa/Daemon/PCMDaemonConnectionSet.mm:
(WebKit::PCM::DaemonConnectionSet::setConnectedNetworkProcessHasDebugModeEnabled):
* Shared/EntryPointUtilities/Cocoa/Daemon/PCMDaemonEntryPoint.mm:
(WebKit::connectionEventHandler):
* Shared/cf/ArgumentCodersCF.cpp:
* Shared/mac/WebCoreArgumentCodersMac.mm:
(IPC::ArgumentCoder<WebCore::CertificateInfo>::encode):
(IPC::ArgumentCoder<WebCore::CertificateInfo>::decode):
* Sources.txt:
* SourcesCocoa.txt:
* WebKit.xcodeproj/project.pbxproj:

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (284128 => 284129)


--- trunk/Source/WebKit/ChangeLog	2021-10-13 22:09:42 UTC (rev 284128)
+++ trunk/Source/WebKit/ChangeLog	2021-10-13 22:16:36 UTC (rev 284129)
@@ -1,3 +1,79 @@
+2021-10-13  Alex Christensen  <[email protected]>
+
+        Prepare adattributiond Connection and IPC code for reuse with webpushd
+        https://bugs.webkit.org/show_bug.cgi?id=231680
+
+        Reviewed by Brady Eidson.
+
+        I move Connection, Encoder, and Decoder out of namespace PCM and into namespace Daemon and keep the PCM parts in PCM::Connection.
+        I remove an unnecessary memory copy by using a Span instead of a Vector for decoding.
+        I make ConnectionToMachService a template to be used with a different communication protocol for communicating with webpushd.
+
+        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementConnection.cpp:
+        (WebKit::PCM::Connection::Connection):
+        (WebKit::PCM::ConnectionToMachService::ConnectionToMachService): Deleted.
+        (WebKit::PCM::ConnectionToMachService::send const): Deleted.
+        (WebKit::PCM::ConnectionToMachService::sendWithReply const): Deleted.
+        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementConnection.h:
+        (WebKit::PCM::Connection::Connection): Deleted.
+        (WebKit::PCM::Connection::get const): Deleted.
+        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerInterface.cpp:
+        (WebKit::PCM::MessageInfo::toStringForTesting::encodeReply):
+        (WebKit::PCM::handlePCMMessage):
+        (WebKit::PCM::handlePCMMessageSetDebugModeIsEnabled):
+        (WebKit::PCM::handlePCMMessageWithReply):
+        (WebKit::PCM::decodeMessageAndSendToManager):
+        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerInterface.h:
+        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerProxy.cpp:
+        (WebKit::PCM::ManagerProxy::sendMessage const):
+        (WebKit::PCM::ReplyCaller<>::callReply):
+        (WebKit::PCM::ReplyCaller<String>::callReply):
+        (WebKit::PCM::ManagerProxy::sendMessageWithReply const):
+        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerProxy.h:
+        * NetworkProcess/PrivateClickMeasurement/cocoa/PrivateClickMeasurementConnectionCocoa.mm:
+        (WebKit::PCM::Connection::newConnectionWasInitialized const):
+        (WebKit::PCM::Connection::connectionReceivedEvent const):
+        (WebKit::PCM::Connection::dictionaryFromMessage const):
+        (WebKit::PCM::ConnectionToMachService::initializeConnectionIfNeeded const): Deleted.
+        (WebKit::PCM::ConnectionToMachService::sendDebugModeIsEnabledMessageIfNecessary const): Deleted.
+        (WebKit::PCM::ConnectionToMachService::checkForDebugMessageBroadcast const): Deleted.
+        (WebKit::PCM::dictionaryFromMessage): Deleted.
+        (WebKit::PCM::Connection::send const): Deleted.
+        (WebKit::PCM::Connection::sendWithReply const): Deleted.
+        (WebKit::PCM::ConnectionToMachService::send const): Deleted.
+        (WebKit::PCM::ConnectionToMachService::sendWithReply const): Deleted.
+        * Platform/IPC/ArgumentCoders.cpp:
+        * Platform/IPC/DaemonConnection.cpp: Copied from Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementEncoder.cpp.
+        (WebKit::Daemon::ConnectionToMachService<Traits>::send const):
+        (WebKit::Daemon::ConnectionToMachService<Traits>::sendWithReply const):
+        * Platform/IPC/DaemonConnection.h: Copied from Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementConnection.h.
+        (WebKit::Daemon::Connection::Connection):
+        (WebKit::Daemon::Connection::get const):
+        (WebKit::Daemon::ConnectionToMachService::ConnectionToMachService):
+        * Platform/IPC/DaemonDecoder.cpp: Renamed from Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDecoder.cpp.
+        * Platform/IPC/DaemonDecoder.h: Renamed from Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDecoder.h.
+        (WebKit::Daemon::Decoder::Decoder):
+        * Platform/IPC/DaemonEncoder.cpp: Renamed from Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementEncoder.cpp.
+        * Platform/IPC/DaemonEncoder.h: Renamed from Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementEncoder.h.
+        * Platform/IPC/cocoa/DaemonConnectionCocoa.mm: Copied from Source/WebKit/NetworkProcess/PrivateClickMeasurement/cocoa/PrivateClickMeasurementConnectionCocoa.mm.
+        (WebKit::Daemon::Connection::send const):
+        (WebKit::Daemon::Connection::sendWithReply const):
+        (WebKit::Daemon::ConnectionToMachService<Traits>::initializeConnectionIfNeeded const):
+        (WebKit::Daemon::ConnectionToMachService<Traits>::send const):
+        (WebKit::Daemon::ConnectionToMachService<Traits>::sendWithReply const):
+        * Shared/EntryPointUtilities/Cocoa/Daemon/PCMDaemonConnectionSet.h:
+        * Shared/EntryPointUtilities/Cocoa/Daemon/PCMDaemonConnectionSet.mm:
+        (WebKit::PCM::DaemonConnectionSet::setConnectedNetworkProcessHasDebugModeEnabled):
+        * Shared/EntryPointUtilities/Cocoa/Daemon/PCMDaemonEntryPoint.mm:
+        (WebKit::connectionEventHandler):
+        * Shared/cf/ArgumentCodersCF.cpp:
+        * Shared/mac/WebCoreArgumentCodersMac.mm:
+        (IPC::ArgumentCoder<WebCore::CertificateInfo>::encode):
+        (IPC::ArgumentCoder<WebCore::CertificateInfo>::decode):
+        * Sources.txt:
+        * SourcesCocoa.txt:
+        * WebKit.xcodeproj/project.pbxproj:
+
 2021-10-13  Sihui Liu  <[email protected]>
 
         Implement FileSystemHandle move()

Modified: trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementConnection.cpp (284128 => 284129)


--- trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementConnection.cpp	2021-10-13 22:09:42 UTC (rev 284128)
+++ trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementConnection.cpp	2021-10-13 22:16:36 UTC (rev 284129)
@@ -26,30 +26,20 @@
 #include "config.h"
 #include "PrivateClickMeasurementConnection.h"
 
-#include "NetworkSession.h"
-#include <WebCore/NotImplemented.h>
-
 namespace WebKit {
 
 namespace PCM {
 
-ConnectionToMachService::ConnectionToMachService(CString&& machServiceName, NetworkSession& networkSession)
-    : m_machServiceName(WTFMove(machServiceName))
-    , m_networkSession(makeWeakPtr(networkSession)) { }
-
-#if !PLATFORM(COCOA)
-
-void ConnectionToMachService::send(MessageType, EncodedMessage&&) const
+Connection::Connection(CString&& machServiceName, NetworkSession& networkSession)
+    : Daemon::ConnectionToMachService<ConnectionTraits>(WTFMove(machServiceName))
+    , m_networkSession(networkSession)
 {
-    notImplemented();
 }
 
-void ConnectionToMachService::sendWithReply(MessageType, EncodedMessage&&, CompletionHandler<void(EncodedMessage&&)>&& completionHandler) const
+#if !PLATFORM(COCOA)
+void Connection::newConnectionWasInitialized() const
 {
-    notImplemented();
-    completionHandler({ });
 }
-
 #endif
 
 } // namespace PCM

Modified: trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementConnection.h (284128 => 284129)


--- trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementConnection.h	2021-10-13 22:09:42 UTC (rev 284128)
+++ trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementConnection.h	2021-10-13 22:16:36 UTC (rev 284129)
@@ -25,16 +25,9 @@
 
 #pragma once
 
-#include <wtf/CompletionHandler.h>
-#include <wtf/Vector.h>
-#include <wtf/WeakPtr.h>
-#include <wtf/text/CString.h>
+#include "DaemonConnection.h"
+#include "PrivateClickMeasurementManagerInterface.h"
 
-#if PLATFORM(COCOA)
-#include <wtf/RetainPtr.h>
-#include <wtf/spi/darwin/XPCSPI.h>
-#endif
-
 namespace WebKit {
 
 class NetworkSession;
@@ -42,37 +35,26 @@
 namespace PCM {
 
 enum class MessageType : uint8_t;
-using EncodedMessage = Vector<uint8_t>;
 
-class Connection : public CanMakeWeakPtr<Connection> {
-public:
-    Connection() = default;
-#if PLATFORM(COCOA)
-    explicit Connection(RetainPtr<xpc_connection_t>&& connection)
-        : m_connection(WTFMove(connection)) { }
-    xpc_connection_t get() const { return m_connection.get(); }
-    void send(xpc_object_t) const;
-    void sendWithReply(xpc_object_t, CompletionHandler<void(xpc_object_t)>&&) const;
-protected:
-    mutable RetainPtr<xpc_connection_t> m_connection;
-#endif
+struct ConnectionTraits {
+    using MessageType = WebKit::PCM::MessageType;
+    static constexpr const char* protocolVersionKey { PCM::protocolVersionKey };
+    static constexpr uint64_t protocolVersionValue { PCM::protocolVersionValue };
+    static constexpr const char* protocolEncodedMessageKey { PCM::protocolEncodedMessageKey };
 };
 
-class ConnectionToMachService : public Connection {
+class Connection : public Daemon::ConnectionToMachService<ConnectionTraits> {
 public:
-    ConnectionToMachService(CString&& machServiceName, NetworkSession&);
+    Connection(CString&& machServiceName, NetworkSession&);
 
-    void send(MessageType, EncodedMessage&&) const;
-    void sendWithReply(MessageType, EncodedMessage&&, CompletionHandler<void(EncodedMessage&&)>&&) const;
-
 private:
-    void initializeConnectionIfNeeded() const;
+    void newConnectionWasInitialized() const final;
 #if PLATFORM(COCOA)
-    void checkForDebugMessageBroadcast(xpc_object_t) const;
+    RetainPtr<xpc_object_t> dictionaryFromMessage(MessageType, Daemon::EncodedMessage&&) const final;
+    void connectionReceivedEvent(xpc_object_t) const final;
 #endif
     void sendDebugModeIsEnabledMessageIfNecessary() const;
 
-    const CString m_machServiceName;
     WeakPtr<NetworkSession> m_networkSession;
 };
 

Deleted: trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDecoder.cpp (284128 => 284129)


--- trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDecoder.cpp	2021-10-13 22:09:42 UTC (rev 284128)
+++ trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDecoder.cpp	2021-10-13 22:16:36 UTC (rev 284129)
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2021 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.
- */
-
-#include "config.h"
-#include "PrivateClickMeasurementDecoder.h"
-
-namespace WebKit {
-
-namespace PCM {
-
-Decoder::~Decoder()
-{
-    ASSERT(m_bufferPosition == m_buffer.size());
-}
-
-bool Decoder::bufferIsLargeEnoughToContainBytes(size_t bytes) const
-{
-    return bytes <= m_buffer.size() - m_bufferPosition;
-}
-
-bool Decoder::decodeFixedLengthData(uint8_t* data, size_t size, size_t)
-{
-    if (!bufferIsLargeEnoughToContainBytes(size))
-        return false;
-    memcpy(data, m_buffer.data() + m_bufferPosition, size);
-    m_bufferPosition += size;
-    return true;
-}
-
-const uint8_t* Decoder::decodeFixedLengthReference(size_t size, size_t)
-{
-    if (!bufferIsLargeEnoughToContainBytes(size))
-        return nullptr;
-    const uint8_t* data = "" + m_bufferPosition;
-    m_bufferPosition += size;
-    return data;
-}
-
-} // namespace PCM
-
-} // namespace WebKit

Deleted: trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDecoder.h (284128 => 284129)


--- trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDecoder.h	2021-10-13 22:09:42 UTC (rev 284128)
+++ trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDecoder.h	2021-10-13 22:16:36 UTC (rev 284129)
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2021 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 "ArgumentCoders.h"
-
-namespace WebKit {
-
-namespace PCM {
-
-class Decoder {
-public:
-    Decoder(Vector<uint8_t>&& buffer)
-        : m_buffer(WTFMove(buffer)) { }
-    ~Decoder();
-
-    template<typename T>
-    Decoder& operator>>(std::optional<T>& t)
-    {
-        t = IPC::ArgumentCoder<std::remove_const_t<std::remove_reference_t<T>>, void>::decode(*this);
-        return *this;
-    }
-
-    template<typename T>
-    WARN_UNUSED_RETURN bool bufferIsLargeEnoughToContain(size_t numElements) const
-    {
-        static_assert(std::is_arithmetic<T>::value, "Type T must have a fixed, known encoded size!");
-
-        if (numElements > std::numeric_limits<size_t>::max() / sizeof(T))
-            return false;
-
-        return bufferIsLargeEnoughToContainBytes(numElements * sizeof(T));
-    }
-
-    WARN_UNUSED_RETURN bool decodeFixedLengthData(uint8_t* data, size_t, size_t alignment);
-    const uint8_t* decodeFixedLengthReference(size_t, size_t);
-
-private:
-    WARN_UNUSED_RETURN bool bufferIsLargeEnoughToContainBytes(size_t) const;
-
-    Vector<uint8_t> m_buffer;
-    size_t m_bufferPosition { 0 };
-};
-
-} // namespace PCM
-
-} // namespace WebKit

Deleted: trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementEncoder.cpp (284128 => 284129)


--- trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementEncoder.cpp	2021-10-13 22:09:42 UTC (rev 284128)
+++ trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementEncoder.cpp	2021-10-13 22:16:36 UTC (rev 284129)
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2021 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.
- */
-
-#include "config.h"
-#include "PrivateClickMeasurementEncoder.h"
-
-namespace WebKit {
-
-namespace PCM {
-
-void Encoder::encodeFixedLengthData(const uint8_t* data, size_t size, size_t)
-{
-    m_buffer.append(data, size);
-}
-
-} // namespace PCM
-
-} // namespace WebKit

Deleted: trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementEncoder.h (284128 => 284129)


--- trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementEncoder.h	2021-10-13 22:09:42 UTC (rev 284128)
+++ trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementEncoder.h	2021-10-13 22:16:36 UTC (rev 284129)
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2021 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 "ArgumentCoders.h"
-
-namespace WebKit {
-
-namespace PCM {
-
-class Encoder {
-public:
-    template<typename T>
-    Encoder& operator<<(T&& t)
-    {
-        IPC::ArgumentCoder<std::remove_const_t<std::remove_reference_t<T>>>::encode(*this, std::forward<T>(t));
-        return *this;
-    }
-
-    template<typename Arg, typename... Args>
-    void encode(Arg&& arg, Args&&... args)
-    {
-        *this << std::forward<Arg>(arg);
-        encode(std::forward<Args>(args)...);
-    }
-    void encode() { }
-
-    Vector<uint8_t> takeBuffer() { return std::exchange(m_buffer, { }); }
-
-    void encodeFixedLengthData(const uint8_t*, size_t, size_t alignment);
-
-private:
-    Vector<uint8_t> m_buffer;
-};
-
-} // namespace PCM
-
-} // namespace WebKit

Modified: trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerInterface.cpp (284128 => 284129)


--- trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerInterface.cpp	2021-10-13 22:09:42 UTC (rev 284128)
+++ trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerInterface.cpp	2021-10-13 22:16:36 UTC (rev 284129)
@@ -26,11 +26,11 @@
 #include "config.h"
 #include "PrivateClickMeasurementManagerInterface.h"
 
+#include "DaemonDecoder.h"
+#include "DaemonEncoder.h"
 #include "HandleMessage.h"
 #include "PrivateClickMeasurementConnection.h"
 #include "PrivateClickMeasurementDaemonClient.h"
-#include "PrivateClickMeasurementDecoder.h"
-#include "PrivateClickMeasurementEncoder.h"
 #include "PrivateClickMeasurementManager.h"
 #include "WebCoreArgumentCoders.h"
 
@@ -143,7 +143,7 @@
 
 PCM::EncodedMessage toStringForTesting::encodeReply(String reply)
 {
-    PCM::Encoder encoder;
+    Daemon::Encoder encoder;
     encoder << reply;
     return encoder.takeBuffer();
 }
@@ -197,9 +197,9 @@
 }
 
 template<typename Info>
-void handlePCMMessage(PCM::EncodedMessage&& encodedMessage)
+void handlePCMMessage(Span<const uint8_t> encodedMessage)
 {
-    PCM::Decoder decoder(WTFMove(encodedMessage));
+    Daemon::Decoder decoder(encodedMessage);
 
     std::optional<typename Info::ArgsTuple> arguments;
     decoder >> arguments;
@@ -209,10 +209,10 @@
     IPC::callMemberFunction(WTFMove(*arguments), &daemonManager(), Info::MemberFunction);
 }
 
-static void handlePCMMessageSetDebugModeIsEnabled(const Connection& connection, PCM::EncodedMessage&& encodedMessage)
+static void handlePCMMessageSetDebugModeIsEnabled(const Daemon::Connection& connection, Span<const uint8_t> encodedMessage)
 {
 #if PLATFORM(COCOA)
-    PCM::Decoder decoder(WTFMove(encodedMessage));
+    Daemon::Decoder decoder(encodedMessage);
     std::optional<bool> enabled;
     decoder >> enabled;
     if (UNLIKELY(!enabled))
@@ -230,9 +230,9 @@
 }
 
 template<typename Info>
-void handlePCMMessageWithReply(PCM::EncodedMessage&& encodedMessage, CompletionHandler<void(PCM::EncodedMessage&&)>&& replySender)
+void handlePCMMessageWithReply(Span<const uint8_t> encodedMessage, CompletionHandler<void(PCM::EncodedMessage&&)>&& replySender)
 {
-    PCM::Decoder decoder(WTFMove(encodedMessage));
+    Daemon::Decoder decoder(encodedMessage);
 
     std::optional<typename Info::ArgsTuple> arguments;
     decoder >> arguments;
@@ -251,63 +251,63 @@
     daemonManager().firePendingAttributionRequests();
 }
 
-void decodeMessageAndSendToManager(const Connection& connection, MessageType messageType, Vector<uint8_t>&& encodedMessage, CompletionHandler<void(Vector<uint8_t>&&)>&& replySender)
+void decodeMessageAndSendToManager(const Daemon::Connection& connection, MessageType messageType, Span<const uint8_t> encodedMessage, CompletionHandler<void(Vector<uint8_t>&&)>&& replySender)
 {
     ASSERT(messageTypeSendsReply(messageType) == !!replySender);
     switch (messageType) {
     case PCM::MessageType::StoreUnattributed:
-        handlePCMMessageWithReply<MessageInfo::storeUnattributed>(WTFMove(encodedMessage), WTFMove(replySender));
+        handlePCMMessageWithReply<MessageInfo::storeUnattributed>(encodedMessage, WTFMove(replySender));
         break;
     case PCM::MessageType::HandleAttribution:
-        handlePCMMessage<MessageInfo::handleAttribution>(WTFMove(encodedMessage));
+        handlePCMMessage<MessageInfo::handleAttribution>(encodedMessage);
         break;
     case PCM::MessageType::Clear:
-        handlePCMMessageWithReply<MessageInfo::clear>(WTFMove(encodedMessage), WTFMove(replySender));
+        handlePCMMessageWithReply<MessageInfo::clear>(encodedMessage, WTFMove(replySender));
         break;
     case PCM::MessageType::ClearForRegistrableDomain:
-        handlePCMMessageWithReply<MessageInfo::clearForRegistrableDomain>(WTFMove(encodedMessage), WTFMove(replySender));
+        handlePCMMessageWithReply<MessageInfo::clearForRegistrableDomain>(encodedMessage, WTFMove(replySender));
         break;
     case PCM::MessageType::SetDebugModeIsEnabled:
-        handlePCMMessageSetDebugModeIsEnabled(connection, WTFMove(encodedMessage));
+        handlePCMMessageSetDebugModeIsEnabled(connection, encodedMessage);
         break;
     case PCM::MessageType::MigratePrivateClickMeasurementFromLegacyStorage:
-        handlePCMMessage<MessageInfo::migratePrivateClickMeasurementFromLegacyStorage>(WTFMove(encodedMessage));
+        handlePCMMessage<MessageInfo::migratePrivateClickMeasurementFromLegacyStorage>(encodedMessage);
         break;
     case PCM::MessageType::ToStringForTesting:
-        handlePCMMessageWithReply<MessageInfo::toStringForTesting>(WTFMove(encodedMessage), WTFMove(replySender));
+        handlePCMMessageWithReply<MessageInfo::toStringForTesting>(encodedMessage, WTFMove(replySender));
         break;
     case PCM::MessageType::SetOverrideTimerForTesting:
-        handlePCMMessage<MessageInfo::setOverrideTimerForTesting>(WTFMove(encodedMessage));
+        handlePCMMessage<MessageInfo::setOverrideTimerForTesting>(encodedMessage);
         break;
     case PCM::MessageType::SetTokenPublicKeyURLForTesting:
-        handlePCMMessage<MessageInfo::setTokenPublicKeyURLForTesting>(WTFMove(encodedMessage));
+        handlePCMMessage<MessageInfo::setTokenPublicKeyURLForTesting>(encodedMessage);
         break;
     case PCM::MessageType::SetTokenSignatureURLForTesting:
-        handlePCMMessage<MessageInfo::setTokenSignatureURLForTesting>(WTFMove(encodedMessage));
+        handlePCMMessage<MessageInfo::setTokenSignatureURLForTesting>(encodedMessage);
         break;
     case PCM::MessageType::SetAttributionReportURLsForTesting:
-        handlePCMMessage<MessageInfo::setAttributionReportURLsForTesting>(WTFMove(encodedMessage));
+        handlePCMMessage<MessageInfo::setAttributionReportURLsForTesting>(encodedMessage);
         break;
     case PCM::MessageType::MarkAllUnattributedAsExpiredForTesting:
-        handlePCMMessage<MessageInfo::markAllUnattributedAsExpiredForTesting>(WTFMove(encodedMessage));
+        handlePCMMessage<MessageInfo::markAllUnattributedAsExpiredForTesting>(encodedMessage);
         break;
     case PCM::MessageType::MarkAttributedPrivateClickMeasurementsAsExpiredForTesting:
-        handlePCMMessageWithReply<MessageInfo::markAttributedPrivateClickMeasurementsAsExpiredForTesting>(WTFMove(encodedMessage), WTFMove(replySender));
+        handlePCMMessageWithReply<MessageInfo::markAttributedPrivateClickMeasurementsAsExpiredForTesting>(encodedMessage, WTFMove(replySender));
         break;
     case PCM::MessageType::SetPCMFraudPreventionValuesForTesting:
-        handlePCMMessage<MessageInfo::setPCMFraudPreventionValuesForTesting>(WTFMove(encodedMessage));
+        handlePCMMessage<MessageInfo::setPCMFraudPreventionValuesForTesting>(encodedMessage);
         break;
     case PCM::MessageType::StartTimerImmediatelyForTesting:
-        handlePCMMessage<MessageInfo::startTimerImmediatelyForTesting>(WTFMove(encodedMessage));
+        handlePCMMessage<MessageInfo::startTimerImmediatelyForTesting>(encodedMessage);
         break;
     case PCM::MessageType::SetPrivateClickMeasurementAppBundleIDForTesting:
-        handlePCMMessage<MessageInfo::setPrivateClickMeasurementAppBundleIDForTesting>(WTFMove(encodedMessage));
+        handlePCMMessage<MessageInfo::setPrivateClickMeasurementAppBundleIDForTesting>(encodedMessage);
         break;
     case PCM::MessageType::DestroyStoreForTesting:
-        handlePCMMessageWithReply<MessageInfo::destroyStoreForTesting>(WTFMove(encodedMessage), WTFMove(replySender));
+        handlePCMMessageWithReply<MessageInfo::destroyStoreForTesting>(encodedMessage, WTFMove(replySender));
         break;
     case PCM::MessageType::AllowTLSCertificateChainForLocalPCMTesting:
-        handlePCMMessage<MessageInfo::allowTLSCertificateChainForLocalPCMTesting>(WTFMove(encodedMessage));
+        handlePCMMessage<MessageInfo::allowTLSCertificateChainForLocalPCMTesting>(encodedMessage);
         break;
     }
 }

Modified: trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerInterface.h (284128 => 284129)


--- trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerInterface.h	2021-10-13 22:09:42 UTC (rev 284128)
+++ trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerInterface.h	2021-10-13 22:16:36 UTC (rev 284129)
@@ -35,6 +35,10 @@
 
 namespace WebKit {
 
+namespace Daemon {
+class Connection;
+}
+
 enum class PrivateClickMeasurementAttributionType : bool { Unattributed, Attributed };
 
 class PrivateClickMeasurementManager;
@@ -41,8 +45,6 @@
 
 namespace PCM {
 
-class Connection;
-
 class ManagerInterface {
 public:
     virtual ~ManagerInterface() { };
@@ -106,7 +108,7 @@
 constexpr const char* protocolEncodedMessageKey { "encoded message" };
 using EncodedMessage = Vector<uint8_t>;
 
-void decodeMessageAndSendToManager(const Connection&, MessageType, Vector<uint8_t>&& message, CompletionHandler<void(Vector<uint8_t>&&)>&&);
+void decodeMessageAndSendToManager(const Daemon::Connection&, MessageType, Span<const uint8_t> encodedMessage, CompletionHandler<void(Vector<uint8_t>&&)>&&);
 void doDailyActivityInManager();
 bool messageTypeSendsReply(MessageType);
 

Modified: trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerProxy.cpp (284128 => 284129)


--- trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerProxy.cpp	2021-10-13 22:09:42 UTC (rev 284128)
+++ trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerProxy.cpp	2021-10-13 22:16:36 UTC (rev 284129)
@@ -26,9 +26,9 @@
 #include "config.h"
 #include "PrivateClickMeasurementManagerProxy.h"
 
+#include "DaemonDecoder.h"
+#include "DaemonEncoder.h"
 #include "PrivateClickMeasurementConnection.h"
-#include "PrivateClickMeasurementDecoder.h"
-#include "PrivateClickMeasurementEncoder.h"
 #include "WebCoreArgumentCoders.h"
 
 namespace WebKit {
@@ -38,7 +38,7 @@
 template<MessageType messageType, typename... Args>
 void ManagerProxy::sendMessage(Args&&... args) const
 {
-    Encoder encoder;
+    Daemon::Encoder encoder;
     encoder.encode(std::forward<Args>(args)...);
     m_connection.send(messageType, encoder.takeBuffer());
 }
@@ -45,13 +45,13 @@
 
 template<typename... Args> struct ReplyCaller;
 template<> struct ReplyCaller<> {
-    static void callReply(Decoder&& decoder, CompletionHandler<void()>&& completionHandler)
+    static void callReply(Daemon::Decoder&& decoder, CompletionHandler<void()>&& completionHandler)
     {
         completionHandler();
     }
 };
 template<> struct ReplyCaller<String> {
-    static void callReply(Decoder&& decoder, CompletionHandler<void(String&&)>&& completionHandler)
+    static void callReply(Daemon::Decoder&& decoder, CompletionHandler<void(String&&)>&& completionHandler)
     {
         std::optional<String> string;
         decoder >> string;
@@ -64,10 +64,10 @@
 template<MessageType messageType, typename... Args, typename... ReplyArgs>
 void ManagerProxy::sendMessageWithReply(CompletionHandler<void(ReplyArgs...)>&& completionHandler, Args&&... args) const
 {
-    Encoder encoder;
+    Daemon::Encoder encoder;
     encoder.encode(std::forward<Args>(args)...);
     m_connection.sendWithReply(messageType, encoder.takeBuffer(), [completionHandler = WTFMove(completionHandler)] (auto replyBuffer) mutable {
-        Decoder decoder(WTFMove(replyBuffer));
+        Daemon::Decoder decoder(WTFMove(replyBuffer));
         ReplyCaller<ReplyArgs...>::callReply(WTFMove(decoder), WTFMove(completionHandler));
     });
 }

Modified: trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerProxy.h (284128 => 284129)


--- trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerProxy.h	2021-10-13 22:09:42 UTC (rev 284128)
+++ trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerProxy.h	2021-10-13 22:16:36 UTC (rev 284129)
@@ -69,7 +69,7 @@
     template<MessageType messageType, typename... Args, typename... ReplyArgs>
     void sendMessageWithReply(CompletionHandler<void(ReplyArgs...)>&&, Args&&...) const;
 
-    ConnectionToMachService m_connection;
+    Connection m_connection;
 };
 
 } // namespace PCM

Modified: trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/cocoa/PrivateClickMeasurementConnectionCocoa.mm (284128 => 284129)


--- trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/cocoa/PrivateClickMeasurementConnectionCocoa.mm	2021-10-13 22:09:42 UTC (rev 284128)
+++ trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/cocoa/PrivateClickMeasurementConnectionCocoa.mm	2021-10-13 22:16:36 UTC (rev 284129)
@@ -26,7 +26,7 @@
 #import "config.h"
 #import "PrivateClickMeasurementConnection.h"
 
-#import "PrivateClickMeasurementEncoder.h"
+#import "DaemonEncoder.h"
 #import "PrivateClickMeasurementXPCUtilities.h"
 #import <wtf/NeverDestroyed.h>
 
@@ -34,29 +34,8 @@
 
 namespace PCM {
 
-void ConnectionToMachService::initializeConnectionIfNeeded() const
+void Connection::newConnectionWasInitialized() const
 {
-    if (m_connection)
-        return;
-    m_connection = adoptNS(xpc_connection_create_mach_service(m_machServiceName.data(), dispatch_get_main_queue(), 0));
-    xpc_connection_set_event_handler(m_connection.get(), [weakThis = makeWeakPtr(*this)](xpc_object_t event) {
-        if (!weakThis)
-            return;
-        if (event == XPC_ERROR_CONNECTION_INVALID)
-            WTFLogAlways("Failed to connect to mach service %s, likely because it is not registered with launchd", weakThis->m_machServiceName.data());
-        if (event == XPC_ERROR_CONNECTION_INTERRUPTED) {
-            // Daemon crashed, we will need to make a new connection to a new instance of the daemon.
-            weakThis->m_connection = nullptr;
-        }
-        weakThis->checkForDebugMessageBroadcast(event);
-    });
-    xpc_connection_activate(m_connection.get());
-
-    sendDebugModeIsEnabledMessageIfNecessary();
-}
-
-void ConnectionToMachService::sendDebugModeIsEnabledMessageIfNecessary() const
-{
     ASSERT(m_connection);
     if (!m_networkSession
         || m_networkSession->sessionID().isEphemeral()
@@ -63,12 +42,12 @@
         || !m_networkSession->privateClickMeasurementDebugModeEnabled())
         return;
 
-    Encoder encoder;
+    Daemon::Encoder encoder;
     encoder.encode(true);
     send(MessageType::SetDebugModeIsEnabled, encoder.takeBuffer());
 }
 
-void ConnectionToMachService::checkForDebugMessageBroadcast(xpc_object_t request) const
+void Connection::connectionReceivedEvent(xpc_object_t request) const
 {
     if (xpc_get_type(request) != XPC_TYPE_DICTIONARY)
         return;
@@ -82,59 +61,14 @@
     m_networkSession->networkProcess().broadcastConsoleMessage(m_networkSession->sessionID(), MessageSource::PrivateClickMeasurement, messageLevel, String::fromUTF8(debugMessage));
 }
 
-static OSObjectPtr<xpc_object_t> dictionaryFromMessage(MessageType messageType, EncodedMessage&& message)
+RetainPtr<xpc_object_t> Connection::dictionaryFromMessage(MessageType messageType, EncodedMessage&& message) const
 {
-    auto dictionary = adoptOSObject(xpc_dictionary_create(nullptr, nullptr, 0));
+    auto dictionary = adoptNS(xpc_dictionary_create(nullptr, nullptr, 0));
     addVersionAndEncodedMessageToDictionary(WTFMove(message), dictionary.get());
     xpc_dictionary_set_uint64(dictionary.get(), protocolMessageTypeKey, static_cast<uint64_t>(messageType));
     return dictionary;
 }
 
-void Connection::send(xpc_object_t message) const
-{
-    ASSERT(RunLoop::isMain());
-    ASSERT(m_connection.get());
-    ASSERT(xpc_get_type(message) == XPC_TYPE_DICTIONARY);
-    xpc_connection_send_message(m_connection.get(), message);
-}
-
-void Connection::sendWithReply(xpc_object_t message, CompletionHandler<void(xpc_object_t)>&& completionHandler) const
-{
-    ASSERT(RunLoop::isMain());
-    ASSERT(m_connection.get());
-    ASSERT(xpc_get_type(message) == XPC_TYPE_DICTIONARY);
-    xpc_connection_send_message_with_reply(m_connection.get(), message, dispatch_get_main_queue(), makeBlockPtr([completionHandler = WTFMove(completionHandler)] (xpc_object_t reply) mutable {
-        ASSERT(RunLoop::isMain());
-        completionHandler(reply);
-    }).get());
-}
-
-void ConnectionToMachService::send(MessageType messageType, EncodedMessage&& message) const
-{
-    initializeConnectionIfNeeded();
-    Connection::send(dictionaryFromMessage(messageType, WTFMove(message)).get());
-}
-
-void ConnectionToMachService::sendWithReply(MessageType messageType, EncodedMessage&& message, CompletionHandler<void(EncodedMessage&&)>&& completionHandler) const
-{
-    ASSERT(RunLoop::isMain());
-    initializeConnectionIfNeeded();
-
-    Connection::sendWithReply(dictionaryFromMessage(messageType, WTFMove(message)).get(), [completionHandler = WTFMove(completionHandler)] (xpc_object_t reply) mutable {
-        if (xpc_get_type(reply) != XPC_TYPE_DICTIONARY) {
-            ASSERT_NOT_REACHED();
-            return completionHandler({ });
-        }
-        if (xpc_dictionary_get_uint64(reply, protocolVersionKey) != protocolVersionValue) {
-            ASSERT_NOT_REACHED();
-            return completionHandler({ });
-        }
-        size_t dataSize { 0 };
-        const void* data = "" protocolEncodedMessageKey, &dataSize);
-        completionHandler({ static_cast<const uint8_t*>(data), dataSize });
-    });
-}
-
 } // namespace PCM
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/Platform/IPC/ArgumentCoders.cpp (284128 => 284129)


--- trunk/Source/WebKit/Platform/IPC/ArgumentCoders.cpp	2021-10-13 22:09:42 UTC (rev 284128)
+++ trunk/Source/WebKit/Platform/IPC/ArgumentCoders.cpp	2021-10-13 22:16:36 UTC (rev 284129)
@@ -26,9 +26,9 @@
 #include "config.h"
 #include "ArgumentCoders.h"
 
+#include "DaemonDecoder.h"
+#include "DaemonEncoder.h"
 #include "DataReference.h"
-#include "PrivateClickMeasurementDecoder.h"
-#include "PrivateClickMeasurementEncoder.h"
 #include "StreamConnectionEncoder.h"
 #include <wtf/text/AtomString.h>
 #include <wtf/text/CString.h>
@@ -44,7 +44,7 @@
 template
 void ArgumentCoder<WallTime>::encode<Encoder>(Encoder&, const WallTime&);
 template
-void ArgumentCoder<WallTime>::encode<WebKit::PCM::Encoder>(WebKit::PCM::Encoder&, const WallTime&);
+void ArgumentCoder<WallTime>::encode<WebKit::Daemon::Encoder>(WebKit::Daemon::Encoder&, const WallTime&);
 
 WARN_UNUSED_RETURN bool ArgumentCoder<WallTime>::decode(Decoder& decoder, WallTime& time)
 {
@@ -68,7 +68,7 @@
 template
 std::optional<WallTime> ArgumentCoder<WallTime>::decode<Decoder>(Decoder&);
 template
-std::optional<WallTime> ArgumentCoder<WallTime>::decode<WebKit::PCM::Decoder>(WebKit::PCM::Decoder&);
+std::optional<WallTime> ArgumentCoder<WallTime>::decode<WebKit::Daemon::Decoder>(WebKit::Daemon::Decoder&);
 
 void ArgumentCoder<AtomString>::encode(Encoder& encoder, const AtomString& atomString)
 {
@@ -99,7 +99,7 @@
     encoder.encodeFixedLengthData(string.dataAsUInt8Ptr(), length, 1);
 }
 template void ArgumentCoder<CString>::encode<Encoder>(Encoder&, const CString&);
-template void ArgumentCoder<CString>::encode<WebKit::PCM::Encoder>(WebKit::PCM::Encoder&, const CString&);
+template void ArgumentCoder<CString>::encode<WebKit::Daemon::Encoder>(WebKit::Daemon::Encoder&, const CString&);
 
 template<typename Decoder>
 std::optional<CString> ArgumentCoder<CString>::decode(Decoder& decoder)
@@ -128,7 +128,7 @@
 template
 std::optional<CString> ArgumentCoder<CString>::decode<Decoder>(Decoder&);
 template
-std::optional<CString> ArgumentCoder<CString>::decode<WebKit::PCM::Decoder>(WebKit::PCM::Decoder&);
+std::optional<CString> ArgumentCoder<CString>::decode<WebKit::Daemon::Decoder>(WebKit::Daemon::Decoder&);
 
 template<typename Encoder>
 void ArgumentCoder<String>::encode(Encoder& encoder, const String& string)
@@ -154,7 +154,7 @@
 template
 void ArgumentCoder<String>::encode<StreamConnectionEncoder>(StreamConnectionEncoder&, const String&);
 template
-void ArgumentCoder<String>::encode<WebKit::PCM::Encoder>(WebKit::PCM::Encoder&, const String&);
+void ArgumentCoder<String>::encode<WebKit::Daemon::Encoder>(WebKit::Daemon::Encoder&, const String&);
 
 template<typename CharacterType, typename Decoder>
 static inline std::optional<String> decodeStringText(Decoder& decoder, uint32_t length)
@@ -196,7 +196,7 @@
 template
 std::optional<String> ArgumentCoder<String>::decode<Decoder>(Decoder&);
 template
-std::optional<String> ArgumentCoder<String>::decode<WebKit::PCM::Decoder>(WebKit::PCM::Decoder&);
+std::optional<String> ArgumentCoder<String>::decode<WebKit::Daemon::Decoder>(WebKit::Daemon::Decoder&);
 
 WARN_UNUSED_RETURN bool ArgumentCoder<String>::decode(Decoder& decoder, String& result)
 {

Copied: trunk/Source/WebKit/Platform/IPC/DaemonConnection.cpp (from rev 284128, trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementConnection.cpp) (0 => 284129)


--- trunk/Source/WebKit/Platform/IPC/DaemonConnection.cpp	                        (rev 0)
+++ trunk/Source/WebKit/Platform/IPC/DaemonConnection.cpp	2021-10-13 22:16:36 UTC (rev 284129)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+
+#include "config.h"
+#include "DaemonConnection.h"
+
+#include "PrivateClickMeasurementConnection.h"
+
+namespace WebKit {
+
+namespace Daemon {
+
+#if !PLATFORM(COCOA)
+
+template<typename Traits>
+void ConnectionToMachService<Traits>::send(typename Traits::MessageType, EncodedMessage&&) const
+{
+}
+
+template<typename Traits>
+void ConnectionToMachService<Traits>::sendWithReply(typename Traits::MessageType, EncodedMessage&&, CompletionHandler<void(EncodedMessage&&)>&& completionHandler) const
+{
+    completionHandler({ });
+}
+
+template class ConnectionToMachService<PCM::ConnectionTraits>;
+
+#endif
+
+} // namespace Daemon
+
+} // namespace WebKit

Copied: trunk/Source/WebKit/Platform/IPC/DaemonConnection.h (from rev 284128, trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementConnection.h) (0 => 284129)


--- trunk/Source/WebKit/Platform/IPC/DaemonConnection.h	                        (rev 0)
+++ trunk/Source/WebKit/Platform/IPC/DaemonConnection.h	2021-10-13 22:16:36 UTC (rev 284129)
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2021 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/CompletionHandler.h>
+#include <wtf/Vector.h>
+#include <wtf/WeakPtr.h>
+#include <wtf/text/CString.h>
+
+#if PLATFORM(COCOA)
+#include <wtf/RetainPtr.h>
+#include <wtf/spi/darwin/XPCSPI.h>
+#endif
+
+namespace WebKit {
+
+namespace Daemon {
+
+using EncodedMessage = Vector<uint8_t>;
+
+class Connection : public CanMakeWeakPtr<Connection> {
+public:
+    Connection() = default;
+#if PLATFORM(COCOA)
+    explicit Connection(RetainPtr<xpc_connection_t>&& connection)
+        : m_connection(WTFMove(connection)) { }
+    xpc_connection_t get() const { return m_connection.get(); }
+    void send(xpc_object_t) const;
+    void sendWithReply(xpc_object_t, CompletionHandler<void(xpc_object_t)>&&) const;
+protected:
+    mutable RetainPtr<xpc_connection_t> m_connection;
+#endif
+};
+
+template<typename Traits>
+class ConnectionToMachService : public Connection {
+public:
+    ConnectionToMachService(CString&& machServiceName)
+        : m_machServiceName(WTFMove(machServiceName)) { }
+    virtual ~ConnectionToMachService() = default;
+
+    void send(typename Traits::MessageType, EncodedMessage&&) const;
+    void sendWithReply(typename Traits::MessageType, EncodedMessage&&, CompletionHandler<void(EncodedMessage&&)>&&) const;
+
+    virtual void newConnectionWasInitialized() const = 0;
+#if PLATFORM(COCOA)
+    virtual RetainPtr<xpc_object_t> dictionaryFromMessage(typename Traits::MessageType, EncodedMessage&&) const = 0;
+    virtual void connectionReceivedEvent(xpc_object_t) const = 0;
+#endif
+
+private:
+    void initializeConnectionIfNeeded() const;
+
+    const CString m_machServiceName;
+};
+
+} // namespace Daemon
+
+} // namespace WebKit

Copied: trunk/Source/WebKit/Platform/IPC/DaemonDecoder.cpp (from rev 284128, trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDecoder.cpp) (0 => 284129)


--- trunk/Source/WebKit/Platform/IPC/DaemonDecoder.cpp	                        (rev 0)
+++ trunk/Source/WebKit/Platform/IPC/DaemonDecoder.cpp	2021-10-13 22:16:36 UTC (rev 284129)
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+
+#include "config.h"
+#include "DaemonDecoder.h"
+
+namespace WebKit {
+
+namespace Daemon {
+
+Decoder::~Decoder()
+{
+    ASSERT(m_bufferPosition == m_buffer.size());
+}
+
+bool Decoder::bufferIsLargeEnoughToContainBytes(size_t bytes) const
+{
+    return bytes <= m_buffer.size() - m_bufferPosition;
+}
+
+bool Decoder::decodeFixedLengthData(uint8_t* data, size_t size, size_t)
+{
+    if (!bufferIsLargeEnoughToContainBytes(size))
+        return false;
+    memcpy(data, m_buffer.data() + m_bufferPosition, size);
+    m_bufferPosition += size;
+    return true;
+}
+
+const uint8_t* Decoder::decodeFixedLengthReference(size_t size, size_t)
+{
+    if (!bufferIsLargeEnoughToContainBytes(size))
+        return nullptr;
+    const uint8_t* data = "" + m_bufferPosition;
+    m_bufferPosition += size;
+    return data;
+}
+
+} // namespace Daemon
+
+} // namespace WebKit

Copied: trunk/Source/WebKit/Platform/IPC/DaemonDecoder.h (from rev 284128, trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDecoder.h) (0 => 284129)


--- trunk/Source/WebKit/Platform/IPC/DaemonDecoder.h	                        (rev 0)
+++ trunk/Source/WebKit/Platform/IPC/DaemonDecoder.h	2021-10-13 22:16:36 UTC (rev 284129)
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2021 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 "ArgumentCoders.h"
+
+namespace WebKit {
+
+namespace Daemon {
+
+class Decoder {
+public:
+    Decoder(Span<const uint8_t> buffer)
+        : m_buffer(buffer) { }
+    ~Decoder();
+
+    template<typename T>
+    Decoder& operator>>(std::optional<T>& t)
+    {
+        t = IPC::ArgumentCoder<std::remove_const_t<std::remove_reference_t<T>>, void>::decode(*this);
+        return *this;
+    }
+
+    template<typename T>
+    WARN_UNUSED_RETURN bool bufferIsLargeEnoughToContain(size_t numElements) const
+    {
+        static_assert(std::is_arithmetic<T>::value, "Type T must have a fixed, known encoded size!");
+
+        if (numElements > std::numeric_limits<size_t>::max() / sizeof(T))
+            return false;
+
+        return bufferIsLargeEnoughToContainBytes(numElements * sizeof(T));
+    }
+
+    WARN_UNUSED_RETURN bool decodeFixedLengthData(uint8_t* data, size_t, size_t alignment);
+    const uint8_t* decodeFixedLengthReference(size_t, size_t);
+
+private:
+    WARN_UNUSED_RETURN bool bufferIsLargeEnoughToContainBytes(size_t) const;
+
+    Span<const uint8_t> m_buffer;
+    size_t m_bufferPosition { 0 };
+};
+
+} // namespace Daemon
+
+} // namespace WebKit

Copied: trunk/Source/WebKit/Platform/IPC/DaemonEncoder.cpp (from rev 284128, trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementEncoder.cpp) (0 => 284129)


--- trunk/Source/WebKit/Platform/IPC/DaemonEncoder.cpp	                        (rev 0)
+++ trunk/Source/WebKit/Platform/IPC/DaemonEncoder.cpp	2021-10-13 22:16:36 UTC (rev 284129)
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+
+#include "config.h"
+#include "DaemonEncoder.h"
+
+namespace WebKit {
+
+namespace Daemon {
+
+void Encoder::encodeFixedLengthData(const uint8_t* data, size_t size, size_t)
+{
+    m_buffer.append(data, size);
+}
+
+} // namespace Daemon
+
+} // namespace WebKit

Copied: trunk/Source/WebKit/Platform/IPC/DaemonEncoder.h (from rev 284128, trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementEncoder.h) (0 => 284129)


--- trunk/Source/WebKit/Platform/IPC/DaemonEncoder.h	                        (rev 0)
+++ trunk/Source/WebKit/Platform/IPC/DaemonEncoder.h	2021-10-13 22:16:36 UTC (rev 284129)
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2021 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 "ArgumentCoders.h"
+
+namespace WebKit {
+
+namespace Daemon {
+
+class Encoder {
+public:
+    template<typename T>
+    Encoder& operator<<(T&& t)
+    {
+        IPC::ArgumentCoder<std::remove_const_t<std::remove_reference_t<T>>>::encode(*this, std::forward<T>(t));
+        return *this;
+    }
+
+    template<typename Arg, typename... Args>
+    void encode(Arg&& arg, Args&&... args)
+    {
+        *this << std::forward<Arg>(arg);
+        encode(std::forward<Args>(args)...);
+    }
+    void encode() { }
+
+    Vector<uint8_t> takeBuffer() { return std::exchange(m_buffer, { }); }
+
+    void encodeFixedLengthData(const uint8_t*, size_t, size_t alignment);
+
+private:
+    Vector<uint8_t> m_buffer;
+};
+
+} // namespace Daemon
+
+} // namespace WebKit

Copied: trunk/Source/WebKit/Platform/IPC/cocoa/DaemonConnectionCocoa.mm (from rev 284128, trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/cocoa/PrivateClickMeasurementConnectionCocoa.mm) (0 => 284129)


--- trunk/Source/WebKit/Platform/IPC/cocoa/DaemonConnectionCocoa.mm	                        (rev 0)
+++ trunk/Source/WebKit/Platform/IPC/cocoa/DaemonConnectionCocoa.mm	2021-10-13 22:16:36 UTC (rev 284129)
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+
+#import "config.h"
+#import "DaemonConnection.h"
+
+#import "DaemonEncoder.h"
+#import "PrivateClickMeasurementConnection.h"
+#import <wtf/BlockPtr.h>
+#import <wtf/RunLoop.h>
+
+namespace WebKit {
+
+namespace Daemon {
+
+void Connection::send(xpc_object_t message) const
+{
+    ASSERT(RunLoop::isMain());
+    ASSERT(m_connection.get());
+    ASSERT(xpc_get_type(message) == XPC_TYPE_DICTIONARY);
+    xpc_connection_send_message(m_connection.get(), message);
+}
+
+void Connection::sendWithReply(xpc_object_t message, CompletionHandler<void(xpc_object_t)>&& completionHandler) const
+{
+    ASSERT(RunLoop::isMain());
+    ASSERT(m_connection.get());
+    ASSERT(xpc_get_type(message) == XPC_TYPE_DICTIONARY);
+    xpc_connection_send_message_with_reply(m_connection.get(), message, dispatch_get_main_queue(), makeBlockPtr([completionHandler = WTFMove(completionHandler)] (xpc_object_t reply) mutable {
+        ASSERT(RunLoop::isMain());
+        completionHandler(reply);
+    }).get());
+}
+
+template<typename Traits>
+void ConnectionToMachService<Traits>::initializeConnectionIfNeeded() const
+{
+    if (m_connection)
+        return;
+    m_connection = adoptNS(xpc_connection_create_mach_service(m_machServiceName.data(), dispatch_get_main_queue(), 0));
+    xpc_connection_set_event_handler(m_connection.get(), [weakThis = WeakPtr { *this }](xpc_object_t event) {
+        if (!weakThis)
+            return;
+        if (event == XPC_ERROR_CONNECTION_INVALID)
+            WTFLogAlways("Failed to connect to mach service %s, likely because it is not registered with launchd", weakThis->m_machServiceName.data());
+        if (event == XPC_ERROR_CONNECTION_INTERRUPTED) {
+            // Daemon crashed, we will need to make a new connection to a new instance of the daemon.
+            weakThis->m_connection = nullptr;
+        }
+        weakThis->connectionReceivedEvent(event);
+    });
+    xpc_connection_activate(m_connection.get());
+    
+    newConnectionWasInitialized();
+}
+
+template<typename Traits>
+void ConnectionToMachService<Traits>::send(typename Traits::MessageType messageType, EncodedMessage&& message) const
+{
+    initializeConnectionIfNeeded();
+    Connection::send(dictionaryFromMessage(messageType, WTFMove(message)).get());
+}
+
+template<typename Traits>
+void ConnectionToMachService<Traits>::sendWithReply(typename Traits::MessageType messageType, EncodedMessage&& message, CompletionHandler<void(EncodedMessage&&)>&& completionHandler) const
+{
+    ASSERT(RunLoop::isMain());
+    initializeConnectionIfNeeded();
+
+    Connection::sendWithReply(dictionaryFromMessage(messageType, WTFMove(message)).get(), [completionHandler = WTFMove(completionHandler)] (xpc_object_t reply) mutable {
+        if (xpc_get_type(reply) != XPC_TYPE_DICTIONARY) {
+            ASSERT_NOT_REACHED();
+            return completionHandler({ });
+        }
+        if (xpc_dictionary_get_uint64(reply, Traits::protocolVersionKey) != Traits::protocolVersionValue) {
+            ASSERT_NOT_REACHED();
+            return completionHandler({ });
+        }
+        size_t dataSize { 0 };
+        const void* data = "" Traits::protocolEncodedMessageKey, &dataSize);
+        completionHandler({ static_cast<const uint8_t*>(data), dataSize });
+    });
+}
+
+template class ConnectionToMachService<PCM::ConnectionTraits>;
+
+} // namespace Daemon
+
+} // namespace WebKit

Modified: trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/Daemon/PCMDaemonConnectionSet.h (284128 => 284129)


--- trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/Daemon/PCMDaemonConnectionSet.h	2021-10-13 22:09:42 UTC (rev 284128)
+++ trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/Daemon/PCMDaemonConnectionSet.h	2021-10-13 22:16:36 UTC (rev 284129)
@@ -34,10 +34,11 @@
 }
 
 namespace WebKit {
+namespace Daemon {
+class Connection;
+}
 namespace PCM {
 
-class Connection;
-
 class DaemonConnectionSet {
 public:
     static DaemonConnectionSet& singleton();
@@ -45,7 +46,7 @@
     void add(xpc_connection_t);
     void remove(xpc_connection_t);
 
-    void setConnectedNetworkProcessHasDebugModeEnabled(const Connection&, bool);
+    void setConnectedNetworkProcessHasDebugModeEnabled(const Daemon::Connection&, bool);
     bool debugModeEnabled() const;
     void broadcastConsoleMessage(JSC::MessageLevel, const String&);
     

Modified: trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/Daemon/PCMDaemonConnectionSet.mm (284128 => 284129)


--- trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/Daemon/PCMDaemonConnectionSet.mm	2021-10-13 22:09:42 UTC (rev 284128)
+++ trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/Daemon/PCMDaemonConnectionSet.mm	2021-10-13 22:16:36 UTC (rev 284129)
@@ -57,7 +57,7 @@
     }
 }
 
-void DaemonConnectionSet::setConnectedNetworkProcessHasDebugModeEnabled(const Connection& connection, bool enabled)
+void DaemonConnectionSet::setConnectedNetworkProcessHasDebugModeEnabled(const Daemon::Connection& connection, bool enabled)
 {
     auto iterator = m_connections.find(connection.get());
     if (iterator == m_connections.end()) {

Modified: trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/Daemon/PCMDaemonEntryPoint.mm (284128 => 284129)


--- trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/Daemon/PCMDaemonEntryPoint.mm	2021-10-13 22:09:42 UTC (rev 284128)
+++ trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/Daemon/PCMDaemonEntryPoint.mm	2021-10-13 22:16:36 UTC (rev 284129)
@@ -26,9 +26,9 @@
 #import "config.h"
 #import "PCMDaemonEntryPoint.h"
 
+#import "DaemonDecoder.h"
 #import "PCMDaemonConnectionSet.h"
 #import "PrivateClickMeasurementConnection.h"
-#import "PrivateClickMeasurementDecoder.h"
 #import "PrivateClickMeasurementManagerInterface.h"
 #import "PrivateClickMeasurementXPCUtilities.h"
 #import <Foundation/Foundation.h>
@@ -69,8 +69,8 @@
     auto messageType { static_cast<PCM::MessageType>(xpc_dictionary_get_uint64(request, PCM::protocolMessageTypeKey)) };
     size_t dataSize { 0 };
     const void* data = "" PCM::protocolEncodedMessageKey, &dataSize);
-    PCM::EncodedMessage encodedMessage { static_cast<const uint8_t*>(data), dataSize };
-    decodeMessageAndSendToManager(PCM::Connection(xpc_dictionary_get_remote_connection(request)), messageType, WTFMove(encodedMessage), replySender(messageType, request));
+    Span<const uint8_t> encodedMessage { static_cast<const uint8_t*>(data), dataSize };
+    decodeMessageAndSendToManager(Daemon::Connection(xpc_dictionary_get_remote_connection(request)), messageType, encodedMessage, replySender(messageType, request));
 }
 
 static void startListeningForMachServiceConnections(const char* serviceName)

Modified: trunk/Source/WebKit/Shared/cf/ArgumentCodersCF.cpp (284128 => 284129)


--- trunk/Source/WebKit/Shared/cf/ArgumentCodersCF.cpp	2021-10-13 22:09:42 UTC (rev 284128)
+++ trunk/Source/WebKit/Shared/cf/ArgumentCodersCF.cpp	2021-10-13 22:16:36 UTC (rev 284129)
@@ -29,11 +29,11 @@
 #include "ArgumentCodersCF.h"
 
 #include "ArgumentCoders.h"
+#include "DaemonDecoder.h"
+#include "DaemonEncoder.h"
 #include "DataReference.h"
 #include "Decoder.h"
 #include "Encoder.h"
-#include "PrivateClickMeasurementDecoder.h"
-#include "PrivateClickMeasurementEncoder.h"
 #include "StreamConnectionEncoder.h"
 #include <CoreGraphics/CoreGraphics.h>
 #include <wtf/EnumTraits.h>
@@ -419,7 +419,7 @@
 }
 
 template std::optional<RetainPtr<CFDataRef>> ArgumentCoder<RetainPtr<CFDataRef>>::decode<Decoder>(Decoder&);
-template std::optional<RetainPtr<CFDataRef>> ArgumentCoder<RetainPtr<CFDataRef>>::decode<WebKit::PCM::Decoder>(WebKit::PCM::Decoder&);
+template std::optional<RetainPtr<CFDataRef>> ArgumentCoder<RetainPtr<CFDataRef>>::decode<WebKit::Daemon::Decoder>(WebKit::Daemon::Decoder&);
 
 template<typename Encoder>
 void ArgumentCoder<CFDateRef>::encode(Encoder& encoder, CFDateRef date)
@@ -840,7 +840,7 @@
 }
 
 template void ArgumentCoder<SecTrustRef>::encode<Encoder>(Encoder&, SecTrustRef);
-template void ArgumentCoder<SecTrustRef>::encode<WebKit::PCM::Encoder>(WebKit::PCM::Encoder&, SecTrustRef);
+template void ArgumentCoder<SecTrustRef>::encode<WebKit::Daemon::Encoder>(WebKit::Daemon::Encoder&, SecTrustRef);
 template void ArgumentCoder<SecTrustRef>::encode<StreamConnectionEncoder>(StreamConnectionEncoder&, SecTrustRef);
 
 template<typename Decoder>
@@ -867,7 +867,7 @@
 }
 
 template std::optional<RetainPtr<SecTrustRef>> ArgumentCoder<RetainPtr<SecTrustRef>>::decode<Decoder>(Decoder&);
-template std::optional<RetainPtr<SecTrustRef>> ArgumentCoder<RetainPtr<SecTrustRef>>::decode<WebKit::PCM::Decoder>(WebKit::PCM::Decoder&);
+template std::optional<RetainPtr<SecTrustRef>> ArgumentCoder<RetainPtr<SecTrustRef>>::decode<WebKit::Daemon::Decoder>(WebKit::Daemon::Decoder&);
 #endif
 
 } // namespace IPC

Modified: trunk/Source/WebKit/Shared/curl/WebCoreArgumentCodersCurl.cpp (284128 => 284129)


--- trunk/Source/WebKit/Shared/curl/WebCoreArgumentCodersCurl.cpp	2021-10-13 22:09:42 UTC (rev 284128)
+++ trunk/Source/WebKit/Shared/curl/WebCoreArgumentCodersCurl.cpp	2021-10-13 22:16:36 UTC (rev 284129)
@@ -26,9 +26,9 @@
 #include "config.h"
 #include "WebCoreArgumentCoders.h"
 
+#include "DaemonDecoder.h"
+#include "DaemonEncoder.h"
 #include "DataReference.h"
-#include "PrivateClickMeasurementDecoder.h"
-#include "PrivateClickMeasurementEncoder.h"
 #include <WebCore/CertificateInfo.h>
 #include <WebCore/CurlProxySettings.h>
 #include <WebCore/DictionaryPopupInfo.h>
@@ -62,7 +62,7 @@
         encoder << certificate;
 }
 template void ArgumentCoder<WebCore::CertificateInfo>::encode<Encoder>(Encoder&, const WebCore::CertificateInfo&);
-template void ArgumentCoder<WebCore::CertificateInfo>::encode<WebKit::PCM::Encoder>(WebKit::PCM::Encoder&, const WebCore::CertificateInfo&);
+template void ArgumentCoder<WebCore::CertificateInfo>::encode<WebKit::Daemon::Encoder>(WebKit::Daemon::Encoder&, const WebCore::CertificateInfo&);
 
 template<typename Decoder>
 std::optional<CertificateInfo> ArgumentCoder<CertificateInfo>::decode(Decoder& decoder)
@@ -90,7 +90,7 @@
     return CertificateInfo { *verificationError, WTFMove(certificateChain) };
 }
 template std::optional<WebCore::CertificateInfo> ArgumentCoder<WebCore::CertificateInfo>::decode<Decoder>(Decoder&);
-template std::optional<WebCore::CertificateInfo> ArgumentCoder<WebCore::CertificateInfo>::decode<WebKit::PCM::Decoder>(WebKit::PCM::Decoder&);
+template std::optional<WebCore::CertificateInfo> ArgumentCoder<WebCore::CertificateInfo>::decode<WebKit::Daemon::Decoder>(WebKit::Daemon::Decoder&);
 
 void ArgumentCoder<ResourceError>::encodePlatformData(Encoder& encoder, const ResourceError& resourceError)
 {

Modified: trunk/Source/WebKit/Shared/glib/ArgumentCodersGLib.cpp (284128 => 284129)


--- trunk/Source/WebKit/Shared/glib/ArgumentCodersGLib.cpp	2021-10-13 22:09:42 UTC (rev 284128)
+++ trunk/Source/WebKit/Shared/glib/ArgumentCodersGLib.cpp	2021-10-13 22:16:36 UTC (rev 284129)
@@ -26,9 +26,9 @@
 #include "config.h"
 #include "ArgumentCodersGLib.h"
 
+#include "DaemonDecoder.h"
+#include "DaemonEncoder.h"
 #include "DataReference.h"
-#include "PrivateClickMeasurementDecoder.h"
-#include "PrivateClickMeasurementEncoder.h"
 #include <gio/gio.h>
 #include <wtf/glib/GUniquePtr.h>
 #include <wtf/text/CString.h>
@@ -107,7 +107,7 @@
     }
 }
 template void ArgumentCoder<GRefPtr<GTlsCertificate>>::encode<Encoder>(Encoder&, GRefPtr<GTlsCertificate>);
-template void ArgumentCoder<GRefPtr<GTlsCertificate>>::encode<WebKit::PCM::Encoder>(WebKit::PCM::Encoder&, GRefPtr<GTlsCertificate>);
+template void ArgumentCoder<GRefPtr<GTlsCertificate>>::encode<WebKit::Daemon::Encoder>(WebKit::Daemon::Encoder&, GRefPtr<GTlsCertificate>);
 
 template<typename Decoder>
 std::optional<GRefPtr<GTlsCertificate>> ArgumentCoder<GRefPtr<GTlsCertificate>>::decode(Decoder& decoder)
@@ -164,6 +164,6 @@
     return certificate;
 }
 template std::optional<GRefPtr<GTlsCertificate>> ArgumentCoder<GRefPtr<GTlsCertificate>>::decode<Decoder>(Decoder&);
-template std::optional<GRefPtr<GTlsCertificate>> ArgumentCoder<GRefPtr<GTlsCertificate>>::decode<WebKit::PCM::Decoder>(WebKit::PCM::Decoder&);
+template std::optional<GRefPtr<GTlsCertificate>> ArgumentCoder<GRefPtr<GTlsCertificate>>::decode<WebKit::Daemon::Decoder>(WebKit::Daemon::Decoder&);
 
 } // namespace IPC

Modified: trunk/Source/WebKit/Shared/mac/WebCoreArgumentCodersMac.mm (284128 => 284129)


--- trunk/Source/WebKit/Shared/mac/WebCoreArgumentCodersMac.mm	2021-10-13 22:09:42 UTC (rev 284128)
+++ trunk/Source/WebKit/Shared/mac/WebCoreArgumentCodersMac.mm	2021-10-13 22:16:36 UTC (rev 284129)
@@ -29,9 +29,9 @@
 
 #import "ArgumentCodersCF.h"
 #import "ArgumentCodersCocoa.h"
+#import "DaemonDecoder.h"
+#import "DaemonEncoder.h"
 #import "DataReference.h"
-#import "PrivateClickMeasurementDecoder.h"
-#import "PrivateClickMeasurementEncoder.h"
 #import <WebCore/CertificateInfo.h>
 #import <WebCore/ContentFilterUnblockHandler.h>
 #import <WebCore/Credential.h>
@@ -67,7 +67,7 @@
 }
 
 template<>
-void ArgumentCoder<WebCore::CertificateInfo>::encode(WebKit::PCM::Encoder& encoder, const WebCore::CertificateInfo& certificateInfo)
+void ArgumentCoder<WebCore::CertificateInfo>::encode(WebKit::Daemon::Encoder& encoder, const WebCore::CertificateInfo& certificateInfo)
 {
     ASSERT(certificateInfo.type() == WebCore::CertificateInfo::Type::Trust);
     encoder << certificateInfo.trust();
@@ -109,7 +109,7 @@
 }
 
 template<>
-std::optional<WebCore::CertificateInfo> ArgumentCoder<WebCore::CertificateInfo>::decode(WebKit::PCM::Decoder& decoder)
+std::optional<WebCore::CertificateInfo> ArgumentCoder<WebCore::CertificateInfo>::decode(WebKit::Daemon::Decoder& decoder)
 {
     std::optional<RetainPtr<SecTrustRef>> trust;
     decoder >> trust;

Modified: trunk/Source/WebKit/Shared/soup/WebCoreArgumentCodersSoup.cpp (284128 => 284129)


--- trunk/Source/WebKit/Shared/soup/WebCoreArgumentCodersSoup.cpp	2021-10-13 22:09:42 UTC (rev 284128)
+++ trunk/Source/WebKit/Shared/soup/WebCoreArgumentCodersSoup.cpp	2021-10-13 22:16:36 UTC (rev 284129)
@@ -29,9 +29,9 @@
 #include "WebCoreArgumentCoders.h"
 
 #include "ArgumentCodersGLib.h"
+#include "DaemonDecoder.h"
+#include "DaemonEncoder.h"
 #include "DataReference.h"
-#include "PrivateClickMeasurementDecoder.h"
-#include "PrivateClickMeasurementEncoder.h"
 #include <WebCore/CertificateInfo.h>
 #include <WebCore/Credential.h>
 #include <WebCore/DictionaryPopupInfo.h>
@@ -67,7 +67,7 @@
     encoder << static_cast<uint32_t>(certificateInfo.tlsErrors());
 }
 template void ArgumentCoder<CertificateInfo>::encode<Encoder>(Encoder&, const CertificateInfo&);
-template void ArgumentCoder<CertificateInfo>::encode<WebKit::PCM::Encoder>(WebKit::PCM::Encoder&, const CertificateInfo&);
+template void ArgumentCoder<CertificateInfo>::encode<WebKit::Daemon::Encoder>(WebKit::Daemon::Encoder&, const CertificateInfo&);
 
 template<typename Decoder>
 std::optional<CertificateInfo> ArgumentCoder<CertificateInfo>::decode(Decoder& decoder)
@@ -91,7 +91,7 @@
     return certificateInfo;
 }
 template std::optional<CertificateInfo> ArgumentCoder<CertificateInfo>::decode<Decoder>(Decoder&);
-template std::optional<CertificateInfo> ArgumentCoder<CertificateInfo>::decode<WebKit::PCM::Decoder>(WebKit::PCM::Decoder&);
+template std::optional<CertificateInfo> ArgumentCoder<CertificateInfo>::decode<WebKit::Daemon::Decoder>(WebKit::Daemon::Decoder&);
 
 void ArgumentCoder<ResourceError>::encodePlatformData(Encoder& encoder, const ResourceError& resourceError)
 {

Modified: trunk/Source/WebKit/Sources.txt (284128 => 284129)


--- trunk/Source/WebKit/Sources.txt	2021-10-13 22:09:42 UTC (rev 284128)
+++ trunk/Source/WebKit/Sources.txt	2021-10-13 22:16:36 UTC (rev 284129)
@@ -106,8 +106,6 @@
 NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementStore.cpp
 NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementConnection.cpp
 NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDaemonClient.cpp
-NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDecoder.cpp
-NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementEncoder.cpp
 NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerProxy.cpp
 
 NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp @no-unify
@@ -162,6 +160,9 @@
 Platform/IPC/ArgumentCoders.cpp @no-unify
 Platform/IPC/Attachment.cpp @no-unify
 Platform/IPC/Connection.cpp @no-unify
+Platform/IPC/DaemonConnection.cpp
+Platform/IPC/DaemonDecoder.cpp
+Platform/IPC/DaemonEncoder.cpp
 Platform/IPC/Decoder.cpp @no-unify
 Platform/IPC/Encoder.cpp @no-unify
 Platform/IPC/JSIPCBinding.cpp @no-unify

Modified: trunk/Source/WebKit/SourcesCocoa.txt (284128 => 284129)


--- trunk/Source/WebKit/SourcesCocoa.txt	2021-10-13 22:09:42 UTC (rev 284128)
+++ trunk/Source/WebKit/SourcesCocoa.txt	2021-10-13 22:16:36 UTC (rev 284129)
@@ -96,6 +96,7 @@
 Platform/ios/PaymentAuthorizationController.mm
 
 Platform/IPC/cocoa/ConnectionCocoa.mm
+Platform/IPC/cocoa/DaemonConnectionCocoa.mm
 Platform/IPC/cocoa/MachMessage.cpp
 
 Platform/IPC/darwin/IPCSemaphoreDarwin.cpp

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (284128 => 284129)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2021-10-13 22:09:42 UTC (rev 284128)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2021-10-13 22:16:36 UTC (rev 284129)
@@ -1256,6 +1256,8 @@
 		5C1427071C23F84C00D41183 /* DownloadManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C1426F91C23F84300D41183 /* DownloadManager.h */; };
 		5C1427181C23F8B700D41183 /* LegacyCustomProtocolManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C1427141C23F8B000D41183 /* LegacyCustomProtocolManager.h */; };
 		5C1579DC27165B8200ED5280 /* webpushd.c in Sources */ = {isa = PBXBuildFile; fileRef = 5C1579DB27165B7500ED5280 /* webpushd.c */; };
+		5C1579EE27172A8B00ED5280 /* DaemonEncoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C1579EA27172A8B00ED5280 /* DaemonEncoder.h */; };
+		5C1579EF27172A8B00ED5280 /* DaemonDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C1579EB27172A8B00ED5280 /* DaemonDecoder.h */; };
 		5C19A5201FD0B29500EEA323 /* URLSchemeTaskParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C19A51F1FD0B14700EEA323 /* URLSchemeTaskParameters.h */; };
 		5C20CBA01BB1ECD800895BB1 /* NetworkSession.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C20CB9E1BB0DD1800895BB1 /* NetworkSession.h */; };
 		5C26958520043212005C439B /* WKOpenPanelParametersPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C26958420042F12005C439B /* WKOpenPanelParametersPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -4535,6 +4537,13 @@
 		5C1579DA27165B2F00ED5280 /* webpushd */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = webpushd; sourceTree = BUILT_PRODUCTS_DIR; };
 		5C1579DB27165B7500ED5280 /* webpushd.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = webpushd.c; sourceTree = "<group>"; };
 		5C1579DD27165BE500ED5280 /* webpushd.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = webpushd.xcconfig; sourceTree = "<group>"; };
+		5C1579E227172A4900ED5280 /* DaemonConnection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DaemonConnection.cpp; sourceTree = "<group>"; };
+		5C1579E327172A4900ED5280 /* DaemonConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DaemonConnection.h; sourceTree = "<group>"; };
+		5C1579E627172A5100ED5280 /* DaemonConnectionCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DaemonConnectionCocoa.mm; sourceTree = "<group>"; };
+		5C1579E827172A8A00ED5280 /* DaemonEncoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DaemonEncoder.cpp; sourceTree = "<group>"; };
+		5C1579E927172A8B00ED5280 /* DaemonDecoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DaemonDecoder.cpp; sourceTree = "<group>"; };
+		5C1579EA27172A8B00ED5280 /* DaemonEncoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DaemonEncoder.h; sourceTree = "<group>"; };
+		5C1579EB27172A8B00ED5280 /* DaemonDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DaemonDecoder.h; sourceTree = "<group>"; };
 		5C19A51E1FD0B14600EEA323 /* URLSchemeTaskParameters.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = URLSchemeTaskParameters.cpp; sourceTree = "<group>"; };
 		5C19A51F1FD0B14700EEA323 /* URLSchemeTaskParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = URLSchemeTaskParameters.h; sourceTree = "<group>"; };
 		5C1B38DF2667140700B1545B /* WebPageNetworkParameters.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebPageNetworkParameters.h; sourceTree = "<group>"; };
@@ -4639,14 +4648,10 @@
 		5CB930F526E802150032B1C0 /* PrivateClickMeasurementManagerProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrivateClickMeasurementManagerProxy.h; sourceTree = "<group>"; };
 		5CB930F626E802150032B1C0 /* PrivateClickMeasurementDaemonClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrivateClickMeasurementDaemonClient.h; sourceTree = "<group>"; };
 		5CB930F726E802150032B1C0 /* PrivateClickMeasurementDaemonClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrivateClickMeasurementDaemonClient.cpp; sourceTree = "<group>"; };
-		5CB930F826E802150032B1C0 /* PrivateClickMeasurementDecoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrivateClickMeasurementDecoder.cpp; sourceTree = "<group>"; };
-		5CB930F926E802150032B1C0 /* PrivateClickMeasurementEncoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrivateClickMeasurementEncoder.cpp; sourceTree = "<group>"; };
 		5CB930FA26E802150032B1C0 /* PrivateClickMeasurementManagerInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrivateClickMeasurementManagerInterface.h; sourceTree = "<group>"; };
 		5CB930FB26E802150032B1C0 /* PrivateClickMeasurementManagerProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrivateClickMeasurementManagerProxy.cpp; sourceTree = "<group>"; };
 		5CB930FC26E802160032B1C0 /* PrivateClickMeasurementConnection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrivateClickMeasurementConnection.cpp; sourceTree = "<group>"; };
-		5CB930FD26E802160032B1C0 /* PrivateClickMeasurementDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrivateClickMeasurementDecoder.h; sourceTree = "<group>"; };
 		5CB930FE26E802160032B1C0 /* PrivateClickMeasurementConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrivateClickMeasurementConnection.h; sourceTree = "<group>"; };
-		5CB930FF26E802160032B1C0 /* PrivateClickMeasurementEncoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrivateClickMeasurementEncoder.h; sourceTree = "<group>"; };
 		5CB9310426E837FC0032B1C0 /* PCMDaemonEntryPoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PCMDaemonEntryPoint.h; sourceTree = "<group>"; };
 		5CB9310526E837FD0032B1C0 /* PCMDaemonEntryPoint.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PCMDaemonEntryPoint.mm; sourceTree = "<group>"; };
 		5CB9310626E839A90032B1C0 /* PrivateClickMeasurementManagerInterface.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrivateClickMeasurementManagerInterface.cpp; sourceTree = "<group>"; };
@@ -7369,6 +7374,12 @@
 				BCEE966B112FAF57006BCC24 /* Attachment.h */,
 				BC032DA210F437D10058C15A /* Connection.cpp */,
 				BC032DA310F437D10058C15A /* Connection.h */,
+				5C1579E227172A4900ED5280 /* DaemonConnection.cpp */,
+				5C1579E327172A4900ED5280 /* DaemonConnection.h */,
+				5C1579E927172A8B00ED5280 /* DaemonDecoder.cpp */,
+				5C1579EB27172A8B00ED5280 /* DaemonDecoder.h */,
+				5C1579E827172A8A00ED5280 /* DaemonEncoder.cpp */,
+				5C1579EA27172A8B00ED5280 /* DaemonEncoder.h */,
 				1AC7537E183BE50F0072CB15 /* DataReference.h */,
 				BC032D9D10F437D10058C15A /* Decoder.cpp */,
 				BC032D9E10F437D10058C15A /* Decoder.h */,
@@ -9437,10 +9448,6 @@
 				5C826D6926D482EA008AEC91 /* PrivateClickMeasurementDatabase.h */,
 				5CBE909026D7FB7C005A2E95 /* PrivateClickMeasurementDebugInfo.cpp */,
 				5CBE908F26D7FB62005A2E95 /* PrivateClickMeasurementDebugInfo.h */,
-				5CB930F826E802150032B1C0 /* PrivateClickMeasurementDecoder.cpp */,
-				5CB930FD26E802160032B1C0 /* PrivateClickMeasurementDecoder.h */,
-				5CB930F926E802150032B1C0 /* PrivateClickMeasurementEncoder.cpp */,
-				5CB930FF26E802160032B1C0 /* PrivateClickMeasurementEncoder.h */,
 				6BD05864220CE8C2000BED5C /* PrivateClickMeasurementManager.cpp */,
 				6BD05863220CE8C2000BED5C /* PrivateClickMeasurementManager.h */,
 				5CB9310626E839A90032B1C0 /* PrivateClickMeasurementManagerInterface.cpp */,
@@ -11171,6 +11178,7 @@
 			isa = PBXGroup;
 			children = (
 				1A30EAC5115D7DA30053E937 /* ConnectionCocoa.mm */,
+				5C1579E627172A5100ED5280 /* DaemonConnectionCocoa.mm */,
 				1A1EC69D1872092100B951F0 /* ImportanceAssertion.h */,
 				1A6D86BF1DF75265007745E8 /* MachMessage.cpp */,
 				1A6D86C01DF75265007745E8 /* MachMessage.h */,
@@ -12311,6 +12319,8 @@
 				57597EBD218184900037F924 /* CtapAuthenticator.h in Headers */,
 				57597EB921811D9A0037F924 /* CtapHidDriver.h in Headers */,
 				570DAACA230385FD00E8FC04 /* CtapNfcDriver.h in Headers */,
+				5C1579EF27172A8B00ED5280 /* DaemonDecoder.h in Headers */,
+				5C1579EE27172A8B00ED5280 /* DaemonEncoder.h in Headers */,
 				C55F91711C59676E0029E92D /* DataDetectionResult.h in Headers */,
 				1AC75380183BE50F0072CB15 /* DataReference.h in Headers */,
 				99036AE923A970870000B06A /* DebuggableInfoData.h in Headers */,
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to