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/. */
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/BrowserChild.h"
13 #include "nsJSUtils.h"
14 #include "jsfriendapi.h"
16 using mozilla::net::gNeckoChild
;
18 namespace mozilla::dom
{
20 NS_IMPL_CYCLE_COLLECTION(TCPServerSocketChildBase
, mServerSocket
)
21 NS_IMPL_CYCLE_COLLECTING_ADDREF(TCPServerSocketChildBase
)
22 NS_IMPL_CYCLE_COLLECTING_RELEASE(TCPServerSocketChildBase
)
24 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TCPServerSocketChildBase
)
25 NS_INTERFACE_MAP_ENTRY(nsISupports
)
28 TCPServerSocketChildBase::TCPServerSocketChildBase() : mIPCOpen(false) {}
30 TCPServerSocketChildBase::~TCPServerSocketChildBase() = default;
32 NS_IMETHODIMP_(MozExternalRefCountType
) TCPServerSocketChild::Release(void) {
33 nsrefcnt refcnt
= TCPServerSocketChildBase::Release();
34 if (refcnt
== 1 && mIPCOpen
) {
35 PTCPServerSocketChild::SendRequestDelete();
41 TCPServerSocketChild::TCPServerSocketChild(TCPServerSocket
* aServerSocket
,
44 bool aUseArrayBuffers
) {
45 mServerSocket
= aServerSocket
;
47 gNeckoChild
->SendPTCPServerSocketConstructor(this, aLocalPort
, aBacklog
,
51 void TCPServerSocketChildBase::ReleaseIPDLReference() {
57 void TCPServerSocketChildBase::AddIPDLReference() {
58 MOZ_ASSERT(!mIPCOpen
);
63 TCPServerSocketChild::~TCPServerSocketChild() = default;
65 mozilla::ipc::IPCResult
TCPServerSocketChild::RecvCallbackAccept(
66 PTCPSocketChild
* psocket
) {
67 RefPtr
<TCPSocketChild
> socket
= static_cast<TCPSocketChild
*>(psocket
);
68 nsresult rv
= mServerSocket
->AcceptChildSocket(socket
);
69 NS_ENSURE_SUCCESS(rv
, IPC_OK());
73 void TCPServerSocketChild::Close() { SendClose(); }
75 } // namespace mozilla::dom