Changeset 84173 in webkit
- Timestamp:
- Apr 18, 2011 1:04:57 PM (13 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r84153 r84173 1 2011-04-18 Anders Carlsson <andersca@apple.com> 2 3 Reviewed by Adam Roben. 4 5 Finish implementing delayed sync replies in the CoreIPC message generator 6 https://bugs.webkit.org/show_bug.cgi?id=58814 7 8 Put the DelayedReply function definitions in the .cpp file and fix bugs found by 9 actually trying to compile the generated files. 10 11 * Scripts/webkit2/messages.py: 12 * Scripts/webkit2/messages_unittest.py: 13 1 14 2011-04-18 Anders Carlsson <andersca@apple.com> 2 15 -
trunk/Source/WebKit2/Scripts/webkit2/messages.py
r83350 r84173 95 95 if attributes_string: 96 96 attributes = frozenset(attributes_string.split()) 97 delayed = "Delayed" in attributes97 is_delayed = "Delayed" in attributes 98 98 dispatch_on_connection_queue = "DispatchOnConnectionQueue" in attributes 99 99 else: 100 delayed = False100 is_delayed = False 101 101 dispatch_on_connection_queue = False 102 102 … … 108 108 reply_parameters = None 109 109 110 messages.append(Message(name, parameters, reply_parameters, delayed, dispatch_on_connection_queue, condition))110 messages.append(Message(name, parameters, reply_parameters, is_delayed, dispatch_on_connection_queue, condition)) 111 111 return MessageReceiver(destination, messages, master_condition) 112 112 113 113 114 114 class Message(object): 115 def __init__(self, name, parameters, reply_parameters, delayed, dispatch_on_connection_queue, condition):115 def __init__(self, name, parameters, reply_parameters, is_delayed, dispatch_on_connection_queue, condition): 116 116 self.name = name 117 117 self.parameters = parameters 118 118 self.reply_parameters = reply_parameters 119 119 if self.reply_parameters is not None: 120 self. delayed =delayed120 self.is_delayed = is_delayed 121 121 self.dispatch_on_connection_queue = dispatch_on_connection_queue 122 122 self.condition = condition … … 225 225 result.append(' static const Kind messageID = %s;\n' % message.id()) 226 226 if message.reply_parameters != None: 227 if message. delayed:227 if message.is_delayed: 228 228 send_parameters = [(function_parameter_type(x.type), x.name) for x in message.reply_parameters] 229 result.append(' struct DelayedReply {\n') 230 result.append(' DelayedReply(PassRefPtr<CoreIPC::Connection> connection, PassOwnPtr<CoreIPC::ArgumentDecoder> arguments)\n') 231 result.append(' : m_connection(connection)\n') 232 result.append(' , m_arguments(arguments)\n') 233 result.append(' {\n') 234 result.append(' }\n') 229 result.append(' struct DelayedReply : public ThreadSafeRefCounted<DelayedReply> {\n') 230 result.append(' DelayedReply(PassRefPtr<CoreIPC::Connection>, PassOwnPtr<CoreIPC::ArgumentEncoder>);\n') 231 result.append(' ~DelayedReply();\n') 235 232 result.append('\n') 236 result.append(' bool send(%s)\n' % ', '.join([' '.join(x) for x in send_parameters])) 237 result.append(' {\n') 238 result.append(' ASSERT(m_arguments);\n') 239 result += [' m_arguments->encode(%s);\n' % x.name for x in message.reply_parameters] 240 result.append(' bool result = m_connection->sendSyncReply(m_arguments.release());\n') 241 result.append(' m_connection = nullptr;\n') 242 result.append(' return result;\n') 243 result.append(' }\n') 233 result.append(' bool send(%s);\n' % ', '.join([' '.join(x) for x in send_parameters])) 244 234 result.append('\n') 245 235 result.append(' private:\n') 246 236 result.append(' RefPtr<CoreIPC::Connection> m_connection;\n') 247 result.append(' OwnPtr<CoreIPC::Argument Decoder> m_arguments;\n')237 result.append(' OwnPtr<CoreIPC::ArgumentEncoder> m_arguments;\n') 248 238 result.append(' };\n\n') 249 else: 250 239 240 result.append(' typedef %s Reply;\n' % reply_type(message)) 251 241 252 242 result.append(' typedef %s DecodeType;\n' % decode_type(message)) … … 310 300 ]) 311 301 302 for message in receiver.messages: 303 if message.reply_parameters != None and message.is_delayed: 304 headers.add('<wtf/ThreadSafeRefCounted.h>') 305 types_by_namespace['CoreIPC'].update(['ArgumentEncoder', 'Connection']) 306 312 307 for parameter in receiver.iterparameters(): 313 308 type = parameter.type … … 396 391 def sync_case_statement(receiver, message): 397 392 dispatch_function = 'handleMessage' 393 if message.is_delayed: 394 dispatch_function += 'Delayed' 398 395 if message.is_variadic: 399 396 dispatch_function += 'Variadic' … … 401 398 result = [] 402 399 result.append(' case Messages::%s::%s:\n' % (receiver.name, message.id())) 403 result.append(' CoreIPC::%s<Messages::%s::%s>(arguments, reply, this, &%s);\n' % (dispatch_function, receiver.name, message.name, handler_function(receiver, message))) 404 # FIXME: Handle delayed replies 405 result.append(' return CoreIPC::AutomaticReply;\n') 400 result.append(' CoreIPC::%s<Messages::%s::%s>(%sarguments, reply, this, &%s);\n' % (dispatch_function, receiver.name, message.name, 'connection, ' if message.is_delayed else '', handler_function(receiver, message))) 401 402 if message.is_delayed: 403 result.append(' return CoreIPC::ManualReply;\n') 404 else: 405 result.append(' return CoreIPC::AutomaticReply;\n') 406 406 407 return surround_in_condition(''.join(result), message.condition) 407 408 … … 530 531 result.append('\n') 531 532 533 sync_delayed_messages = [] 534 for message in receiver.messages: 535 if message.reply_parameters != None and message.is_delayed: 536 sync_delayed_messages.append(message) 537 538 if sync_delayed_messages: 539 result.append('namespace Messages {\n\nnamespace %s {\n\n' % receiver.name) 540 541 for message in sync_delayed_messages: 542 send_parameters = [(function_parameter_type(x.type), x.name) for x in message.reply_parameters] 543 544 result.append('%s::DelayedReply::DelayedReply(PassRefPtr<CoreIPC::Connection> connection, PassOwnPtr<CoreIPC::ArgumentEncoder> arguments)\n' % message.name) 545 result.append(' : m_connection(connection)\n') 546 result.append(' , m_arguments(arguments)\n') 547 result.append('{\n') 548 result.append('}\n') 549 result.append('\n') 550 result.append('%s::DelayedReply::~DelayedReply()\n' % message.name) 551 result.append('{\n') 552 result.append(' ASSERT(!m_connection);\n') 553 result.append('}\n') 554 result.append('\n') 555 result.append('bool %s::DelayedReply::send(%s)\n' % (message.name, ', '.join([' '.join(x) for x in send_parameters]))) 556 result.append('{\n') 557 result.append(' ASSERT(m_arguments);\n') 558 result += [' m_arguments->encode(%s);\n' % x.name for x in message.reply_parameters] 559 result.append(' bool result = m_connection->sendSyncReply(m_arguments.release());\n') 560 result.append(' m_connection = nullptr;\n') 561 result.append(' return result;\n') 562 result.append('}\n') 563 result.append('\n') 564 565 result.append('} // namespace %s\n\n} // namespace Messages\n\n' % receiver.name) 566 532 567 result.append('namespace WebKit {\n\n') 533 568 … … 553 588 if sync_messages: 554 589 result.append('\n') 555 result.append('CoreIPC::SyncReplyMode %s::didReceiveSync%sMessage(CoreIPC::Connection* , CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments, CoreIPC::ArgumentEncoder* reply)\n' % (receiver.name, receiver.name))590 result.append('CoreIPC::SyncReplyMode %s::didReceiveSync%sMessage(CoreIPC::Connection*%s, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments, CoreIPC::ArgumentEncoder* reply)\n' % (receiver.name, receiver.name, ' connection' if sync_delayed_messages else '')) 556 591 result.append('{\n') 557 592 result.append(' switch (messageID.get<Messages::%s::Kind>()) {\n' % receiver.name) -
trunk/Source/WebKit2/Scripts/webkit2/messages_unittest.py
r83350 r84173 271 271 #include <WebCore/KeyboardEvent.h> 272 272 #include <WebCore/PluginData.h> 273 #include <wtf/ThreadSafeRefCounted.h> 273 274 #include <wtf/Vector.h> 274 275 275 276 namespace CoreIPC { 277 class ArgumentEncoder; 278 class Connection; 276 279 class MachPort; 277 280 } … … 406 409 struct GetPluginProcessConnection : CoreIPC::Arguments1<const WTF::String&> { 407 410 static const Kind messageID = GetPluginProcessConnectionID; 408 struct DelayedReply { 409 DelayedReply(PassRefPtr<CoreIPC::Connection> connection, PassOwnPtr<CoreIPC::ArgumentDecoder> arguments) 410 : m_connection(connection) 411 , m_arguments(arguments) 412 { 413 } 414 415 bool send(const CoreIPC::Connection::Handle& connectionHandle) 416 { 417 ASSERT(m_arguments); 418 m_arguments->encode(connectionHandle); 419 bool result = m_connection->sendSyncReply(m_arguments.release()); 420 m_connection = nullptr; 421 return result; 422 } 411 struct DelayedReply : public ThreadSafeRefCounted<DelayedReply> { 412 DelayedReply(PassRefPtr<CoreIPC::Connection>, PassOwnPtr<CoreIPC::ArgumentEncoder>); 413 ~DelayedReply(); 414 415 bool send(const CoreIPC::Connection::Handle& connectionHandle); 423 416 424 417 private: 425 418 RefPtr<CoreIPC::Connection> m_connection; 426 OwnPtr<CoreIPC::Argument Decoder> m_arguments;419 OwnPtr<CoreIPC::ArgumentEncoder> m_arguments; 427 420 }; 428 421 422 typedef CoreIPC::Arguments1<CoreIPC::Connection::Handle&> Reply; 429 423 typedef CoreIPC::Arguments1<const WTF::String&> DecodeType; 430 424 explicit GetPluginProcessConnection(const WTF::String& pluginPath) … … 436 430 struct TestMultipleAttributes : CoreIPC::Arguments0 { 437 431 static const Kind messageID = TestMultipleAttributesID; 438 struct DelayedReply { 439 DelayedReply(PassRefPtr<CoreIPC::Connection> connection, PassOwnPtr<CoreIPC::ArgumentDecoder> arguments) 440 : m_connection(connection) 441 , m_arguments(arguments) 442 { 443 } 444 445 bool send() 446 { 447 ASSERT(m_arguments); 448 bool result = m_connection->sendSyncReply(m_arguments.release()); 449 m_connection = nullptr; 450 return result; 451 } 432 struct DelayedReply : public ThreadSafeRefCounted<DelayedReply> { 433 DelayedReply(PassRefPtr<CoreIPC::Connection>, PassOwnPtr<CoreIPC::ArgumentEncoder>); 434 ~DelayedReply(); 435 436 bool send(); 452 437 453 438 private: 454 439 RefPtr<CoreIPC::Connection> m_connection; 455 OwnPtr<CoreIPC::Argument Decoder> m_arguments;440 OwnPtr<CoreIPC::ArgumentEncoder> m_arguments; 456 441 }; 457 442 443 typedef CoreIPC::Arguments0 Reply; 458 444 typedef CoreIPC::Arguments0 DecodeType; 459 445 }; … … 548 534 #include "WebPreferencesStore.h" 549 535 536 namespace Messages { 537 538 namespace WebPage { 539 540 GetPluginProcessConnection::DelayedReply::DelayedReply(PassRefPtr<CoreIPC::Connection> connection, PassOwnPtr<CoreIPC::ArgumentEncoder> arguments) 541 : m_connection(connection) 542 , m_arguments(arguments) 543 { 544 } 545 546 GetPluginProcessConnection::DelayedReply::~DelayedReply() 547 { 548 ASSERT(!m_connection); 549 } 550 551 bool GetPluginProcessConnection::DelayedReply::send(const CoreIPC::Connection::Handle& connectionHandle) 552 { 553 ASSERT(m_arguments); 554 m_arguments->encode(connectionHandle); 555 bool result = m_connection->sendSyncReply(m_arguments.release()); 556 m_connection = nullptr; 557 return result; 558 } 559 560 TestMultipleAttributes::DelayedReply::DelayedReply(PassRefPtr<CoreIPC::Connection> connection, PassOwnPtr<CoreIPC::ArgumentEncoder> arguments) 561 : m_connection(connection) 562 , m_arguments(arguments) 563 { 564 } 565 566 TestMultipleAttributes::DelayedReply::~DelayedReply() 567 { 568 ASSERT(!m_connection); 569 } 570 571 bool TestMultipleAttributes::DelayedReply::send() 572 { 573 ASSERT(m_arguments); 574 bool result = m_connection->sendSyncReply(m_arguments.release()); 575 m_connection = nullptr; 576 return result; 577 } 578 579 } // namespace WebPage 580 581 } // namespace Messages 582 550 583 namespace WebKit { 551 584 … … 588 621 } 589 622 590 CoreIPC::SyncReplyMode WebPage::didReceiveSyncWebPageMessage(CoreIPC::Connection* , CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments, CoreIPC::ArgumentEncoder* reply)623 CoreIPC::SyncReplyMode WebPage::didReceiveSyncWebPageMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments, CoreIPC::ArgumentEncoder* reply) 591 624 { 592 625 switch (messageID.get<Messages::WebPage::Kind>()) { … … 601 634 return CoreIPC::AutomaticReply; 602 635 case Messages::WebPage::GetPluginProcessConnectionID: 603 CoreIPC::handleMessage <Messages::WebPage::GetPluginProcessConnection>(arguments, reply, this, &WebPage::getPluginProcessConnection);604 return CoreIPC:: AutomaticReply;636 CoreIPC::handleMessageDelayed<Messages::WebPage::GetPluginProcessConnection>(connection, arguments, reply, this, &WebPage::getPluginProcessConnection); 637 return CoreIPC::ManualReply; 605 638 case Messages::WebPage::TestMultipleAttributesID: 606 CoreIPC::handleMessage <Messages::WebPage::TestMultipleAttributes>(arguments, reply, this, &WebPage::testMultipleAttributes);607 return CoreIPC:: AutomaticReply;639 CoreIPC::handleMessageDelayed<Messages::WebPage::TestMultipleAttributes>(connection, arguments, reply, this, &WebPage::testMultipleAttributes); 640 return CoreIPC::ManualReply; 608 641 #if PLATFORM(MAC) 609 642 case Messages::WebPage::InterpretKeyEventID:
Note: See TracChangeset
for help on using the changeset viewer.