Enable IPC sending and receiving non-default-constructible types
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Mar 2019 21:23:15 +0000 (21:23 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Mar 2019 21:23:15 +0000 (21:23 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196132

Reviewed by Geoff Garen.

Source/WebCore:

This basically just requires the decoding of std::tuple to return an Optional<std::tuple> instead of
constructing a std::tuple then decoding into it.  I now decode synchronous replies into an Optional<std::tuple>
then move it into the tuple of references where the successfully decoded reply should go.  This required
the synchronous reply types be move constructible and move assignable.

* Modules/indexeddb/shared/IDBRequestData.h:
* Modules/indexeddb/shared/IDBTransactionInfo.h:
* platform/DragImage.h:
* platform/PasteboardWriterData.h:
* platform/audio/mac/CAAudioStreamDescription.h:
* platform/graphics/RemoteVideoSample.h:

Source/WebKit:

* Platform/IPC/ArgumentCoder.h:
* Platform/IPC/ArgumentCoders.h:
(IPC::TupleEncoder::encode):
(IPC::tupleFromTupleAndObject):
(IPC::TupleDecoderImpl::decode):
(IPC::TupleDecoderImpl<Type>::decode):
(IPC::TupleDecoder::decode):
(IPC::TupleDecoder<0>::decode):
(IPC::TupleCoder::encode): Deleted.
(IPC::TupleCoder::decode): Deleted.
* Platform/IPC/Connection.h:
(IPC::Connection::sendWithReply):
(IPC::TupleMover::move):
(IPC::moveTuple):
(IPC::Connection::sendSync):
* Platform/IPC/Decoder.h:
(IPC::Decoder::decode):
(IPC::Decoder::operator>>):
* Platform/IPC/HandleMessage.h:
(IPC::handleMessage):
(IPC::handleMessageSynchronous):
(IPC::handleMessageSynchronousWantsConnection):
(IPC::handleMessageAsync):
* Platform/SharedMemory.h:
* Scripts/webkit/LegacyMessages-expected.h:
* Scripts/webkit/Messages-expected.h:
* Scripts/webkit/MessagesSuperclass-expected.h:
* Scripts/webkit/messages.py:
* Shared/Databases/IndexedDB/WebIDBResult.h:
* Shared/RemoteLayerTree/RemoteLayerTreeTransaction.h:
* Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm:
* Shared/ShareableBitmap.h:
* Shared/ShareableResource.h:
* Shared/UpdateInfo.h:
* Shared/WebEvent.h:
* Shared/WebProcessCreationParameters.cpp:
* Shared/WebProcessCreationParameters.h:
* Shared/mac/SecItemResponseData.cpp:
(WebKit::SecItemResponseData::SecItemResponseData):
(WebKit::SecItemResponseData::decode):
* Shared/mac/SecItemResponseData.h:
* WebProcess/MediaStream/MediaDeviceSandboxExtensions.h:

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

33 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/shared/IDBRequestData.h
Source/WebCore/Modules/indexeddb/shared/IDBTransactionInfo.h
Source/WebCore/platform/DragImage.h
Source/WebCore/platform/PasteboardWriterData.h
Source/WebCore/platform/audio/mac/CAAudioStreamDescription.h
Source/WebCore/platform/graphics/RemoteVideoSample.h
Source/WebKit/ChangeLog
Source/WebKit/Platform/IPC/ArgumentCoder.h
Source/WebKit/Platform/IPC/ArgumentCoders.h
Source/WebKit/Platform/IPC/Connection.h
Source/WebKit/Platform/IPC/Decoder.h
Source/WebKit/Platform/IPC/HandleMessage.h
Source/WebKit/Platform/SharedMemory.h
Source/WebKit/Platform/cocoa/SharedMemoryCocoa.cpp
Source/WebKit/Platform/unix/SharedMemoryUnix.cpp
Source/WebKit/Platform/win/SharedMemoryWin.cpp
Source/WebKit/Scripts/webkit/LegacyMessages-expected.h
Source/WebKit/Scripts/webkit/Messages-expected.h
Source/WebKit/Scripts/webkit/MessagesSuperclass-expected.h
Source/WebKit/Scripts/webkit/messages.py
Source/WebKit/Shared/Databases/IndexedDB/WebIDBResult.h
Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.h
Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm
Source/WebKit/Shared/ShareableBitmap.h
Source/WebKit/Shared/ShareableResource.h
Source/WebKit/Shared/UpdateInfo.h
Source/WebKit/Shared/WebEvent.h
Source/WebKit/Shared/WebProcessCreationParameters.cpp
Source/WebKit/Shared/WebProcessCreationParameters.h
Source/WebKit/Shared/mac/SecItemResponseData.cpp
Source/WebKit/Shared/mac/SecItemResponseData.h
Source/WebKit/WebProcess/MediaStream/MediaDeviceSandboxExtensions.h

index f512d79..fbe8963 100644 (file)
@@ -1,5 +1,24 @@
 2019-03-25  Alex Christensen  <achristensen@webkit.org>
 
+        Enable IPC sending and receiving non-default-constructible types
+        https://bugs.webkit.org/show_bug.cgi?id=196132
+
+        Reviewed by Geoff Garen.
+
+        This basically just requires the decoding of std::tuple to return an Optional<std::tuple> instead of
+        constructing a std::tuple then decoding into it.  I now decode synchronous replies into an Optional<std::tuple>
+        then move it into the tuple of references where the successfully decoded reply should go.  This required
+        the synchronous reply types be move constructible and move assignable.
+
+        * Modules/indexeddb/shared/IDBRequestData.h:
+        * Modules/indexeddb/shared/IDBTransactionInfo.h:
+        * platform/DragImage.h:
+        * platform/PasteboardWriterData.h:
+        * platform/audio/mac/CAAudioStreamDescription.h:
+        * platform/graphics/RemoteVideoSample.h:
+
+2019-03-25  Alex Christensen  <achristensen@webkit.org>
+
         Stop storing raw pointers to Documents
         https://bugs.webkit.org/show_bug.cgi?id=196042
 
index 93b1f43..b582167 100644 (file)
@@ -50,6 +50,8 @@ public:
     IDBRequestData(const IDBClient::IDBConnectionProxy&, const IDBOpenDBRequest&);
     explicit IDBRequestData(IDBClient::TransactionOperation&);
     IDBRequestData(const IDBRequestData&);
+    IDBRequestData(IDBRequestData&&) = default;
+    IDBRequestData& operator=(IDBRequestData&&) = default;
 
     enum IsolatedCopyTag { IsolatedCopy };
     IDBRequestData(const IDBRequestData&, IsolatedCopyTag);
index cc25d59..930d802 100644 (file)
@@ -50,6 +50,8 @@ public:
     static IDBTransactionInfo versionChange(const IDBServer::IDBConnectionToClient&, const IDBDatabaseInfo& originalDatabaseInfo, uint64_t newVersion);
 
     IDBTransactionInfo(const IDBTransactionInfo&);
+    IDBTransactionInfo(IDBTransactionInfo&&) = default;
+    IDBTransactionInfo& operator=(IDBTransactionInfo&&) = default;
 
     enum IsolatedCopyTag { IsolatedCopy };
     IDBTransactionInfo(const IDBTransactionInfo&, IsolatedCopyTag);
index c9cfe64..a102e34 100644 (file)
@@ -102,10 +102,10 @@ class DragImage final {
 public:
     WEBCORE_EXPORT DragImage();
     explicit DragImage(DragImageRef);
-    DragImage(DragImage&&);
+    WEBCORE_EXPORT DragImage(DragImage&&);
     WEBCORE_EXPORT ~DragImage();
 
-    DragImage& operator=(DragImage&&);
+    WEBCORE_EXPORT DragImage& operator=(DragImage&&);
 
     void setIndicatorData(const TextIndicatorData& data) { m_indicatorData = data; }
     bool hasIndicatorData() const { return !!m_indicatorData; }
index d45fe50..ed2eeef 100644 (file)
@@ -47,7 +47,7 @@ public:
 
     struct WebContent {
         WebContent();
-        ~WebContent();
+        WEBCORE_EXPORT ~WebContent();
 
 #if PLATFORM(COCOA)
         String contentOrigin;
index 33af4c3..e5e1097 100644 (file)
@@ -33,19 +33,19 @@ namespace WebCore {
 WEBCORE_EXPORT bool operator==(const AudioStreamBasicDescription&, const AudioStreamBasicDescription&);
 inline bool operator!=(const AudioStreamBasicDescription& a, const AudioStreamBasicDescription& b) { return !(a == b); }
 
-class CAAudioStreamDescription final : public AudioStreamDescription {
+class WEBCORE_EXPORT CAAudioStreamDescription final : public AudioStreamDescription {
     WTF_MAKE_FAST_ALLOCATED;
 
 public:
 
-    WEBCORE_EXPORT CAAudioStreamDescription();
-    WEBCORE_EXPORT CAAudioStreamDescription(const AudioStreamBasicDescription&);
-    WEBCORE_EXPORT CAAudioStreamDescription(double, uint32_t, PCMFormat, bool);
-    WEBCORE_EXPORT ~CAAudioStreamDescription();
+    CAAudioStreamDescription();
+    CAAudioStreamDescription(const AudioStreamBasicDescription&);
+    CAAudioStreamDescription(double, uint32_t, PCMFormat, bool);
+    ~CAAudioStreamDescription();
 
     const PlatformDescription& platformDescription() const final;
 
-    WEBCORE_EXPORT PCMFormat format() const final;
+    PCMFormat format() const final;
 
     double sampleRate() const final { return m_streamDescription.mSampleRate; }
     bool isPCM() const final { return m_streamDescription.mFormatID == kAudioFormatLinearPCM; }
index 8773069..f02d4fc 100644 (file)
@@ -41,6 +41,8 @@ namespace WebCore {
 class RemoteVideoSample {
 public:
     RemoteVideoSample() = default;
+    RemoteVideoSample(RemoteVideoSample&&) = default;
+    RemoteVideoSample& operator=(RemoteVideoSample&&) = default;
     ~RemoteVideoSample() = default;
 
 #if HAVE(IOSURFACE)
index 61ad34a..835af79 100644 (file)
@@ -1,3 +1,53 @@
+2019-03-25  Alex Christensen  <achristensen@webkit.org>
+
+        Enable IPC sending and receiving non-default-constructible types
+        https://bugs.webkit.org/show_bug.cgi?id=196132
+
+        Reviewed by Geoff Garen.
+
+        * Platform/IPC/ArgumentCoder.h:
+        * Platform/IPC/ArgumentCoders.h:
+        (IPC::TupleEncoder::encode):
+        (IPC::tupleFromTupleAndObject):
+        (IPC::TupleDecoderImpl::decode):
+        (IPC::TupleDecoderImpl<Type>::decode):
+        (IPC::TupleDecoder::decode):
+        (IPC::TupleDecoder<0>::decode):
+        (IPC::TupleCoder::encode): Deleted.
+        (IPC::TupleCoder::decode): Deleted.
+        * Platform/IPC/Connection.h:
+        (IPC::Connection::sendWithReply):
+        (IPC::TupleMover::move):
+        (IPC::moveTuple):
+        (IPC::Connection::sendSync):
+        * Platform/IPC/Decoder.h:
+        (IPC::Decoder::decode):
+        (IPC::Decoder::operator>>):
+        * Platform/IPC/HandleMessage.h:
+        (IPC::handleMessage):
+        (IPC::handleMessageSynchronous):
+        (IPC::handleMessageSynchronousWantsConnection):
+        (IPC::handleMessageAsync):
+        * Platform/SharedMemory.h:
+        * Scripts/webkit/LegacyMessages-expected.h:
+        * Scripts/webkit/Messages-expected.h:
+        * Scripts/webkit/MessagesSuperclass-expected.h:
+        * Scripts/webkit/messages.py:
+        * Shared/Databases/IndexedDB/WebIDBResult.h:
+        * Shared/RemoteLayerTree/RemoteLayerTreeTransaction.h:
+        * Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm:
+        * Shared/ShareableBitmap.h:
+        * Shared/ShareableResource.h:
+        * Shared/UpdateInfo.h:
+        * Shared/WebEvent.h:
+        * Shared/WebProcessCreationParameters.cpp:
+        * Shared/WebProcessCreationParameters.h:
+        * Shared/mac/SecItemResponseData.cpp:
+        (WebKit::SecItemResponseData::SecItemResponseData):
+        (WebKit::SecItemResponseData::decode):
+        * Shared/mac/SecItemResponseData.h:
+        * WebProcess/MediaStream/MediaDeviceSandboxExtensions.h:
+
 2019-03-25  Tim Horton  <timothy_horton@apple.com>
 
         Animated keyboard scrolling is extremely chaotic
index e3f6d87..1bbaf10 100644 (file)
@@ -41,6 +41,8 @@ class Encoder;
 
 template<typename> struct ArgumentCoder;
 
+template<typename> class UsesModernDecoder;
+
 template<typename U>
 class UsesModernDecoder {
 private:
@@ -53,6 +55,13 @@ public:
     static constexpr bool argumentCoderValue = sizeof(check<U>(nullptr)) == sizeof(uint8_t);
     static constexpr bool value = argumentCoderValue || sizeof(checkArgumentCoder<U>(nullptr)) == sizeof(uint8_t);
 };
+    
+template<typename... Types>
+class UsesModernDecoder<std::tuple<Types...>> {
+public:
+    static constexpr bool value = true;
+    static constexpr bool argumentCoderValue = true;
+};
 
 template<typename U>
 class UsesLegacyDecoder {
index 6990c34..e0671e7 100644 (file)
@@ -160,58 +160,90 @@ template<typename T, typename U> struct ArgumentCoder<std::pair<T, U>> {
 };
 
 template<size_t index, typename... Elements>
-struct TupleCoder {
+struct TupleEncoder {
     static void encode(Encoder& encoder, const std::tuple<Elements...>& tuple)
     {
         encoder << std::get<sizeof...(Elements) - index>(tuple);
-        TupleCoder<index - 1, Elements...>::encode(encoder, tuple);
+        TupleEncoder<index - 1, Elements...>::encode(encoder, tuple);
     }
+};
 
-    template<typename U = typename std::remove_reference<typename std::tuple_element<sizeof...(Elements) - index, std::tuple<Elements...>>::type>::type, std::enable_if_t<!UsesModernDecoder<U>::value>* = nullptr>
-    static bool decode(Decoder& decoder, std::tuple<Elements...>& tuple)
+template<typename... Elements>
+struct TupleEncoder<0, Elements...> {
+    static void encode(Encoder&, const std::tuple<Elements...>&)
     {
-        if (!decoder.decode(std::get<sizeof...(Elements) - index>(tuple)))
-            return false;
-        return TupleCoder<index - 1, Elements...>::decode(decoder, tuple);
     }
-    
-    template<typename U = typename std::remove_reference<typename std::tuple_element<sizeof...(Elements) - index, std::tuple<Elements...>>::type>::type, std::enable_if_t<UsesModernDecoder<U>::value>* = nullptr>
-    static bool decode(Decoder& decoder, std::tuple<Elements...>& tuple)
+};
+
+template <typename T, typename... Elements, size_t... Indices>
+auto tupleFromTupleAndObject(T&& object, std::tuple<Elements...>&& tuple, std::index_sequence<Indices...>)
+{
+    return std::make_tuple(WTFMove(object), WTFMove(std::get<Indices>(tuple))...);
+}
+
+template <typename T, typename... Elements>
+auto tupleFromTupleAndObject(T&& object, std::tuple<Elements...>&& tuple)
+{
+    return tupleFromTupleAndObject(WTFMove(object), WTFMove(tuple), std::index_sequence_for<Elements...>());
+}
+
+template<typename Type, typename... Types>
+struct TupleDecoderImpl {
+    static Optional<std::tuple<Type, Types...>> decode(Decoder& decoder)
     {
-        Optional<U> optional;
+        Optional<Type> optional;
         decoder >> optional;
         if (!optional)
-            return false;
-        std::get<sizeof...(Elements) - index>(tuple) = WTFMove(*optional);
-        return TupleCoder<index - 1, Elements...>::decode(decoder, tuple);
+            return WTF::nullopt;
+
+        Optional<std::tuple<Types...>> subTuple = TupleDecoderImpl<Types...>::decode(decoder);
+        if (!subTuple)
+            return WTF::nullopt;
+
+        return tupleFromTupleAndObject(WTFMove(*optional), WTFMove(*subTuple));
     }
 };
 
-template<typename... Elements>
-struct TupleCoder<0, Elements...> {
-    static void encode(Encoder&, const std::tuple<Elements...>&)
+template<typename Type>
+struct TupleDecoderImpl<Type> {
+    static Optional<std::tuple<Type>> decode(Decoder& decoder)
     {
+        Optional<Type> optional;
+        decoder >> optional;
+        if (!optional)
+            return WTF::nullopt;
+        return std::make_tuple(WTFMove(*optional));
     }
+};
 
-    static bool decode(Decoder&, std::tuple<Elements...>&)
+template<size_t size, typename... Elements>
+struct TupleDecoder {
+    static Optional<std::tuple<Elements...>> decode(Decoder& decoder)
     {
-        return true;
+        return TupleDecoderImpl<Elements...>::decode(decoder);
+    }
+};
+
+template<>
+struct TupleDecoder<0> {
+    static Optional<std::tuple<>> decode(Decoder& decoder)
+    {
+        return std::make_tuple();
     }
 };
 
 template<typename... Elements> struct ArgumentCoder<std::tuple<Elements...>> {
     static void encode(Encoder& encoder, const std::tuple<Elements...>& tuple)
     {
-        TupleCoder<sizeof...(Elements), Elements...>::encode(encoder, tuple);
+        TupleEncoder<sizeof...(Elements), Elements...>::encode(encoder, tuple);
     }
 
-    static bool decode(Decoder& decoder, std::tuple<Elements...>& tuple)
+    static Optional<std::tuple<Elements...>> decode(Decoder& decoder)
     {
-        return TupleCoder<sizeof...(Elements), Elements...>::decode(decoder, tuple);
+        return TupleDecoder<sizeof...(Elements), Elements...>::decode(decoder);
     }
 };
 
-
 template<typename KeyType, typename ValueType> struct ArgumentCoder<WTF::KeyValuePair<KeyType, ValueType>> {
     static void encode(Encoder& encoder, const WTF::KeyValuePair<KeyType, ValueType>& pair)
     {
index 0ca3a3f..f3739b4 100644 (file)
@@ -444,9 +444,10 @@ void Connection::sendWithReply(T&& message, uint64_t destinationID, FunctionDisp
 
     sendMessageWithReply(requestID, WTFMove(encoder), replyDispatcher, [replyHandler = WTFMove(replyHandler)](std::unique_ptr<Decoder> decoder) {
         if (decoder) {
-            typename CodingType<typename T::Reply>::Type reply;
-            if (decoder->decode(reply)) {
-                replyHandler(WTFMove(reply));
+            Optional<typename CodingType<typename T::Reply>::Type> reply;
+            *decoder >> reply;
+            if (reply) {
+                replyHandler(WTFMove(*reply));
                 return;
             }
         }
@@ -455,6 +456,25 @@ void Connection::sendWithReply(T&& message, uint64_t destinationID, FunctionDisp
     });
 }
 
+template<size_t i, typename A, typename B> struct TupleMover {
+    static void move(A&& a, B& b)
+    {
+        std::get<i - 1>(b) = WTFMove(std::get<i - 1>(a));
+        TupleMover<i - 1, A, B>::move(WTFMove(a), b);
+    }
+};
+
+template<typename A, typename B> struct TupleMover<0, A, B> {
+    static void move(A&&, B&) { }
+};
+
+template<typename... A, typename... B>
+void moveTuple(std::tuple<A...>&& a, std::tuple<B...>& b)
+{
+    static_assert(sizeof...(A) == sizeof...(B), "Should be used with two tuples of same size");
+    TupleMover<sizeof...(A), std::tuple<A...>, std::tuple<B...>>::move(WTFMove(a), b);
+}
+
 template<typename T> bool Connection::sendSync(T&& message, typename T::Reply&& reply, uint64_t destinationID, Seconds timeout, OptionSet<SendSyncOption> sendSyncOptions)
 {
     COMPILE_ASSERT(T::isSync, SyncMessageExpected);
@@ -476,7 +496,12 @@ template<typename T> bool Connection::sendSync(T&& message, typename T::Reply&&
         return false;
 
     // Decode the reply.
-    return replyDecoder->decode(reply);
+    Optional<typename T::ReplyArguments> replyArguments;
+    *replyDecoder >> replyArguments;
+    if (!replyArguments)
+        return false;
+    moveTuple(WTFMove(*replyArguments), reply);
+    return true;
 }
 
 template<typename T> bool Connection::waitForAndDispatchImmediately(uint64_t destinationID, Seconds timeout, OptionSet<WaitForOption> waitForOptions)
index 9471788..4e0154b 100644 (file)
@@ -150,12 +150,35 @@ public:
         return ArgumentCoder<T>::decode(*this, t);
     }
 
+    template<typename T, std::enable_if_t<!std::is_enum<T>::value && !UsesLegacyDecoder<T>::value>* = nullptr>
+    bool decode(T& t)
+    {
+        Optional<T> optional;
+        *this >> optional;
+        if (!optional)
+            return false;
+        t = WTFMove(*optional);
+        return true;
+    }
+
     template<typename T, std::enable_if_t<UsesModernDecoder<T>::value>* = nullptr>
     Decoder& operator>>(Optional<T>& t)
     {
         t = ArgumentCoder<T>::decode(*this);
         return *this;
     }
+    
+    template<typename T, std::enable_if_t<!std::is_enum<T>::value && !UsesModernDecoder<T>::value>* = nullptr>
+    Decoder& operator>>(Optional<T>& optional)
+    {
+        T t;
+        if (ArgumentCoder<T>::decode(*this, t)) {
+            optional = WTFMove(t);
+            return *this;
+        }
+        optional = WTF::nullopt;
+        return *this;
+    }
 
     bool removeAttachment(Attachment&);
 
index 415970e..85452cd 100644 (file)
@@ -110,31 +110,34 @@ struct CodingType<std::tuple<Ts...>> {
 template<typename T, typename C, typename MF>
 void handleMessage(Decoder& decoder, C* object, MF function)
 {
-    typename CodingType<typename T::Arguments>::Type arguments;
-    if (!decoder.decode(arguments)) {
+    Optional<typename CodingType<typename T::Arguments>::Type> arguments;
+    decoder >> arguments;
+    if (!arguments) {
         ASSERT(decoder.isInvalid());
         return;
     }
 
-    callMemberFunction(WTFMove(arguments), object, function);
+    callMemberFunction(WTFMove(*arguments), object, function);
 }
 
 template<typename T, typename C, typename MF>
 void handleMessage(Connection& connection, Decoder& decoder, C* object, MF function)
 {
-    typename CodingType<typename T::Arguments>::Type arguments;
-    if (!decoder.decode(arguments)) {
+    Optional<typename CodingType<typename T::Arguments>::Type> arguments;
+    decoder >> arguments;
+    if (!arguments) {
         ASSERT(decoder.isInvalid());
         return;
     }
-    callMemberFunction(connection, WTFMove(arguments), object, function);
+    callMemberFunction(connection, WTFMove(*arguments), object, function);
 }
 
 template<typename T, typename C, typename MF>
 void handleMessageSynchronous(Connection& connection, Decoder& decoder, std::unique_ptr<Encoder>& replyEncoder, C* object, MF function)
 {
-    typename CodingType<typename T::Arguments>::Type arguments;
-    if (!decoder.decode(arguments)) {
+    Optional<typename CodingType<typename T::Arguments>::Type> arguments;
+    decoder >> arguments;
+    if (!arguments) {
         ASSERT(decoder.isInvalid());
         return;
     }
@@ -142,14 +145,15 @@ void handleMessageSynchronous(Connection& connection, Decoder& decoder, std::uni
     typename T::DelayedReply completionHandler = [replyEncoder = WTFMove(replyEncoder), connection = makeRef(connection)] (auto&&... args) mutable {
         T::send(WTFMove(replyEncoder), WTFMove(connection), args...);
     };
-    callMemberFunction(WTFMove(arguments), WTFMove(completionHandler), object, function);
+    callMemberFunction(WTFMove(*arguments), WTFMove(completionHandler), object, function);
 }
 
 template<typename T, typename C, typename MF>
 void handleMessageSynchronousWantsConnection(Connection& connection, Decoder& decoder, std::unique_ptr<Encoder>& replyEncoder, C* object, MF function)
 {
-    typename CodingType<typename T::Arguments>::Type arguments;
-    if (!decoder.decode(arguments)) {
+    Optional<typename CodingType<typename T::Arguments>::Type> arguments;
+    decoder >> arguments;
+    if (!arguments) {
         ASSERT(decoder.isInvalid());
         return;
     }
@@ -157,7 +161,7 @@ void handleMessageSynchronousWantsConnection(Connection& connection, Decoder& de
     typename T::DelayedReply completionHandler = [replyEncoder = WTFMove(replyEncoder), connection = makeRef(connection)] (auto&&... args) mutable {
         T::send(WTFMove(replyEncoder), WTFMove(connection), args...);
     };
-    callMemberFunction(connection, WTFMove(arguments), WTFMove(completionHandler), object, function);
+    callMemberFunction(connection, WTFMove(*arguments), WTFMove(completionHandler), object, function);
 }
 
 template<typename T, typename C, typename MF>
@@ -170,8 +174,9 @@ void handleMessageAsync(Connection& connection, Decoder& decoder, C* object, MF
         return;
     }
     
-    typename CodingType<typename T::Arguments>::Type arguments;
-    if (!decoder.decode(arguments)) {
+    Optional<typename CodingType<typename T::Arguments>::Type> arguments;
+    decoder >> arguments;
+    if (!arguments) {
         ASSERT(decoder.isInvalid());
         return;
     }
@@ -181,7 +186,7 @@ void handleMessageAsync(Connection& connection, Decoder& decoder, C* object, MF
         *encoder << listenerID;
         T::send(WTFMove(encoder), WTFMove(connection), args...);
     };
-    callMemberFunction(WTFMove(arguments), WTFMove(completionHandler), object, function);
+    callMemberFunction(WTFMove(*arguments), WTFMove(completionHandler), object, function);
 }
 
 } // namespace IPC
index 769adc1..38e241f 100644 (file)
@@ -64,6 +64,8 @@ public:
     public:
         Handle();
         ~Handle();
+        Handle(Handle&&);
+        Handle& operator=(Handle&&);
 
         bool isNull() const;
 
index e028891..e8c6fc0 100644 (file)
@@ -46,6 +46,19 @@ SharedMemory::Handle::Handle()
 {
 }
 
+SharedMemory::Handle::Handle(Handle&& other)
+{
+    m_port = std::exchange(other.m_port, MACH_PORT_NULL);
+    m_size = std::exchange(other.m_size, 0);
+}
+
+auto SharedMemory::Handle::operator=(Handle&& other) -> Handle&
+{
+    m_port = std::exchange(other.m_port, MACH_PORT_NULL);
+    m_size = std::exchange(other.m_size, 0);
+    return *this;
+}
+
 SharedMemory::Handle::~Handle()
 {
     clear();
index 6f18da0..f413abf 100644 (file)
@@ -59,6 +59,9 @@ SharedMemory::Handle::~Handle()
 {
 }
 
+SharedMemory::Handle::Handle(Handle&&) = default;
+SharedMemory::Handle& SharedMemory::Handle::operator=(Handle&& other) = default;
+
 void SharedMemory::Handle::clear()
 {
     m_attachment = IPC::Attachment();
index 81f7b28..5b62d43 100644 (file)
@@ -39,6 +39,19 @@ SharedMemory::Handle::Handle()
 {
 }
 
+SharedMemory::Handle::Handle(Handle&& other)
+{
+    m_handle = std::exchange(other.m_handle, 0);
+    m_size = std::exchange(other.m_size, 0);
+}
+
+auto SharedMemory::Handle::operator=(Handle&& other) -> Handle&
+{
+    m_handle = std::exchange(other.m_handle, 0);
+    m_size = std::exchange(other.m_size, 0);
+    return *this;
+}
+
 SharedMemory::Handle::~Handle()
 {
     clear();
index 68e2e8e..ffd13d3 100644 (file)
@@ -288,7 +288,8 @@ public:
     static IPC::StringReference name() { return IPC::StringReference("CreatePlugin"); }
     static const bool isSync = true;
 
-    typedef std::tuple<bool&> Reply;
+    using Reply = std::tuple<bool&>;
+    using ReplyArguments = std::tuple<bool>;
     CreatePlugin(uint64_t pluginInstanceID, const WebKit::Plugin::Parameters& parameters)
         : m_arguments(pluginInstanceID, parameters)
     {
@@ -311,7 +312,8 @@ public:
     static IPC::StringReference name() { return IPC::StringReference("RunJavaScriptAlert"); }
     static const bool isSync = true;
 
-    typedef std::tuple<> Reply;
+    using Reply = std::tuple<>;
+    using ReplyArguments = std::tuple<>;
     RunJavaScriptAlert(uint64_t frameID, const String& message)
         : m_arguments(frameID, message)
     {
@@ -334,7 +336,8 @@ public:
     static IPC::StringReference name() { return IPC::StringReference("GetPlugins"); }
     static const bool isSync = true;
 
-    typedef std::tuple<Vector<WebCore::PluginInfo>&> Reply;
+    using Reply = std::tuple<Vector<WebCore::PluginInfo>&>;
+    using ReplyArguments = std::tuple<Vector<WebCore::PluginInfo>>;
     explicit GetPlugins(bool refresh)
         : m_arguments(refresh)
     {
@@ -359,7 +362,8 @@ public:
 
     using DelayedReply = CompletionHandler<void(const IPC::Connection::Handle& connectionHandle)>;
     static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, const IPC::Connection::Handle& connectionHandle);
-    typedef std::tuple<IPC::Connection::Handle&> Reply;
+    using Reply = std::tuple<IPC::Connection::Handle&>;
+    using ReplyArguments = std::tuple<IPC::Connection::Handle>;
     explicit GetPluginProcessConnection(const String& pluginPath)
         : m_arguments(pluginPath)
     {
@@ -384,7 +388,8 @@ public:
 
     using DelayedReply = CompletionHandler<void()>;
     static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&);
-    typedef std::tuple<> Reply;
+    using Reply = std::tuple<>;
+    using ReplyArguments = std::tuple<>;
     const Arguments& arguments() const
     {
         return m_arguments;
@@ -493,7 +498,8 @@ public:
     static IPC::StringReference name() { return IPC::StringReference("InterpretKeyEvent"); }
     static const bool isSync = true;
 
-    typedef std::tuple<Vector<WebCore::KeypressCommand>&> Reply;
+    using Reply = std::tuple<Vector<WebCore::KeypressCommand>&>;
+    using ReplyArguments = std::tuple<Vector<WebCore::KeypressCommand>>;
     explicit InterpretKeyEvent(uint32_t type)
         : m_arguments(type)
     {
index 68e2e8e..ffd13d3 100644 (file)
@@ -288,7 +288,8 @@ public:
     static IPC::StringReference name() { return IPC::StringReference("CreatePlugin"); }
     static const bool isSync = true;
 
-    typedef std::tuple<bool&> Reply;
+    using Reply = std::tuple<bool&>;
+    using ReplyArguments = std::tuple<bool>;
     CreatePlugin(uint64_t pluginInstanceID, const WebKit::Plugin::Parameters& parameters)
         : m_arguments(pluginInstanceID, parameters)
     {
@@ -311,7 +312,8 @@ public:
     static IPC::StringReference name() { return IPC::StringReference("RunJavaScriptAlert"); }
     static const bool isSync = true;
 
-    typedef std::tuple<> Reply;
+    using Reply = std::tuple<>;
+    using ReplyArguments = std::tuple<>;
     RunJavaScriptAlert(uint64_t frameID, const String& message)
         : m_arguments(frameID, message)
     {
@@ -334,7 +336,8 @@ public:
     static IPC::StringReference name() { return IPC::StringReference("GetPlugins"); }
     static const bool isSync = true;
 
-    typedef std::tuple<Vector<WebCore::PluginInfo>&> Reply;
+    using Reply = std::tuple<Vector<WebCore::PluginInfo>&>;
+    using ReplyArguments = std::tuple<Vector<WebCore::PluginInfo>>;
     explicit GetPlugins(bool refresh)
         : m_arguments(refresh)
     {
@@ -359,7 +362,8 @@ public:
 
     using DelayedReply = CompletionHandler<void(const IPC::Connection::Handle& connectionHandle)>;
     static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, const IPC::Connection::Handle& connectionHandle);
-    typedef std::tuple<IPC::Connection::Handle&> Reply;
+    using Reply = std::tuple<IPC::Connection::Handle&>;
+    using ReplyArguments = std::tuple<IPC::Connection::Handle>;
     explicit GetPluginProcessConnection(const String& pluginPath)
         : m_arguments(pluginPath)
     {
@@ -384,7 +388,8 @@ public:
 
     using DelayedReply = CompletionHandler<void()>;
     static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&);
-    typedef std::tuple<> Reply;
+    using Reply = std::tuple<>;
+    using ReplyArguments = std::tuple<>;
     const Arguments& arguments() const
     {
         return m_arguments;
@@ -493,7 +498,8 @@ public:
     static IPC::StringReference name() { return IPC::StringReference("InterpretKeyEvent"); }
     static const bool isSync = true;
 
-    typedef std::tuple<Vector<WebCore::KeypressCommand>&> Reply;
+    using Reply = std::tuple<Vector<WebCore::KeypressCommand>&>;
+    using ReplyArguments = std::tuple<Vector<WebCore::KeypressCommand>>;
     explicit InterpretKeyEvent(uint32_t type)
         : m_arguments(type)
     {
index 9d978b1..0f6fcc2 100644 (file)
@@ -80,7 +80,8 @@ public:
     static IPC::StringReference asyncMessageReplyName() { return { "TestAsyncMessageReply" }; }
     using AsyncReply = CompletionHandler<void(uint64_t result)>;
     static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, uint64_t result);
-    typedef std::tuple<uint64_t&> Reply;
+    using Reply = std::tuple<uint64_t&>;
+    using ReplyArguments = std::tuple<uint64_t>;
     explicit TestAsyncMessage(WebKit::TestTwoStateEnum twoStateEnum)
         : m_arguments(twoStateEnum)
     {
@@ -110,7 +111,8 @@ public:
     static IPC::StringReference asyncMessageReplyName() { return { "TestAsyncMessageWithNoArgumentsReply" }; }
     using AsyncReply = CompletionHandler<void()>;
     static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&);
-    typedef std::tuple<> Reply;
+    using Reply = std::tuple<>;
+    using ReplyArguments = std::tuple<>;
     const Arguments& arguments() const
     {
         return m_arguments;
@@ -135,7 +137,8 @@ public:
     static IPC::StringReference asyncMessageReplyName() { return { "TestAsyncMessageWithMultipleArgumentsReply" }; }
     using AsyncReply = CompletionHandler<void(bool flag, uint64_t value)>;
     static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, bool flag, uint64_t value);
-    typedef std::tuple<bool&, uint64_t&> Reply;
+    using Reply = std::tuple<bool&, uint64_t&>;
+    using ReplyArguments = std::tuple<bool, uint64_t>;
     const Arguments& arguments() const
     {
         return m_arguments;
@@ -156,7 +159,8 @@ public:
 
     using DelayedReply = CompletionHandler<void(uint8_t reply)>;
     static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, uint8_t reply);
-    typedef std::tuple<uint8_t&> Reply;
+    using Reply = std::tuple<uint8_t&>;
+    using ReplyArguments = std::tuple<uint8_t>;
     explicit TestSyncMessage(uint32_t param)
         : m_arguments(param)
     {
@@ -181,7 +185,8 @@ public:
 
     using DelayedReply = CompletionHandler<void(const Optional<WebKit::TestClassName>& optionalReply)>;
     static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, const Optional<WebKit::TestClassName>& optionalReply);
-    typedef std::tuple<Optional<WebKit::TestClassName>&> Reply;
+    using Reply = std::tuple<Optional<WebKit::TestClassName>&>;
+    using ReplyArguments = std::tuple<Optional<WebKit::TestClassName>>;
     explicit TestSynchronousMessage(bool value)
         : m_arguments(value)
     {
index ab52dc2..12fef65 100644 (file)
@@ -109,6 +109,10 @@ def reply_type(message):
     return 'std::tuple<%s>' % (', '.join(reply_parameter_type(parameter.type) for parameter in message.reply_parameters))
 
 
+def reply_arguments_type(message):
+    return 'std::tuple<%s>' % (', '.join(parameter.type for parameter in message.reply_parameters))
+
+
 def message_to_struct_declaration(message):
     result = []
     function_parameters = [(function_parameter_type(x.type, x.kind), x.name) for x in message.parameters]
@@ -137,7 +141,8 @@ def message_to_struct_declaration(message):
             if len(send_parameters):
                 result.append(', %s' % completion_handler_parameters)
             result.append(');\n')
-        result.append('    typedef %s Reply;\n' % reply_type(message))
+        result.append('    using Reply = %s;\n' % reply_type(message))
+        result.append('    using ReplyArguments = %s;\n' % reply_arguments_type(message))
 
     if len(function_parameters):
         result.append('    %s%s(%s)' % (len(function_parameters) == 1 and 'explicit ' or '', message.name, ', '.join([' '.join(x) for x in function_parameters])))
index 777b8e2..97a2a87 100644 (file)
@@ -50,6 +50,9 @@ public:
         , m_handles(WTFMove(handles))
     {
     }
+    
+    WebIDBResult(WebIDBResult&&) = default;
+    WebIDBResult& operator=(WebIDBResult&&) = default;
 
     const WebCore::IDBResultData& resultData() const { return m_resultData; }
     const SandboxExtension::HandleArray& handles() const { return m_handles; }
index c32696e..26e43df 100644 (file)
@@ -50,8 +50,6 @@ class Encoder;
 
 namespace WebKit {
 
-class PlatformCALayerRemote;
-
 class RemoteLayerTreeTransaction {
 public:
     enum LayerChange {
@@ -177,6 +175,8 @@ public:
 
     explicit RemoteLayerTreeTransaction();
     ~RemoteLayerTreeTransaction();
+    RemoteLayerTreeTransaction(RemoteLayerTreeTransaction&&);
+    RemoteLayerTreeTransaction& operator=(RemoteLayerTreeTransaction&&);
 
     void encode(IPC::Encoder&) const;
     static bool decode(IPC::Decoder&, RemoteLayerTreeTransaction&);
index 78edd18..26c7597 100644 (file)
@@ -39,6 +39,9 @@
 
 namespace WebKit {
 
+RemoteLayerTreeTransaction::RemoteLayerTreeTransaction(RemoteLayerTreeTransaction&&) = default;
+RemoteLayerTreeTransaction& RemoteLayerTreeTransaction::operator=(RemoteLayerTreeTransaction&&) = default;
+
 RemoteLayerTreeTransaction::LayerCreationProperties::LayerCreationProperties()
     : layerID(0)
     , type(WebCore::PlatformCALayer::LayerTypeLayer)
index 6fd6304..a4a3e5b 100644 (file)
@@ -63,6 +63,8 @@ public:
         WTF_MAKE_NONCOPYABLE(Handle);
     public:
         Handle();
+        Handle(Handle&&) = default;
+        Handle& operator=(Handle&&) = default;
 
         bool isNull() const { return m_handle.isNull(); }
 
index ca1d3f4..7cd4a48 100644 (file)
@@ -45,6 +45,8 @@ public:
         WTF_MAKE_NONCOPYABLE(Handle);
     public:
         Handle();
+        Handle(Handle&&) = default;
+        Handle& operator=(Handle&&) = default;
 
         bool isNull() const { return m_handle.isNull(); }
         unsigned size() const { return m_size; }
index b1d4af9..a64deed 100644 (file)
@@ -43,6 +43,8 @@ class UpdateInfo {
 
 public:
     UpdateInfo() { }
+    UpdateInfo(UpdateInfo&&) = default;
+    UpdateInfo& operator=(UpdateInfo&&) = default;
 
     void encode(IPC::Encoder&) const;
     static bool decode(IPC::Decoder&, UpdateInfo&);
index b42539e..ed408fe 100644 (file)
@@ -24,8 +24,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef WebEvent_h
-#define WebEvent_h
+#pragma once
 
 // FIXME: We should probably move to makeing the WebCore/PlatformFooEvents trivial classes so that
 // we can use them as the event type.
@@ -34,6 +33,7 @@
 #include <WebCore/FloatSize.h>
 #include <WebCore/IntPoint.h>
 #include <WebCore/IntSize.h>
+#include <WebCore/KeypressCommand.h>
 #include <wtf/OptionSet.h>
 #include <wtf/WallTime.h>
 #include <wtf/text/WTFString.h>
@@ -497,5 +497,3 @@ private:
 #endif // ENABLE(TOUCH_EVENTS)
 
 } // namespace WebKit
-
-#endif // WebEvent_h
index 741ffab..9582e6b 100644 (file)
@@ -34,6 +34,9 @@
 
 namespace WebKit {
 
+WebProcessCreationParameters::WebProcessCreationParameters(WebProcessCreationParameters&&) = default;
+WebProcessCreationParameters& WebProcessCreationParameters::operator=(WebProcessCreationParameters&&) = default;
+
 WebProcessCreationParameters::WebProcessCreationParameters()
 {
 }
index 7096d92..8450dce 100644 (file)
@@ -65,6 +65,8 @@ namespace WebKit {
 struct WebProcessCreationParameters {
     WebProcessCreationParameters();
     ~WebProcessCreationParameters();
+    WebProcessCreationParameters(WebProcessCreationParameters&&);
+    WebProcessCreationParameters& operator=(WebProcessCreationParameters&&);
 
     void encode(IPC::Encoder&) const;
     static bool decode(IPC::Decoder&, WebProcessCreationParameters&);
index 2a453dd..466f6ac 100644 (file)
 
 namespace WebKit {
 
-SecItemResponseData::SecItemResponseData()
-{
-}
-
-SecItemResponseData::SecItemResponseData(OSStatus resultCode, CFTypeRef resultObject)
+SecItemResponseData::SecItemResponseData(OSStatus resultCode, RetainPtr<CFTypeRef>&& resultObject)
     : m_resultObject(resultObject)
-    , m_resultCode(resultCode)
+    , m_resultCode(WTFMove(resultCode))
 {
 }
 
@@ -49,22 +45,21 @@ void SecItemResponseData::encode(IPC::Encoder& encoder) const
         IPC::encode(encoder, m_resultObject.get());
 }
 
-bool SecItemResponseData::decode(IPC::Decoder& decoder, SecItemResponseData& secItemResponseData)
+Optional<SecItemResponseData> SecItemResponseData::decode(IPC::Decoder& decoder)
 {
     int64_t resultCode;
     if (!decoder.decode(resultCode))
-        return false;
-    secItemResponseData.m_resultCode = (OSStatus)resultCode;
-    secItemResponseData.m_resultObject = 0;
+        return WTF::nullopt;
 
     bool expectResultObject;
     if (!decoder.decode(expectResultObject))
-        return false;
+        return WTF::nullopt;
 
-    if (expectResultObject && !IPC::decode(decoder, secItemResponseData.m_resultObject))
-        return false;
+    RetainPtr<CFTypeRef> result;
+    if (expectResultObject && !IPC::decode(decoder, result))
+        return WTF::nullopt;
 
-    return true;
+    return {{ static_cast<OSStatus>(resultCode), WTFMove(result) }};
 }
 
 } // namespace WebKit
index dbdf8d0..1306be7 100644 (file)
@@ -37,11 +37,10 @@ namespace WebKit {
     
 class SecItemResponseData {
 public:
-    SecItemResponseData();
-    SecItemResponseData(OSStatus, CFTypeRef result);
+    SecItemResponseData(OSStatus, RetainPtr<CFTypeRef>&& result);
 
     void encode(IPC::Encoder&) const;
-    static bool decode(IPC::Decoder&, SecItemResponseData&);
+    static Optional<SecItemResponseData> decode(IPC::Decoder&);
 
     RetainPtr<CFTypeRef>& resultObject() { return m_resultObject; }
     OSStatus resultCode() const { return m_resultCode; }
index bfba496..cb0c037 100644 (file)
@@ -39,6 +39,8 @@ public:
     MediaDeviceSandboxExtensions()
     {
     }
+    MediaDeviceSandboxExtensions(MediaDeviceSandboxExtensions&&) = default;
+    MediaDeviceSandboxExtensions& operator=(MediaDeviceSandboxExtensions&&) = default;
 
     MediaDeviceSandboxExtensions(Vector<String> ids, SandboxExtension::HandleArray&& handles);