WebMDNSRegister no longer needs to be provided sessionIDs
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Sep 2019 20:49:36 +0000 (20:49 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Sep 2019 20:49:36 +0000 (20:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=201876

Reviewed by Geoffrey Garen.

WebMDNSRegister no longer needs to be provided sessionIDs, now that we
have one session per WebProcess.

* NetworkProcess/webrtc/NetworkMDNSRegister.cpp:
(WebKit::NetworkMDNSRegister::registerMDNSName):
(WebKit::NetworkMDNSRegister::sessionID const):
* NetworkProcess/webrtc/NetworkMDNSRegister.h:
* NetworkProcess/webrtc/NetworkMDNSRegister.messages.in:
* WebProcess/Network/webrtc/LibWebRTCProvider.cpp:
(WebKit::LibWebRTCProvider::registerMDNSName):
(WebKit::LibWebRTCProvider::createSocketFactory):
* WebProcess/Network/webrtc/WebMDNSRegister.cpp:
(WebKit::WebMDNSRegister::registerMDNSName):
* WebProcess/Network/webrtc/WebMDNSRegister.h:

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

12 files changed:
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/webrtc/NetworkMDNSRegister.cpp
Source/WebKit/NetworkProcess/webrtc/NetworkMDNSRegister.h
Source/WebKit/NetworkProcess/webrtc/NetworkMDNSRegister.messages.in
Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.cpp
Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.h
Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.messages.in
Source/WebKit/WebProcess/Network/webrtc/LibWebRTCProvider.cpp
Source/WebKit/WebProcess/Network/webrtc/LibWebRTCSocketFactory.cpp
Source/WebKit/WebProcess/Network/webrtc/LibWebRTCSocketFactory.h
Source/WebKit/WebProcess/Network/webrtc/WebMDNSRegister.cpp
Source/WebKit/WebProcess/Network/webrtc/WebMDNSRegister.h

index e2b62c0..6eb575f 100644 (file)
@@ -1,5 +1,27 @@
 2019-09-17  Chris Dumez  <cdumez@apple.com>
 
+        WebMDNSRegister no longer needs to be provided sessionIDs
+        https://bugs.webkit.org/show_bug.cgi?id=201876
+
+        Reviewed by Geoffrey Garen.
+
+        WebMDNSRegister no longer needs to be provided sessionIDs, now that we
+        have one session per WebProcess.
+
+        * NetworkProcess/webrtc/NetworkMDNSRegister.cpp:
+        (WebKit::NetworkMDNSRegister::registerMDNSName):
+        (WebKit::NetworkMDNSRegister::sessionID const):
+        * NetworkProcess/webrtc/NetworkMDNSRegister.h:
+        * NetworkProcess/webrtc/NetworkMDNSRegister.messages.in:
+        * WebProcess/Network/webrtc/LibWebRTCProvider.cpp:
+        (WebKit::LibWebRTCProvider::registerMDNSName):
+        (WebKit::LibWebRTCProvider::createSocketFactory):
+        * WebProcess/Network/webrtc/WebMDNSRegister.cpp:
+        (WebKit::WebMDNSRegister::registerMDNSName):
+        * WebProcess/Network/webrtc/WebMDNSRegister.h:
+
+2019-09-17  Chris Dumez  <cdumez@apple.com>
+
         WebSWServerConnection does not need to store a sessionID
         https://bugs.webkit.org/show_bug.cgi?id=201878
 
index 926668c..2a3091d 100644 (file)
@@ -37,7 +37,7 @@
 
 namespace WebKit {
 
-#define RELEASE_LOG_IF_ALLOWED(sessionID, fmt, ...) RELEASE_LOG_IF(sessionID.isAlwaysOnLoggingAllowed(), Network, "%p - NetworkMDNSRegister::" fmt, this, ##__VA_ARGS__)
+#define RELEASE_LOG_IF_ALLOWED(fmt, ...) RELEASE_LOG_IF(sessionID().isAlwaysOnLoggingAllowed(), Network, "%p - NetworkMDNSRegister::" fmt, this, ##__VA_ARGS__)
 #define RELEASE_LOG_IF_ALLOWED_IN_CALLBACK(sessionID, fmt, ...) RELEASE_LOG_IF(sessionID.isAlwaysOnLoggingAllowed(), Network, "NetworkMDNSRegister callback - " fmt, ##__VA_ARGS__)
 
 NetworkMDNSRegister::NetworkMDNSRegister(NetworkConnectionToWebProcess& connection)
@@ -104,20 +104,20 @@ static void registerMDNSNameCallback(DNSServiceRef, DNSRecordRef record, DNSServ
     request->connection->send(Messages::WebMDNSRegister::FinishedRegisteringMDNSName { request->requestIdentifier, request->name }, 0);
 }
 
-void NetworkMDNSRegister::registerMDNSName(uint64_t requestIdentifier, PAL::SessionID sessionID, WebCore::DocumentIdentifier documentIdentifier, const String& ipAddress)
+void NetworkMDNSRegister::registerMDNSName(uint64_t requestIdentifier, WebCore::DocumentIdentifier documentIdentifier, const String& ipAddress)
 {
     DNSServiceRef service;
     auto iterator = m_services.find(documentIdentifier);
     if (iterator == m_services.end()) {
         auto error = DNSServiceCreateConnection(&service);
         if (error) {
-            RELEASE_LOG_IF_ALLOWED(sessionID, "registerMDNSName DNSServiceCreateConnection error %d", error);
+            RELEASE_LOG_IF_ALLOWED("registerMDNSName DNSServiceCreateConnection error %d", error);
             m_connection.connection().send(Messages::WebMDNSRegister::FinishedRegisteringMDNSName { requestIdentifier, makeUnexpected(WebCore::MDNSRegisterError::DNSSD) }, 0);
             return;
         }
         error = DNSServiceSetDispatchQueue(service, dispatch_get_main_queue());
         if (error) {
-            RELEASE_LOG_IF_ALLOWED(sessionID, "registerMDNSName DNSServiceCreateConnection error %d", error);
+            RELEASE_LOG_IF_ALLOWED("registerMDNSName DNSServiceCreateConnection error %d", error);
             m_connection.connection().send(Messages::WebMDNSRegister::FinishedRegisteringMDNSName { requestIdentifier, makeUnexpected(WebCore::MDNSRegisterError::DNSSD) }, 0);
             return;
         }
@@ -131,12 +131,12 @@ void NetworkMDNSRegister::registerMDNSName(uint64_t requestIdentifier, PAL::Sess
     auto ip = inet_addr(ipAddress.utf8().data());
 
     if (ip == ( in_addr_t)(-1)) {
-        RELEASE_LOG_IF_ALLOWED(sessionID, "registerMDNSName inet_addr error");
+        RELEASE_LOG_IF_ALLOWED("registerMDNSName inet_addr error");
         m_connection.connection().send(Messages::WebMDNSRegister::FinishedRegisteringMDNSName { requestIdentifier, makeUnexpected(WebCore::MDNSRegisterError::BadParameter) }, 0);
         return;
     }
 
-    auto pendingRequest = makeUnique<PendingRegistrationRequest>(makeRef(m_connection.connection()), requestIdentifier, WTFMove(name), sessionID);
+    auto pendingRequest = makeUnique<PendingRegistrationRequest>(makeRef(m_connection.connection()), requestIdentifier, WTFMove(name), sessionID());
     auto* record = &pendingRequest->record;
     auto error = DNSServiceRegisterRecord(service,
         record,
@@ -155,7 +155,7 @@ void NetworkMDNSRegister::registerMDNSName(uint64_t requestIdentifier, PAL::Sess
         registerMDNSNameCallback,
         reinterpret_cast<void*>(pendingRegistrationRequestCount));
     if (error) {
-        RELEASE_LOG_IF_ALLOWED(sessionID, "registerMDNSName DNSServiceRegisterRecord error %d", error);
+        RELEASE_LOG_IF_ALLOWED("registerMDNSName DNSServiceRegisterRecord error %d", error);
         m_connection.connection().send(Messages::WebMDNSRegister::FinishedRegisteringMDNSName { requestIdentifier, makeUnexpected(WebCore::MDNSRegisterError::DNSSD) }, 0);
         return;
     }
@@ -168,14 +168,19 @@ void NetworkMDNSRegister::unregisterMDNSNames(WebCore::DocumentIdentifier)
 {
 }
 
-void NetworkMDNSRegister::registerMDNSName(uint64_t requestIdentifier, PAL::SessionID sessionID, WebCore::DocumentIdentifier documentIdentifier, const String& ipAddress)
+void NetworkMDNSRegister::registerMDNSName(uint64_t requestIdentifier, WebCore::DocumentIdentifier documentIdentifier, const String& ipAddress)
 {
-    RELEASE_LOG_IF_ALLOWED(sessionID, "registerMDNSName not implemented");
+    RELEASE_LOG_IF_ALLOWED("registerMDNSName not implemented");
     m_connection.connection().send(Messages::WebMDNSRegister::FinishedRegisteringMDNSName { requestIdentifier, makeUnexpected(WebCore::MDNSRegisterError::NotImplemented) }, 0);
 }
 
 #endif
 
+PAL::SessionID NetworkMDNSRegister::sessionID() const
+{
+    return m_connection.sessionID();
+}
+
 } // namespace WebKit
 
 #undef RELEASE_LOG_IF_ALLOWED
index 7ab0b7b..48c7f71 100644 (file)
@@ -65,8 +65,10 @@ public:
 
 private:
     void unregisterMDNSNames(WebCore::DocumentIdentifier);
-    void registerMDNSName(uint64_t requestIdentifier, PAL::SessionID, WebCore::DocumentIdentifier, const String& ipAddress);
-    void resolveMDNSName(uint64_t requestIdentifier, PAL::SessionID, const String& name);
+    void registerMDNSName(uint64_t requestIdentifier, WebCore::DocumentIdentifier, const String& ipAddress);
+    void resolveMDNSName(uint64_t requestIdentifier, const String& name);
+    
+    PAL::SessionID sessionID() const;
 
     NetworkConnectionToWebProcess& m_connection;
 #if ENABLE_MDNS
index 62bed7e..2bf495a 100644 (file)
@@ -24,7 +24,7 @@
 
 messages -> NetworkMDNSRegister {
     UnregisterMDNSNames(WebCore::DocumentIdentifier documentIdentifier)
-    RegisterMDNSName(uint64_t requestIdentifier, PAL::SessionID sessionID, WebCore::DocumentIdentifier documentIdentifier, String ipAddress)
+    RegisterMDNSName(uint64_t requestIdentifier, WebCore::DocumentIdentifier documentIdentifier, String ipAddress)
 }
 
 #endif // ENABLE(WEB_RTC)
index 66590f1..f7ee4db 100644 (file)
@@ -137,9 +137,9 @@ rtc::ProxyInfo NetworkRTCProvider::proxyInfoFromSession(const RTCNetwork::Socket
 }
 #endif
 
-void NetworkRTCProvider::createClientTCPSocket(uint64_t identifier, const RTCNetwork::SocketAddress& localAddress, const RTCNetwork::SocketAddress& remoteAddress, PAL::SessionID sessionID, String&& userAgent, int options)
+void NetworkRTCProvider::createClientTCPSocket(uint64_t identifier, const RTCNetwork::SocketAddress& localAddress, const RTCNetwork::SocketAddress& remoteAddress, String&& userAgent, int options)
 {
-    auto* session = m_connection->networkProcess().networkSession(sessionID);
+    auto* session = m_connection->networkSession();
     if (!session) {
         m_connection->connection().send(Messages::WebRTCSocket::SignalClose(1), identifier);
         return;
index 6643dd8..d054fb6 100644 (file)
@@ -98,7 +98,7 @@ private:
     explicit NetworkRTCProvider(NetworkConnectionToWebProcess&);
 
     void createUDPSocket(uint64_t, const RTCNetwork::SocketAddress&, uint16_t, uint16_t);
-    void createClientTCPSocket(uint64_t, const RTCNetwork::SocketAddress&, const RTCNetwork::SocketAddress&, PAL::SessionID, String&& userAgent, int);
+    void createClientTCPSocket(uint64_t, const RTCNetwork::SocketAddress&, const RTCNetwork::SocketAddress&, String&& userAgent, int);
     void createServerTCPSocket(uint64_t, const RTCNetwork::SocketAddress&, uint16_t minPort, uint16_t maxPort, int);
     void wrapNewTCPConnection(uint64_t identifier, uint64_t newConnectionSocketIdentifier);
 
index b415537..12236b3 100644 (file)
@@ -25,7 +25,7 @@
 messages -> NetworkRTCProvider {
     CreateUDPSocket(int identifier, WebKit::RTCNetwork::SocketAddress localAddress, uint16_t minPort, uint16_t maxPort)
     CreateServerTCPSocket(int identifier, WebKit::RTCNetwork::SocketAddress localAddress, uint16_t minPort, uint16_t maxPort, int options)
-    CreateClientTCPSocket(int identifier, WebKit::RTCNetwork::SocketAddress localAddress, WebKit::RTCNetwork::SocketAddress remoteAddress, PAL::SessionID sessionID, String userAgent, int options)
+    CreateClientTCPSocket(int identifier, WebKit::RTCNetwork::SocketAddress localAddress, WebKit::RTCNetwork::SocketAddress remoteAddress, String userAgent, int options)
     CreateResolver(uint64_t identifier, String address)
     StopResolver(uint64_t identifier)
     WrapNewTCPConnection(uint64_t identifier, uint64_t newConnectionSocketIdentifier)
index 3d89dd7..fe8acfd 100644 (file)
@@ -60,17 +60,16 @@ void LibWebRTCProvider::unregisterMDNSNames(uint64_t documentIdentifier)
     WebProcess::singleton().libWebRTCNetwork().mdnsRegister().unregisterMDNSNames(documentIdentifier);
 }
 
-void LibWebRTCProvider::registerMDNSName(PAL::SessionID sessionID, uint64_t documentIdentifier, const String& ipAddress, CompletionHandler<void(MDNSNameOrError&&)>&& callback)
+void LibWebRTCProvider::registerMDNSName(PAL::SessionID, uint64_t documentIdentifier, const String& ipAddress, CompletionHandler<void(MDNSNameOrError&&)>&& callback)
 {
-    WebProcess::singleton().libWebRTCNetwork().mdnsRegister().registerMDNSName(sessionID, documentIdentifier, ipAddress, WTFMove(callback));
+    WebProcess::singleton().libWebRTCNetwork().mdnsRegister().registerMDNSName(documentIdentifier, ipAddress, WTFMove(callback));
 }
 
 class RTCSocketFactory final : public rtc::PacketSocketFactory {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    RTCSocketFactory(PAL::SessionID sessionID, String&& userAgent)
-        : m_sessionID(sessionID)
-        , m_userAgent(WTFMove(userAgent))
+    explicit RTCSocketFactory(String&& userAgent)
+        : m_userAgent(WTFMove(userAgent))
     {
     }
 
@@ -87,7 +86,7 @@ private:
 
     rtc::AsyncPacketSocket* CreateClientTcpSocket(const rtc::SocketAddress& localAddress, const rtc::SocketAddress& remoteAddress, const rtc::ProxyInfo&, const std::string&, int options) final
     {
-        return factory().createClientTcpSocket(localAddress, remoteAddress, m_sessionID, String { m_userAgent }, options);
+        return factory().createClientTcpSocket(localAddress, remoteAddress, String { m_userAgent }, options);
     }
 
     rtc::AsyncResolverInterface* CreateAsyncResolver() final
@@ -98,13 +97,12 @@ private:
     LibWebRTCSocketFactory& factory() { return WebProcess::singleton().libWebRTCNetwork().socketFactory(); }
 
 private:
-    PAL::SessionID m_sessionID;
     String m_userAgent;
 };
 
-std::unique_ptr<rtc::PacketSocketFactory> LibWebRTCProvider::createSocketFactory(PAL::SessionID sessionID, String&& userAgent)
+std::unique_ptr<rtc::PacketSocketFactory> LibWebRTCProvider::createSocketFactory(PAL::SessionID, String&& userAgent)
 {
-    return makeUnique<RTCSocketFactory>(sessionID, WTFMove(userAgent));
+    return makeUnique<RTCSocketFactory>(WTFMove(userAgent));
 }
 
 } // namespace WebKit
index 23582de..6d3c0b1 100644 (file)
@@ -78,14 +78,14 @@ rtc::AsyncPacketSocket* LibWebRTCSocketFactory::createUdpSocket(const rtc::Socke
     return socket.release();
 }
 
-rtc::AsyncPacketSocket* LibWebRTCSocketFactory::createClientTcpSocket(const rtc::SocketAddress& localAddress, const rtc::SocketAddress& remoteAddress, PAL::SessionID sessionID, String&& userAgent, int options)
+rtc::AsyncPacketSocket* LibWebRTCSocketFactory::createClientTcpSocket(const rtc::SocketAddress& localAddress, const rtc::SocketAddress& remoteAddress, String&& userAgent, int options)
 {
     auto socket = makeUnique<LibWebRTCSocket>(*this, ++s_uniqueSocketIdentifier, LibWebRTCSocket::Type::ClientTCP, localAddress, remoteAddress);
     socket->setState(LibWebRTCSocket::STATE_CONNECTING);
     m_sockets.set(socket->identifier(), socket.get());
 
-    callOnMainThread([identifier = socket->identifier(), localAddress = prepareSocketAddress(localAddress, m_disableNonLocalhostConnections), remoteAddress = prepareSocketAddress(remoteAddress, m_disableNonLocalhostConnections), sessionID, userAgent = WTFMove(userAgent).isolatedCopy(), options]() {
-        if (!WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkRTCProvider::CreateClientTCPSocket(identifier, RTCNetwork::SocketAddress(localAddress), RTCNetwork::SocketAddress(remoteAddress), sessionID, userAgent, options), 0)) {
+    callOnMainThread([identifier = socket->identifier(), localAddress = prepareSocketAddress(localAddress, m_disableNonLocalhostConnections), remoteAddress = prepareSocketAddress(remoteAddress, m_disableNonLocalhostConnections), userAgent = WTFMove(userAgent).isolatedCopy(), options]() {
+        if (!WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkRTCProvider::CreateClientTCPSocket(identifier, RTCNetwork::SocketAddress(localAddress), RTCNetwork::SocketAddress(remoteAddress), userAgent, options), 0)) {
             // FIXME: Set error back to socket
             return;
         }
index 2446604..494f9d4 100644 (file)
@@ -53,7 +53,7 @@ public:
 
     rtc::AsyncPacketSocket* createUdpSocket(const rtc::SocketAddress&, uint16_t minPort, uint16_t maxPort);
     rtc::AsyncPacketSocket* createServerTcpSocket(const rtc::SocketAddress&, uint16_t minPort, uint16_t maxPort, int options);
-    rtc::AsyncPacketSocket* createClientTcpSocket(const rtc::SocketAddress& localAddress, const rtc::SocketAddress& remoteAddress, PAL::SessionID, String&& userAgent, int options);
+    rtc::AsyncPacketSocket* createClientTcpSocket(const rtc::SocketAddress& localAddress, const rtc::SocketAddress& remoteAddress, String&& userAgent, int options);
     rtc::AsyncResolverInterface* createAsyncResolver();
 
 private:
index f227008..bc10b95 100644 (file)
@@ -62,7 +62,7 @@ void WebMDNSRegister::unregisterMDNSNames(uint64_t documentIdentifier)
     connection.send(Messages::NetworkMDNSRegister::UnregisterMDNSNames { identifier }, 0);
 }
 
-void WebMDNSRegister::registerMDNSName(PAL::SessionID sessionID, uint64_t documentIdentifier, const String& ipAddress, CompletionHandler<void(LibWebRTCProvider::MDNSNameOrError&&)>&& callback)
+void WebMDNSRegister::registerMDNSName(uint64_t documentIdentifier, const String& ipAddress, CompletionHandler<void(LibWebRTCProvider::MDNSNameOrError&&)>&& callback)
 {
     auto identifier = makeObjectIdentifier<DocumentIdentifierType>(documentIdentifier);
     auto& map = m_registeringDocuments.ensure(identifier, [] {
@@ -78,7 +78,7 @@ void WebMDNSRegister::registerMDNSName(PAL::SessionID sessionID, uint64_t docume
     m_pendingRegistrations.add(++m_pendingRequestsIdentifier, PendingRegistration { WTFMove(callback), identifier, ipAddress });
 
     auto& connection = WebProcess::singleton().ensureNetworkProcessConnection().connection();
-    if (!connection.send(Messages::NetworkMDNSRegister::RegisterMDNSName { m_pendingRequestsIdentifier, sessionID, identifier, ipAddress }, 0))
+    if (!connection.send(Messages::NetworkMDNSRegister::RegisterMDNSName { m_pendingRequestsIdentifier, identifier, ipAddress }, 0))
         finishedRegisteringMDNSName(m_pendingRequestsIdentifier, makeUnexpected(MDNSRegisterError::Internal));
 }
 
index c1bbcac..3f73881 100644 (file)
@@ -45,7 +45,7 @@ public:
     WebMDNSRegister() = default;
 
     void unregisterMDNSNames(uint64_t documentIdentifier);
-    void registerMDNSName(PAL::SessionID, uint64_t documentIdentifier, const String& ipAddress, CompletionHandler<void(WebCore::LibWebRTCProvider::MDNSNameOrError&&)>&&);
+    void registerMDNSName(uint64_t documentIdentifier, const String& ipAddress, CompletionHandler<void(WebCore::LibWebRTCProvider::MDNSNameOrError&&)>&&);
 
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&);