Bug 1503655 part 1 - Remove nested-oop support from RenderFrameParent. r=kats,froydnj

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

--HG--
extra : rebase_source : c38238f2fa07f7a196ba9c14f745832ef7ad3cd5
extra : histedit_source : 02897684f5400f157973d5aa6bc4a6f6908697a4
This commit is contained in:
Ryan Hunt 2018-11-01 12:23:37 -05:00
parent c87f5760f9
commit 535b26ac9c
5 changed files with 14 additions and 119 deletions

View File

@ -1657,81 +1657,6 @@ ContentParent::ProcessingError(Result aCode, const char* aReason)
#endif
}
/* static */
bool
ContentParent::AllocateLayerTreeId(TabParent* aTabParent, layers::LayersId* aId)
{
return AllocateLayerTreeId(aTabParent->Manager()->AsContentParent(),
aTabParent, aTabParent->GetTabId(), aId);
}
/* static */
bool
ContentParent::AllocateLayerTreeId(ContentParent* aContent,
TabParent* aTopLevel, const TabId& aTabId,
layers::LayersId* aId)
{
GPUProcessManager* gpu = GPUProcessManager::Get();
*aId = gpu->AllocateLayerTreeId();
if (!aContent || !aTopLevel) {
return false;
}
gpu->MapLayerTreeId(*aId, aContent->OtherPid());
return true;
}
mozilla::ipc::IPCResult
ContentParent::RecvAllocateLayerTreeId(const ContentParentId& aCpId,
const TabId& aTabId, layers::LayersId* aId)
{
// Protect against spoofing by a compromised child. aCpId must either
// correspond to the process that this ContentParent represents or be a
// child of it.
ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
RefPtr<ContentParent> contentParent = cpm->GetContentProcessById(aCpId);
if (!contentParent ||
(ChildID() != aCpId && !contentParent->CanCommunicateWith(ChildID()))) {
return IPC_FAIL_NO_REASON(this);
}
// GetTopLevelTabParentByProcessAndTabId will make sure that aTabId
// lives in the process for aCpId.
RefPtr<TabParent> browserParent =
cpm->GetTopLevelTabParentByProcessAndTabId(aCpId, aTabId);
MOZ_ASSERT(contentParent && browserParent);
if (!AllocateLayerTreeId(contentParent, browserParent, aTabId, aId)) {
return IPC_FAIL_NO_REASON(this);
}
return IPC_OK();
}
mozilla::ipc::IPCResult
ContentParent::RecvDeallocateLayerTreeId(const ContentParentId& aCpId,
const layers::LayersId& aId)
{
GPUProcessManager* gpu = GPUProcessManager::Get();
ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
RefPtr<ContentParent> contentParent = cpm->GetContentProcessById(aCpId);
if (!contentParent || !contentParent->CanCommunicateWith(ChildID())) {
return IPC_FAIL(this, "Spoofed DeallocateLayerTreeId call");
}
if (!gpu->IsLayerTreeIdMapped(aId, contentParent->OtherPid())) {
// You can't deallocate layer tree ids that you didn't allocate
KillHard("DeallocateLayerTreeId");
}
gpu->UnmapLayerTreeId(aId, contentParent->OtherPid());
return IPC_OK();
}
namespace {
void

View File

@ -570,8 +570,6 @@ public:
const IPC::Principal& aTriggeringPrincipal,
const uint32_t& aReferrerPolicy) override;
static bool AllocateLayerTreeId(TabParent* aTabParent, layers::LayersId* aId);
static void
BroadcastBlobURLRegistration(const nsACString& aURI,
BlobImpl* aBlobImpl,
@ -870,10 +868,6 @@ private:
static void ForceKillTimerCallback(nsITimer* aTimer, void* aClosure);
static bool AllocateLayerTreeId(ContentParent* aContent,
TabParent* aTopLevel, const TabId& aTabId,
layers::LayersId* aId);
/**
* Get or create the corresponding content parent array to |aContentProcessType|.
*/
@ -1140,13 +1134,6 @@ public:
virtual void ProcessingError(Result aCode, const char* aMsgName) override;
virtual mozilla::ipc::IPCResult RecvAllocateLayerTreeId(const ContentParentId& aCpId,
const TabId& aTabId,
layers::LayersId* aId) override;
virtual mozilla::ipc::IPCResult RecvDeallocateLayerTreeId(const ContentParentId& aCpId,
const layers::LayersId& aId) override;
virtual mozilla::ipc::IPCResult RecvGraphicsError(const nsCString& aError) override;
virtual mozilla::ipc::IPCResult

View File

@ -913,11 +913,6 @@ parent:
async CopyFavicon(URIParams oldURI, URIParams newURI, Principal aLoadingPrincipal, bool isPrivate);
// Tell the compositor to allocate a layer tree id for nested remote mozbrowsers.
sync AllocateLayerTreeId(ContentParentId cpId, TabId tabId)
returns (LayersId id);
async DeallocateLayerTreeId(ContentParentId cpId, LayersId id);
/**
* Notifies the parent about a recording device is starting or shutdown.
* @param recordingStatus starting or shutdown

View File

@ -882,8 +882,6 @@ description =
description =
[PContent::NotifyKeywordSearchLoading]
description =
[PContent::AllocateLayerTreeId]
description =
[PContent::BeginDriverCrashGuard]
description =
[PContent::EndDriverCrashGuard]

View File

@ -118,26 +118,21 @@ RenderFrameParent::Init(nsFrameLoader* aFrameLoader)
RefPtr<LayerManager> lm = GetLayerManager(mFrameLoader);
mAsyncPanZoomEnabled = lm && lm->AsyncPanZoomEnabled();
PCompositorBridgeChild* compositor = lm
? lm->GetCompositorBridgeChild()
: nullptr;
TabParent* browser = TabParent::GetFrom(mFrameLoader);
if (XRE_IsParentProcess()) {
PCompositorBridgeChild* compositor = nullptr;
if (lm) {
compositor = lm->GetCompositorBridgeChild();
}
TabParent* browser = TabParent::GetFrom(aFrameLoader);
base::ProcessId pid = browser->Manager()->AsContentParent()->OtherPid();
// Our remote frame will push layers updates to the compositor,
// and we'll keep an indirect reference to that tree.
GPUProcessManager* gpm = GPUProcessManager::Get();
mLayersConnected = gpm->AllocateAndConnectLayerTreeId(
compositor,
browser->Manager()->AsContentParent()->OtherPid(),
&mLayersId,
&mCompositorOptions);
} else if (XRE_IsContentProcess()) {
ContentChild::GetSingleton()->SendAllocateLayerTreeId(browser->Manager()->ChildID(), browser->GetTabId(), &mLayersId);
mLayersConnected = CompositorBridgeChild::Get()->SendNotifyChildCreated(mLayersId, &mCompositorOptions);
}
// Our remote frame will push layers updates to the compositor,
// and we'll keep an indirect reference to that tree.
GPUProcessManager* gpm = GPUProcessManager::Get();
mLayersConnected = gpm->AllocateAndConnectLayerTreeId(
compositor,
pid,
&mLayersId,
&mCompositorOptions);
mInitted = true;
return true;
@ -239,12 +234,7 @@ void
RenderFrameParent::ActorDestroy(ActorDestroyReason why)
{
if (mLayersId.IsValid()) {
if (XRE_IsParentProcess()) {
GPUProcessManager::Get()->UnmapLayerTreeId(mLayersId, OtherPid());
} else if (XRE_IsContentProcess()) {
TabParent* browser = TabParent::GetFrom(mFrameLoader);
ContentChild::GetSingleton()->SendDeallocateLayerTreeId(browser->Manager()->ChildID(), mLayersId);
}
GPUProcessManager::Get()->UnmapLayerTreeId(mLayersId, OtherPid());
}
mFrameLoader = nullptr;