Diff
Modified: trunk/Source/WebKit/ChangeLog (292532 => 292533)
--- trunk/Source/WebKit/ChangeLog 2022-04-07 13:28:51 UTC (rev 292532)
+++ trunk/Source/WebKit/ChangeLog 2022-04-07 13:34:59 UTC (rev 292533)
@@ -1,3 +1,54 @@
+2022-04-07 Kimmo Kinnunen <[email protected]>
+
+ IPC::Connection should support diverting all messages to a message queue in other thread
+ https://bugs.webkit.org/show_bug.cgi?id=238608
+
+ Reviewed by Simon Fraser.
+
+ Previously, it was possible to divert all messages to certain ReceiverName to
+ a message queue. This is used in IPC streams functionality.
+
+ Add a possibility to divert all messages to a message queue. Instead of
+ passing ReceiverName, id pair to Connection, pass new struct ReceiverMatcher.
+ Use ReceiverMatcher instead of pair optional<ReceiverName>, optional<id>, since
+ nullopt, id is not a valid case.
+ This will be used in future patch for the case where IPC::Connection is created for
+ the sole purpose of using it together with IPC stream connection.
+ This also clarifies the overloaded use of destinationID 0 as a wildcard as well as
+ a valid message destination.
+
+ Also implement the possibility to divert all messages to particular ReceiverName,
+ id 0. Previously this was signifying the destination ID wildcard.
+
+ No new tests, refactor.
+
+ * Platform/IPC/Connection.cpp:
+ (IPC::Connection::SyncMessageState::enqueueMatchingMessages):
+ (IPC::Connection::enqueueMatchingMessagesToMessageReceiveQueue):
+ (IPC::Connection::addMessageReceiveQueue):
+ (IPC::Connection::removeMessageReceiveQueue):
+ (IPC::Connection::addWorkQueueMessageReceiver):
+ (IPC::Connection::removeWorkQueueMessageReceiver):
+ (IPC::Connection::addThreadMessageReceiver):
+ (IPC::Connection::removeThreadMessageReceiver):
+ * Platform/IPC/Connection.h:
+ * Platform/IPC/Decoder.h:
+ (IPC::Decoder::matches const):
+ * Platform/IPC/MessageReceiveQueueMap.cpp:
+ (IPC::MessageReceiveQueueMap::addImpl):
+ (IPC::MessageReceiveQueueMap::remove):
+ (IPC::MessageReceiveQueueMap::get const):
+ * Platform/IPC/MessageReceiveQueueMap.h:
+ (IPC::MessageReceiveQueueMap::add):
+ * Platform/IPC/ReceiverMatcher.h: Copied from Source/WebKit/Platform/IPC/MessageReceiveQueueMap.h.
+ (IPC::ReceiverMatcher::ReceiverMatcher):
+ (IPC::ReceiverMatcher::createForLegacyAPI):
+ (IPC::ReceiverMatcher::matches const):
+ * Platform/IPC/StreamServerConnection.cpp:
+ (IPC::StreamServerConnectionBase::startReceivingMessagesImpl):
+ (IPC::StreamServerConnectionBase::stopReceivingMessagesImpl):
+ * WebKit.xcodeproj/project.pbxproj:
+
2022-04-07 Carlos Garcia Campos <[email protected]>
Unreviewed. Fix GTK build after r292506
Modified: trunk/Source/WebKit/Platform/IPC/Connection.cpp (292532 => 292533)
--- trunk/Source/WebKit/Platform/IPC/Connection.cpp 2022-04-07 13:28:51 UTC (rev 292532)
+++ trunk/Source/WebKit/Platform/IPC/Connection.cpp 2022-04-07 13:34:59 UTC (rev 292533)
@@ -99,7 +99,7 @@
void dispatchMessages(Function<void(MessageName, uint64_t)>&& willDispatchMessage = { });
// Add matching pending messages to the provided MessageReceiveQueue.
- void enqueueMatchingMessages(Connection&, MessageReceiveQueue&, ReceiverName, uint64_t destinationID);
+ void enqueueMatchingMessages(Connection&, MessageReceiveQueue&, const ReceiverMatcher&);
private:
friend class LazyNeverDestroyed<Connection::SyncMessageState>;
@@ -141,13 +141,13 @@
return syncMessageState;
}
-void Connection::SyncMessageState::enqueueMatchingMessages(Connection& connection, MessageReceiveQueue& receiveQueue, ReceiverName receiverName, uint64_t destinationID)
+void Connection::SyncMessageState::enqueueMatchingMessages(Connection& connection, MessageReceiveQueue& receiveQueue, const ReceiverMatcher& receiverMatcher)
{
ASSERT(isMainRunLoop());
auto enqueueMatchingMessagesInContainer = [&](Deque<ConnectionAndIncomingMessage>& connectionAndMessages) {
Deque<ConnectionAndIncomingMessage> rest;
for (auto& connectionAndMessage : connectionAndMessages) {
- if (connectionAndMessage.connection.ptr() == &connection && connectionAndMessage.message->messageReceiverName() == receiverName && (connectionAndMessage.message->destinationID() == destinationID || !destinationID))
+ if (connectionAndMessage.connection.ptr() == &connection && connectionAndMessage.message->matches(receiverMatcher))
receiveQueue.enqueueMessage(connection, WTFMove(connectionAndMessage.message));
else
rest.append(WTFMove(connectionAndMessage));
@@ -340,15 +340,15 @@
// Enqueue any pending message to the MessageReceiveQueue that is meant to go on that queue. This is important to maintain the ordering of
// IPC messages as some messages may get received on the IPC thread before the message receiver registered itself on the main thread.
-void Connection::enqueueMatchingMessagesToMessageReceiveQueue(MessageReceiveQueue& receiveQueue, ReceiverName receiverName, uint64_t destinationID)
+void Connection::enqueueMatchingMessagesToMessageReceiveQueue(MessageReceiveQueue& receiveQueue, const ReceiverMatcher& receiverMatcher)
{
ASSERT(isMainRunLoop());
- SyncMessageState::singleton().enqueueMatchingMessages(*this, receiveQueue, receiverName, destinationID);
+ SyncMessageState::singleton().enqueueMatchingMessages(*this, receiveQueue, receiverMatcher);
Deque<std::unique_ptr<Decoder>> remainingIncomingMessages;
for (auto& message : m_incomingMessages) {
- if (message->messageReceiverName() == receiverName && (message->destinationID() == destinationID || !destinationID))
+ if (message->matches(receiverMatcher))
receiveQueue.enqueueMessage(*this, WTFMove(message));
else
remainingIncomingMessages.append(WTFMove(message));
@@ -356,33 +356,46 @@
m_incomingMessages = WTFMove(remainingIncomingMessages);
}
-void Connection::addMessageReceiveQueue(MessageReceiveQueue& receiveQueue, ReceiverName receiverName, uint64_t destinationID)
+void Connection::addMessageReceiveQueue(MessageReceiveQueue& receiveQueue, const ReceiverMatcher& receiverMatcher)
{
Locker incomingMessagesLocker { m_incomingMessagesLock };
- enqueueMatchingMessagesToMessageReceiveQueue(receiveQueue, receiverName, destinationID);
- m_receiveQueues.add(receiveQueue, receiverName, destinationID);
+ enqueueMatchingMessagesToMessageReceiveQueue(receiveQueue, receiverMatcher);
+ m_receiveQueues.add(receiveQueue, receiverMatcher);
}
+void Connection::removeMessageReceiveQueue(const ReceiverMatcher& receiverMatcher)
+{
+ Locker locker { m_incomingMessagesLock };
+ m_receiveQueues.remove(receiverMatcher);
+}
+
void Connection::addWorkQueueMessageReceiver(ReceiverName receiverName, WorkQueue& workQueue, WorkQueueMessageReceiver& receiver, uint64_t destinationID)
{
+ auto receiverMatcher = ReceiverMatcher::createWithZeroAsAnyDestination(receiverName, destinationID);
+
auto receiveQueue = makeUnique<WorkQueueMessageReceiverQueue>(workQueue, receiver);
Locker incomingMessagesLocker { m_incomingMessagesLock };
- enqueueMatchingMessagesToMessageReceiveQueue(*receiveQueue, receiverName, destinationID);
- m_receiveQueues.add(WTFMove(receiveQueue), receiverName, destinationID);
+ enqueueMatchingMessagesToMessageReceiveQueue(*receiveQueue, receiverMatcher);
+ m_receiveQueues.add(WTFMove(receiveQueue), receiverMatcher);
}
+void Connection::removeWorkQueueMessageReceiver(ReceiverName receiverName, uint64_t destinationID)
+{
+ removeMessageReceiveQueue(ReceiverMatcher::createWithZeroAsAnyDestination(receiverName, destinationID));
+}
+
void Connection::addThreadMessageReceiver(ReceiverName receiverName, ThreadMessageReceiver* receiver, uint64_t destinationID)
{
+ auto receiverMatcher = ReceiverMatcher::createWithZeroAsAnyDestination(receiverName, destinationID);
auto receiveQueue = makeUnique<ThreadMessageReceiverQueue>(*receiver);
Locker incomingMessagesLocker { m_incomingMessagesLock };
- enqueueMatchingMessagesToMessageReceiveQueue(*receiveQueue, receiverName, destinationID);
- m_receiveQueues.add(WTFMove(receiveQueue), receiverName, destinationID);
+ enqueueMatchingMessagesToMessageReceiveQueue(*receiveQueue, receiverMatcher);
+ m_receiveQueues.add(WTFMove(receiveQueue), receiverMatcher);
}
-void Connection::removeMessageReceiveQueue(ReceiverName receiverName, uint64_t destinationID)
+void Connection::removeThreadMessageReceiver(ReceiverName receiverName, uint64_t destinationID)
{
- Locker locker { m_incomingMessagesLock };
- m_receiveQueues.remove(receiverName, destinationID);
+ removeMessageReceiveQueue(ReceiverMatcher::createWithZeroAsAnyDestination(receiverName, destinationID));
}
void Connection::dispatchMessageReceiverMessage(MessageReceiver& messageReceiver, std::unique_ptr<Decoder>&& decoder)
Modified: trunk/Source/WebKit/Platform/IPC/Connection.h (292532 => 292533)
--- trunk/Source/WebKit/Platform/IPC/Connection.h 2022-04-07 13:28:51 UTC (rev 292532)
+++ trunk/Source/WebKit/Platform/IPC/Connection.h 2022-04-07 13:34:59 UTC (rev 292533)
@@ -32,6 +32,7 @@
#include "Encoder.h"
#include "MessageReceiveQueueMap.h"
#include "MessageReceiver.h"
+#include "ReceiverMatcher.h"
#include "Timeout.h"
#include <wtf/CompletionHandler.h>
#include <wtf/Condition.h>
@@ -235,19 +236,21 @@
// Adds a message receive queue. The client should make sure the instance is removed before it goes
// out of scope.
- void addMessageReceiveQueue(MessageReceiveQueue&, ReceiverName, uint64_t destinationID = 0);
+ // std::nullopt ReceiverMatchSpec matches all receivers.
+ void addMessageReceiveQueue(MessageReceiveQueue&, const ReceiverMatcher&);
+ void removeMessageReceiveQueue(const ReceiverMatcher&);
- void removeMessageReceiveQueue(ReceiverName, uint64_t destinationID = 0);
-
// Adds a message receieve queue that dispatches through WorkQueue to WorkQueueMessageReceiver.
// Keeps the WorkQueue and the WorkQueueMessageReceiver alive. Dispatched tasks keep WorkQueueMessageReceiver alive.
+ // destinationID == 0 matches all ids.
void addWorkQueueMessageReceiver(ReceiverName, WorkQueue&, WorkQueueMessageReceiver&, uint64_t destinationID = 0);
- void removeWorkQueueMessageReceiver(ReceiverName receiverName, uint64_t destinationID = 0) { removeMessageReceiveQueue(receiverName, destinationID); }
+ void removeWorkQueueMessageReceiver(ReceiverName, uint64_t destinationID = 0);
// Adds a message receieve queue that dispatches through ThreadMessageReceiver.
// Keeps the ThreadMessageReceiver alive. Dispatched tasks keep the ThreadMessageReceiver alive.
+ // destinationID == 0 matches all ids.
void addThreadMessageReceiver(ReceiverName, ThreadMessageReceiver*, uint64_t destinationID = 0);
- void removeThreadMessageReceiver(ReceiverName receiverName, uint64_t destinationID = 0) { removeMessageReceiveQueue(receiverName, destinationID); }
+ void removeThreadMessageReceiver(ReceiverName, uint64_t destinationID = 0);
bool open();
void invalidate();
@@ -351,7 +354,7 @@
void popPendingSyncRequestID(SyncRequestID);
std::unique_ptr<Decoder> waitForSyncReply(SyncRequestID, MessageName, Timeout, OptionSet<SendSyncOption>);
- void enqueueMatchingMessagesToMessageReceiveQueue(MessageReceiveQueue&, ReceiverName, uint64_t destinationID) WTF_REQUIRES_LOCK(m_incomingMessagesLock);
+ void enqueueMatchingMessagesToMessageReceiveQueue(MessageReceiveQueue&, const ReceiverMatcher&) WTF_REQUIRES_LOCK(m_incomingMessagesLock);
// Called on the connection work queue.
void processIncomingMessage(std::unique_ptr<Decoder>);
Modified: trunk/Source/WebKit/Platform/IPC/Decoder.h (292532 => 292533)
--- trunk/Source/WebKit/Platform/IPC/Decoder.h 2022-04-07 13:28:51 UTC (rev 292532)
+++ trunk/Source/WebKit/Platform/IPC/Decoder.h 2022-04-07 13:34:59 UTC (rev 292533)
@@ -27,6 +27,7 @@
#include "Attachment.h"
#include "MessageNames.h"
+#include "ReceiverMatcher.h"
#include <wtf/Function.h>
#include <wtf/OptionSet.h>
#include <wtf/Vector.h>
@@ -62,6 +63,7 @@
ReceiverName messageReceiverName() const { return receiverName(m_messageName); }
MessageName messageName() const { return m_messageName; }
uint64_t destinationID() const { return m_destinationID; }
+ bool matches(const ReceiverMatcher& matcher) const { return matcher.matches(messageReceiverName(), destinationID()); }
bool isSyncMessage() const { return messageIsSync(messageName()); }
ShouldDispatchWhenWaitingForSyncReply shouldDispatchMessageWhenWaitingForSyncReply() const;
Modified: trunk/Source/WebKit/Platform/IPC/MessageReceiveQueueMap.cpp (292532 => 292533)
--- trunk/Source/WebKit/Platform/IPC/MessageReceiveQueueMap.cpp 2022-04-07 13:28:51 UTC (rev 292532)
+++ trunk/Source/WebKit/Platform/IPC/MessageReceiveQueueMap.cpp 2022-04-07 13:34:59 UTC (rev 292533)
@@ -29,44 +29,67 @@
namespace IPC {
-void MessageReceiveQueueMap::addImpl(StoreType&& queue, ReceiverName receiverName, uint64_t destinationID)
+void MessageReceiveQueueMap::addImpl(StoreType&& queue, const ReceiverMatcher& matcher)
{
- auto key = std::make_pair(static_cast<uint8_t>(receiverName), destinationID);
- if (m_queues.contains(key)) {
- // FIXME: This should be an assertion. See webkit.org/b/237674 and webkit.org/b/238391.
- ALWAYS_LOG_WITH_STREAM(stream << "MessageReceiveQueueMap::addImpl - adding duplicate receiver " << static_cast<uint8_t>(receiverName) << " for destination " << destinationID);
+ if (!matcher.receiverName) {
+ ASSERT(!m_anyReceiverQueue);
+ m_anyReceiverQueue = WTFMove(queue);
+ return;
}
- m_queues.add(key, WTFMove(queue));
+ uint8_t receiverName = static_cast<uint8_t>(*matcher.receiverName);
+ if (!matcher.destinationID.has_value()) {
+ auto result = m_anyIDQueues.add(receiverName, WTFMove(queue));
+ if (!result.isNewEntry) {
+ // FIXME: This should be an assertion. See webkit.org/b/237674 and webkit.org/b/238391.
+ ALWAYS_LOG_WITH_STREAM(stream << "MessageReceiveQueueMap::addImpl - adding duplicate any id receiver " << static_cast<uint8_t>(receiverName));
+ }
+ return;
+ }
+ auto result = m_queues.add(std::make_pair(receiverName, *matcher.destinationID), WTFMove(queue));
+ ASSERT_UNUSED(result, result.isNewEntry);
}
-void MessageReceiveQueueMap::remove(ReceiverName receiverName, uint64_t destinationID)
+void MessageReceiveQueueMap::remove(const ReceiverMatcher& matcher)
{
- auto key = std::make_pair(static_cast<uint8_t>(receiverName), destinationID);
- if (!m_queues.contains(key)) {
- // FIXME: This should be an assertion. See webkit.org/b/237674 and webkit.org/b/238391.
- ALWAYS_LOG_WITH_STREAM(stream << "MessageReceiveQueueMap::remove - failed to remove receiver " << static_cast<uint8_t>(receiverName) << " with destination " << destinationID);
+ if (!matcher.receiverName) {
+ ASSERT(m_anyReceiverQueue);
+ m_anyReceiverQueue = nullptr;
+ return;
}
- m_queues.remove(key);
+ uint8_t receiverName = static_cast<uint8_t>(*matcher.receiverName);
+ if (!matcher.destinationID.has_value()) {
+ auto result = m_anyIDQueues.remove(receiverName);
+ if (result) {
+ // FIXME: This should be an assertion. See webkit.org/b/237674 and webkit.org/b/238391.
+ ALWAYS_LOG_WITH_STREAM(stream << "MessageReceiveQueueMap::addImpl - adding duplicate any id receiver " << static_cast<uint8_t>(receiverName));
+ }
+ return;
+ }
+ auto result = m_queues.remove(std::make_pair(receiverName, *matcher.destinationID));
+ ASSERT_UNUSED(result, result);
}
MessageReceiveQueue* MessageReceiveQueueMap::get(const Decoder& message) const
{
- if (m_queues.isEmpty())
- return nullptr;
- auto key = std::make_pair(static_cast<uint8_t>(message.messageReceiverName()), 0);
- auto it = m_queues.find(key);
- if (it == m_queues.end()) {
- key.second = message.destinationID();
- if (key.second)
- it = m_queues.find(key);
+ uint8_t receiverName = static_cast<uint8_t>(message.messageReceiverName());
+ auto queueExtractor = WTF::makeVisitor(
+ [](const std::unique_ptr<MessageReceiveQueue>& queue) { return queue.get(); },
+ [](MessageReceiveQueue* queue) { return queue; }
+ );
+
+ {
+ auto it = m_anyIDQueues.find(receiverName);
+ if (it != m_anyIDQueues.end())
+ return std::visit(queueExtractor, it->value);
}
- if (it == m_queues.end())
- return nullptr;
- return std::visit(
- WTF::makeVisitor(
- [](const std::unique_ptr<MessageReceiveQueue>& queue) { return queue.get(); },
- [](MessageReceiveQueue* queue) { return queue; }
- ), it->value);
+ {
+ auto it = m_queues.find(std::make_pair(receiverName, message.destinationID()));
+ if (it != m_queues.end())
+ return std::visit(queueExtractor, it->value);
+ }
+ if (m_anyReceiverQueue)
+ return std::visit(queueExtractor, *m_anyReceiverQueue);
+ return nullptr;
}
}
Modified: trunk/Source/WebKit/Platform/IPC/MessageReceiveQueueMap.h (292532 => 292533)
--- trunk/Source/WebKit/Platform/IPC/MessageReceiveQueueMap.h 2022-04-07 13:28:51 UTC (rev 292532)
+++ trunk/Source/WebKit/Platform/IPC/MessageReceiveQueueMap.h 2022-04-07 13:34:59 UTC (rev 292533)
@@ -44,17 +44,20 @@
return QueueMap::isValidKey(std::make_pair(static_cast<uint8_t>(message.messageReceiverName()), message.destinationID()));
}
- // Adds a wildcard filter if destinationID == 0.
- void add(MessageReceiveQueue& queue, ReceiverName receiverName, uint64_t destinationID) { addImpl(StoreType(&queue), receiverName, destinationID); }
- void add(std::unique_ptr<MessageReceiveQueue>&& queue, ReceiverName receiverName, uint64_t destinationID) { addImpl(StoreType(WTFMove(queue)), receiverName, destinationID); }
- void remove(ReceiverName, uint64_t destinationID);
+ void add(MessageReceiveQueue& queue, const ReceiverMatcher& matcher) { addImpl(StoreType(&queue), matcher); }
+ void add(std::unique_ptr<MessageReceiveQueue>&& queue, const ReceiverMatcher& matcher) { addImpl(StoreType(WTFMove(queue)), matcher); }
+ void remove(const ReceiverMatcher&);
MessageReceiveQueue* get(const Decoder&) const;
private:
using StoreType = std::variant<MessageReceiveQueue*, std::unique_ptr<MessageReceiveQueue>>;
- void addImpl(StoreType&&, ReceiverName, uint64_t destinationID);
+ void addImpl(StoreType&&, const ReceiverMatcher&);
using QueueMap = HashMap<std::pair<uint8_t, uint64_t>, StoreType>;
+ // Key is ReceiverName. FIXME: make it possible to use ReceiverName.
+ using AnyIDQueueMap = HashMap<uint8_t, StoreType>;
QueueMap m_queues;
+ AnyIDQueueMap m_anyIDQueues;
+ std::optional<StoreType> m_anyReceiverQueue;
};
} // namespace IPC
Copied: trunk/Source/WebKit/Platform/IPC/ReceiverMatcher.h (from rev 292532, trunk/Source/WebKit/Platform/IPC/MessageReceiveQueueMap.h) (0 => 292533)
--- trunk/Source/WebKit/Platform/IPC/ReceiverMatcher.h (rev 0)
+++ trunk/Source/WebKit/Platform/IPC/ReceiverMatcher.h 2022-04-07 13:34:59 UTC (rev 292533)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2022 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+namespace IPC {
+
+struct ReceiverMatcher {
+ // Matches all messages.
+ ReceiverMatcher() = default;
+
+ // Matches message to specific receiver, any destination ID.
+ ReceiverMatcher(ReceiverName receiverName)
+ : receiverName(receiverName)
+ {
+ }
+
+ // Matches message to specific receiver, specific destination ID.
+ // Note: destinationID == 0 matches only 0 ids.
+ ReceiverMatcher(ReceiverName receiverName, uint64_t destinationID)
+ : receiverName(receiverName)
+ , destinationID(destinationID)
+ {
+ }
+
+ // Creates a matcher from parameters where destinationID == 0 means any destintation ID. Deprecated.
+ static ReceiverMatcher createWithZeroAsAnyDestination(ReceiverName receiverName, uint64_t destinationID)
+ {
+ if (destinationID)
+ return ReceiverMatcher { receiverName, destinationID };
+ return ReceiverMatcher { receiverName };
+ }
+
+ bool matches(ReceiverName matchReceiverName, uint64_t matchDestinationID) const
+ {
+ return !receiverName || (*receiverName == matchReceiverName && (!destinationID || *destinationID == matchDestinationID));
+ }
+
+ std::optional<ReceiverName> receiverName;
+ std::optional<uint64_t> destinationID;
+};
+
+}
Modified: trunk/Source/WebKit/Platform/IPC/StreamServerConnection.cpp (292532 => 292533)
--- trunk/Source/WebKit/Platform/IPC/StreamServerConnection.cpp 2022-04-07 13:28:51 UTC (rev 292532)
+++ trunk/Source/WebKit/Platform/IPC/StreamServerConnection.cpp 2022-04-07 13:34:59 UTC (rev 292533)
@@ -49,7 +49,7 @@
// FIXME: Can we avoid synchronous dispatch here by adjusting the assertion in `Connection::enqueueMatchingMessagesToMessageReceiveQueue`?
callOnMainRunLoopAndWait([&] {
- m_connection->addMessageReceiveQueue(*this, receiverName, destinationID);
+ m_connection->addMessageReceiveQueue(*this, { receiverName, destinationID });
});
m_workQueue.addStreamConnection(*this);
}
@@ -57,7 +57,7 @@
void StreamServerConnection::startReceivingMessages(ReceiverName receiverName)
{
callOnMainRunLoopAndWait([&] {
- m_connection->addMessageReceiveQueue(*this, receiverName);
+ m_connection->addMessageReceiveQueue(*this, { receiverName });
});
m_workQueue.addStreamConnection(*this);
}
@@ -64,13 +64,13 @@
void StreamServerConnection::stopReceivingMessages(ReceiverName receiverName)
{
- m_connection->removeMessageReceiveQueue(receiverName);
+ m_connection->removeMessageReceiveQueue({ receiverName });
m_workQueue.removeStreamConnection(*this);
}
void StreamServerConnection::stopReceivingMessages(ReceiverName receiverName, uint64_t destinationID)
{
- m_connection->removeMessageReceiveQueue(receiverName, destinationID);
+ m_connection->removeMessageReceiveQueue({ receiverName, destinationID });
m_workQueue.removeStreamConnection(*this);
auto key = std::make_pair(static_cast<uint8_t>(receiverName), destinationID);
Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (292532 => 292533)
--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2022-04-07 13:28:51 UTC (rev 292532)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2022-04-07 13:34:59 UTC (rev 292533)
@@ -1352,6 +1352,7 @@
7BCF70DE2615D06E00E4FB70 /* ScopedRenderingResourcesRequestCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7BCF70CB2614935E00E4FB70 /* ScopedRenderingResourcesRequestCocoa.mm */; };
7BDDA3192747C0400038659E /* (null) in Headers */ = {isa = PBXBuildFile; };
7BE37F9327C7CA51007A6CD3 /* IPCStreamTesterIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BE37F9227C7C518007A6CD3 /* IPCStreamTesterIdentifier.h */; };
+ 7BE9326327F5C75A00D5FEFB /* ReceiverMatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BE9326227F5C75A00D5FEFB /* ReceiverMatcher.h */; };
7C065F2C1C8CD95F00C2D950 /* WebUserContentControllerDataTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C065F2A1C8CD95F00C2D950 /* WebUserContentControllerDataTypes.h */; };
7C135AA9173B0BCA00586AE2 /* WKPluginInformation.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C135AA7173B0BCA00586AE2 /* WKPluginInformation.h */; settings = {ATTRIBUTES = (Private, ); }; };
7C1BA33E1A4A0E600043E249 /* APIDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C1BA33C1A4A0E600043E249 /* APIDictionary.h */; };
@@ -5522,6 +5523,7 @@
7BE37F9527C7CD90007A6CD3 /* IPCStreamTester.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = IPCStreamTester.cpp; sourceTree = "<group>"; };
7BE726572574F67200E85D98 /* RemoteGraphicsContextGLProxyFunctionsGenerated.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteGraphicsContextGLProxyFunctionsGenerated.cpp; sourceTree = "<group>"; };
7BE72668257680EF00E85D98 /* RemoteGraphicsContextGLCocoa.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteGraphicsContextGLCocoa.cpp; sourceTree = "<group>"; };
+ 7BE9326227F5C75A00D5FEFB /* ReceiverMatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReceiverMatcher.h; sourceTree = "<group>"; };
7C065F291C8CD95F00C2D950 /* WebUserContentControllerDataTypes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebUserContentControllerDataTypes.cpp; sourceTree = "<group>"; };
7C065F2A1C8CD95F00C2D950 /* WebUserContentControllerDataTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebUserContentControllerDataTypes.h; sourceTree = "<group>"; };
7C135AA6173B0BCA00586AE2 /* WKPluginInformation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKPluginInformation.cpp; sourceTree = "<group>"; };
@@ -8342,6 +8344,7 @@
1A3EED0D161A535300AEB4F5 /* MessageReceiverMap.h */,
1AAB0377185A7C6A00EDF501 /* MessageSender.cpp */,
1AAB0378185A7C6A00EDF501 /* MessageSender.h */,
+ 7BE9326227F5C75A00D5FEFB /* ReceiverMatcher.h */,
7BAB110F25DD02B2008FC479 /* ScopedActiveMessageReceiveQueue.h */,
2DC18001D90DDD15FC6991A9 /* SharedBufferCopy.cpp */,
5CC5DB9121488E16006CB8A8 /* SharedBufferCopy.h */,
@@ -14508,6 +14511,7 @@
93B631F327ABAD8000443A44 /* QuotaIncreaseRequestIdentifier.h in Headers */,
93B631F127ABACA900443A44 /* QuotaManager.h in Headers */,
5CB6AE442609799C00B6ED5A /* ReasonSPI.h in Headers */,
+ 7BE9326327F5C75A00D5FEFB /* ReceiverMatcher.h in Headers */,
57FD318222B3515E008D0E8B /* RedirectSOAuthorizationSession.h in Headers */,
9B1229D223FF2BCC008CA751 /* RemoteAudioDestinationIdentifier.h in Headers */,
9B1229CD23FF25F2008CA751 /* RemoteAudioDestinationManager.h in Headers */,