LCOV - code coverage report
Current view: top level - media/mtransport/ipc - StunAddrsRequestParent.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 37 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 8 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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 "StunAddrsRequestParent.h"
       6             : 
       7             : #include "../runnable_utils.h"
       8             : #include "nsNetUtil.h"
       9             : 
      10             : #include "mtransport/nricectx.h"
      11             : #include "mtransport/nricemediastream.h" // needed only for including nricectx.h
      12             : #include "mtransport/nricestunaddr.h"
      13             : 
      14             : using namespace mozilla::ipc;
      15             : 
      16             : namespace mozilla {
      17             : namespace net {
      18             : 
      19           0 : StunAddrsRequestParent::StunAddrsRequestParent()
      20           0 :   : mIPCClosed(false)
      21             : {
      22           0 :   NS_GetMainThread(getter_AddRefs(mMainThread));
      23             : 
      24             :   nsresult res;
      25           0 :   mSTSThread = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &res);
      26           0 :   MOZ_ASSERT(mSTSThread);
      27           0 : }
      28             : 
      29             : mozilla::ipc::IPCResult
      30           0 : StunAddrsRequestParent::RecvGetStunAddrs()
      31             : {
      32           0 :   ASSERT_ON_THREAD(mMainThread);
      33             : 
      34           0 :   if (mIPCClosed) {
      35           0 :     return IPC_OK();
      36             :   }
      37             : 
      38           0 :   RUN_ON_THREAD(mSTSThread,
      39           0 :                 WrapRunnable(RefPtr<StunAddrsRequestParent>(this),
      40             :                              &StunAddrsRequestParent::GetStunAddrs_s),
      41           0 :                 NS_DISPATCH_NORMAL);
      42             : 
      43           0 :   return IPC_OK();
      44             : }
      45             : 
      46             : mozilla::ipc::IPCResult
      47           0 : StunAddrsRequestParent::Recv__delete__()
      48             : {
      49             :   // see note below in ActorDestroy
      50           0 :   mIPCClosed = true;
      51           0 :   return IPC_OK();
      52             : }
      53             : 
      54             : void
      55           0 : StunAddrsRequestParent::ActorDestroy(ActorDestroyReason why)
      56             : {
      57             :   // We may still have refcount>0 if we haven't made it through
      58             :   // GetStunAddrs_s and SendStunAddrs_m yet, but child process
      59             :   // has crashed.  We must not send any more msgs to child, or
      60             :   // IPDL will kill chrome process, too.
      61           0 :   mIPCClosed = true;
      62           0 : }
      63             : 
      64             : void
      65           0 : StunAddrsRequestParent::GetStunAddrs_s()
      66             : {
      67           0 :   ASSERT_ON_THREAD(mSTSThread);
      68             : 
      69             :   // get the stun addresses while on STS thread
      70           0 :   NrIceStunAddrArray addrs = NrIceCtx::GetStunAddrs();
      71             : 
      72           0 :   if (mIPCClosed) {
      73           0 :     return;
      74             :   }
      75             : 
      76             :   // in order to return the result over IPC, we need to be on main thread
      77           0 :   RUN_ON_THREAD(mMainThread,
      78           0 :                 WrapRunnable(RefPtr<StunAddrsRequestParent>(this),
      79             :                              &StunAddrsRequestParent::SendStunAddrs_m,
      80           0 :                              std::move(addrs)),
      81           0 :                 NS_DISPATCH_NORMAL);
      82             : }
      83             : 
      84             : void
      85           0 : StunAddrsRequestParent::SendStunAddrs_m(const NrIceStunAddrArray& addrs)
      86             : {
      87           0 :   ASSERT_ON_THREAD(mMainThread);
      88             : 
      89           0 :   if (mIPCClosed) {
      90             :     // nothing to do: child probably crashed
      91           0 :     return;
      92             :   }
      93             : 
      94           0 :   mIPCClosed = true;
      95             :   // send the new addresses back to the child
      96           0 :   Unused << SendOnStunAddrsAvailable(addrs);
      97             : }
      98             : 
      99           0 : NS_IMPL_ADDREF(StunAddrsRequestParent)
     100           0 : NS_IMPL_RELEASE(StunAddrsRequestParent)
     101             : 
     102             : } // namespace net
     103             : } // namespace mozilla

Generated by: LCOV version 1.13