mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 1346678 - Label runnables in dom/media/gmp/GMPParent.cpp and its friends. r=cpearce
MozReview-Commit-ID: DWYx30T7gCJ --HG-- extra : rebase_source : 68caf369926ea08cd7a56846c1de1cf75a6c54e6 extra : intermediate-source : b57189c8fa07cc066cf430358401c471b0927063 extra : source : b014f243626f5361a496edacb639a663abea2964
This commit is contained in:
parent
6150d45675
commit
017020976f
@ -19,7 +19,9 @@ GMPCrashHelper::Destroy()
|
||||
delete this;
|
||||
} else {
|
||||
// Don't addref, as then we'd end up releasing after the detele runs!
|
||||
NS_DispatchToMainThread(mozilla::NewNonOwningRunnableMethod(this, &GMPCrashHelper::Destroy));
|
||||
SystemGroup::Dispatch(
|
||||
"GMPCrashHelper::Destroy", TaskCategory::Other,
|
||||
NewNonOwningRunnableMethod(this, &GMPCrashHelper::Destroy));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ extern LogModule* GetGMPLog();
|
||||
|
||||
namespace gmp {
|
||||
|
||||
GMPParent::GMPParent()
|
||||
GMPParent::GMPParent(AbstractThread* aMainThread)
|
||||
: mState(GMPStateNotLoaded)
|
||||
, mProcess(nullptr)
|
||||
, mDeleteProcessOnlyOnUnload(false)
|
||||
@ -70,6 +70,7 @@ GMPParent::GMPParent()
|
||||
, mGMPContentChildCount(0)
|
||||
, mChildPid(0)
|
||||
, mHoldingSelfRef(false)
|
||||
, mMainThread(aMainThread)
|
||||
{
|
||||
mPluginId = GeckoChildProcessHost::GetUniqueID();
|
||||
LOGD("GMPParent ctor id=%u", mPluginId);
|
||||
@ -302,7 +303,8 @@ GMPParent::Shutdown()
|
||||
class NotifyGMPShutdownTask : public Runnable {
|
||||
public:
|
||||
explicit NotifyGMPShutdownTask(const nsAString& aNodeId)
|
||||
: mNodeId(aNodeId)
|
||||
: Runnable("NotifyGMPShutdownTask")
|
||||
, mNodeId(aNodeId)
|
||||
{
|
||||
}
|
||||
NS_IMETHOD Run() override {
|
||||
@ -354,9 +356,9 @@ GMPParent::DeleteProcess()
|
||||
mProcess = nullptr;
|
||||
mState = GMPStateNotLoaded;
|
||||
|
||||
NS_DispatchToMainThread(
|
||||
new NotifyGMPShutdownTask(NS_ConvertUTF8toUTF16(mNodeId)),
|
||||
NS_DISPATCH_NORMAL);
|
||||
nsCOMPtr<nsIRunnable> r
|
||||
= new NotifyGMPShutdownTask(NS_ConvertUTF8toUTF16(mNodeId));
|
||||
mMainThread->Dispatch(r.forget());
|
||||
|
||||
if (mHoldingSelfRef) {
|
||||
Release();
|
||||
@ -517,9 +519,9 @@ GMPParent::ActorDestroy(ActorDestroyReason aWhy)
|
||||
}
|
||||
|
||||
// NotifyObservers is mainthread-only
|
||||
NS_DispatchToMainThread(WrapRunnableNM(&GMPNotifyObservers,
|
||||
mPluginId, mDisplayName, dumpID),
|
||||
NS_DISPATCH_NORMAL);
|
||||
nsCOMPtr<nsIRunnable> r = WrapRunnableNM(
|
||||
&GMPNotifyObservers, mPluginId, mDisplayName, dumpID);
|
||||
mMainThread->Dispatch(r.forget());
|
||||
}
|
||||
#endif
|
||||
// warn us off trying to close again
|
||||
@ -728,8 +730,7 @@ GMPParent::ReadChromiumManifestFile(nsIFile* aFile)
|
||||
|
||||
// DOM JSON parsing needs to run on the main thread.
|
||||
return InvokeAsync<nsString&&>(
|
||||
// Non DocGroup-version of AbstractThread::MainThread for the task in parent.
|
||||
AbstractThread::MainThread(), this, __func__,
|
||||
mMainThread, this, __func__,
|
||||
&GMPParent::ParseChromiumManifest, NS_ConvertUTF8toUTF16(json));
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ class GMPParent final : public PGMPParent
|
||||
public:
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GMPParent)
|
||||
|
||||
GMPParent();
|
||||
explicit GMPParent(AbstractThread* aMainThread);
|
||||
|
||||
RefPtr<GenericPromise> Init(GeckoMediaPluginServiceParent* aService, nsIFile* aPluginDir);
|
||||
nsresult CloneFrom(const GMPParent* aOther);
|
||||
@ -228,6 +228,8 @@ private:
|
||||
#ifdef MOZ_CRASHREPORTER
|
||||
UniquePtr<ipc::CrashReporterHost> mCrashReporter;
|
||||
#endif
|
||||
|
||||
const RefPtr<AbstractThread> mMainThread;
|
||||
};
|
||||
|
||||
} // namespace gmp
|
||||
|
@ -79,12 +79,11 @@ public:
|
||||
if (NS_IsMainThread()) {
|
||||
service = GetOrCreateOnMainThread();
|
||||
} else {
|
||||
nsCOMPtr<nsIThread> mainThread = do_GetMainThread();
|
||||
MOZ_ASSERT(mainThread);
|
||||
|
||||
RefPtr<GMPServiceCreateHelper> createHelper = new GMPServiceCreateHelper();
|
||||
|
||||
mozilla::SyncRunnable::DispatchToThread(mainThread, createHelper, true);
|
||||
mozilla::SyncRunnable::DispatchToThread(
|
||||
SystemGroup::EventTargetFor(mozilla::TaskCategory::Other),
|
||||
createHelper, true);
|
||||
|
||||
service = createHelper->mService.forget();
|
||||
}
|
||||
@ -94,6 +93,7 @@ public:
|
||||
|
||||
private:
|
||||
GMPServiceCreateHelper()
|
||||
: Runnable("GMPServiceCreateHelper")
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -305,8 +305,9 @@ GeckoMediaPluginServiceChild::GetServiceChild()
|
||||
MozPromiseHolder<GetServiceChildPromise>* holder = mGetServiceChildPromises.AppendElement();
|
||||
RefPtr<GetServiceChildPromise> promise = holder->Ensure(__func__);
|
||||
if (mGetServiceChildPromises.Length() == 1) {
|
||||
NS_DispatchToMainThread(WrapRunnable(contentChild,
|
||||
&dom::ContentChild::SendCreateGMPService));
|
||||
nsCOMPtr<nsIRunnable> r = WrapRunnable(
|
||||
contentChild, &dom::ContentChild::SendCreateGMPService);
|
||||
SystemGroup::Dispatch("SendCreateGMPService", TaskCategory::Other, r.forget());
|
||||
}
|
||||
return promise;
|
||||
}
|
||||
|
@ -94,6 +94,7 @@ GeckoMediaPluginServiceParent::GeckoMediaPluginServiceParent()
|
||||
, mInitPromiseMonitor("GeckoMediaPluginServiceParent::mInitPromiseMonitor")
|
||||
, mLoadPluginsFromDiskComplete(false)
|
||||
, mServiceUserCount(0)
|
||||
, mMainThread(SystemGroup::AbstractMainThreadFor(TaskCategory::Other))
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
mInitPromise.SetMonitor(&mInitPromiseMonitor);
|
||||
@ -462,9 +463,10 @@ GeckoMediaPluginServiceParent::UnloadPlugins()
|
||||
plugin->CloseActive(true);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRunnable> task(NewRunnableMethod(
|
||||
this, &GeckoMediaPluginServiceParent::NotifySyncShutdownComplete));
|
||||
NS_DispatchToMainThread(task);
|
||||
nsCOMPtr<nsIRunnable> task = NewRunnableMethod(
|
||||
"GeckoMediaPluginServiceParent::NotifySyncShutdownComplete",
|
||||
this, &GeckoMediaPluginServiceParent::NotifySyncShutdownComplete);
|
||||
mMainThread->Dispatch(task.forget());
|
||||
}
|
||||
|
||||
void
|
||||
@ -520,7 +522,8 @@ GeckoMediaPluginServiceParent::LoadFromEnvironment()
|
||||
class NotifyObserversTask final : public mozilla::Runnable {
|
||||
public:
|
||||
explicit NotifyObserversTask(const char* aTopic, nsString aData = EmptyString())
|
||||
: mTopic(aTopic)
|
||||
: Runnable(aTopic)
|
||||
, mTopic(aTopic)
|
||||
, mData(aData)
|
||||
{}
|
||||
NS_IMETHOD Run() override {
|
||||
@ -553,9 +556,10 @@ void
|
||||
GeckoMediaPluginServiceParent::UpdateContentProcessGMPCapabilities()
|
||||
{
|
||||
if (!NS_IsMainThread()) {
|
||||
nsCOMPtr<nsIRunnable> task =
|
||||
NewRunnableMethod(this, &GeckoMediaPluginServiceParent::UpdateContentProcessGMPCapabilities);
|
||||
NS_DispatchToMainThread(task);
|
||||
nsCOMPtr<nsIRunnable> task = NewRunnableMethod(
|
||||
"GeckoMediaPluginServiceParent::UpdateContentProcessGMPCapabilities",
|
||||
this, &GeckoMediaPluginServiceParent::UpdateContentProcessGMPCapabilities);
|
||||
mMainThread->Dispatch(task.forget());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -617,7 +621,7 @@ GeckoMediaPluginServiceParent::AsyncAddPluginDirectory(const nsAString& aDirecto
|
||||
thread, this, __func__,
|
||||
&GeckoMediaPluginServiceParent::AddOnGMPThread, dir)
|
||||
->Then(
|
||||
AbstractThread::MainThread(), // Non DocGroup-version for the task in parent.
|
||||
mMainThread,
|
||||
__func__,
|
||||
[dir, self]() -> void {
|
||||
LOGD(("GeckoMediaPluginServiceParent::AsyncAddPluginDirectory %s succeeded",
|
||||
@ -779,7 +783,7 @@ GeckoMediaPluginServiceParent::SelectPluginForAPI(const nsACString& aNodeId,
|
||||
}
|
||||
|
||||
RefPtr<GMPParent>
|
||||
CreateGMPParent()
|
||||
CreateGMPParent(AbstractThread* aMainThread)
|
||||
{
|
||||
#if defined(XP_LINUX) && defined(MOZ_GMP_SANDBOX)
|
||||
if (!SandboxInfo::Get().CanSandboxMedia()) {
|
||||
@ -790,7 +794,7 @@ CreateGMPParent()
|
||||
NS_WARNING("Loading media plugin despite lack of sandboxing.");
|
||||
}
|
||||
#endif
|
||||
return new GMPParent();
|
||||
return new GMPParent(aMainThread);
|
||||
}
|
||||
|
||||
already_AddRefed<GMPParent>
|
||||
@ -798,7 +802,7 @@ GeckoMediaPluginServiceParent::ClonePlugin(const GMPParent* aOriginal)
|
||||
{
|
||||
MOZ_ASSERT(aOriginal);
|
||||
|
||||
RefPtr<GMPParent> gmp = CreateGMPParent();
|
||||
RefPtr<GMPParent> gmp = CreateGMPParent(mMainThread);
|
||||
nsresult rv = gmp ? gmp->CloneFrom(aOriginal) : NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
@ -837,7 +841,7 @@ GeckoMediaPluginServiceParent::AddOnGMPThread(nsString aDirectory)
|
||||
return GenericPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
|
||||
}
|
||||
|
||||
RefPtr<GMPParent> gmp = CreateGMPParent();
|
||||
RefPtr<GMPParent> gmp = CreateGMPParent(mMainThread);
|
||||
if (!gmp) {
|
||||
NS_WARNING("Can't Create GMPParent");
|
||||
return GenericPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
|
||||
@ -920,9 +924,9 @@ GeckoMediaPluginServiceParent::RemoveOnGMPThread(const nsAString& aDirectory,
|
||||
}
|
||||
if (NS_SUCCEEDED(directory->Remove(true))) {
|
||||
mPluginsWaitingForDeletion.RemoveElement(aDirectory);
|
||||
NS_DispatchToMainThread(new NotifyObserversTask("gmp-directory-deleted",
|
||||
nsString(aDirectory)),
|
||||
NS_DISPATCH_NORMAL);
|
||||
nsCOMPtr<nsIRunnable> task = new NotifyObserversTask(
|
||||
"gmp-directory-deleted", nsString(aDirectory));
|
||||
mMainThread->Dispatch(task.forget());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1537,7 +1541,9 @@ GeckoMediaPluginServiceParent::ClearRecentHistoryOnGMPThread(PRTime aSince)
|
||||
|
||||
ClearNodeIdAndPlugin(filter);
|
||||
|
||||
NS_DispatchToMainThread(new NotifyObserversTask("gmp-clear-storage-complete"), NS_DISPATCH_NORMAL);
|
||||
nsCOMPtr<nsIRunnable> task
|
||||
= new NotifyObserversTask("gmp-clear-storage-complete");
|
||||
mMainThread->Dispatch(task.forget());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1647,7 +1653,9 @@ GeckoMediaPluginServiceParent::ClearStorage()
|
||||
// Clear private-browsing storage.
|
||||
mTempGMPStorage.Clear();
|
||||
|
||||
NS_DispatchToMainThread(new NotifyObserversTask("gmp-clear-storage-complete"), NS_DISPATCH_NORMAL);
|
||||
nsCOMPtr<nsIRunnable> task
|
||||
= new NotifyObserversTask("gmp-clear-storage-complete");
|
||||
mMainThread->Dispatch(task.forget());
|
||||
}
|
||||
|
||||
already_AddRefed<GMPParent>
|
||||
@ -1664,9 +1672,10 @@ GeckoMediaPluginServiceParent::GetById(uint32_t aPluginId)
|
||||
|
||||
GMPServiceParent::~GMPServiceParent()
|
||||
{
|
||||
NS_DispatchToMainThread(
|
||||
NewRunnableMethod(mService.get(),
|
||||
&GeckoMediaPluginServiceParent::ServiceUserDestroyed));
|
||||
nsCOMPtr<nsIRunnable> task = NewRunnableMethod(
|
||||
"GeckoMediaPluginServiceParent::ServiceUserDestroyed",
|
||||
mService.get(), &GeckoMediaPluginServiceParent::ServiceUserDestroyed);
|
||||
mService->MainThread()->Dispatch(task.forget());
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
|
@ -65,6 +65,8 @@ public:
|
||||
|
||||
void UpdateContentProcessGMPCapabilities();
|
||||
|
||||
AbstractThread* MainThread() const { return mMainThread; }
|
||||
|
||||
private:
|
||||
friend class GMPServiceParent;
|
||||
|
||||
@ -202,6 +204,8 @@ private:
|
||||
// Tracks how many users are running (on the GMP thread). Only when this count
|
||||
// drops to 0 can we safely shut down the thread.
|
||||
MainThreadOnly<int32_t> mServiceUserCount;
|
||||
|
||||
const RefPtr<AbstractThread> mMainThread;
|
||||
};
|
||||
|
||||
nsresult ReadSalt(nsIFile* aPath, nsACString& aOutData);
|
||||
|
Loading…
Reference in New Issue
Block a user