summaryrefslogtreecommitdiffstats
path: root/dom/media/webrtc/transport/ipc/StunAddrsRequestParent.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /dom/media/webrtc/transport/ipc/StunAddrsRequestParent.h
parentInitial commit. (diff)
downloadthunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz
thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/webrtc/transport/ipc/StunAddrsRequestParent.h')
-rw-r--r--dom/media/webrtc/transport/ipc/StunAddrsRequestParent.h82
1 files changed, 82 insertions, 0 deletions
diff --git a/dom/media/webrtc/transport/ipc/StunAddrsRequestParent.h b/dom/media/webrtc/transport/ipc/StunAddrsRequestParent.h
new file mode 100644
index 0000000000..33e71abbc7
--- /dev/null
+++ b/dom/media/webrtc/transport/ipc/StunAddrsRequestParent.h
@@ -0,0 +1,82 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_net_StunAddrsRequestParent_h
+#define mozilla_net_StunAddrsRequestParent_h
+
+#include "mozilla/net/PStunAddrsRequestParent.h"
+
+struct MDNSService;
+
+namespace mozilla::net {
+
+class StunAddrsRequestParent : public PStunAddrsRequestParent {
+ friend class PStunAddrsRequestParent;
+
+ public:
+ StunAddrsRequestParent();
+
+ NS_IMETHOD_(MozExternalRefCountType) AddRef();
+ NS_IMETHOD_(MozExternalRefCountType) Release();
+
+ mozilla::ipc::IPCResult Recv__delete__() override;
+
+ void OnQueryComplete(const nsACString& hostname,
+ const Maybe<nsCString>& address);
+
+ protected:
+ virtual ~StunAddrsRequestParent();
+
+ virtual mozilla::ipc::IPCResult RecvGetStunAddrs() override;
+ virtual mozilla::ipc::IPCResult RecvRegisterMDNSHostname(
+ const nsACString& hostname, const nsACString& address) override;
+ virtual mozilla::ipc::IPCResult RecvQueryMDNSHostname(
+ const nsACString& hostname) override;
+ virtual mozilla::ipc::IPCResult RecvUnregisterMDNSHostname(
+ const nsACString& hostname) override;
+ virtual void ActorDestroy(ActorDestroyReason why) override;
+
+ nsCOMPtr<nsIThread> mMainThread;
+ nsCOMPtr<nsISerialEventTarget> mSTSThread;
+
+ void GetStunAddrs_s();
+ void SendStunAddrs_m(const NrIceStunAddrArray& addrs);
+
+ void OnQueryComplete_m(const nsACString& hostname,
+ const Maybe<nsCString>& address);
+
+ ThreadSafeAutoRefCnt mRefCnt;
+ NS_DECL_OWNINGTHREAD
+
+ private:
+ bool mIPCClosed; // true if IPDL channel has been closed (child crash)
+
+ class MDNSServiceWrapper {
+ public:
+ explicit MDNSServiceWrapper(const std::string& ifaddr);
+ void RegisterHostname(const char* hostname, const char* address);
+ void QueryHostname(void* data, const char* hostname);
+ void UnregisterHostname(const char* hostname);
+
+ NS_IMETHOD_(MozExternalRefCountType) AddRef();
+ NS_IMETHOD_(MozExternalRefCountType) Release();
+
+ protected:
+ ThreadSafeAutoRefCnt mRefCnt;
+ NS_DECL_OWNINGTHREAD
+
+ private:
+ virtual ~MDNSServiceWrapper();
+ void StartIfRequired();
+
+ std::string ifaddr;
+ MDNSService* mMDNSService = nullptr;
+ };
+
+ static StaticRefPtr<MDNSServiceWrapper> mSharedMDNSService;
+};
+
+} // namespace mozilla::net
+
+#endif // mozilla_net_StunAddrsRequestParent_h