Bug 1410209, part 4 - Add names to some IPC runnables. r=kanru
This patch requires that each instance of IPC's RunnableFunction is
passed in a name, like the non-IPC RunnableFunction.
MozReview-Commit-ID: Atu1W3Rl66S
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -1805,17 +1805,18 @@ ContentChild::RecvPBrowserConstructor(PB
const bool& aIsForBrowser)
{
MOZ_ASSERT(!IsShuttingDown());
static bool hasRunOnce = false;
if (!hasRunOnce) {
hasRunOnce = true;
MOZ_ASSERT(!gFirstIdleTask);
- RefPtr<CancelableRunnable> firstIdleTask = NewCancelableRunnableFunction(FirstIdle);
+ RefPtr<CancelableRunnable> firstIdleTask = NewCancelableRunnableFunction("FirstIdleRunnable",
+ FirstIdle);
gFirstIdleTask = firstIdleTask;
NS_IdleDispatchToCurrentThread(firstIdleTask.forget());
}
return nsIContentChild::RecvPBrowserConstructor(aActor,
aTabId,
aSameTabGroupAs,
aContext,
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -1758,17 +1758,18 @@ ContentParent::ActorDestroy(ActorDestroy
RefPtr<ParentIdleListener> listener;
for (int32_t i = mIdleListeners.Length() - 1; i >= 0; --i) {
listener = static_cast<ParentIdleListener*>(mIdleListeners[i].get());
idleService->RemoveIdleObserver(listener, listener->mTime);
}
mIdleListeners.Clear();
MessageLoop::current()->
- PostTask(NewRunnableFunction(DelayedDeleteSubprocess, mSubprocess));
+ PostTask(NewRunnableFunction("DelayedDeleteSubprocessRunnable",
+ DelayedDeleteSubprocess, mSubprocess));
mSubprocess = nullptr;
// IPDL rules require actors to live on past ActorDestroy, but it
// may be that the kungFuDeathGrip above is the last reference to
// |this|. If so, when we go out of scope here, we're deleted and
// all hell breaks loose.
//
// This runnable ensures that a reference to |this| lives on at
@@ -3115,17 +3116,18 @@ ContentParent::OnGenerateMinidumpComplet
}
if (mSubprocess) {
mSubprocess->SetAlreadyDead();
}
// EnsureProcessTerminated has responsibilty for closing otherProcessHandle.
XRE_GetIOMessageLoop()->PostTask(
- NewRunnableFunction(&ProcessWatcher::EnsureProcessTerminated,
+ NewRunnableFunction("EnsureProcessTerminatedRunnable",
+ &ProcessWatcher::EnsureProcessTerminated,
otherProcessHandle, /*force=*/true));
}
void
ContentParent::FriendlyName(nsAString& aName, bool aAnonymize)
{
aName.Truncate();
if (mIsForBrowser) {
--- a/dom/media/ipc/VideoDecoderManagerChild.cpp
+++ b/dom/media/ipc/VideoDecoderManagerChild.cpp
@@ -47,17 +47,18 @@ VideoDecoderManagerChild::InitializeThre
sRecreateTasks = MakeUnique<nsTArray<RefPtr<Runnable>>>();
}
}
/* static */ void
VideoDecoderManagerChild::InitForContent(Endpoint<PVideoDecoderManagerChild>&& aVideoManager)
{
InitializeThread();
- sVideoDecoderChildThread->Dispatch(NewRunnableFunction(&Open, Move(aVideoManager)), NS_DISPATCH_NORMAL);
+ sVideoDecoderChildThread->Dispatch(NewRunnableFunction("InitForContentRunnable",
+ &Open, Move(aVideoManager)), NS_DISPATCH_NORMAL);
}
/* static */ void
VideoDecoderManagerChild::Shutdown()
{
MOZ_ASSERT(NS_IsMainThread());
if (sVideoDecoderChildThread) {
--- a/gfx/ipc/GPUProcessHost.cpp
+++ b/gfx/ipc/GPUProcessHost.cpp
@@ -240,13 +240,13 @@ GPUProcessHost::DestroyProcess()
// Cancel all tasks. We don't want anything triggering after our caller
// expects this to go away.
{
MonitorAutoLock lock(mMonitor);
mTaskFactory.RevokeAll();
}
MessageLoop::current()->
- PostTask(NewRunnableFunction(DelayedDeleteSubprocess, this));
+ PostTask(NewRunnableFunction("DestroyProcessRunnable", DelayedDeleteSubprocess, this));
}
} // namespace gfx
} // namespace mozilla
--- a/gfx/layers/PaintThread.cpp
+++ b/gfx/layers/PaintThread.cpp
@@ -191,17 +191,19 @@ PaintThread::Shutdown()
{
MOZ_ASSERT(NS_IsMainThread());
UniquePtr<PaintThread> pt(sSingleton.forget());
if (!pt) {
return;
}
- sThread->Dispatch(NewRunnableFunction(DestroyPaintThread, Move(pt)));
+ sThread->Dispatch(NewRunnableFunction("DestroyPaintThreadRunnable",
+ DestroyPaintThread,
+ Move(pt)));
sThread->Shutdown();
sThread = nullptr;
}
void
PaintThread::ShutdownOnPaintThread()
{
MOZ_ASSERT(IsOnPaintThread());
--- a/gfx/layers/apz/src/APZCTreeManager.cpp
+++ b/gfx/layers/apz/src/APZCTreeManager.cpp
@@ -2379,17 +2379,18 @@ APZCTreeManager::BuildOverscrollHandoffC
return result;
}
void
APZCTreeManager::SetLongTapEnabled(bool aLongTapEnabled)
{
APZThreadUtils::RunOnControllerThread(
- NewRunnableFunction(GestureEventListener::SetLongTapEnabled, aLongTapEnabled));
+ NewRunnableFunction("SetLongTapEnabledRunnable",
+ GestureEventListener::SetLongTapEnabled, aLongTapEnabled));
}
RefPtr<HitTestingTreeNode>
APZCTreeManager::FindScrollThumbNode(const AsyncDragMetrics& aDragMetrics)
{
MutexAutoLock lock(mTreeLock);
return DepthFirstSearch<ReverseIterator>(mRootNode.get(),
--- a/gfx/layers/client/TextureClient.cpp
+++ b/gfx/layers/client/TextureClient.cpp
@@ -333,23 +333,25 @@ DeallocateTextureClient(TextureDeallocPa
}
// First make sure that the work is happening on the IPDL thread.
if (ipdlMsgLoop && MessageLoop::current() != ipdlMsgLoop) {
if (params.syncDeallocation) {
bool done = false;
ReentrantMonitor barrier("DeallocateTextureClient");
ReentrantMonitorAutoEnter autoMon(barrier);
- ipdlMsgLoop->PostTask(NewRunnableFunction(DeallocateTextureClientSyncProxy,
+ ipdlMsgLoop->PostTask(NewRunnableFunction("DeallocateTextureClientSyncProxyRunnable",
+ DeallocateTextureClientSyncProxy,
params, &barrier, &done));
while (!done) {
barrier.Wait();
}
} else {
- ipdlMsgLoop->PostTask(NewRunnableFunction(DeallocateTextureClient,
+ ipdlMsgLoop->PostTask(NewRunnableFunction("DeallocateTextureClientRunnable",
+ DeallocateTextureClient,
params));
}
// The work has been forwarded to the IPDL thread, we are done.
return;
}
// Below this line, we are either in the IPDL thread or ther is no IPDL
// thread anymore.
@@ -835,17 +837,18 @@ void CancelTextureClientRecycle(uint64_t
MessageLoop* msgLoop = nullptr;
msgLoop = aAllocator->GetMessageLoop();
if (!msgLoop) {
return;
}
if (MessageLoop::current() == msgLoop) {
aAllocator->CancelWaitForRecycle(aTextureId);
} else {
- msgLoop->PostTask(NewRunnableFunction(CancelTextureClientRecycle,
+ msgLoop->PostTask(NewRunnableFunction("CancelTextureClientRecycleRunnable",
+ CancelTextureClientRecycle,
aTextureId, aAllocator));
}
}
void
TextureClient::CancelWaitForRecycle()
{
if (GetFlags() & TextureFlags::RECYCLE) {
--- a/gfx/layers/ipc/CompositorBridgeChild.cpp
+++ b/gfx/layers/ipc/CompositorBridgeChild.cpp
@@ -490,17 +490,18 @@ CompositorBridgeChild::RecvCaptureAllPlu
{
#if defined(XP_WIN)
MOZ_ASSERT(NS_IsMainThread());
nsIWidget::CaptureRegisteredPlugins(aParentWidget);
// Bounce the call to SendAllPluginsCaptured off the ImageBridgeChild loop,
// to make sure that the image updates on that thread have been processed.
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(
- NewRunnableFunction(&ScheduleSendAllPluginsCaptured, this,
+ NewRunnableFunction("ScheduleSendAllPluginsCapturedRunnable",
+ &ScheduleSendAllPluginsCaptured, this,
MessageLoop::current()));
return IPC_OK();
#else
MOZ_ASSERT_UNREACHABLE(
"CompositorBridgeChild::RecvCaptureAllPlugins calls unexpected.");
return IPC_FAIL_NO_REASON(this);
#endif
}
--- a/gfx/layers/ipc/CompositorBridgeParent.cpp
+++ b/gfx/layers/ipc/CompositorBridgeParent.cpp
@@ -377,20 +377,22 @@ CompositorBridgeParent::Initialize()
MOZ_ASSERT(CompositorThread(),
"The compositor thread must be Initialized before instanciating a CompositorBridgeParent.");
mCompositorBridgeID = 0;
// FIXME: This holds on the the fact that right now the only thing that
// can destroy this instance is initialized on the compositor thread after
// this task has been processed.
MOZ_ASSERT(CompositorLoop());
- CompositorLoop()->PostTask(NewRunnableFunction(&AddCompositor,
+ CompositorLoop()->PostTask(NewRunnableFunction("AddCompositorRunnable",
+ &AddCompositor,
this, &mCompositorBridgeID));
- CompositorLoop()->PostTask(NewRunnableFunction(SetThreadPriority));
+ CompositorLoop()->PostTask(NewRunnableFunction("SetThreadPriorityRunnable",
+ SetThreadPriority));
{ // scope lock
MonitorAutoLock lock(*sIndirectLayerTreesLock);
sIndirectLayerTrees[mRootLayerTreeID].mParent = this;
}
LayerScope::SetPixelScale(mScale.scale);
@@ -1783,17 +1785,18 @@ CompositorBridgeParent::DeallocateLayerT
MOZ_ASSERT(NS_IsMainThread());
// Here main thread notifies compositor to remove an element from
// sIndirectLayerTrees. This removed element might be queried soon.
// Checking the elements of sIndirectLayerTrees exist or not before using.
if (!CompositorLoop()) {
gfxCriticalError() << "Attempting to post to a invalid Compositor Loop";
return;
}
- CompositorLoop()->PostTask(NewRunnableFunction(&EraseLayerState, aId));
+ CompositorLoop()->PostTask(NewRunnableFunction("EraseLayerStateRunnable",
+ &EraseLayerState, aId));
}
static void
UpdateControllerForLayersId(uint64_t aLayersId,
GeckoContentController* aController)
{
// Adopt ref given to us by SetControllerForLayerTree()
MonitorAutoLock lock(*sIndirectLayerTreesLock);
@@ -1820,17 +1823,18 @@ ScopedLayerTreeRegistration::~ScopedLaye
}
/*static*/ void
CompositorBridgeParent::SetControllerForLayerTree(uint64_t aLayersId,
GeckoContentController* aController)
{
// This ref is adopted by UpdateControllerForLayersId().
aController->AddRef();
- CompositorLoop()->PostTask(NewRunnableFunction(&UpdateControllerForLayersId,
+ CompositorLoop()->PostTask(NewRunnableFunction("UpdateControllerForLayersIdRunnable",
+ &UpdateControllerForLayersId,
aLayersId,
aController));
}
/*static*/ already_AddRefed<APZCTreeManager>
CompositorBridgeParent::GetAPZCTreeManager(uint64_t aLayersId)
{
EnsureLayerTreeMapReady();
@@ -1860,17 +1864,18 @@ InsertVsyncProfilerMarker(TimeStamp aVsy
/*static */ void
CompositorBridgeParent::PostInsertVsyncProfilerMarker(TimeStamp aVsyncTimestamp)
{
#if defined(MOZ_GECKO_PROFILER)
// Called in the vsync thread
if (profiler_is_active() && CompositorThreadHolder::IsActive()) {
CompositorLoop()->PostTask(
- NewRunnableFunction(InsertVsyncProfilerMarker, aVsyncTimestamp));
+ NewRunnableFunction("InsertVsyncProfilerMarkerRunnable", InsertVsyncProfilerMarker,
+ aVsyncTimestamp));
}
#endif
}
widget::PCompositorWidgetParent*
CompositorBridgeParent::AllocPCompositorWidgetParent(const CompositorWidgetInitData& aInitData)
{
#if defined(MOZ_WIDGET_SUPPORTS_OOP_COMPOSITING)
--- a/gfx/vr/ipc/VRManagerChild.cpp
+++ b/gfx/vr/ipc/VRManagerChild.cpp
@@ -151,17 +151,18 @@ void
VRManagerChild::Destroy()
{
// Keep ourselves alive until everything has been shut down
RefPtr<VRManagerChild> selfRef = this;
// The DeferredDestroyVRManager task takes ownership of
// the VRManagerChild and will release it when it runs.
MessageLoop::current()->PostTask(
- NewRunnableFunction(DeferredDestroy, selfRef));
+ NewRunnableFunction("VRManagerChildDestroyRunnable",
+ DeferredDestroy, selfRef));
}
PVRLayerChild*
VRManagerChild::AllocPVRLayerChild(const uint32_t& aDisplayID,
const uint32_t& aGroup)
{
return VRLayerChild::CreateIPDLActor();
}
--- a/gfx/vr/ipc/VRManagerParent.cpp
+++ b/gfx/vr/ipc/VRManagerParent.cpp
@@ -116,17 +116,18 @@ VRManagerParent::RegisterVRManagerInVRLi
/*static*/ VRManagerParent*
VRManagerParent::CreateSameProcess()
{
MessageLoop* loop = VRListenerThreadHolder::Loop();
RefPtr<VRManagerParent> vmp = new VRManagerParent(base::GetCurrentProcId(), false);
vmp->mVRListenerThreadHolder = VRListenerThreadHolder::GetSingleton();
vmp->mSelfRef = vmp;
- loop->PostTask(NewRunnableFunction(RegisterVRManagerInVRListenerThread, vmp.get()));
+ loop->PostTask(NewRunnableFunction("RegisterVRManagerInVRListenerThreadRunnable",
+ RegisterVRManagerInVRListenerThread, vmp.get()));
return vmp.get();
}
bool
VRManagerParent::CreateForGPUProcess(Endpoint<PVRManagerParent>&& aEndpoint)
{
MessageLoop* loop = VRListenerThreadHolder::Loop();
--- a/gfx/webrender_bindings/RenderThread.cpp
+++ b/gfx/webrender_bindings/RenderThread.cpp
@@ -229,16 +229,17 @@ RenderThread::UpdateAndRender(wr::Window
// Render did not happen, do not call NotifyDidRender.
return;
}
TimeStamp end = TimeStamp::Now();
auto epochs = renderer->FlushRenderedEpochs();
layers::CompositorThreadHolder::Loop()->PostTask(NewRunnableFunction(
+ "NotifyDidRenderRunnable",
&NotifyDidRender,
renderer->GetCompositorBridge(),
epochs,
start, end
));
}
void
--- a/gfx/webrender_bindings/RendererOGL.cpp
+++ b/gfx/webrender_bindings/RendererOGL.cpp
@@ -222,16 +222,17 @@ DoNotifyWebRenderError(layers::Composito
{
aBridge->NotifyWebRenderError(aError);
}
void
RendererOGL::NotifyWebRenderError(WebRenderError aError)
{
layers::CompositorThreadHolder::Loop()->PostTask(NewRunnableFunction(
+ "DoNotifyWebRenderErrorRunnable",
&DoNotifyWebRenderError,
mBridge,
aError
));
}
} // namespace wr
} // namespace mozilla
--- a/ipc/chromium/src/base/task.h
+++ b/ipc/chromium/src/base/task.h
@@ -330,18 +330,18 @@ NewRunnableMethod(T* object, Method meth
} // namespace dont_add_new_uses_of_this
// RunnableFunction and NewRunnableFunction implementation ---------------------
template <class Function, class Params>
class RunnableFunction : public mozilla::CancelableRunnable {
public:
- RunnableFunction(Function function, Params&& params)
- : mozilla::CancelableRunnable("RunnableFunction")
+ RunnableFunction(const char* name, Function function, Params&& params)
+ : mozilla::CancelableRunnable(name)
, function_(function)
, params_(mozilla::Forward<Params>(params))
{
}
~RunnableFunction() {
}
@@ -357,27 +357,27 @@ class RunnableFunction : public mozilla:
}
Function function_;
Params params_;
};
template <class Function, typename... Args>
inline already_AddRefed<mozilla::CancelableRunnable>
-NewCancelableRunnableFunction(Function function, Args&&... args) {
+NewCancelableRunnableFunction(const char* name, Function function, Args&&... args) {
typedef mozilla::Tuple<typename mozilla::Decay<Args>::Type...> ArgsTuple;
RefPtr<mozilla::CancelableRunnable> t =
- new RunnableFunction<Function, ArgsTuple>(function,
+ new RunnableFunction<Function, ArgsTuple>(name, function,
mozilla::MakeTuple(mozilla::Forward<Args>(args)...));
return t.forget();
}
template <class Function, typename... Args>
inline already_AddRefed<mozilla::Runnable>
-NewRunnableFunction(Function function, Args&&... args) {
+NewRunnableFunction(const char* name, Function function, Args&&... args) {
typedef mozilla::Tuple<typename mozilla::Decay<Args>::Type...> ArgsTuple;
RefPtr<mozilla::Runnable> t =
- new RunnableFunction<Function, ArgsTuple>(function,
+ new RunnableFunction<Function, ArgsTuple>(name, function,
mozilla::MakeTuple(mozilla::Forward<Args>(args)...));
return t.forget();
}
#endif // BASE_TASK_H_
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -429,16 +429,17 @@ public:
};
NativePanZoomController::GlobalRef npzc = mNPZC;
RefPtr<nsThread> uiThread = GetAndroidUiThread();
if (!uiThread) {
return;
}
uiThread->Dispatch(NewRunnableFunction(
+ "OnDetachRunnable",
static_cast<void(*)(const NPZCRef&)>(callDestroy),
mozilla::Move(npzc)), nsIThread::DISPATCH_NORMAL);
}
const NativePanZoomController::Ref& GetJavaNPZC() const
{
return mNPZC;
}