зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1824465 - Part 16: Make PVRManager refcounted, r=ipc-reviewers,mccr8
Differential Revision: https://phabricator.services.mozilla.com/D173731
This commit is contained in:
Родитель
f47a74ba59
Коммит
2278c1bb9f
|
@ -34,7 +34,7 @@ namespace gfx {
|
|||
* enumeration and sensor state between the compositor thread and
|
||||
* content threads/processes.
|
||||
*/
|
||||
[ManualDealloc, NeedsOtherPid, ChildImpl="VRManagerChild", ParentImpl="VRManagerParent"]
|
||||
[NeedsOtherPid, ChildImpl="VRManagerChild", ParentImpl="VRManagerParent"]
|
||||
sync protocol PVRManager
|
||||
{
|
||||
manages PVRLayer;
|
||||
|
|
|
@ -53,7 +53,6 @@ VRManagerChild::VRManagerChild()
|
|||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
mStartTimeStamp = TimeStamp::Now();
|
||||
AddRef();
|
||||
}
|
||||
|
||||
VRManagerChild::~VRManagerChild() { MOZ_ASSERT(NS_IsMainThread()); }
|
||||
|
@ -149,8 +148,6 @@ void VRManagerChild::ShutDown() {
|
|||
sVRManagerChildSingleton = nullptr;
|
||||
}
|
||||
|
||||
void VRManagerChild::ActorDealloc() { Release(); }
|
||||
|
||||
void VRManagerChild::ActorDestroy(ActorDestroyReason aReason) {
|
||||
if (sVRManagerChildSingleton == this) {
|
||||
sVRManagerChildSingleton = nullptr;
|
||||
|
|
|
@ -50,7 +50,7 @@ class VRManagerChild : public PVRManagerChild {
|
|||
friend class PVRManagerChild;
|
||||
|
||||
public:
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VRManagerChild);
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VRManagerChild, override);
|
||||
|
||||
static VRManagerChild* Get();
|
||||
|
||||
|
@ -117,8 +117,6 @@ class VRManagerChild : public PVRManagerChild {
|
|||
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
|
||||
|
|
|
@ -96,7 +96,7 @@ void VRManagerParent::Bind(Endpoint<PVRManagerParent>&& aEndpoint) {
|
|||
if (!aEndpoint.Bind(this)) {
|
||||
return;
|
||||
}
|
||||
mSelfRef = this;
|
||||
mCompositorThreadHolder = CompositorThreadHolder::GetSingleton();
|
||||
|
||||
RegisterWithManager();
|
||||
}
|
||||
|
@ -108,15 +108,14 @@ void VRManagerParent::RegisterVRManagerInCompositorThread(
|
|||
}
|
||||
|
||||
/*static*/
|
||||
VRManagerParent* VRManagerParent::CreateSameProcess() {
|
||||
already_AddRefed<VRManagerParent> VRManagerParent::CreateSameProcess() {
|
||||
RefPtr<VRManagerParent> vmp =
|
||||
new VRManagerParent(base::GetCurrentProcId(), false);
|
||||
vmp->mCompositorThreadHolder = CompositorThreadHolder::GetSingleton();
|
||||
vmp->mSelfRef = vmp;
|
||||
CompositorThread()->Dispatch(
|
||||
NewRunnableFunction("RegisterVRManagerIncompositorThreadRunnable",
|
||||
RegisterVRManagerInCompositorThread, vmp.get()));
|
||||
return vmp.get();
|
||||
return vmp.forget();
|
||||
}
|
||||
|
||||
bool VRManagerParent::CreateForGPUProcess(
|
||||
|
@ -124,7 +123,6 @@ bool VRManagerParent::CreateForGPUProcess(
|
|||
RefPtr<VRManagerParent> vmp =
|
||||
new VRManagerParent(aEndpoint.OtherPid(), false);
|
||||
vmp->mCompositorThreadHolder = CompositorThreadHolder::GetSingleton();
|
||||
vmp->mSelfRef = vmp;
|
||||
CompositorThread()->Dispatch(NewRunnableMethod<Endpoint<PVRManagerParent>&&>(
|
||||
"gfx::VRManagerParent::Bind", vmp, &VRManagerParent::Bind,
|
||||
std::move(aEndpoint)));
|
||||
|
@ -148,20 +146,9 @@ void VRManagerParent::Shutdown() {
|
|||
}));
|
||||
}
|
||||
|
||||
void VRManagerParent::ActorDestroy(ActorDestroyReason why) {}
|
||||
|
||||
void VRManagerParent::ActorAlloc() {
|
||||
// FIXME: This actor should probably use proper refcounting instead of manual
|
||||
// reference management, and probably shouldn't manage
|
||||
// `mCompositorThreadHolder` in the alloc/dealloc methods.
|
||||
PVRManagerParent::ActorAlloc();
|
||||
mCompositorThreadHolder = CompositorThreadHolder::GetSingleton();
|
||||
}
|
||||
|
||||
void VRManagerParent::ActorDealloc() {
|
||||
void VRManagerParent::ActorDestroy(ActorDestroyReason why) {
|
||||
UnregisterFromManager();
|
||||
mCompositorThreadHolder = nullptr;
|
||||
mSelfRef = nullptr;
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult VRManagerParent::RecvDetectRuntimes() {
|
||||
|
|
|
@ -22,14 +22,14 @@ namespace gfx {
|
|||
class VRManager;
|
||||
|
||||
class VRManagerParent final : public PVRManagerParent {
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VRManagerParent);
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VRManagerParent, final);
|
||||
|
||||
friend class PVRManagerParent;
|
||||
|
||||
public:
|
||||
explicit VRManagerParent(ProcessId aChildProcessId, bool aIsContentChild);
|
||||
|
||||
static VRManagerParent* CreateSameProcess();
|
||||
static already_AddRefed<VRManagerParent> CreateSameProcess();
|
||||
static bool CreateForGPUProcess(Endpoint<PVRManagerParent>&& aEndpoint);
|
||||
static bool CreateForContent(Endpoint<PVRManagerParent>&& aEndpoint);
|
||||
static void Shutdown();
|
||||
|
@ -73,8 +73,6 @@ class VRManagerParent final : public PVRManagerParent {
|
|||
mozilla::ipc::IPCResult RecvResetPuppet();
|
||||
|
||||
private:
|
||||
void ActorAlloc() override;
|
||||
void ActorDealloc() override;
|
||||
void RegisterWithManager();
|
||||
void UnregisterFromManager();
|
||||
|
||||
|
@ -82,9 +80,6 @@ class VRManagerParent final : public PVRManagerParent {
|
|||
|
||||
static void RegisterVRManagerInCompositorThread(VRManagerParent* aVRManager);
|
||||
|
||||
// This keeps us alive until ActorDestroy(), at which point we do a
|
||||
// deferred destruction of ourselves.
|
||||
RefPtr<VRManagerParent> mSelfRef;
|
||||
// Keep the compositor thread alive, until we have destroyed ourselves.
|
||||
RefPtr<CompositorThreadHolder> mCompositorThreadHolder;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче