tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

StunAddrsRequestChild.cpp (1314B)


      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 #include "StunAddrsRequestChild.h"
      6 
      7 #include "mozilla/net/NeckoChild.h"
      8 #include "nsISerialEventTarget.h"
      9 
     10 using namespace mozilla::ipc;
     11 
     12 namespace mozilla::net {
     13 
     14 StunAddrsRequestChild::StunAddrsRequestChild(StunAddrsListener* listener)
     15    : mListener(listener) {
     16  gNeckoChild->SendPStunAddrsRequestConstructor(this);
     17  // IPDL holds a reference until IPDL channel gets destroyed
     18  AddIPDLReference();
     19 }
     20 
     21 mozilla::ipc::IPCResult StunAddrsRequestChild::RecvOnMDNSQueryComplete(
     22    const nsACString& hostname, const Maybe<nsCString>& address) {
     23  if (mListener) {
     24    mListener->OnMDNSQueryComplete(PromiseFlatCString(hostname), address);
     25  }
     26  return IPC_OK();
     27 }
     28 
     29 mozilla::ipc::IPCResult StunAddrsRequestChild::RecvOnStunAddrsAvailable(
     30    const NrIceStunAddrArray& addrs) {
     31  if (mListener) {
     32    mListener->OnStunAddrsAvailable(addrs);
     33  }
     34  return IPC_OK();
     35 }
     36 
     37 void StunAddrsRequestChild::Cancel() { mListener = nullptr; }
     38 
     39 NS_IMPL_ADDREF(StunAddrsRequestChild)
     40 NS_IMPL_RELEASE(StunAddrsRequestChild)
     41 
     42 NS_IMPL_ADDREF(StunAddrsListener)
     43 NS_IMPL_RELEASE(StunAddrsListener)
     44 
     45 }  // namespace mozilla::net