зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1551615 - Make PGMPContent protocol refcounted. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D68904
This commit is contained in:
Родитель
20a9b720d4
Коммит
24bf867f09
|
@ -651,12 +651,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;
|
||||
|
|
Загрузка…
Ссылка в новой задаче