Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / dom / network / TCPSocketParent.h
blob388add862d4daf1e4eb504458bfc46c82a2cbcd5
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_TCPSocketParent_h
8 #define mozilla_dom_TCPSocketParent_h
10 #include "mozilla/dom/TCPSocketBinding.h"
11 #include "mozilla/net/PTCPSocketParent.h"
12 #include "nsCycleCollectionParticipant.h"
13 #include "nsCOMPtr.h"
14 #include "js/TypeDecls.h"
16 #define TCPSOCKETPARENT_CID \
17 { \
18 0x4e7246c6, 0xa8b3, 0x426d, { \
19 0x9c, 0x17, 0x76, 0xda, 0xb1, 0xe1, 0xe1, 0x4a \
20 } \
23 namespace mozilla::dom {
25 class TCPSocket;
27 class TCPSocketParentBase : public nsISupports {
28 public:
29 NS_DECL_CYCLE_COLLECTION_CLASS(TCPSocketParentBase)
30 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
32 void AddIPDLReference();
33 void ReleaseIPDLReference();
35 bool IPCOpen() const { return mIPCOpen; }
37 protected:
38 TCPSocketParentBase();
39 virtual ~TCPSocketParentBase();
41 RefPtr<TCPSocket> mSocket;
42 bool mIPCOpen;
45 class TCPSocketParent : public mozilla::net::PTCPSocketParent,
46 public TCPSocketParentBase {
47 public:
48 NS_IMETHOD_(MozExternalRefCountType) Release() override;
50 TCPSocketParent() = default;
52 mozilla::ipc::IPCResult RecvOpen(const nsString& aHost, const uint16_t& aPort,
53 const bool& useSSL,
54 const bool& aUseArrayBuffers);
56 mozilla::ipc::IPCResult RecvStartTLS();
57 mozilla::ipc::IPCResult RecvSuspend();
58 mozilla::ipc::IPCResult RecvResume();
59 mozilla::ipc::IPCResult RecvClose();
60 mozilla::ipc::IPCResult RecvData(const SendableData& aData);
61 mozilla::ipc::IPCResult RecvRequestDelete();
63 void FireErrorEvent(const nsAString& aName, const nsAString& aType,
64 nsresult aError, TCPReadyState aReadyState);
65 void FireEvent(const nsAString& aType, TCPReadyState aReadyState);
66 void FireArrayBufferDataEvent(nsTArray<uint8_t>& aBuffer,
67 TCPReadyState aReadyState);
68 void FireStringDataEvent(const nsACString& aData, TCPReadyState aReadyState);
70 void SetSocket(TCPSocket* socket);
71 nsresult GetHost(nsAString& aHost);
72 nsresult GetPort(uint16_t* aPort);
74 private:
75 virtual void ActorDestroy(ActorDestroyReason why) override;
76 void SendEvent(const nsAString& aType, CallbackData aData,
77 TCPReadyState aReadyState);
80 } // namespace mozilla::dom
82 #endif