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
|
|
|
|
|
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 {
|
|
|
|
bool
|
|
|
|
DeserializeArrayBuffer(JSContext* cx,
|
|
|
|
const InfallibleTArray<uint8_t>& aBuffer,
|
|
|
|
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
|
|
|
|
2015-03-25 17:36:56 +03:00
|
|
|
TCPSocketChild(const nsAString& aHost, const uint16_t& aPort);
|
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);
|
|
|
|
void SendWindowlessOpenBind(nsITCPSocketCallback* aSocket,
|
2015-09-21 06:05:20 +03:00
|
|
|
const nsACString& aRemoteHost, uint16_t aRemotePort,
|
|
|
|
const nsACString& aLocalHost, uint16_t aLocalPort,
|
|
|
|
bool aUseSSL);
|
|
|
|
NS_IMETHOD SendSendArray(nsTArray<uint8_t>& aArray,
|
|
|
|
uint32_t aTrackingNumber);
|
2015-03-25 17:36:56 +03:00
|
|
|
void SendSend(const nsACString& aData, uint32_t aTrackingNumber);
|
|
|
|
nsresult SendSend(const ArrayBuffer& aData,
|
|
|
|
uint32_t aByteOffset,
|
|
|
|
uint32_t aByteLength,
|
|
|
|
uint32_t aTrackingNumber);
|
2015-09-21 06:05:20 +03:00
|
|
|
void SendSendArray(nsTArray<uint8_t>* arr,
|
|
|
|
uint32_t trackingNumber);
|
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
|
|
|
|
2012-09-24 22:53:49 +04:00
|
|
|
virtual bool RecvCallback(const nsString& aType,
|
|
|
|
const CallbackData& aData,
|
2015-03-25 17:36:56 +03:00
|
|
|
const uint32_t& aReadyState) override;
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool RecvRequestDelete() override;
|
2013-11-14 12:00:28 +04:00
|
|
|
virtual bool RecvUpdateBufferedAmount(const uint32_t& aBufferred,
|
2015-03-21 19:28:04 +03:00
|
|
|
const uint32_t& aTrackingNumber) override;
|
2016-02-11 12:18:46 +03:00
|
|
|
nsresult SetFilterName(const nsACString& aFilterName);
|
2012-09-24 22:53:49 +04:00
|
|
|
private:
|
2013-12-19 07:21:12 +04:00
|
|
|
nsString mHost;
|
|
|
|
uint16_t mPort;
|
2016-02-11 12:18:46 +03:00
|
|
|
nsCString mFilterName;
|
2012-09-24 22:53:49 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2013-11-26 20:38:52 +04:00
|
|
|
|
|
|
|
#endif
|