Exemple #1
0
 void Done(GMPContentParent* aGMPParent) override
 {
   GMPDecryptorParent* ksp = nullptr;
   if (aGMPParent && NS_SUCCEEDED(aGMPParent->GetGMPDecryptor(&ksp))) {
     ksp->SetCrashHelper(mHelper);
   }
   mCallback->Done(ksp);
 }
Exemple #2
0
NS_IMETHODIMP
GeckoMediaPluginService::GetGMPDecryptor(GMPCrashHelper* aHelper,
                                         nsTArray<nsCString>* aTags,
                                         const nsACString& aNodeId,
                                         UniquePtr<GetGMPDecryptorCallback>&& aCallback)
{
#if defined(XP_LINUX) && defined(MOZ_GMP_SANDBOX)
  if (!SandboxInfo::Get().CanSandboxMedia()) {
    NS_WARNING("GeckoMediaPluginService::GetGMPDecryptor: "
               "EME decryption not available without sandboxing support.");
    return NS_ERROR_NOT_AVAILABLE;
  }
#endif

  MOZ_ASSERT(NS_GetCurrentThread() == mGMPThread);
  NS_ENSURE_ARG(aTags && aTags->Length() > 0);
  NS_ENSURE_ARG(aCallback);

  if (mShuttingDownOnGMPThread) {
    return NS_ERROR_FAILURE;
  }

  GetGMPDecryptorCallback* rawCallback = aCallback.release();
  RefPtr<AbstractThread> thread(GetAbstractGMPThread());
  RefPtr<GMPCrashHelper> helper(aHelper);
  GetContentParent(aHelper, aNodeId, NS_LITERAL_CSTRING(GMP_API_DECRYPTOR), *aTags)
    ->Then(thread, __func__,
      [rawCallback, helper](RefPtr<GMPContentParent::CloseBlocker> wrapper) {
        RefPtr<GMPContentParent> parent = wrapper->mParent;
        UniquePtr<GetGMPDecryptorCallback> callback(rawCallback);
        GMPDecryptorParent* actor = nullptr;
        if (parent && NS_SUCCEEDED(parent->GetGMPDecryptor(&actor))) {
          actor->SetCrashHelper(helper);
        }
        callback->Done(actor);
      },
      [rawCallback] {
        UniquePtr<GetGMPDecryptorCallback> callback(rawCallback);
        callback->Done(nullptr);
      });

  return NS_OK;
}