StunAddrsRequestChild.h (1878B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 #ifndef mozilla_net_StunAddrsRequestChild_h 6 #define mozilla_net_StunAddrsRequestChild_h 7 8 #include "mozilla/net/PStunAddrsRequestChild.h" 9 10 class nsISerialEventTarget; 11 12 namespace mozilla::net { 13 14 class StunAddrsListener { 15 public: 16 virtual void OnMDNSQueryComplete(const nsCString& hostname, 17 const Maybe<nsCString>& address) = 0; 18 virtual void OnStunAddrsAvailable(const NrIceStunAddrArray& addrs) = 0; 19 20 NS_IMETHOD_(MozExternalRefCountType) AddRef(); 21 NS_IMETHOD_(MozExternalRefCountType) Release(); 22 23 protected: 24 virtual ~StunAddrsListener() = default; 25 26 ThreadSafeAutoRefCnt mRefCnt; 27 NS_DECL_OWNINGTHREAD 28 }; 29 30 class StunAddrsRequestChild final : public PStunAddrsRequestChild { 31 friend class PStunAddrsRequestChild; 32 33 public: 34 explicit StunAddrsRequestChild(StunAddrsListener* listener); 35 36 NS_IMETHOD_(MozExternalRefCountType) AddRef(); 37 NS_IMETHOD_(MozExternalRefCountType) Release(); 38 39 // Not sure why AddIPDLReference & ReleaseIPDLReference don't come 40 // from PStunAddrsRequestChild since the IPC plumbing seem to 41 // expect this. 42 void AddIPDLReference() { AddRef(); } 43 void ReleaseIPDLReference() { Release(); } 44 45 void Cancel(); 46 47 protected: 48 virtual ~StunAddrsRequestChild() = default; 49 50 virtual mozilla::ipc::IPCResult RecvOnMDNSQueryComplete( 51 const nsACString& aHostname, const Maybe<nsCString>& aAddress) override; 52 53 virtual mozilla::ipc::IPCResult RecvOnStunAddrsAvailable( 54 const NrIceStunAddrArray& addrs) override; 55 56 RefPtr<StunAddrsListener> mListener; 57 58 ThreadSafeAutoRefCnt mRefCnt; 59 NS_DECL_OWNINGTHREAD 60 }; 61 62 } // namespace mozilla::net 63 64 #endif // mozilla_net_StunAddrsRequestChild_h