Diff
Modified: trunk/Source/WebKit2/ChangeLog (132425 => 132426)
--- trunk/Source/WebKit2/ChangeLog 2012-10-24 23:55:49 UTC (rev 132425)
+++ trunk/Source/WebKit2/ChangeLog 2012-10-24 23:59:39 UTC (rev 132426)
@@ -1,3 +1,25 @@
+2012-10-24 Anders Carlsson <[email protected]>
+
+ Make it a compile error to send a sync message as async (and vice versa)
+ https://bugs.webkit.org/show_bug.cgi?id=100285
+
+ Reviewed by Sam Weinig.
+
+ Add an "isSync" boolean to each generated message struct and add compile asserts to the message senders.
+
+ * Platform/CoreIPC/Connection.h:
+ (CoreIPC::Connection::send):
+ (CoreIPC::Connection::sendSync):
+ * Platform/CoreIPC/MessageSender.h:
+ (CoreIPC::MessageSender::send):
+ (CoreIPC::MessageSender::sendSync):
+ * Scripts/webkit2/messages.py:
+ (message_to_struct_declaration):
+ * Scripts/webkit2/messages_unittest.py:
+ * UIProcess/WebProcessProxy.h:
+ (WebKit::WebProcessProxy::send):
+ (WebKit::WebProcessProxy::sendSync):
+
2012-10-24 Kiran Muppala <[email protected]>
Disable auto termination of WebKit2 processes on mac
Modified: trunk/Source/WebKit2/Platform/CoreIPC/Connection.h (132425 => 132426)
--- trunk/Source/WebKit2/Platform/CoreIPC/Connection.h 2012-10-24 23:55:49 UTC (rev 132425)
+++ trunk/Source/WebKit2/Platform/CoreIPC/Connection.h 2012-10-24 23:59:39 UTC (rev 132426)
@@ -397,6 +397,8 @@
template<typename T> bool Connection::send(const T& message, uint64_t destinationID, unsigned messageSendFlags)
{
+ COMPILE_ASSERT(!T::isSync, AsyncMessageExpected);
+
OwnPtr<MessageEncoder> encoder = MessageEncoder::create(T::receiverName(), T::name(), destinationID);
encoder->encode(message);
@@ -405,6 +407,8 @@
template<typename T> bool Connection::sendSync(const T& message, const typename T::Reply& reply, uint64_t destinationID, double timeout, unsigned syncSendFlags)
{
+ COMPILE_ASSERT(T::isSync, SyncMessageExpected);
+
uint64_t syncRequestID = 0;
OwnPtr<MessageEncoder> encoder = createSyncMessageEncoder(T::receiverName(), T::name(), destinationID, syncRequestID);
Modified: trunk/Source/WebKit2/Platform/CoreIPC/MessageSender.h (132425 => 132426)
--- trunk/Source/WebKit2/Platform/CoreIPC/MessageSender.h 2012-10-24 23:55:49 UTC (rev 132425)
+++ trunk/Source/WebKit2/Platform/CoreIPC/MessageSender.h 2012-10-24 23:59:39 UTC (rev 132426)
@@ -40,6 +40,7 @@
template<typename U> bool send(const U& message, uint64_t destinationID)
{
+ COMPILE_ASSERT(!U::isSync, AsyncMessageExpected);
OwnPtr<MessageEncoder> encoder = MessageEncoder::create(U::receiverName(), U::name(), destinationID);
encoder->encode(message);
@@ -56,6 +57,7 @@
template<typename U> bool sendSync(const U& message, const typename U::Reply& reply, double timeout = Connection::NoTimeout)
{
+ COMPILE_ASSERT(U::isSync, SyncMessageExpected);
return sendSync(message, reply, static_cast<T*>(this)->destinationID(), timeout);
}
Modified: trunk/Source/WebKit2/Scripts/webkit2/messages.py (132425 => 132426)
--- trunk/Source/WebKit2/Scripts/webkit2/messages.py 2012-10-24 23:55:49 UTC (rev 132425)
+++ trunk/Source/WebKit2/Scripts/webkit2/messages.py 2012-10-24 23:59:39 UTC (rev 132426)
@@ -131,6 +131,7 @@
result.append(' static const Kind messageID = %s;\n' % message.id())
result.append(' static CoreIPC::StringReference receiverName() { return messageReceiverName(); }\n')
result.append(' static CoreIPC::StringReference name() { return CoreIPC::StringReference("%s"); }\n' % message.name)
+ result.append(' static const bool isSync = %s;\n' % ('false', 'true')[message.reply_parameters != None])
result.append('\n')
if message.reply_parameters != None:
if message.has_attribute(DELAYED_ATTRIBUTE):
Modified: trunk/Source/WebKit2/Scripts/webkit2/messages_unittest.py (132425 => 132426)
--- trunk/Source/WebKit2/Scripts/webkit2/messages_unittest.py 2012-10-24 23:55:49 UTC (rev 132425)
+++ trunk/Source/WebKit2/Scripts/webkit2/messages_unittest.py 2012-10-24 23:59:39 UTC (rev 132426)
@@ -382,6 +382,7 @@
static const Kind messageID = LoadURLID;
static CoreIPC::StringReference receiverName() { return messageReceiverName(); }
static CoreIPC::StringReference name() { return CoreIPC::StringReference("LoadURL"); }
+ static const bool isSync = false;
typedef CoreIPC::Arguments1<const WTF::String&> DecodeType;
explicit LoadURL(const WTF::String& url)
@@ -395,6 +396,7 @@
static const Kind messageID = TouchEventID;
static CoreIPC::StringReference receiverName() { return messageReceiverName(); }
static CoreIPC::StringReference name() { return CoreIPC::StringReference("TouchEvent"); }
+ static const bool isSync = false;
typedef CoreIPC::Arguments1<const WebKit::WebTouchEvent&> DecodeType;
explicit TouchEvent(const WebKit::WebTouchEvent& event)
@@ -408,6 +410,7 @@
static const Kind messageID = DidReceivePolicyDecisionID;
static CoreIPC::StringReference receiverName() { return messageReceiverName(); }
static CoreIPC::StringReference name() { return CoreIPC::StringReference("DidReceivePolicyDecision"); }
+ static const bool isSync = false;
typedef CoreIPC::Arguments3<uint64_t, uint64_t, uint32_t> DecodeType;
DidReceivePolicyDecision(uint64_t frameID, uint64_t listenerID, uint32_t policyAction)
@@ -420,6 +423,7 @@
static const Kind messageID = CloseID;
static CoreIPC::StringReference receiverName() { return messageReceiverName(); }
static CoreIPC::StringReference name() { return CoreIPC::StringReference("Close"); }
+ static const bool isSync = false;
typedef CoreIPC::Arguments0 DecodeType;
};
@@ -428,6 +432,7 @@
static const Kind messageID = PreferencesDidChangeID;
static CoreIPC::StringReference receiverName() { return messageReceiverName(); }
static CoreIPC::StringReference name() { return CoreIPC::StringReference("PreferencesDidChange"); }
+ static const bool isSync = false;
typedef CoreIPC::Arguments1<const WebKit::WebPreferencesStore&> DecodeType;
explicit PreferencesDidChange(const WebKit::WebPreferencesStore& store)
@@ -440,6 +445,7 @@
static const Kind messageID = SendDoubleAndFloatID;
static CoreIPC::StringReference receiverName() { return messageReceiverName(); }
static CoreIPC::StringReference name() { return CoreIPC::StringReference("SendDoubleAndFloat"); }
+ static const bool isSync = false;
typedef CoreIPC::Arguments2<double, float> DecodeType;
SendDoubleAndFloat(double d, float f)
@@ -452,6 +458,7 @@
static const Kind messageID = SendIntsID;
static CoreIPC::StringReference receiverName() { return messageReceiverName(); }
static CoreIPC::StringReference name() { return CoreIPC::StringReference("SendInts"); }
+ static const bool isSync = false;
typedef CoreIPC::Arguments2<const Vector<uint64_t>&, const Vector<Vector<uint64_t> >&> DecodeType;
SendInts(const Vector<uint64_t>& ints, const Vector<Vector<uint64_t> >& intVectors)
@@ -464,6 +471,7 @@
static const Kind messageID = CreatePluginID;
static CoreIPC::StringReference receiverName() { return messageReceiverName(); }
static CoreIPC::StringReference name() { return CoreIPC::StringReference("CreatePlugin"); }
+ static const bool isSync = true;
typedef CoreIPC::Arguments1<bool&> Reply;
typedef CoreIPC::Arguments2<uint64_t, const WebKit::Plugin::Parameters&> DecodeType;
@@ -477,6 +485,7 @@
static const Kind messageID = RunJavaScriptAlertID;
static CoreIPC::StringReference receiverName() { return messageReceiverName(); }
static CoreIPC::StringReference name() { return CoreIPC::StringReference("RunJavaScriptAlert"); }
+ static const bool isSync = true;
typedef CoreIPC::Arguments0 Reply;
typedef CoreIPC::Arguments2<uint64_t, const WTF::String&> DecodeType;
@@ -490,6 +499,7 @@
static const Kind messageID = GetPluginsID;
static CoreIPC::StringReference receiverName() { return messageReceiverName(); }
static CoreIPC::StringReference name() { return CoreIPC::StringReference("GetPlugins"); }
+ static const bool isSync = true;
typedef CoreIPC::Arguments1<Vector<WebCore::PluginInfo>&> Reply;
typedef CoreIPC::Arguments1<bool> DecodeType;
@@ -503,6 +513,7 @@
static const Kind messageID = GetPluginProcessConnectionID;
static CoreIPC::StringReference receiverName() { return messageReceiverName(); }
static CoreIPC::StringReference name() { return CoreIPC::StringReference("GetPluginProcessConnection"); }
+ static const bool isSync = true;
struct DelayedReply : public ThreadSafeRefCounted<DelayedReply> {
DelayedReply(PassRefPtr<CoreIPC::Connection>, PassOwnPtr<CoreIPC::MessageEncoder>);
@@ -527,6 +538,7 @@
static const Kind messageID = TestMultipleAttributesID;
static CoreIPC::StringReference receiverName() { return messageReceiverName(); }
static CoreIPC::StringReference name() { return CoreIPC::StringReference("TestMultipleAttributes"); }
+ static const bool isSync = true;
struct DelayedReply : public ThreadSafeRefCounted<DelayedReply> {
DelayedReply(PassRefPtr<CoreIPC::Connection>, PassOwnPtr<CoreIPC::MessageEncoder>);
@@ -547,6 +559,7 @@
static const Kind messageID = TestConnectionQueueID;
static CoreIPC::StringReference receiverName() { return messageReceiverName(); }
static CoreIPC::StringReference name() { return CoreIPC::StringReference("TestConnectionQueue"); }
+ static const bool isSync = false;
typedef CoreIPC::Arguments1<uint64_t> DecodeType;
explicit TestConnectionQueue(uint64_t pluginID)
@@ -559,6 +572,7 @@
static const Kind messageID = TestParameterAttributesID;
static CoreIPC::StringReference receiverName() { return messageReceiverName(); }
static CoreIPC::StringReference name() { return CoreIPC::StringReference("TestParameterAttributes"); }
+ static const bool isSync = false;
typedef CoreIPC::Arguments3<uint64_t, double, double> DecodeType;
TestParameterAttributes(uint64_t foo, double bar, double baz)
@@ -572,6 +586,7 @@
static const Kind messageID = DidCreateWebProcessConnectionID;
static CoreIPC::StringReference receiverName() { return messageReceiverName(); }
static CoreIPC::StringReference name() { return CoreIPC::StringReference("DidCreateWebProcessConnection"); }
+ static const bool isSync = false;
typedef CoreIPC::Arguments1<const CoreIPC::MachPort&> DecodeType;
explicit DidCreateWebProcessConnection(const CoreIPC::MachPort& connectionIdentifier)
@@ -586,6 +601,7 @@
static const Kind messageID = InterpretKeyEventID;
static CoreIPC::StringReference receiverName() { return messageReceiverName(); }
static CoreIPC::StringReference name() { return CoreIPC::StringReference("InterpretKeyEvent"); }
+ static const bool isSync = true;
typedef CoreIPC::Arguments1<Vector<WebCore::KeypressCommand>&> Reply;
typedef CoreIPC::Arguments1<uint32_t> DecodeType;
@@ -601,6 +617,7 @@
static const Kind messageID = DeprecatedOperationID;
static CoreIPC::StringReference receiverName() { return messageReceiverName(); }
static CoreIPC::StringReference name() { return CoreIPC::StringReference("DeprecatedOperation"); }
+ static const bool isSync = false;
typedef CoreIPC::Arguments1<const CoreIPC::DummyType&> DecodeType;
explicit DeprecatedOperation(const CoreIPC::DummyType& dummy)
@@ -615,6 +632,7 @@
static const Kind messageID = ExperimentalOperationID;
static CoreIPC::StringReference receiverName() { return messageReceiverName(); }
static CoreIPC::StringReference name() { return CoreIPC::StringReference("ExperimentalOperation"); }
+ static const bool isSync = false;
typedef CoreIPC::Arguments1<const CoreIPC::DummyType&> DecodeType;
explicit ExperimentalOperation(const CoreIPC::DummyType& dummy)
Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.h (132425 => 132426)
--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.h 2012-10-24 23:55:49 UTC (rev 132425)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.h 2012-10-24 23:59:39 UTC (rev 132426)
@@ -218,6 +218,8 @@
template<typename T>
bool WebProcessProxy::send(const T& message, uint64_t destinationID, unsigned messageSendFlags)
{
+ COMPILE_ASSERT(!T::isSync, AsyncMessageExpected);
+
OwnPtr<CoreIPC::MessageEncoder> encoder = CoreIPC::MessageEncoder::create(T::receiverName(), "", destinationID);
encoder->encode(message);
@@ -227,6 +229,8 @@
template<typename U>
bool WebProcessProxy::sendSync(const U& message, const typename U::Reply& reply, uint64_t destinationID, double timeout)
{
+ COMPILE_ASSERT(U::isSync, SyncMessageExpected);
+
if (!m_connection)
return false;