LibWebRTCNetwork.h [plain text]
#pragma once
#include "Connection.h"
#include "LibWebRTCProvider.h"
#include "LibWebRTCSocketFactory.h"
#include "WebMDNSRegister.h"
#include "WebRTCMonitor.h"
#include "WebRTCResolver.h"
#include <WebCore/LibWebRTCSocketIdentifier.h>
namespace WebKit {
class LibWebRTCNetwork : public IPC::Connection::ThreadMessageReceiverRefCounted {
WTF_MAKE_FAST_ALLOCATED;
public:
LibWebRTCNetwork() = default;
~LibWebRTCNetwork();
IPC::Connection* connection() { return m_connection.get(); }
void setConnection(RefPtr<IPC::Connection>&&);
void networkProcessCrashed();
bool isActive() const { return m_isActive; }
#if USE(LIBWEBRTC)
void didReceiveMessage(IPC::Connection&, IPC::Decoder&);
WebRTCMonitor& monitor() { return m_webNetworkMonitor; }
LibWebRTCSocketFactory& socketFactory() { return m_socketFactory; }
void disableNonLocalhostConnections() { socketFactory().disableNonLocalhostConnections(); }
WebRTCResolver resolver(LibWebRTCResolverIdentifier identifier) { return WebRTCResolver(socketFactory(), identifier); }
#endif
#if ENABLE(WEB_RTC)
WebMDNSRegister& mdnsRegister() { return m_mdnsRegister; }
#endif
void setAsActive();
private:
#if USE(LIBWEBRTC)
void setSocketFactoryConnection();
void signalReadPacket(WebCore::LibWebRTCSocketIdentifier, const IPC::DataReference&, const RTCNetwork::IPAddress&, uint16_t port, int64_t);
void signalSentPacket(WebCore::LibWebRTCSocketIdentifier, int, int64_t);
void signalAddressReady(WebCore::LibWebRTCSocketIdentifier, const RTCNetwork::SocketAddress&);
void signalConnect(WebCore::LibWebRTCSocketIdentifier);
void signalClose(WebCore::LibWebRTCSocketIdentifier, int);
void signalNewConnection(WebCore::LibWebRTCSocketIdentifier socketIdentifier, WebCore::LibWebRTCSocketIdentifier newSocketIdentifier, const WebKit::RTCNetwork::SocketAddress&);
#endif
void dispatchToThread(Function<void()>&&) final;
#if USE(LIBWEBRTC)
LibWebRTCSocketFactory m_socketFactory;
WebRTCMonitor m_webNetworkMonitor;
#endif
#if ENABLE(WEB_RTC)
WebMDNSRegister m_mdnsRegister;
#endif
bool m_isActive { false };
RefPtr<IPC::Connection> m_connection;
};
}