void Connection::dispatchSyncMessage(MessageID messageID, ArgumentDecoder* arguments) { ASSERT(messageID.isSync()); // Decode the sync request ID. uint64_t syncRequestID = 0; if (!arguments->decodeUInt64(syncRequestID) || !syncRequestID) { // We received an invalid sync message. arguments->markInvalid(); return; } // Create our reply encoder. ArgumentEncoder* replyEncoder = ArgumentEncoder::create(syncRequestID).leakPtr(); // Hand off both the decoder and encoder to the client.. SyncReplyMode syncReplyMode = m_client->didReceiveSyncMessage(this, messageID, arguments, replyEncoder); // FIXME: If the message was invalid, we should send back a SyncMessageError. ASSERT(!arguments->isInvalid()); if (syncReplyMode == ManualReply) { // The client will take ownership of the reply encoder and send it at some point in the future. // We won't do anything here. return; } // Send the reply. sendSyncReply(replyEncoder); }
void Connection::dispatchWorkQueueMessageReceiverMessage(WorkQueueMessageReceiver* workQueueMessageReceiver, MessageDecoder* incomingMessageDecoder) { OwnPtr<MessageDecoder> decoder = adoptPtr(incomingMessageDecoder); if (!decoder->isSyncMessage()) { workQueueMessageReceiver->didReceiveMessage(this, *decoder); return; } uint64_t syncRequestID = 0; if (!decoder->decode(syncRequestID) || !syncRequestID) { // We received an invalid sync message. // FIXME: Handle this. decoder->markInvalid(); return; } auto replyEncoder = std::make_unique<MessageEncoder>("IPC", "SyncMessageReply", syncRequestID); // Hand off both the decoder and encoder to the work queue message receiver. workQueueMessageReceiver->didReceiveSyncMessage(this, *decoder, replyEncoder); // FIXME: If the message was invalid, we should send back a SyncMessageError. ASSERT(!decoder->isInvalid()); if (replyEncoder) sendSyncReply(std::move(replyEncoder)); }
void Connection::dispatchMessages() { Vector<IncomingMessage> incomingMessages; { MutexLocker locker(m_incomingMessagesLock); m_incomingMessages.swap(incomingMessages); } // Dispatch messages. for (size_t i = 0; i < incomingMessages.size(); ++i) { // If someone calls invalidate while we're invalidating messages, we should stop. if (!m_client) return; IncomingMessage& message = incomingMessages[i]; OwnPtr<ArgumentDecoder> arguments = message.releaseArguments(); if (message.messageID().isSync()) { // Decode the sync request ID. uint64_t syncRequestID = 0; if (!arguments->decodeUInt64(syncRequestID)) { // FIXME: Handle this case. ASSERT_NOT_REACHED(); } // Create our reply encoder. ArgumentEncoder* replyEncoder = new ArgumentEncoder(syncRequestID); // Hand off both the decoder and encoder to the client.. SyncReplyMode syncReplyMode = m_client->didReceiveSyncMessage(this, message.messageID(), arguments.get(), replyEncoder); // FIXME: If the message was invalid, we should send back a SyncMessageError. ASSERT(!arguments->isInvalid()); if (syncReplyMode == AutomaticReply) { // Send the reply. sendSyncReply(replyEncoder); } else { // The client will take ownership of the reply encoder and send it at some point in the future. // We won't do anything here. } } else m_client->didReceiveMessage(this, message.messageID(), arguments.get()); if (arguments->isInvalid()) m_client->didReceiveInvalidMessage(this, message.messageID()); } }
void Connection::dispatchSyncMessage(MessageDecoder& decoder) { ASSERT(decoder.isSyncMessage()); uint64_t syncRequestID = 0; if (!decoder.decode(syncRequestID) || !syncRequestID) { // We received an invalid sync message. decoder.markInvalid(); return; } auto replyEncoder = std::make_unique<MessageEncoder>("IPC", "SyncMessageReply", syncRequestID); // Hand off both the decoder and encoder to the client. m_client->didReceiveSyncMessage(this, decoder, replyEncoder); // FIXME: If the message was invalid, we should send back a SyncMessageError. ASSERT(!decoder.isInvalid()); if (replyEncoder) sendSyncReply(std::move(replyEncoder)); }