Bug 1551615 - Make PGMPContent protocol refcounted. r=nika

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Bryce Seager van Dyk 2020-03-31 15:37:27 +00:00
Родитель f8896b428d
Коммит 3b7d4c0469
7 изменённых файлов: 15 добавлений и 28 удалений

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

@ -655,12 +655,9 @@ mozilla::ipc::IPCResult GMPChild::RecvInitGMPContentChild(
void GMPChild::GMPContentChildActorDestroy(GMPContentChild* aGMPContentChild) {
for (uint32_t i = mGMPContentChildren.Length(); i > 0; i--) {
UniquePtr<GMPContentChild>& toDestroy = mGMPContentChildren[i - 1];
if (toDestroy.get() == aGMPContentChild) {
RefPtr<GMPContentChild>& destroyedActor = mGMPContentChildren[i - 1];
if (destroyedActor.get() == aGMPContentChild) {
SendPGMPContentChildDestroyed();
RefPtr<DeleteTask<GMPContentChild>> task =
new DeleteTask<GMPContentChild>(toDestroy.release());
MessageLoop::current()->PostTask(task.forget());
mGMPContentChildren.RemoveElementAt(i - 1);
break;
}

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

@ -69,7 +69,7 @@ class GMPChild : public PGMPChild {
nsTArray<std::pair<nsCString, nsCString>> MakeCDMHostVerificationPaths();
nsTArray<UniquePtr<GMPContentChild>> mGMPContentChildren;
nsTArray<RefPtr<GMPContentChild>> mGMPContentChildren;
RefPtr<GMPTimerChild> mTimerChild;
RefPtr<GMPStorageChild> mStorage;

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

@ -14,12 +14,6 @@
namespace mozilla {
namespace gmp {
GMPContentChild::GMPContentChild(GMPChild* aChild) : mGMPChild(aChild) {
MOZ_COUNT_CTOR(GMPContentChild);
}
GMPContentChild::~GMPContentChild() { MOZ_COUNT_DTOR(GMPContentChild); }
MessageLoop* GMPContentChild::GMPMessageLoop() {
return mGMPChild->GMPMessageLoop();
}

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

@ -16,8 +16,11 @@ class GMPChild;
class GMPContentChild : public PGMPContentChild, public GMPSharedMem {
public:
explicit GMPContentChild(GMPChild* aChild);
virtual ~GMPContentChild();
// Mark AddRef and Release as `final`, as they overload pure virtual
// implementations in PGMPContentChild.
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GMPContentChild, final)
explicit GMPContentChild(GMPChild* aChild) : mGMPChild(aChild) {}
MessageLoop* GMPMessageLoop();
@ -45,6 +48,9 @@ class GMPContentChild : public PGMPContentChild, public GMPSharedMem {
bool IsUsed();
GMPChild* mGMPChild;
private:
~GMPContentChild() = default;
};
} // namespace gmp

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

@ -42,23 +42,11 @@ GMPContentParent::~GMPContentParent() {
GetBoolString(mChromiumCDMs.IsEmpty()), mCloseBlockerCount);
}
class ReleaseGMPContentParent : public Runnable {
public:
explicit ReleaseGMPContentParent(GMPContentParent* aToRelease)
: Runnable("gmp::ReleaseGMPContentParent"), mToRelease(aToRelease) {}
NS_IMETHOD Run() override { return NS_OK; }
private:
RefPtr<GMPContentParent> mToRelease;
};
void GMPContentParent::ActorDestroy(ActorDestroyReason aWhy) {
GMP_LOG_DEBUG("GMPContentParent::ActorDestroy(this=%p, aWhy=%d)", this,
static_cast<int>(aWhy));
MOZ_ASSERT(mVideoDecoders.IsEmpty() && mVideoEncoders.IsEmpty() &&
mChromiumCDMs.IsEmpty());
NS_DispatchToCurrentThread(new ReleaseGMPContentParent(this));
}
void GMPContentParent::CheckThread() {

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

@ -22,7 +22,9 @@ class GMPContentParent final : public PGMPContentParent, public GMPSharedMem {
friend class PGMPContentParent;
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GMPContentParent)
// Mark AddRef and Release as `final`, as they overload pure virtual
// implementations in PGMPContentParent.
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GMPContentParent, final)
explicit GMPContentParent(GMPParent* aParent = nullptr);

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

@ -10,7 +10,7 @@ include protocol PChromiumCDM;
namespace mozilla {
namespace gmp {
intr protocol PGMPContent
intr refcounted protocol PGMPContent
{
manages PGMPVideoDecoder;
manages PGMPVideoEncoder;