/src/mozilla-central/dom/network/TCPServerSocketChild.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
5 | | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #include "TCPServerSocketChild.h" |
8 | | #include "TCPSocketChild.h" |
9 | | #include "TCPServerSocket.h" |
10 | | #include "mozilla/net/NeckoChild.h" |
11 | | #include "mozilla/dom/PBrowserChild.h" |
12 | | #include "mozilla/dom/TabChild.h" |
13 | | #include "nsJSUtils.h" |
14 | | #include "jsfriendapi.h" |
15 | | |
16 | | using mozilla::net::gNeckoChild; |
17 | | |
18 | | namespace mozilla { |
19 | | namespace dom { |
20 | | |
21 | | NS_IMPL_CYCLE_COLLECTION(TCPServerSocketChildBase, mServerSocket) |
22 | | NS_IMPL_CYCLE_COLLECTING_ADDREF(TCPServerSocketChildBase) |
23 | | NS_IMPL_CYCLE_COLLECTING_RELEASE(TCPServerSocketChildBase) |
24 | | |
25 | 0 | NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TCPServerSocketChildBase) |
26 | 0 | NS_INTERFACE_MAP_ENTRY(nsISupports) |
27 | 0 | NS_INTERFACE_MAP_END |
28 | | |
29 | | TCPServerSocketChildBase::TCPServerSocketChildBase() |
30 | | : mIPCOpen(false) |
31 | 0 | { |
32 | 0 | } |
33 | | |
34 | | TCPServerSocketChildBase::~TCPServerSocketChildBase() |
35 | 0 | { |
36 | 0 | } |
37 | | |
38 | | NS_IMETHODIMP_(MozExternalRefCountType) TCPServerSocketChild::Release(void) |
39 | 0 | { |
40 | 0 | nsrefcnt refcnt = TCPServerSocketChildBase::Release(); |
41 | 0 | if (refcnt == 1 && mIPCOpen) { |
42 | 0 | PTCPServerSocketChild::SendRequestDelete(); |
43 | 0 | return 1; |
44 | 0 | } |
45 | 0 | return refcnt; |
46 | 0 | } |
47 | | |
48 | | TCPServerSocketChild::TCPServerSocketChild(TCPServerSocket* aServerSocket, uint16_t aLocalPort, |
49 | | uint16_t aBacklog, bool aUseArrayBuffers, |
50 | | nsIEventTarget* aIPCEventTarget) |
51 | 0 | { |
52 | 0 | mServerSocket = aServerSocket; |
53 | 0 | if (aIPCEventTarget) { |
54 | 0 | gNeckoChild->SetEventTargetForActor(this, aIPCEventTarget); |
55 | 0 | } |
56 | 0 | AddIPDLReference(); |
57 | 0 | gNeckoChild->SendPTCPServerSocketConstructor(this, aLocalPort, aBacklog, aUseArrayBuffers); |
58 | 0 | } |
59 | | |
60 | | void |
61 | | TCPServerSocketChildBase::ReleaseIPDLReference() |
62 | 0 | { |
63 | 0 | MOZ_ASSERT(mIPCOpen); |
64 | 0 | mIPCOpen = false; |
65 | 0 | this->Release(); |
66 | 0 | } |
67 | | |
68 | | void |
69 | | TCPServerSocketChildBase::AddIPDLReference() |
70 | 0 | { |
71 | 0 | MOZ_ASSERT(!mIPCOpen); |
72 | 0 | mIPCOpen = true; |
73 | 0 | this->AddRef(); |
74 | 0 | } |
75 | | |
76 | | TCPServerSocketChild::~TCPServerSocketChild() |
77 | 0 | { |
78 | 0 | } |
79 | | |
80 | | mozilla::ipc::IPCResult |
81 | | TCPServerSocketChild::RecvCallbackAccept(PTCPSocketChild *psocket) |
82 | 0 | { |
83 | 0 | RefPtr<TCPSocketChild> socket = static_cast<TCPSocketChild*>(psocket); |
84 | 0 | nsresult rv = mServerSocket->AcceptChildSocket(socket); |
85 | 0 | NS_ENSURE_SUCCESS(rv, IPC_OK()); |
86 | 0 | return IPC_OK(); |
87 | 0 | } |
88 | | |
89 | | void |
90 | | TCPServerSocketChild::Close() |
91 | 0 | { |
92 | 0 | SendClose(); |
93 | 0 | } |
94 | | |
95 | | } // namespace dom |
96 | | } // namespace mozilla |