nsresult GMPParent::CloneFrom(const GMPParent* aOther) { MOZ_ASSERT(GMPThread() == NS_GetCurrentThread()); MOZ_ASSERT(aOther->mDirectory && aOther->mService, "null plugin directory"); return Init(aOther->mService, aOther->mDirectory); }
nsresult GMPParent::LoadProcess() { MOZ_ASSERT(mDirectory, "Plugin directory cannot be NULL!"); MOZ_ASSERT(GMPThread() == NS_GetCurrentThread()); MOZ_ASSERT(mState == GMPStateNotLoaded); nsAutoCString path; if (NS_FAILED(mDirectory->GetNativePath(path))) { return NS_ERROR_FAILURE; } LOGD(("%s::%s: %p for %s", __CLASS__, __FUNCTION__, this, path.get())); if (!mProcess) { mProcess = new GMPProcessParent(path.get()); if (!mProcess->Launch(30 * 1000)) { mProcess->Delete(); mProcess = nullptr; return NS_ERROR_FAILURE; } bool opened = Open(mProcess->GetChannel(), mProcess->GetChildProcessHandle()); if (!opened) { mProcess->Delete(); mProcess = nullptr; return NS_ERROR_FAILURE; } LOGD(("%s::%s: Created new process %p", __CLASS__, __FUNCTION__, (void *)mProcess)); } mState = GMPStateLoaded; return NS_OK; }
void GMPParent::Shutdown() { LOGD(("%s::%s: %p", __CLASS__, __FUNCTION__, this)); MOZ_ASSERT(GMPThread() == NS_GetCurrentThread()); if (mAbnormalShutdownInProgress) { return; } MOZ_ASSERT(mVideoDecoders.IsEmpty() && mVideoEncoders.IsEmpty()); if (mState == GMPStateNotLoaded || mState == GMPStateClosing) { return; } mState = GMPStateClosing; DeleteProcess(); // XXX Get rid of mDeleteProcessOnlyOnUnload and this code when // Bug 1043671 is fixed if (!mDeleteProcessOnlyOnUnload) { // Destroy ourselves and rise from the fire to save memory nsRefPtr<GMPParent> self(this); mService->ReAddOnGMPThread(self); } // else we've been asked to die and stay dead MOZ_ASSERT(mState == GMPStateNotLoaded); }
PGMPTimerParent* GMPParent::AllocPGMPTimerParent() { GMPTimerParent* p = new GMPTimerParent(GMPThread()); NS_ADDREF(p); // Released in DeallocPGMPTimerParent. return p; }
void GMPContentParent::AudioDecoderDestroyed(GMPAudioDecoderParent* aDecoder) { MOZ_ASSERT(GMPThread() == NS_GetCurrentThread()); MOZ_ALWAYS_TRUE(mAudioDecoders.RemoveElement(aDecoder)); CloseIfUnused(); }
void GMPContentParent::DecryptorDestroyed(GMPDecryptorParent* aSession) { MOZ_ASSERT(GMPThread() == NS_GetCurrentThread()); MOZ_ALWAYS_TRUE(mDecryptors.RemoveElement(aSession)); CloseIfUnused(); }
void GMPContentParent::VideoDecoderDestroyed(GMPVideoDecoderParent* aDecoder) { MOZ_ASSERT(GMPThread() == NS_GetCurrentThread()); // If the constructor fails, we'll get called before it's added Unused << NS_WARN_IF(!mVideoDecoders.RemoveElement(aDecoder)); CloseIfUnused(); }
void GMPParent::AudioDecoderDestroyed(GMPAudioDecoderParent* aDecoder) { MOZ_ASSERT(GMPThread() == NS_GetCurrentThread()); MOZ_ALWAYS_TRUE(mAudioDecoders.RemoveElement(aDecoder)); // Recv__delete__ is on the stack, don't potentially destroy the top-level actor // until after this has completed. nsCOMPtr<nsIRunnable> event = NS_NewRunnableMethod(this, &GMPParent::CloseIfUnused); NS_DispatchToCurrentThread(event); }
void GMPParent::CloseIfUnused() { MOZ_ASSERT(GMPThread() == NS_GetCurrentThread()); if ((mState == GMPStateLoaded || mState == GMPStateUnloading) && mVideoDecoders.IsEmpty() && mVideoEncoders.IsEmpty()) { Shutdown(); } }
void GMPParent::DecryptorDestroyed(GMPDecryptorParent* aSession) { MOZ_ASSERT(GMPThread() == NS_GetCurrentThread()); MOZ_ALWAYS_TRUE(mDecryptors.RemoveElement(aSession)); // Recv__delete__ is on the stack, don't potentially destroy the top-level actor // until after this has completed. if (mDecryptors.IsEmpty()) { nsCOMPtr<nsIRunnable> event = NS_NewRunnableMethod(this, &GMPParent::CloseIfUnused); NS_DispatchToCurrentThread(event); } }
void GMPParent::CloseIfUnused() { MOZ_ASSERT(GMPThread() == NS_GetCurrentThread()); if ((mDeleteProcessOnlyOnUnload || mState == GMPStateLoaded || mState == GMPStateUnloading) && mVideoDecoders.IsEmpty() && mVideoEncoders.IsEmpty() && mDecryptors.IsEmpty() && mAudioDecoders.IsEmpty()) { Shutdown(); } }
void GMPParent::Shutdown() { MOZ_ASSERT(GMPThread() == NS_GetCurrentThread()); MOZ_ASSERT(mVideoDecoders.IsEmpty() && mVideoEncoders.IsEmpty()); if (mState == GMPStateNotLoaded || mState == GMPStateClosing) { return; } mState = GMPStateClosing; Close(); DeleteProcess(); MOZ_ASSERT(mState == GMPStateNotLoaded); }
void GMPParent::VideoEncoderDestroyed(GMPVideoEncoderParent* aEncoder) { MOZ_ASSERT(GMPThread() == NS_GetCurrentThread()); // If the constructor fails, we'll get called before it's added unused << NS_WARN_IF(!mVideoEncoders.RemoveElement(aEncoder)); if (mVideoDecoders.IsEmpty() && mVideoEncoders.IsEmpty()) { // Recv__delete__ is on the stack, don't potentially destroy the top-level actor // until after this has completed. nsCOMPtr<nsIRunnable> event = NS_NewRunnableMethod(this, &GMPParent::CloseIfUnused); NS_DispatchToCurrentThread(event); } }
nsresult GMPParent::Init(nsIFile* aPluginDir) { MOZ_ASSERT(aPluginDir); MOZ_ASSERT(GMPThread() == NS_GetCurrentThread()); mDirectory = aPluginDir; nsAutoString leafname; nsresult rv = aPluginDir->GetLeafName(leafname); if (NS_FAILED(rv)) { return rv; } MOZ_ASSERT(leafname.Length() > 4); mName = Substring(leafname, 4); return ReadGMPMetaData(); }
nsresult GMPParent::GetGMPVideoEncoder(GMPVideoEncoderParent** aGMPVE) { MOZ_ASSERT(GMPThread() == NS_GetCurrentThread()); if (!EnsureProcessLoaded()) { return NS_ERROR_FAILURE; } // returned with one anonymous AddRef that locks it until Destroy PGMPVideoEncoderParent* pvep = SendPGMPVideoEncoderConstructor(); if (!pvep) { return NS_ERROR_FAILURE; } GMPVideoEncoderParent *vep = static_cast<GMPVideoEncoderParent*>(pvep); *aGMPVE = vep; mVideoEncoders.AppendElement(vep); return NS_OK; }
nsresult GMPParent::GetGMPDecryptor(GMPDecryptorParent** aGMPDP) { MOZ_ASSERT(GMPThread() == NS_GetCurrentThread()); if (!EnsureProcessLoaded()) { return NS_ERROR_FAILURE; } PGMPDecryptorParent* pdp = SendPGMPDecryptorConstructor(); if (!pdp) { return NS_ERROR_FAILURE; } GMPDecryptorParent* dp = static_cast<GMPDecryptorParent*>(pdp); // This addref corresponds to the Proxy pointer the consumer is returned. // It's dropped by calling Close() on the interface. NS_ADDREF(dp); mDecryptors.AppendElement(dp); *aGMPDP = dp; return NS_OK; }
nsresult GMPParent::Init(GeckoMediaPluginService *aService, nsIFile* aPluginDir) { MOZ_ASSERT(aPluginDir); MOZ_ASSERT(aService); MOZ_ASSERT(GMPThread() == NS_GetCurrentThread()); mService = aService; mDirectory = aPluginDir; nsAutoString leafname; nsresult rv = aPluginDir->GetLeafName(leafname); if (NS_FAILED(rv)) { return rv; } LOGD(("%s::%s: %p for %s", __CLASS__, __FUNCTION__, this, NS_LossyConvertUTF16toASCII(leafname).get())); MOZ_ASSERT(leafname.Length() > 4); mName = Substring(leafname, 4); return ReadGMPMetaData(); }
nsresult GMPParent::GetGMPVideoEncoder(GMPVideoEncoderParent** aGMPVE) { MOZ_ASSERT(GMPThread() == NS_GetCurrentThread()); if (!EnsureProcessLoaded()) { return NS_ERROR_FAILURE; } // returned with one anonymous AddRef that locks it until Destroy PGMPVideoEncoderParent* pvep = SendPGMPVideoEncoderConstructor(); if (!pvep) { return NS_ERROR_FAILURE; } GMPVideoEncoderParent *vep = static_cast<GMPVideoEncoderParent*>(pvep); // This addref corresponds to the Proxy pointer the consumer is returned. // It's dropped by calling Close() on the interface. NS_ADDREF(vep); *aGMPVE = vep; mVideoEncoders.AppendElement(vep); return NS_OK; }