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/. */
5 #include "TCPServerSocketChild.h"
6 #include "TCPSocketChild.h"
7 #include "mozilla/net/NeckoChild.h"
8 #include "mozilla/dom/PBrowserChild.h"
9 #include "mozilla/dom/TabChild.h"
10 #include "nsIDOMTCPSocket.h"
11 #include "nsJSUtils.h"
12 #include "jsfriendapi.h"
14 using mozilla::net::gNeckoChild
;
19 NS_IMPL_CYCLE_COLLECTION(TCPServerSocketChildBase
, mServerSocket
)
20 NS_IMPL_CYCLE_COLLECTING_ADDREF(TCPServerSocketChildBase
)
21 NS_IMPL_CYCLE_COLLECTING_RELEASE(TCPServerSocketChildBase
)
23 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TCPServerSocketChildBase
)
24 NS_INTERFACE_MAP_ENTRY(nsITCPServerSocketChild
)
25 NS_INTERFACE_MAP_ENTRY(nsISupports
)
28 TCPServerSocketChildBase::TCPServerSocketChildBase()
33 TCPServerSocketChildBase::~TCPServerSocketChildBase()
37 NS_IMETHODIMP_(MozExternalRefCountType
) TCPServerSocketChild::Release(void)
39 nsrefcnt refcnt
= TCPServerSocketChildBase::Release();
40 if (refcnt
== 1 && mIPCOpen
) {
41 PTCPServerSocketChild::SendRequestDelete();
47 TCPServerSocketChild::TCPServerSocketChild()
52 TCPServerSocketChild::Listen(nsITCPServerSocketInternal
* aServerSocket
, uint16_t aLocalPort
,
53 uint16_t aBacklog
, const nsAString
& aBinaryType
, JSContext
* aCx
)
55 mServerSocket
= aServerSocket
;
57 gNeckoChild
->SendPTCPServerSocketConstructor(this, aLocalPort
, aBacklog
, nsString(aBinaryType
));
62 TCPServerSocketChildBase::ReleaseIPDLReference()
70 TCPServerSocketChildBase::AddIPDLReference()
72 MOZ_ASSERT(!mIPCOpen
);
77 TCPServerSocketChild::~TCPServerSocketChild()
82 TCPServerSocketChild::RecvCallbackAccept(PTCPSocketChild
*psocket
)
84 TCPSocketChild
* socket
= static_cast<TCPSocketChild
*>(psocket
);
86 nsresult rv
= mServerSocket
->CallListenerAccept(static_cast<nsITCPSocketChild
*>(socket
));
88 NS_WARNING("CallListenerAccept threw exception.");
94 TCPServerSocketChild::RecvCallbackError(const nsString
& aMessage
,
95 const nsString
& aFilename
,
96 const uint32_t& aLineNumber
,
97 const uint32_t& aColumnNumber
)
99 nsresult rv
= mServerSocket
->CallListenerError(aMessage
, aFilename
,
100 aLineNumber
, aColumnNumber
);
102 NS_WARNING("CallListenerError threw exception.");
108 TCPServerSocketChild::Close()
115 } // namespace mozilla