Make NetworkRTCProvider receive IPC messages from a background thread
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Jul 2020 07:08:29 +0000 (07:08 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Jul 2020 07:08:29 +0000 (07:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=213557

Reviewed by Geoffrey Garen.

To ensure webrtc packets do not get blocked on the main thread,
we process WebProcess IPC message directly in the socket thread.
For new sockets, we still go through the main thread, to check suspension or proxy values.
For sending packets/setting options/closing sockets, we stay in the background thread.

* DerivedSources-output.xcfilelist:
* DerivedSources.make:
* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::didReceiveMessage):
* NetworkProcess/webrtc/LibWebRTCSocketClient.cpp:
(WebKit::LibWebRTCSocketClient::sendTo):
* NetworkProcess/webrtc/LibWebRTCSocketClient.h:
* NetworkProcess/webrtc/NetworkRTCProvider.cpp:
(WebKit::NetworkRTCProvider::NetworkRTCProvider):
(WebKit::NetworkRTCProvider::close):
(WebKit::NetworkRTCProvider::createSocket):
(WebKit::NetworkRTCProvider::createUDPSocket):
(WebKit::NetworkRTCProvider::createServerTCPSocket):
(WebKit::NetworkRTCProvider::createClientTCPSocket):
(WebKit::NetworkRTCProvider::wrapNewTCPConnection):
(WebKit::NetworkRTCProvider::sendToSocket):
(WebKit::NetworkRTCProvider::closeSocket):
(WebKit::NetworkRTCProvider::setSocketOption):
(WebKit::NetworkRTCProvider::addSocket):
(WebKit::NetworkRTCProvider::takeSocket):
(WebKit::NetworkRTCProvider::newConnection):
(WebKit::NetworkRTCProvider::dispatchToThread):
* NetworkProcess/webrtc/NetworkRTCProvider.h:
(WebKit::NetworkRTCProvider::didReceiveNetworkRTCMonitorMessage):
* NetworkProcess/webrtc/NetworkRTCProvider.messages.in:
* NetworkProcess/webrtc/NetworkRTCSocket.cpp: Removed.
* NetworkProcess/webrtc/NetworkRTCSocket.h: Removed.
* NetworkProcess/webrtc/NetworkRTCSocket.messages.in: Removed.
* SourcesCocoa.txt:
* SourcesGTK.txt:
* SourcesWPE.txt:
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/Network/webrtc/LibWebRTCSocket.cpp:
(WebKit::LibWebRTCSocket::SendTo):
(WebKit::LibWebRTCSocket::Close):
(WebKit::LibWebRTCSocket::SetOption):
(WebKit::LibWebRTCSocket::suspend):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@263789 268f45cc-cd09-0410-ab3c-d52691b4dbfc

19 files changed:
Source/WebKit/CMakeLists.txt
Source/WebKit/ChangeLog
Source/WebKit/DerivedSources-input.xcfilelist
Source/WebKit/DerivedSources-output.xcfilelist
Source/WebKit/DerivedSources.make
Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp
Source/WebKit/NetworkProcess/webrtc/LibWebRTCSocketClient.cpp
Source/WebKit/NetworkProcess/webrtc/LibWebRTCSocketClient.h
Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.cpp
Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.h
Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.messages.in
Source/WebKit/NetworkProcess/webrtc/NetworkRTCSocket.cpp [deleted file]
Source/WebKit/NetworkProcess/webrtc/NetworkRTCSocket.h [deleted file]
Source/WebKit/NetworkProcess/webrtc/NetworkRTCSocket.messages.in [deleted file]
Source/WebKit/SourcesCocoa.txt
Source/WebKit/SourcesGTK.txt
Source/WebKit/SourcesWPE.txt
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Source/WebKit/WebProcess/Network/webrtc/LibWebRTCSocket.cpp

index f2dde12..98c2c81 100644 (file)
@@ -167,7 +167,6 @@ set(WebKit_MESSAGES_IN_FILES
     NetworkProcess/webrtc/NetworkMDNSRegister
     NetworkProcess/webrtc/NetworkRTCMonitor
     NetworkProcess/webrtc/NetworkRTCProvider
-    NetworkProcess/webrtc/NetworkRTCSocket
 
     PluginProcess/PluginControllerProxy
     PluginProcess/PluginProcess
index 86f02b5..599a847 100644 (file)
@@ -1,3 +1,53 @@
+2020-07-01  Youenn Fablet  <youenn@apple.com>
+
+        Make NetworkRTCProvider receive IPC messages from a background thread
+        https://bugs.webkit.org/show_bug.cgi?id=213557
+
+        Reviewed by Geoffrey Garen.
+
+        To ensure webrtc packets do not get blocked on the main thread,
+        we process WebProcess IPC message directly in the socket thread.
+        For new sockets, we still go through the main thread, to check suspension or proxy values.
+        For sending packets/setting options/closing sockets, we stay in the background thread.
+
+        * DerivedSources-output.xcfilelist:
+        * DerivedSources.make:
+        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+        (WebKit::NetworkConnectionToWebProcess::didReceiveMessage):
+        * NetworkProcess/webrtc/LibWebRTCSocketClient.cpp:
+        (WebKit::LibWebRTCSocketClient::sendTo):
+        * NetworkProcess/webrtc/LibWebRTCSocketClient.h:
+        * NetworkProcess/webrtc/NetworkRTCProvider.cpp:
+        (WebKit::NetworkRTCProvider::NetworkRTCProvider):
+        (WebKit::NetworkRTCProvider::close):
+        (WebKit::NetworkRTCProvider::createSocket):
+        (WebKit::NetworkRTCProvider::createUDPSocket):
+        (WebKit::NetworkRTCProvider::createServerTCPSocket):
+        (WebKit::NetworkRTCProvider::createClientTCPSocket):
+        (WebKit::NetworkRTCProvider::wrapNewTCPConnection):
+        (WebKit::NetworkRTCProvider::sendToSocket):
+        (WebKit::NetworkRTCProvider::closeSocket):
+        (WebKit::NetworkRTCProvider::setSocketOption):
+        (WebKit::NetworkRTCProvider::addSocket):
+        (WebKit::NetworkRTCProvider::takeSocket):
+        (WebKit::NetworkRTCProvider::newConnection):
+        (WebKit::NetworkRTCProvider::dispatchToThread):
+        * NetworkProcess/webrtc/NetworkRTCProvider.h:
+        (WebKit::NetworkRTCProvider::didReceiveNetworkRTCMonitorMessage):
+        * NetworkProcess/webrtc/NetworkRTCProvider.messages.in:
+        * NetworkProcess/webrtc/NetworkRTCSocket.cpp: Removed.
+        * NetworkProcess/webrtc/NetworkRTCSocket.h: Removed.
+        * NetworkProcess/webrtc/NetworkRTCSocket.messages.in: Removed.
+        * SourcesCocoa.txt:
+        * SourcesGTK.txt:
+        * SourcesWPE.txt:
+        * WebKit.xcodeproj/project.pbxproj:
+        * WebProcess/Network/webrtc/LibWebRTCSocket.cpp:
+        (WebKit::LibWebRTCSocket::SendTo):
+        (WebKit::LibWebRTCSocket::Close):
+        (WebKit::LibWebRTCSocket::SetOption):
+        (WebKit::LibWebRTCSocket::suspend):
+
 2020-06-30  Sam Weinig  <weinig@apple.com>
 
         Split Color serialization out of Color classes
index 6a29111..098eae5 100644 (file)
@@ -56,7 +56,6 @@ $(PROJECT_DIR)/NetworkProcess/mac/com.apple.WebKit.NetworkProcess.sb.in
 $(PROJECT_DIR)/NetworkProcess/webrtc/NetworkMDNSRegister.messages.in
 $(PROJECT_DIR)/NetworkProcess/webrtc/NetworkRTCMonitor.messages.in
 $(PROJECT_DIR)/NetworkProcess/webrtc/NetworkRTCProvider.messages.in
-$(PROJECT_DIR)/NetworkProcess/webrtc/NetworkRTCSocket.messages.in
 $(PROJECT_DIR)/PluginProcess/PluginControllerProxy.messages.in
 $(PROJECT_DIR)/PluginProcess/PluginProcess.messages.in
 $(PROJECT_DIR)/PluginProcess/WebProcessConnection.messages.in
index bd8933e..33d421b 100644 (file)
@@ -97,9 +97,6 @@ $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/NetworkRTCMonitorMessagesReplies.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/NetworkRTCProviderMessageReceiver.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/NetworkRTCProviderMessages.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/NetworkRTCProviderMessagesReplies.h
-$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/NetworkRTCSocketMessageReceiver.cpp
-$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/NetworkRTCSocketMessages.h
-$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/NetworkRTCSocketMessagesReplies.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/NetworkResourceLoaderMessageReceiver.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/NetworkResourceLoaderMessages.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/NetworkResourceLoaderMessagesReplies.h
index 5f5f25c..dfa7c2b 100644 (file)
@@ -126,7 +126,6 @@ MESSAGE_RECEIVERS = \
        NetworkProcess/NetworkProcess \
        NetworkProcess/NetworkResourceLoader \
        NetworkProcess/webrtc/NetworkMDNSRegister \
-       NetworkProcess/webrtc/NetworkRTCSocket \
        NetworkProcess/webrtc/NetworkRTCProvider \
        NetworkProcess/webrtc/NetworkRTCMonitor \
        NetworkProcess/Cookies/WebCookieManager \
index 6f0ce64..5c192f2 100644 (file)
@@ -39,7 +39,6 @@
 #include "NetworkProcessProxyMessages.h"
 #include "NetworkRTCMonitorMessages.h"
 #include "NetworkRTCProviderMessages.h"
-#include "NetworkRTCSocketMessages.h"
 #include "NetworkResourceLoadParameters.h"
 #include "NetworkResourceLoader.h"
 #include "NetworkResourceLoaderMessages.h"
@@ -215,18 +214,14 @@ void NetworkConnectionToWebProcess::didReceiveMessage(IPC::Connection& connectio
     }
 
 #if USE(LIBWEBRTC)
-    if (decoder.messageReceiverName() == Messages::NetworkRTCSocket::messageReceiverName()) {
-        rtcProvider().didReceiveNetworkRTCSocketMessage(connection, decoder);
+    if (decoder.messageReceiverName() == Messages::NetworkRTCProvider::messageReceiverName()) {
+        rtcProvider().didReceiveMessage(connection, decoder);
         return;
     }
     if (decoder.messageReceiverName() == Messages::NetworkRTCMonitor::messageReceiverName()) {
         rtcProvider().didReceiveNetworkRTCMonitorMessage(connection, decoder);
         return;
     }
-    if (decoder.messageReceiverName() == Messages::NetworkRTCProvider::messageReceiverName()) {
-        rtcProvider().didReceiveMessage(connection, decoder);
-        return;
-    }
 #endif
 #if ENABLE(WEB_RTC)
     if (decoder.messageReceiverName() == Messages::NetworkMDNSRegister::messageReceiverName()) {
index 4e64c11..788340e 100644 (file)
@@ -70,9 +70,9 @@ LibWebRTCSocketClient::LibWebRTCSocketClient(WebCore::LibWebRTCSocketIdentifier
     }
 }
 
-void LibWebRTCSocketClient::sendTo(const WebCore::SharedBuffer& buffer, const rtc::SocketAddress& socketAddress, const rtc::PacketOptions& options)
+void LibWebRTCSocketClient::sendTo(const uint8_t* data, size_t size, const rtc::SocketAddress& socketAddress, const rtc::PacketOptions& options)
 {
-    auto result = m_socket->SendTo(reinterpret_cast<const uint8_t*>(buffer.data()), buffer.size(), socketAddress, options);
+    auto result = m_socket->SendTo(data, size, socketAddress, options);
     RELEASE_LOG_ERROR_IF(result && m_sendError != result, Network, "LibWebRTCSocketClient::sendTo failed with error %d", m_socket->GetError());
     m_sendError = result;
 }
index 8e3f480..3bc74ea 100644 (file)
@@ -49,7 +49,7 @@ private:
     void close() final;
 
     void setOption(int option, int value) final;
-    void sendTo(const WebCore::SharedBuffer&, const rtc::SocketAddress&, const rtc::PacketOptions&) final;
+    void sendTo(const uint8_t*, size_t, const rtc::SocketAddress&, const rtc::PacketOptions&) final;
 
     void signalReadPacket(rtc::AsyncPacketSocket*, const char*, size_t, const rtc::SocketAddress&, const rtc::PacketTime&);
     void signalSentPacket(rtc::AsyncPacketSocket*, const rtc::SentPacket&);
index 979cc53..e8e93c3 100644 (file)
@@ -33,8 +33,9 @@
 #include "Logging.h"
 #include "NetworkConnectionToWebProcess.h"
 #include "NetworkProcess.h"
+#include "NetworkRTCProviderMessages.h"
 #include "NetworkRTCResolver.h"
-#include "NetworkRTCSocket.h"
+#include "RTCPacketOptions.h"
 #include "WebRTCResolverMessages.h"
 #include <WebCore/LibWebRTCMacros.h>
 #include <webrtc/rtc_base/async_packet_socket.h>
@@ -76,6 +77,7 @@ static void doReleaseLogging(rtc::LoggingSeverity severity, const char* message)
 
 NetworkRTCProvider::NetworkRTCProvider(NetworkConnectionToWebProcess& connection)
     : m_connection(&connection)
+    , m_ipcConnection(makeRef(connection.connection()))
     , m_rtcMonitor(*this)
     , m_rtcNetworkThread(createThread())
     , m_packetSocketFactory(makeUniqueRefWithoutFastMallocCheck<rtc::BasicPacketSocketFactory>(m_rtcNetworkThread.get()))
@@ -84,6 +86,7 @@ NetworkRTCProvider::NetworkRTCProvider(NetworkConnectionToWebProcess& connection
 #if !RELEASE_LOG_DISABLED
     rtc::LogMessage::SetLogOutput(WebKit2LogWebRTC.state == WTFLogChannelState::On ? rtc::LS_INFO : rtc::LS_WARNING, doReleaseLogging);
 #endif
+    m_connection->connection().addThreadMessageReceiver(Messages::NetworkRTCProvider::messageReceiverName(), this);
 }
 
 NetworkRTCProvider::~NetworkRTCProvider()
@@ -101,6 +104,7 @@ void NetworkRTCProvider::close()
     while (!m_resolvers.isEmpty())
         stopResolver(*m_resolvers.keys().begin());
 
+    m_connection->connection().removeThreadMessageReceiver(Messages::NetworkRTCProvider::messageReceiverName());
     m_connection = nullptr;
     m_rtcMonitor.stopUpdating();
 
@@ -115,6 +119,7 @@ void NetworkRTCProvider::close()
 
 void NetworkRTCProvider::createSocket(LibWebRTCSocketIdentifier identifier, std::unique_ptr<rtc::AsyncPacketSocket>&& socket, Socket::Type type, Ref<IPC::Connection>&& connection)
 {
+    ASSERT(m_rtcNetworkThread->IsCurrent());
     if (!socket) {
         RELEASE_LOG_ERROR_IF_ALLOWED("createSocket with %u sockets is unable to create a new socket", m_sockets.size());
         connection->send(Messages::LibWebRTCNetwork::SignalClose(identifier, 1), 0);
@@ -125,23 +130,25 @@ void NetworkRTCProvider::createSocket(LibWebRTCSocketIdentifier identifier, std:
 
 void NetworkRTCProvider::createUDPSocket(LibWebRTCSocketIdentifier identifier, const RTCNetwork::SocketAddress& address, uint16_t minPort, uint16_t maxPort)
 {
-    callOnRTCNetworkThread([this, identifier, address = RTCNetwork::isolatedCopy(address.value), minPort, maxPort, connection = makeRef(m_connection->connection())]() mutable {
-        std::unique_ptr<rtc::AsyncPacketSocket> socket(m_packetSocketFactory->CreateUdpSocket(address, minPort, maxPort));
-        createSocket(identifier, WTFMove(socket), Socket::Type::UDP, WTFMove(connection));
-    });
+    ASSERT(m_rtcNetworkThread->IsCurrent());
+    std::unique_ptr<rtc::AsyncPacketSocket> socket(m_packetSocketFactory->CreateUdpSocket(address.value, minPort, maxPort));
+    createSocket(identifier, WTFMove(socket), Socket::Type::UDP, m_ipcConnection.copyRef());
 }
 
 void NetworkRTCProvider::createServerTCPSocket(LibWebRTCSocketIdentifier identifier, const RTCNetwork::SocketAddress& address, uint16_t minPort, uint16_t maxPort, int options)
 {
-    if (!m_isListeningSocketAuthorized) {
-        if (m_connection)
-            m_connection->connection().send(Messages::LibWebRTCNetwork::SignalClose(identifier, 1), 0);
-        return;
-    }
+    ASSERT(m_rtcNetworkThread->IsCurrent());
+    callOnMainThread([this, protectedThis = makeRef(*this), identifier, address, minPort, maxPort, options] {
+        if (!m_isListeningSocketAuthorized) {
+            if (m_connection)
+                m_connection->connection().send(Messages::LibWebRTCNetwork::SignalClose(identifier, 1), 0);
+            return;
+        }
 
-    callOnRTCNetworkThread([this, identifier, address = RTCNetwork::isolatedCopy(address.value), minPort, maxPort, options, connection = makeRef(m_connection->connection())]() mutable {
-        std::unique_ptr<rtc::AsyncPacketSocket> socket(m_packetSocketFactory->CreateServerTcpSocket(address, minPort, maxPort, options));
-        createSocket(identifier, WTFMove(socket), Socket::Type::ServerTCP, WTFMove(connection));
+        callOnRTCNetworkThread([this, identifier, address = RTCNetwork::isolatedCopy(address.value), minPort, maxPort, options, connection = makeRef(m_connection->connection())]() mutable {
+            std::unique_ptr<rtc::AsyncPacketSocket> socket(m_packetSocketFactory->CreateServerTcpSocket(address, minPort, maxPort, options));
+            createSocket(identifier, WTFMove(socket), Socket::Type::ServerTCP, m_ipcConnection.copyRef());
+        });
     });
 }
 
@@ -154,56 +161,91 @@ rtc::ProxyInfo NetworkRTCProvider::proxyInfoFromSession(const RTCNetwork::Socket
 
 void NetworkRTCProvider::createClientTCPSocket(LibWebRTCSocketIdentifier identifier, const RTCNetwork::SocketAddress& localAddress, const RTCNetwork::SocketAddress& remoteAddress, String&& userAgent, int options)
 {
-    auto* session = m_connection->networkSession();
-    if (!session) {
-        m_connection->connection().send(Messages::LibWebRTCNetwork::SignalClose(identifier, 1), 0);
-        return;
-    }
-    callOnRTCNetworkThread([this, identifier, localAddress = RTCNetwork::isolatedCopy(localAddress.value), remoteAddress = RTCNetwork::isolatedCopy(remoteAddress.value), proxyInfo = proxyInfoFromSession(remoteAddress, *session), userAgent = WTFMove(userAgent).isolatedCopy(), options, connection = makeRef(m_connection->connection())]() mutable {
-        rtc::PacketSocketTcpOptions tcpOptions;
-        tcpOptions.opts = options;
-        std::unique_ptr<rtc::AsyncPacketSocket> socket(m_packetSocketFactory->CreateClientTcpSocket(localAddress, remoteAddress, proxyInfo, userAgent.utf8().data(), tcpOptions));
-        createSocket(identifier, WTFMove(socket), Socket::Type::ClientTCP, WTFMove(connection));
+    callOnMainThread([this, protectedThis = makeRef(*this), identifier, localAddress, remoteAddress, userAgent = WTFMove(userAgent).isolatedCopy(), options]() mutable {
+        auto* session = m_connection->networkSession();
+        if (!session) {
+            m_connection->connection().send(Messages::LibWebRTCNetwork::SignalClose(identifier, 1), 0);
+            return;
+        }
+        callOnRTCNetworkThread([this, identifier, localAddress = RTCNetwork::isolatedCopy(localAddress.value), remoteAddress = RTCNetwork::isolatedCopy(remoteAddress.value), proxyInfo = proxyInfoFromSession(remoteAddress, *session), userAgent = WTFMove(userAgent).isolatedCopy(), options, connection = makeRef(m_connection->connection())]() mutable {
+            rtc::PacketSocketTcpOptions tcpOptions;
+            tcpOptions.opts = options;
+            std::unique_ptr<rtc::AsyncPacketSocket> socket(m_packetSocketFactory->CreateClientTcpSocket(localAddress, remoteAddress, proxyInfo, userAgent.utf8().data(), tcpOptions));
+            createSocket(identifier, WTFMove(socket), Socket::Type::ClientTCP, m_ipcConnection.copyRef());
+        });
     });
 }
 
 void NetworkRTCProvider::wrapNewTCPConnection(LibWebRTCSocketIdentifier identifier, LibWebRTCSocketIdentifier newConnectionSocketIdentifier)
 {
-    callOnRTCNetworkThread([this, identifier, newConnectionSocketIdentifier, connection = makeRef(m_connection->connection())]() mutable {
-        auto socket = m_pendingIncomingSockets.take(newConnectionSocketIdentifier);
-        RELEASE_LOG_IF(!socket, WebRTC, "NetworkRTCProvider::wrapNewTCPConnection received an invalid socket identifier");
-        if (socket)
-            addSocket(identifier, makeUnique<LibWebRTCSocketClient>(identifier, *this, WTFMove(socket), Socket::Type::ServerConnectionTCP, WTFMove(connection)));
-    });
+    ASSERT(m_rtcNetworkThread->IsCurrent());
+    auto socket = m_pendingIncomingSockets.take(newConnectionSocketIdentifier);
+    RELEASE_LOG_IF(!socket, WebRTC, "NetworkRTCProvider::wrapNewTCPConnection received an invalid socket identifier");
+    if (socket)
+        addSocket(identifier, makeUnique<LibWebRTCSocketClient>(identifier, *this, WTFMove(socket), Socket::Type::ServerConnectionTCP, m_ipcConnection.copyRef()));
+}
+
+void NetworkRTCProvider::sendToSocket(LibWebRTCSocketIdentifier identifier, const IPC::DataReference& data, RTCNetwork::SocketAddress&& address, RTCPacketOptions&& options)
+{
+    ASSERT(m_rtcNetworkThread->IsCurrent());
+    auto* socket = m_sockets.get(identifier);
+    if (!socket)
+        return;
+
+    socket->sendTo(data.data(), data.size(), address.value, options.options);
+}
+
+void NetworkRTCProvider::closeSocket(LibWebRTCSocketIdentifier identifier)
+{
+    ASSERT(m_rtcNetworkThread->IsCurrent());
+    auto* socket = m_sockets.get(identifier);
+    if (!socket)
+        return;
+    socket->close();
+}
+
+void NetworkRTCProvider::setSocketOption(LibWebRTCSocketIdentifier identifier, int option, int value)
+{
+    ASSERT(m_rtcNetworkThread->IsCurrent());
+    auto* socket = m_sockets.get(identifier);
+    if (!socket)
+        return;
+    socket->setOption(option, value);
 }
 
 void NetworkRTCProvider::addSocket(LibWebRTCSocketIdentifier identifier, std::unique_ptr<Socket>&& socket)
 {
+    ASSERT(m_rtcNetworkThread->IsCurrent());
     m_sockets.add(identifier, WTFMove(socket));
 }
 
 std::unique_ptr<NetworkRTCProvider::Socket> NetworkRTCProvider::takeSocket(LibWebRTCSocketIdentifier identifier)
 {
+    ASSERT(m_rtcNetworkThread->IsCurrent());
     return m_sockets.take(identifier);
 }
 
 void NetworkRTCProvider::newConnection(Socket& serverSocket, std::unique_ptr<rtc::AsyncPacketSocket>&& newSocket)
 {
+    ASSERT(m_rtcNetworkThread->IsCurrent());
     auto incomingSocketIdentifier = LibWebRTCSocketIdentifier::generate();
-    sendFromMainThread([identifier = serverSocket.identifier(), incomingSocketIdentifier, remoteAddress = RTCNetwork::isolatedCopy(newSocket->GetRemoteAddress())](IPC::Connection& connection) {
-        connection.send(Messages::LibWebRTCNetwork::SignalNewConnection(identifier, incomingSocketIdentifier, RTCNetwork::SocketAddress(remoteAddress)), 0);
-    });
+    m_ipcConnection->send(Messages::LibWebRTCNetwork::SignalNewConnection(serverSocket.identifier(), incomingSocketIdentifier, RTCNetwork::SocketAddress(newSocket->GetRemoteAddress())), 0);
     m_pendingIncomingSockets.add(incomingSocketIdentifier, WTFMove(newSocket));
 }
 
-void NetworkRTCProvider::didReceiveNetworkRTCSocketMessage(IPC::Connection& connection, IPC::Decoder& decoder)
+void NetworkRTCProvider::dispatchToThread(Function<void()>&& callback)
 {
-    NetworkRTCSocket(makeObjectIdentifier<LibWebRTCSocketIdentifierType>(decoder.destinationID()), *this).didReceiveMessage(connection, decoder);
+    callOnRTCNetworkThread((WTFMove(callback)));
 }
 
-
-void NetworkRTCProvider::createResolver(LibWebRTCResolverIdentifier identifier, const String& address)
+void NetworkRTCProvider::createResolver(LibWebRTCResolverIdentifier identifier, String&& address)
 {
+    if (!isMainThread()) {
+        callOnMainThread([this, protectedThis = makeRef(*this), identifier, address = WTFMove(address).isolatedCopy()]() mutable {
+            createResolver(identifier, WTFMove(address));
+        });
+        return;
+    }
     WebCore::DNSCompletionHandler completionHandler = [this, identifier](auto&& result) {
         if (!result.has_value()) {
             if (result.error() != WebCore::DNSError::Cancelled)
@@ -234,6 +276,12 @@ void NetworkRTCProvider::createResolver(LibWebRTCResolverIdentifier identifier,
 
 void NetworkRTCProvider::stopResolver(LibWebRTCResolverIdentifier identifier)
 {
+    if (!isMainThread()) {
+        callOnMainThread([this, protectedThis = makeRef(*this), identifier] {
+            stopResolver(identifier);
+        });
+        return;
+    }
 #if PLATFORM(COCOA)
     if (auto resolver = m_resolvers.take(identifier))
         resolver->stop();
@@ -244,6 +292,7 @@ void NetworkRTCProvider::stopResolver(LibWebRTCResolverIdentifier identifier)
 
 void NetworkRTCProvider::closeListeningSockets(Function<void()>&& completionHandler)
 {
+    ASSERT(isMainThread());
     if (!m_isListeningSocketAuthorized) {
         completionHandler();
         return;
@@ -291,14 +340,6 @@ void NetworkRTCProvider::callOnRTCNetworkThread(Function<void()>&& callback)
     m_rtcNetworkThread->Post(RTC_FROM_HERE, this, 1, new NetworkMessageData(*this, WTFMove(callback)));
 }
 
-void NetworkRTCProvider::callSocket(LibWebRTCSocketIdentifier identifier, Function<void(Socket&)>&& callback)
-{
-    callOnRTCNetworkThread([this, identifier, callback = WTFMove(callback)]() {
-        if (auto* socket = m_sockets.get(identifier))
-            callback(*socket);
-    });
-}
-
 void NetworkRTCProvider::sendFromMainThread(Function<void(IPC::Connection&)>&& callback)
 {
     callOnMainThread([provider = makeRef(*this), callback = WTFMove(callback)]() {
index 2ec20d1..6448029 100644 (file)
@@ -27,6 +27,7 @@
 
 #if USE(LIBWEBRTC)
 
+#include "Connection.h"
 #include "LibWebRTCResolverIdentifier.h"
 #include "NetworkRTCMonitor.h"
 #include "RTCNetwork.h"
@@ -56,17 +57,16 @@ class SharedBuffer;
 namespace WebKit {
 class NetworkConnectionToWebProcess;
 class NetworkRTCResolver;
-class NetworkRTCSocket;
 class NetworkSession;
+struct RTCPacketOptions;
 
-class NetworkRTCProvider : public ThreadSafeRefCounted<NetworkRTCProvider>, public rtc::MessageHandler {
+class NetworkRTCProvider : public rtc::MessageHandler, public IPC::Connection::ThreadMessageReceiver {
 public:
     static Ref<NetworkRTCProvider> create(NetworkConnectionToWebProcess& connection) { return adoptRef(*new NetworkRTCProvider(connection)); }
     ~NetworkRTCProvider();
 
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&);
     void didReceiveNetworkRTCMonitorMessage(IPC::Connection& connection, IPC::Decoder& decoder) { m_rtcMonitor.didReceiveMessage(connection, decoder); }
-    void didReceiveNetworkRTCSocketMessage(IPC::Connection&, IPC::Decoder&);
 
     class Socket {
     public:
@@ -78,7 +78,7 @@ public:
 
         virtual void close() = 0;
         virtual void setOption(int option, int value) = 0;
-        virtual void sendTo(const WebCore::SharedBuffer&, const rtc::SocketAddress&, const rtc::PacketOptions&) = 0;
+        virtual void sendTo(const uint8_t*, size_t, const rtc::SocketAddress&, const rtc::PacketOptions&) = 0;
     };
 
     std::unique_ptr<Socket> takeSocket(WebCore::LibWebRTCSocketIdentifier);
@@ -86,7 +86,6 @@ public:
 
     void close();
 
-    void callSocket(WebCore::LibWebRTCSocketIdentifier, Function<void(Socket&)>&&);
     void callOnRTCNetworkThread(Function<void()>&&);
     void sendFromMainThread(Function<void(IPC::Connection&)>&&);
 
@@ -104,8 +103,11 @@ private:
     void createClientTCPSocket(WebCore::LibWebRTCSocketIdentifier, const RTCNetwork::SocketAddress&, const RTCNetwork::SocketAddress&, String&& userAgent, int);
     void createServerTCPSocket(WebCore::LibWebRTCSocketIdentifier, const RTCNetwork::SocketAddress&, uint16_t minPort, uint16_t maxPort, int);
     void wrapNewTCPConnection(WebCore::LibWebRTCSocketIdentifier identifier, WebCore::LibWebRTCSocketIdentifier newConnectionSocketIdentifier);
+    void sendToSocket(WebCore::LibWebRTCSocketIdentifier, const IPC::DataReference&, RTCNetwork::SocketAddress&&, RTCPacketOptions&&);
+    void closeSocket(WebCore::LibWebRTCSocketIdentifier);
+    void setSocketOption(WebCore::LibWebRTCSocketIdentifier, int option, int value);
 
-    void createResolver(LibWebRTCResolverIdentifier, const String&);
+    void createResolver(LibWebRTCResolverIdentifier, String&&);
     void stopResolver(LibWebRTCResolverIdentifier);
 
     void addSocket(WebCore::LibWebRTCSocketIdentifier, std::unique_ptr<Socket>&&);
@@ -114,11 +116,15 @@ private:
 
     void OnMessage(rtc::Message*);
 
+    // IPC::Connection::ThreadMessageReceiver
+    void dispatchToThread(Function<void()>&&) final;
+
     static rtc::ProxyInfo proxyInfoFromSession(const RTCNetwork::SocketAddress&, NetworkSession&);
 
     HashMap<LibWebRTCResolverIdentifier, std::unique_ptr<NetworkRTCResolver>> m_resolvers;
     HashMap<WebCore::LibWebRTCSocketIdentifier, std::unique_ptr<Socket>> m_sockets;
     NetworkConnectionToWebProcess* m_connection;
+    Ref<IPC::Connection> m_ipcConnection;
     bool m_isStarted { true };
 
     NetworkRTCMonitor m_rtcMonitor;
index 018d8b2..8a360af 100644 (file)
@@ -30,6 +30,10 @@ messages -> NetworkRTCProvider {
 
     CreateResolver(WebKit::LibWebRTCResolverIdentifier identifier, String address)
     StopResolver(WebKit::LibWebRTCResolverIdentifier identifier)
+
+    void SendToSocket(WebCore::LibWebRTCSocketIdentifier identifier, IPC::DataReference data, WebKit::RTCNetwork::SocketAddress address, struct WebKit::RTCPacketOptions options)
+    void CloseSocket(WebCore::LibWebRTCSocketIdentifier identifier)
+    void SetSocketOption(WebCore::LibWebRTCSocketIdentifier identifier, int option, int value)
 }
 
 #endif // USE(LIBWEBRTC)
diff --git a/Source/WebKit/NetworkProcess/webrtc/NetworkRTCSocket.cpp b/Source/WebKit/NetworkProcess/webrtc/NetworkRTCSocket.cpp
deleted file mode 100644 (file)
index 820d07b..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2017 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.
- */
-
-#include "config.h"
-#include "NetworkRTCSocket.h"
-
-#if USE(LIBWEBRTC)
-
-#include "DataReference.h"
-#include "NetworkRTCProvider.h"
-#include "RTCPacketOptions.h"
-#include <WebCore/SharedBuffer.h>
-#include <wtf/Function.h>
-
-namespace WebKit {
-
-NetworkRTCSocket::NetworkRTCSocket(WebCore::LibWebRTCSocketIdentifier identifier, NetworkRTCProvider& rtcProvider)
-    : m_identifier(identifier)
-    , m_rtcProvider(rtcProvider)
-{
-}
-
-void NetworkRTCSocket::sendTo(const IPC::DataReference& data, RTCNetwork::SocketAddress&& socketAddress, RTCPacketOptions&& options)
-{
-    auto buffer = WebCore::SharedBuffer::create(data.data(), data.size());
-    m_rtcProvider.callSocket(m_identifier, [buffer = WTFMove(buffer), socketAddress = WTFMove(socketAddress), options = WTFMove(options.options)](auto& socket) {
-        socket.sendTo(buffer.get(), socketAddress.value, options);
-    });
-}
-
-void NetworkRTCSocket::close()
-{
-    m_rtcProvider.callSocket(m_identifier, [](auto& socket) {
-        socket.close();
-    });
-}
-    
-void NetworkRTCSocket::setOption(int option, int value)
-{
-    m_rtcProvider.callSocket(m_identifier, [option, value](auto& socket) {
-        socket.setOption(option, value);
-    });
-}
-
-} // namespace WebKit
-
-#endif // USE(LIBWEBRTC)
diff --git a/Source/WebKit/NetworkProcess/webrtc/NetworkRTCSocket.h b/Source/WebKit/NetworkProcess/webrtc/NetworkRTCSocket.h
deleted file mode 100644 (file)
index 3f1c61e..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2017 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
-
-#if USE(LIBWEBRTC)
-
-#include "RTCNetwork.h"
-
-#include <WebCore/LibWebRTCMacros.h>
-#include <WebCore/LibWebRTCSocketIdentifier.h>
-#include <webrtc/rtc_base/async_packet_socket.h>
-#include <webrtc/rtc_base/third_party/sigslot/sigslot.h>
-
-namespace IPC {
-class Connection;
-class DataReference;
-}
-
-namespace rtc {
-class AsyncPacketSocket;
-class SocketAddress;
-struct PacketOptions;
-struct SentPacket;
-typedef int64_t PacketTime;
-}
-
-namespace WebCore {
-class SharedBuffer;
-}
-
-namespace WebKit {
-
-class NetworkConnectionToWebProcess;
-class NetworkRTCProvider;
-struct RTCPacketOptions;
-
-class NetworkRTCSocket {
-public:
-    NetworkRTCSocket(WebCore::LibWebRTCSocketIdentifier, NetworkRTCProvider&);
-    void didReceiveMessage(IPC::Connection&, IPC::Decoder&);
-private:
-    void sendTo(const IPC::DataReference&, RTCNetwork::SocketAddress&&, RTCPacketOptions&&);
-    void close();
-    void setOption(int option, int value);
-
-    WebCore::LibWebRTCSocketIdentifier m_identifier;
-    NetworkRTCProvider& m_rtcProvider;
-};
-
-} // namespace WebKit
-
-#endif // USE(LIBWEBRTC)
diff --git a/Source/WebKit/NetworkProcess/webrtc/NetworkRTCSocket.messages.in b/Source/WebKit/NetworkProcess/webrtc/NetworkRTCSocket.messages.in
deleted file mode 100644 (file)
index d7a5791..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright (C) 2017 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.
-
-#if USE(LIBWEBRTC)
-
-messages -> NetworkRTCSocket NotRefCounted {
-    void SendTo(IPC::DataReference data, WebKit::RTCNetwork::SocketAddress address, struct WebKit::RTCPacketOptions options)
-    void Close()
-    void SetOption(int option, int value)
-}
-
-#endif // USE(LIBWEBRTC)s
index 2519b7e..ab62a94 100644 (file)
@@ -55,7 +55,6 @@ NetworkProcess/webrtc/NetworkRTCMonitor.cpp
 NetworkProcess/webrtc/NetworkRTCProvider.cpp
 NetworkProcess/webrtc/NetworkRTCResolver.cpp
 NetworkProcess/webrtc/NetworkRTCResolverCocoa.cpp
-NetworkProcess/webrtc/NetworkRTCSocket.cpp
 
 GPUProcess/EntryPoint/Cocoa/XPCService/GPUServiceEntryPoint.mm
 GPUProcess/ios/GPUProcessIOS.mm
index 5167ae9..b20795a 100644 (file)
@@ -49,7 +49,6 @@ NetworkProcess/soup/WebSocketTaskSoup.cpp
 NetworkProcess/webrtc/LibWebRTCSocketClient.cpp
 NetworkProcess/webrtc/NetworkRTCMonitor.cpp
 NetworkProcess/webrtc/NetworkRTCProvider.cpp
-NetworkProcess/webrtc/NetworkRTCSocket.cpp
 
 Platform/IPC/unix/AttachmentUnix.cpp
 Platform/IPC/unix/ConnectionUnix.cpp
index e3f8f47..a940b3d 100644 (file)
@@ -49,7 +49,6 @@ NetworkProcess/soup/WebSocketTaskSoup.cpp
 NetworkProcess/webrtc/LibWebRTCSocketClient.cpp
 NetworkProcess/webrtc/NetworkRTCMonitor.cpp
 NetworkProcess/webrtc/NetworkRTCProvider.cpp
-NetworkProcess/webrtc/NetworkRTCSocket.cpp
 
 Platform/IPC/unix/AttachmentUnix.cpp
 Platform/IPC/unix/ConnectionUnix.cpp
index 69406f6..4c948ac 100644 (file)
                411A8DDB20DDD1AC0060D34F /* WKMockMediaDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = 411A8DD920DDB6050060D34F /* WKMockMediaDevice.h */; settings = {ATTRIBUTES = (Private, ); }; };
                411B22641E371BA6004F7363 /* LibWebRTCNetwork.h in Headers */ = {isa = PBXBuildFile; fileRef = 411B22621E371244004F7363 /* LibWebRTCNetwork.h */; };
                41287D4E225D1ECB009A3E26 /* WebSocketTaskCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 41287D4B225C05C4009A3E26 /* WebSocketTaskCocoa.mm */; };
-               413075AB1DE85F330039EC69 /* NetworkRTCSocket.h in Headers */ = {isa = PBXBuildFile; fileRef = 413075991DE84FB00039EC69 /* NetworkRTCSocket.h */; };
                413075AC1DE85F370039EC69 /* NetworkRTCMonitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 4130759B1DE84FB00039EC69 /* NetworkRTCMonitor.h */; };
                413075AD1DE85F580039EC69 /* LibWebRTCSocket.h in Headers */ = {isa = PBXBuildFile; fileRef = 413075A01DE85EE70039EC69 /* LibWebRTCSocket.h */; };
                413075B01DE85F580039EC69 /* WebRTCMonitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 413075A31DE85EE70039EC69 /* WebRTCMonitor.h */; };
                51F060E01654317F00F3281B /* WebResourceLoaderMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 51F060DE1654317500F3281B /* WebResourceLoaderMessages.h */; };
                51F060E11654318500F3281B /* WebResourceLoaderMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51F060DD1654317500F3281B /* WebResourceLoaderMessageReceiver.cpp */; };
                51F060E11654318500F3281C /* LibWebRTCNetworkMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51F060DD1654317500F3281C /* LibWebRTCNetworkMessageReceiver.cpp */; };
-               51F060E11654318500F3281D /* NetworkRTCSocketMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51F060DD1654317500F3281D /* NetworkRTCSocketMessageReceiver.cpp */; };
                51F060E11654318500F3281E /* NetworkRTCMonitorMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51F060DD1654317500F3281E /* NetworkRTCMonitorMessageReceiver.cpp */; };
                51F060E11654318500F3281F /* WebRTCMonitorMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51F060DD1654317500F3281F /* WebRTCMonitorMessageReceiver.cpp */; };
                51F060E11654318500F3282C /* WebRTCResolverMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51F060DD1654317500F3282C /* WebRTCResolverMessageReceiver.cpp */; };
                41287D4B225C05C4009A3E26 /* WebSocketTaskCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebSocketTaskCocoa.mm; sourceTree = "<group>"; };
                41287D4C225C05C5009A3E26 /* WebSocketTaskCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSocketTaskCocoa.h; sourceTree = "<group>"; };
                41287D4D225C161F009A3E26 /* WebSocketTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSocketTask.h; sourceTree = "<group>"; };
-               413075981DE84FB00039EC69 /* NetworkRTCSocket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkRTCSocket.cpp; sourceTree = "<group>"; };
-               413075991DE84FB00039EC69 /* NetworkRTCSocket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkRTCSocket.h; sourceTree = "<group>"; };
                4130759A1DE84FB00039EC69 /* NetworkRTCMonitor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkRTCMonitor.cpp; sourceTree = "<group>"; };
                4130759B1DE84FB00039EC69 /* NetworkRTCMonitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkRTCMonitor.h; sourceTree = "<group>"; };
                4130759C1DE84FB00039EC69 /* NetworkRTCMonitor.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NetworkRTCMonitor.messages.in; sourceTree = "<group>"; };
-               4130759D1DE84FB00039EC69 /* NetworkRTCSocket.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NetworkRTCSocket.messages.in; sourceTree = "<group>"; };
                4130759F1DE85EE70039EC69 /* WebRTCSocket.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = WebRTCSocket.messages.in; path = Network/webrtc/WebRTCSocket.messages.in; sourceTree = "<group>"; };
                413075A01DE85EE70039EC69 /* LibWebRTCSocket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LibWebRTCSocket.h; path = Network/webrtc/LibWebRTCSocket.h; sourceTree = "<group>"; };
                413075A11DE85EE70039EC69 /* LibWebRTCSocket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LibWebRTCSocket.cpp; path = Network/webrtc/LibWebRTCSocket.cpp; sourceTree = "<group>"; };
                51E949961D761CC700EC9EB9 /* UIGamepadProviderIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UIGamepadProviderIOS.mm; sourceTree = "<group>"; };
                51F060DD1654317500F3281B /* WebResourceLoaderMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = WebResourceLoaderMessageReceiver.cpp; path = DerivedSources/WebKit2/WebResourceLoaderMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
                51F060DD1654317500F3281C /* LibWebRTCNetworkMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = LibWebRTCNetworkMessageReceiver.cpp; path = DerivedSources/WebKit2/LibWebRTCNetworkMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
-               51F060DD1654317500F3281D /* NetworkRTCSocketMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = NetworkRTCSocketMessageReceiver.cpp; path = DerivedSources/WebKit2/NetworkRTCSocketMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
                51F060DD1654317500F3281E /* NetworkRTCMonitorMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = NetworkRTCMonitorMessageReceiver.cpp; path = DerivedSources/WebKit2/NetworkRTCMonitorMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
                51F060DD1654317500F3281F /* WebRTCMonitorMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = WebRTCMonitorMessageReceiver.cpp; path = DerivedSources/WebKit2/WebRTCMonitorMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
                51F060DD1654317500F3282C /* WebRTCResolverMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = WebRTCResolverMessageReceiver.cpp; path = DerivedSources/WebKit2/WebRTCResolverMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
                                4112B5481F9FD3AC00E67875 /* NetworkRTCResolver.h */,
                                4112B5471F9FD3AB00E67986 /* NetworkRTCResolverCocoa.cpp */,
                                4112B5481F9FD3AC00E67986 /* NetworkRTCResolverCocoa.h */,
-                               413075981DE84FB00039EC69 /* NetworkRTCSocket.cpp */,
-                               413075991DE84FB00039EC69 /* NetworkRTCSocket.h */,
-                               4130759D1DE84FB00039EC69 /* NetworkRTCSocket.messages.in */,
                        );
                        path = webrtc;
                        sourceTree = "<group>";
                                E152551917011819003D7ADB /* NetworkResourceLoaderMessages.h */,
                                51F060DD1654317500F3281E /* NetworkRTCMonitorMessageReceiver.cpp */,
                                51F060DD1654317500F3282E /* NetworkRTCProviderMessageReceiver.cpp */,
-                               51F060DD1654317500F3281D /* NetworkRTCSocketMessageReceiver.cpp */,
                                31F060DD1654317500F3281C /* NetworkSocketChannelMessageReceiver.cpp */,
                                5C0B17741E7C879C00E9123C /* NetworkSocketStreamMessageReceiver.cpp */,
                                5C0B17751E7C879C00E9123C /* NetworkSocketStreamMessages.h */,
                                5C1426F01C23F80900D41183 /* NetworkResourceLoadParameters.h in Headers */,
                                413075AC1DE85F370039EC69 /* NetworkRTCMonitor.h in Headers */,
                                41DC45961E3D6E2200B11F51 /* NetworkRTCProvider.h in Headers */,
-                               413075AB1DE85F330039EC69 /* NetworkRTCSocket.h in Headers */,
                                5C20CBA01BB1ECD800895BB1 /* NetworkSession.h in Headers */,
                                532159551DBAE7290054AA3C /* NetworkSessionCocoa.h in Headers */,
                                417915B92257046F00D6F97E /* NetworkSocketChannel.h in Headers */,
                                51F060E11654318500F3281E /* NetworkRTCMonitorMessageReceiver.cpp in Sources */,
                                4176901422FDD41B00B1576D /* NetworkRTCProvider.mm in Sources */,
                                51F060E11654318500F3282E /* NetworkRTCProviderMessageReceiver.cpp in Sources */,
-                               51F060E11654318500F3281D /* NetworkRTCSocketMessageReceiver.cpp in Sources */,
                                31F060E11654318500F3281C /* NetworkSocketChannelMessageReceiver.cpp in Sources */,
                                5C0B17781E7C880E00E9123C /* NetworkSocketStreamMessageReceiver.cpp in Sources */,
                                2D92A790212B6AD400F493FD /* NPIdentifierData.cpp in Sources */,
index e8ee734..ecaeb14 100644 (file)
@@ -31,7 +31,7 @@
 #include "DataReference.h"
 #include "LibWebRTCSocketFactory.h"
 #include "NetworkProcessConnection.h"
-#include "NetworkRTCSocketMessages.h"
+#include "NetworkRTCProviderMessages.h"
 #include "RTCPacketOptions.h"
 #include "WebProcess.h"
 #include <WebCore/SharedBuffer.h>
@@ -136,7 +136,7 @@ int LibWebRTCSocket::SendTo(const void *value, size_t size, const rtc::SocketAdd
         return size;
 
     IPC::DataReference data(static_cast<const uint8_t*>(value), size);
-    connection->send(Messages::NetworkRTCSocket::SendTo { data, RTCNetwork::SocketAddress { address }, RTCPacketOptions { options } }, m_identifier);
+    connection->send(Messages::NetworkRTCProvider::SendToSocket { m_identifier, data, RTCNetwork::SocketAddress { address }, RTCPacketOptions { options } }, 0);
 
     return size;
 }
@@ -149,7 +149,7 @@ int LibWebRTCSocket::Close()
 
     m_state = STATE_CLOSED;
 
-    connection->send(Messages::NetworkRTCSocket::Close(), m_identifier);
+    connection->send(Messages::NetworkRTCProvider::CloseSocket { m_identifier }, 0);
 
     return 0;
 }
@@ -171,7 +171,7 @@ int LibWebRTCSocket::SetOption(rtc::Socket::Option option, int value)
     m_options[option] = value;
 
     if (auto* connection = m_factory.connection())
-        connection->send(Messages::NetworkRTCSocket::SetOption(option, value), m_identifier);
+        connection->send(Messages::NetworkRTCProvider::SetSocketOption { m_identifier, option, value }, 0);
 
     return 0;
 }
@@ -201,7 +201,7 @@ void LibWebRTCSocket::suspend()
         return;
 
     if (auto* connection = m_factory.connection())
-        connection->send(Messages::NetworkRTCSocket::Close { }, m_identifier);
+        connection->send(Messages::NetworkRTCProvider::CloseSocket { m_identifier }, 0);
 }
 
 } // namespace WebKit