Bug 1500257 part 2 - Add PRemoteFrame stub implementation. r=qdot

This commit adds a PRemoteFrame actor which is managed by PBrowser. It will
be created in a child process nsFrameLoader when loading a remote subframe.

This actor will mostly just bounce messages from a nsFrameLoader in the child
process to the actor in the parent process which will redirect the messages
to the TabParent of the remote subframe.

The piece in the parent actor to create the proxied PBrowser actors is
deferred to the next commit.

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

--HG--
extra : source : e72d9d31a8bc15e0d3e17d3bdae0b5717465c4b9
extra : intermediate-source : 12d7dba3473315edbdc2d73e3febec3ca9e987ae
This commit is contained in:
Ryan Hunt 2019-01-23 10:38:09 -06:00
parent 6315e17e86
commit 590bdf0728
11 changed files with 258 additions and 0 deletions

View File

@ -19,6 +19,7 @@ include protocol PFileDescriptorSet;
include protocol PIPCBlobInputStream;
include protocol PPaymentRequest;
include protocol PWindowGlobal;
include protocol PRemoteFrame;
include DOMTypes;
include IPCBlob;
@ -142,6 +143,7 @@ nested(upto inside_cpow) sync protocol PBrowser
manages PPluginWidget;
manages PPaymentRequest;
manages PWindowGlobal;
manages PRemoteFrame;
both:
async AsyncMessage(nsString aMessage, CpowEntry[] aCpows,
@ -174,6 +176,11 @@ parent:
*/
async PWindowGlobal(WindowGlobalInit init);
/**
* Construct a new Remote iframe actor.
*/
async PRemoteFrame(nsString aPresentationURL, nsString aRemoteType);
/**
* Sends an NS_NATIVE_CHILD_OF_SHAREABLE_WINDOW to be adopted by the
* widget's shareable window on the chrome side. Only used on Windows.

25
dom/ipc/PRemoteFrame.ipdl Normal file
View File

@ -0,0 +1,25 @@
/* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8 -*- */
/* vim: set sw=4 ts=8 et tw=80 ft=cpp : */
/* 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 protocol PBrowser;
include DOMTypes;
namespace mozilla {
namespace dom {
/**
* PRemoteFrame corresponds to a remote iframe.
*/
async protocol PRemoteFrame {
manager PBrowser;
parent:
// Destroy the remote web browser due to the nsFrameLoader going away.
async __delete__();
};
} // namespace dom
} // namespace mozilla

View File

@ -0,0 +1,49 @@
/* -*- 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/RemoteFrameChild.h"
using namespace mozilla::ipc;
namespace mozilla {
namespace dom {
RemoteFrameChild::RemoteFrameChild(nsFrameLoader* aFrameLoader)
: mLayersId{0}, mIPCOpen(true), mFrameLoader(aFrameLoader) {}
RemoteFrameChild::~RemoteFrameChild() {}
already_AddRefed<RemoteFrameChild> RemoteFrameChild::Create(
nsFrameLoader* aFrameLoader, const TabContext& aContext,
const nsString& aRemoteType) {
MOZ_ASSERT(XRE_IsContentProcess());
// Determine our embedder's TabChild actor.
RefPtr<Element> owner = aFrameLoader->GetOwnerContent();
MOZ_DIAGNOSTIC_ASSERT(owner);
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(owner->GetOwnerGlobal());
MOZ_DIAGNOSTIC_ASSERT(docShell);
RefPtr<TabChild> tabChild = TabChild::GetFrom(docShell);
MOZ_DIAGNOSTIC_ASSERT(tabChild);
RefPtr<RemoteFrameChild> remoteFrame = new RemoteFrameChild(aFrameLoader);
// Reference is freed in TabChild::DeallocPRemoteFrameChild.
tabChild->SendPRemoteFrameConstructor(
do_AddRef(remoteFrame).take(),
PromiseFlatString(aContext.PresentationURL()), aRemoteType);
remoteFrame->mIPCOpen = true;
return remoteFrame.forget();
}
void RemoteFrameChild::ActorDestroy(ActorDestroyReason aWhy) {
mIPCOpen = false;
}
} // namespace dom
} // namespace mozilla

View File

@ -0,0 +1,48 @@
/* -*- 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/. */
#ifndef mozilla_dom_RemoteFrameChild_h
#define mozilla_dom_RemoteFrameChild_h
#include "mozilla/dom/PRemoteFrameChild.h"
#include "mozilla/dom/TabChild.h"
namespace mozilla {
namespace dom {
/**
* Child side for a remote frame.
*/
class RemoteFrameChild : public PRemoteFrameChild {
public:
NS_INLINE_DECL_REFCOUNTING(RemoteFrameChild);
TabChild* Manager() {
MOZ_ASSERT(mIPCOpen);
return static_cast<TabChild*>(PRemoteFrameChild::Manager());
}
mozilla::layers::LayersId GetLayersId() { return mLayersId; }
static already_AddRefed<RemoteFrameChild> Create(nsFrameLoader* aFrameLoader,
const TabContext& aContext,
const nsString& aRemoteType);
protected:
void ActorDestroy(ActorDestroyReason aWhy) override;
private:
explicit RemoteFrameChild(nsFrameLoader* aFrameLoader);
~RemoteFrameChild();
mozilla::layers::LayersId mLayersId;
bool mIPCOpen;
RefPtr<nsFrameLoader> mFrameLoader;
};
} // namespace dom
} // namespace mozilla
#endif // !defined(mozilla_dom_RemoteFrameParent_h)

View File

@ -0,0 +1,31 @@
/* -*- 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/RemoteFrameParent.h"
#include "mozilla/dom/ContentParent.h"
#include "mozilla/dom/ContentProcessManager.h"
using namespace mozilla::ipc;
using namespace mozilla::layout;
namespace mozilla {
namespace dom {
RemoteFrameParent::RemoteFrameParent() : mIPCOpen(false) {}
RemoteFrameParent::~RemoteFrameParent() {}
nsresult RemoteFrameParent::Init(const nsString& aPresentationURL,
const nsString& aRemoteType) {
return NS_OK;
}
void RemoteFrameParent::ActorDestroy(ActorDestroyReason aWhy) {
mIPCOpen = false;
}
} // namespace dom
} // namespace mozilla

View File

@ -0,0 +1,46 @@
/* -*- 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/. */
#ifndef mozilla_dom_RemoteFrameParent_h
#define mozilla_dom_RemoteFrameParent_h
#include "mozilla/dom/PRemoteFrameParent.h"
#include "mozilla/dom/TabParent.h"
namespace mozilla {
namespace dom {
class RemoteFrameParent : public PRemoteFrameParent {
public:
NS_INLINE_DECL_REFCOUNTING(RemoteFrameParent);
RemoteFrameParent();
// Initialize this actor after performing startup.
nsresult Init(const nsString& aPresentationURL, const nsString& aRemoteType);
TabParent* GetTabParent() { return mTabParent; }
// Get our manager actor.
TabParent* Manager() {
MOZ_ASSERT(mIPCOpen);
return static_cast<TabParent*>(PRemoteFrameParent::Manager());
}
protected:
void ActorDestroy(ActorDestroyReason aWhy) override;
private:
~RemoteFrameParent();
RefPtr<TabParent> mTabParent;
bool mIPCOpen;
};
} // namespace dom
} // namespace mozilla
#endif // !defined(mozilla_dom_RemoteFrameParent_h)

View File

@ -30,6 +30,7 @@
#include "mozilla/dom/PaymentRequestChild.h"
#include "mozilla/dom/PBrowser.h"
#include "mozilla/dom/WindowProxyHolder.h"
#include "mozilla/dom/RemoteFrameChild.h"
#include "mozilla/gfx/CrossProcessPaint.h"
#include "mozilla/IMEStateManager.h"
#include "mozilla/ipc/URIUtils.h"
@ -3179,6 +3180,18 @@ bool TabChild::DeallocPWindowGlobalChild(PWindowGlobalChild* aActor) {
return true;
}
PRemoteFrameChild* TabChild::AllocPRemoteFrameChild(const nsString&,
const nsString&) {
MOZ_CRASH("We should never be manually allocating PRemoteFrameChild actors");
return nullptr;
}
bool TabChild::DeallocPRemoteFrameChild(PRemoteFrameChild* aActor) {
// This reference was added in RemoteFrameChild::Create.
static_cast<RemoteFrameChild*>(aActor)->Release();
return true;
}
ScreenIntSize TabChild::GetInnerSize() {
LayoutDeviceIntSize innerSize =
RoundedToInt(mUnscaledInnerSize * mPuppetWidget->GetDefaultScale());

View File

@ -670,6 +670,11 @@ class TabChild final : public TabChildBase,
virtual bool DeallocPWindowGlobalChild(PWindowGlobalChild* aActor) override;
virtual PRemoteFrameChild* AllocPRemoteFrameChild(
const nsString& aName, const nsString& aRemoteType) override;
virtual bool DeallocPRemoteFrameChild(PRemoteFrameChild* aActor) override;
virtual mozilla::ipc::IPCResult RecvDestroy() override;
virtual mozilla::ipc::IPCResult RecvSetDocShellIsActive(

View File

@ -22,6 +22,7 @@
#include "mozilla/dom/indexedDB/ActorsParent.h"
#include "mozilla/dom/IPCBlobUtils.h"
#include "mozilla/dom/PaymentRequestParent.h"
#include "mozilla/dom/RemoteFrameParent.h"
#include "mozilla/EventStateManager.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/gfx/DataSurfaceHelpers.h"
@ -1015,6 +1016,25 @@ bool TabParent::DeallocPWindowGlobalParent(PWindowGlobalParent* aActor) {
return true;
}
IPCResult TabParent::RecvPRemoteFrameConstructor(PRemoteFrameParent* aActor,
const nsString& aName,
const nsString& aRemoteType) {
static_cast<RemoteFrameParent*>(aActor)->Init(aName, aRemoteType);
return IPC_OK();
}
PRemoteFrameParent* TabParent::AllocPRemoteFrameParent(
const nsString& aName, const nsString& aRemoteType) {
// Reference freed in DeallocPRemoteFrameParent.
return do_AddRef(new RemoteFrameParent()).take();
}
bool TabParent::DeallocPRemoteFrameParent(PRemoteFrameParent* aActor) {
// Free reference from AllocPRemoteFrameParent.
static_cast<RemoteFrameParent*>(aActor)->Release();
return true;
}
void TabParent::SendMouseEvent(const nsAString& aType, float aX, float aY,
int32_t aButton, int32_t aClickCount,
int32_t aModifiers,

View File

@ -316,6 +316,15 @@ class TabParent final : public PBrowserParent,
virtual mozilla::ipc::IPCResult RecvPWindowGlobalConstructor(
PWindowGlobalParent* aActor, const WindowGlobalInit& aInit) override;
PRemoteFrameParent* AllocPRemoteFrameParent(const nsString& aPresentationURL,
const nsString& aRemoteType);
bool DeallocPRemoteFrameParent(PRemoteFrameParent* aActor);
virtual mozilla::ipc::IPCResult RecvPRemoteFrameConstructor(
PRemoteFrameParent* aActor, const nsString& aPresentationURL,
const nsString& aRemoteType) override;
void LoadURL(nsIURI* aURI);
void InitRendering();

View File

@ -47,6 +47,8 @@ EXPORTS.mozilla.dom += [
'nsIContentChild.h',
'nsIContentParent.h',
'PermissionMessageUtils.h',
'RemoteFrameChild.h',
'RemoteFrameParent.h',
'TabChild.h',
'TabContext.h',
'TabMessageUtils.h',
@ -86,6 +88,8 @@ UNIFIED_SOURCES += [
'PermissionMessageUtils.cpp',
'PreallocatedProcessManager.cpp',
'ProcessPriorityManager.cpp',
'RemoteFrameChild.cpp',
'RemoteFrameParent.cpp',
'SharedMap.cpp',
'SharedStringMap.cpp',
'StructuredCloneData.cpp',
@ -120,6 +124,7 @@ IPDL_SOURCES += [
'PPluginWidget.ipdl',
'PProcessHangMonitor.ipdl',
'PrefsTypes.ipdlh',
'PRemoteFrame.ipdl',
'PTabContext.ipdlh',
'PURLClassifier.ipdl',
'PURLClassifierInfo.ipdlh',