Title: [156378] trunk/Source/WebKit2
Revision
156378
Author
ander...@apple.com
Date
2013-09-24 18:03:31 -0700 (Tue, 24 Sep 2013)

Log Message

Only allow rvalues to be passed as synchronous message replies
https://bugs.webkit.org/show_bug.cgi?id=121870

Reviewed by Andreas Kling.

This lets us get rid of a nasty const cast and is more logical.

* Platform/CoreIPC/Connection.h:
(CoreIPC::Connection::sendSync):
* Platform/CoreIPC/MessageSender.h:
(CoreIPC::MessageSender::send):
(CoreIPC::MessageSender::sendSync):
* Shared/ChildProcessProxy.h:
(WebKit::ChildProcessProxy::sendSync):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (156377 => 156378)


--- trunk/Source/WebKit2/ChangeLog	2013-09-25 01:01:17 UTC (rev 156377)
+++ trunk/Source/WebKit2/ChangeLog	2013-09-25 01:03:31 UTC (rev 156378)
@@ -1,3 +1,20 @@
+2013-09-24  Anders Carlsson  <ander...@apple.com>
+
+        Only allow rvalues to be passed as synchronous message replies
+        https://bugs.webkit.org/show_bug.cgi?id=121870
+
+        Reviewed by Andreas Kling.
+
+        This lets us get rid of a nasty const cast and is more logical.
+
+        * Platform/CoreIPC/Connection.h:
+        (CoreIPC::Connection::sendSync):
+        * Platform/CoreIPC/MessageSender.h:
+        (CoreIPC::MessageSender::send):
+        (CoreIPC::MessageSender::sendSync):
+        * Shared/ChildProcessProxy.h:
+        (WebKit::ChildProcessProxy::sendSync):
+
 2013-09-24  Csaba Osztrogonác  <o...@webkit.org>
 
         Unreviewed buildfix.

Modified: trunk/Source/WebKit2/Platform/CoreIPC/Connection.h (156377 => 156378)


--- trunk/Source/WebKit2/Platform/CoreIPC/Connection.h	2013-09-25 01:01:17 UTC (rev 156377)
+++ trunk/Source/WebKit2/Platform/CoreIPC/Connection.h	2013-09-25 01:03:31 UTC (rev 156378)
@@ -170,7 +170,7 @@
     static const int NoTimeout = -1;
 
     template<typename T> bool send(const T& message, uint64_t destinationID, unsigned messageSendFlags = 0);
-    template<typename T> bool sendSync(const T& message, const typename T::Reply& reply, uint64_t destinationID, double timeout = NoTimeout, unsigned syncSendFlags = 0);
+    template<typename T> bool sendSync(const T& message, typename T::Reply&& reply, uint64_t destinationID, double timeout = NoTimeout, unsigned syncSendFlags = 0);
     template<typename T> bool waitForAndDispatchImmediately(uint64_t destinationID, double timeout);
 
     std::unique_ptr<MessageEncoder> createSyncMessageEncoder(StringReference messageReceiverName, StringReference messageName, uint64_t destinationID, uint64_t& syncRequestID);
@@ -355,7 +355,7 @@
     return sendMessage(std::move(encoder), messageSendFlags);
 }
 
-template<typename T> bool Connection::sendSync(const T& message, const typename T::Reply& reply, uint64_t destinationID, double timeout, unsigned syncSendFlags)
+template<typename T> bool Connection::sendSync(const T& message, typename T::Reply&& reply, uint64_t destinationID, double timeout, unsigned syncSendFlags)
 {
     COMPILE_ASSERT(T::isSync, SyncMessageExpected);
 
@@ -371,7 +371,7 @@
         return false;
 
     // Decode the reply.
-    return replyDecoder->decode(const_cast<typename T::Reply&>(reply));
+    return replyDecoder->decode(reply);
 }
 
 template<typename T> bool Connection::waitForAndDispatchImmediately(uint64_t destinationID, double timeout)

Modified: trunk/Source/WebKit2/Platform/CoreIPC/MessageSender.h (156377 => 156378)


--- trunk/Source/WebKit2/Platform/CoreIPC/MessageSender.h	2013-09-25 01:01:17 UTC (rev 156377)
+++ trunk/Source/WebKit2/Platform/CoreIPC/MessageSender.h	2013-09-25 01:03:31 UTC (rev 156378)
@@ -42,24 +42,26 @@
 
     template<typename U> bool send(const U& message, uint64_t destinationID)
     {
-        COMPILE_ASSERT(!U::isSync, AsyncMessageExpected);
+        static_assert(!U::isSync, "Message is sync!");
+
         auto encoder = std::make_unique<MessageEncoder>(U::receiverName(), U::name(), destinationID);
         encoder->encode(message);
         
         return sendMessage(std::move(encoder));
     }
 
-    template<typename U> bool sendSync(const U& message, const typename U::Reply& reply, double timeout = Connection::NoTimeout)
+    template<typename U> bool sendSync(const U& message, typename U::Reply&& reply, double timeout = Connection::NoTimeout)
     {
-        COMPILE_ASSERT(U::isSync, SyncMessageExpected);
-        return sendSync(message, reply, messageSenderDestinationID(), timeout);
+        static_assert(U::isSync, "Message is not sync!");
+
+        return sendSync(message, std::move(reply), messageSenderDestinationID(), timeout);
     }
 
-    template<typename U> bool sendSync(const U& message, const typename U::Reply& reply, uint64_t destinationID, double timeout = Connection::NoTimeout)
+    template<typename U> bool sendSync(const U& message, typename U::Reply&& reply, uint64_t destinationID, double timeout = Connection::NoTimeout)
     {
         ASSERT(messageSenderConnection());
 
-        return messageSenderConnection()->sendSync(message, reply, destinationID, timeout);
+        return messageSenderConnection()->sendSync(message, std::move(reply), destinationID, timeout);
     }
 
     bool sendMessage(std::unique_ptr<MessageEncoder>);

Modified: trunk/Source/WebKit2/Shared/ChildProcessProxy.h (156377 => 156378)


--- trunk/Source/WebKit2/Shared/ChildProcessProxy.h	2013-09-25 01:01:17 UTC (rev 156377)
+++ trunk/Source/WebKit2/Shared/ChildProcessProxy.h	2013-09-25 01:03:31 UTC (rev 156378)
@@ -48,7 +48,7 @@
     void terminate();
 
     template<typename T> bool send(const T& message, uint64_t destinationID, unsigned messageSendFlags = 0);
-    template<typename U> bool sendSync(const U& message, const typename U::Reply&, uint64_t destinationID, double timeout = 1);
+    template<typename U> bool sendSync(const U& message, typename U::Reply&&, uint64_t destinationID, double timeout = 1);
     
     CoreIPC::Connection* connection() const
     {
@@ -101,14 +101,14 @@
 }
 
 template<typename U> 
-bool ChildProcessProxy::sendSync(const U& message, const typename U::Reply& reply, uint64_t destinationID, double timeout)
+bool ChildProcessProxy::sendSync(const U& message, typename U::Reply&& reply, uint64_t destinationID, double timeout)
 {
     COMPILE_ASSERT(U::isSync, SyncMessageExpected);
 
     if (!m_connection)
         return false;
 
-    return connection()->sendSync(message, reply, destinationID, timeout);
+    return connection()->sendSync(message, std::move(reply), destinationID, timeout);
 }
 
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to