| Differences between
and this patch
- a/Source/WebKit/ChangeLog +47 lines
Lines 1-3 a/Source/WebKit/ChangeLog_sec1
1
2020-05-01  Youenn Fablet  <youenn@apple.com>
2
3
        Receiving WebRTC network packets should not go through the main thread
4
        https://bugs.webkit.org/show_bug.cgi?id=211290
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        WIP.
9
10
        * DerivedSources-input.xcfilelist:
11
        * DerivedSources-output.xcfilelist:
12
        * DerivedSources.make:
13
        * NetworkProcess/webrtc/LibWebRTCSocketClient.cpp:
14
        (WebKit::LibWebRTCSocketClient::signalReadPacket):
15
        (WebKit::LibWebRTCSocketClient::signalSentPacket):
16
        (WebKit::LibWebRTCSocketClient::signalAddressReady):
17
        (WebKit::LibWebRTCSocketClient::signalConnect):
18
        (WebKit::LibWebRTCSocketClient::signalClose):
19
        * NetworkProcess/webrtc/NetworkRTCProvider.cpp:
20
        (WebKit::NetworkRTCProvider::createSocket):
21
        (WebKit::NetworkRTCProvider::createServerTCPSocket):
22
        (WebKit::NetworkRTCProvider::createClientTCPSocket):
23
        (WebKit::NetworkRTCProvider::newConnection):
24
        (WebKit::NetworkRTCProvider::closeListeningSockets):
25
        * Sources.txt:
26
        * WebKit.xcodeproj/project.pbxproj:
27
        * WebProcess/Network/NetworkProcessConnection.cpp:
28
        (WebKit::NetworkProcessConnection::NetworkProcessConnection):
29
        (WebKit::NetworkProcessConnection::didReceiveMessage):
30
        * WebProcess/Network/webrtc/LibWebRTCNetwork.h:
31
        (WebKit::LibWebRTCNetwork::connection):
32
        (WebKit::LibWebRTCNetwork::~LibWebRTCNetwork):
33
        (WebKit::LibWebRTCNetwork::networkProcessCrashed):
34
        (WebKit::LibWebRTCNetwork::setConnection):
35
        (WebKit::LibWebRTCNetwork::dispatchToThread):
36
        (WebKit::LibWebRTCNetwork::signalAddressReady):
37
        (WebKit::LibWebRTCNetwork::signalReadPacket):
38
        (WebKit::LibWebRTCNetwork::signalSentPacket):
39
        (WebKit::LibWebRTCNetwork::signalConnect):
40
        (WebKit::LibWebRTCNetwork::signalClose):
41
        (WebKit::LibWebRTCNetwork::signalNewConnection):
42
        * WebProcess/Network/webrtc/LibWebRTCNetwork.messages.in: Renamed from Source/WebKit/WebProcess/Network/webrtc/WebRTCSocket.messages.in.
43
        * WebProcess/Network/webrtc/LibWebRTCSocket.h:
44
        * WebProcess/Network/webrtc/LibWebRTCSocketFactory.cpp:
45
        * WebProcess/Network/webrtc/WebRTCSocket.cpp: Removed.
46
        * WebProcess/Network/webrtc/WebRTCSocket.h: Removed.
47
1
2020-05-01  Youenn Fablet  <youenn@apple.com>
48
2020-05-01  Youenn Fablet  <youenn@apple.com>
2
49
3
        Remove AudioMediaStreamTrackRenderer::muted
50
        Remove AudioMediaStreamTrackRenderer::muted
- a/Source/WebKit/DerivedSources-input.xcfilelist +1 lines
Lines 140-145 $(PROJECT_DIR)/WebProcess/Network/NetworkProcessConnection.messages.in a/Source/WebKit/DerivedSources-input.xcfilelist_sec1
140
$(PROJECT_DIR)/WebProcess/Network/WebResourceLoader.messages.in
140
$(PROJECT_DIR)/WebProcess/Network/WebResourceLoader.messages.in
141
$(PROJECT_DIR)/WebProcess/Network/WebSocketChannel.messages.in
141
$(PROJECT_DIR)/WebProcess/Network/WebSocketChannel.messages.in
142
$(PROJECT_DIR)/WebProcess/Network/WebSocketStream.messages.in
142
$(PROJECT_DIR)/WebProcess/Network/WebSocketStream.messages.in
143
$(PROJECT_DIR)/WebProcess/Network/webrtc/LibWebRTCNetwork.messages.in
143
$(PROJECT_DIR)/WebProcess/Network/webrtc/WebMDNSRegister.messages.in
144
$(PROJECT_DIR)/WebProcess/Network/webrtc/WebMDNSRegister.messages.in
144
$(PROJECT_DIR)/WebProcess/Network/webrtc/WebRTCMonitor.messages.in
145
$(PROJECT_DIR)/WebProcess/Network/webrtc/WebRTCMonitor.messages.in
145
$(PROJECT_DIR)/WebProcess/Network/webrtc/WebRTCResolver.messages.in
146
$(PROJECT_DIR)/WebProcess/Network/webrtc/WebRTCResolver.messages.in
- a/Source/WebKit/DerivedSources-output.xcfilelist +3 lines
Lines 57-62 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/LibWebRTCCodecsMessagesReplies.h a/Source/WebKit/DerivedSources-output.xcfilelist_sec1
57
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/LibWebRTCCodecsProxyMessageReceiver.cpp
57
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/LibWebRTCCodecsProxyMessageReceiver.cpp
58
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/LibWebRTCCodecsProxyMessages.h
58
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/LibWebRTCCodecsProxyMessages.h
59
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/LibWebRTCCodecsProxyMessagesReplies.h
59
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/LibWebRTCCodecsProxyMessagesReplies.h
60
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/LibWebRTCNetworkMessageReceiver.cpp
61
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/LibWebRTCNetworkMessages.h
62
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/LibWebRTCNetworkMessagesReplies.h
60
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/LibWebRTCRemoteCodecsMessageReceiver.cpp
63
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/LibWebRTCRemoteCodecsMessageReceiver.cpp
61
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/LibWebRTCRemoteCodecsMessages.h
64
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/LibWebRTCRemoteCodecsMessages.h
62
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/LibWebRTCRemoteCodecsMessagesReplies.h
65
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/LibWebRTCRemoteCodecsMessagesReplies.h
- a/Source/WebKit/DerivedSources.make -1 / +1 lines
Lines 129-134 MESSAGE_RECEIVERS = \ a/Source/WebKit/DerivedSources.make_sec1
129
    LegacyCustomProtocolManagerProxy \
129
    LegacyCustomProtocolManagerProxy \
130
    LibWebRTCCodecs \
130
    LibWebRTCCodecs \
131
    LibWebRTCCodecsProxy \
131
    LibWebRTCCodecsProxy \
132
    LibWebRTCNetwork \
132
    MediaPlayerPrivateRemote \
133
    MediaPlayerPrivateRemote \
133
    NPObjectMessageReceiver \
134
    NPObjectMessageReceiver \
134
    NetworkConnectionToWebProcess \
135
    NetworkConnectionToWebProcess \
Lines 228-234 MESSAGE_RECEIVERS = \ a/Source/WebKit/DerivedSources.make_sec2
228
    WebProcessProxy \
229
    WebProcessProxy \
229
    WebRTCMonitor \
230
    WebRTCMonitor \
230
    WebRTCResolver \
231
    WebRTCResolver \
231
    WebRTCSocket \
232
    WebResourceLoader \
232
    WebResourceLoader \
233
    WebSWClientConnection \
233
    WebSWClientConnection \
234
    WebSWContextManagerConnection \
234
    WebSWContextManagerConnection \
- a/Source/WebKit/NetworkProcess/webrtc/LibWebRTCSocketClient.cpp -6 / +6 lines
Lines 30-38 a/Source/WebKit/NetworkProcess/webrtc/LibWebRTCSocketClient.cpp_sec1
30
30
31
#include "Connection.h"
31
#include "Connection.h"
32
#include "DataReference.h"
32
#include "DataReference.h"
33
#include "LibWebRTCNetworkMessages.h"
33
#include "Logging.h"
34
#include "Logging.h"
34
#include "NetworkRTCProvider.h"
35
#include "NetworkRTCProvider.h"
35
#include "WebRTCSocketMessages.h"
36
#include <WebCore/SharedBuffer.h>
36
#include <WebCore/SharedBuffer.h>
37
#include <wtf/Function.h>
37
#include <wtf/Function.h>
38
38
Lines 100-106 void LibWebRTCSocketClient::signalReadPacket(rtc::AsyncPacketSocket* socket, con a/Source/WebKit/NetworkProcess/webrtc/LibWebRTCSocketClient.cpp_sec2
100
    auto buffer = WebCore::SharedBuffer::create(value, length);
100
    auto buffer = WebCore::SharedBuffer::create(value, length);
101
    m_rtcProvider.sendFromMainThread([identifier = m_identifier, buffer = WTFMove(buffer), address = RTCNetwork::isolatedCopy(address), packetTime](IPC::Connection& connection) {
101
    m_rtcProvider.sendFromMainThread([identifier = m_identifier, buffer = WTFMove(buffer), address = RTCNetwork::isolatedCopy(address), packetTime](IPC::Connection& connection) {
102
        IPC::DataReference data(reinterpret_cast<const uint8_t*>(buffer->data()), buffer->size());
102
        IPC::DataReference data(reinterpret_cast<const uint8_t*>(buffer->data()), buffer->size());
103
        connection.send(Messages::WebRTCSocket::SignalReadPacket(data, RTCNetwork::IPAddress(address.ipaddr()), address.port(), packetTime), identifier);
103
        connection.send(Messages::LibWebRTCNetwork::SignalReadPacket(identifier, data, RTCNetwork::IPAddress(address.ipaddr()), address.port(), packetTime), 0);
104
    });
104
    });
105
}
105
}
106
106
Lines 108-114 void LibWebRTCSocketClient::signalSentPacket(rtc::AsyncPacketSocket* socket, con a/Source/WebKit/NetworkProcess/webrtc/LibWebRTCSocketClient.cpp_sec3
108
{
108
{
109
    ASSERT_UNUSED(socket, m_socket.get() == socket);
109
    ASSERT_UNUSED(socket, m_socket.get() == socket);
110
    m_rtcProvider.sendFromMainThread([identifier = m_identifier, sentPacket](IPC::Connection& connection) {
110
    m_rtcProvider.sendFromMainThread([identifier = m_identifier, sentPacket](IPC::Connection& connection) {
111
        connection.send(Messages::WebRTCSocket::SignalSentPacket(sentPacket.packet_id, sentPacket.send_time_ms), identifier);
111
        connection.send(Messages::LibWebRTCNetwork::SignalSentPacket(identifier, sentPacket.packet_id, sentPacket.send_time_ms), 0);
112
    });
112
    });
113
}
113
}
114
114
Lines 122-128 void LibWebRTCSocketClient::signalAddressReady(rtc::AsyncPacketSocket* socket, c a/Source/WebKit/NetworkProcess/webrtc/LibWebRTCSocketClient.cpp_sec4
122
{
122
{
123
    ASSERT_UNUSED(socket, m_socket.get() == socket);
123
    ASSERT_UNUSED(socket, m_socket.get() == socket);
124
    m_rtcProvider.sendFromMainThread([identifier = m_identifier, address = RTCNetwork::isolatedCopy(address)](IPC::Connection& connection) {
124
    m_rtcProvider.sendFromMainThread([identifier = m_identifier, address = RTCNetwork::isolatedCopy(address)](IPC::Connection& connection) {
125
        connection.send(Messages::WebRTCSocket::SignalAddressReady(RTCNetwork::SocketAddress(address)), identifier);
125
        connection.send(Messages::LibWebRTCNetwork::SignalAddressReady(identifier, RTCNetwork::SocketAddress(address)), 0);
126
    });
126
    });
127
}
127
}
128
128
Lines 135-141 void LibWebRTCSocketClient::signalConnect(rtc::AsyncPacketSocket* socket) a/Source/WebKit/NetworkProcess/webrtc/LibWebRTCSocketClient.cpp_sec5
135
{
135
{
136
    ASSERT_UNUSED(socket, m_socket.get() == socket);
136
    ASSERT_UNUSED(socket, m_socket.get() == socket);
137
    m_rtcProvider.sendFromMainThread([identifier = m_identifier](IPC::Connection& connection) {
137
    m_rtcProvider.sendFromMainThread([identifier = m_identifier](IPC::Connection& connection) {
138
        connection.send(Messages::WebRTCSocket::SignalConnect(), identifier);
138
        connection.send(Messages::LibWebRTCNetwork::SignalConnect(identifier), 0);
139
    });
139
    });
140
}
140
}
141
141
Lines 143-149 void LibWebRTCSocketClient::signalClose(rtc::AsyncPacketSocket* socket, int erro a/Source/WebKit/NetworkProcess/webrtc/LibWebRTCSocketClient.cpp_sec6
143
{
143
{
144
    ASSERT_UNUSED(socket, m_socket.get() == socket);
144
    ASSERT_UNUSED(socket, m_socket.get() == socket);
145
    m_rtcProvider.sendFromMainThread([identifier = m_identifier, error](IPC::Connection& connection) {
145
    m_rtcProvider.sendFromMainThread([identifier = m_identifier, error](IPC::Connection& connection) {
146
        connection.send(Messages::WebRTCSocket::SignalClose(error), identifier);
146
        connection.send(Messages::LibWebRTCNetwork::SignalClose(identifier, error), 0);
147
    });
147
    });
148
    // We want to remove 'this' from the socket map now but we will destroy it asynchronously
148
    // We want to remove 'this' from the socket map now but we will destroy it asynchronously
149
    // so that the socket parameter of signalClose remains alive as the caller of signalClose may actually being using it afterwards.
149
    // so that the socket parameter of signalClose remains alive as the caller of signalClose may actually being using it afterwards.
- a/Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.cpp -6 / +6 lines
Lines 28-33 a/Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.cpp_sec1
28
28
29
#if USE(LIBWEBRTC)
29
#if USE(LIBWEBRTC)
30
30
31
#include "LibWebRTCNetworkMessages.h"
31
#include "LibWebRTCSocketClient.h"
32
#include "LibWebRTCSocketClient.h"
32
#include "Logging.h"
33
#include "Logging.h"
33
#include "NetworkConnectionToWebProcess.h"
34
#include "NetworkConnectionToWebProcess.h"
Lines 35-41 a/Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.cpp_sec2
35
#include "NetworkRTCResolver.h"
36
#include "NetworkRTCResolver.h"
36
#include "NetworkRTCSocket.h"
37
#include "NetworkRTCSocket.h"
37
#include "WebRTCResolverMessages.h"
38
#include "WebRTCResolverMessages.h"
38
#include "WebRTCSocketMessages.h"
39
#include <WebCore/LibWebRTCMacros.h>
39
#include <WebCore/LibWebRTCMacros.h>
40
#include <webrtc/rtc_base/async_packet_socket.h>
40
#include <webrtc/rtc_base/async_packet_socket.h>
41
#include <webrtc/rtc_base/logging.h>
41
#include <webrtc/rtc_base/logging.h>
Lines 118-124 void NetworkRTCProvider::createSocket(LibWebRTCSocketIdentifier identifier, std: a/Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.cpp_sec3
118
    if (!socket) {
118
    if (!socket) {
119
        sendFromMainThread([this, identifier, size = m_sockets.size()](IPC::Connection& connection) {
119
        sendFromMainThread([this, identifier, size = m_sockets.size()](IPC::Connection& connection) {
120
            RELEASE_LOG_ERROR_IF_ALLOWED("createSocket with %u sockets is unable to create a new socket", size);
120
            RELEASE_LOG_ERROR_IF_ALLOWED("createSocket with %u sockets is unable to create a new socket", size);
121
            connection.send(Messages::WebRTCSocket::SignalClose(1), identifier);
121
            connection.send(Messages::LibWebRTCNetwork::SignalClose(identifier, 1), 0);
122
        });
122
        });
123
        return;
123
        return;
124
    }
124
    }
Lines 137-143 void NetworkRTCProvider::createServerTCPSocket(LibWebRTCSocketIdentifier identif a/Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.cpp_sec4
137
{
137
{
138
    if (!m_isListeningSocketAuthorized) {
138
    if (!m_isListeningSocketAuthorized) {
139
        if (m_connection)
139
        if (m_connection)
140
            m_connection->connection().send(Messages::WebRTCSocket::SignalClose(1), identifier);
140
            m_connection->connection().send(Messages::LibWebRTCNetwork::SignalClose(identifier, 1), 0);
141
        return;
141
        return;
142
    }
142
    }
143
143
Lines 158-164 void NetworkRTCProvider::createClientTCPSocket(LibWebRTCSocketIdentifier identif a/Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.cpp_sec5
158
{
158
{
159
    auto* session = m_connection->networkSession();
159
    auto* session = m_connection->networkSession();
160
    if (!session) {
160
    if (!session) {
161
        m_connection->connection().send(Messages::WebRTCSocket::SignalClose(1), identifier);
161
        m_connection->connection().send(Messages::LibWebRTCNetwork::SignalClose(identifier, 1), 0);
162
        return;
162
        return;
163
    }
163
    }
164
    callOnRTCNetworkThread([this, identifier, localAddress = RTCNetwork::isolatedCopy(localAddress.value), remoteAddress = RTCNetwork::isolatedCopy(remoteAddress.value), proxyInfo = proxyInfoFromSession(remoteAddress, *session), userAgent = WTFMove(userAgent).isolatedCopy(), options]() {
164
    callOnRTCNetworkThread([this, identifier, localAddress = RTCNetwork::isolatedCopy(localAddress.value), remoteAddress = RTCNetwork::isolatedCopy(remoteAddress.value), proxyInfo = proxyInfoFromSession(remoteAddress, *session), userAgent = WTFMove(userAgent).isolatedCopy(), options]() {
Lines 193-199 void NetworkRTCProvider::newConnection(Socket& serverSocket, std::unique_ptr<rtc a/Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.cpp_sec6
193
{
193
{
194
    auto incomingSocketIdentifier = LibWebRTCSocketIdentifier::generate();
194
    auto incomingSocketIdentifier = LibWebRTCSocketIdentifier::generate();
195
    sendFromMainThread([identifier = serverSocket.identifier(), incomingSocketIdentifier, remoteAddress = RTCNetwork::isolatedCopy(newSocket->GetRemoteAddress())](IPC::Connection& connection) {
195
    sendFromMainThread([identifier = serverSocket.identifier(), incomingSocketIdentifier, remoteAddress = RTCNetwork::isolatedCopy(newSocket->GetRemoteAddress())](IPC::Connection& connection) {
196
        connection.send(Messages::WebRTCSocket::SignalNewConnection(incomingSocketIdentifier, RTCNetwork::SocketAddress(remoteAddress)), identifier);
196
        connection.send(Messages::LibWebRTCNetwork::SignalNewConnection(identifier, incomingSocketIdentifier, RTCNetwork::SocketAddress(remoteAddress)), 0);
197
    });
197
    });
198
    m_pendingIncomingSockets.add(incomingSocketIdentifier, WTFMove(newSocket));
198
    m_pendingIncomingSockets.add(incomingSocketIdentifier, WTFMove(newSocket));
199
}
199
}
Lines 264-270 void NetworkRTCProvider::closeListeningSockets(Function<void()>&& completionHand a/Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.cpp_sec7
264
        callOnMainThread([provider = makeRef(*this), listeningSocketIdentifiers = WTFMove(listeningSocketIdentifiers), completionHandler = WTFMove(completionHandler)] {
264
        callOnMainThread([provider = makeRef(*this), listeningSocketIdentifiers = WTFMove(listeningSocketIdentifiers), completionHandler = WTFMove(completionHandler)] {
265
            if (provider->m_connection) {
265
            if (provider->m_connection) {
266
                for (auto identifier : listeningSocketIdentifiers)
266
                for (auto identifier : listeningSocketIdentifiers)
267
                    provider->m_connection->connection().send(Messages::WebRTCSocket::SignalClose(ECONNABORTED), identifier);
267
                    provider->m_connection->connection().send(Messages::LibWebRTCNetwork::SignalClose(identifier, ECONNABORTED), 0);
268
            }
268
            }
269
            completionHandler();
269
            completionHandler();
270
        });
270
        });
- a/Source/WebKit/Sources.txt -1 lines
Lines 596-602 WebProcess/Network/webrtc/LibWebRTCSocketFactory.cpp a/Source/WebKit/Sources.txt_sec1
596
WebProcess/Network/webrtc/WebMDNSRegister.cpp
596
WebProcess/Network/webrtc/WebMDNSRegister.cpp
597
WebProcess/Network/webrtc/WebRTCMonitor.cpp
597
WebProcess/Network/webrtc/WebRTCMonitor.cpp
598
WebProcess/Network/webrtc/WebRTCResolver.cpp
598
WebProcess/Network/webrtc/WebRTCResolver.cpp
599
WebProcess/Network/webrtc/WebRTCSocket.cpp
600
599
601
WebProcess/Notifications/NotificationPermissionRequestManager.cpp
600
WebProcess/Notifications/NotificationPermissionRequestManager.cpp
602
WebProcess/Notifications/WebNotificationManager.cpp
601
WebProcess/Notifications/WebNotificationManager.cpp
- a/Source/WebKit/WebKit.xcodeproj/project.pbxproj -4 / +6 lines
Lines 1074-1080 a/Source/WebKit/WebKit.xcodeproj/project.pbxproj_sec1
1074
		51EFC1CF1524E62500C9A938 /* WKBundleDOMWindowExtension.h in Headers */ = {isa = PBXBuildFile; fileRef = 51FA2D541521118600C1BA0B /* WKBundleDOMWindowExtension.h */; settings = {ATTRIBUTES = (Private, ); }; };
1074
		51EFC1CF1524E62500C9A938 /* WKBundleDOMWindowExtension.h in Headers */ = {isa = PBXBuildFile; fileRef = 51FA2D541521118600C1BA0B /* WKBundleDOMWindowExtension.h */; settings = {ATTRIBUTES = (Private, ); }; };
1075
		51F060E01654317F00F3281B /* WebResourceLoaderMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 51F060DE1654317500F3281B /* WebResourceLoaderMessages.h */; };
1075
		51F060E01654317F00F3281B /* WebResourceLoaderMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 51F060DE1654317500F3281B /* WebResourceLoaderMessages.h */; };
1076
		51F060E11654318500F3281B /* WebResourceLoaderMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51F060DD1654317500F3281B /* WebResourceLoaderMessageReceiver.cpp */; };
1076
		51F060E11654318500F3281B /* WebResourceLoaderMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51F060DD1654317500F3281B /* WebResourceLoaderMessageReceiver.cpp */; };
1077
		51F060E11654318500F3281C /* WebRTCSocketMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51F060DD1654317500F3281C /* WebRTCSocketMessageReceiver.cpp */; };
1077
		51F060E11654318500F3281C /* LibWebRTCNetworkMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51F060DD1654317500F3281C /* LibWebRTCNetworkMessageReceiver.cpp */; };
1078
		51F060E11654318500F3281D /* NetworkRTCSocketMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51F060DD1654317500F3281D /* NetworkRTCSocketMessageReceiver.cpp */; };
1078
		51F060E11654318500F3281D /* NetworkRTCSocketMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51F060DD1654317500F3281D /* NetworkRTCSocketMessageReceiver.cpp */; };
1079
		51F060E11654318500F3281E /* NetworkRTCMonitorMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51F060DD1654317500F3281E /* NetworkRTCMonitorMessageReceiver.cpp */; };
1079
		51F060E11654318500F3281E /* NetworkRTCMonitorMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51F060DD1654317500F3281E /* NetworkRTCMonitorMessageReceiver.cpp */; };
1080
		51F060E11654318500F3281F /* WebRTCMonitorMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51F060DD1654317500F3281F /* WebRTCMonitorMessageReceiver.cpp */; };
1080
		51F060E11654318500F3281F /* WebRTCMonitorMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51F060DD1654317500F3281F /* WebRTCMonitorMessageReceiver.cpp */; };
Lines 3429-3434 a/Source/WebKit/WebKit.xcodeproj/project.pbxproj_sec2
3429
		4157E4AF20E2EC9800A6C0D7 /* com.google.o1dbrowserplugin.sb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = com.google.o1dbrowserplugin.sb; sourceTree = "<group>"; };
3429
		4157E4AF20E2EC9800A6C0D7 /* com.google.o1dbrowserplugin.sb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = com.google.o1dbrowserplugin.sb; sourceTree = "<group>"; };
3430
		4158649A23BE092400A0A61E /* RTCEncoderIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCEncoderIdentifier.h; sourceTree = "<group>"; };
3430
		4158649A23BE092400A0A61E /* RTCEncoderIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCEncoderIdentifier.h; sourceTree = "<group>"; };
3431
		416CD74523FB178B00661D99 /* MDNSRegisterIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MDNSRegisterIdentifier.h; path = Network/webrtc/MDNSRegisterIdentifier.h; sourceTree = "<group>"; };
3431
		416CD74523FB178B00661D99 /* MDNSRegisterIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MDNSRegisterIdentifier.h; path = Network/webrtc/MDNSRegisterIdentifier.h; sourceTree = "<group>"; };
3432
		416F8086245B397400B68F02 /* LibWebRTCNetwork.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = LibWebRTCNetwork.messages.in; path = Network/webrtc/LibWebRTCNetwork.messages.in; sourceTree = "<group>"; };
3432
		4172198923B6128200AE5686 /* LibWebRTCCodecs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LibWebRTCCodecs.h; sourceTree = "<group>"; };
3433
		4172198923B6128200AE5686 /* LibWebRTCCodecs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LibWebRTCCodecs.h; sourceTree = "<group>"; };
3433
		4172198A23B6128200AE5686 /* LibWebRTCCodecs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LibWebRTCCodecs.cpp; sourceTree = "<group>"; };
3434
		4172198A23B6128200AE5686 /* LibWebRTCCodecs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LibWebRTCCodecs.cpp; sourceTree = "<group>"; };
3434
		4172198C23B612E800AE5686 /* RTCDecoderIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCDecoderIdentifier.h; sourceTree = "<group>"; };
3435
		4172198C23B612E800AE5686 /* RTCDecoderIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCDecoderIdentifier.h; sourceTree = "<group>"; };
Lines 3811-3817 a/Source/WebKit/WebKit.xcodeproj/project.pbxproj_sec3
3811
		51E8B68D1E712873001B7132 /* WebURLSchemeTask.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebURLSchemeTask.cpp; sourceTree = "<group>"; };
3812
		51E8B68D1E712873001B7132 /* WebURLSchemeTask.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebURLSchemeTask.cpp; sourceTree = "<group>"; };
3812
		51E949961D761CC700EC9EB9 /* UIGamepadProviderIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UIGamepadProviderIOS.mm; sourceTree = "<group>"; };
3813
		51E949961D761CC700EC9EB9 /* UIGamepadProviderIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UIGamepadProviderIOS.mm; sourceTree = "<group>"; };
3813
		51F060DD1654317500F3281B /* WebResourceLoaderMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = WebResourceLoaderMessageReceiver.cpp; path = DerivedSources/WebKit2/WebResourceLoaderMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
3814
		51F060DD1654317500F3281B /* WebResourceLoaderMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = WebResourceLoaderMessageReceiver.cpp; path = DerivedSources/WebKit2/WebResourceLoaderMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
3814
		51F060DD1654317500F3281C /* WebRTCSocketMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = WebRTCSocketMessageReceiver.cpp; path = DerivedSources/WebKit2/WebRTCSocketMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
3815
		51F060DD1654317500F3281C /* LibWebRTCNetworkMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = LibWebRTCNetworkMessageReceiver.cpp; path = DerivedSources/WebKit2/LibWebRTCNetworkMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
3815
		51F060DD1654317500F3281D /* NetworkRTCSocketMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = NetworkRTCSocketMessageReceiver.cpp; path = DerivedSources/WebKit2/NetworkRTCSocketMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
3816
		51F060DD1654317500F3281D /* NetworkRTCSocketMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = NetworkRTCSocketMessageReceiver.cpp; path = DerivedSources/WebKit2/NetworkRTCSocketMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
3816
		51F060DD1654317500F3281E /* NetworkRTCMonitorMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = NetworkRTCMonitorMessageReceiver.cpp; path = DerivedSources/WebKit2/NetworkRTCMonitorMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
3817
		51F060DD1654317500F3281E /* NetworkRTCMonitorMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = NetworkRTCMonitorMessageReceiver.cpp; path = DerivedSources/WebKit2/NetworkRTCMonitorMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
3817
		51F060DD1654317500F3281F /* WebRTCMonitorMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = WebRTCMonitorMessageReceiver.cpp; path = DerivedSources/WebKit2/WebRTCMonitorMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
3818
		51F060DD1654317500F3281F /* WebRTCMonitorMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = WebRTCMonitorMessageReceiver.cpp; path = DerivedSources/WebKit2/WebRTCMonitorMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
Lines 7586-7591 a/Source/WebKit/WebKit.xcodeproj/project.pbxproj_sec4
7586
			isa = PBXGroup;
7587
			isa = PBXGroup;
7587
			children = (
7588
			children = (
7588
				411B22621E371244004F7363 /* LibWebRTCNetwork.h */,
7589
				411B22621E371244004F7363 /* LibWebRTCNetwork.h */,
7590
				416F8086245B397400B68F02 /* LibWebRTCNetwork.messages.in */,
7589
				413075A71DE85EE70039EC69 /* LibWebRTCProvider.cpp */,
7591
				413075A71DE85EE70039EC69 /* LibWebRTCProvider.cpp */,
7590
				413075A81DE85EE70039EC69 /* LibWebRTCProvider.h */,
7592
				413075A81DE85EE70039EC69 /* LibWebRTCProvider.h */,
7591
				41FAF5F71E3C0B47001AE678 /* LibWebRTCResolver.cpp */,
7593
				41FAF5F71E3C0B47001AE678 /* LibWebRTCResolver.cpp */,
Lines 10184-10190 a/Source/WebKit/WebKit.xcodeproj/project.pbxproj_sec5
10184
				51F060DE1654317500F3281B /* WebResourceLoaderMessages.h */,
10186
				51F060DE1654317500F3281B /* WebResourceLoaderMessages.h */,
10185
				51F060DD1654317500F3281F /* WebRTCMonitorMessageReceiver.cpp */,
10187
				51F060DD1654317500F3281F /* WebRTCMonitorMessageReceiver.cpp */,
10186
				51F060DD1654317500F3282C /* WebRTCResolverMessageReceiver.cpp */,
10188
				51F060DD1654317500F3282C /* WebRTCResolverMessageReceiver.cpp */,
10187
				51F060DD1654317500F3281C /* WebRTCSocketMessageReceiver.cpp */,
10189
				51F060DD1654317500F3281C /* LibWebRTCNetworkMessageReceiver.cpp */,
10188
				41F060DD1654317500F3281C /* WebSocketChannelMessageReceiver.cpp */,
10190
				41F060DD1654317500F3281C /* WebSocketChannelMessageReceiver.cpp */,
10189
				5C0B17761E7C879C00E9123C /* WebSocketStreamMessageReceiver.cpp */,
10191
				5C0B17761E7C879C00E9123C /* WebSocketStreamMessageReceiver.cpp */,
10190
				5C0B17771E7C879C00E9123C /* WebSocketStreamMessages.h */,
10192
				5C0B17771E7C879C00E9123C /* WebSocketStreamMessages.h */,
Lines 13021-13027 a/Source/WebKit/WebKit.xcodeproj/project.pbxproj_sec6
13021
				51F060E11654318500F3281B /* WebResourceLoaderMessageReceiver.cpp in Sources */,
13023
				51F060E11654318500F3281B /* WebResourceLoaderMessageReceiver.cpp in Sources */,
13022
				51F060E11654318500F3281F /* WebRTCMonitorMessageReceiver.cpp in Sources */,
13024
				51F060E11654318500F3281F /* WebRTCMonitorMessageReceiver.cpp in Sources */,
13023
				51F060E11654318500F3282C /* WebRTCResolverMessageReceiver.cpp in Sources */,
13025
				51F060E11654318500F3282C /* WebRTCResolverMessageReceiver.cpp in Sources */,
13024
				51F060E11654318500F3281C /* WebRTCSocketMessageReceiver.cpp in Sources */,
13026
				51F060E11654318500F3281C /* LibWebRTCNetworkMessageReceiver.cpp in Sources */,
13025
				41E0A7CB23B645CD00561060 /* WebSocketChannel.cpp in Sources */,
13027
				41E0A7CB23B645CD00561060 /* WebSocketChannel.cpp in Sources */,
13026
				41F060E11654318500F3281C /* WebSocketChannelMessageReceiver.cpp in Sources */,
13028
				41F060E11654318500F3281C /* WebSocketChannelMessageReceiver.cpp in Sources */,
13027
				5C0B17791E7C882100E9123C /* WebSocketStreamMessageReceiver.cpp in Sources */,
13029
				5C0B17791E7C882100E9123C /* WebSocketStreamMessageReceiver.cpp in Sources */,
- a/Source/WebKit/WebProcess/Network/NetworkProcessConnection.cpp -9 / +1 lines
Lines 46-52 a/Source/WebKit/WebProcess/Network/NetworkProcessConnection.cpp_sec1
46
#include "WebRTCMonitor.h"
46
#include "WebRTCMonitor.h"
47
#include "WebRTCMonitorMessages.h"
47
#include "WebRTCMonitorMessages.h"
48
#include "WebRTCResolverMessages.h"
48
#include "WebRTCResolverMessages.h"
49
#include "WebRTCSocketMessages.h"
50
#include "WebResourceLoaderMessages.h"
49
#include "WebResourceLoaderMessages.h"
51
#include "WebSWClientConnection.h"
50
#include "WebSWClientConnection.h"
52
#include "WebSWClientConnectionMessages.h"
51
#include "WebSWClientConnectionMessages.h"
Lines 77-82 NetworkProcessConnection::NetworkProcessConnection(IPC::Connection::Identifier c a/Source/WebKit/WebProcess/Network/NetworkProcessConnection.cpp_sec2
77
    , m_cookieAcceptPolicy(cookieAcceptPolicy)
76
    , m_cookieAcceptPolicy(cookieAcceptPolicy)
78
{
77
{
79
    m_connection->open();
78
    m_connection->open();
79
    WebProcess::singleton().libWebRTCNetwork().setConnection(m_connection.copyRef());
80
}
80
}
81
81
82
NetworkProcessConnection::~NetworkProcessConnection()
82
NetworkProcessConnection::~NetworkProcessConnection()
Lines 112-125 void NetworkProcessConnection::didReceiveMessage(IPC::Connection& connection, IP a/Source/WebKit/WebProcess/Network/NetworkProcessConnection.cpp_sec3
112
    }
112
    }
113
113
114
#if USE(LIBWEBRTC)
114
#if USE(LIBWEBRTC)
115
    if (decoder.messageReceiverName() == Messages::WebRTCSocket::messageReceiverName()) {
116
        auto& network = WebProcess::singleton().libWebRTCNetwork();
117
        if (network.isActive())
118
            network.socket(makeObjectIdentifier<LibWebRTCSocketIdentifierType>(decoder.destinationID())).didReceiveMessage(connection, decoder);
119
        else
120
            RELEASE_LOG_ERROR(WebRTC, "Received WebRTCSocket message while libWebRTCNetwork is not active");
121
        return;
122
    }
123
    if (decoder.messageReceiverName() == Messages::WebRTCMonitor::messageReceiverName()) {
115
    if (decoder.messageReceiverName() == Messages::WebRTCMonitor::messageReceiverName()) {
124
        auto& network = WebProcess::singleton().libWebRTCNetwork();
116
        auto& network = WebProcess::singleton().libWebRTCNetwork();
125
        if (network.isActive())
117
        if (network.isActive())
- a/Source/WebKit/WebProcess/Network/webrtc/LibWebRTCNetwork.h -3 / +91 lines
Lines 26-59 a/Source/WebKit/WebProcess/Network/webrtc/LibWebRTCNetwork.h_sec1
26
#pragma once
26
#pragma once
27
27
28
#if USE(LIBWEBRTC)
28
#if USE(LIBWEBRTC)
29
#include "LibWebRTCNetworkMessages.h"
29
#include "LibWebRTCProvider.h"
30
#include "LibWebRTCProvider.h"
30
#include "LibWebRTCSocketFactory.h"
31
#include "LibWebRTCSocketFactory.h"
31
#include "WebRTCMonitor.h"
32
#include "WebRTCMonitor.h"
32
#include "WebRTCResolver.h"
33
#include "WebRTCResolver.h"
33
#include "WebRTCSocket.h"
34
#endif
34
#endif
35
35
36
#include "DataReference.h"
36
#include "WebMDNSRegister.h"
37
#include "WebMDNSRegister.h"
37
#include <WebCore/LibWebRTCSocketIdentifier.h>
38
#include <WebCore/LibWebRTCSocketIdentifier.h>
39
#include <WebCore/SharedBuffer.h>
38
40
39
namespace WebKit {
41
namespace WebKit {
40
42
41
class LibWebRTCNetwork {
43
class LibWebRTCNetwork : public IPC::Connection::ThreadMessageReceiver {
42
    WTF_MAKE_FAST_ALLOCATED;
44
    WTF_MAKE_FAST_ALLOCATED;
43
public:
45
public:
44
    LibWebRTCNetwork() = default;
46
    LibWebRTCNetwork() = default;
47
    ~LibWebRTCNetwork();
45
48
49
    void setConnection(RefPtr<IPC::Connection>&&);
46
    void networkProcessCrashed();
50
    void networkProcessCrashed();
47
51
48
    bool isActive() const;
52
    bool isActive() const;
49
53
54
    void didReceiveMessage(IPC::Connection&, IPC::Decoder&);
55
56
    IPC::Connection* connection() { return m_connection.get(); }
50
#if USE(LIBWEBRTC)
57
#if USE(LIBWEBRTC)
51
    WebRTCMonitor& monitor() { return m_webNetworkMonitor; }
58
    WebRTCMonitor& monitor() { return m_webNetworkMonitor; }
52
    LibWebRTCSocketFactory& socketFactory() { return m_socketFactory; }
59
    LibWebRTCSocketFactory& socketFactory() { return m_socketFactory; }
53
60
54
    void disableNonLocalhostConnections() { socketFactory().disableNonLocalhostConnections(); }
61
    void disableNonLocalhostConnections() { socketFactory().disableNonLocalhostConnections(); }
55
62
56
    WebRTCSocket socket(WebCore::LibWebRTCSocketIdentifier identifier) { return WebRTCSocket(socketFactory(), identifier); }
57
    WebRTCResolver resolver(LibWebRTCResolverIdentifier identifier) { return WebRTCResolver(socketFactory(), identifier); }
63
    WebRTCResolver resolver(LibWebRTCResolverIdentifier identifier) { return WebRTCResolver(socketFactory(), identifier); }
58
#endif
64
#endif
59
65
Lines 62-67 public: a/Source/WebKit/WebProcess/Network/webrtc/LibWebRTCNetwork.h_sec2
62
#endif
68
#endif
63
69
64
private:
70
private:
71
#if USE(LIBWEBRTC)
72
    void signalReadPacket(WebCore::LibWebRTCSocketIdentifier, const IPC::DataReference&, const RTCNetwork::IPAddress&, uint16_t port, int64_t);
73
    void signalSentPacket(WebCore::LibWebRTCSocketIdentifier, int, int64_t);
74
    void signalAddressReady(WebCore::LibWebRTCSocketIdentifier, const RTCNetwork::SocketAddress&);
75
    void signalConnect(WebCore::LibWebRTCSocketIdentifier);
76
    void signalClose(WebCore::LibWebRTCSocketIdentifier, int);
77
    void signalNewConnection(WebCore::LibWebRTCSocketIdentifier socketIdentifier, WebCore::LibWebRTCSocketIdentifier newSocketIdentifier, const WebKit::RTCNetwork::SocketAddress&);
78
#endif
79
80
    // IPC::Connection::ThreadMessageReceiver
81
    void dispatchToThread(Function<void()>&&) final;
82
65
#if USE(LIBWEBRTC)
83
#if USE(LIBWEBRTC)
66
    LibWebRTCSocketFactory m_socketFactory;
84
    LibWebRTCSocketFactory m_socketFactory;
67
    WebRTCMonitor m_webNetworkMonitor;
85
    WebRTCMonitor m_webNetworkMonitor;
Lines 69-83 private: a/Source/WebKit/WebProcess/Network/webrtc/LibWebRTCNetwork.h_sec3
69
#if ENABLE(WEB_RTC)
87
#if ENABLE(WEB_RTC)
70
    WebMDNSRegister m_mdnsRegister;
88
    WebMDNSRegister m_mdnsRegister;
71
#endif
89
#endif
90
    RefPtr<IPC::Connection> m_connection;
72
};
91
};
73
92
93
inline LibWebRTCNetwork::~LibWebRTCNetwork()
94
{
95
    setConnection(nullptr);
96
}
97
74
inline void LibWebRTCNetwork::networkProcessCrashed()
98
inline void LibWebRTCNetwork::networkProcessCrashed()
75
{
99
{
100
    setConnection(nullptr);
101
76
#if USE(LIBWEBRTC)
102
#if USE(LIBWEBRTC)
77
    m_webNetworkMonitor.networkProcessCrashed();
103
    m_webNetworkMonitor.networkProcessCrashed();
78
#endif
104
#endif
79
}
105
}
80
106
107
inline void LibWebRTCNetwork::setConnection(RefPtr<IPC::Connection>&& connection)
108
{
109
    if (m_connection)
110
        m_connection->removeThreadMessageReceiver(Messages::LibWebRTCNetwork::messageReceiverName());
111
    m_connection = WTFMove(connection);
112
    if (m_connection)
113
        m_connection->addThreadMessageReceiver(Messages::LibWebRTCNetwork::messageReceiverName(), this);
114
}
115
81
inline bool LibWebRTCNetwork::isActive() const
116
inline bool LibWebRTCNetwork::isActive() const
82
{
117
{
83
#if USE(LIBWEBRTC)
118
#if USE(LIBWEBRTC)
Lines 87-90 inline bool LibWebRTCNetwork::isActive() const a/Source/WebKit/WebProcess/Network/webrtc/LibWebRTCNetwork.h_sec4
87
#endif
122
#endif
88
}
123
}
89
124
125
inline void LibWebRTCNetwork::dispatchToThread(Function<void()>&& callback)
126
{
127
#if USE(LIBWEBRTC)
128
    // FIXME: Need to dispatch when thread is available only.
129
    WebCore::LibWebRTCProvider::callOnWebRTCNetworkThread([callback = WTFMove(callback)]() {
130
        callback();
131
    });
132
#else
133
    UNUSED_PARAM(callback);
134
#endif
135
}
136
137
#if USE(LIBWEBRTC)
138
inline void LibWebRTCNetwork::signalAddressReady(WebCore::LibWebRTCSocketIdentifier identifier, const RTCNetwork::SocketAddress& address)
139
{
140
    if (auto* socket = m_socketFactory.socket(identifier))
141
        socket->signalAddressReady(address.value);
142
}
143
144
inline void LibWebRTCNetwork::signalReadPacket(WebCore::LibWebRTCSocketIdentifier identifier, const IPC::DataReference& data, const RTCNetwork::IPAddress& address, uint16_t port, int64_t timestamp)
145
{
146
    if (auto* socket = m_socketFactory.socket(identifier)) {
147
        // FIXME: remove buffer allocation.
148
        auto buffer = WebCore::SharedBuffer::create(data.data(), data.size());
149
        socket->signalReadPacket(buffer.get(), rtc::SocketAddress(address.value, port), timestamp);
150
    }
151
}
152
153
inline void LibWebRTCNetwork::signalSentPacket(WebCore::LibWebRTCSocketIdentifier identifier, int rtcPacketID, int64_t sendTimeMs)
154
{
155
    if (auto* socket = m_socketFactory.socket(identifier))
156
        socket->signalSentPacket(rtcPacketID, sendTimeMs);
157
}
158
159
inline void LibWebRTCNetwork::signalConnect(WebCore::LibWebRTCSocketIdentifier identifier)
160
{
161
    if (auto* socket = m_socketFactory.socket(identifier))
162
        socket->signalConnect();
163
}
164
165
inline void LibWebRTCNetwork::signalClose(WebCore::LibWebRTCSocketIdentifier identifier, int error)
166
{
167
    if (auto* socket = m_socketFactory.socket(identifier))
168
        socket->signalClose(error);
169
}
170
171
inline void LibWebRTCNetwork::signalNewConnection(WebCore::LibWebRTCSocketIdentifier identifier, WebCore::LibWebRTCSocketIdentifier newSocketIdentifier, const RTCNetwork::SocketAddress& remoteAddress)
172
{
173
    if (auto* socket = m_socketFactory.socket(identifier))
174
        socket->signalNewConnection(m_socketFactory.createNewConnectionSocket(*socket, newSocketIdentifier, remoteAddress.value));
175
}
176
#endif
177
90
} // namespace WebKit
178
} // namespace WebKit
- a/Source/WebKit/WebProcess/Network/webrtc/LibWebRTCNetwork.messages.in +34 lines
Line 0 a/Source/WebKit/WebProcess/Network/webrtc/LibWebRTCNetwork.messages.in_sec1
1
# Copyright (C) 2017 Apple Inc. All rights reserved.
2
#
3
# Redistribution and use in source and binary forms, with or without
4
# modification, are permitted provided that the following conditions
5
# are met:
6
# 1.  Redistributions of source code must retain the above copyright
7
#     notice, this list of conditions and the following disclaimer.
8
# 2.  Redistributions in binary form must reproduce the above copyright
9
#     notice, this list of conditions and the following disclaimer in the
10
#     documentation and/or other materials provided with the distribution.
11
#
12
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
13
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
14
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
15
# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
16
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
18
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
19
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
20
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
21
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22
23
#if USE(LIBWEBRTC)
24
25
messages -> LibWebRTCNetwork NotRefCounted {
26
    SignalReadPacket(WebCore::LibWebRTCSocketIdentifier socketIdentifier, IPC::DataReference data, WebKit::RTCNetwork::IPAddress address, uint16_t port, int64_t timestamp)
27
    SignalSentPacket(WebCore::LibWebRTCSocketIdentifier socketIdentifier, int packetSize, int64_t timestamp)
28
    SignalAddressReady(WebCore::LibWebRTCSocketIdentifier socketIdentifier, WebKit::RTCNetwork::SocketAddress address)
29
    SignalConnect(WebCore::LibWebRTCSocketIdentifier socketIdentifier)
30
    SignalClose(WebCore::LibWebRTCSocketIdentifier socketIdentifier, int error)
31
    SignalNewConnection(WebCore::LibWebRTCSocketIdentifier socketIdentifier, WebCore::LibWebRTCSocketIdentifier newSocketIdentifier, WebKit::RTCNetwork::SocketAddress remoteAddress)
32
}
33
34
#endif // USE(LIBWEBRTC)
- a/Source/WebKit/WebProcess/Network/webrtc/LibWebRTCSocket.h -1 / +1 lines
Lines 69-75 public: a/Source/WebKit/WebProcess/Network/webrtc/LibWebRTCSocket.h_sec1
69
private:
69
private:
70
    bool willSend(size_t);
70
    bool willSend(size_t);
71
71
72
    friend class WebRTCSocket;
72
    friend class LibWebRTCNetwork;
73
    void signalReadPacket(const WebCore::SharedBuffer&, rtc::SocketAddress&&, int64_t);
73
    void signalReadPacket(const WebCore::SharedBuffer&, rtc::SocketAddress&&, int64_t);
74
    void signalSentPacket(int, int64_t);
74
    void signalSentPacket(int, int64_t);
75
    void signalAddressReady(const rtc::SocketAddress&);
75
    void signalAddressReady(const rtc::SocketAddress&);
- a/Source/WebKit/WebProcess/Network/webrtc/LibWebRTCSocketFactory.cpp -1 lines
Lines 32-38 a/Source/WebKit/WebProcess/Network/webrtc/LibWebRTCSocketFactory.cpp_sec1
32
#include "NetworkRTCMonitorMessages.h"
32
#include "NetworkRTCMonitorMessages.h"
33
#include "NetworkRTCProviderMessages.h"
33
#include "NetworkRTCProviderMessages.h"
34
#include "WebProcess.h"
34
#include "WebProcess.h"
35
#include "WebRTCSocket.h"
36
#include <wtf/MainThread.h>
35
#include <wtf/MainThread.h>
37
36
38
namespace WebKit {
37
namespace WebKit {
- a/Source/WebKit/WebProcess/Network/webrtc/WebRTCSocket.cpp -103 lines
Lines 1-103 a/Source/WebKit/WebProcess/Network/webrtc/WebRTCSocket.cpp_sec1
1
/*
2
 * Copyright (C) 2017 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
#include "WebRTCSocket.h"
28
29
#if USE(LIBWEBRTC)
30
31
#include "DataReference.h"
32
#include "LibWebRTCSocket.h"
33
#include "LibWebRTCSocketFactory.h"
34
#include "NetworkRTCSocketMessages.h"
35
#include <WebCore/SharedBuffer.h>
36
#include <wtf/Function.h>
37
38
namespace WebKit {
39
using namespace WebCore;
40
41
void WebRTCSocket::signalOnNetworkThread(LibWebRTCSocketFactory& factory, LibWebRTCSocketIdentifier identifier, Function<void(LibWebRTCSocket&)>&& callback)
42
{
43
    // factory is staying valid during the process lifetime.
44
    WebCore::LibWebRTCProvider::callOnWebRTCNetworkThread([&factory, identifier, callback = WTFMove(callback)]() {
45
        auto* socket = factory.socket(identifier);
46
        if (!socket)
47
            return;
48
        callback(*socket);
49
    });
50
}
51
52
WebRTCSocket::WebRTCSocket(LibWebRTCSocketFactory& factory, LibWebRTCSocketIdentifier identifier)
53
    : m_factory(factory)
54
    , m_identifier(identifier)
55
{
56
}
57
58
void WebRTCSocket::signalAddressReady(const RTCNetwork::SocketAddress& address)
59
{
60
    signalOnNetworkThread(m_factory, m_identifier, [address](LibWebRTCSocket& socket) {
61
        socket.signalAddressReady(address.value);
62
    });
63
}
64
65
void WebRTCSocket::signalReadPacket(const IPC::DataReference& data, const RTCNetwork::IPAddress& address, uint16_t port, int64_t timestamp)
66
{
67
    auto buffer = WebCore::SharedBuffer::create(data.data(), data.size());
68
    signalOnNetworkThread(m_factory, m_identifier, [buffer = WTFMove(buffer), address, port, timestamp](LibWebRTCSocket& socket) {
69
        socket.signalReadPacket(buffer.get(), rtc::SocketAddress(address.value, port), timestamp);
70
    });
71
}
72
73
void WebRTCSocket::signalSentPacket(int rtcPacketID, int64_t sendTimeMs)
74
{
75
    signalOnNetworkThread(m_factory, m_identifier, [rtcPacketID, sendTimeMs](auto& socket) {
76
        socket.signalSentPacket(rtcPacketID, sendTimeMs);
77
    });
78
}
79
80
void WebRTCSocket::signalConnect()
81
{
82
    signalOnNetworkThread(m_factory, m_identifier, [](auto& socket) {
83
        socket.signalConnect();
84
    });
85
}
86
87
void WebRTCSocket::signalClose(int error)
88
{
89
    signalOnNetworkThread(m_factory, m_identifier, [error](auto& socket) {
90
        socket.signalClose(error);
91
    });
92
}
93
94
void WebRTCSocket::signalNewConnection(LibWebRTCSocketIdentifier newSocketIdentifier, const RTCNetwork::SocketAddress& remoteAddress)
95
{
96
    signalOnNetworkThread(m_factory, m_identifier, [newSocketIdentifier, remoteAddress = RTCNetwork::isolatedCopy(remoteAddress.value)](auto& socket) {
97
        socket.signalNewConnection(socket.m_factory.createNewConnectionSocket(socket, newSocketIdentifier, remoteAddress));
98
    });
99
}
100
101
} // namespace WebKit
102
103
#endif // USE(LIBWEBRTC)
- a/Source/WebKit/WebProcess/Network/webrtc/WebRTCSocket.h -67 lines
Lines 1-67 a/Source/WebKit/WebProcess/Network/webrtc/WebRTCSocket.h_sec1
1
/*
2
 * Copyright (C) 2017 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#pragma once
27
28
#if USE(LIBWEBRTC)
29
30
#include "RTCNetwork.h"
31
#include <WebCore/LibWebRTCSocketIdentifier.h>
32
#include <wtf/Function.h>
33
34
namespace IPC {
35
class Connection;
36
class DataReference;
37
class Decoder;
38
}
39
40
namespace WebKit {
41
42
class LibWebRTCSocket;
43
class LibWebRTCSocketFactory;
44
45
class WebRTCSocket {
46
public:
47
    WebRTCSocket(LibWebRTCSocketFactory&, WebCore::LibWebRTCSocketIdentifier);
48
49
    void didReceiveMessage(IPC::Connection&, IPC::Decoder&);
50
51
    static void signalOnNetworkThread(LibWebRTCSocketFactory&, WebCore::LibWebRTCSocketIdentifier, Function<void(LibWebRTCSocket&)>&&);
52
53
private:
54
    void signalReadPacket(const IPC::DataReference&, const RTCNetwork::IPAddress&, uint16_t port, int64_t);
55
    void signalSentPacket(int, int64_t);
56
    void signalAddressReady(const RTCNetwork::SocketAddress&);
57
    void signalConnect();
58
    void signalClose(int);
59
    void signalNewConnection(WebCore::LibWebRTCSocketIdentifier newSocketIdentifier, const WebKit::RTCNetwork::SocketAddress&);
60
61
    LibWebRTCSocketFactory& m_factory;
62
    WebCore::LibWebRTCSocketIdentifier m_identifier;
63
};
64
65
} // namespace WebKit
66
67
#endif // USE(LIBWEBRTC)
- a/Source/WebKit/WebProcess/Network/webrtc/WebRTCSocket.messages.in -34 lines
Lines 1-34 a/Source/WebKit/WebProcess/Network/webrtc/WebRTCSocket.messages.in_sec1
1
# Copyright (C) 2017 Apple Inc. All rights reserved.
2
#
3
# Redistribution and use in source and binary forms, with or without
4
# modification, are permitted provided that the following conditions
5
# are met:
6
# 1.  Redistributions of source code must retain the above copyright
7
#     notice, this list of conditions and the following disclaimer.
8
# 2.  Redistributions in binary form must reproduce the above copyright
9
#     notice, this list of conditions and the following disclaimer in the
10
#     documentation and/or other materials provided with the distribution.
11
#
12
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
13
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
14
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
15
# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
16
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
18
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
19
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
20
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
21
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22
23
#if USE(LIBWEBRTC)
24
25
messages -> WebRTCSocket NotRefCounted {
26
    SignalReadPacket(IPC::DataReference data, WebKit::RTCNetwork::IPAddress address, uint16_t port, int64_t timestamp)
27
    SignalSentPacket(int packetSize, int64_t timestamp)
28
    SignalAddressReady(WebKit::RTCNetwork::SocketAddress address)
29
    SignalConnect()
30
    SignalClose(int error)
31
    SignalNewConnection(WebCore::LibWebRTCSocketIdentifier newSocketIdentifier, WebKit::RTCNetwork::SocketAddress remoteAddress)
32
}
33
34
#endif // USE(LIBWEBRTC)

Return to Bug 211290