Open content VRManagers using endpoints. (bug 1287597 part 1, r=billm)

This commit is contained in:
David Anderson 2016-07-21 00:14:59 -07:00
Родитель b4d852ccc0
Коммит 38864a48be
11 изменённых файлов: 73 добавлений и 76 удалений

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

@ -1254,6 +1254,12 @@ ContentChild::RecvInitImageBridge(Endpoint<PImageBridgeChild>&& aEndpoint)
return ImageBridgeChild::InitForContent(Move(aEndpoint));
}
bool
ContentChild::RecvInitVRManager(Endpoint<PVRManagerChild>&& aEndpoint)
{
return gfx::VRManagerChild::InitForContent(Move(aEndpoint));
}
PSharedBufferManagerChild*
ContentChild::AllocPSharedBufferManagerChild(mozilla::ipc::Transport* aTransport,
base::ProcessId aOtherProcess)
@ -1261,13 +1267,6 @@ ContentChild::AllocPSharedBufferManagerChild(mozilla::ipc::Transport* aTransport
return SharedBufferManagerChild::StartUpInChildProcess(aTransport, aOtherProcess);
}
gfx::PVRManagerChild*
ContentChild::AllocPVRManagerChild(Transport* aTransport,
ProcessId aOtherProcess)
{
return gfx::VRManagerChild::StartUpInChildProcess(aTransport, aOtherProcess);
}
PBackgroundChild*
ContentChild::AllocPBackgroundChild(Transport* aTransport,
ProcessId aOtherProcess)

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

@ -152,6 +152,8 @@ public:
RecvInitCompositor(Endpoint<PCompositorBridgeChild>&& aEndpoint) override;
bool
RecvInitImageBridge(Endpoint<PImageBridgeChild>&& aEndpoint) override;
bool
RecvInitVRManager(Endpoint<PVRManagerChild>&& aEndpoint) override;
PSharedBufferManagerChild*
AllocPSharedBufferManagerChild(mozilla::ipc::Transport* aTransport,
@ -161,10 +163,6 @@ public:
AllocPProcessHangMonitorChild(Transport* aTransport,
ProcessId aOtherProcess) override;
PVRManagerChild*
AllocPVRManagerChild(Transport* aTransport,
ProcessId aOtherProcess) override;
virtual bool RecvSetProcessSandbox(const MaybeFileDesc& aBroker) override;
PBackgroundChild*

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

@ -275,8 +275,6 @@ using namespace mozilla::system;
#include "nsThread.h"
#endif
#include "VRManagerParent.h" // for VRManagerParent
// For VP9Benchmark::sBenchmarkFpsPref
#include "Benchmark.h"
@ -2449,8 +2447,11 @@ ContentParent::InitInternal(ProcessPriority aInitialPriority,
}
{
DebugOnly<bool> opened = gfx::PVRManager::Open(this);
Endpoint<PVRManagerChild> endpoint;
DebugOnly<bool> opened =
gpm->CreateContentVRManager(OtherPid(), &endpoint);
MOZ_ASSERT(opened);
Unused << SendInitVRManager(Move(endpoint));
}
}
#ifdef MOZ_WIDGET_GONK
@ -3241,13 +3242,6 @@ ContentParent::DeallocPAPZParent(PAPZParent* aActor)
return true;
}
gfx::PVRManagerParent*
ContentParent::AllocPVRManagerParent(Transport* aTransport,
ProcessId aOtherProcess)
{
return gfx::VRManagerParent::CreateCrossProcess(aTransport, aOtherProcess);
}
PBackgroundParent*
ContentParent::AllocPBackgroundParent(Transport* aTransport,
ProcessId aOtherProcess)

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

@ -757,10 +757,6 @@ private:
AllocPProcessHangMonitorParent(Transport* aTransport,
ProcessId aOtherProcess) override;
PVRManagerParent*
AllocPVRManagerParent(Transport* aTransport,
ProcessId aOtherProcess) override;
virtual bool RecvGetProcessAttributes(ContentParentId* aCpId,
bool* aIsForApp,
bool* aIsForBrowser) override;

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

@ -387,7 +387,6 @@ prio(normal upto urgent) sync protocol PContent
parent opens PProcessHangMonitor;
parent opens PSharedBufferManager;
parent opens PGMPService;
parent opens PVRManager;
child opens PBackground;
manages PAPZ;
@ -472,6 +471,7 @@ child:
// Give the content process its endpoints to the compositor.
async InitCompositor(Endpoint<PCompositorBridgeChild> compositor);
async InitImageBridge(Endpoint<PImageBridgeChild> bridge);
async InitVRManager(Endpoint<PVRManagerChild> endpoint);
/**
* Enable system-level sandboxing features, if available. Can

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

@ -17,6 +17,7 @@
#endif
#include "nsBaseWidget.h"
#include "nsContentUtils.h"
#include "VRManagerParent.h"
#include "VsyncBridgeChild.h"
#include "VsyncIOThreadHolder.h"
@ -418,6 +419,32 @@ GPUProcessManager::CreateContentImageBridge(base::ProcessId aOtherProcess,
return true;
}
bool
GPUProcessManager::CreateContentVRManager(base::ProcessId aOtherProcess,
ipc::Endpoint<PVRManagerChild>* aOutEndpoint)
{
base::ProcessId gpuPid = base::GetCurrentProcId();
ipc::Endpoint<PVRManagerParent> parentPipe;
ipc::Endpoint<PVRManagerChild> childPipe;
nsresult rv = PVRManager::CreateEndpoints(
gpuPid,
aOtherProcess,
&parentPipe,
&childPipe);
if (NS_FAILED(rv)) {
gfxCriticalNote << "Could not create content compositor bridge: " << hexa(int(rv));
return false;
}
if (!VRManagerParent::CreateForContent(Move(parentPipe))) {
return false;
}
*aOutEndpoint = Move(childPipe);
return true;
}
already_AddRefed<APZCTreeManager>
GPUProcessManager::GetAPZCTreeManagerForLayers(uint64_t aLayersId)
{

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

@ -45,6 +45,7 @@ namespace gfx {
class GPUChild;
class VsyncBridgeChild;
class VsyncIOThreadHolder;
class PVRManagerChild;
// The GPUProcessManager is a singleton responsible for creating GPU-bound
// objects that may live in another process. Currently, it provides access
@ -83,9 +84,10 @@ public:
bool CreateContentCompositorBridge(base::ProcessId aOtherProcess,
ipc::Endpoint<PCompositorBridgeChild>* aOutEndpoint);
bool CreateContentImageBridge(base::ProcessId aOtherProcess,
ipc::Endpoint<PImageBridgeChild>* aOutEndpoint);
bool CreateContentVRManager(base::ProcessId aOtherProcess,
ipc::Endpoint<PVRManagerChild>* aOutEndpoint);
// This returns a reference to the APZCTreeManager to which
// pan/zoom-related events can be sent.

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

@ -43,23 +43,19 @@ VRManagerChild::Get()
return sVRManagerChildSingleton;
}
/*static*/ VRManagerChild*
VRManagerChild::StartUpInChildProcess(Transport* aTransport, ProcessId aOtherPid)
/* static */ bool
VRManagerChild::InitForContent(Endpoint<PVRManagerChild>&& aEndpoint)
{
MOZ_ASSERT(NS_IsMainThread());
// There's only one VRManager per child process.
MOZ_ASSERT(!sVRManagerChildSingleton);
RefPtr<VRManagerChild> child(new VRManagerChild());
if (!child->Open(aTransport, aOtherPid, XRE_GetIOMessageLoop(), ipc::ChildSide)) {
if (!aEndpoint.Bind(child, nullptr)) {
NS_RUNTIMEABORT("Couldn't Open() Compositor channel.");
return nullptr;
return false;
}
sVRManagerChildSingleton = child;
return sVRManagerChildSingleton;
return true;
}
/*static*/ void

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

@ -28,10 +28,9 @@ public:
int GetInputFrameID();
bool GetVRDevices(nsTArray<RefPtr<VRDeviceProxy> >& aDevices);
bool RefreshVRDevicesWithCallback(dom::Navigator* aNavigator);
static VRManagerChild* StartUpInChildProcess(Transport* aTransport,
ProcessId aOtherProcess);
static void StartUpSameProcess();
static bool InitForContent(Endpoint<PVRManagerChild>&& aEndpoint);
static void ShutDown();

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

@ -17,9 +17,7 @@
namespace mozilla {
namespace gfx {
VRManagerParent::VRManagerParent(MessageLoop* aLoop,
Transport* aTransport,
ProcessId aChildProcessId)
VRManagerParent::VRManagerParent(ProcessId aChildProcessId)
{
MOZ_COUNT_CTOR(VRManagerParent);
MOZ_ASSERT(NS_IsMainThread());
@ -50,24 +48,27 @@ void VRManagerParent::UnregisterFromManager()
mVRManagerHolder = nullptr;
}
/*static*/ void
VRManagerParent::ConnectVRManagerInParentProcess(VRManagerParent* aVRManager,
ipc::Transport* aTransport,
base::ProcessId aOtherPid)
/* static */ bool
VRManagerParent::CreateForContent(Endpoint<PVRManagerParent>&& aEndpoint)
{
aVRManager->Open(aTransport, aOtherPid, XRE_GetIOMessageLoop(), ipc::ParentSide);
aVRManager->RegisterWithManager();
MessageLoop* loop = layers::CompositorThreadHolder::Loop();
RefPtr<VRManagerParent> vmp = new VRManagerParent(aEndpoint.OtherPid());
loop->PostTask(NewRunnableMethod<Endpoint<PVRManagerParent>&&>(
vmp, &VRManagerParent::Bind, Move(aEndpoint)));
return true;
}
/*static*/ VRManagerParent*
VRManagerParent::CreateCrossProcess(Transport* aTransport, ProcessId aChildProcessId)
void
VRManagerParent::Bind(Endpoint<PVRManagerParent>&& aEndpoint)
{
MessageLoop* loop = mozilla::layers::CompositorThreadHolder::Loop();
RefPtr<VRManagerParent> vmp = new VRManagerParent(loop, aTransport, aChildProcessId);
vmp->mSelfRef = vmp;
loop->PostTask(NewRunnableFunction(ConnectVRManagerInParentProcess,
vmp.get(), aTransport, aChildProcessId));
return vmp.get();
if (!aEndpoint.Bind(this, nullptr)) {
return;
}
mSelfRef = this;
RegisterWithManager();
}
/*static*/ void
@ -80,7 +81,7 @@ VRManagerParent::RegisterVRManagerInCompositorThread(VRManagerParent* aVRManager
VRManagerParent::CreateSameProcess()
{
MessageLoop* loop = mozilla::layers::CompositorThreadHolder::Loop();
RefPtr<VRManagerParent> vmp = new VRManagerParent(loop, nullptr, base::GetCurrentProcId());
RefPtr<VRManagerParent> vmp = new VRManagerParent(base::GetCurrentProcId());
vmp->mCompositorThreadHolder = layers::CompositorThreadHolder::GetSingleton();
vmp->mSelfRef = vmp;
loop->PostTask(NewRunnableFunction(RegisterVRManagerInCompositorThread, vmp.get()));
@ -106,19 +107,7 @@ VRManagerParent::CloneToplevel(const InfallibleTArray<mozilla::ipc::ProtocolFdMa
base::ProcessHandle aPeerProcess,
mozilla::ipc::ProtocolCloneContext* aCtx)
{
for (unsigned int i = 0; i < aFds.Length(); i++) {
if (aFds[i].protocolId() == unsigned(GetProtocolId())) {
UniquePtr<Transport> transport =
OpenDescriptor(aFds[i].fd(), Transport::MODE_SERVER);
PVRManagerParent* vm = CreateCrossProcess(transport.get(), base::GetProcId(aPeerProcess));
vm->CloneManagees(this, aCtx);
vm->IToplevelProtocol::SetTransport(Move(transport));
// The reference to the compositor thread is held in OnChannelConnected().
// We need to do this for cloned actors, too.
vm->OnChannelConnected(base::GetProcId(aPeerProcess));
return vm;
}
}
MOZ_ASSERT_UNREACHABLE("Not supported");
return nullptr;
}

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

@ -23,11 +23,10 @@ class VRManagerParent final : public PVRManagerParent
{
NS_INLINE_DECL_THREADSAFE_REFCOUNTING_WITH_MAIN_THREAD_DESTRUCTION(VRManagerParent)
public:
VRManagerParent(MessageLoop* aLoop, Transport* aTransport, ProcessId aChildProcessId);
explicit VRManagerParent(ProcessId aChildProcessId);
static VRManagerParent* CreateCrossProcess(Transport* aTransport,
ProcessId aOtherProcess);
static VRManagerParent* CreateSameProcess();
static bool CreateForContent(Endpoint<PVRManagerParent>&& aEndpoint);
// Overriden from IToplevelProtocol
@ -52,14 +51,12 @@ protected:
const double& zFar) override;
private:
void RegisterWithManager();
void UnregisterFromManager();
void Bind(Endpoint<PVRManagerParent>&& aEndpoint);
static void RegisterVRManagerInCompositorThread(VRManagerParent* aVRManager);
static void ConnectVRManagerInParentProcess(VRManagerParent* aVRManager,
ipc::Transport* aTransport,
base::ProcessId aOtherPid);
void DeferredDestroy();