WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-212276-20200522140417.patch (text/plain), 9.95 KB, created by
Wenson Hsieh
on 2020-05-22 14:04:17 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Wenson Hsieh
Created:
2020-05-22 14:04:17 PDT
Size:
9.95 KB
patch
obsolete
>Subversion Revision: 262047 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 897b8a4c3745f5ecda601a893dced222a3a6bbad..dc6f33e8161fae63cb7adc96d8e5e2012e1a662f 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,42 @@ >+2020-05-22 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ [IPC] Add support for specifying `Async WantsConnection` in message files >+ https://bugs.webkit.org/show_bug.cgi?id=212276 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Augments the IPC message receiver generation script to allow for "Async WantsConnection" in `.message.in` files. >+ Currently, specifying this in a message causes the `connection` argument to be passed twice when handling the >+ IPC message. This is because normal async IPC messages without replies normally don't have the `IPC::Connection` >+ argument, and use the overloaded `handleMessage(Connection& connection, ...)` version of `handleMessage` when >+ `WantsConnection` is specified. >+ >+ However, in the `Async` reply case, we already pass in the `IPC::Connection`. Instead of overloading the method >+ signature, we introduce a different method instead, named `handleMessageAsyncWantsConnection`, which forwards >+ the given `IPC::Connection` along to the member function. >+ >+ Test: TestAsyncMessageWithConnection >+ >+ * Platform/IPC/HandleMessage.h: >+ (IPC::handleMessageAsyncWantsConnection): >+ >+ Add another variant of the message receiver template, for the case where the message receiver wants a connection. >+ This is similar to handleMessageSynchronousWantsConnection, above. >+ >+ * Scripts/test-superclassMessageReceiver.cpp: >+ (Messages::WebPage::TestAsyncMessageWithConnection::callReply): >+ (Messages::WebPage::TestAsyncMessageWithConnection::cancelReply): >+ (Messages::WebPage::TestAsyncMessageWithConnection::send): >+ (WebKit::WebPage::didReceiveMessage): >+ * Scripts/test-superclassMessages.h: >+ (Messages::WebPage::TestAsyncMessageWithConnection::name): >+ (Messages::WebPage::TestAsyncMessageWithConnection::asyncMessageReplyName): >+ (Messages::WebPage::TestAsyncMessageWithConnection::TestAsyncMessageWithConnection): >+ (Messages::WebPage::TestAsyncMessageWithConnection::arguments const): >+ * Scripts/webkit/messages.py: >+ * Scripts/webkit/messages_unittest.py: >+ * Scripts/webkit/test-superclass.messages.in: >+ > 2020-05-21 Sam Weinig <weinig@apple.com> > > Extended Color Cleanup: Move Color coder definitions to Color to allow for future encaspulation improvements >diff --git a/Source/WebKit/Platform/IPC/HandleMessage.h b/Source/WebKit/Platform/IPC/HandleMessage.h >index f27fb626648f0eab8d6f95d41dd6b109d3c8e598..45c52a354aeb12252510d8268cbd7a591459392f 100644 >--- a/Source/WebKit/Platform/IPC/HandleMessage.h >+++ b/Source/WebKit/Platform/IPC/HandleMessage.h >@@ -183,4 +183,29 @@ void handleMessageAsync(Connection& connection, Decoder& decoder, C* object, MF > callMemberFunction(WTFMove(*arguments), WTFMove(completionHandler), object, function); > } > >+template<typename T, typename C, typename MF> >+void handleMessageAsyncWantsConnection(Connection& connection, Decoder& decoder, C* object, MF function) >+{ >+ Optional<uint64_t> listenerID; >+ decoder >> listenerID; >+ if (!listenerID) { >+ decoder.markInvalid(); >+ return; >+ } >+ >+ Optional<typename CodingType<typename T::Arguments>::Type> arguments; >+ decoder >> arguments; >+ if (!arguments) { >+ decoder.markInvalid(); >+ return; >+ } >+ >+ typename T::AsyncReply completionHandler = [listenerID = *listenerID, connection = makeRef(connection)] (auto&&... args) mutable { >+ auto encoder = makeUnique<Encoder>(T::asyncMessageReplyName(), 0); >+ *encoder << listenerID; >+ T::send(WTFMove(encoder), WTFMove(connection), args...); >+ }; >+ callMemberFunction(connection, WTFMove(*arguments), WTFMove(completionHandler), object, function); >+} >+ > } // namespace IPC >diff --git a/Source/WebKit/Scripts/test-superclassMessageReceiver.cpp b/Source/WebKit/Scripts/test-superclassMessageReceiver.cpp >index 17d26941010180fa54aa391e90163426bd9da0fe..89f64c507a2689cc8d42e11f2dc155e521abfb30 100644 >--- a/Source/WebKit/Scripts/test-superclassMessageReceiver.cpp >+++ b/Source/WebKit/Scripts/test-superclassMessageReceiver.cpp >@@ -122,6 +122,33 @@ void TestAsyncMessageWithMultipleArguments::send(std::unique_ptr<IPC::Encoder>&& > > #endif > >+#if ENABLE(TEST_FEATURE) >+ >+void TestAsyncMessageWithConnection::callReply(IPC::Decoder& decoder, CompletionHandler<void(bool&&)>&& completionHandler) >+{ >+ Optional<bool> flag; >+ decoder >> flag; >+ if (!flag) { >+ ASSERT_NOT_REACHED(); >+ cancelReply(WTFMove(completionHandler)); >+ return; >+ } >+ completionHandler(WTFMove(*flag)); >+} >+ >+void TestAsyncMessageWithConnection::cancelReply(CompletionHandler<void(bool&&)>&& completionHandler) >+{ >+ completionHandler(IPC::AsyncReplyError<bool>::create()); >+} >+ >+void TestAsyncMessageWithConnection::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, bool flag) >+{ >+ *encoder << flag; >+ connection.sendSyncReply(WTFMove(encoder)); >+} >+ >+#endif >+ > void TestSyncMessage::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, uint8_t reply) > { > *encoder << reply; >@@ -164,6 +191,12 @@ void WebPage::didReceiveMessage(IPC::Connection& connection, IPC::Decoder& decod > IPC::handleMessageAsync<Messages::WebPage::TestAsyncMessageWithMultipleArguments>(connection, decoder, this, &WebPage::testAsyncMessageWithMultipleArguments); > return; > } >+#endif >+#if ENABLE(TEST_FEATURE) >+ if (decoder.messageName() == Messages::WebPage::TestAsyncMessageWithConnection::name()) { >+ IPC::handleMessageAsyncWantsConnection<Messages::WebPage::TestAsyncMessageWithConnection>(connection, decoder, this, &WebPage::testAsyncMessageWithConnection); >+ return; >+ } > #endif > WebPageBase::didReceiveMessage(connection, decoder); > } >diff --git a/Source/WebKit/Scripts/test-superclassMessages.h b/Source/WebKit/Scripts/test-superclassMessages.h >index de36457b6487d450c2922a3e0b5b096f269cb20c..2206b835a5a49022283323572ec0b8a914405ee7 100644 >--- a/Source/WebKit/Scripts/test-superclassMessages.h >+++ b/Source/WebKit/Scripts/test-superclassMessages.h >@@ -147,6 +147,36 @@ private: > }; > #endif > >+#if ENABLE(TEST_FEATURE) >+class TestAsyncMessageWithConnection { >+public: >+ typedef std::tuple<const int&> Arguments; >+ >+ static IPC::MessageName name() { return IPC::MessageName::WebPage_TestAsyncMessageWithConnection; } >+ static const bool isSync = false; >+ >+ static void callReply(IPC::Decoder&, CompletionHandler<void(bool&&)>&&); >+ static void cancelReply(CompletionHandler<void(bool&&)>&&); >+ static IPC::MessageName asyncMessageReplyName() { return IPC::MessageName::WebPage_TestAsyncMessageWithConnectionReply; } >+ using AsyncReply = TestAsyncMessageWithConnectionAsyncReply; >+ static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, bool flag); >+ using Reply = std::tuple<bool&>; >+ using ReplyArguments = std::tuple<bool>; >+ explicit TestAsyncMessageWithConnection(const int& value) >+ : m_arguments(value) >+ { >+ } >+ >+ const Arguments& arguments() const >+ { >+ return m_arguments; >+ } >+ >+private: >+ Arguments m_arguments; >+}; >+#endif >+ > class TestSyncMessage { > public: > typedef std::tuple<uint32_t> Arguments; >diff --git a/Source/WebKit/Scripts/webkit/messages.py b/Source/WebKit/Scripts/webkit/messages.py >index 19fa71624a932b7b9a155e1d2dfd2ac1173e4a04..3fdd8049d49608baed0ae06e6ebd0714c178692a 100644 >--- a/Source/WebKit/Scripts/webkit/messages.py >+++ b/Source/WebKit/Scripts/webkit/messages.py >@@ -474,7 +474,10 @@ def async_message_statement(receiver, message): > dispatch_function_args.insert(0, 'connection') > > if message.has_attribute(WANTS_CONNECTION_ATTRIBUTE): >- dispatch_function_args.insert(0, 'connection') >+ if message.has_attribute(ASYNC_ATTRIBUTE): >+ dispatch_function += 'WantsConnection' >+ else: >+ dispatch_function_args.insert(0, 'connection') > > result = [] > result.append(' if (decoder.messageName() == Messages::%s::%s::name()) {\n' % (receiver.name, message.name)) >diff --git a/Source/WebKit/Scripts/webkit/messages_unittest.py b/Source/WebKit/Scripts/webkit/messages_unittest.py >index 9744ef58658176344cc293601a2d59d7cc35d0ec..031a77fe6252ee47e7e47d7db0f301be8318ef92 100644 >--- a/Source/WebKit/Scripts/webkit/messages_unittest.py >+++ b/Source/WebKit/Scripts/webkit/messages_unittest.py >@@ -274,6 +274,16 @@ _expected_superclass_results = { > ), > 'conditions': ('ENABLE(TEST_FEATURE)'), > }, >+ { >+ 'name': 'TestAsyncMessageWithConnection', >+ 'parameters': ( >+ ('int', 'value'), >+ ), >+ 'reply_parameters': ( >+ ('bool', 'flag'), >+ ), >+ 'conditions': ('ENABLE(TEST_FEATURE)'), >+ }, > { > 'name': 'TestSyncMessage', > 'parameters': ( >diff --git a/Source/WebKit/Scripts/webkit/test-superclass.messages.in b/Source/WebKit/Scripts/webkit/test-superclass.messages.in >index 6d59532cb57766a21399810550f36c985048f474..0a3102032565b734a0edadf8b1d5d993efe703ec 100644 >--- a/Source/WebKit/Scripts/webkit/test-superclass.messages.in >+++ b/Source/WebKit/Scripts/webkit/test-superclass.messages.in >@@ -26,6 +26,7 @@ messages -> WebPage : WebPageBase { > TestAsyncMessage(enum:bool WebKit::TestTwoStateEnum twoStateEnum) -> (uint64_t result) Async > TestAsyncMessageWithNoArguments() -> () Async > TestAsyncMessageWithMultipleArguments() -> (bool flag, uint64_t value) Async >+ TestAsyncMessageWithConnection(int value) -> (bool flag) Async WantsConnection > #endif > TestSyncMessage(uint32_t param) -> (uint8_t reply) Synchronous > TestSynchronousMessage(bool value) -> (Optional<WebKit::TestClassName> optionalReply) Synchronous
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 212276
: 400074