Bug 1072024 - Destroy uninitialized GMP objects - r=cpearce

This commit is contained in:
Edwin Flores 2014-10-14 11:04:59 +13:00
Родитель 93b110ea4a
Коммит 3e448dc9d3
8 изменённых файлов: 37 добавлений и 19 удалений

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

@ -31,6 +31,7 @@ namespace gmp {
GMPAudioDecoderParent::GMPAudioDecoderParent(GMPParent* aPlugin)
: mIsOpen(false)
, mShuttingDown(false)
, mPlugin(aPlugin)
, mCallback(nullptr)
{
@ -161,17 +162,19 @@ GMPAudioDecoderParent::Shutdown()
LOGD(("%s: %p", __FUNCTION__, this));
MOZ_ASSERT(mPlugin->GMPThread() == NS_GetCurrentThread());
if (mShuttingDown) {
return NS_OK;
}
mShuttingDown = true;
// Notify client we're gone! Won't occur after Close()
if (mCallback) {
mCallback->Terminated();
mCallback = nullptr;
}
if (mIsOpen) {
// Don't send DecodingComplete if we died
mIsOpen = false;
unused << SendDecodingComplete();
}
mIsOpen = false;
unused << SendDecodingComplete();
return NS_OK;
}

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

@ -53,6 +53,7 @@ private:
virtual bool Recv__delete__() MOZ_OVERRIDE;
bool mIsOpen;
bool mShuttingDown;
nsRefPtr<GMPParent> mPlugin;
GMPAudioDecoderProxyCallback* mCallback;
};

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

@ -13,6 +13,7 @@ namespace gmp {
GMPDecryptorParent::GMPDecryptorParent(GMPParent* aPlugin)
: mIsOpen(false)
, mShuttingDown(false)
, mPlugin(aPlugin)
, mCallback(nullptr)
{
@ -328,16 +329,19 @@ GMPDecryptorParent::Shutdown()
{
MOZ_ASSERT(mPlugin->GMPThread() == NS_GetCurrentThread());
if (mShuttingDown) {
return;
}
mShuttingDown = true;
// Notify client we're gone! Won't occur after Close()
if (mCallback) {
mCallback->Terminated();
mCallback = nullptr;
}
if (mIsOpen) {
mIsOpen = false;
unused << SendDecryptingComplete();
}
mIsOpen = false;
unused << SendDecryptingComplete();
}
// Note: Keep this sync'd up with Shutdown

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

@ -106,6 +106,7 @@ private:
virtual bool Recv__delete__() MOZ_OVERRIDE;
bool mIsOpen;
bool mShuttingDown;
nsRefPtr<GMPParent> mPlugin;
GMPDecryptorProxyCallback* mCallback;
};

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

@ -45,6 +45,7 @@ namespace gmp {
GMPVideoDecoderParent::GMPVideoDecoderParent(GMPParent* aPlugin)
: GMPSharedMemManager(aPlugin)
, mIsOpen(false)
, mShuttingDown(false)
, mPlugin(aPlugin)
, mCallback(nullptr)
, mVideoHost(MOZ_THIS_IN_INITIALIZER_LIST())
@ -187,6 +188,11 @@ GMPVideoDecoderParent::Shutdown()
LOGD(("%s: %p", __FUNCTION__, this));
MOZ_ASSERT(mPlugin->GMPThread() == NS_GetCurrentThread());
if (mShuttingDown) {
return NS_OK;
}
mShuttingDown = true;
// Notify client we're gone! Won't occur after Close()
if (mCallback) {
mCallback->Terminated();
@ -194,11 +200,8 @@ GMPVideoDecoderParent::Shutdown()
}
mVideoHost.DoneWithAPI();
if (mIsOpen) {
// Don't send DecodingComplete if we died
mIsOpen = false;
unused << SendDecodingComplete();
}
mIsOpen = false;
unused << SendDecodingComplete();
return NS_OK;
}

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

@ -77,6 +77,7 @@ private:
virtual bool Recv__delete__() MOZ_OVERRIDE;
bool mIsOpen;
bool mShuttingDown;
nsRefPtr<GMPParent> mPlugin;
GMPVideoDecoderCallbackProxy* mCallback;
GMPVideoHostImpl mVideoHost;

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

@ -52,6 +52,7 @@ namespace gmp {
GMPVideoEncoderParent::GMPVideoEncoderParent(GMPParent *aPlugin)
: GMPSharedMemManager(aPlugin),
mIsOpen(false),
mShuttingDown(false),
mPlugin(aPlugin),
mCallback(nullptr),
mVideoHost(MOZ_THIS_IN_INITIALIZER_LIST())
@ -220,17 +221,20 @@ GMPVideoEncoderParent::Shutdown()
LOGD(("%s::%s: %p", __CLASS__, __FUNCTION__, this));
MOZ_ASSERT(mPlugin->GMPThread() == NS_GetCurrentThread());
if (mShuttingDown) {
return;
}
mShuttingDown = true;
// Notify client we're gone! Won't occur after Close()
if (mCallback) {
mCallback->Terminated();
mCallback = nullptr;
}
mVideoHost.DoneWithAPI();
if (mIsOpen) {
// Don't send EncodingComplete if we died
mIsOpen = false;
unused << SendEncodingComplete();
}
mIsOpen = false;
unused << SendEncodingComplete();
}
static void

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

@ -74,6 +74,7 @@ private:
virtual bool Recv__delete__() MOZ_OVERRIDE;
bool mIsOpen;
bool mShuttingDown;
nsRefPtr<GMPParent> mPlugin;
GMPVideoEncoderCallbackProxy* mCallback;
GMPVideoHostImpl mVideoHost;