Bug 1903805 - Added additional allowed characters to search-config-icons-schema.json...
[gecko.git] / dom / network / TCPSocketChild.h
blob69907a3f29b791e1a7233200238fed16c0d90b9b
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"
13 #include "nsCOMPtr.h"
14 #include "js/TypeDecls.h"
16 class nsITCPSocketCallback;
18 namespace IPC {
19 bool DeserializeArrayBuffer(JSContext* cx, const nsTArray<uint8_t>& aBuffer,
20 JS::MutableHandle<JS::Value> aVal);
23 namespace mozilla::dom {
25 class TCPSocket;
27 class TCPSocketChildBase : public nsISupports {
28 public:
29 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TCPSocketChildBase)
30 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
32 void AddIPDLReference();
33 void ReleaseIPDLReference();
35 protected:
36 TCPSocketChildBase();
37 virtual ~TCPSocketChildBase();
39 nsCOMPtr<nsITCPSocketCallback> mSocket;
40 bool mIPCOpen;
43 class TCPSocketChild : public mozilla::net::PTCPSocketChild,
44 public TCPSocketChildBase {
45 public:
46 NS_IMETHOD_(MozExternalRefCountType) Release() override;
48 TCPSocketChild(const nsAString& aHost, const uint16_t& aPort,
49 nsISerialEventTarget* aTarget);
50 ~TCPSocketChild();
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);
68 private:
69 nsString mHost;
70 uint16_t mPort;
71 nsCOMPtr<nsISerialEventTarget> mIPCEventTarget;
74 } // namespace mozilla::dom
76 #endif