Files
palemoon27/dom/ipc/ContentBridgeParent.cpp
T
roytam1 fed7084085 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1190733 - Test initializedLength() instead of length() during the fast path for reversing unboxed arrays, r=jandem. (b5dcbd0e3)
- Bug 1070767 - Enable {Array, %TypedArray%}.prototype.includes in all builds. r=lth (de595c002)
- Bug 1195298 - Fix NewDenseArray intrinsic to work when the first argument is a double. r=till (1f551ada2)
- Bug 1190727 - Make initialization of temporary results array resilient against Array.prototype setters in self-hosted Map#next implementation. r=jandem (d705c623c)
- Bug 1200108 - Remove NewDenseArray intrinsic, use std_Array instead. r=till (e5c4126c6)
- Bug 1199822 - Turn self-hosting's cycle-check into an assertion; r=till (804600283)
- Bug 1194148 - Self-host Array.prototype.toString. r=till (4ffb4712c)
- pointer style (7b1a9900c)
- Bug 1200809 part 5 - Convert self-hosting intrinsics to new InlinableNatives system. r=till (8dd5eb0b9)
- pointer style (7974610a2)
- Bug 1200809 part 6 - Convert various natives to new InlinableNatives system. r=nbp (81d75199c)
- Bug 1200809 part 7 - Convert SIMD natives to new InlinableNatives system. r=nbp (5e67097e0)
- Bug 1200809 part 8 - Don't call shouldAbortOnPreliminaryGroups if we have an uninlinable native. r=bhackett (bd20f201f)
- Bug 1114507 - Part 1: Add/release the appId's refcnt if frame is in main process. r=kanru (741889791)
- Bug 1190903 - Don't send StopIMEStateManagement message after TabParent has been destroyed (r=masayuki) (97bba211b)
- Bug 1166592 - Remove ParentIdleListener from idle service when ActorDestroy() to avoid leaking ContentParent. r=khuey (771549a18)
- Bug 1114507 - Part 3: Remove PContetBridge channel when grandchild-process is killed. r=kanru (a84f888b3)
- Bug 1114507 - Part 2: Add/release the appId's refcnt in oop case. r=kanru (1fdb788b0)
- Bug 1114507 - Part 4: Test cases. r=kanru (889a770c7)
- pointer style (80bd2082b)
- Bug 1159347 - Make BaseProxyHandler::getPropertyDescriptor not-pure virtual. r=efaust (56de51919)
- Bug 1166847 - Implement OpaqueCrossCompartmentWrapper;r=evilpies (d762e785e)
2021-11-04 09:20:44 +08:00

202 lines
6.6 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/ContentBridgeParent.h"
#include "mozilla/dom/TabParent.h"
#include "mozilla/jsipc/CrossProcessObjectWrappers.h"
#include "nsXULAppAPI.h"
#include "nsIObserverService.h"
using namespace mozilla::ipc;
using namespace mozilla::jsipc;
namespace mozilla {
namespace dom {
NS_IMPL_ISUPPORTS(ContentBridgeParent,
nsIContentParent,
nsIObserver)
ContentBridgeParent::ContentBridgeParent(Transport* aTransport)
: mTransport(aTransport)
{}
ContentBridgeParent::~ContentBridgeParent()
{
XRE_GetIOMessageLoop()->PostTask(FROM_HERE, new DeleteTask<Transport>(mTransport));
}
void
ContentBridgeParent::ActorDestroy(ActorDestroyReason aWhy)
{
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
if (os) {
os->RemoveObserver(this, "content-child-shutdown");
}
MessageLoop::current()->PostTask(
FROM_HERE,
NewRunnableMethod(this, &ContentBridgeParent::DeferredDestroy));
}
/*static*/ ContentBridgeParent*
ContentBridgeParent::Create(Transport* aTransport, ProcessId aOtherPid)
{
nsRefPtr<ContentBridgeParent> bridge =
new ContentBridgeParent(aTransport);
bridge->mSelfRef = bridge;
DebugOnly<bool> ok = bridge->Open(aTransport, aOtherPid,
XRE_GetIOMessageLoop());
MOZ_ASSERT(ok);
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
if (os) {
os->AddObserver(bridge, "content-child-shutdown", false);
}
// Initialize the message manager (and load delayed scripts) now that we
// have established communications with the child.
bridge->mMessageManager->InitWithCallback(bridge);
return bridge.get();
}
void
ContentBridgeParent::DeferredDestroy()
{
mSelfRef = nullptr;
// |this| was just destroyed, hands off
}
bool
ContentBridgeParent::RecvSyncMessage(const nsString& aMsg,
const ClonedMessageData& aData,
InfallibleTArray<jsipc::CpowEntry>&& aCpows,
const IPC::Principal& aPrincipal,
nsTArray<OwningSerializedStructuredCloneBuffer>* aRetvals)
{
return nsIContentParent::RecvSyncMessage(aMsg, aData, Move(aCpows),
aPrincipal, aRetvals);
}
bool
ContentBridgeParent::RecvAsyncMessage(const nsString& aMsg,
const ClonedMessageData& aData,
InfallibleTArray<jsipc::CpowEntry>&& aCpows,
const IPC::Principal& aPrincipal)
{
return nsIContentParent::RecvAsyncMessage(aMsg, aData, Move(aCpows),
aPrincipal);
}
PBlobParent*
ContentBridgeParent::SendPBlobConstructor(PBlobParent* actor,
const BlobConstructorParams& params)
{
return PContentBridgeParent::SendPBlobConstructor(actor, params);
}
PBrowserParent*
ContentBridgeParent::SendPBrowserConstructor(PBrowserParent* aActor,
const TabId& aTabId,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
return PContentBridgeParent::SendPBrowserConstructor(aActor,
aTabId,
aContext,
aChromeFlags,
aCpID,
aIsForApp,
aIsForBrowser);
}
PBlobParent*
ContentBridgeParent::AllocPBlobParent(const BlobConstructorParams& aParams)
{
return nsIContentParent::AllocPBlobParent(aParams);
}
bool
ContentBridgeParent::DeallocPBlobParent(PBlobParent* aActor)
{
return nsIContentParent::DeallocPBlobParent(aActor);
}
mozilla::jsipc::PJavaScriptParent *
ContentBridgeParent::AllocPJavaScriptParent()
{
return nsIContentParent::AllocPJavaScriptParent();
}
bool
ContentBridgeParent::DeallocPJavaScriptParent(PJavaScriptParent *parent)
{
return nsIContentParent::DeallocPJavaScriptParent(parent);
}
PBrowserParent*
ContentBridgeParent::AllocPBrowserParent(const TabId& aTabId,
const IPCTabContext &aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
return nsIContentParent::AllocPBrowserParent(aTabId,
aContext,
aChromeFlags,
aCpID,
aIsForApp,
aIsForBrowser);
}
bool
ContentBridgeParent::DeallocPBrowserParent(PBrowserParent* aParent)
{
return nsIContentParent::DeallocPBrowserParent(aParent);
}
void
ContentBridgeParent::NotifyTabDestroyed()
{
int32_t numLiveTabs = ManagedPBrowserParent().Length();
if (numLiveTabs == 1) {
MessageLoop::current()->PostTask(
FROM_HERE,
NewRunnableMethod(this, &ContentBridgeParent::Close));
}
}
// This implementation is identical to ContentParent::GetCPOWManager but we can't
// move it to nsIContentParent because it calls ManagedPJavaScriptParent() which
// only exists in PContentParent and PContentBridgeParent.
jsipc::CPOWManager*
ContentBridgeParent::GetCPOWManager()
{
if (ManagedPJavaScriptParent().Length()) {
return CPOWManagerFor(ManagedPJavaScriptParent()[0]);
}
return CPOWManagerFor(SendPJavaScriptConstructor());
}
NS_IMETHODIMP
ContentBridgeParent::Observe(nsISupports* aSubject,
const char* aTopic,
const char16_t* aData)
{
if (!strcmp(aTopic, "content-child-shutdown")) {
Close();
}
return NS_OK;
}
} // namespace dom
} // namespace mozilla