Bug 1047107 - Make CDMProxy Close() its GMPDecryptorProxy on Shutdown. r=ehsan

This commit is contained in:
Chris Pearce 2014-08-08 14:43:54 +12:00
parent 59b45ae708
commit b7a84dcba6
3 changed files with 29 additions and 4 deletions

View File

@ -302,6 +302,19 @@ CDMProxy::Shutdown()
{
MOZ_ASSERT(NS_IsMainThread());
mKeys.Clear();
// Note: This may end up being the last owning reference to the CDMProxy.
nsRefPtr<nsIRunnable> task(NS_NewRunnableMethod(this, &CDMProxy::gmp_Shutdown));
mGMPThread->Dispatch(task, NS_DISPATCH_NORMAL);
}
void
CDMProxy::gmp_Shutdown()
{
MOZ_ASSERT(IsOnGMPThread());
if (mCDM) {
mCDM->Close();
mCDM = nullptr;
}
}
void
@ -485,10 +498,7 @@ CDMProxy::gmp_Terminated()
{
MOZ_ASSERT(IsOnGMPThread());
EME_LOG("CDM terminated");
if (mCDM) {
mCDM->Close();
mCDM = nullptr;
}
gmp_Shutdown();
}
} // namespace mozilla

View File

@ -167,6 +167,9 @@ private:
// GMP thread only.
void gmp_Init(uint32_t aPromiseId);
// GMP thread only.
void gmp_Shutdown();
// Main thread only.
void OnCDMCreated(uint32_t aPromiseId);

View File

@ -44,12 +44,24 @@ MediaKeys::MediaKeys(nsPIDOMWindow* aParent, const nsAString& aKeySystem)
SetIsDOMBinding();
}
static PLDHashOperator
RejectPromises(const uint32_t& aKey,
nsRefPtr<dom::Promise>& aPromise,
void* aClosure)
{
aPromise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR);
return PL_DHASH_NEXT;
}
MediaKeys::~MediaKeys()
{
if (mProxy) {
mProxy->Shutdown();
mProxy = nullptr;
}
mPromises.Enumerate(&RejectPromises, nullptr);
mPromises.Clear();
}
nsPIDOMWindow*