Bug 1523638 - Part 3: Construct WindowGlobal actors using ManagedEndpoint, r=kmag

Differential Revision: https://phabricator.services.mozilla.com/D37650

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nika Layzell 2019-08-08 16:06:56 +00:00
Родитель e90e6161b3
Коммит 5f47039328
10 изменённых файлов: 39 добавлений и 63 удалений

Просмотреть файл

@ -1236,20 +1236,20 @@ IPCResult BrowserParent::RecvIndexedDBPermissionRequest(
return IPC_OK();
}
IPCResult BrowserParent::RecvPWindowGlobalConstructor(
PWindowGlobalParent* aActor, const WindowGlobalInit& aInit) {
static_cast<WindowGlobalParent*>(aActor)->Init(aInit);
IPCResult BrowserParent::RecvNewWindowGlobal(
ManagedEndpoint<PWindowGlobalParent>&& aEndpoint,
const WindowGlobalInit& aInit) {
// Construct our new WindowGlobalParent, bind, and initialize it.
auto wgp = MakeRefPtr<WindowGlobalParent>(aInit, /* inproc */ false);
// Reference freed in DeallocPWindowGlobalParent.
BindPWindowGlobalEndpoint(std::move(aEndpoint), do_AddRef(wgp).take());
wgp->Init(aInit);
return IPC_OK();
}
PWindowGlobalParent* BrowserParent::AllocPWindowGlobalParent(
const WindowGlobalInit& aInit) {
// Reference freed in DeallocPWindowGlobalParent.
return do_AddRef(new WindowGlobalParent(aInit, /* inproc */ false)).take();
}
bool BrowserParent::DeallocPWindowGlobalParent(PWindowGlobalParent* aActor) {
// Free reference from AllocPWindowGlobalParent.
// Free reference from RecvNewWindowGlobal.
static_cast<WindowGlobalParent*>(aActor)->Release();
return true;
}

Просмотреть файл

@ -473,12 +473,11 @@ class BrowserParent final : public PBrowserParent,
const uint64_t& aParentID, const uint32_t& aMsaaID,
const IAccessibleHolder& aDocCOMProxy) override;
PWindowGlobalParent* AllocPWindowGlobalParent(const WindowGlobalInit& aInit);
bool DeallocPWindowGlobalParent(PWindowGlobalParent* aActor);
virtual mozilla::ipc::IPCResult RecvPWindowGlobalConstructor(
PWindowGlobalParent* aActor, const WindowGlobalInit& aInit) override;
mozilla::ipc::IPCResult RecvNewWindowGlobal(
ManagedEndpoint<PWindowGlobalParent>&& aEndpoint,
const WindowGlobalInit& aInit);
already_AddRefed<PBrowserBridgeParent> AllocPBrowserBridgeParent(
const nsString& aPresentationURL, const nsString& aRemoteType,

Просмотреть файл

@ -203,12 +203,6 @@ parent:
async PPaymentRequest();
/**
* Construct a new WindowGlobal actor for a window global in the given
* BrowsingContext and with the given principal.
*/
async PWindowGlobal(WindowGlobalInit init);
/**
* Construct a new Remote iframe actor.
*/
@ -1025,6 +1019,12 @@ parent:
/** Fetches the visited status for an array of URIs (Android-only). */
async QueryVisitedState(URIParams[] aURIs);
/**
* Construct a new WindowGlobal for an existing global in the content process
*/
async NewWindowGlobal(ManagedEndpoint<PWindowGlobalParent> aEndpoint,
WindowGlobalInit aInit);
/*
* FIXME: write protocol!

Просмотреть файл

@ -8,7 +8,6 @@
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/dom/WindowGlobalParent.h"
#include "mozilla/ipc/InProcessChild.h"
#include "mozilla/dom/BrowsingContext.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/dom/MozFrameLoaderOwnerBinding.h"
@ -18,6 +17,7 @@
#include "mozilla/dom/WindowGlobalActorsBinding.h"
#include "mozilla/dom/WindowGlobalParent.h"
#include "mozilla/ipc/InProcessChild.h"
#include "mozilla/ipc/InProcessParent.h"
#include "nsContentUtils.h"
#include "nsDocShell.h"
#include "nsFrameLoaderOwner.h"
@ -90,22 +90,34 @@ already_AddRefed<WindowGlobalChild> WindowGlobalChild::Create(
return wgc.forget();
}
// Send the link constructor over PInProcessChild or PBrowser.
// Send the link constructor over PBrowser, or link over PInProcess.
if (XRE_IsParentProcess()) {
InProcessChild* ipc = InProcessChild::Singleton();
if (!ipc) {
InProcessChild* ipChild = InProcessChild::Singleton();
InProcessParent* ipParent = InProcessParent::Singleton();
if (!ipChild || !ipParent) {
return nullptr;
}
// Note: ref is released in DeallocPWindowGlobalChild
ipc->SendPWindowGlobalConstructor(do_AddRef(wgc).take(), init);
ManagedEndpoint<PWindowGlobalParent> endpoint =
ipChild->OpenPWindowGlobalEndpoint(do_AddRef(wgc).take());
auto wgp = MakeRefPtr<WindowGlobalParent>(init, /* aInProcess */ true);
// Note: ref is released in DeallocPWindowGlobalParent
ipParent->BindPWindowGlobalEndpoint(std::move(endpoint),
do_AddRef(wgp).take());
wgp->Init(init);
} else {
RefPtr<BrowserChild> browserChild =
BrowserChild::GetFrom(static_cast<mozIDOMWindow*>(aWindow));
MOZ_ASSERT(browserChild);
// Note: ref is released in DeallocPWindowGlobalChild
browserChild->SendPWindowGlobalConstructor(do_AddRef(wgc).take(), init);
ManagedEndpoint<PWindowGlobalParent> endpoint =
browserChild->OpenPWindowGlobalEndpoint(do_AddRef(wgc).take());
browserChild->SendNewWindowGlobal(std::move(endpoint), init);
}
// Register this WindowGlobal in the gWindowGlobalParentsById map.

Просмотреть файл

@ -12,12 +12,6 @@ using namespace mozilla::dom;
namespace mozilla {
namespace ipc {
PWindowGlobalChild* InProcessChild::AllocPWindowGlobalChild(
const WindowGlobalInit& aInit) {
MOZ_ASSERT_UNREACHABLE("PWindowGlobalChild should not be created manually");
return nullptr;
}
bool InProcessChild::DeallocPWindowGlobalChild(PWindowGlobalChild* aActor) {
// Free IPC-held reference
static_cast<WindowGlobalChild*>(aActor)->Release();

Просмотреть файл

@ -44,9 +44,6 @@ class InProcessChild : public PInProcessChild {
static IProtocol* ParentActorFor(IProtocol* aActor);
protected:
mozilla::dom::PWindowGlobalChild* AllocPWindowGlobalChild(
const WindowGlobalInit& aInit);
bool DeallocPWindowGlobalChild(mozilla::dom::PWindowGlobalChild* aActor);
private:

Просмотреть файл

@ -14,18 +14,6 @@ namespace ipc {
NS_IMPL_ISUPPORTS(InProcessParent, nsIObserver)
IPCResult InProcessParent::RecvPWindowGlobalConstructor(
PWindowGlobalParent* aActor, const WindowGlobalInit& aInit) {
static_cast<WindowGlobalParent*>(aActor)->Init(aInit);
return IPC_OK();
}
PWindowGlobalParent* InProcessParent::AllocPWindowGlobalParent(
const WindowGlobalInit& aInit) {
// Reference freed in DeallocPWindowGlobalParent.
return do_AddRef(new WindowGlobalParent(aInit, /* inproc */ true)).take();
}
bool InProcessParent::DeallocPWindowGlobalParent(PWindowGlobalParent* aActor) {
// Free IPC-held reference.
static_cast<WindowGlobalParent*>(aActor)->Release();
@ -33,4 +21,4 @@ bool InProcessParent::DeallocPWindowGlobalParent(PWindowGlobalParent* aActor) {
}
} // namespace ipc
} // namespace mozilla
} // namespace mozilla

Просмотреть файл

@ -45,15 +45,8 @@ class InProcessParent : public nsIObserver, public PInProcessParent {
static IProtocol* ChildActorFor(IProtocol* aActor);
protected:
mozilla::dom::PWindowGlobalParent* AllocPWindowGlobalParent(
const WindowGlobalInit& aInit);
bool DeallocPWindowGlobalParent(mozilla::dom::PWindowGlobalParent* aActor);
virtual IPCResult RecvPWindowGlobalConstructor(
mozilla::dom::PWindowGlobalParent* aActor,
const WindowGlobalInit& aInit) override;
private:
// Lifecycle management is implemented in InProcessImpl.cpp
virtual void ActorDestroy(ActorDestroyReason aWhy) override;

Просмотреть файл

@ -22,13 +22,6 @@ namespace ipc {
async protocol PInProcess
{
manages PWindowGlobal;
parent:
/**
* Construct a new WindowGlobal actor for a window global in the given
* BrowsingContext and with the given principal.
*/
async PWindowGlobal(WindowGlobalInit init);
};
} // namespace ipc

Просмотреть файл

@ -983,7 +983,7 @@ class GatherDecls(TcheckVisitor):
managed.manager = p
managed.accept(self)
if 0 == len(p.managers) and 0 == len(p.messageDecls):
if not (p.managers or p.messageDecls or p.managesStmts):
self.error(p.loc,
"top-level protocol `%s' cannot be empty",
p.name)