Commit e99e5322 authored by andersca@apple.com's avatar andersca@apple.com

2011-03-26 Anders Carlsson <andersca@apple.com>

        Reviewed by Sam Weinig.

        Factor processing of incoming sync replies out into processIncomingSyncReply
        https://bugs.webkit.org/show_bug.cgi?id=57161

        * Platform/CoreIPC/Connection.cpp:
        (CoreIPC::Connection::sendSyncMessage):
        Pass DispatchMessageEvenWhenWaitingForSyncReply to sendMessage.

        (CoreIPC::Connection::processIncomingSyncReply):
        Move code from processIncomingMessage to here.

        (CoreIPC::Connection::processIncomingMessage):
        Call processIncomingSyncReply.


git-svn-id: svn://svn.chromium.org/blink/trunk@82041 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent b67658d8
2011-03-26 Anders Carlsson <andersca@apple.com>
Reviewed by Sam Weinig.
Factor processing of incoming sync replies out into processIncomingSyncReply
https://bugs.webkit.org/show_bug.cgi?id=57161
* Platform/CoreIPC/Connection.cpp:
(CoreIPC::Connection::sendSyncMessage):
Pass DispatchMessageEvenWhenWaitingForSyncReply to sendMessage.
(CoreIPC::Connection::processIncomingSyncReply):
Move code from processIncomingMessage to here.
(CoreIPC::Connection::processIncomingMessage):
Call processIncomingSyncReply.
2011-03-26 Sam Weinig <sam@webkit.org>
Reviewed by Anders Carlsson.
......
......@@ -346,8 +346,7 @@ PassOwnPtr<ArgumentDecoder> Connection::sendSyncMessage(MessageID messageID, uin
}
// First send the message.
messageID = messageID.messageIDWithAddedFlags(MessageID::DispatchMessageWhenWaitingForSyncReply | MessageID::SyncMessage);
sendMessage(messageID, encoder);
sendMessage(messageID.messageIDWithAddedFlags(MessageID::SyncMessage), encoder, DispatchMessageEvenWhenWaitingForSyncReply);
// Then wait for a reply. Waiting for a reply could involve dispatching incoming sync messages, so
// keep an extra reference to the connection here in case it's invalidated.
......@@ -398,36 +397,41 @@ PassOwnPtr<ArgumentDecoder> Connection::waitForSyncReply(uint64_t syncRequestID,
return 0;
}
void Connection::processIncomingMessage(MessageID messageID, PassOwnPtr<ArgumentDecoder> arguments)
void Connection::processIncomingSyncReply(PassOwnPtr<ArgumentDecoder> arguments)
{
// Check if this is a sync reply.
if (messageID == MessageID(CoreIPCMessage::SyncMessageReply)) {
MutexLocker locker(m_syncReplyStateMutex);
ASSERT(!m_pendingSyncReplies.isEmpty());
MutexLocker locker(m_syncReplyStateMutex);
ASSERT(!m_pendingSyncReplies.isEmpty());
// Go through the stack of sync requests that have pending replies and see which one
// this reply is for.
for (size_t i = m_pendingSyncReplies.size(); i > 0; --i) {
PendingSyncReply& pendingSyncReply = m_pendingSyncReplies[i - 1];
// Go through the stack of sync requests that have pending replies and see which one
// this reply is for.
for (size_t i = m_pendingSyncReplies.size(); i > 0; --i) {
PendingSyncReply& pendingSyncReply = m_pendingSyncReplies[i - 1];
if (pendingSyncReply.syncRequestID != arguments->destinationID())
continue;
if (pendingSyncReply.syncRequestID != arguments->destinationID())
continue;
ASSERT(!pendingSyncReply.replyDecoder);
ASSERT(!pendingSyncReply.replyDecoder);
pendingSyncReply.replyDecoder = arguments.leakPtr();
pendingSyncReply.didReceiveReply = true;
pendingSyncReply.replyDecoder = arguments.leakPtr();
pendingSyncReply.didReceiveReply = true;
// We got a reply to the last send message, wake up the client run loop so it can be processed.
if (i == m_pendingSyncReplies.size())
m_syncMessageState->wakeUpClientRunLoop();
// We got a reply to the last send message, wake up the client run loop so it can be processed.
if (i == m_pendingSyncReplies.size())
m_syncMessageState->wakeUpClientRunLoop();
return;
}
return;
}
// We got a reply for a message we never sent.
// FIXME: Dispatch a didReceiveInvalidMessage callback on the client.
ASSERT_NOT_REACHED();
}
// We got a reply for a message we never sent.
// FIXME: Dispatch a didReceiveInvalidMessage callback on the client.
ASSERT_NOT_REACHED();
void Connection::processIncomingMessage(MessageID messageID, PassOwnPtr<ArgumentDecoder> arguments)
{
// Check if this is a sync reply.
if (messageID == MessageID(CoreIPCMessage::SyncMessageReply)) {
processIncomingSyncReply(arguments);
return;
}
......
......@@ -191,6 +191,8 @@ private:
// Called on the connection work queue.
void processIncomingMessage(MessageID, PassOwnPtr<ArgumentDecoder>);
void processIncomingSyncReply(PassOwnPtr<ArgumentDecoder>);
bool canSendOutgoingMessages() const;
bool platformCanSendOutgoingMessages() const;
void sendOutgoingMessages();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment