2014-06-11 09:44:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2015-05-03 22:32:37 +03:00
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2014-06-11 09:44:13 +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 "mozilla/dom/ContentBridgeChild.h"
|
|
|
|
#include "mozilla/dom/ContentChild.h"
|
2014-10-08 20:15:23 +04:00
|
|
|
#include "mozilla/dom/File.h"
|
2014-06-11 09:44:13 +04:00
|
|
|
#include "mozilla/dom/TabChild.h"
|
2014-09-27 03:21:57 +04:00
|
|
|
#include "mozilla/dom/ipc/BlobChild.h"
|
2015-01-27 00:32:18 +03:00
|
|
|
#include "mozilla/jsipc/CrossProcessObjectWrappers.h"
|
2014-06-11 09:44:13 +04:00
|
|
|
#include "mozilla/ipc/InputStreamUtils.h"
|
|
|
|
|
|
|
|
using namespace mozilla::ipc;
|
|
|
|
using namespace mozilla::jsipc;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2015-06-10 20:08:00 +03:00
|
|
|
NS_IMPL_ISUPPORTS(ContentBridgeChild,
|
2015-08-31 08:53:00 +03:00
|
|
|
nsIContentChild)
|
2014-06-11 09:44:13 +04:00
|
|
|
|
|
|
|
ContentBridgeChild::ContentBridgeChild(Transport* aTransport)
|
|
|
|
: mTransport(aTransport)
|
|
|
|
{}
|
|
|
|
|
|
|
|
ContentBridgeChild::~ContentBridgeChild()
|
|
|
|
{
|
|
|
|
XRE_GetIOMessageLoop()->PostTask(FROM_HERE, new DeleteTask<Transport>(mTransport));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ContentBridgeChild::ActorDestroy(ActorDestroyReason aWhy)
|
|
|
|
{
|
|
|
|
MessageLoop::current()->PostTask(
|
|
|
|
FROM_HERE,
|
|
|
|
NewRunnableMethod(this, &ContentBridgeChild::DeferredDestroy));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*static*/ ContentBridgeChild*
|
2015-04-01 11:40:35 +03:00
|
|
|
ContentBridgeChild::Create(Transport* aTransport, ProcessId aOtherPid)
|
2014-06-11 09:44:13 +04:00
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ContentBridgeChild> bridge =
|
2014-06-11 09:44:13 +04:00
|
|
|
new ContentBridgeChild(aTransport);
|
|
|
|
bridge->mSelfRef = bridge;
|
|
|
|
|
2015-04-01 11:40:35 +03:00
|
|
|
DebugOnly<bool> ok = bridge->Open(aTransport, aOtherPid, XRE_GetIOMessageLoop());
|
2014-06-11 09:44:13 +04:00
|
|
|
MOZ_ASSERT(ok);
|
2015-06-10 20:08:00 +03:00
|
|
|
|
2014-06-11 09:44:13 +04:00
|
|
|
return bridge;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ContentBridgeChild::DeferredDestroy()
|
|
|
|
{
|
|
|
|
mSelfRef = nullptr;
|
|
|
|
// |this| was just destroyed, hands off
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentBridgeChild::RecvAsyncMessage(const nsString& aMsg,
|
|
|
|
const ClonedMessageData& aData,
|
2015-01-16 22:58:52 +03:00
|
|
|
InfallibleTArray<jsipc::CpowEntry>&& aCpows,
|
2014-06-11 09:44:13 +04:00
|
|
|
const IPC::Principal& aPrincipal)
|
|
|
|
{
|
2015-01-16 22:58:52 +03:00
|
|
|
return nsIContentChild::RecvAsyncMessage(aMsg, aData, Move(aCpows), aPrincipal);
|
2014-06-11 09:44:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
PBlobChild*
|
|
|
|
ContentBridgeChild::SendPBlobConstructor(PBlobChild* actor,
|
|
|
|
const BlobConstructorParams& params)
|
|
|
|
{
|
|
|
|
return PContentBridgeChild::SendPBlobConstructor(actor, params);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentBridgeChild::SendPBrowserConstructor(PBrowserChild* aActor,
|
2014-10-29 21:11:00 +03:00
|
|
|
const TabId& aTabId,
|
2014-06-11 09:44:13 +04:00
|
|
|
const IPCTabContext& aContext,
|
|
|
|
const uint32_t& aChromeFlags,
|
2014-10-24 04:28:00 +04:00
|
|
|
const ContentParentId& aCpID,
|
2014-06-11 09:44:13 +04:00
|
|
|
const bool& aIsForApp,
|
|
|
|
const bool& aIsForBrowser)
|
|
|
|
{
|
|
|
|
return PContentBridgeChild::SendPBrowserConstructor(aActor,
|
2014-10-29 21:11:00 +03:00
|
|
|
aTabId,
|
2014-06-11 09:44:13 +04:00
|
|
|
aContext,
|
|
|
|
aChromeFlags,
|
2014-10-24 04:28:00 +04:00
|
|
|
aCpID,
|
2014-06-11 09:44:13 +04:00
|
|
|
aIsForApp,
|
|
|
|
aIsForBrowser);
|
|
|
|
}
|
|
|
|
|
|
|
|
// This implementation is identical to ContentChild::GetCPOWManager but we can't
|
|
|
|
// move it to nsIContentChild because it calls ManagedPJavaScriptChild() which
|
|
|
|
// only exists in PContentChild and PContentBridgeChild.
|
2015-01-27 00:32:18 +03:00
|
|
|
jsipc::CPOWManager*
|
2014-06-11 09:44:13 +04:00
|
|
|
ContentBridgeChild::GetCPOWManager()
|
|
|
|
{
|
2015-10-08 03:15:56 +03:00
|
|
|
if (PJavaScriptChild* c = LoneManagedOrNull(ManagedPJavaScriptChild())) {
|
|
|
|
return CPOWManagerFor(c);
|
2014-06-11 09:44:13 +04:00
|
|
|
}
|
2015-01-27 00:32:18 +03:00
|
|
|
return CPOWManagerFor(SendPJavaScriptConstructor());
|
2014-06-11 09:44:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::jsipc::PJavaScriptChild *
|
|
|
|
ContentBridgeChild::AllocPJavaScriptChild()
|
|
|
|
{
|
|
|
|
return nsIContentChild::AllocPJavaScriptChild();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentBridgeChild::DeallocPJavaScriptChild(PJavaScriptChild *child)
|
|
|
|
{
|
|
|
|
return nsIContentChild::DeallocPJavaScriptChild(child);
|
|
|
|
}
|
|
|
|
|
|
|
|
PBrowserChild*
|
2014-10-29 21:11:00 +03:00
|
|
|
ContentBridgeChild::AllocPBrowserChild(const TabId& aTabId,
|
|
|
|
const IPCTabContext &aContext,
|
2014-06-11 09:44:13 +04:00
|
|
|
const uint32_t& aChromeFlags,
|
2014-10-24 04:28:00 +04:00
|
|
|
const ContentParentId& aCpID,
|
2014-06-11 09:44:13 +04:00
|
|
|
const bool& aIsForApp,
|
|
|
|
const bool& aIsForBrowser)
|
|
|
|
{
|
2014-10-29 21:11:00 +03:00
|
|
|
return nsIContentChild::AllocPBrowserChild(aTabId,
|
|
|
|
aContext,
|
2014-06-11 09:44:13 +04:00
|
|
|
aChromeFlags,
|
2014-10-24 04:28:00 +04:00
|
|
|
aCpID,
|
2014-06-11 09:44:13 +04:00
|
|
|
aIsForApp,
|
|
|
|
aIsForBrowser);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentBridgeChild::DeallocPBrowserChild(PBrowserChild* aChild)
|
|
|
|
{
|
|
|
|
return nsIContentChild::DeallocPBrowserChild(aChild);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentBridgeChild::RecvPBrowserConstructor(PBrowserChild* aActor,
|
2014-10-29 21:11:00 +03:00
|
|
|
const TabId& aTabId,
|
2014-06-11 09:44:13 +04:00
|
|
|
const IPCTabContext& aContext,
|
|
|
|
const uint32_t& aChromeFlags,
|
2014-10-24 04:28:00 +04:00
|
|
|
const ContentParentId& aCpID,
|
2014-06-11 09:44:13 +04:00
|
|
|
const bool& aIsForApp,
|
|
|
|
const bool& aIsForBrowser)
|
|
|
|
{
|
|
|
|
return ContentChild::GetSingleton()->RecvPBrowserConstructor(aActor,
|
2014-10-29 21:11:00 +03:00
|
|
|
aTabId,
|
2014-06-11 09:44:13 +04:00
|
|
|
aContext,
|
|
|
|
aChromeFlags,
|
2014-10-24 04:28:00 +04:00
|
|
|
aCpID,
|
2014-06-11 09:44:13 +04:00
|
|
|
aIsForApp,
|
|
|
|
aIsForBrowser);
|
|
|
|
}
|
|
|
|
|
|
|
|
PBlobChild*
|
|
|
|
ContentBridgeChild::AllocPBlobChild(const BlobConstructorParams& aParams)
|
|
|
|
{
|
|
|
|
return nsIContentChild::AllocPBlobChild(aParams);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentBridgeChild::DeallocPBlobChild(PBlobChild* aActor)
|
|
|
|
{
|
|
|
|
return nsIContentChild::DeallocPBlobChild(aActor);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|