void PlatformMessagePortChannel::createChannel(PassRefPtr<MessagePort> port1, PassRefPtr<MessagePort> port2) { // Create proxies for each endpoint. RefPtr<PlatformMessagePortChannel> channel1 = PlatformMessagePortChannel::create(); RefPtr<PlatformMessagePortChannel> channel2 = PlatformMessagePortChannel::create(); // Entangle the two endpoints. channel1->setEntangledChannel(channel2); channel2->setEntangledChannel(channel1); // Now entangle the proxies with the appropriate local ports. port1->entangle(MessagePortChannel::create(channel2)); port2->entangle(MessagePortChannel::create(channel1)); }
void MessagePortChannel::createChannel(PassRefPtr<MessagePort> port1, PassRefPtr<MessagePort> port2) { RefPtr<PlatformMessagePortChannel::MessagePortQueue> queue1 = PlatformMessagePortChannel::MessagePortQueue::create(); RefPtr<PlatformMessagePortChannel::MessagePortQueue> queue2 = PlatformMessagePortChannel::MessagePortQueue::create(); auto channel1 = std::make_unique<MessagePortChannel>(PlatformMessagePortChannel::create(queue1, queue2)); auto channel2 = std::make_unique<MessagePortChannel>(PlatformMessagePortChannel::create(queue2, queue1)); channel1->m_channel->m_entangledChannel = channel2->m_channel; channel2->m_channel->m_entangledChannel = channel1->m_channel; port1->entangle(WTF::move(channel2)); port2->entangle(WTF::move(channel1)); }