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