2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-09-24 22:53:49 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2013-11-26 20:38:52 +04:00
|
|
|
#ifndef mozilla_dom_TCPSocketChild_h
|
|
|
|
#define mozilla_dom_TCPSocketChild_h
|
|
|
|
|
2016-08-10 09:18:29 +03:00
|
|
|
#include "mozilla/dom/TypedArray.h"
|
2012-09-24 22:53:49 +04:00
|
|
|
#include "mozilla/net/PTCPSocketChild.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2013-08-28 06:59:14 +04:00
|
|
|
#include "js/TypeDecls.h"
|
2012-09-24 22:53:49 +04:00
|
|
|
|
2015-09-21 06:05:20 +03:00
|
|
|
class nsITCPSocketCallback;
|
|
|
|
|
2015-09-21 06:05:20 +03:00
|
|
|
namespace IPC {
|
2019-07-10 06:27:30 +03:00
|
|
|
bool DeserializeArrayBuffer(JSContext* cx, const nsTArray<uint8_t>& aBuffer,
|
2015-09-21 06:05:20 +03:00
|
|
|
JS::MutableHandle<JS::Value> aVal);
|
|
|
|
}
|
|
|
|
|
2012-09-24 22:53:49 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2015-03-25 17:36:56 +03:00
|
|
|
class TCPSocket;
|
|
|
|
|
|
|
|
class TCPSocketChildBase : public nsISupports {
|
2012-09-24 22:53:49 +04:00
|
|
|
public:
|
2015-07-08 23:06:33 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TCPSocketChildBase)
|
2012-09-24 22:53:49 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
|
|
|
|
void AddIPDLReference();
|
|
|
|
void ReleaseIPDLReference();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
TCPSocketChildBase();
|
|
|
|
virtual ~TCPSocketChildBase();
|
|
|
|
|
2015-09-21 06:05:20 +03:00
|
|
|
nsCOMPtr<nsITCPSocketCallback> mSocket;
|
2012-09-24 22:53:49 +04:00
|
|
|
bool mIPCOpen;
|
|
|
|
};
|
|
|
|
|
|
|
|
class TCPSocketChild : public mozilla::net::PTCPSocketChild,
|
|
|
|
public TCPSocketChildBase {
|
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD_(MozExternalRefCountType) Release() override;
|
2012-09-24 22:53:49 +04:00
|
|
|
|
2017-06-12 01:22:00 +03:00
|
|
|
TCPSocketChild(const nsAString& aHost, const uint16_t& aPort,
|
2020-06-23 06:21:14 +03:00
|
|
|
nsISerialEventTarget* aTarget);
|
2012-09-24 22:53:49 +04:00
|
|
|
~TCPSocketChild();
|
|
|
|
|
2015-09-21 06:05:20 +03:00
|
|
|
void SendOpen(nsITCPSocketCallback* aSocket, bool aUseSSL,
|
|
|
|
bool aUseArrayBuffers);
|
2019-09-17 21:18:15 +03:00
|
|
|
void SendSend(const nsACString& aData);
|
2015-03-25 17:36:56 +03:00
|
|
|
nsresult SendSend(const ArrayBuffer& aData, uint32_t aByteOffset,
|
2019-09-17 21:18:15 +03:00
|
|
|
uint32_t aByteLength);
|
2015-03-25 17:36:56 +03:00
|
|
|
void SetSocket(TCPSocket* aSocket);
|
|
|
|
|
|
|
|
void GetHost(nsAString& aHost);
|
|
|
|
void GetPort(uint16_t* aPort);
|
2013-12-19 07:21:12 +04:00
|
|
|
|
2019-02-06 18:58:43 +03:00
|
|
|
mozilla::ipc::IPCResult RecvCallback(const nsString& aType,
|
|
|
|
const CallbackData& aData,
|
|
|
|
const uint32_t& aReadyState);
|
|
|
|
mozilla::ipc::IPCResult RecvRequestDelete();
|
|
|
|
mozilla::ipc::IPCResult RecvUpdateBufferedAmount(
|
|
|
|
const uint32_t& aBufferred, const uint32_t& aTrackingNumber);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2012-09-24 22:53:49 +04:00
|
|
|
private:
|
2013-12-19 07:21:12 +04:00
|
|
|
nsString mHost;
|
|
|
|
uint16_t mPort;
|
2020-06-23 06:21:14 +03:00
|
|
|
nsCOMPtr<nsISerialEventTarget> mIPCEventTarget;
|
2012-09-24 22:53:49 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2013-11-26 20:38:52 +04:00
|
|
|
|
|
|
|
#endif
|