Bug 1614570 - Make VRManagerChild life time handling more like CompositorManagerChild r=aosmond

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
sotaro 2020-02-14 15:10:40 +00:00
parent 04d22436c3
commit 385addd8c7
3 changed files with 12 additions and 26 deletions

View File

@ -1631,7 +1631,7 @@ mozilla::ipc::IPCResult ContentChild::RecvReinitRendering(
namespaces[2])) {
return GetResultForRenderingInitFailure(aImageBridge.OtherPid());
}
if (!gfx::VRManagerChild::ReinitForContent(std::move(aVRBridge))) {
if (!gfx::VRManagerChild::InitForContent(std::move(aVRBridge))) {
return GetResultForRenderingInitFailure(aVRBridge.OtherPid());
}
gfxPlatform::GetPlatform()->CompositorUpdated();

View File

@ -43,6 +43,7 @@ VRManagerChild::VRManagerChild()
MOZ_ASSERT(NS_IsMainThread());
mStartTimeStamp = TimeStamp::Now();
AddRef();
}
VRManagerChild::~VRManagerChild() { MOZ_ASSERT(NS_IsMainThread()); }
@ -90,7 +91,6 @@ bool VRManagerChild::IsPresenting() {
/* static */
bool VRManagerChild::InitForContent(Endpoint<PVRManagerChild>&& aEndpoint) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!sVRManagerChildSingleton);
RefPtr<VRManagerChild> child(new VRManagerChild());
if (!aEndpoint.Bind(child)) {
@ -100,15 +100,6 @@ bool VRManagerChild::InitForContent(Endpoint<PVRManagerChild>&& aEndpoint) {
return true;
}
/* static */
bool VRManagerChild::ReinitForContent(Endpoint<PVRManagerChild>&& aEndpoint) {
MOZ_ASSERT(NS_IsMainThread());
ShutDown();
return InitForContent(std::move(aEndpoint));
}
/*static*/
void VRManagerChild::InitSameProcess() {
MOZ_ASSERT(NS_IsMainThread());
@ -135,21 +126,16 @@ void VRManagerChild::InitWithGPUProcess(Endpoint<PVRManagerChild>&& aEndpoint) {
/*static*/
void VRManagerChild::ShutDown() {
MOZ_ASSERT(NS_IsMainThread());
if (sVRManagerChildSingleton) {
sVRManagerChildSingleton->Destroy();
SpinEventLoopUntil([&]() { return !sVRManagerChildSingleton; });
if (!sVRManagerChildSingleton) {
return;
}
sVRManagerChildSingleton->Close();
sVRManagerChildSingleton = nullptr;
}
void VRManagerChild::Destroy() {
// Keep ourselves alive until everything has been shut down
RefPtr<VRManagerChild> selfRef = this;
MessageLoop::current()->PostTask(NewRunnableMethod(
"VRManagerChild::AfterDestroy", selfRef, &VRManagerChild::AfterDestroy));
}
void VRManagerChild::ActorDealloc() { Release(); }
void VRManagerChild::AfterDestroy() {
Close();
void VRManagerChild::ActorDestroy(ActorDestroyReason aReason) {
if (sVRManagerChildSingleton == this) {
sVRManagerChildSingleton = nullptr;
}

View File

@ -73,7 +73,6 @@ class VRManagerChild : public PVRManagerChild {
static void InitSameProcess();
static void InitWithGPUProcess(Endpoint<PVRManagerChild>&& aEndpoint);
static bool InitForContent(Endpoint<PVRManagerChild>&& aEndpoint);
static bool ReinitForContent(Endpoint<PVRManagerChild>&& aEndpoint);
static void ShutDown();
static bool IsCreated();
@ -103,7 +102,8 @@ class VRManagerChild : public PVRManagerChild {
void FireDOMVRDisplayPresentChangeEvent(uint32_t aDisplayID);
void FireDOMVRDisplayConnectEventsForLoad(VRManagerEventObserver* aObserver);
virtual void HandleFatalError(const char* aMsg) const override;
void HandleFatalError(const char* aMsg) const override;
void ActorDestroy(ActorDestroyReason aReason) override;
void RunPuppet(const nsTArray<uint64_t>& aBuffer, dom::Promise* aPromise,
ErrorResult& aRv);
@ -112,13 +112,13 @@ class VRManagerChild : public PVRManagerChild {
protected:
explicit VRManagerChild();
~VRManagerChild();
void Destroy();
void AfterDestroy();
PVRLayerChild* AllocPVRLayerChild(const uint32_t& aDisplayID,
const uint32_t& aGroup);
bool DeallocPVRLayerChild(PVRLayerChild* actor);
void ActorDealloc() override;
// MOZ_CAN_RUN_SCRIPT_BOUNDARY until we can mark ipdl-generated things as
// MOZ_CAN_RUN_SCRIPT.
MOZ_CAN_RUN_SCRIPT_BOUNDARY