Title: [131784] trunk/Source/WebKit2
Revision
131784
Author
ander...@apple.com
Date
2012-10-18 11:53:00 -0700 (Thu, 18 Oct 2012)

Log Message

Generated messages should have a receiver name and a name
https://bugs.webkit.org/show_bug.cgi?id=99740

Reviewed by Andreas Kling.

As a first step towards getting rid of MessageID, give each generated message a name and receiver name
and pass them along when sending the messages.

* Platform/CoreIPC/Connection.h:
(CoreIPC::Connection::send):
(CoreIPC::Connection::sendSync):
* Platform/CoreIPC/MessageSender.h:
(CoreIPC::MessageSender::send):
* Scripts/webkit2/messages.py:
(message_to_struct_declaration):
(generate_messages_header):
* Scripts/webkit2/messages_unittest.py:

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (131783 => 131784)


--- trunk/Source/WebKit2/ChangeLog	2012-10-18 18:43:15 UTC (rev 131783)
+++ trunk/Source/WebKit2/ChangeLog	2012-10-18 18:53:00 UTC (rev 131784)
@@ -1,3 +1,23 @@
+2012-10-18  Anders Carlsson  <ander...@apple.com>
+
+        Generated messages should have a receiver name and a name
+        https://bugs.webkit.org/show_bug.cgi?id=99740
+
+        Reviewed by Andreas Kling.
+
+        As a first step towards getting rid of MessageID, give each generated message a name and receiver name
+        and pass them along when sending the messages.
+
+        * Platform/CoreIPC/Connection.h:
+        (CoreIPC::Connection::send):
+        (CoreIPC::Connection::sendSync):
+        * Platform/CoreIPC/MessageSender.h:
+        (CoreIPC::MessageSender::send):
+        * Scripts/webkit2/messages.py:
+        (message_to_struct_declaration):
+        (generate_messages_header):
+        * Scripts/webkit2/messages_unittest.py:
+
 2012-10-18  Pablo Flouret  <pab...@motorola.com>
 
         Implement css3-conditional's @supports rule

Modified: trunk/Source/WebKit2/Platform/CoreIPC/Connection.h (131783 => 131784)


--- trunk/Source/WebKit2/Platform/CoreIPC/Connection.h	2012-10-18 18:43:15 UTC (rev 131783)
+++ trunk/Source/WebKit2/Platform/CoreIPC/Connection.h	2012-10-18 18:53:00 UTC (rev 131784)
@@ -410,7 +410,7 @@
 
 template<typename T> bool Connection::send(const T& message, uint64_t destinationID, unsigned messageSendFlags)
 {
-    OwnPtr<MessageEncoder> encoder = MessageEncoder::create("", "", destinationID);
+    OwnPtr<MessageEncoder> encoder = MessageEncoder::create(T::receiverName(), T::name(), destinationID);
     encoder->encode(message);
     
     return sendMessage(MessageID(T::messageID), encoder.release(), messageSendFlags);
@@ -419,7 +419,7 @@
 template<typename T> bool Connection::sendSync(const T& message, const typename T::Reply& reply, uint64_t destinationID, double timeout, unsigned syncSendFlags)
 {
     uint64_t syncRequestID = 0;
-    OwnPtr<MessageEncoder> encoder = createSyncMessageEncoder("", "", destinationID, syncRequestID);
+    OwnPtr<MessageEncoder> encoder = createSyncMessageEncoder(T::receiverName(), T::name(), destinationID, syncRequestID);
     
     // Encode the rest of the input arguments.
     encoder->encode(message);

Modified: trunk/Source/WebKit2/Platform/CoreIPC/MessageSender.h (131783 => 131784)


--- trunk/Source/WebKit2/Platform/CoreIPC/MessageSender.h	2012-10-18 18:43:15 UTC (rev 131783)
+++ trunk/Source/WebKit2/Platform/CoreIPC/MessageSender.h	2012-10-18 18:53:00 UTC (rev 131784)
@@ -40,7 +40,7 @@
 
     template<typename U> bool send(const U& message, uint64_t destinationID)
     {
-        OwnPtr<MessageEncoder> encoder = MessageEncoder::create("", "", destinationID);
+        OwnPtr<MessageEncoder> encoder = MessageEncoder::create(U::receiverName(), U::name(), destinationID);
         encoder->encode(message);
         
         return static_cast<T*>(this)->sendMessage(MessageID(U::messageID), encoder.release());

Modified: trunk/Source/WebKit2/Scripts/webkit2/messages.py (131783 => 131784)


--- trunk/Source/WebKit2/Scripts/webkit2/messages.py	2012-10-18 18:43:15 UTC (rev 131783)
+++ trunk/Source/WebKit2/Scripts/webkit2/messages.py	2012-10-18 18:53:00 UTC (rev 131784)
@@ -129,6 +129,9 @@
     result.append('struct %s : %s' % (message.name, base_class(message)))
     result.append(' {\n')
     result.append('    static const Kind messageID = %s;\n' % message.id())
+    result.append('    static const char const* receiverName() { return messageReceiverName(); }\n')
+    result.append('    static const char const* name() { return "%s"; }\n' % message.name)
+    result.append('\n')
     if message.reply_parameters != None:
         if message.has_attribute(DELAYED_ATTRIBUTE):
             send_parameters = [(function_parameter_type(x.type), x.name) for x in message.reply_parameters]
@@ -279,11 +282,19 @@
     result.append(forward_declarations)
     result.append('\n')
 
-    result.append('namespace Messages {\n\nnamespace %s {\n\n' % receiver.name)
+    result.append('namespace Messages {\nnamespace %s {\n' % receiver.name)
+    result.append('\n')
+    result.append('static inline const char const* messageReceiverName()\n')
+    result.append('{\n')
+    result.append('    return "%s";\n' % receiver.name)
+    result.append('}\n')
+    result.append('\n')
+
     result.append(messages_to_kind_enum(receiver.messages))
     result.append('\n')
     result.append('\n'.join([message_to_struct_declaration(x) for x in receiver.messages]))
-    result.append('\n} // namespace %s\n\n} // namespace Messages\n' % receiver.name)
+    result.append('\n')
+    result.append('} // namespace %s\n} // namespace Messages\n' % receiver.name)
 
     result.append('\nnamespace CoreIPC {\n\n')
     result.append('template<> struct MessageKindTraits<Messages::%s::Kind> {\n' % receiver.name)

Modified: trunk/Source/WebKit2/Scripts/webkit2/messages_unittest.py (131783 => 131784)


--- trunk/Source/WebKit2/Scripts/webkit2/messages_unittest.py	2012-10-18 18:43:15 UTC (rev 131783)
+++ trunk/Source/WebKit2/Scripts/webkit2/messages_unittest.py	2012-10-18 18:53:00 UTC (rev 131784)
@@ -339,9 +339,13 @@
 }
 
 namespace Messages {
-
 namespace WebPage {
 
+static inline const char const* messageReceiverName()
+{
+    return "WebPage";
+}
+
 enum Kind {
     LoadURLID,
 #if ENABLE(TOUCH_EVENTS)
@@ -375,6 +379,9 @@
 
 struct LoadURL : CoreIPC::Arguments1<const WTF::String&> {
     static const Kind messageID = LoadURLID;
+    static const char const* receiverName() { return messageReceiverName(); }
+    static const char const* name() { return "LoadURL"; }
+
     typedef CoreIPC::Arguments1<const WTF::String&> DecodeType;
     explicit LoadURL(const WTF::String& url)
         : CoreIPC::Arguments1<const WTF::String&>(url)
@@ -385,6 +392,9 @@
 #if ENABLE(TOUCH_EVENTS)
 struct TouchEvent : CoreIPC::Arguments1<const WebKit::WebTouchEvent&> {
     static const Kind messageID = TouchEventID;
+    static const char const* receiverName() { return messageReceiverName(); }
+    static const char const* name() { return "TouchEvent"; }
+
     typedef CoreIPC::Arguments1<const WebKit::WebTouchEvent&> DecodeType;
     explicit TouchEvent(const WebKit::WebTouchEvent& event)
         : CoreIPC::Arguments1<const WebKit::WebTouchEvent&>(event)
@@ -395,6 +405,9 @@
 
 struct DidReceivePolicyDecision : CoreIPC::Arguments3<uint64_t, uint64_t, uint32_t> {
     static const Kind messageID = DidReceivePolicyDecisionID;
+    static const char const* receiverName() { return messageReceiverName(); }
+    static const char const* name() { return "DidReceivePolicyDecision"; }
+
     typedef CoreIPC::Arguments3<uint64_t, uint64_t, uint32_t> DecodeType;
     DidReceivePolicyDecision(uint64_t frameID, uint64_t listenerID, uint32_t policyAction)
         : CoreIPC::Arguments3<uint64_t, uint64_t, uint32_t>(frameID, listenerID, policyAction)
@@ -404,11 +417,17 @@
 
 struct Close : CoreIPC::Arguments0 {
     static const Kind messageID = CloseID;
+    static const char const* receiverName() { return messageReceiverName(); }
+    static const char const* name() { return "Close"; }
+
     typedef CoreIPC::Arguments0 DecodeType;
 };
 
 struct PreferencesDidChange : CoreIPC::Arguments1<const WebKit::WebPreferencesStore&> {
     static const Kind messageID = PreferencesDidChangeID;
+    static const char const* receiverName() { return messageReceiverName(); }
+    static const char const* name() { return "PreferencesDidChange"; }
+
     typedef CoreIPC::Arguments1<const WebKit::WebPreferencesStore&> DecodeType;
     explicit PreferencesDidChange(const WebKit::WebPreferencesStore& store)
         : CoreIPC::Arguments1<const WebKit::WebPreferencesStore&>(store)
@@ -418,6 +437,9 @@
 
 struct SendDoubleAndFloat : CoreIPC::Arguments2<double, float> {
     static const Kind messageID = SendDoubleAndFloatID;
+    static const char const* receiverName() { return messageReceiverName(); }
+    static const char const* name() { return "SendDoubleAndFloat"; }
+
     typedef CoreIPC::Arguments2<double, float> DecodeType;
     SendDoubleAndFloat(double d, float f)
         : CoreIPC::Arguments2<double, float>(d, f)
@@ -427,6 +449,9 @@
 
 struct SendInts : CoreIPC::Arguments2<const Vector<uint64_t>&, const Vector<Vector<uint64_t> >&> {
     static const Kind messageID = SendIntsID;
+    static const char const* receiverName() { return messageReceiverName(); }
+    static const char const* name() { return "SendInts"; }
+
     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)
         : CoreIPC::Arguments2<const Vector<uint64_t>&, const Vector<Vector<uint64_t> >&>(ints, intVectors)
@@ -436,6 +461,9 @@
 
 struct CreatePlugin : CoreIPC::Arguments2<uint64_t, const WebKit::Plugin::Parameters&> {
     static const Kind messageID = CreatePluginID;
+    static const char const* receiverName() { return messageReceiverName(); }
+    static const char const* name() { return "CreatePlugin"; }
+
     typedef CoreIPC::Arguments1<bool&> Reply;
     typedef CoreIPC::Arguments2<uint64_t, const WebKit::Plugin::Parameters&> DecodeType;
     CreatePlugin(uint64_t pluginInstanceID, const WebKit::Plugin::Parameters& parameters)
@@ -446,6 +474,9 @@
 
 struct RunJavaScriptAlert : CoreIPC::Arguments2<uint64_t, const WTF::String&> {
     static const Kind messageID = RunJavaScriptAlertID;
+    static const char const* receiverName() { return messageReceiverName(); }
+    static const char const* name() { return "RunJavaScriptAlert"; }
+
     typedef CoreIPC::Arguments0 Reply;
     typedef CoreIPC::Arguments2<uint64_t, const WTF::String&> DecodeType;
     RunJavaScriptAlert(uint64_t frameID, const WTF::String& message)
@@ -456,6 +487,9 @@
 
 struct GetPlugins : CoreIPC::Arguments1<bool> {
     static const Kind messageID = GetPluginsID;
+    static const char const* receiverName() { return messageReceiverName(); }
+    static const char const* name() { return "GetPlugins"; }
+
     typedef CoreIPC::Arguments1<Vector<WebCore::PluginInfo>&> Reply;
     typedef CoreIPC::Arguments1<bool> DecodeType;
     explicit GetPlugins(bool refresh)
@@ -466,6 +500,9 @@
 
 struct GetPluginProcessConnection : CoreIPC::Arguments1<const WTF::String&> {
     static const Kind messageID = GetPluginProcessConnectionID;
+    static const char const* receiverName() { return messageReceiverName(); }
+    static const char const* name() { return "GetPluginProcessConnection"; }
+
     struct DelayedReply : public ThreadSafeRefCounted<DelayedReply> {
         DelayedReply(PassRefPtr<CoreIPC::Connection>, PassOwnPtr<CoreIPC::ArgumentEncoder>);
         ~DelayedReply();
@@ -487,6 +524,9 @@
 
 struct TestMultipleAttributes : CoreIPC::Arguments0 {
     static const Kind messageID = TestMultipleAttributesID;
+    static const char const* receiverName() { return messageReceiverName(); }
+    static const char const* name() { return "TestMultipleAttributes"; }
+
     struct DelayedReply : public ThreadSafeRefCounted<DelayedReply> {
         DelayedReply(PassRefPtr<CoreIPC::Connection>, PassOwnPtr<CoreIPC::ArgumentEncoder>);
         ~DelayedReply();
@@ -504,6 +544,9 @@
 
 struct TestConnectionQueue : CoreIPC::Arguments1<uint64_t> {
     static const Kind messageID = TestConnectionQueueID;
+    static const char const* receiverName() { return messageReceiverName(); }
+    static const char const* name() { return "TestConnectionQueue"; }
+
     typedef CoreIPC::Arguments1<uint64_t> DecodeType;
     explicit TestConnectionQueue(uint64_t pluginID)
         : CoreIPC::Arguments1<uint64_t>(pluginID)
@@ -513,6 +556,9 @@
 
 struct TestParameterAttributes : CoreIPC::Arguments3<uint64_t, double, double> {
     static const Kind messageID = TestParameterAttributesID;
+    static const char const* receiverName() { return messageReceiverName(); }
+    static const char const* name() { return "TestParameterAttributes"; }
+
     typedef CoreIPC::Arguments3<uint64_t, double, double> DecodeType;
     TestParameterAttributes(uint64_t foo, double bar, double baz)
         : CoreIPC::Arguments3<uint64_t, double, double>(foo, bar, baz)
@@ -523,6 +569,9 @@
 #if PLATFORM(MAC)
 struct DidCreateWebProcessConnection : CoreIPC::Arguments1<const CoreIPC::MachPort&> {
     static const Kind messageID = DidCreateWebProcessConnectionID;
+    static const char const* receiverName() { return messageReceiverName(); }
+    static const char const* name() { return "DidCreateWebProcessConnection"; }
+
     typedef CoreIPC::Arguments1<const CoreIPC::MachPort&> DecodeType;
     explicit DidCreateWebProcessConnection(const CoreIPC::MachPort& connectionIdentifier)
         : CoreIPC::Arguments1<const CoreIPC::MachPort&>(connectionIdentifier)
@@ -534,6 +583,9 @@
 #if PLATFORM(MAC)
 struct InterpretKeyEvent : CoreIPC::Arguments1<uint32_t> {
     static const Kind messageID = InterpretKeyEventID;
+    static const char const* receiverName() { return messageReceiverName(); }
+    static const char const* name() { return "InterpretKeyEvent"; }
+
     typedef CoreIPC::Arguments1<Vector<WebCore::KeypressCommand>&> Reply;
     typedef CoreIPC::Arguments1<uint32_t> DecodeType;
     explicit InterpretKeyEvent(uint32_t type)
@@ -546,6 +598,9 @@
 #if ENABLE(DEPRECATED_FEATURE)
 struct DeprecatedOperation : CoreIPC::Arguments1<const CoreIPC::DummyType&> {
     static const Kind messageID = DeprecatedOperationID;
+    static const char const* receiverName() { return messageReceiverName(); }
+    static const char const* name() { return "DeprecatedOperation"; }
+
     typedef CoreIPC::Arguments1<const CoreIPC::DummyType&> DecodeType;
     explicit DeprecatedOperation(const CoreIPC::DummyType& dummy)
         : CoreIPC::Arguments1<const CoreIPC::DummyType&>(dummy)
@@ -557,6 +612,9 @@
 #if ENABLE(EXPERIMENTAL_FEATURE)
 struct ExperimentalOperation : CoreIPC::Arguments1<const CoreIPC::DummyType&> {
     static const Kind messageID = ExperimentalOperationID;
+    static const char const* receiverName() { return messageReceiverName(); }
+    static const char const* name() { return "ExperimentalOperation"; }
+
     typedef CoreIPC::Arguments1<const CoreIPC::DummyType&> DecodeType;
     explicit ExperimentalOperation(const CoreIPC::DummyType& dummy)
         : CoreIPC::Arguments1<const CoreIPC::DummyType&>(dummy)
@@ -566,7 +624,6 @@
 #endif
 
 } // namespace WebPage
-
 } // namespace Messages
 
 namespace CoreIPC {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to