void
GlobalAllocPolicy::Dealloc()
{
  ReentrantMonitorAutoEnter mon(mMonitor);
  ++mDecoderLimit;
  ResolvePromise(mon);
}
void
CDMProxy::SetServerCertificate(PromiseId aPromiseId,
                               const Uint8Array& aCertData)
{
  MOZ_ASSERT(NS_IsMainThread());
  MOZ_ASSERT(mGMPThread);

  // TODO: Dispatch task to GMPThread to call CDM SetServerCertificate via IPC.

  ResolvePromise(aPromiseId);
}
void
CDMProxy::CloseSession(const nsAString& aSessionId,
                       PromiseId aPromiseId)
{
  MOZ_ASSERT(NS_IsMainThread());
  NS_ENSURE_TRUE_VOID(!mKeys.IsNull());

  // TODO: Dispatch task to GMPThread to call CDM CloseSession via IPC.

  nsRefPtr<dom::MediaKeySession> session(mKeys->GetSession(aSessionId));

  // Pretend that the CDM actually does close the session...
  // "...the [MediaKeySession's] closed attribute promise is resolved
  // when the session is closed."
  session->OnClosed();

  // "The promise is resolved when the request has been processed."
  ResolvePromise(aPromiseId);
}
void
CDMProxy::UpdateSession(const nsAString& aSessionId,
                        PromiseId aPromiseId,
                        const Uint8Array& aResponse)
{
  MOZ_ASSERT(NS_IsMainThread());
  MOZ_ASSERT(mGMPThread);
  NS_ENSURE_TRUE_VOID(!mKeys.IsNull());

  // TODO: Dispatch task to GMPThread to call CDM UpdateSession via IPC.

  nsRefPtr<dom::MediaKeySession> session(mKeys->GetSession(aSessionId));
  nsAutoCString str(NS_LITERAL_CSTRING("Update_"));
  str.AppendInt(sUpdateCount++);
  nsTArray<uint8_t> msg;
  msg.AppendElements(str.get(), str.Length());
  session->DispatchKeyMessage(msg, NS_LITERAL_STRING("http://bogus.url"));
  ResolvePromise(aPromiseId);
}