Changeset 70833 in webkit


Ignore:
Timestamp:
Oct 28, 2010 6:29:35 PM (13 years ago)
Author:
andersca@apple.com
Message:

Move code to dispatch a sync message out into a separate function
https://bugs.webkit.org/show_bug.cgi?id=48605

Reviewed by Adam Roben.

  • Platform/CoreIPC/Connection.cpp:

(CoreIPC::Connection::dispatchSyncMessage):
Factor code out from dispatchMessage. Handle receiving a message with an invalid reply ID.

(CoreIPC::Connection::dispatchMessages):
Call dispatchSyncMessage.

  • Platform/CoreIPC/Connection.h:
Location:
trunk/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit2/ChangeLog

    r70828 r70833  
     12010-10-28  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Adam Roben.
     4
     5        Move code to dispatch a sync message out into a separate function
     6        https://bugs.webkit.org/show_bug.cgi?id=48605
     7
     8        * Platform/CoreIPC/Connection.cpp:
     9        (CoreIPC::Connection::dispatchSyncMessage):
     10        Factor code out from dispatchMessage. Handle receiving a message with an invalid reply ID.
     11
     12        (CoreIPC::Connection::dispatchMessages):
     13        Call dispatchSyncMessage.
     14
     15        * Platform/CoreIPC/Connection.h:
     16
    1172010-10-28  Anders Carlsson  <andersca@apple.com>
    218
  • trunk/WebKit2/Platform/CoreIPC/Connection.cpp

    r70085 r70833  
    313313}
    314314
     315void Connection::dispatchSyncMessage(MessageID messageID, ArgumentDecoder* arguments)
     316{
     317    ASSERT(messageID.isSync());
     318
     319    // Decode the sync request ID.
     320    uint64_t syncRequestID = 0;
     321
     322    if (!arguments->decodeUInt64(syncRequestID) || !syncRequestID) {
     323        // We received an invalid sync message.
     324        arguments->markInvalid();
     325        return;
     326    }
     327
     328    // Create our reply encoder.
     329    ArgumentEncoder* replyEncoder = new ArgumentEncoder(syncRequestID);
     330   
     331    // Hand off both the decoder and encoder to the client..
     332    SyncReplyMode syncReplyMode = m_client->didReceiveSyncMessage(this, messageID, arguments, replyEncoder);
     333
     334    // FIXME: If the message was invalid, we should send back a SyncMessageError.
     335    ASSERT(!arguments->isInvalid());
     336
     337    if (syncReplyMode == ManualReply) {
     338        // The client will take ownership of the reply encoder and send it at some point in the future.
     339        // We won't do anything here.
     340        return;
     341    }
     342
     343    // Send the reply.
     344    sendSyncReply(replyEncoder);
     345}
     346
    315347void Connection::dispatchMessages()
    316348{
     
    331363        OwnPtr<ArgumentDecoder> arguments = message.releaseArguments();
    332364
    333         if (message.messageID().isSync()) {
    334             // Decode the sync request ID.
    335             uint64_t syncRequestID = 0;
    336 
    337             if (!arguments->decodeUInt64(syncRequestID)) {
    338                 // FIXME: Handle this case.
    339                 ASSERT_NOT_REACHED();
    340             }
    341 
    342             // Create our reply encoder.
    343             ArgumentEncoder* replyEncoder = new ArgumentEncoder(syncRequestID);
    344            
    345             // Hand off both the decoder and encoder to the client..
    346             SyncReplyMode syncReplyMode = m_client->didReceiveSyncMessage(this, message.messageID(), arguments.get(), replyEncoder);
    347            
    348             // FIXME: If the message was invalid, we should send back a SyncMessageError.
    349             ASSERT(!arguments->isInvalid());
    350 
    351             if (syncReplyMode == AutomaticReply) {
    352                 // Send the reply.
    353                 sendSyncReply(replyEncoder);
    354             } else {
    355                 // The client will take ownership of the reply encoder and send it at some point in the future.
    356                 // We won't do anything here.
    357             }
    358         } else
     365        if (message.messageID().isSync())
     366            dispatchSyncMessage(message.messageID(), arguments.get());
     367        else
    359368            m_client->didReceiveMessage(this, message.messageID(), arguments.get());
    360369
  • trunk/WebKit2/Platform/CoreIPC/Connection.h

    r70085 r70833  
    169169    void dispatchConnectionDidClose();
    170170    void dispatchMessages();
    171    
     171    void dispatchSyncMessage(MessageID, ArgumentDecoder*);
     172                             
    172173    Client* m_client;
    173174    bool m_isServer;
Note: See TracChangeset for help on using the changeset viewer.