Changeset 249376 in webkit
- Timestamp:
- Sep 1, 2019 11:20:18 PM (5 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r249375 r249376 1 2019-09-01 Youenn Fablet <youenn@apple.com> 2 3 Abstract out LibWebRTCSocketClient so that rtc sockets can be implemented without libwebrtc sockets 4 https://bugs.webkit.org/show_bug.cgi?id=201302 5 6 Reviewed by Alex Christensen. 7 8 Introduce NetworkRTCProvider::Socket to be able to implement RTC socket support with non libwebrtc API 9 10 * NetworkProcess/webrtc/LibWebRTCSocketClient.h: 11 * NetworkProcess/webrtc/NetworkRTCProvider.cpp: 12 (WebKit::NetworkRTCProvider::createSocket): 13 (WebKit::NetworkRTCProvider::createUDPSocket): 14 (WebKit::NetworkRTCProvider::createServerTCPSocket): 15 (WebKit::NetworkRTCProvider::proxyInfoFromSession): 16 (WebKit::NetworkRTCProvider::createClientTCPSocket): 17 (WebKit::NetworkRTCProvider::wrapNewTCPConnection): 18 (WebKit::NetworkRTCProvider::addSocket): 19 (WebKit::NetworkRTCProvider::takeSocket): 20 (WebKit::NetworkRTCProvider::newConnection): 21 (WebKit::NetworkRTCProvider::closeListeningSockets): 22 (WebKit::NetworkRTCProvider::callSocket): 23 * NetworkProcess/webrtc/NetworkRTCProvider.h: 24 * NetworkProcess/webrtc/NetworkRTCProvider.mm: 25 (WebKit::NetworkRTCProvider::createClientTCPSocket): 26 * NetworkProcess/webrtc/NetworkRTCSocket.cpp: 27 (WebKit::NetworkRTCSocket::sendTo): 28 (WebKit::NetworkRTCSocket::close): 29 (WebKit::NetworkRTCSocket::setOption): 30 1 31 2019-09-01 Fujii Hironori <Hironori.Fujii@sony.com> 2 32 -
trunk/Source/WebKit/NetworkProcess/webrtc/LibWebRTCSocketClient.h
r248762 r249376 28 28 #if USE(LIBWEBRTC) 29 29 30 #include <WebCore/LibWebRTCMacros.h>30 #include "NetworkRTCProvider.h" 31 31 #include <webrtc/rtc_base/asyncpacketsocket.h> 32 #include <webrtc/rtc_base/third_party/sigslot/sigslot.h>33 32 34 33 namespace rtc { 35 34 class AsyncPacketSocket; 36 class SocketAddress;37 struct PacketOptions;38 35 struct SentPacket; 39 36 typedef int64_t PacketTime; 40 37 } 41 38 42 namespace WebCore {43 class SharedBuffer;44 }45 46 39 namespace WebKit { 47 40 48 class NetworkRTCProvider; 49 50 class LibWebRTCSocketClient final : public sigslot::has_slots<> { 41 class LibWebRTCSocketClient final : public NetworkRTCProvider::Socket, public sigslot::has_slots<> { 51 42 WTF_MAKE_FAST_ALLOCATED; 52 43 public: 53 enum class Type { UDP, ServerTCP, ClientTCP, ServerConnectionTCP };54 55 44 LibWebRTCSocketClient(uint64_t identifier, NetworkRTCProvider&, std::unique_ptr<rtc::AsyncPacketSocket>&&, Type); 56 45 57 uint64_t identifier() const { return m_identifier; } 58 Type type() const { return m_type; } 59 void close(); 46 private: 47 uint64_t identifier() const final { return m_identifier; } 48 Type type() const final { return m_type; } 49 void close() final; 60 50 61 private: 62 friend class NetworkRTCSocket; 63 64 void setOption(int option, int value); 65 void sendTo(const WebCore::SharedBuffer&, const rtc::SocketAddress&, const rtc::PacketOptions&); 51 void setOption(int option, int value) final; 52 void sendTo(const WebCore::SharedBuffer&, const rtc::SocketAddress&, const rtc::PacketOptions&) final; 66 53 67 54 void signalReadPacket(rtc::AsyncPacketSocket*, const char*, size_t, const rtc::SocketAddress&, const rtc::PacketTime&); -
trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.cpp
r248846 r249376 29 29 #if USE(LIBWEBRTC) 30 30 31 #include "LibWebRTCSocketClient.h" 31 32 #include "Logging.h" 32 33 #include "NetworkConnectionToWebProcess.h" … … 96 97 } 97 98 98 void NetworkRTCProvider::createSocket(uint64_t identifier, std::unique_ptr<rtc::AsyncPacketSocket>&& socket, LibWebRTCSocketClient::Type type)99 void NetworkRTCProvider::createSocket(uint64_t identifier, std::unique_ptr<rtc::AsyncPacketSocket>&& socket, Socket::Type type) 99 100 { 100 101 if (!socket) { … … 112 113 callOnRTCNetworkThread([this, identifier, address = RTCNetwork::isolatedCopy(address.value), minPort, maxPort]() { 113 114 std::unique_ptr<rtc::AsyncPacketSocket> socket(m_packetSocketFactory->CreateUdpSocket(address, minPort, maxPort)); 114 createSocket(identifier, WTFMove(socket), LibWebRTCSocketClient::Type::UDP);115 createSocket(identifier, WTFMove(socket), Socket::Type::UDP); 115 116 }); 116 117 } … … 126 127 callOnRTCNetworkThread([this, identifier, address = RTCNetwork::isolatedCopy(address.value), minPort, maxPort, options]() { 127 128 std::unique_ptr<rtc::AsyncPacketSocket> socket(m_packetSocketFactory->CreateServerTcpSocket(address, minPort, maxPort, options)); 128 createSocket(identifier, WTFMove(socket), LibWebRTCSocketClient::Type::ServerTCP);129 createSocket(identifier, WTFMove(socket), Socket::Type::ServerTCP); 129 130 }); 130 131 } … … 146 147 callOnRTCNetworkThread([this, identifier, localAddress = RTCNetwork::isolatedCopy(localAddress.value), remoteAddress = RTCNetwork::isolatedCopy(remoteAddress.value), proxyInfo = proxyInfoFromSession(remoteAddress, *session), userAgent = WTFMove(userAgent).isolatedCopy(), options]() { 147 148 std::unique_ptr<rtc::AsyncPacketSocket> socket(m_packetSocketFactory->CreateClientTcpSocket(localAddress, remoteAddress, proxyInfo, userAgent.utf8().data(), options)); 148 createSocket(identifier, WTFMove(socket), LibWebRTCSocketClient::Type::ClientTCP);149 createSocket(identifier, WTFMove(socket), Socket::Type::ClientTCP); 149 150 }); 150 151 } … … 154 155 callOnRTCNetworkThread([this, identifier, newConnectionSocketIdentifier]() { 155 156 std::unique_ptr<rtc::AsyncPacketSocket> socket = m_pendingIncomingSockets.take(newConnectionSocketIdentifier); 156 addSocket(identifier, makeUnique<LibWebRTCSocketClient>(identifier, *this, WTFMove(socket), LibWebRTCSocketClient::Type::ServerConnectionTCP));157 }); 158 } 159 160 void NetworkRTCProvider::addSocket(uint64_t identifier, std::unique_ptr< LibWebRTCSocketClient>&& socket)157 addSocket(identifier, makeUnique<LibWebRTCSocketClient>(identifier, *this, WTFMove(socket), Socket::Type::ServerConnectionTCP)); 158 }); 159 } 160 161 void NetworkRTCProvider::addSocket(uint64_t identifier, std::unique_ptr<Socket>&& socket) 161 162 { 162 163 m_sockets.add(identifier, WTFMove(socket)); 163 164 } 164 165 165 std::unique_ptr< LibWebRTCSocketClient> NetworkRTCProvider::takeSocket(uint64_t identifier)166 std::unique_ptr<NetworkRTCProvider::Socket> NetworkRTCProvider::takeSocket(uint64_t identifier) 166 167 { 167 168 return m_sockets.take(identifier); 168 169 } 169 170 170 void NetworkRTCProvider::newConnection( LibWebRTCSocketClient& serverSocket, std::unique_ptr<rtc::AsyncPacketSocket>&& newSocket)171 void NetworkRTCProvider::newConnection(Socket& serverSocket, std::unique_ptr<rtc::AsyncPacketSocket>&& newSocket) 171 172 { 172 173 sendFromMainThread([identifier = serverSocket.identifier(), incomingSocketIdentifier = ++m_incomingSocketIdentifier, remoteAddress = RTCNetwork::isolatedCopy(newSocket->GetRemoteAddress())](IPC::Connection& connection) { … … 247 248 Vector<uint64_t> listeningSocketIdentifiers; 248 249 for (auto& keyValue : m_sockets) { 249 if (keyValue.value->type() == LibWebRTCSocketClient::Type::ServerTCP)250 if (keyValue.value->type() == Socket::Type::ServerTCP) 250 251 listeningSocketIdentifiers.append(keyValue.key); 251 252 } … … 285 286 } 286 287 287 void NetworkRTCProvider::callSocket(uint64_t identifier, Function<void( LibWebRTCSocketClient&)>&& callback)288 void NetworkRTCProvider::callSocket(uint64_t identifier, Function<void(Socket&)>&& callback) 288 289 { 289 290 callOnRTCNetworkThread([this, identifier, callback = WTFMove(callback)]() { -
trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.h
r248592 r249376 28 28 #if USE(LIBWEBRTC) 29 29 30 #include "LibWebRTCSocketClient.h"31 30 #include "NetworkRTCMonitor.h" 32 31 #include "RTCNetwork.h" … … 43 42 class Connection; 44 43 class Decoder; 44 } 45 46 namespace rtc { 47 class SocketAddress; 48 struct PacketOptions; 49 } 50 51 namespace WebCore { 52 class SharedBuffer; 45 53 } 46 54 … … 60 68 void didReceiveNetworkRTCSocketMessage(IPC::Connection&, IPC::Decoder&); 61 69 62 std::unique_ptr<LibWebRTCSocketClient> takeSocket(uint64_t); 70 class Socket { 71 public: 72 virtual ~Socket() = default; 73 74 enum class Type : uint8_t { UDP, ServerTCP, ClientTCP, ServerConnectionTCP }; 75 virtual Type type() const = 0; 76 virtual uint64_t identifier() const = 0; 77 78 virtual void close() = 0; 79 virtual void setOption(int option, int value) = 0; 80 virtual void sendTo(const WebCore::SharedBuffer&, const rtc::SocketAddress&, const rtc::PacketOptions&) = 0; 81 }; 82 83 std::unique_ptr<Socket> takeSocket(uint64_t); 63 84 void resolverDone(uint64_t); 64 85 65 86 void close(); 66 87 67 void callSocket(uint64_t, Function<void( LibWebRTCSocketClient&)>&&);88 void callSocket(uint64_t, Function<void(Socket&)>&&); 68 89 void callOnRTCNetworkThread(Function<void()>&&); 69 90 void sendFromMainThread(Function<void(IPC::Connection&)>&&); 70 91 71 void newConnection( LibWebRTCSocketClient&, std::unique_ptr<rtc::AsyncPacketSocket>&&);92 void newConnection(Socket&, std::unique_ptr<rtc::AsyncPacketSocket>&&); 72 93 73 94 void closeListeningSockets(Function<void()>&&); … … 85 106 void stopResolver(uint64_t); 86 107 87 void addSocket(uint64_t, std::unique_ptr< LibWebRTCSocketClient>&&);108 void addSocket(uint64_t, std::unique_ptr<Socket>&&); 88 109 89 void createSocket(uint64_t identifier, std::unique_ptr<rtc::AsyncPacketSocket>&&, LibWebRTCSocketClient::Type);110 void createSocket(uint64_t identifier, std::unique_ptr<rtc::AsyncPacketSocket>&&, Socket::Type); 90 111 91 112 void OnMessage(rtc::Message*); … … 94 115 95 116 HashMap<uint64_t, std::unique_ptr<NetworkRTCResolver>> m_resolvers; 96 HashMap<uint64_t, std::unique_ptr< LibWebRTCSocketClient>> m_sockets;117 HashMap<uint64_t, std::unique_ptr<Socket>> m_sockets; 97 118 NetworkConnectionToWebProcess* m_connection; 98 119 bool m_isStarted { true }; -
trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCSocket.cpp
r222894 r249376 30 30 31 31 #include "DataReference.h" 32 #include "LibWebRTCSocketClient.h"33 32 #include "NetworkRTCProvider.h" 34 33 #include "RTCPacketOptions.h" … … 47 46 { 48 47 auto buffer = WebCore::SharedBuffer::create(data.data(), data.size()); 49 m_rtcProvider.callSocket(m_identifier, [buffer = WTFMove(buffer), socketAddress = WTFMove(socketAddress), options = WTFMove(options.options)]( LibWebRTCSocketClient& client) {50 client.sendTo(buffer.get(), socketAddress.value, options);48 m_rtcProvider.callSocket(m_identifier, [buffer = WTFMove(buffer), socketAddress = WTFMove(socketAddress), options = WTFMove(options.options)](auto& socket) { 49 socket.sendTo(buffer.get(), socketAddress.value, options); 51 50 }); 52 51 } … … 54 53 void NetworkRTCSocket::close() 55 54 { 56 m_rtcProvider.callSocket(m_identifier, []( LibWebRTCSocketClient& socket) {55 m_rtcProvider.callSocket(m_identifier, [](auto& socket) { 57 56 socket.close(); 58 57 }); … … 61 60 void NetworkRTCSocket::setOption(int option, int value) 62 61 { 63 m_rtcProvider.callSocket(m_identifier, [option, value]( LibWebRTCSocketClient& socket) {62 m_rtcProvider.callSocket(m_identifier, [option, value](auto& socket) { 64 63 socket.setOption(option, value); 65 64 });
Note: See TracChangeset
for help on using the changeset viewer.