Bug 1570369 - Part 8: Use IPDL refcounted for PGMPVideo{Encoder,Decoder}, r=jya

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nika Layzell 2019-08-08 16:46:40 +00:00
parent c58a226270
commit d9b972bae8
10 changed files with 32 additions and 81 deletions

View File

@ -36,29 +36,14 @@ void GMPContentChild::ProcessingError(Result aCode, const char* aReason) {
mGMPChild->ProcessingError(aCode, aReason);
}
PGMPVideoDecoderChild* GMPContentChild::AllocPGMPVideoDecoderChild(
const uint32_t& aDecryptorId) {
GMPVideoDecoderChild* actor = new GMPVideoDecoderChild(this);
actor->AddRef();
return actor;
already_AddRefed<PGMPVideoDecoderChild>
GMPContentChild::AllocPGMPVideoDecoderChild(const uint32_t& aDecryptorId) {
return MakeAndAddRef<GMPVideoDecoderChild>(this);
}
bool GMPContentChild::DeallocPGMPVideoDecoderChild(
PGMPVideoDecoderChild* aActor) {
static_cast<GMPVideoDecoderChild*>(aActor)->Release();
return true;
}
PGMPVideoEncoderChild* GMPContentChild::AllocPGMPVideoEncoderChild() {
GMPVideoEncoderChild* actor = new GMPVideoEncoderChild(this);
actor->AddRef();
return actor;
}
bool GMPContentChild::DeallocPGMPVideoEncoderChild(
PGMPVideoEncoderChild* aActor) {
static_cast<GMPVideoEncoderChild*>(aActor)->Release();
return true;
already_AddRefed<PGMPVideoEncoderChild>
GMPContentChild::AllocPGMPVideoEncoderChild() {
return MakeAndAddRef<GMPVideoEncoderChild>(this);
}
already_AddRefed<PChromiumCDMChild> GMPContentChild::AllocPChromiumCDMChild() {

View File

@ -28,12 +28,10 @@ class GMPContentChild : public PGMPContentChild, public GMPSharedMem {
mozilla::ipc::IPCResult RecvPChromiumCDMConstructor(
PChromiumCDMChild* aActor) override;
PGMPVideoDecoderChild* AllocPGMPVideoDecoderChild(
already_AddRefed<PGMPVideoDecoderChild> AllocPGMPVideoDecoderChild(
const uint32_t& aDecryptorId);
bool DeallocPGMPVideoDecoderChild(PGMPVideoDecoderChild* aActor);
PGMPVideoEncoderChild* AllocPGMPVideoEncoderChild();
bool DeallocPGMPVideoEncoderChild(PGMPVideoEncoderChild* aActor);
already_AddRefed<PGMPVideoEncoderChild> AllocPGMPVideoEncoderChild();
already_AddRefed<PChromiumCDMChild> AllocPChromiumCDMChild();

View File

@ -177,15 +177,15 @@ already_AddRefed<ChromiumCDMParent> GMPContentParent::GetChromiumCDM() {
nsresult GMPContentParent::GetGMPVideoDecoder(GMPVideoDecoderParent** aGMPVD,
uint32_t aDecryptorId) {
GMP_LOG("GMPContentParent::GetGMPVideoDecoder(this=%p)", this);
// returned with one anonymous AddRef that locks it until Destroy
PGMPVideoDecoderParent* pvdp = SendPGMPVideoDecoderConstructor(aDecryptorId);
if (!pvdp) {
RefPtr<GMPVideoDecoderParent> vdp = new GMPVideoDecoderParent(this);
if (!SendPGMPVideoDecoderConstructor(vdp, aDecryptorId)) {
return NS_ERROR_FAILURE;
}
GMPVideoDecoderParent* vdp = static_cast<GMPVideoDecoderParent*>(pvdp);
// This addref corresponds to the Proxy pointer the consumer is returned.
// It's dropped by calling Close() on the interface.
NS_ADDREF(vdp);
vdp.get()->AddRef();
*aGMPVD = vdp;
mVideoDecoders.AppendElement(vdp);
@ -194,53 +194,20 @@ nsresult GMPContentParent::GetGMPVideoDecoder(GMPVideoDecoderParent** aGMPVD,
nsresult GMPContentParent::GetGMPVideoEncoder(GMPVideoEncoderParent** aGMPVE) {
GMP_LOG("GMPContentParent::GetGMPVideoEncoder(this=%p)", this);
// returned with one anonymous AddRef that locks it until Destroy
PGMPVideoEncoderParent* pvep = SendPGMPVideoEncoderConstructor();
if (!pvep) {
RefPtr<GMPVideoEncoderParent> vep = new GMPVideoEncoderParent(this);
if (!SendPGMPVideoEncoderConstructor(vep)) {
return NS_ERROR_FAILURE;
}
GMPVideoEncoderParent* vep = static_cast<GMPVideoEncoderParent*>(pvep);
// This addref corresponds to the Proxy pointer the consumer is returned.
// It's dropped by calling Close() on the interface.
NS_ADDREF(vep);
vep.get()->AddRef();
*aGMPVE = vep;
mVideoEncoders.AppendElement(vep);
return NS_OK;
}
PGMPVideoDecoderParent* GMPContentParent::AllocPGMPVideoDecoderParent(
const uint32_t& aDecryptorId) {
GMP_LOG("GMPContentParent::AllocPGMPVideoDecoderParent(this=%p)", this);
GMPVideoDecoderParent* vdp = new GMPVideoDecoderParent(this);
NS_ADDREF(vdp);
return vdp;
}
bool GMPContentParent::DeallocPGMPVideoDecoderParent(
PGMPVideoDecoderParent* aActor) {
GMP_LOG("GMPContentParent::DeallocPGMPVideoDecoderParent(this=%p, aActor=%p)",
this, aActor);
GMPVideoDecoderParent* vdp = static_cast<GMPVideoDecoderParent*>(aActor);
NS_RELEASE(vdp);
return true;
}
PGMPVideoEncoderParent* GMPContentParent::AllocPGMPVideoEncoderParent() {
GMP_LOG("GMPContentParent::AllocPGMPVideoEncoderParent(this=%p)", this);
GMPVideoEncoderParent* vep = new GMPVideoEncoderParent(this);
NS_ADDREF(vep);
return vep;
}
bool GMPContentParent::DeallocPGMPVideoEncoderParent(
PGMPVideoEncoderParent* aActor) {
GMP_LOG("GMPContentParent::DeallocPGMPVideoEncoderParent(this=%p, aActor=%p)",
this, aActor);
GMPVideoEncoderParent* vep = static_cast<GMPVideoEncoderParent*>(aActor);
NS_RELEASE(vep);
return true;
}
} // namespace gmp
} // namespace mozilla

View File

@ -69,13 +69,6 @@ class GMPContentParent final : public PGMPContentParent, public GMPSharedMem {
void ActorDestroy(ActorDestroyReason aWhy) override;
PGMPVideoDecoderParent* AllocPGMPVideoDecoderParent(
const uint32_t& aDecryptorId) override;
bool DeallocPGMPVideoDecoderParent(PGMPVideoDecoderParent* aActor) override;
PGMPVideoEncoderParent* AllocPGMPVideoEncoderParent() override;
bool DeallocPGMPVideoEncoderParent(PGMPVideoEncoderParent* aActor) override;
void CloseIfUnused();
// Needed because NewRunnableMethod tried to use the class that the method
// lives on to store the receiver, but PGMPContentParent isn't refcounted.

View File

@ -24,7 +24,9 @@ class GMPVideoDecoderChild : public PGMPVideoDecoderChild,
friend class PGMPVideoDecoderChild;
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GMPVideoDecoderChild);
// Mark AddRef and Release as `final`, as they overload pure virtual
// implementations in PGMPVideoDecoderChild.
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GMPVideoDecoderChild, final);
explicit GMPVideoDecoderChild(GMPContentChild* aPlugin);

View File

@ -29,7 +29,9 @@ class GMPVideoDecoderParent final : public PGMPVideoDecoderParent,
friend class PGMPVideoDecoderParent;
public:
NS_INLINE_DECL_REFCOUNTING(GMPVideoDecoderParent)
// Mark AddRef and Release as `final`, as they overload pure virtual
// implementations in PGMPVideoDecoderParent.
NS_INLINE_DECL_REFCOUNTING(GMPVideoDecoderParent, final)
explicit GMPVideoDecoderParent(GMPContentParent* aPlugin);

View File

@ -23,7 +23,9 @@ class GMPVideoEncoderChild : public PGMPVideoEncoderChild,
friend class PGMPVideoEncoderChild;
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GMPVideoEncoderChild);
// Mark AddRef and Release as `final`, as they overload pure virtual
// implementations in PGMPVideoEncoderChild.
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GMPVideoEncoderChild, final);
explicit GMPVideoEncoderChild(GMPContentChild* aPlugin);

View File

@ -28,7 +28,9 @@ class GMPVideoEncoderParent : public GMPVideoEncoderProxy,
friend class PGMPVideoEncoderParent;
public:
NS_INLINE_DECL_REFCOUNTING(GMPVideoEncoderParent)
// Mark AddRef and Release as `final`, as they overload pure virtual
// implementations in PGMPVideoEncoderParent.
NS_INLINE_DECL_REFCOUNTING(GMPVideoEncoderParent, final)
explicit GMPVideoEncoderParent(GMPContentParent* aPlugin);

View File

@ -14,7 +14,7 @@ include "GMPMessageUtils.h";
namespace mozilla {
namespace gmp {
intr protocol PGMPVideoDecoder
intr refcounted protocol PGMPVideoDecoder
{
manager PGMPContent;
child:

View File

@ -15,7 +15,7 @@ include "GMPMessageUtils.h";
namespace mozilla {
namespace gmp {
intr protocol PGMPVideoEncoder
intr refcounted protocol PGMPVideoEncoder
{
manager PGMPContent;
child: