зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1554976 - Add methods to register/unregister mDNS hostnames to StunAddrsRequestParent; r=mjf
Differential Revision: https://phabricator.services.mozilla.com/D38492 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
b9e2e7f9b3
Коммит
6803a86c10
|
@ -18,6 +18,9 @@ async protocol PStunAddrsRequest
|
|||
parent:
|
||||
async GetStunAddrs();
|
||||
|
||||
async RegisterMDNSHostname(nsCString hostname, nsCString address);
|
||||
async UnregisterMDNSHostname(nsCString hostname);
|
||||
|
||||
async __delete__();
|
||||
|
||||
child:
|
||||
|
|
|
@ -11,12 +11,15 @@
|
|||
#include "mtransport/nricemediastream.h" // needed only for including nricectx.h
|
||||
#include "mtransport/nricestunaddr.h"
|
||||
|
||||
#include "../mdns_service/mdns_service.h"
|
||||
|
||||
using namespace mozilla::ipc;
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
|
||||
StunAddrsRequestParent::StunAddrsRequestParent() : mIPCClosed(false) {
|
||||
StunAddrsRequestParent::StunAddrsRequestParent()
|
||||
: mIPCClosed(false), mMDNSService(nullptr) {
|
||||
NS_GetMainThread(getter_AddRefs(mMainThread));
|
||||
|
||||
nsresult res;
|
||||
|
@ -24,6 +27,13 @@ StunAddrsRequestParent::StunAddrsRequestParent() : mIPCClosed(false) {
|
|||
MOZ_ASSERT(mSTSThread);
|
||||
}
|
||||
|
||||
StunAddrsRequestParent::~StunAddrsRequestParent() {
|
||||
if (mMDNSService) {
|
||||
mdns_service_stop(mMDNSService);
|
||||
mMDNSService = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult StunAddrsRequestParent::RecvGetStunAddrs() {
|
||||
ASSERT_ON_THREAD(mMainThread);
|
||||
|
||||
|
@ -39,6 +49,41 @@ mozilla::ipc::IPCResult StunAddrsRequestParent::RecvGetStunAddrs() {
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult StunAddrsRequestParent::RecvRegisterMDNSHostname(
|
||||
const nsCString& aHostname, const nsCString& aAddress) {
|
||||
ASSERT_ON_THREAD(mMainThread);
|
||||
|
||||
if (mIPCClosed) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
if (!mMDNSService) {
|
||||
mMDNSService = mdns_service_start();
|
||||
}
|
||||
|
||||
if (mMDNSService) {
|
||||
mdns_service_register_hostname(mMDNSService, aHostname.BeginReading(),
|
||||
aAddress.BeginReading());
|
||||
}
|
||||
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult StunAddrsRequestParent::RecvUnregisterMDNSHostname(
|
||||
const nsCString& aHostname) {
|
||||
ASSERT_ON_THREAD(mMainThread);
|
||||
|
||||
if (mIPCClosed) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
if (mMDNSService) {
|
||||
mdns_service_unregister_hostname(mMDNSService, aHostname.BeginReading());
|
||||
}
|
||||
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult StunAddrsRequestParent::Recv__delete__() {
|
||||
// see note below in ActorDestroy
|
||||
mIPCClosed = true;
|
||||
|
@ -79,7 +124,6 @@ void StunAddrsRequestParent::SendStunAddrs_m(const NrIceStunAddrArray& addrs) {
|
|||
return;
|
||||
}
|
||||
|
||||
mIPCClosed = true;
|
||||
// send the new addresses back to the child
|
||||
Unused << SendOnStunAddrsAvailable(addrs);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,11 @@
|
|||
|
||||
#include "mozilla/net/PStunAddrsRequestParent.h"
|
||||
|
||||
#include "nsICancelable.h"
|
||||
#include "nsIDNSServiceDiscovery.h"
|
||||
|
||||
struct MDNSService;
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
|
||||
|
@ -22,9 +27,11 @@ class StunAddrsRequestParent : public PStunAddrsRequestParent {
|
|||
mozilla::ipc::IPCResult Recv__delete__() override;
|
||||
|
||||
protected:
|
||||
virtual ~StunAddrsRequestParent() {}
|
||||
virtual ~StunAddrsRequestParent();
|
||||
|
||||
virtual mozilla::ipc::IPCResult RecvGetStunAddrs() override;
|
||||
virtual mozilla::ipc::IPCResult RecvRegisterMDNSHostname(const nsCString& hostname, const nsCString& address) override;
|
||||
virtual mozilla::ipc::IPCResult RecvUnregisterMDNSHostname(const nsCString& hostname) override;
|
||||
virtual void ActorDestroy(ActorDestroyReason why) override;
|
||||
|
||||
nsCOMPtr<nsIThread> mMainThread;
|
||||
|
@ -38,6 +45,8 @@ class StunAddrsRequestParent : public PStunAddrsRequestParent {
|
|||
|
||||
private:
|
||||
bool mIPCClosed; // true if IPDL channel has been closed (child crash)
|
||||
|
||||
MDNSService* mMDNSService;
|
||||
};
|
||||
|
||||
} // namespace net
|
||||
|
|
Загрузка…
Ссылка в новой задаче