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/. */
|
|
|
|
|
|
|
|
#include "TCPSocketParent.h"
|
|
|
|
#include "jsapi.h"
|
|
|
|
#include "jsfriendapi.h"
|
|
|
|
#include "nsJSUtils.h"
|
2016-08-23 07:09:32 +03:00
|
|
|
#include "mozilla/Unused.h"
|
2013-08-21 10:49:42 +04:00
|
|
|
#include "mozilla/net/NeckoCommon.h"
|
|
|
|
#include "mozilla/net/PNeckoParent.h"
|
2013-08-29 10:15:08 +04:00
|
|
|
#include "mozilla/dom/ContentParent.h"
|
2014-08-15 05:47:15 +04:00
|
|
|
#include "mozilla/dom/ScriptSettings.h"
|
2013-08-29 10:15:08 +04:00
|
|
|
#include "mozilla/dom/TabParent.h"
|
2014-09-23 23:19:19 +04:00
|
|
|
#include "mozilla/HoldDropJSObjects.h"
|
2015-01-05 10:49:24 +03:00
|
|
|
#include "nsISocketTransportService.h"
|
|
|
|
#include "nsISocketTransport.h"
|
2013-09-24 01:30:40 +04:00
|
|
|
#include "nsIScriptSecurityManager.h"
|
2015-07-06 08:55:00 +03:00
|
|
|
#include "nsNetUtil.h"
|
2012-09-24 22:53:49 +04:00
|
|
|
|
|
|
|
namespace IPC {
|
|
|
|
|
|
|
|
//Defined in TCPSocketChild.cpp
|
|
|
|
extern bool
|
2015-03-25 17:36:56 +03:00
|
|
|
DeserializeArrayBuffer(JSContext* aCx,
|
2013-04-19 13:25:33 +04:00
|
|
|
const InfallibleTArray<uint8_t>& aBuffer,
|
2013-05-11 06:39:45 +04:00
|
|
|
JS::MutableHandle<JS::Value> aVal);
|
2012-09-24 22:53:49 +04:00
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace IPC
|
2012-09-24 22:53:49 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
2016-05-19 05:02:57 +03:00
|
|
|
|
|
|
|
namespace net {
|
|
|
|
//
|
2016-05-26 21:08:47 +03:00
|
|
|
// set MOZ_LOG=TCPSocket:5
|
2016-05-19 05:02:57 +03:00
|
|
|
//
|
|
|
|
extern LazyLogModule gTCPSocketLog;
|
|
|
|
#define TCPSOCKET_LOG(args) MOZ_LOG(gTCPSocketLog, LogLevel::Debug, args)
|
|
|
|
#define TCPSOCKET_LOG_ENABLED() MOZ_LOG_TEST(gTCPSocketLog, LogLevel::Debug)
|
|
|
|
} // namespace net
|
|
|
|
|
2012-09-24 22:53:49 +04:00
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
static void
|
|
|
|
FireInteralError(mozilla::net::PTCPSocketParent* aActor, uint32_t aLineNo)
|
|
|
|
{
|
2015-11-02 08:53:26 +03:00
|
|
|
mozilla::Unused <<
|
2012-09-24 22:53:49 +04:00
|
|
|
aActor->SendCallback(NS_LITERAL_STRING("onerror"),
|
2015-03-25 17:36:56 +03:00
|
|
|
TCPError(NS_LITERAL_STRING("InvalidStateError"), NS_LITERAL_STRING("Internal error")),
|
|
|
|
static_cast<uint32_t>(TCPReadyState::Connecting));
|
2012-09-24 22:53:49 +04:00
|
|
|
}
|
|
|
|
|
2013-07-29 21:36:43 +04:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TCPSocketParentBase)
|
2012-09-24 22:53:49 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2015-03-25 17:36:56 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION(TCPSocketParentBase, mSocket)
|
2014-09-23 23:19:19 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(TCPSocketParentBase)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(TCPSocketParentBase)
|
|
|
|
|
2013-07-29 21:36:43 +04:00
|
|
|
TCPSocketParentBase::TCPSocketParentBase()
|
|
|
|
: mIPCOpen(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
TCPSocketParentBase::~TCPSocketParentBase()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TCPSocketParentBase::ReleaseIPDLReference()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mIPCOpen);
|
|
|
|
mIPCOpen = false;
|
|
|
|
this->Release();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TCPSocketParentBase::AddIPDLReference()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mIPCOpen);
|
|
|
|
mIPCOpen = true;
|
|
|
|
this->AddRef();
|
|
|
|
}
|
|
|
|
|
2014-03-28 00:38:33 +04:00
|
|
|
NS_IMETHODIMP_(MozExternalRefCountType) TCPSocketParent::Release(void)
|
2013-07-29 21:36:43 +04:00
|
|
|
{
|
|
|
|
nsrefcnt refcnt = TCPSocketParentBase::Release();
|
|
|
|
if (refcnt == 1 && mIPCOpen) {
|
2015-11-02 08:53:26 +03:00
|
|
|
mozilla::Unused << PTCPSocketParent::SendRequestDelete();
|
2013-07-29 21:36:43 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return refcnt;
|
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2013-07-29 21:36:43 +04:00
|
|
|
TCPSocketParent::RecvOpen(const nsString& aHost, const uint16_t& aPort, const bool& aUseSSL,
|
2015-03-25 17:36:56 +03:00
|
|
|
const bool& aUseArrayBuffers)
|
2012-09-24 22:53:49 +04:00
|
|
|
{
|
2015-03-25 17:36:56 +03:00
|
|
|
mSocket = new TCPSocket(nullptr, aHost, aPort, aUseSSL, aUseArrayBuffers);
|
|
|
|
mSocket->SetSocketBridgeParent(this);
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_SUCCESS(mSocket->Init(), IPC_OK());
|
|
|
|
return IPC_OK();
|
2012-09-24 22:53:49 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-01-05 10:49:24 +03:00
|
|
|
TCPSocketParent::RecvOpenBind(const nsCString& aRemoteHost,
|
|
|
|
const uint16_t& aRemotePort,
|
|
|
|
const nsCString& aLocalAddr,
|
|
|
|
const uint16_t& aLocalPort,
|
|
|
|
const bool& aUseSSL,
|
2016-12-22 10:38:06 +03:00
|
|
|
const bool& aReuseAddrPort,
|
2016-02-11 12:18:46 +03:00
|
|
|
const bool& aUseArrayBuffers,
|
|
|
|
const nsCString& aFilter)
|
2015-01-05 10:49:24 +03:00
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsISocketTransportService> sts =
|
|
|
|
do_GetService("@mozilla.org/network/socket-transport-service;1", &rv);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
FireInteralError(this, __LINE__);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-01-05 10:49:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsISocketTransport> socketTransport;
|
2017-01-03 21:34:19 +03:00
|
|
|
if (aUseSSL) {
|
|
|
|
const char* socketTypes[1];
|
|
|
|
socketTypes[0] = "ssl";
|
|
|
|
rv = sts->CreateTransport(socketTypes, 1,
|
|
|
|
aRemoteHost, aRemotePort,
|
|
|
|
nullptr, getter_AddRefs(socketTransport));
|
|
|
|
} else {
|
|
|
|
rv = sts->CreateTransport(nullptr, 0,
|
|
|
|
aRemoteHost, aRemotePort,
|
|
|
|
nullptr, getter_AddRefs(socketTransport));
|
|
|
|
}
|
|
|
|
|
2015-01-05 10:49:24 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
FireInteralError(this, __LINE__);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-01-05 10:49:24 +03:00
|
|
|
}
|
|
|
|
|
2016-12-22 10:38:06 +03:00
|
|
|
// in most cases aReuseAddrPort is false, but ICE TCP needs
|
|
|
|
// sockets options set that allow addr/port reuse
|
|
|
|
socketTransport->SetReuseAddrPort(aReuseAddrPort);
|
|
|
|
|
2015-01-05 10:49:24 +03:00
|
|
|
PRNetAddr prAddr;
|
|
|
|
if (PR_SUCCESS != PR_InitializeNetAddr(PR_IpAddrAny, aLocalPort, &prAddr)) {
|
|
|
|
FireInteralError(this, __LINE__);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-01-05 10:49:24 +03:00
|
|
|
}
|
|
|
|
if (PR_SUCCESS != PR_StringToNetAddr(aLocalAddr.BeginReading(), &prAddr)) {
|
|
|
|
FireInteralError(this, __LINE__);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-01-05 10:49:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::net::NetAddr addr;
|
|
|
|
PRNetAddrToNetAddr(&prAddr, &addr);
|
|
|
|
rv = socketTransport->Bind(&addr);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
FireInteralError(this, __LINE__);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-01-05 10:49:24 +03:00
|
|
|
}
|
|
|
|
|
2016-02-11 12:18:46 +03:00
|
|
|
if (!aFilter.IsEmpty()) {
|
|
|
|
nsAutoCString contractId(NS_NETWORK_TCP_SOCKET_FILTER_HANDLER_PREFIX);
|
|
|
|
contractId.Append(aFilter);
|
|
|
|
nsCOMPtr<nsISocketFilterHandler> filterHandler =
|
|
|
|
do_GetService(contractId.get());
|
|
|
|
if (!filterHandler) {
|
|
|
|
NS_ERROR("Content doesn't have a valid filter");
|
|
|
|
FireInteralError(this, __LINE__);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-02-11 12:18:46 +03:00
|
|
|
}
|
|
|
|
rv = filterHandler->NewFilter(getter_AddRefs(mFilter));
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("Cannot create filter that content specified");
|
|
|
|
FireInteralError(this, __LINE__);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-02-11 12:18:46 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-21 06:05:20 +03:00
|
|
|
mSocket = new TCPSocket(nullptr, NS_ConvertUTF8toUTF16(aRemoteHost), aRemotePort, aUseSSL, aUseArrayBuffers);
|
2015-01-05 10:49:24 +03:00
|
|
|
mSocket->SetSocketBridgeParent(this);
|
2015-09-21 06:05:20 +03:00
|
|
|
rv = mSocket->InitWithUnconnectedTransport(socketTransport);
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, IPC_OK());
|
|
|
|
return IPC_OK();
|
2015-01-05 10:49:24 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2013-08-31 23:09:17 +04:00
|
|
|
TCPSocketParent::RecvStartTLS()
|
|
|
|
{
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_TRUE(mSocket, IPC_OK());
|
2015-03-25 17:36:56 +03:00
|
|
|
ErrorResult rv;
|
|
|
|
mSocket->UpgradeToSecure(rv);
|
2016-07-22 17:50:10 +03:00
|
|
|
if (NS_WARN_IF(rv.Failed())) {
|
|
|
|
rv.SuppressException();
|
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2013-08-31 23:09:17 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2012-09-24 22:53:49 +04:00
|
|
|
TCPSocketParent::RecvSuspend()
|
|
|
|
{
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_TRUE(mSocket, IPC_OK());
|
2015-03-25 17:36:56 +03:00
|
|
|
mSocket->Suspend();
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-09-24 22:53:49 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2012-09-24 22:53:49 +04:00
|
|
|
TCPSocketParent::RecvResume()
|
|
|
|
{
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_TRUE(mSocket, IPC_OK());
|
2015-03-25 17:36:56 +03:00
|
|
|
ErrorResult rv;
|
|
|
|
mSocket->Resume(rv);
|
2016-07-22 17:50:10 +03:00
|
|
|
if (NS_WARN_IF(rv.Failed())) {
|
|
|
|
rv.SuppressException();
|
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-09-24 22:53:49 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2013-11-14 12:00:28 +04:00
|
|
|
TCPSocketParent::RecvData(const SendableData& aData,
|
|
|
|
const uint32_t& aTrackingNumber)
|
2012-09-24 22:53:49 +04:00
|
|
|
{
|
2015-03-25 17:36:56 +03:00
|
|
|
ErrorResult rv;
|
2016-02-11 12:18:46 +03:00
|
|
|
|
|
|
|
if (mFilter) {
|
|
|
|
mozilla::net::NetAddr addr; // dummy value
|
|
|
|
bool allowed;
|
|
|
|
MOZ_ASSERT(aData.type() == SendableData::TArrayOfuint8_t,
|
|
|
|
"Unsupported data type for filtering");
|
|
|
|
const InfallibleTArray<uint8_t>& data(aData.get_ArrayOfuint8_t());
|
|
|
|
nsresult nsrv = mFilter->FilterPacket(&addr, data.Elements(),
|
|
|
|
data.Length(),
|
|
|
|
nsISocketFilter::SF_OUTGOING,
|
|
|
|
&allowed);
|
|
|
|
|
|
|
|
// Reject sending of unallowed data
|
|
|
|
if (NS_WARN_IF(NS_FAILED(nsrv)) || !allowed) {
|
|
|
|
TCPSOCKET_LOG(("%s: Dropping outgoing TCP packet", __FUNCTION__));
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_FAIL_NO_REASON(this);
|
2016-02-11 12:18:46 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-24 22:53:49 +04:00
|
|
|
switch (aData.type()) {
|
|
|
|
case SendableData::TArrayOfuint8_t: {
|
2015-03-25 17:36:56 +03:00
|
|
|
AutoSafeJSContext autoCx;
|
|
|
|
JS::Rooted<JS::Value> val(autoCx);
|
|
|
|
const nsTArray<uint8_t>& buffer = aData.get_ArrayOfuint8_t();
|
|
|
|
bool ok = IPC::DeserializeArrayBuffer(autoCx, buffer, &val);
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_TRUE(ok, IPC_OK());
|
2017-08-11 04:04:54 +03:00
|
|
|
RootedSpiderMonkeyInterface<ArrayBuffer> data(autoCx);
|
2015-03-25 17:36:56 +03:00
|
|
|
data.Init(&val.toObject());
|
|
|
|
Optional<uint32_t> byteLength(buffer.Length());
|
|
|
|
mSocket->SendWithTrackingNumber(autoCx, data, 0, byteLength, aTrackingNumber, rv);
|
2012-09-24 22:53:49 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-03-25 17:36:56 +03:00
|
|
|
case SendableData::TnsCString: {
|
|
|
|
const nsCString& strData = aData.get_nsCString();
|
|
|
|
mSocket->SendWithTrackingNumber(strData, aTrackingNumber, rv);
|
2012-09-24 22:53:49 +04:00
|
|
|
break;
|
2015-03-25 17:36:56 +03:00
|
|
|
}
|
2012-09-24 22:53:49 +04:00
|
|
|
|
|
|
|
default:
|
2013-06-29 05:38:30 +04:00
|
|
|
MOZ_CRASH("unexpected SendableData type");
|
2012-09-24 22:53:49 +04:00
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv.StealNSResult(), IPC_OK());
|
|
|
|
return IPC_OK();
|
2012-09-24 22:53:49 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2012-09-24 22:53:49 +04:00
|
|
|
TCPSocketParent::RecvClose()
|
|
|
|
{
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_TRUE(mSocket, IPC_OK());
|
2015-03-25 17:36:56 +03:00
|
|
|
mSocket->Close();
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-09-24 22:53:49 +04:00
|
|
|
}
|
|
|
|
|
2015-03-25 17:36:56 +03:00
|
|
|
void
|
|
|
|
TCPSocketParent::FireErrorEvent(const nsAString& aName, const nsAString& aType, TCPReadyState aReadyState)
|
2012-09-24 22:53:49 +04:00
|
|
|
{
|
2015-03-25 17:36:56 +03:00
|
|
|
SendEvent(NS_LITERAL_STRING("error"), TCPError(nsString(aName), nsString(aType)), aReadyState);
|
|
|
|
}
|
2012-09-24 22:53:49 +04:00
|
|
|
|
2015-03-25 17:36:56 +03:00
|
|
|
void
|
|
|
|
TCPSocketParent::FireEvent(const nsAString& aType, TCPReadyState aReadyState)
|
|
|
|
{
|
|
|
|
return SendEvent(aType, mozilla::void_t(), aReadyState);
|
2012-09-24 22:53:49 +04:00
|
|
|
}
|
|
|
|
|
2015-03-25 17:36:56 +03:00
|
|
|
void
|
|
|
|
TCPSocketParent::FireArrayBufferDataEvent(nsTArray<uint8_t>& aBuffer, TCPReadyState aReadyState)
|
2013-07-29 21:36:43 +04:00
|
|
|
{
|
2015-03-25 17:36:56 +03:00
|
|
|
InfallibleTArray<uint8_t> arr;
|
|
|
|
arr.SwapElements(aBuffer);
|
2016-02-11 12:18:46 +03:00
|
|
|
|
|
|
|
if (mFilter) {
|
|
|
|
bool allowed;
|
|
|
|
mozilla::net::NetAddr addr;
|
|
|
|
nsresult nsrv = mFilter->FilterPacket(&addr, arr.Elements(), arr.Length(),
|
|
|
|
nsISocketFilter::SF_INCOMING,
|
|
|
|
&allowed);
|
|
|
|
// receiving unallowed data, drop it.
|
|
|
|
if (NS_WARN_IF(NS_FAILED(nsrv)) || !allowed) {
|
|
|
|
TCPSOCKET_LOG(("%s: Dropping incoming TCP packet", __FUNCTION__));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-25 17:36:56 +03:00
|
|
|
SendableData data(arr);
|
|
|
|
SendEvent(NS_LITERAL_STRING("data"), data, aReadyState);
|
2013-07-29 21:36:43 +04:00
|
|
|
}
|
|
|
|
|
2015-03-25 17:36:56 +03:00
|
|
|
void
|
|
|
|
TCPSocketParent::FireStringDataEvent(const nsACString& aData, TCPReadyState aReadyState)
|
2013-11-14 12:00:28 +04:00
|
|
|
{
|
2016-02-11 12:18:46 +03:00
|
|
|
SendableData data((nsCString(aData)));
|
|
|
|
|
|
|
|
MOZ_ASSERT(!mFilter, "Socket filtering doesn't support nsCString");
|
|
|
|
|
|
|
|
SendEvent(NS_LITERAL_STRING("data"), data, aReadyState);
|
2015-03-25 17:36:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TCPSocketParent::SendEvent(const nsAString& aType, CallbackData aData, TCPReadyState aReadyState)
|
|
|
|
{
|
2017-01-23 11:23:34 +03:00
|
|
|
if (mIPCOpen) {
|
|
|
|
mozilla::Unused << PTCPSocketParent::SendCallback(nsString(aType),
|
|
|
|
aData,
|
|
|
|
static_cast<uint32_t>(aReadyState));
|
|
|
|
}
|
2015-03-25 17:36:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TCPSocketParent::SetSocket(TCPSocket *socket)
|
|
|
|
{
|
|
|
|
mSocket = socket;
|
2013-11-14 12:00:28 +04:00
|
|
|
}
|
|
|
|
|
2015-03-25 17:36:56 +03:00
|
|
|
nsresult
|
2013-12-19 07:21:12 +04:00
|
|
|
TCPSocketParent::GetHost(nsAString& aHost)
|
|
|
|
{
|
|
|
|
if (!mSocket) {
|
|
|
|
NS_ERROR("No internal socket instance mSocket!");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2015-03-25 17:36:56 +03:00
|
|
|
mSocket->GetHost(aHost);
|
|
|
|
return NS_OK;
|
2013-12-19 07:21:12 +04:00
|
|
|
}
|
|
|
|
|
2015-03-25 17:36:56 +03:00
|
|
|
nsresult
|
2013-12-19 07:21:12 +04:00
|
|
|
TCPSocketParent::GetPort(uint16_t* aPort)
|
|
|
|
{
|
|
|
|
if (!mSocket) {
|
|
|
|
NS_ERROR("No internal socket instance mSocket!");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2015-03-25 17:36:56 +03:00
|
|
|
*aPort = mSocket->Port();
|
|
|
|
return NS_OK;
|
2013-12-19 07:21:12 +04:00
|
|
|
}
|
|
|
|
|
2012-09-24 22:53:49 +04:00
|
|
|
void
|
|
|
|
TCPSocketParent::ActorDestroy(ActorDestroyReason why)
|
|
|
|
{
|
|
|
|
if (mSocket) {
|
|
|
|
mSocket->Close();
|
|
|
|
}
|
|
|
|
mSocket = nullptr;
|
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2012-09-24 22:53:49 +04:00
|
|
|
TCPSocketParent::RecvRequestDelete()
|
|
|
|
{
|
2015-11-02 08:53:26 +03:00
|
|
|
mozilla::Unused << Send__delete__(this);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-09-24 22:53:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|