Bug 1824465 - Part 7: Make PRemoteDecoderManager refcounted, r=ipc-reviewers,mccr8

Differential Revision: https://phabricator.services.mozilla.com/D173722
This commit is contained in:
Nika Layzell 2023-04-19 22:10:08 +00:00
parent 20e947c8c3
commit cb22e7a8aa
5 changed files with 1 additions and 15 deletions

View file

@ -38,7 +38,7 @@ union RemoteDecoderInfoIPDL
VideoDecoderInfoIPDL; VideoDecoderInfoIPDL;
}; };
[ManualDealloc, NeedsOtherPid] [NeedsOtherPid]
sync protocol PRemoteDecoderManager sync protocol PRemoteDecoderManager
{ {
manages PRemoteDecoder; manages PRemoteDecoder;

View file

@ -768,15 +768,10 @@ void RemoteDecoderManagerChild::OpenRemoteDecoderManagerChildForProcess(
new RemoteDecoderManagerChild(aLocation); new RemoteDecoderManagerChild(aLocation);
if (aEndpoint.Bind(manager)) { if (aEndpoint.Bind(manager)) {
remoteDecoderManagerChild = manager; remoteDecoderManagerChild = manager;
manager->InitIPDL();
} }
} }
} }
void RemoteDecoderManagerChild::InitIPDL() { mIPDLSelfRef = this; }
void RemoteDecoderManagerChild::ActorDealloc() { mIPDLSelfRef = nullptr; }
bool RemoteDecoderManagerChild::DeallocShmem(mozilla::ipc::Shmem& aShmem) { bool RemoteDecoderManagerChild::DeallocShmem(mozilla::ipc::Shmem& aShmem) {
nsCOMPtr<nsISerialEventTarget> managerThread = GetManagerThread(); nsCOMPtr<nsISerialEventTarget> managerThread = GetManagerThread();
if (!managerThread) { if (!managerThread) {

View file

@ -107,10 +107,6 @@ class RemoteDecoderManagerChild final
RemoteDecodeIn aLocation); RemoteDecodeIn aLocation);
protected: protected:
void InitIPDL();
void ActorDealloc() override;
void HandleFatalError(const char* aMsg) const override; void HandleFatalError(const char* aMsg) const override;
PRemoteDecoderChild* AllocPRemoteDecoderChild( PRemoteDecoderChild* AllocPRemoteDecoderChild(
@ -140,7 +136,6 @@ class RemoteDecoderManagerChild final
// A thread-safe method to launch the RDD process if it hasn't launched yet. // A thread-safe method to launch the RDD process if it hasn't launched yet.
static RefPtr<GenericNonExclusivePromise> LaunchRDDProcessIfNeeded(); static RefPtr<GenericNonExclusivePromise> LaunchRDDProcessIfNeeded();
RefPtr<RemoteDecoderManagerChild> mIPDLSelfRef;
// The location for decoding, Rdd or Gpu process. // The location for decoding, Rdd or Gpu process.
const RemoteDecodeIn mLocation; const RemoteDecodeIn mLocation;
}; };

View file

@ -277,11 +277,8 @@ void RemoteDecoderManagerParent::Open(
// We can't recover from this. // We can't recover from this.
MOZ_CRASH("Failed to bind RemoteDecoderManagerParent to endpoint"); MOZ_CRASH("Failed to bind RemoteDecoderManagerParent to endpoint");
} }
AddRef();
} }
void RemoteDecoderManagerParent::ActorDealloc() { Release(); }
mozilla::ipc::IPCResult RemoteDecoderManagerParent::RecvReadback( mozilla::ipc::IPCResult RemoteDecoderManagerParent::RecvReadback(
const SurfaceDescriptorGPUVideo& aSD, SurfaceDescriptor* aResult) { const SurfaceDescriptorGPUVideo& aSD, SurfaceDescriptor* aResult) {
const SurfaceDescriptorRemoteDecoder& sd = aSD; const SurfaceDescriptorRemoteDecoder& sd = aSD;

View file

@ -76,7 +76,6 @@ class RemoteDecoderManagerParent final
const SurfaceDescriptorGPUVideo& aSD); const SurfaceDescriptorGPUVideo& aSD);
void ActorDestroy(mozilla::ipc::IProtocol::ActorDestroyReason) override; void ActorDestroy(mozilla::ipc::IProtocol::ActorDestroyReason) override;
void ActorDealloc() override;
private: private:
explicit RemoteDecoderManagerParent(nsISerialEventTarget* aThread); explicit RemoteDecoderManagerParent(nsISerialEventTarget* aThread);