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 #ifndef mozilla_dom_TCPSocketChild_h
8 #define mozilla_dom_TCPSocketChild_h
10 #include "mozilla/dom/TypedArray.h"
11 #include "mozilla/net/PTCPSocketChild.h"
12 #include "nsCycleCollectionParticipant.h"
14 #include "js/TypeDecls.h"
16 class nsITCPSocketCallback
;
19 bool DeserializeArrayBuffer(JSContext
* cx
, const nsTArray
<uint8_t>& aBuffer
,
20 JS::MutableHandle
<JS::Value
> aVal
);
23 namespace mozilla::dom
{
27 class TCPSocketChildBase
: public nsISupports
{
29 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TCPSocketChildBase
)
30 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
32 void AddIPDLReference();
33 void ReleaseIPDLReference();
37 virtual ~TCPSocketChildBase();
39 nsCOMPtr
<nsITCPSocketCallback
> mSocket
;
43 class TCPSocketChild
: public mozilla::net::PTCPSocketChild
,
44 public TCPSocketChildBase
{
46 NS_IMETHOD_(MozExternalRefCountType
) Release() override
;
48 TCPSocketChild(const nsAString
& aHost
, const uint16_t& aPort
,
49 nsISerialEventTarget
* aTarget
);
52 void SendOpen(nsITCPSocketCallback
* aSocket
, bool aUseSSL
,
53 bool aUseArrayBuffers
);
54 void SendSend(const nsACString
& aData
);
55 void SendSend(nsTArray
<uint8_t>&& aData
);
56 void SetSocket(TCPSocket
* aSocket
);
58 void GetHost(nsAString
& aHost
);
59 void GetPort(uint16_t* aPort
) const;
61 mozilla::ipc::IPCResult
RecvCallback(const nsString
& aType
,
62 const CallbackData
& aData
,
63 const uint32_t& aReadyState
);
64 mozilla::ipc::IPCResult
RecvRequestDelete();
65 mozilla::ipc::IPCResult
RecvUpdateBufferedAmount(
66 const uint32_t& aBufferred
, const uint32_t& aTrackingNumber
);
71 nsCOMPtr
<nsISerialEventTarget
> mIPCEventTarget
;
74 } // namespace mozilla::dom