NS_IMETHODIMP GeckoMediaPluginService::GetGMPAudioDecoder(GMPCrashHelper* aHelper, nsTArray<nsCString>* aTags, const nsACString& aNodeId, UniquePtr<GetGMPAudioDecoderCallback>&& aCallback) { MOZ_ASSERT(NS_GetCurrentThread() == mGMPThread); NS_ENSURE_ARG(aTags && aTags->Length() > 0); NS_ENSURE_ARG(aCallback); if (mShuttingDownOnGMPThread) { return NS_ERROR_FAILURE; } GetGMPAudioDecoderCallback* rawCallback = aCallback.release(); RefPtr<AbstractThread> thread(GetAbstractGMPThread()); RefPtr<GMPCrashHelper> helper(aHelper); GetContentParent(aHelper, aNodeId, NS_LITERAL_CSTRING(GMP_API_AUDIO_DECODER), *aTags) ->Then(thread, __func__, [rawCallback, helper](RefPtr<GMPContentParent::CloseBlocker> wrapper) { RefPtr<GMPContentParent> parent = wrapper->mParent; UniquePtr<GetGMPAudioDecoderCallback> callback(rawCallback); GMPAudioDecoderParent* actor = nullptr; if (parent && NS_SUCCEEDED(parent->GetGMPAudioDecoder(&actor))) { actor->SetCrashHelper(helper); } callback->Done(actor); }, [rawCallback] { UniquePtr<GetGMPAudioDecoderCallback> callback(rawCallback); callback->Done(nullptr); }); return NS_OK; }
void Done(GMPContentParent* aGMPParent) override { GMPAudioDecoderParent* gmpADP = nullptr; if (aGMPParent && NS_SUCCEEDED(aGMPParent->GetGMPAudioDecoder(&gmpADP))) { gmpADP->SetCrashHelper(mHelper); } mCallback->Done(gmpADP); }