Title: [292863] trunk/Source
Revision
292863
Author
[email protected]
Date
2022-04-14 07:12:02 -0700 (Thu, 14 Apr 2022)

Log Message

[WK2] Enable more efficient encoding of synchronous-message reply arguments
https://bugs.webkit.org/show_bug.cgi?id=238740
<rdar://problem/91567779>

Reviewed by Kimmo Kinnunen.

Source/WebKit:

Handling of synchronous messages requires construction of a
CompletionHandler object that wraps a lambda function which handles
logging of the passed-in reply arguments as well as subsequent encoding
and dispatching of the reply into the IPC channel.

Right now, for any given message the CompletionHandler type is generated
from the IPC message specification, and it's essentially a function type
with a void return value and const lvalue references for every
non-builtin parameter type. This type is imposed onto the lambda handler
and when invoked, all the reply arguments are passed on to the IPC
encoding as lvalue references.

This inhibits opportunities where the reply argument could instead be
moved into the completion handler invocation, enabling a more efficient
encoding of the passed-in value. For instance, if a Unix file descriptor
was moved into the completion handler invocation, it could be trickled
down into an IPC::Attachment object and dispatched over IPC without any
problems. Instead, because the lvalue reference is imposed as the type,
it will have to be duplicated even if the object itself is expiring or
would be movable down the invocation.

To cover these cases, the actual completion handler type is now deduced
from the synchronous-message-handling method itself. This means that
the completion handler parameter for the given handler method can now
specify whether it wants to receive reply arguments by value or by
either lvalue or rvalue reference. The completion handler lambda can
combine these parameter types with std::forward() to pass down the
actual arguments in the most optimal fashion.

To avoid problems, each CompletionHandler specialization retrieved from
the method siganture is validated against the CompletionHandler type
generated from the IPC specification, requiring that the decayed
parameter types match between the two. It's still possible to directly
use the CompletionHandler type from the IPC specification as the
completion handler type in the message-handling method.

An rvalue reference variant of ArgumentCoder<T>::encode() is added.
Generic implementation again casts the passed-in reference into an
rvalue and calls the encode() on that object. If that type provides
ref-qualified encode() methods, implementations of those methods can
adjust and more aggressively move things into the encoder when the
method is called on an rvalue. It would also be possible to delete the
ref-qualified method covering lvalues, meaning encoding would be allowed
only for objects that are moved into the completion handler.

For types with custom specializations of ArgumentCoder<T>, those
specializations would again have to provide rvalue variants of the
encode() method and handle the passed-in values appropriately.

The send() methods that were previously generated for every IPC message
are removed in favor of encoding and calling Connection::sendSyncReply()
in the completion-handler lambda. Missing std::forward() calls are added
in parameter pack expansions as required.

* GPUProcess/media/RemoteCDMProxy.cpp:
(WebKit::RemoteCDMProxy::getSupportedConfiguration):
* GPUProcess/media/RemoteCDMProxy.h:
* GPUProcess/media/RemoteImageDecoderAVFProxy.cpp:
(WebKit::RemoteImageDecoderAVFProxy::createFrameImageAtIndex):
* GPUProcess/media/RemoteImageDecoderAVFProxy.h:
* Platform/IPC/ArgumentCoder.h:
(IPC::ArgumentCoder::encode):
* Platform/IPC/HandleMessage.h:
(IPC::C::):
(IPC::CompletionHandlerValidation::matchingParameters):
(IPC::CompletionHandlerValidation::matchingTypes):
(IPC::handleMessageSynchronous):
(IPC::handleMessageSynchronousWantsConnection):
(IPC::handleMessageAsync):
(IPC::handleMessageAsyncWantsConnection):
* Platform/IPC/StreamServerConnection.h:
(IPC::StreamServerConnection::sendSyncReply):
* Scripts/webkit/messages.py:
(message_to_struct_declaration):
(generate_message_handler):
* Scripts/webkit/tests/TestWithCVPixelBufferMessageReceiver.cpp:
(Messages::TestWithCVPixelBuffer::ReceiveCVPixelBuffer::send): Deleted.
* Scripts/webkit/tests/TestWithCVPixelBufferMessages.h:
* Scripts/webkit/tests/TestWithImageDataMessageReceiver.cpp:
(Messages::TestWithImageData::ReceiveImageData::send): Deleted.
* Scripts/webkit/tests/TestWithImageDataMessages.h:
* Scripts/webkit/tests/TestWithLegacyReceiverMessageReceiver.cpp:
(Messages::TestWithLegacyReceiver::CreatePlugin::send): Deleted.
(Messages::TestWithLegacyReceiver::RunJavaScriptAlert::send): Deleted.
(Messages::TestWithLegacyReceiver::GetPlugins::send): Deleted.
(Messages::TestWithLegacyReceiver::GetPluginProcessConnection::send): Deleted.
(Messages::TestWithLegacyReceiver::TestMultipleAttributes::send): Deleted.
(Messages::TestWithLegacyReceiver::InterpretKeyEvent::send): Deleted.
* Scripts/webkit/tests/TestWithLegacyReceiverMessages.h:
* Scripts/webkit/tests/TestWithSemaphoreMessageReceiver.cpp:
(Messages::TestWithSemaphore::ReceiveSemaphore::send): Deleted.
* Scripts/webkit/tests/TestWithSemaphoreMessages.h:
* Scripts/webkit/tests/TestWithSuperclassMessageReceiver.cpp:
(Messages::TestWithSuperclass::TestAsyncMessage::send): Deleted.
(Messages::TestWithSuperclass::TestAsyncMessageWithNoArguments::send): Deleted.
(Messages::TestWithSuperclass::TestAsyncMessageWithMultipleArguments::send): Deleted.
(Messages::TestWithSuperclass::TestAsyncMessageWithConnection::send): Deleted.
(Messages::TestWithSuperclass::TestSyncMessage::send): Deleted.
(Messages::TestWithSuperclass::TestSynchronousMessage::send): Deleted.
* Scripts/webkit/tests/TestWithSuperclassMessages.h:
* Scripts/webkit/tests/TestWithoutAttributesMessageReceiver.cpp:
(Messages::TestWithoutAttributes::CreatePlugin::send): Deleted.
(Messages::TestWithoutAttributes::RunJavaScriptAlert::send): Deleted.
(Messages::TestWithoutAttributes::GetPlugins::send): Deleted.
(Messages::TestWithoutAttributes::GetPluginProcessConnection::send): Deleted.
(Messages::TestWithoutAttributes::TestMultipleAttributes::send): Deleted.
(Messages::TestWithoutAttributes::InterpretKeyEvent::send): Deleted.
* Scripts/webkit/tests/TestWithoutAttributesMessages.h:
* UIProcess/ProvisionalPageProxy.cpp:
Add a missing include that brings in the definition of the
WebBackForwardListCounts type along with its encode() method.

Source/WTF:

Add two helper types, OutType and InTypes, on both CompletionHandler
classes. OutType is an alias against the return type of the invokable
handler, InTypes is a tuple with types corresponding to the parameter
types of the invokable handler.

These are especially helpful in various templates dealing with the
CompletionHandler types.

* wtf/CompletionHandler.h:
(WTF::CompletionHandler):
(WTF::CompletionHandlerWithFinalizer):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (292862 => 292863)


--- trunk/Source/WTF/ChangeLog	2022-04-14 13:23:44 UTC (rev 292862)
+++ trunk/Source/WTF/ChangeLog	2022-04-14 14:12:02 UTC (rev 292863)
@@ -1,3 +1,23 @@
+2022-04-14  Zan Dobersek  <[email protected]>
+
+        [WK2] Enable more efficient encoding of synchronous-message reply arguments
+        https://bugs.webkit.org/show_bug.cgi?id=238740
+        <rdar://problem/91567779>
+
+        Reviewed by Kimmo Kinnunen.
+
+        Add two helper types, OutType and InTypes, on both CompletionHandler
+        classes. OutType is an alias against the return type of the invokable
+        handler, InTypes is a tuple with types corresponding to the parameter
+        types of the invokable handler.
+
+        These are especially helpful in various templates dealing with the
+        CompletionHandler types.
+
+        * wtf/CompletionHandler.h:
+        (WTF::CompletionHandler):
+        (WTF::CompletionHandlerWithFinalizer):
+
 2022-04-13  Chris Dumez  <[email protected]>
 
         Replace calls to substring(0, x) with the more concise left(x)

Modified: trunk/Source/WTF/wtf/CompletionHandler.h (292862 => 292863)


--- trunk/Source/WTF/wtf/CompletionHandler.h	2022-04-14 13:23:44 UTC (rev 292862)
+++ trunk/Source/WTF/wtf/CompletionHandler.h	2022-04-14 14:12:02 UTC (rev 292863)
@@ -25,6 +25,7 @@
 
 #pragma once
 
+#include <tuple>
 #include <utility>
 #include <wtf/Function.h>
 #include <wtf/MainThread.h>
@@ -39,6 +40,9 @@
 class CompletionHandler<Out(In...)> {
     WTF_MAKE_FAST_ALLOCATED;
 public:
+    using OutType = Out;
+    using InTypes = std::tuple<In...>;
+
     CompletionHandler() = default;
 
     template<typename CallableType, class = typename std::enable_if<std::is_rvalue_reference<CallableType&&>::value>::type>
@@ -83,6 +87,9 @@
 class CompletionHandlerWithFinalizer<Out(In...)> {
     WTF_MAKE_FAST_ALLOCATED;
 public:
+    using OutType = Out;
+    using InTypes = std::tuple<In...>;
+
     template<typename CallableType, class = typename std::enable_if<std::is_rvalue_reference<CallableType&&>::value>::type>
     CompletionHandlerWithFinalizer(CallableType&& callable, Function<void(Function<Out(In...)>&)>&& finalizer)
         : m_function(std::forward<CallableType>(callable))

Modified: trunk/Source/WebKit/ChangeLog (292862 => 292863)


--- trunk/Source/WebKit/ChangeLog	2022-04-14 13:23:44 UTC (rev 292862)
+++ trunk/Source/WebKit/ChangeLog	2022-04-14 14:12:02 UTC (rev 292863)
@@ -1,3 +1,123 @@
+2022-04-14  Zan Dobersek  <[email protected]>
+
+        [WK2] Enable more efficient encoding of synchronous-message reply arguments
+        https://bugs.webkit.org/show_bug.cgi?id=238740
+        <rdar://problem/91567779>
+
+        Reviewed by Kimmo Kinnunen.
+
+        Handling of synchronous messages requires construction of a
+        CompletionHandler object that wraps a lambda function which handles
+        logging of the passed-in reply arguments as well as subsequent encoding
+        and dispatching of the reply into the IPC channel.
+
+        Right now, for any given message the CompletionHandler type is generated
+        from the IPC message specification, and it's essentially a function type
+        with a void return value and const lvalue references for every
+        non-builtin parameter type. This type is imposed onto the lambda handler
+        and when invoked, all the reply arguments are passed on to the IPC
+        encoding as lvalue references.
+
+        This inhibits opportunities where the reply argument could instead be
+        moved into the completion handler invocation, enabling a more efficient
+        encoding of the passed-in value. For instance, if a Unix file descriptor
+        was moved into the completion handler invocation, it could be trickled
+        down into an IPC::Attachment object and dispatched over IPC without any
+        problems. Instead, because the lvalue reference is imposed as the type,
+        it will have to be duplicated even if the object itself is expiring or
+        would be movable down the invocation.
+
+        To cover these cases, the actual completion handler type is now deduced
+        from the synchronous-message-handling method itself. This means that
+        the completion handler parameter for the given handler method can now
+        specify whether it wants to receive reply arguments by value or by
+        either lvalue or rvalue reference. The completion handler lambda can
+        combine these parameter types with std::forward() to pass down the
+        actual arguments in the most optimal fashion.
+
+        To avoid problems, each CompletionHandler specialization retrieved from
+        the method siganture is validated against the CompletionHandler type
+        generated from the IPC specification, requiring that the decayed
+        parameter types match between the two. It's still possible to directly
+        use the CompletionHandler type from the IPC specification as the
+        completion handler type in the message-handling method.
+
+        An rvalue reference variant of ArgumentCoder<T>::encode() is added.
+        Generic implementation again casts the passed-in reference into an
+        rvalue and calls the encode() on that object. If that type provides
+        ref-qualified encode() methods, implementations of those methods can
+        adjust and more aggressively move things into the encoder when the
+        method is called on an rvalue. It would also be possible to delete the
+        ref-qualified method covering lvalues, meaning encoding would be allowed
+        only for objects that are moved into the completion handler.
+
+        For types with custom specializations of ArgumentCoder<T>, those
+        specializations would again have to provide rvalue variants of the
+        encode() method and handle the passed-in values appropriately.
+
+        The send() methods that were previously generated for every IPC message
+        are removed in favor of encoding and calling Connection::sendSyncReply()
+        in the completion-handler lambda. Missing std::forward() calls are added
+        in parameter pack expansions as required.
+
+        * GPUProcess/media/RemoteCDMProxy.cpp:
+        (WebKit::RemoteCDMProxy::getSupportedConfiguration):
+        * GPUProcess/media/RemoteCDMProxy.h:
+        * GPUProcess/media/RemoteImageDecoderAVFProxy.cpp:
+        (WebKit::RemoteImageDecoderAVFProxy::createFrameImageAtIndex):
+        * GPUProcess/media/RemoteImageDecoderAVFProxy.h:
+        * Platform/IPC/ArgumentCoder.h:
+        (IPC::ArgumentCoder::encode):
+        * Platform/IPC/HandleMessage.h:
+        (IPC::C::):
+        (IPC::CompletionHandlerValidation::matchingParameters):
+        (IPC::CompletionHandlerValidation::matchingTypes):
+        (IPC::handleMessageSynchronous):
+        (IPC::handleMessageSynchronousWantsConnection):
+        (IPC::handleMessageAsync):
+        (IPC::handleMessageAsyncWantsConnection):
+        * Platform/IPC/StreamServerConnection.h:
+        (IPC::StreamServerConnection::sendSyncReply):
+        * Scripts/webkit/messages.py:
+        (message_to_struct_declaration):
+        (generate_message_handler):
+        * Scripts/webkit/tests/TestWithCVPixelBufferMessageReceiver.cpp:
+        (Messages::TestWithCVPixelBuffer::ReceiveCVPixelBuffer::send): Deleted.
+        * Scripts/webkit/tests/TestWithCVPixelBufferMessages.h:
+        * Scripts/webkit/tests/TestWithImageDataMessageReceiver.cpp:
+        (Messages::TestWithImageData::ReceiveImageData::send): Deleted.
+        * Scripts/webkit/tests/TestWithImageDataMessages.h:
+        * Scripts/webkit/tests/TestWithLegacyReceiverMessageReceiver.cpp:
+        (Messages::TestWithLegacyReceiver::CreatePlugin::send): Deleted.
+        (Messages::TestWithLegacyReceiver::RunJavaScriptAlert::send): Deleted.
+        (Messages::TestWithLegacyReceiver::GetPlugins::send): Deleted.
+        (Messages::TestWithLegacyReceiver::GetPluginProcessConnection::send): Deleted.
+        (Messages::TestWithLegacyReceiver::TestMultipleAttributes::send): Deleted.
+        (Messages::TestWithLegacyReceiver::InterpretKeyEvent::send): Deleted.
+        * Scripts/webkit/tests/TestWithLegacyReceiverMessages.h:
+        * Scripts/webkit/tests/TestWithSemaphoreMessageReceiver.cpp:
+        (Messages::TestWithSemaphore::ReceiveSemaphore::send): Deleted.
+        * Scripts/webkit/tests/TestWithSemaphoreMessages.h:
+        * Scripts/webkit/tests/TestWithSuperclassMessageReceiver.cpp:
+        (Messages::TestWithSuperclass::TestAsyncMessage::send): Deleted.
+        (Messages::TestWithSuperclass::TestAsyncMessageWithNoArguments::send): Deleted.
+        (Messages::TestWithSuperclass::TestAsyncMessageWithMultipleArguments::send): Deleted.
+        (Messages::TestWithSuperclass::TestAsyncMessageWithConnection::send): Deleted.
+        (Messages::TestWithSuperclass::TestSyncMessage::send): Deleted.
+        (Messages::TestWithSuperclass::TestSynchronousMessage::send): Deleted.
+        * Scripts/webkit/tests/TestWithSuperclassMessages.h:
+        * Scripts/webkit/tests/TestWithoutAttributesMessageReceiver.cpp:
+        (Messages::TestWithoutAttributes::CreatePlugin::send): Deleted.
+        (Messages::TestWithoutAttributes::RunJavaScriptAlert::send): Deleted.
+        (Messages::TestWithoutAttributes::GetPlugins::send): Deleted.
+        (Messages::TestWithoutAttributes::GetPluginProcessConnection::send): Deleted.
+        (Messages::TestWithoutAttributes::TestMultipleAttributes::send): Deleted.
+        (Messages::TestWithoutAttributes::InterpretKeyEvent::send): Deleted.
+        * Scripts/webkit/tests/TestWithoutAttributesMessages.h:
+        * UIProcess/ProvisionalPageProxy.cpp:
+        Add a missing include that brings in the definition of the
+        WebBackForwardListCounts type along with its encode() method.
+
 2022-04-14  Kimmo Kinnunen  <[email protected]>
 
         Some IPC related message forwarding functions use const lvalue references

Modified: trunk/Source/WebKit/GPUProcess/media/RemoteCDMProxy.cpp (292862 => 292863)


--- trunk/Source/WebKit/GPUProcess/media/RemoteCDMProxy.cpp	2022-04-14 13:23:44 UTC (rev 292862)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteCDMProxy.cpp	2022-04-14 14:12:02 UTC (rev 292863)
@@ -81,7 +81,7 @@
     return m_private->sanitizeSessionId(sessionId);
 }
 
-void RemoteCDMProxy::getSupportedConfiguration(WebCore::CDMKeySystemConfiguration&& configuration, WebCore::CDMPrivate::LocalStorageAccess access, WebCore::CDMPrivate::SupportedConfigurationCallback&& callback)
+void RemoteCDMProxy::getSupportedConfiguration(WebCore::CDMKeySystemConfiguration&& configuration, WebCore::CDMPrivate::LocalStorageAccess access, CompletionHandler<void(std::optional<WebCore::CDMKeySystemConfiguration>)>&& callback)
 {
     m_private->getSupportedConfiguration(WTFMove(configuration), access, WTFMove(callback));
 }

Modified: trunk/Source/WebKit/GPUProcess/media/RemoteCDMProxy.h (292862 => 292863)


--- trunk/Source/WebKit/GPUProcess/media/RemoteCDMProxy.h	2022-04-14 13:23:44 UTC (rev 292862)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteCDMProxy.h	2022-04-14 14:12:02 UTC (rev 292863)
@@ -76,7 +76,7 @@
     bool didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, UniqueRef<IPC::Encoder>&) final;
 
     // Messages
-    void getSupportedConfiguration(WebCore::CDMKeySystemConfiguration&&, WebCore::CDMPrivate::LocalStorageAccess, WebCore::CDMPrivate::SupportedConfigurationCallback&&);
+    void getSupportedConfiguration(WebCore::CDMKeySystemConfiguration&&, WebCore::CDMPrivate::LocalStorageAccess, CompletionHandler<void(std::optional<WebCore::CDMKeySystemConfiguration>)>&&);
     void createInstance(CompletionHandler<void(RemoteCDMInstanceIdentifier, RemoteCDMInstanceConfiguration&&)>&&);
     void loadAndInitialize();
     void setLogIdentifier(uint64_t);

Modified: trunk/Source/WebKit/GPUProcess/media/RemoteImageDecoderAVFProxy.cpp (292862 => 292863)


--- trunk/Source/WebKit/GPUProcess/media/RemoteImageDecoderAVFProxy.cpp	2022-04-14 13:23:44 UTC (rev 292862)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteImageDecoderAVFProxy.cpp	2022-04-14 14:12:02 UTC (rev 292863)
@@ -114,7 +114,7 @@
     completionHandler(frameCount, imageDecoder->size(), imageDecoder->hasTrack(), WTFMove(frameInfos));
 }
 
-void RemoteImageDecoderAVFProxy::createFrameImageAtIndex(ImageDecoderIdentifier identifier, size_t index, CompletionHandler<void(std::optional<WTF::MachSendRight>&&, WebCore::DestinationColorSpace)>&& completionHandler)
+void RemoteImageDecoderAVFProxy::createFrameImageAtIndex(ImageDecoderIdentifier identifier, size_t index, CompletionHandler<void(std::optional<WTF::MachSendRight>&&, std::optional<WebCore::DestinationColorSpace>&&)>&& completionHandler)
 {
     ASSERT(m_imageDecoders.contains(identifier));
     if (!m_imageDecoders.contains(identifier)) {

Modified: trunk/Source/WebKit/GPUProcess/media/RemoteImageDecoderAVFProxy.h (292862 => 292863)


--- trunk/Source/WebKit/GPUProcess/media/RemoteImageDecoderAVFProxy.h	2022-04-14 13:23:44 UTC (rev 292862)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteImageDecoderAVFProxy.h	2022-04-14 14:12:02 UTC (rev 292863)
@@ -60,7 +60,7 @@
     void deleteDecoder(WebCore::ImageDecoderIdentifier);
     void setExpectedContentSize(WebCore::ImageDecoderIdentifier, long long expectedContentSize);
     void setData(WebCore::ImageDecoderIdentifier, const IPC::SharedBufferCopy&, bool allDataReceived, CompletionHandler<void(size_t frameCount, const WebCore::IntSize& size, bool hasTrack, std::optional<Vector<WebCore::ImageDecoder::FrameInfo>>&&)>&&);
-    void createFrameImageAtIndex(WebCore::ImageDecoderIdentifier, size_t index, CompletionHandler<void(std::optional<WTF::MachSendRight>&&, WebCore::DestinationColorSpace)>&&);
+    void createFrameImageAtIndex(WebCore::ImageDecoderIdentifier, size_t index, CompletionHandler<void(std::optional<WTF::MachSendRight>&&, std::optional<WebCore::DestinationColorSpace>&&)>&&);
     void clearFrameBufferCache(WebCore::ImageDecoderIdentifier, size_t index);
 
     void encodedDataStatusChanged(WebCore::ImageDecoderIdentifier);

Modified: trunk/Source/WebKit/Platform/IPC/ArgumentCoder.h (292862 => 292863)


--- trunk/Source/WebKit/Platform/IPC/ArgumentCoder.h	2022-04-14 13:23:44 UTC (rev 292862)
+++ trunk/Source/WebKit/Platform/IPC/ArgumentCoder.h	2022-04-14 14:12:02 UTC (rev 292863)
@@ -50,6 +50,12 @@
         t.encode(encoder);
     }
 
+    template<typename Encoder>
+    static void encode(Encoder& encoder, T&& t)
+    {
+        WTFMove(t).encode(encoder);
+    }
+
     template<typename Decoder>
     static std::optional<T> decode(Decoder& decoder)
     {

Modified: trunk/Source/WebKit/Platform/IPC/HandleMessage.h (292862 => 292863)


--- trunk/Source/WebKit/Platform/IPC/HandleMessage.h	2022-04-14 13:23:44 UTC (rev 292862)
+++ trunk/Source/WebKit/Platform/IPC/HandleMessage.h	2022-04-14 14:12:02 UTC (rev 292863)
@@ -173,6 +173,63 @@
     callMemberFunctionImpl(object, function, connection, std::forward<ArgsTuple>(args), ArgsIndices());
 }
 
+template<typename T>
+struct CompletionHandlerTypeDeduction;
+
+// The following two partial specializations enable retrieval of the parameter type at the specified index position.
+// This allows retrieving the exact type of the parameter where the CompletionHandler is expected in a given
+// synchronous-reply method.
+
+template<typename R, typename C, typename... Args>
+struct CompletionHandlerTypeDeduction<R(C::*)(Args...)> {
+    template<size_t N, typename = std::enable_if_t<(N < sizeof...(Args))>>
+    using Type = std::remove_cvref_t<typename std::tuple_element_t<N, std::tuple<Args...>>>;
+};
+
+template<typename R, typename C, typename... Args>
+struct CompletionHandlerTypeDeduction<R(C::*)(Args...) const> {
+    template<size_t N, typename = std::enable_if_t<(N < sizeof...(Args))>>
+    using Type = std::remove_cvref_t<typename std::tuple_element_t<N, std::tuple<Args...>>>;
+};
+
+// CompletionHandlerValidation::matchingTypes<ReplyType>() expects both CHType and ReplyType
+// to be specializations of the CompletionHandler template. CHType is the type specified in
+// the IPC handling method on the C++ class. ReplyType is the type generated from the IPC
+// message specification (and can still be used in the C++ method). Validation passes if both
+// types are indeed specializations of the CompletionHandler template and all the decayed
+// parameter types match between the two CompletionHandler specializations.
+
+struct CompletionHandlerValidation {
+    template<typename CHType>
+    struct ValidCompletionHandlerType : std::false_type { };
+
+    template<size_t N, typename TupleType>
+    using ParameterType = std::remove_cvref_t<std::tuple_element_t<N, TupleType>>;
+
+    template<typename CHArgsTuple, typename ReplyArgsTuple, size_t... Indices>
+    static constexpr bool matchingParameters(std::index_sequence<Indices...>)
+    {
+        return (std::is_same_v<ParameterType<Indices, CHArgsTuple>, ParameterType<Indices, ReplyArgsTuple>> && ...);
+    }
+
+    template<typename CHType, typename ReplyType>
+    static constexpr bool matchingTypes()
+    {
+        using CHInTypes = typename CHType::InTypes;
+        using ReplyInTypes = typename ReplyType::InTypes;
+
+        return ValidCompletionHandlerType<CHType>::value && ValidCompletionHandlerType<ReplyType>::value
+            && (std::tuple_size_v<CHInTypes> == std::tuple_size_v<ReplyInTypes>)
+            && matchingParameters<CHInTypes, ReplyInTypes>(std::make_index_sequence<std::tuple_size_v<CHInTypes>>());
+    }
+};
+
+// This specialization is used in matchingTypes() and affirms that the passed-in CHType or
+// ReplyType is indeed a proper CompletionHandler type.
+
+template<typename... InTypes>
+struct CompletionHandlerValidation::ValidCompletionHandlerType<CompletionHandler<void(InTypes...)>> : std::true_type { };
+
 // Main dispatch functions
 
 template<typename T>
@@ -214,12 +271,17 @@
     if (UNLIKELY(!arguments))
         return false;
 
-    typename T::DelayedReply completionHandler = [replyEncoder = WTFMove(replyEncoder), connection = Ref { connection }] (auto&&... args) mutable {
-        logReply(connection, T::name(), args...);
-        T::send(WTFMove(replyEncoder), WTFMove(connection), args...);
-    };
+    using CompletionHandlerFromMF = typename CompletionHandlerTypeDeduction<MF>::template Type<std::tuple_size_v<typename T::Arguments>>;
+    static_assert(CompletionHandlerValidation::template matchingTypes<CompletionHandlerFromMF, typename T::DelayedReply>());
+
     logMessage(connection, T::name(), *arguments);
-    callMemberFunction(WTFMove(*arguments), WTFMove(completionHandler), object, function);
+    callMemberFunction(WTFMove(*arguments),
+        CompletionHandlerFromMF([replyEncoder = WTFMove(replyEncoder), connection = Ref { connection }] (auto&&... args) mutable {
+            logReply(connection, T::name(), args...);
+            (replyEncoder.get() << ... << std::forward<decltype(args)>(args));
+            connection->sendSyncReply(WTFMove(replyEncoder));
+        }),
+        object, function);
     return true;
 }
 
@@ -230,12 +292,17 @@
     if (UNLIKELY(!arguments))
         return false;
     
-    typename T::DelayedReply completionHandler = [replyEncoder = WTFMove(replyEncoder), connection = Ref { connection }] (auto&&... args) mutable {
-        logReply(connection, T::name(), args...);
-        T::send(WTFMove(replyEncoder), WTFMove(connection), args...);
-    };
+    using CompletionHandlerFromMF = typename CompletionHandlerTypeDeduction<MF>::template Type<1 + std::tuple_size_v<typename T::Arguments>>;
+    static_assert(CompletionHandlerValidation::template matchingTypes<CompletionHandlerFromMF, typename T::DelayedReply>());
+
     logMessage(connection, T::name(), *arguments);
-    callMemberFunction(connection, WTFMove(*arguments), WTFMove(completionHandler), object, function);
+    callMemberFunction(connection, WTFMove(*arguments),
+        CompletionHandlerFromMF([replyEncoder = WTFMove(replyEncoder), connection = Ref { connection }] (auto&&... args) mutable {
+            logReply(connection, T::name(), args...);
+            (replyEncoder.get() << ... << std::forward<decltype(args)>(args));
+            connection->sendSyncReply(WTFMove(replyEncoder));
+        }),
+        object, function);
     return true;
 }
 
@@ -250,12 +317,16 @@
     if (UNLIKELY(!arguments))
         return;
 
-    typename T::DelayedReply completionHandler = [syncRequestID, connection = Ref { connection }] (auto&&... args) mutable {
-        logReply(connection->connection(), T::name(), args...);
-        connection->sendSyncReply<T>(syncRequestID, args...);
-    };
+    using CompletionHandlerFromMF = typename CompletionHandlerTypeDeduction<MF>::template Type<std::tuple_size_v<typename T::Arguments>>;
+    static_assert(CompletionHandlerValidation::template matchingTypes<CompletionHandlerFromMF, typename T::DelayedReply>());
+
     logMessage(connection.connection(), T::name(), *arguments);
-    callMemberFunction(WTFMove(*arguments), WTFMove(completionHandler), object, function);
+    callMemberFunction(WTFMove(*arguments),
+        CompletionHandlerFromMF([syncRequestID, connection = Ref { connection }] (auto&&... args) mutable {
+            logReply(connection->connection(), T::name(), args...);
+            connection->sendSyncReply<T>(syncRequestID, std::forward<decltype(args)>(args)...);
+        }),
+        object, function);
 }
 
 template<typename T, typename C, typename MF>
@@ -269,13 +340,18 @@
     if (UNLIKELY(!arguments))
         return;
 
-    typename T::AsyncReply completionHandler = { [listenerID = *listenerID, connection = Ref { connection }] (auto&&... args) mutable {
-        auto encoder = makeUniqueRef<Encoder>(T::asyncMessageReplyName(), listenerID);
-        logReply(connection, T::name(), args...);
-        T::send(WTFMove(encoder), WTFMove(connection), args...);
-    }, T::callbackThread };
+    using CompletionHandlerFromMF = typename CompletionHandlerTypeDeduction<MF>::template Type<std::tuple_size_v<typename T::Arguments>>;
+    static_assert(CompletionHandlerValidation::template matchingTypes<CompletionHandlerFromMF, typename T::AsyncReply>());
+
     logMessage(connection, T::name(), *arguments);
-    callMemberFunction(WTFMove(*arguments), WTFMove(completionHandler), object, function);
+    callMemberFunction(WTFMove(*arguments),
+        CompletionHandlerFromMF { [listenerID = *listenerID, connection = Ref { connection }] (auto&&... args) mutable {
+            auto encoder = makeUniqueRef<Encoder>(T::asyncMessageReplyName(), listenerID);
+            logReply(connection, T::name(), args...);
+            (encoder.get() << ... << std::forward<decltype(args)>(args));
+            connection->sendSyncReply(WTFMove(encoder));
+        }, T::callbackThread },
+        object, function);
 }
 
 template<typename T, typename C, typename MF>
@@ -289,13 +365,18 @@
     if (UNLIKELY(!arguments))
         return;
 
-    typename T::AsyncReply completionHandler = { [listenerID = *listenerID, connection = Ref { connection }] (auto&&... args) mutable {
-        auto encoder = makeUniqueRef<Encoder>(T::asyncMessageReplyName(), listenerID);
-        logReply(connection, T::name(), args...);
-        T::send(WTFMove(encoder), WTFMove(connection), args...);
-    }, T::callbackThread };
+    using CompletionHandlerFromMF = typename CompletionHandlerTypeDeduction<MF>::template Type<1 + std::tuple_size_v<typename T::Arguments>>;
+    static_assert(CompletionHandlerValidation::template matchingTypes<CompletionHandlerFromMF, typename T::AsyncReply>());
+
     logMessage(connection, T::name(), *arguments);
-    callMemberFunction(connection, WTFMove(*arguments), WTFMove(completionHandler), object, function);
+    callMemberFunction(connection, WTFMove(*arguments),
+        CompletionHandlerFromMF { [listenerID = *listenerID, connection = Ref { connection }] (auto&&... args) mutable {
+            auto encoder = makeUniqueRef<Encoder>(T::asyncMessageReplyName(), listenerID);
+            logReply(connection, T::name(), args...);
+            (encoder.get() << ... << std::forward<decltype(args)>(args));
+            connection->sendSyncReply(WTFMove(encoder));
+        }, T::callbackThread },
+        object, function);
 }
 
 } // namespace IPC

Modified: trunk/Source/WebKit/Platform/IPC/StreamServerConnection.h (292862 => 292863)


--- trunk/Source/WebKit/Platform/IPC/StreamServerConnection.h	2022-04-14 13:23:44 UTC (rev 292862)
+++ trunk/Source/WebKit/Platform/IPC/StreamServerConnection.h	2022-04-14 14:12:02 UTC (rev 292863)
@@ -154,7 +154,7 @@
     }
     auto encoder = makeUniqueRef<Encoder>(MessageName::SyncMessageReply, syncRequestID.toUInt64());
 
-    (encoder.get() << ... << arguments);
+    (encoder.get() << ... << std::forward<Arguments>(arguments));
     m_connection->sendSyncReply(WTFMove(encoder));
 }
 

Modified: trunk/Source/WebKit/Scripts/webkit/messages.py (292862 => 292863)


--- trunk/Source/WebKit/Scripts/webkit/messages.py	2022-04-14 13:23:44 UTC (rev 292862)
+++ trunk/Source/WebKit/Scripts/webkit/messages.py	2022-04-14 14:12:02 UTC (rev 292863)
@@ -210,11 +210,6 @@
             result.append('    static constexpr auto callbackThread = WTF::CompletionHandlerCallThread::MainThread;\n')
         else:
             result.append('    static constexpr auto callbackThread = WTF::CompletionHandlerCallThread::ConstructionThread;\n')
-        if not receiver.has_attribute(STREAM_ATTRIBUTE):
-            result.append('    static void send(UniqueRef<IPC::Encoder>&&, IPC::Connection&')
-            if len(send_parameters):
-                result.append(', %s' % completion_handler_parameters)
-            result.append(');\n')
         result.append('    using Reply = %s;\n' % reply_tuple(message))
         result.append('    using ReplyArguments = %s;\n' % reply_arguments_type(message))
 
@@ -1112,15 +1107,6 @@
                 result.append(', '.join(['IPC::AsyncReplyError<' + x.type + '>::create()' for x in message.reply_parameters]))
                 result.append(');\n}\n\n')
 
-            result.append('void %s::send(UniqueRef<IPC::Encoder>&& encoder, IPC::Connection& connection' % (message.name))
-            if len(send_parameters):
-                result.append(', %s' % ', '.join([' '.join(x) for x in send_parameters]))
-            result.append(')\n{\n')
-            result += ['    encoder.get() << %s;\n' % x.name for x in message.reply_parameters]
-            result.append('    connection.sendSyncReply(WTFMove(encoder));\n')
-            result.append('}\n')
-            result.append('\n')
-
             if message.condition:
                 result.append('#endif\n\n')
 

Modified: trunk/Source/WebKit/Scripts/webkit/tests/TestWithCVPixelBufferMessageReceiver.cpp (292862 => 292863)


--- trunk/Source/WebKit/Scripts/webkit/tests/TestWithCVPixelBufferMessageReceiver.cpp	2022-04-14 13:23:44 UTC (rev 292862)
+++ trunk/Source/WebKit/Scripts/webkit/tests/TestWithCVPixelBufferMessageReceiver.cpp	2022-04-14 14:12:02 UTC (rev 292863)
@@ -65,12 +65,6 @@
     completionHandler(IPC::AsyncReplyError<RetainPtr<CVPixelBufferRef>>::create());
 }
 
-void ReceiveCVPixelBuffer::send(UniqueRef<IPC::Encoder>&& encoder, IPC::Connection& connection, const RetainPtr<CVPixelBufferRef>& r0)
-{
-    encoder.get() << r0;
-    connection.sendSyncReply(WTFMove(encoder));
-}
-
 #endif
 
 } // namespace TestWithCVPixelBuffer

Modified: trunk/Source/WebKit/Scripts/webkit/tests/TestWithCVPixelBufferMessages.h (292862 => 292863)


--- trunk/Source/WebKit/Scripts/webkit/tests/TestWithCVPixelBufferMessages.h	2022-04-14 13:23:44 UTC (rev 292862)
+++ trunk/Source/WebKit/Scripts/webkit/tests/TestWithCVPixelBufferMessages.h	2022-04-14 14:12:02 UTC (rev 292863)
@@ -80,7 +80,6 @@
     static IPC::MessageName asyncMessageReplyName() { return IPC::MessageName::TestWithCVPixelBuffer_ReceiveCVPixelBufferReply; }
     using AsyncReply = ReceiveCVPixelBufferAsyncReply;
     static constexpr auto callbackThread = WTF::CompletionHandlerCallThread::ConstructionThread;
-    static void send(UniqueRef<IPC::Encoder>&&, IPC::Connection&, const RetainPtr<CVPixelBufferRef>& r0);
     using Reply = std::tuple<RetainPtr<CVPixelBufferRef>&>;
     using ReplyArguments = std::tuple<RetainPtr<CVPixelBufferRef>>;
     const Arguments& arguments() const

Modified: trunk/Source/WebKit/Scripts/webkit/tests/TestWithImageDataMessageReceiver.cpp (292862 => 292863)


--- trunk/Source/WebKit/Scripts/webkit/tests/TestWithImageDataMessageReceiver.cpp	2022-04-14 13:23:44 UTC (rev 292862)
+++ trunk/Source/WebKit/Scripts/webkit/tests/TestWithImageDataMessageReceiver.cpp	2022-04-14 14:12:02 UTC (rev 292863)
@@ -58,12 +58,6 @@
     completionHandler(IPC::AsyncReplyError<RefPtr<WebCore::ImageData>>::create());
 }
 
-void ReceiveImageData::send(UniqueRef<IPC::Encoder>&& encoder, IPC::Connection& connection, const RefPtr<WebCore::ImageData>& r0)
-{
-    encoder.get() << r0;
-    connection.sendSyncReply(WTFMove(encoder));
-}
-
 } // namespace TestWithImageData
 
 } // namespace Messages

Modified: trunk/Source/WebKit/Scripts/webkit/tests/TestWithImageDataMessages.h (292862 => 292863)


--- trunk/Source/WebKit/Scripts/webkit/tests/TestWithImageDataMessages.h	2022-04-14 13:23:44 UTC (rev 292862)
+++ trunk/Source/WebKit/Scripts/webkit/tests/TestWithImageDataMessages.h	2022-04-14 14:12:02 UTC (rev 292863)
@@ -75,7 +75,6 @@
     static IPC::MessageName asyncMessageReplyName() { return IPC::MessageName::TestWithImageData_ReceiveImageDataReply; }
     using AsyncReply = ReceiveImageDataAsyncReply;
     static constexpr auto callbackThread = WTF::CompletionHandlerCallThread::ConstructionThread;
-    static void send(UniqueRef<IPC::Encoder>&&, IPC::Connection&, const RefPtr<WebCore::ImageData>& r0);
     using Reply = std::tuple<RefPtr<WebCore::ImageData>&>;
     using ReplyArguments = std::tuple<RefPtr<WebCore::ImageData>>;
     const Arguments& arguments() const

Modified: trunk/Source/WebKit/Scripts/webkit/tests/TestWithLegacyReceiverMessageReceiver.cpp (292862 => 292863)


--- trunk/Source/WebKit/Scripts/webkit/tests/TestWithLegacyReceiverMessageReceiver.cpp	2022-04-14 13:23:44 UTC (rev 292862)
+++ trunk/Source/WebKit/Scripts/webkit/tests/TestWithLegacyReceiverMessageReceiver.cpp	2022-04-14 14:12:02 UTC (rev 292863)
@@ -84,12 +84,6 @@
     completionHandler(IPC::AsyncReplyError<bool>::create());
 }
 
-void CreatePlugin::send(UniqueRef<IPC::Encoder>&& encoder, IPC::Connection& connection, bool result)
-{
-    encoder.get() << result;
-    connection.sendSyncReply(WTFMove(encoder));
-}
-
 void RunJavaScriptAlert::callReply(IPC::Decoder& decoder, CompletionHandler<void()>&& completionHandler)
 {
     completionHandler();
@@ -100,11 +94,6 @@
     completionHandler();
 }
 
-void RunJavaScriptAlert::send(UniqueRef<IPC::Encoder>&& encoder, IPC::Connection& connection)
-{
-    connection.sendSyncReply(WTFMove(encoder));
-}
-
 void GetPlugins::callReply(IPC::Decoder& decoder, CompletionHandler<void(Vector<WebCore::PluginInfo>&&)>&& completionHandler)
 {
     std::optional<Vector<WebCore::PluginInfo>> plugins;
@@ -122,23 +111,6 @@
     completionHandler(IPC::AsyncReplyError<Vector<WebCore::PluginInfo>>::create());
 }
 
-void GetPlugins::send(UniqueRef<IPC::Encoder>&& encoder, IPC::Connection& connection, const Vector<WebCore::PluginInfo>& plugins)
-{
-    encoder.get() << plugins;
-    connection.sendSyncReply(WTFMove(encoder));
-}
-
-void GetPluginProcessConnection::send(UniqueRef<IPC::Encoder>&& encoder, IPC::Connection& connection, const IPC::Connection::Handle& connectionHandle)
-{
-    encoder.get() << connectionHandle;
-    connection.sendSyncReply(WTFMove(encoder));
-}
-
-void TestMultipleAttributes::send(UniqueRef<IPC::Encoder>&& encoder, IPC::Connection& connection)
-{
-    connection.sendSyncReply(WTFMove(encoder));
-}
-
 #if PLATFORM(MAC)
 
 void InterpretKeyEvent::callReply(IPC::Decoder& decoder, CompletionHandler<void(Vector<WebCore::KeypressCommand>&&)>&& completionHandler)
@@ -158,12 +130,6 @@
     completionHandler(IPC::AsyncReplyError<Vector<WebCore::KeypressCommand>>::create());
 }
 
-void InterpretKeyEvent::send(UniqueRef<IPC::Encoder>&& encoder, IPC::Connection& connection, const Vector<WebCore::KeypressCommand>& commandName)
-{
-    encoder.get() << commandName;
-    connection.sendSyncReply(WTFMove(encoder));
-}
-
 #endif
 
 } // namespace TestWithLegacyReceiver

Modified: trunk/Source/WebKit/Scripts/webkit/tests/TestWithLegacyReceiverMessages.h (292862 => 292863)


--- trunk/Source/WebKit/Scripts/webkit/tests/TestWithLegacyReceiverMessages.h	2022-04-14 13:23:44 UTC (rev 292862)
+++ trunk/Source/WebKit/Scripts/webkit/tests/TestWithLegacyReceiverMessages.h	2022-04-14 14:12:02 UTC (rev 292863)
@@ -288,7 +288,6 @@
     static IPC::MessageName asyncMessageReplyName() { return IPC::MessageName::TestWithLegacyReceiver_CreatePluginReply; }
     using AsyncReply = CreatePluginAsyncReply;
     static constexpr auto callbackThread = WTF::CompletionHandlerCallThread::ConstructionThread;
-    static void send(UniqueRef<IPC::Encoder>&&, IPC::Connection&, bool result);
     using Reply = std::tuple<bool&>;
     using ReplyArguments = std::tuple<bool>;
     CreatePlugin(uint64_t pluginInstanceID, const WebKit::Plugin::Parameters& parameters)
@@ -317,7 +316,6 @@
     static IPC::MessageName asyncMessageReplyName() { return IPC::MessageName::TestWithLegacyReceiver_RunJavaScriptAlertReply; }
     using AsyncReply = RunJavaScriptAlertAsyncReply;
     static constexpr auto callbackThread = WTF::CompletionHandlerCallThread::ConstructionThread;
-    static void send(UniqueRef<IPC::Encoder>&&, IPC::Connection&);
     using Reply = std::tuple<>;
     using ReplyArguments = std::tuple<>;
     RunJavaScriptAlert(uint64_t frameID, const String& message)
@@ -346,7 +344,6 @@
     static IPC::MessageName asyncMessageReplyName() { return IPC::MessageName::TestWithLegacyReceiver_GetPluginsReply; }
     using AsyncReply = GetPluginsAsyncReply;
     static constexpr auto callbackThread = WTF::CompletionHandlerCallThread::ConstructionThread;
-    static void send(UniqueRef<IPC::Encoder>&&, IPC::Connection&, const Vector<WebCore::PluginInfo>& plugins);
     using Reply = std::tuple<Vector<WebCore::PluginInfo>&>;
     using ReplyArguments = std::tuple<Vector<WebCore::PluginInfo>>;
     explicit GetPlugins(bool refresh)
@@ -372,7 +369,6 @@
 
     using DelayedReply = GetPluginProcessConnectionDelayedReply;
     static constexpr auto callbackThread = WTF::CompletionHandlerCallThread::ConstructionThread;
-    static void send(UniqueRef<IPC::Encoder>&&, IPC::Connection&, const IPC::Connection::Handle& connectionHandle);
     using Reply = std::tuple<IPC::Connection::Handle&>;
     using ReplyArguments = std::tuple<IPC::Connection::Handle>;
     explicit GetPluginProcessConnection(const String& pluginPath)
@@ -398,7 +394,6 @@
 
     using DelayedReply = TestMultipleAttributesDelayedReply;
     static constexpr auto callbackThread = WTF::CompletionHandlerCallThread::ConstructionThread;
-    static void send(UniqueRef<IPC::Encoder>&&, IPC::Connection&);
     using Reply = std::tuple<>;
     using ReplyArguments = std::tuple<>;
     const Arguments& arguments() const
@@ -509,7 +504,6 @@
     static IPC::MessageName asyncMessageReplyName() { return IPC::MessageName::TestWithLegacyReceiver_InterpretKeyEventReply; }
     using AsyncReply = InterpretKeyEventAsyncReply;
     static constexpr auto callbackThread = WTF::CompletionHandlerCallThread::ConstructionThread;
-    static void send(UniqueRef<IPC::Encoder>&&, IPC::Connection&, const Vector<WebCore::KeypressCommand>& commandName);
     using Reply = std::tuple<Vector<WebCore::KeypressCommand>&>;
     using ReplyArguments = std::tuple<Vector<WebCore::KeypressCommand>>;
     explicit InterpretKeyEvent(uint32_t type)

Modified: trunk/Source/WebKit/Scripts/webkit/tests/TestWithSemaphoreMessageReceiver.cpp (292862 => 292863)


--- trunk/Source/WebKit/Scripts/webkit/tests/TestWithSemaphoreMessageReceiver.cpp	2022-04-14 13:23:44 UTC (rev 292862)
+++ trunk/Source/WebKit/Scripts/webkit/tests/TestWithSemaphoreMessageReceiver.cpp	2022-04-14 14:12:02 UTC (rev 292863)
@@ -55,12 +55,6 @@
     completionHandler(IPC::AsyncReplyError<IPC::Semaphore>::create());
 }
 
-void ReceiveSemaphore::send(UniqueRef<IPC::Encoder>&& encoder, IPC::Connection& connection, const IPC::Semaphore& r0)
-{
-    encoder.get() << r0;
-    connection.sendSyncReply(WTFMove(encoder));
-}
-
 } // namespace TestWithSemaphore
 
 } // namespace Messages

Modified: trunk/Source/WebKit/Scripts/webkit/tests/TestWithSemaphoreMessages.h (292862 => 292863)


--- trunk/Source/WebKit/Scripts/webkit/tests/TestWithSemaphoreMessages.h	2022-04-14 13:23:44 UTC (rev 292862)
+++ trunk/Source/WebKit/Scripts/webkit/tests/TestWithSemaphoreMessages.h	2022-04-14 14:12:02 UTC (rev 292863)
@@ -74,7 +74,6 @@
     static IPC::MessageName asyncMessageReplyName() { return IPC::MessageName::TestWithSemaphore_ReceiveSemaphoreReply; }
     using AsyncReply = ReceiveSemaphoreAsyncReply;
     static constexpr auto callbackThread = WTF::CompletionHandlerCallThread::ConstructionThread;
-    static void send(UniqueRef<IPC::Encoder>&&, IPC::Connection&, const IPC::Semaphore& r0);
     using Reply = std::tuple<IPC::Semaphore&>;
     using ReplyArguments = std::tuple<IPC::Semaphore>;
     const Arguments& arguments() const

Modified: trunk/Source/WebKit/Scripts/webkit/tests/TestWithSuperclassMessageReceiver.cpp (292862 => 292863)


--- trunk/Source/WebKit/Scripts/webkit/tests/TestWithSuperclassMessageReceiver.cpp	2022-04-14 13:23:44 UTC (rev 292862)
+++ trunk/Source/WebKit/Scripts/webkit/tests/TestWithSuperclassMessageReceiver.cpp	2022-04-14 14:12:02 UTC (rev 292863)
@@ -63,12 +63,6 @@
     completionHandler(IPC::AsyncReplyError<uint64_t>::create());
 }
 
-void TestAsyncMessage::send(UniqueRef<IPC::Encoder>&& encoder, IPC::Connection& connection, uint64_t result)
-{
-    encoder.get() << result;
-    connection.sendSyncReply(WTFMove(encoder));
-}
-
 #endif
 
 #if ENABLE(TEST_FEATURE)
@@ -83,11 +77,6 @@
     completionHandler();
 }
 
-void TestAsyncMessageWithNoArguments::send(UniqueRef<IPC::Encoder>&& encoder, IPC::Connection& connection)
-{
-    connection.sendSyncReply(WTFMove(encoder));
-}
-
 #endif
 
 #if ENABLE(TEST_FEATURE)
@@ -116,13 +105,6 @@
     completionHandler(IPC::AsyncReplyError<bool>::create(), IPC::AsyncReplyError<uint64_t>::create());
 }
 
-void TestAsyncMessageWithMultipleArguments::send(UniqueRef<IPC::Encoder>&& encoder, IPC::Connection& connection, bool flag, uint64_t value)
-{
-    encoder.get() << flag;
-    encoder.get() << value;
-    connection.sendSyncReply(WTFMove(encoder));
-}
-
 #endif
 
 #if ENABLE(TEST_FEATURE)
@@ -144,26 +126,8 @@
     completionHandler(IPC::AsyncReplyError<bool>::create());
 }
 
-void TestAsyncMessageWithConnection::send(UniqueRef<IPC::Encoder>&& encoder, IPC::Connection& connection, bool flag)
-{
-    encoder.get() << flag;
-    connection.sendSyncReply(WTFMove(encoder));
-}
-
 #endif
 
-void TestSyncMessage::send(UniqueRef<IPC::Encoder>&& encoder, IPC::Connection& connection, uint8_t reply)
-{
-    encoder.get() << reply;
-    connection.sendSyncReply(WTFMove(encoder));
-}
-
-void TestSynchronousMessage::send(UniqueRef<IPC::Encoder>&& encoder, IPC::Connection& connection, const std::optional<WebKit::TestClassName>& optionalReply)
-{
-    encoder.get() << optionalReply;
-    connection.sendSyncReply(WTFMove(encoder));
-}
-
 } // namespace TestWithSuperclass
 
 } // namespace Messages

Modified: trunk/Source/WebKit/Scripts/webkit/tests/TestWithSuperclassMessages.h (292862 => 292863)


--- trunk/Source/WebKit/Scripts/webkit/tests/TestWithSuperclassMessages.h	2022-04-14 13:23:44 UTC (rev 292862)
+++ trunk/Source/WebKit/Scripts/webkit/tests/TestWithSuperclassMessages.h	2022-04-14 14:12:02 UTC (rev 292863)
@@ -80,7 +80,6 @@
     static IPC::MessageName asyncMessageReplyName() { return IPC::MessageName::TestWithSuperclass_TestAsyncMessageReply; }
     using AsyncReply = TestAsyncMessageAsyncReply;
     static constexpr auto callbackThread = WTF::CompletionHandlerCallThread::MainThread;
-    static void send(UniqueRef<IPC::Encoder>&&, IPC::Connection&, uint64_t result);
     using Reply = std::tuple<uint64_t&>;
     using ReplyArguments = std::tuple<uint64_t>;
     explicit TestAsyncMessage(WebKit::TestTwoStateEnum twoStateEnum)
@@ -111,7 +110,6 @@
     static IPC::MessageName asyncMessageReplyName() { return IPC::MessageName::TestWithSuperclass_TestAsyncMessageWithNoArgumentsReply; }
     using AsyncReply = TestAsyncMessageWithNoArgumentsAsyncReply;
     static constexpr auto callbackThread = WTF::CompletionHandlerCallThread::ConstructionThread;
-    static void send(UniqueRef<IPC::Encoder>&&, IPC::Connection&);
     using Reply = std::tuple<>;
     using ReplyArguments = std::tuple<>;
     const Arguments& arguments() const
@@ -137,7 +135,6 @@
     static IPC::MessageName asyncMessageReplyName() { return IPC::MessageName::TestWithSuperclass_TestAsyncMessageWithMultipleArgumentsReply; }
     using AsyncReply = TestAsyncMessageWithMultipleArgumentsAsyncReply;
     static constexpr auto callbackThread = WTF::CompletionHandlerCallThread::ConstructionThread;
-    static void send(UniqueRef<IPC::Encoder>&&, IPC::Connection&, bool flag, uint64_t value);
     using Reply = std::tuple<bool&, uint64_t&>;
     using ReplyArguments = std::tuple<bool, uint64_t>;
     const Arguments& arguments() const
@@ -163,7 +160,6 @@
     static IPC::MessageName asyncMessageReplyName() { return IPC::MessageName::TestWithSuperclass_TestAsyncMessageWithConnectionReply; }
     using AsyncReply = TestAsyncMessageWithConnectionAsyncReply;
     static constexpr auto callbackThread = WTF::CompletionHandlerCallThread::ConstructionThread;
-    static void send(UniqueRef<IPC::Encoder>&&, IPC::Connection&, bool flag);
     using Reply = std::tuple<bool&>;
     using ReplyArguments = std::tuple<bool>;
     explicit TestAsyncMessageWithConnection(const int& value)
@@ -190,7 +186,6 @@
 
     using DelayedReply = TestSyncMessageDelayedReply;
     static constexpr auto callbackThread = WTF::CompletionHandlerCallThread::ConstructionThread;
-    static void send(UniqueRef<IPC::Encoder>&&, IPC::Connection&, uint8_t reply);
     using Reply = std::tuple<uint8_t&>;
     using ReplyArguments = std::tuple<uint8_t>;
     explicit TestSyncMessage(uint32_t param)
@@ -216,7 +211,6 @@
 
     using DelayedReply = TestSynchronousMessageDelayedReply;
     static constexpr auto callbackThread = WTF::CompletionHandlerCallThread::ConstructionThread;
-    static void send(UniqueRef<IPC::Encoder>&&, IPC::Connection&, const std::optional<WebKit::TestClassName>& optionalReply);
     using Reply = std::tuple<std::optional<WebKit::TestClassName>&>;
     using ReplyArguments = std::tuple<std::optional<WebKit::TestClassName>>;
     explicit TestSynchronousMessage(bool value)

Modified: trunk/Source/WebKit/Scripts/webkit/tests/TestWithoutAttributesMessageReceiver.cpp (292862 => 292863)


--- trunk/Source/WebKit/Scripts/webkit/tests/TestWithoutAttributesMessageReceiver.cpp	2022-04-14 13:23:44 UTC (rev 292862)
+++ trunk/Source/WebKit/Scripts/webkit/tests/TestWithoutAttributesMessageReceiver.cpp	2022-04-14 14:12:02 UTC (rev 292863)
@@ -84,12 +84,6 @@
     completionHandler(IPC::AsyncReplyError<bool>::create());
 }
 
-void CreatePlugin::send(UniqueRef<IPC::Encoder>&& encoder, IPC::Connection& connection, bool result)
-{
-    encoder.get() << result;
-    connection.sendSyncReply(WTFMove(encoder));
-}
-
 void RunJavaScriptAlert::callReply(IPC::Decoder& decoder, CompletionHandler<void()>&& completionHandler)
 {
     completionHandler();
@@ -100,11 +94,6 @@
     completionHandler();
 }
 
-void RunJavaScriptAlert::send(UniqueRef<IPC::Encoder>&& encoder, IPC::Connection& connection)
-{
-    connection.sendSyncReply(WTFMove(encoder));
-}
-
 void GetPlugins::callReply(IPC::Decoder& decoder, CompletionHandler<void(Vector<WebCore::PluginInfo>&&)>&& completionHandler)
 {
     std::optional<Vector<WebCore::PluginInfo>> plugins;
@@ -122,23 +111,6 @@
     completionHandler(IPC::AsyncReplyError<Vector<WebCore::PluginInfo>>::create());
 }
 
-void GetPlugins::send(UniqueRef<IPC::Encoder>&& encoder, IPC::Connection& connection, const Vector<WebCore::PluginInfo>& plugins)
-{
-    encoder.get() << plugins;
-    connection.sendSyncReply(WTFMove(encoder));
-}
-
-void GetPluginProcessConnection::send(UniqueRef<IPC::Encoder>&& encoder, IPC::Connection& connection, const IPC::Connection::Handle& connectionHandle)
-{
-    encoder.get() << connectionHandle;
-    connection.sendSyncReply(WTFMove(encoder));
-}
-
-void TestMultipleAttributes::send(UniqueRef<IPC::Encoder>&& encoder, IPC::Connection& connection)
-{
-    connection.sendSyncReply(WTFMove(encoder));
-}
-
 #if PLATFORM(MAC)
 
 void InterpretKeyEvent::callReply(IPC::Decoder& decoder, CompletionHandler<void(Vector<WebCore::KeypressCommand>&&)>&& completionHandler)
@@ -158,12 +130,6 @@
     completionHandler(IPC::AsyncReplyError<Vector<WebCore::KeypressCommand>>::create());
 }
 
-void InterpretKeyEvent::send(UniqueRef<IPC::Encoder>&& encoder, IPC::Connection& connection, const Vector<WebCore::KeypressCommand>& commandName)
-{
-    encoder.get() << commandName;
-    connection.sendSyncReply(WTFMove(encoder));
-}
-
 #endif
 
 } // namespace TestWithoutAttributes

Modified: trunk/Source/WebKit/Scripts/webkit/tests/TestWithoutAttributesMessages.h (292862 => 292863)


--- trunk/Source/WebKit/Scripts/webkit/tests/TestWithoutAttributesMessages.h	2022-04-14 13:23:44 UTC (rev 292862)
+++ trunk/Source/WebKit/Scripts/webkit/tests/TestWithoutAttributesMessages.h	2022-04-14 14:12:02 UTC (rev 292863)
@@ -288,7 +288,6 @@
     static IPC::MessageName asyncMessageReplyName() { return IPC::MessageName::TestWithoutAttributes_CreatePluginReply; }
     using AsyncReply = CreatePluginAsyncReply;
     static constexpr auto callbackThread = WTF::CompletionHandlerCallThread::ConstructionThread;
-    static void send(UniqueRef<IPC::Encoder>&&, IPC::Connection&, bool result);
     using Reply = std::tuple<bool&>;
     using ReplyArguments = std::tuple<bool>;
     CreatePlugin(uint64_t pluginInstanceID, const WebKit::Plugin::Parameters& parameters)
@@ -317,7 +316,6 @@
     static IPC::MessageName asyncMessageReplyName() { return IPC::MessageName::TestWithoutAttributes_RunJavaScriptAlertReply; }
     using AsyncReply = RunJavaScriptAlertAsyncReply;
     static constexpr auto callbackThread = WTF::CompletionHandlerCallThread::ConstructionThread;
-    static void send(UniqueRef<IPC::Encoder>&&, IPC::Connection&);
     using Reply = std::tuple<>;
     using ReplyArguments = std::tuple<>;
     RunJavaScriptAlert(uint64_t frameID, const String& message)
@@ -346,7 +344,6 @@
     static IPC::MessageName asyncMessageReplyName() { return IPC::MessageName::TestWithoutAttributes_GetPluginsReply; }
     using AsyncReply = GetPluginsAsyncReply;
     static constexpr auto callbackThread = WTF::CompletionHandlerCallThread::ConstructionThread;
-    static void send(UniqueRef<IPC::Encoder>&&, IPC::Connection&, const Vector<WebCore::PluginInfo>& plugins);
     using Reply = std::tuple<Vector<WebCore::PluginInfo>&>;
     using ReplyArguments = std::tuple<Vector<WebCore::PluginInfo>>;
     explicit GetPlugins(bool refresh)
@@ -372,7 +369,6 @@
 
     using DelayedReply = GetPluginProcessConnectionDelayedReply;
     static constexpr auto callbackThread = WTF::CompletionHandlerCallThread::ConstructionThread;
-    static void send(UniqueRef<IPC::Encoder>&&, IPC::Connection&, const IPC::Connection::Handle& connectionHandle);
     using Reply = std::tuple<IPC::Connection::Handle&>;
     using ReplyArguments = std::tuple<IPC::Connection::Handle>;
     explicit GetPluginProcessConnection(const String& pluginPath)
@@ -398,7 +394,6 @@
 
     using DelayedReply = TestMultipleAttributesDelayedReply;
     static constexpr auto callbackThread = WTF::CompletionHandlerCallThread::ConstructionThread;
-    static void send(UniqueRef<IPC::Encoder>&&, IPC::Connection&);
     using Reply = std::tuple<>;
     using ReplyArguments = std::tuple<>;
     const Arguments& arguments() const
@@ -509,7 +504,6 @@
     static IPC::MessageName asyncMessageReplyName() { return IPC::MessageName::TestWithoutAttributes_InterpretKeyEventReply; }
     using AsyncReply = InterpretKeyEventAsyncReply;
     static constexpr auto callbackThread = WTF::CompletionHandlerCallThread::ConstructionThread;
-    static void send(UniqueRef<IPC::Encoder>&&, IPC::Connection&, const Vector<WebCore::KeypressCommand>& commandName);
     using Reply = std::tuple<Vector<WebCore::KeypressCommand>&>;
     using ReplyArguments = std::tuple<Vector<WebCore::KeypressCommand>>;
     explicit InterpretKeyEvent(uint32_t type)

Modified: trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp (292862 => 292863)


--- trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp	2022-04-14 13:23:44 UTC (rev 292862)
+++ trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp	2022-04-14 14:12:02 UTC (rev 292863)
@@ -36,6 +36,7 @@
 #include "URLSchemeTaskParameters.h"
 #include "WebBackForwardCacheEntry.h"
 #include "WebBackForwardList.h"
+#include "WebBackForwardListCounts.h"
 #include "WebBackForwardListItem.h"
 #include "WebErrors.h"
 #include "WebNavigationDataStore.h"
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to