Bug 1363560 - Name more runnables (r=mccr8)
authorBill McCloskey <billm@mozilla.com>
Tue, 09 May 2017 16:19:37 -0700
changeset 357476 372920baafa4800664cb9c3d64a66070c5b9f84e
parent 357475 d289923632be8940a76be9b195d1796d85c5e463
child 357477 92676fadb9e2f129418e58d75b1dc38760b7110c
push id31792
push usercbook@mozilla.com
push dateWed, 10 May 2017 13:07:59 +0000
treeherdermozilla-central@ebbcdaa5b580 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1363560
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1363560 - Name more runnables (r=mccr8) MozReview-Commit-ID: 3hxZDA4JlTV
dom/base/ImageEncoder.cpp
dom/base/nsGlobalWindow.cpp
dom/base/nsObjectLoadingContent.cpp
dom/crypto/WebCryptoTask.cpp
dom/html/HTMLMediaElement.cpp
dom/jsurl/nsJSProtocolHandler.cpp
dom/media/MediaStreamGraph.cpp
dom/media/webaudio/AudioContext.cpp
dom/workers/ScriptLoader.cpp
dom/workers/ServiceWorkerJob.cpp
extensions/spellcheck/src/mozInlineSpellChecker.cpp
image/VectorImage.cpp
image/imgRequest.cpp
ipc/glue/BackgroundImpl.cpp
layout/base/nsRefreshDriver.cpp
netwerk/base/Predictor.cpp
netwerk/base/nsAsyncRedirectVerifyHelper.cpp
netwerk/base/nsAsyncRedirectVerifyHelper.h
parser/html/nsHtml5RefPtr.h
parser/html/nsHtml5StreamParser.cpp
toolkit/components/telemetry/ipc/TelemetryIPCAccumulator.cpp
xpcom/threads/nsThreadSyncDispatch.h
--- a/dom/base/ImageEncoder.cpp
+++ b/dom/base/ImageEncoder.cpp
@@ -24,17 +24,20 @@ using namespace mozilla::gfx;
 namespace mozilla {
 namespace dom {
 
 // This class should be placed inside GetBRGADataSourceSurfaceSync(). However,
 // due to B2G ICS uses old complier (C++98/03) which forbids local class as
 // template parameter, we need to move this class outside.
 class SurfaceHelper : public Runnable {
 public:
-  explicit SurfaceHelper(already_AddRefed<layers::Image> aImage) : mImage(aImage) {}
+  explicit SurfaceHelper(already_AddRefed<layers::Image> aImage)
+    : Runnable("SurfaceHelper")
+    , mImage(aImage)
+  {}
 
   // It retrieves a SourceSurface reference and convert color format on main
   // thread and passes DataSourceSurface to caller thread.
   NS_IMETHOD Run() override {
     // It guarantees the reference will be released on main thread.
     nsCountedRef<nsMainThreadSourceSurfaceRef> surface;
     surface.own(mImage->GetAsSourceSurface().take());
 
@@ -74,17 +77,18 @@ GetBRGADataSourceSurfaceSync(already_Add
 }
 
 class EncodingCompleteEvent : public CancelableRunnable
 {
   virtual ~EncodingCompleteEvent() {}
 
 public:
   explicit EncodingCompleteEvent(EncodeCompleteCallback* aEncodeCompleteCallback)
-    : mImgSize(0)
+    : CancelableRunnable("EncodingCompleteEvent")
+    , mImgSize(0)
     , mType()
     , mImgData(nullptr)
     , mEncodeCompleteCallback(aEncodeCompleteCallback)
     , mFailed(false)
   {
     if (!NS_IsMainThread() && workers::GetCurrentThreadWorkerPrivate()) {
       mCreationThread = NS_GetCurrentThread();
     } else {
@@ -147,17 +151,18 @@ public:
                    const nsAString& aOptions,
                    UniquePtr<uint8_t[]> aImageBuffer,
                    layers::Image* aImage,
                    imgIEncoder* aEncoder,
                    EncodingCompleteEvent* aEncodingCompleteEvent,
                    int32_t aFormat,
                    const nsIntSize aSize,
                    bool aUsingCustomOptions)
-    : mType(aType)
+    : Runnable("EncodingRunnable")
+    , mType(aType)
     , mOptions(aOptions)
     , mImageBuffer(Move(aImageBuffer))
     , mImage(aImage)
     , mEncoder(aEncoder)
     , mEncodingCompleteEvent(aEncodingCompleteEvent)
     , mFormat(aFormat)
     , mSize(aSize)
     , mUsingCustomOptions(aUsingCustomOptions)
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -556,16 +556,17 @@ NS_IMPL_ADDREF_INHERITED(IdleRequestExec
 NS_IMPL_RELEASE_INHERITED(IdleRequestExecutorTimeoutHandler, TimeoutHandler)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(IdleRequestExecutorTimeoutHandler)
 NS_INTERFACE_MAP_END_INHERITING(TimeoutHandler)
 
 
 class IdleRequestExecutor final : public nsIRunnable
                                 , public nsICancelableRunnable
+                                , public nsINamed
                                 , public nsIIncrementalRunnable
 {
 public:
   explicit IdleRequestExecutor(nsGlobalWindow* aWindow)
     : mDispatched(false)
     , mDeadline(TimeStamp::Now())
     , mWindow(aWindow)
   {
@@ -575,16 +576,17 @@ public:
     mIdlePeriodLimit = { mDeadline, mWindow->LastIdleRequestHandle() };
     mDelayedExecutorDispatcher = new IdleRequestExecutorTimeoutHandler(this);
   }
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(IdleRequestExecutor, nsIRunnable)
 
   NS_DECL_NSIRUNNABLE
+  NS_DECL_NSINAMED
   nsresult Cancel() override;
   void SetDeadline(TimeStamp aDeadline) override;
 
   bool IsCancelled() const { return !mWindow || mWindow->AsInner()->InnerObjectsFreed(); }
   // Checks if aRequest shouldn't execute in the current idle period
   // since it has been queued from a chained call to
   // requestIdleCallback from within a running idle callback.
   bool IneligibleForCurrentIdlePeriod(IdleRequest* aRequest) const
@@ -641,21 +643,35 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(IdleRequestExecutor)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindow)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDelayedExecutorDispatcher)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(IdleRequestExecutor)
   NS_INTERFACE_MAP_ENTRY(nsIRunnable)
   NS_INTERFACE_MAP_ENTRY(nsICancelableRunnable)
+  NS_INTERFACE_MAP_ENTRY(nsINamed)
   NS_INTERFACE_MAP_ENTRY(nsIIncrementalRunnable)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIRunnable)
 NS_INTERFACE_MAP_END
 
 NS_IMETHODIMP
+IdleRequestExecutor::GetName(nsACString& aName)
+{
+    aName.AssignASCII("IdleRequestExecutor");
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+IdleRequestExecutor::SetName(const char* aName)
+{
+  return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
 IdleRequestExecutor::Run()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   mDispatched = false;
   if (mWindow) {
     return mWindow->ExecuteIdleRequest(mDeadline);
   }
--- a/dom/base/nsObjectLoadingContent.cpp
+++ b/dom/base/nsObjectLoadingContent.cpp
@@ -146,17 +146,17 @@ InActiveDocument(nsIContent *aContent)
 
 ///
 /// Runnables and helper classes
 ///
 
 class nsAsyncInstantiateEvent : public Runnable {
 public:
   explicit nsAsyncInstantiateEvent(nsObjectLoadingContent* aContent)
-  : mContent(aContent) {}
+    : Runnable("nsAsyncInstantiateEvent"), mContent(aContent) {}
 
   ~nsAsyncInstantiateEvent() override = default;
 
   NS_IMETHOD Run() override;
 
 private:
   nsCOMPtr<nsIObjectLoadingContent> mContent;
 };
@@ -255,17 +255,18 @@ CheckPluginStopEvent::Run()
 }
 
 /**
  * Helper task for firing simple events
  */
 class nsSimplePluginEvent : public Runnable {
 public:
   nsSimplePluginEvent(nsIContent* aTarget, const nsAString &aEvent)
-    : mTarget(aTarget)
+    : Runnable("nsSimplePluginEvent")
+    , mTarget(aTarget)
     , mDocument(aTarget->GetComposedDoc())
     , mEvent(aEvent)
   {
     MOZ_ASSERT(aTarget && mDocument);
   }
 
   nsSimplePluginEvent(nsIDocument* aTarget, const nsAString& aEvent)
     : mTarget(aTarget)
@@ -320,17 +321,18 @@ public:
   bool mSubmittedCrashReport;
 
   nsPluginCrashedEvent(nsIContent* aContent,
                        const nsAString& aPluginDumpID,
                        const nsAString& aBrowserDumpID,
                        const nsAString& aPluginName,
                        const nsAString& aPluginFilename,
                        bool submittedCrashReport)
-    : mContent(aContent),
+    : Runnable("nsPluginCrashedEvent"),
+      mContent(aContent),
       mPluginDumpID(aPluginDumpID),
       mBrowserDumpID(aBrowserDumpID),
       mPluginName(aPluginName),
       mPluginFilename(aPluginFilename),
       mSubmittedCrashReport(submittedCrashReport)
   {}
 
   ~nsPluginCrashedEvent() override = default;
--- a/dom/crypto/WebCryptoTask.cpp
+++ b/dom/crypto/WebCryptoTask.cpp
@@ -3721,17 +3721,18 @@ WebCryptoTask::CreateUnwrapKeyTask(nsIGl
                                       aUnwrappingKey, aUnwrapAlgorithm,
                                       importTask);
   }
 
   return new FailureTask(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
 }
 
 WebCryptoTask::WebCryptoTask()
-  : mEarlyRv(NS_OK)
+  : CancelableRunnable("WebCryptoTask")
+  , mEarlyRv(NS_OK)
   , mEarlyComplete(false)
   , mOriginalThread(nullptr)
   , mReleasedNSSResources(false)
   , mRv(NS_ERROR_NOT_INITIALIZED)
 {
 }
 
 WebCryptoTask::~WebCryptoTask()
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -1205,16 +1205,17 @@ public:
     nsContentUtils::RegisterShutdownObserver(loadListener);
   }
 
   nsresult Load(HTMLMediaElement* aElement)
   {
     // Per bug 1235183 comment 8, we can't spin the event loop from stable
     // state. Defer NS_NewChannel() to a new regular runnable.
     return NS_DispatchToMainThread(NewRunnableMethod<HTMLMediaElement*>(
+      "ChannelLoader::LoadInternal",
       this, &ChannelLoader::LoadInternal, aElement));
   }
 
   void Cancel()
   {
     mCancelled = true;
     if (mChannel) {
       mChannel->Cancel(NS_BINDING_ABORTED);
@@ -1814,28 +1815,30 @@ void HTMLMediaElement::RunInStableState(
 void HTMLMediaElement::QueueLoadFromSourceTask()
 {
   if (!mIsLoadingFromSourceChildren || mShuttingDown) {
     return;
   }
 
   ChangeDelayLoadStatus(true);
   ChangeNetworkState(nsIDOMHTMLMediaElement::NETWORK_LOADING);
-  RefPtr<Runnable> r = NewRunnableMethod(this, &HTMLMediaElement::LoadFromSourceChildren);
+  RefPtr<Runnable> r = NewRunnableMethod("HTMLMediaElement::LoadFromSourceChildren",
+                                         this, &HTMLMediaElement::LoadFromSourceChildren);
   RunInStableState(r);
 }
 
 void HTMLMediaElement::QueueSelectResourceTask()
 {
   // Don't allow multiple async select resource calls to be queued.
   if (mHaveQueuedSelectResource)
     return;
   mHaveQueuedSelectResource = true;
   ChangeNetworkState(nsIDOMHTMLMediaElement::NETWORK_NO_SOURCE);
-  RefPtr<Runnable> r = NewRunnableMethod(this, &HTMLMediaElement::SelectResourceWrapper);
+  RefPtr<Runnable> r = NewRunnableMethod("HTMLMediaElement::SelectResourceWrapper",
+                                         this, &HTMLMediaElement::SelectResourceWrapper);
   RunInStableState(r);
 }
 
 static bool HasSourceChildren(nsIContent* aElement)
 {
   for (nsIContent* child = aElement->GetFirstChild();
        child;
        child = child->GetNextSibling()) {
@@ -1961,17 +1964,18 @@ void HTMLMediaElement::SelectResource()
     } else {
       const char16_t* params[] = { src.get() };
       ReportLoadError("MediaLoadInvalidURI", params, ArrayLength(params));
     }
     // The media element has neither a src attribute nor a source element child:
     // set the networkState to NETWORK_EMPTY, and abort these steps; the
     // synchronous section ends.
     nsCOMPtr<nsIRunnable> event =
-        NewRunnableMethod<nsCString>(this, &HTMLMediaElement::NoSupportedMediaSourceError, nsCString());
+      NewRunnableMethod<nsCString>("HTMLMediaElement::NoSupportedMediaSourceError",
+                                   this, &HTMLMediaElement::NoSupportedMediaSourceError, nsCString());
     NS_DispatchToMainThread(event);
   } else {
     // Otherwise, the source elements will be used.
     mIsLoadingFromSourceChildren = true;
     LoadFromSourceChildren();
   }
 }
 
@@ -2120,17 +2124,18 @@ void HTMLMediaElement::NotifyMediaTrackD
         // for instance if the MediaInputPort was destroyed in the same
         // iteration as it was added.
         MediaStreamTrack* outputTrack = ms.mStream->FindOwnedDOMTrack(
             ms.mTrackPorts[i].second()->GetDestination(),
             ms.mTrackPorts[i].second()->GetDestinationTrackId());
         MOZ_ASSERT(outputTrack);
         if (outputTrack) {
           NS_DispatchToMainThread(
-            NewRunnableMethod(outputTrack, &MediaStreamTrack::OverrideEnded));
+            NewRunnableMethod("MediaStreamTrack::OverrideEnded",
+                              outputTrack, &MediaStreamTrack::OverrideEnded));
         }
 
         ms.mTrackPorts[i].second()->Destroy();
         ms.mTrackPorts.RemoveElementAt(i);
         break;
       }
     }
 #ifdef DEBUG
@@ -2166,17 +2171,18 @@ void HTMLMediaElement::NotifyMediaStream
 void HTMLMediaElement::DealWithFailedElement(nsIContent* aSourceElement)
 {
   if (mShuttingDown) {
     return;
   }
 
   DispatchAsyncSourceError(aSourceElement);
   nsCOMPtr<nsIRunnable> event =
-    NewRunnableMethod(this, &HTMLMediaElement::QueueLoadFromSourceTask);
+    NewRunnableMethod("HTMLMediaElement::QueueLoadFromSourceTask",
+                      this, &HTMLMediaElement::QueueLoadFromSourceTask);
   NS_DispatchToMainThread(event);
 }
 
 void
 HTMLMediaElement::NotifyOutputTrackStopped(DOMMediaStream* aOwningStream,
                                            TrackID aDestinationTrackID)
 {
   for (OutputMediaStream& ms : mOutputStreams) {
@@ -3284,16 +3290,17 @@ HTMLMediaElement::AddCaptureMediaTrackTo
                           : MediaSegment::VIDEO;
 
   RefPtr<MediaStreamTrack> track =
     aOutputStream.mStream->CreateDOMTrack(destinationTrackID, type, source);
 
   if (aAsyncAddtrack) {
     NS_DispatchToMainThread(
       NewRunnableMethod<StoreRefPtrPassByPtr<MediaStreamTrack>>(
+        "DOMMediaStream::AddTrackInternal",
         aOutputStream.mStream, &DOMMediaStream::AddTrackInternal, track));
   } else {
     aOutputStream.mStream->AddTrackInternal(track);
   }
 
   // Track is muted initially, so we don't leak data if it's added while paused
   // and an MSG iteration passes before the mute comes into effect.
   processedOutputSource->SetTrackEnabled(destinationTrackID,
--- a/dom/jsurl/nsJSProtocolHandler.cpp
+++ b/dom/jsurl/nsJSProtocolHandler.cpp
@@ -625,19 +625,21 @@ nsJSChannel::AsyncOpen(nsIStreamListener
     if (mDocumentOnloadBlockedOn) {
         mDocumentOnloadBlockedOn->BlockOnload();
     }
 
 
     mPopupState = win->GetPopupControlState();
 
     void (nsJSChannel::*method)();
+    const char* name;
     if (mIsAsync) {
         // post an event to do the rest
         method = &nsJSChannel::EvaluateScript;
+        name = "nsJSChannel::EvaluateScript";
     } else {
         EvaluateScript();
         if (mOpenedStreamChannel) {
             // That will handle notifying things
             return NS_OK;
         }
 
         NS_ASSERTION(NS_FAILED(mStatus), "We should have failed _somehow_");
@@ -652,20 +654,21 @@ nsJSChannel::AsyncOpen(nsIStreamListener
             // loadgroup and marking us as not active anymore.
             CleanupStrongRefs();
             return mStatus;
         }
 
         // We're returning success from asyncOpen2(), but we didn't open a
         // stream channel.  We'll have to notify ourselves, but make sure to do
         // it asynchronously.
-        method = &nsJSChannel::NotifyListener;            
+        method = &nsJSChannel::NotifyListener;
+        name = "nsJSChannel::NotifyListener";
     }
 
-    nsresult rv = NS_DispatchToCurrentThread(mozilla::NewRunnableMethod(this, method));
+    nsresult rv = NS_DispatchToCurrentThread(mozilla::NewRunnableMethod(name, this, method));
 
     if (NS_FAILED(rv)) {
         loadGroup->RemoveRequest(this, nullptr, rv);
         mIsActive = false;
         CleanupStrongRefs();
     }
     return rv;
 }
--- a/dom/media/MediaStreamGraph.cpp
+++ b/dom/media/MediaStreamGraph.cpp
@@ -1550,17 +1550,18 @@ MediaStreamGraphImpl::Notify(nsITimer* a
 
 /* static */ StaticRefPtr<nsIAsyncShutdownBlocker> gMediaStreamGraphShutdownBlocker;
 
 namespace {
 
 class MediaStreamGraphShutDownRunnable : public Runnable {
 public:
   explicit MediaStreamGraphShutDownRunnable(MediaStreamGraphImpl* aGraph)
-    : mGraph(aGraph)
+    : Runnable("MediaStreamGraphShutDownRunnable")
+    , mGraph(aGraph)
   {}
   NS_IMETHOD Run()
   {
     NS_ASSERTION(mGraph->mDetectedNotRunning,
                  "We should know the graph thread control loop isn't running!");
 
     LOG(LogLevel::Debug, ("Shutting down graph %p", mGraph.get()));
 
@@ -2671,17 +2672,18 @@ MediaStream::AddMainThreadListener(MainT
   if (!mFinishedNotificationSent) {
     return;
   }
 
   class NotifyRunnable final : public Runnable
   {
   public:
     explicit NotifyRunnable(MediaStream* aStream)
-      : mStream(aStream)
+      : Runnable("MediaStream::NotifyRunnable")
+      , mStream(aStream)
     {}
 
     NS_IMETHOD Run() override
     {
       MOZ_ASSERT(NS_IsMainThread());
       mStream->NotifyMainThreadListeners();
       return NS_OK;
     }
@@ -3754,18 +3756,19 @@ MediaStreamGraph::AddStream(MediaStream*
   aStream->SetGraphImpl(graph);
   graph->AppendMessage(MakeUnique<CreateMessage>(aStream));
 }
 
 class GraphStartedRunnable final : public Runnable
 {
 public:
   GraphStartedRunnable(AudioNodeStream* aStream, MediaStreamGraph* aGraph)
-  : mStream(aStream)
-  , mGraph(aGraph)
+    : Runnable("GraphStartedRunnable")
+    , mStream(aStream)
+    , mGraph(aGraph)
   { }
 
   NS_IMETHOD Run() override {
     mGraph->NotifyWhenGraphStarted(mStream);
     return NS_OK;
   }
 
 private:
--- a/dom/media/webaudio/AudioContext.cpp
+++ b/dom/media/webaudio/AudioContext.cpp
@@ -671,29 +671,31 @@ AudioContext::Shutdown()
   if (mIsOffline && mDestination) {
     mDestination->OfflineShutdown();
   }
 }
 
 StateChangeTask::StateChangeTask(AudioContext* aAudioContext,
                                  void* aPromise,
                                  AudioContextState aNewState)
-  : mAudioContext(aAudioContext)
+  : Runnable("dom::StateChangeTask")
+  , mAudioContext(aAudioContext)
   , mPromise(aPromise)
   , mAudioNodeStream(nullptr)
   , mNewState(aNewState)
 {
   MOZ_ASSERT(NS_IsMainThread(),
              "This constructor should be used from the main thread.");
 }
 
 StateChangeTask::StateChangeTask(AudioNodeStream* aStream,
                                  void* aPromise,
                                  AudioContextState aNewState)
-  : mAudioContext(nullptr)
+  : Runnable("dom::StateChangeTask")
+  , mAudioContext(nullptr)
   , mPromise(aPromise)
   , mAudioNodeStream(aStream)
   , mNewState(aNewState)
 {
   MOZ_ASSERT(!NS_IsMainThread(),
              "This constructor should be used from the graph thread.");
 }
 
@@ -724,17 +726,18 @@ StateChangeTask::Run()
   return NS_OK;
 }
 
 /* This runnable allows to fire the "statechange" event */
 class OnStateChangeTask final : public Runnable
 {
 public:
   explicit OnStateChangeTask(AudioContext* aAudioContext)
-    : mAudioContext(aAudioContext)
+    : Runnable("dom::OnStateChangeTask")
+    , mAudioContext(aAudioContext)
   {}
 
   NS_IMETHODIMP
   Run() override
   {
     nsPIDOMWindowInner* parent = mAudioContext->GetParentObject();
     if (!parent) {
       return NS_ERROR_FAILURE;
--- a/dom/workers/ScriptLoader.cpp
+++ b/dom/workers/ScriptLoader.cpp
@@ -551,17 +551,18 @@ private:
   RefPtr<ScriptLoaderRunnable> mRunnable;
   uint32_t mIndex;
 };
 
 NS_IMPL_ISUPPORTS(LoaderListener, nsIStreamLoaderObserver, nsIRequestObserver)
 
 class ScriptLoaderHolder;
 
-class ScriptLoaderRunnable final : public nsIRunnable
+class ScriptLoaderRunnable final : public nsIRunnable,
+                                   public nsINamed
 {
   friend class ScriptExecutorRunnable;
   friend class ScriptLoaderHolder;
   friend class CachePromiseHandler;
   friend class CacheScriptLoader;
   friend class LoaderListener;
 
   WorkerPrivate* mWorkerPrivate;
@@ -606,16 +607,29 @@ private:
     nsresult rv = RunInternal();
     if (NS_WARN_IF(NS_FAILED(rv))) {
       CancelMainThread(rv);
     }
 
     return NS_OK;
   }
 
+  NS_IMETHOD
+  GetName(nsACString& aName) override
+  {
+    aName.AssignASCII("ScriptLoaderRunnable");
+    return NS_OK;
+  }
+
+  NS_IMETHOD
+  SetName(const char* aName) override
+  {
+    return NS_ERROR_NOT_IMPLEMENTED;
+  }
+
   void
   LoadingFinished(uint32_t aIndex, nsresult aRv)
   {
     AssertIsOnMainThread();
     MOZ_ASSERT(aIndex < mLoadInfos.Length());
     ScriptLoadInfo& loadInfo = mLoadInfos[aIndex];
 
     loadInfo.mLoadResult = aRv;
@@ -1329,17 +1343,17 @@ private:
                                    firstIndex, lastIndex);
       if (!runnable->Dispatch()) {
         MOZ_ASSERT(false, "This should never fail!");
       }
     }
   }
 };
 
-NS_IMPL_ISUPPORTS(ScriptLoaderRunnable, nsIRunnable)
+NS_IMPL_ISUPPORTS(ScriptLoaderRunnable, nsIRunnable, nsINamed)
 
 class MOZ_STACK_CLASS ScriptLoaderHolder final : public WorkerHolder
 {
   // Raw pointer because this holder object follows the mRunnable life-time.
   ScriptLoaderRunnable* mRunnable;
 
 public:
   explicit ScriptLoaderHolder(ScriptLoaderRunnable* aRunnable)
--- a/dom/workers/ServiceWorkerJob.cpp
+++ b/dom/workers/ServiceWorkerJob.cpp
@@ -90,17 +90,18 @@ ServiceWorkerJob::Start(Callback* aFinal
   MOZ_DIAGNOSTIC_ASSERT(!mFinalCallback);
   MOZ_ASSERT(!mResultCallbackList.Contains(aFinalCallback));
   mFinalCallback = aFinalCallback;
 
   MOZ_DIAGNOSTIC_ASSERT(mState == State::Initial);
   mState = State::Started;
 
   nsCOMPtr<nsIRunnable> runnable =
-    NewRunnableMethod(this, &ServiceWorkerJob::AsyncExecute);
+    NewRunnableMethod("ServiceWorkerJob::AsyncExecute",
+                      this, &ServiceWorkerJob::AsyncExecute);
 
   // We may have to wait for the PBackground actor to be initialized
   // before proceeding.  We should always be able to get a ServiceWorkerManager,
   // however, since Start() should not be called during shutdown.
   RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
   if (!swm) {
     // browser shutdown
     return;
--- a/extensions/spellcheck/src/mozInlineSpellChecker.cpp
+++ b/extensions/spellcheck/src/mozInlineSpellChecker.cpp
@@ -468,17 +468,18 @@ mozInlineSpellStatus::PositionToCollapse
 
 // mozInlineSpellResume
 
 class mozInlineSpellResume : public Runnable
 {
 public:
   mozInlineSpellResume(UniquePtr<mozInlineSpellStatus>&& aStatus,
                        uint32_t aDisabledAsyncToken)
-    : mDisabledAsyncToken(aDisabledAsyncToken)
+    : Runnable("mozInlineSpellResume")
+    , mDisabledAsyncToken(aDisabledAsyncToken)
     , mStatus(Move(aStatus))
   {
   }
 
   nsresult Post()
   {
     return NS_DispatchToMainThread(this);
   }
--- a/image/VectorImage.cpp
+++ b/image/VectorImage.cpp
@@ -1123,17 +1123,18 @@ VectorImage::RequestDiscard()
   return NS_OK;
 }
 
 void
 VectorImage::OnSurfaceDiscarded(const SurfaceKey& aSurfaceKey)
 {
   MOZ_ASSERT(mProgressTracker);
 
-  NS_DispatchToMainThread(NewRunnableMethod(mProgressTracker, &ProgressTracker::OnDiscard));
+  NS_DispatchToMainThread(NewRunnableMethod("ProgressTracker::OnDiscard",
+                                            mProgressTracker, &ProgressTracker::OnDiscard));
 }
 
 //******************************************************************************
 NS_IMETHODIMP
 VectorImage::ResetAnimation()
 {
   if (mError) {
     return NS_ERROR_FAILURE;
--- a/image/imgRequest.cpp
+++ b/image/imgRequest.cpp
@@ -312,17 +312,18 @@ imgRequest::CancelAndAbort(nsresult aSta
     mPrevChannelSink = nullptr;
   }
 }
 
 class imgRequestMainThreadCancel : public Runnable
 {
 public:
   imgRequestMainThreadCancel(imgRequest* aImgRequest, nsresult aStatus)
-    : mImgRequest(aImgRequest)
+    : Runnable("imgRequestMainThreadCancel")
+    , mImgRequest(aImgRequest)
     , mStatus(aStatus)
   {
     MOZ_ASSERT(!NS_IsMainThread(), "Create me off main thread only!");
     MOZ_ASSERT(aImgRequest);
   }
 
   NS_IMETHOD Run() override
   {
@@ -362,17 +363,18 @@ imgRequest::ContinueCancel(nsresult aSta
      mRequest->Cancel(aStatus);
   }
 }
 
 class imgRequestMainThreadEvict : public Runnable
 {
 public:
   explicit imgRequestMainThreadEvict(imgRequest* aImgRequest)
-    : mImgRequest(aImgRequest)
+    : Runnable("imgRequestMainThreadEvict")
+    , mImgRequest(aImgRequest)
   {
     MOZ_ASSERT(!NS_IsMainThread(), "Create me off main thread only!");
     MOZ_ASSERT(aImgRequest);
   }
 
   NS_IMETHOD Run() override
   {
     MOZ_ASSERT(NS_IsMainThread(), "I should be running on the main thread!");
@@ -1048,17 +1050,18 @@ PrepareForNewPart(nsIRequest* aRequest, 
   return result;
 }
 
 class FinishPreparingForNewPartRunnable final : public Runnable
 {
 public:
   FinishPreparingForNewPartRunnable(imgRequest* aImgRequest,
                                     NewPartResult&& aResult)
-    : mImgRequest(aImgRequest)
+    : Runnable("FinishPreparingForNewPartRunnable")
+    , mImgRequest(aImgRequest)
     , mResult(aResult)
   {
     MOZ_ASSERT(aImgRequest);
   }
 
   NS_IMETHOD Run() override
   {
     mImgRequest->FinishPreparingForNewPart(mResult);
--- a/ipc/glue/BackgroundImpl.cpp
+++ b/ipc/glue/BackgroundImpl.cpp
@@ -487,17 +487,19 @@ private:
 
 class ParentImpl::RequestMessageLoopRunnable final : public Runnable
 {
   nsCOMPtr<nsIThread> mTargetThread;
   MessageLoop* mMessageLoop;
 
 public:
   explicit RequestMessageLoopRunnable(nsIThread* aTargetThread)
-  : mTargetThread(aTargetThread), mMessageLoop(nullptr)
+    : Runnable("Background::ParentImpl::RequestMessageLoopRunnable")
+    , mTargetThread(aTargetThread)
+    , mMessageLoop(nullptr)
   {
     AssertIsInMainProcess();
     AssertIsOnMainThread();
     MOZ_ASSERT(aTargetThread);
   }
 
 private:
   ~RequestMessageLoopRunnable()
@@ -505,16 +507,17 @@ private:
 
   NS_DECL_NSIRUNNABLE
 };
 
 class ParentImpl::ShutdownBackgroundThreadRunnable final : public Runnable
 {
 public:
   ShutdownBackgroundThreadRunnable()
+    : Runnable("Background::ParentImpl::ShutdownBackgroundThreadRunnable")
   {
     AssertIsInMainProcess();
     AssertIsOnMainThread();
   }
 
 private:
   ~ShutdownBackgroundThreadRunnable()
   { }
@@ -523,17 +526,18 @@ private:
 };
 
 class ParentImpl::ForceCloseBackgroundActorsRunnable final : public Runnable
 {
   nsTArray<ParentImpl*>* mActorArray;
 
 public:
   explicit ForceCloseBackgroundActorsRunnable(nsTArray<ParentImpl*>* aActorArray)
-  : mActorArray(aActorArray)
+    : Runnable("Background::ParentImpl::ForceCloseBackgroundActorsRunnable")
+    , mActorArray(aActorArray)
   {
     AssertIsInMainProcess();
     AssertIsOnMainThread();
     MOZ_ASSERT(aActorArray);
   }
 
 private:
   ~ForceCloseBackgroundActorsRunnable()
@@ -543,17 +547,18 @@ private:
 };
 
 class ParentImpl::CreateCallbackRunnable final : public Runnable
 {
   RefPtr<CreateCallback> mCallback;
 
 public:
   explicit CreateCallbackRunnable(CreateCallback* aCallback)
-  : mCallback(aCallback)
+    : Runnable("Background::ParentImpl::CreateCallbackRunnable")
+    , mCallback(aCallback)
   {
     AssertIsInMainProcess();
     AssertIsOnMainThread();
     MOZ_ASSERT(aCallback);
   }
 
 private:
   ~CreateCallbackRunnable()
@@ -567,18 +572,20 @@ class ParentImpl::ConnectActorRunnable f
   RefPtr<ParentImpl> mActor;
   Endpoint<PBackgroundParent> mEndpoint;
   nsTArray<ParentImpl*>* mLiveActorArray;
 
 public:
   ConnectActorRunnable(ParentImpl* aActor,
                        Endpoint<PBackgroundParent>&& aEndpoint,
                        nsTArray<ParentImpl*>* aLiveActorArray)
-  : mActor(aActor), mEndpoint(Move(aEndpoint)),
-    mLiveActorArray(aLiveActorArray)
+    : Runnable("Background::ParentImpl::ConnectActorRunnable")
+    , mActor(aActor)
+    , mEndpoint(Move(aEndpoint))
+    , mLiveActorArray(aLiveActorArray)
   {
     AssertIsInMainProcess();
     AssertIsOnMainThread();
     MOZ_ASSERT(mEndpoint.IsValid());
     MOZ_ASSERT(aLiveActorArray);
   }
 
 private:
@@ -629,17 +636,18 @@ private:
 };
 
 class ChildImpl::CreateActorRunnable final : public Runnable
 {
   nsCOMPtr<nsIEventTarget> mEventTarget;
 
 public:
   CreateActorRunnable()
-  : mEventTarget(NS_GetCurrentThread())
+    : Runnable("Background::ChildImpl::CreateActorRunnable")
+    , mEventTarget(NS_GetCurrentThread())
   {
     MOZ_ASSERT(mEventTarget);
   }
 
 private:
   ~CreateActorRunnable()
   { }
 
@@ -673,32 +681,34 @@ private:
 };
 
 // Must be cancelable in order to dispatch on active worker threads
 class ChildImpl::AlreadyCreatedCallbackRunnable final :
   public CancelableRunnable
 {
 public:
   AlreadyCreatedCallbackRunnable()
+    : CancelableRunnable("Background::ChildImpl::AlreadyCreatedCallbackRunnable")
   {
     // May be created on any thread!
   }
 
 protected:
   virtual ~AlreadyCreatedCallbackRunnable()
   { }
 
   NS_DECL_NSIRUNNABLE
   nsresult Cancel() override;
 };
 
 class ChildImpl::FailedCreateCallbackRunnable final : public Runnable
 {
 public:
   FailedCreateCallbackRunnable()
+    : Runnable("Background::ChildImpl::FailedCreateCallbackRunnable")
   {
     // May be created on any thread!
   }
 
 protected:
   virtual ~FailedCreateCallbackRunnable()
   { }
 
@@ -708,17 +718,19 @@ protected:
 class ChildImpl::OpenChildProcessActorRunnable final : public Runnable
 {
   RefPtr<ChildImpl> mActor;
   Endpoint<PBackgroundChild> mEndpoint;
 
 public:
   OpenChildProcessActorRunnable(already_AddRefed<ChildImpl>&& aActor,
                                 Endpoint<PBackgroundChild>&& aEndpoint)
-  : mActor(aActor), mEndpoint(Move(aEndpoint))
+    : Runnable("Background::ChildImpl::OpenChildProcessActorRunnable")
+    , mActor(aActor)
+    , mEndpoint(Move(aEndpoint))
   {
     AssertIsOnMainThread();
     MOZ_ASSERT(mActor);
     MOZ_ASSERT(mEndpoint.IsValid());
   }
 
 private:
   ~OpenChildProcessActorRunnable()
--- a/layout/base/nsRefreshDriver.cpp
+++ b/layout/base/nsRefreshDriver.cpp
@@ -551,16 +551,17 @@ private:
         mRecentVsync = aVsyncTimestamp;
         if (!mBlockUntil.IsNull() && mBlockUntil > aVsyncTimestamp) {
           if (mProcessedVsync) {
             // Re-post vsync update as a normal priority runnable. This way
             // runnables already in normal priority queue get processed.
             mProcessedVsync = false;
             nsCOMPtr<nsIRunnable> vsyncEvent =
               NewRunnableMethod<>(
+                "RefreshDriverVsyncObserver::NormalPriorityNotify",
                 this, &RefreshDriverVsyncObserver::NormalPriorityNotify);
             NS_DispatchToMainThread(vsyncEvent);
           }
 
           return true;
         }
 
         TickRefreshDriver(aVsyncTimestamp);
--- a/netwerk/base/Predictor.cpp
+++ b/netwerk/base/Predictor.cpp
@@ -690,17 +690,18 @@ private:
   nsCOMPtr<nsIThread> mIOThread;
   nsCOMPtr<nsIFile> mDBFile;
 };
 
 class PredictorLearnRunnable final : public Runnable {
 public:
   PredictorLearnRunnable(nsIURI *targetURI, nsIURI *sourceURI,
                          PredictorLearnReason reason, const OriginAttributes &oa)
-    : mTargetURI(targetURI)
+    : Runnable("PredictorLearnRunnable")
+    , mTargetURI(targetURI)
     , mSourceURI(sourceURI)
     , mReason(reason)
     , mOA(oa)
   { }
 
   ~PredictorLearnRunnable() { }
 
   NS_IMETHOD Run() override
--- a/netwerk/base/nsAsyncRedirectVerifyHelper.cpp
+++ b/netwerk/base/nsAsyncRedirectVerifyHelper.cpp
@@ -18,17 +18,18 @@ namespace mozilla {
 namespace net {
 
 static LazyLogModule gRedirectLog("nsRedirect");
 #undef LOG
 #define LOG(args) MOZ_LOG(gRedirectLog, LogLevel::Debug, args)
 
 NS_IMPL_ISUPPORTS(nsAsyncRedirectVerifyHelper,
                   nsIAsyncVerifyRedirectCallback,
-                  nsIRunnable)
+                  nsIRunnable,
+                  nsINamed)
 
 class nsAsyncVerifyRedirectCallbackEvent : public Runnable {
 public:
     nsAsyncVerifyRedirectCallbackEvent(nsIAsyncVerifyRedirectCallback *cb,
                                        nsresult result)
         : Runnable("nsAsyncVerifyRedirectCallbackEvent")
         , mCallback(cb)
         , mResult(result) {}
@@ -223,16 +224,29 @@ nsAsyncRedirectVerifyHelper::InitCallbac
     mCallbackInitiated = true;
 
     // Invoke the callback if we are done
     if (mExpectedCallbacks == 0)
         ExplicitCallback(mResult);
 }
 
 NS_IMETHODIMP
+nsAsyncRedirectVerifyHelper::GetName(nsACString& aName)
+{
+    aName.AssignASCII("nsAsyncRedirectVerifyHelper");
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsAsyncRedirectVerifyHelper::SetName(const char* aName)
+{
+  return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
 nsAsyncRedirectVerifyHelper::Run()
 {
     /* If the channel got canceled after it fired AsyncOnChannelRedirect
      * and before we got here, mostly because docloader load has been canceled,
      * we must completely ignore this notification and prevent any further
      * notification.
      */
     if (IsOldChannelCanceled()) {
--- a/netwerk/base/nsAsyncRedirectVerifyHelper.h
+++ b/netwerk/base/nsAsyncRedirectVerifyHelper.h
@@ -22,20 +22,22 @@ namespace mozilla {
 namespace net {
 
 /**
  * This class simplifies call of OnChannelRedirect of IOService and
  * the sink bound with the channel being redirected while the result of
  * redirect decision is returned through the callback.
  */
 class nsAsyncRedirectVerifyHelper final : public nsIRunnable,
+                                          public nsINamed,
                                           public nsIAsyncVerifyRedirectCallback
 {
     NS_DECL_THREADSAFE_ISUPPORTS
     NS_DECL_NSIRUNNABLE
+    NS_DECL_NSINAMED
     NS_DECL_NSIASYNCVERIFYREDIRECTCALLBACK
 
 public:
     nsAsyncRedirectVerifyHelper();
 
     /*
      * Calls AsyncOnChannelRedirect() on the given sink with the given
      * channels and flags. Keeps track of number of async callbacks to expect.
--- a/parser/html/nsHtml5RefPtr.h
+++ b/parser/html/nsHtml5RefPtr.h
@@ -10,17 +10,18 @@
 
 template <class T>
 class nsHtml5RefPtrReleaser : public mozilla::Runnable
   {
     private:
       T* mPtr;
     public:
       explicit nsHtml5RefPtrReleaser(T* aPtr)
-          : mPtr(aPtr)
+          : mozilla::Runnable("nsHtml5RefPtrReleaser")
+          , mPtr(aPtr)
         {}
       NS_IMETHOD Run() override
         {
           mPtr->Release();
           return NS_OK;
         }
   };
 
--- a/parser/html/nsHtml5StreamParser.cpp
+++ b/parser/html/nsHtml5StreamParser.cpp
@@ -115,34 +115,36 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 class nsHtml5ExecutorFlusher : public Runnable
 {
   private:
     RefPtr<nsHtml5TreeOpExecutor> mExecutor;
   public:
     explicit nsHtml5ExecutorFlusher(nsHtml5TreeOpExecutor* aExecutor)
-      : mExecutor(aExecutor)
+      : Runnable("nsHtml5ExecutorFlusher")
+      , mExecutor(aExecutor)
     {}
     NS_IMETHOD Run() override
     {
       if (!mExecutor->isInList()) {
         mExecutor->RunFlushLoop();
       }
       return NS_OK;
     }
 };
 
 class nsHtml5LoadFlusher : public Runnable
 {
   private:
     RefPtr<nsHtml5TreeOpExecutor> mExecutor;
   public:
     explicit nsHtml5LoadFlusher(nsHtml5TreeOpExecutor* aExecutor)
-      : mExecutor(aExecutor)
+      : Runnable("nsHtml5LoadFlusher")
+      , mExecutor(aExecutor)
     {}
     NS_IMETHOD Run() override
     {
       mExecutor->FlushSpeculativeLoads();
       return NS_OK;
     }
 };
 
@@ -1061,17 +1063,18 @@ nsHtml5StreamParser::DoStopRequest()
 }
 
 class nsHtml5RequestStopper : public Runnable
 {
   private:
     nsHtml5RefPtr<nsHtml5StreamParser> mStreamParser;
   public:
     explicit nsHtml5RequestStopper(nsHtml5StreamParser* aStreamParser)
-      : mStreamParser(aStreamParser)
+      : Runnable("nsHtml5RequestStopper")
+      , mStreamParser(aStreamParser)
     {}
     NS_IMETHOD Run() override
     {
       mozilla::MutexAutoLock autoLock(mStreamParser->mTokenizerMutex);
       mStreamParser->DoStopRequest();
       return NS_OK;
     }
 };
@@ -1150,17 +1153,18 @@ class nsHtml5DataAvailable : public Runn
   private:
     nsHtml5RefPtr<nsHtml5StreamParser> mStreamParser;
     UniquePtr<uint8_t[]>               mData;
     uint32_t                           mLength;
   public:
     nsHtml5DataAvailable(nsHtml5StreamParser* aStreamParser,
                          UniquePtr<uint8_t[]> aData,
                          uint32_t             aLength)
-      : mStreamParser(aStreamParser)
+      : Runnable("nsHtml5DataAvailable")
+      , mStreamParser(aStreamParser)
       , mData(Move(aData))
       , mLength(aLength)
     {}
     NS_IMETHOD Run() override
     {
       mozilla::MutexAutoLock autoLock(mStreamParser->mTokenizerMutex);
       mStreamParser->DoDataAvailable(mData.get(), mLength);
       return NS_OK;
@@ -1476,17 +1480,18 @@ nsHtml5StreamParser::ParseAvailableData(
 }
 
 class nsHtml5StreamParserContinuation : public Runnable
 {
 private:
   nsHtml5RefPtr<nsHtml5StreamParser> mStreamParser;
 public:
   explicit nsHtml5StreamParserContinuation(nsHtml5StreamParser* aStreamParser)
-    : mStreamParser(aStreamParser)
+    : Runnable("nsHtml5StreamParserContinuation")
+    , mStreamParser(aStreamParser)
   {}
   NS_IMETHOD Run() override
   {
     mozilla::MutexAutoLock autoLock(mStreamParser->mTokenizerMutex);
     mStreamParser->Uninterrupt();
     mStreamParser->ParseAvailableData();
     return NS_OK;
   }
@@ -1642,17 +1647,18 @@ nsHtml5StreamParser::ContinueAfterFailed
 }
 
 class nsHtml5TimerKungFu : public Runnable
 {
 private:
   nsHtml5RefPtr<nsHtml5StreamParser> mStreamParser;
 public:
   explicit nsHtml5TimerKungFu(nsHtml5StreamParser* aStreamParser)
-    : mStreamParser(aStreamParser)
+    : Runnable("nsHtml5TimerKungFu")
+    , mStreamParser(aStreamParser)
   {}
   NS_IMETHOD Run() override
   {
     mozilla::MutexAutoLock flushTimerLock(mStreamParser->mFlushTimerMutex);
     if (mStreamParser->mFlushTimer) {
       mStreamParser->mFlushTimer->Cancel();
       mStreamParser->mFlushTimer = nullptr;
     }
--- a/toolkit/components/telemetry/ipc/TelemetryIPCAccumulator.cpp
+++ b/toolkit/components/telemetry/ipc/TelemetryIPCAccumulator.cpp
@@ -102,70 +102,74 @@ ArmIPCTimer(const StaticMutexAutoLock& l
                                                     "TelemetryIPCAccumulator::ArmIPCTimer",
                                                     []() -> void {
       StaticMutexAutoLock locker(gTelemetryIPCAccumulatorMutex);
       DoArmIPCTimerMainThread(locker);
     }));
   }
 }
 
+void
+DispatchIPCTimerFired()
+{
+  TelemetryIPCAccumulator::DispatchToMainThread(
+    NS_NewRunnableFunction("TelemetryIPCAccumulator::IPCTimerFired",
+                           []() -> void {
+      TelemetryIPCAccumulator::IPCTimerFired(nullptr, nullptr);
+    }));
+}
+
 } // anonymous namespace
 
 ////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////
 //
 // EXTERNALLY VISIBLE FUNCTIONS in namespace TelemetryIPCAccumulator::
 
 void
 TelemetryIPCAccumulator::AccumulateChildHistogram(mozilla::Telemetry::HistogramID aId,
                                                   uint32_t aSample)
 {
   StaticMutexAutoLock locker(gTelemetryIPCAccumulatorMutex);
   if (!gHistogramAccumulations) {
     gHistogramAccumulations = new nsTArray<Accumulation>();
   }
   if (gHistogramAccumulations->Length() == kHistogramAccumulationsArrayHighWaterMark) {
-    TelemetryIPCAccumulator::DispatchToMainThread(NS_NewRunnableFunction([]() -> void {
-      TelemetryIPCAccumulator::IPCTimerFired(nullptr, nullptr);
-    }));
+    DispatchIPCTimerFired();
   }
   gHistogramAccumulations->AppendElement(Accumulation{aId, aSample});
   ArmIPCTimer(locker);
 }
 
 void
 TelemetryIPCAccumulator::AccumulateChildKeyedHistogram(mozilla::Telemetry::HistogramID aId,
                                                        const nsCString& aKey, uint32_t aSample)
 {
   StaticMutexAutoLock locker(gTelemetryIPCAccumulatorMutex);
   if (!gKeyedHistogramAccumulations) {
     gKeyedHistogramAccumulations = new nsTArray<KeyedAccumulation>();
   }
   if (gKeyedHistogramAccumulations->Length() == kHistogramAccumulationsArrayHighWaterMark) {
-    TelemetryIPCAccumulator::DispatchToMainThread(NS_NewRunnableFunction([]() -> void {
-      TelemetryIPCAccumulator::IPCTimerFired(nullptr, nullptr);
-    }));
+    DispatchIPCTimerFired();
   }
   gKeyedHistogramAccumulations->AppendElement(KeyedAccumulation{aId, aSample, aKey});
   ArmIPCTimer(locker);
 }
 
 void
 TelemetryIPCAccumulator::RecordChildScalarAction(mozilla::Telemetry::ScalarID aId,
                                                  ScalarActionType aAction, const ScalarVariant& aValue)
 {
   StaticMutexAutoLock locker(gTelemetryIPCAccumulatorMutex);
   // Make sure to have the storage.
   if (!gChildScalarsActions) {
     gChildScalarsActions = new nsTArray<ScalarAction>();
   }
   if (gChildScalarsActions->Length() == kScalarActionsArrayHighWaterMark) {
-    TelemetryIPCAccumulator::DispatchToMainThread(NS_NewRunnableFunction([]() -> void {
-      TelemetryIPCAccumulator::IPCTimerFired(nullptr, nullptr);
-    }));
+    DispatchIPCTimerFired();
   }
   // Store the action.
   gChildScalarsActions->AppendElement(ScalarAction{aId, aAction, Some(aValue)});
   ArmIPCTimer(locker);
 }
 
 void
 TelemetryIPCAccumulator::RecordChildKeyedScalarAction(mozilla::Telemetry::ScalarID aId,
@@ -174,19 +178,17 @@ TelemetryIPCAccumulator::RecordChildKeye
                                                       const ScalarVariant& aValue)
 {
   StaticMutexAutoLock locker(gTelemetryIPCAccumulatorMutex);
   // Make sure to have the storage.
   if (!gChildKeyedScalarsActions) {
     gChildKeyedScalarsActions = new nsTArray<KeyedScalarAction>();
   }
   if (gChildKeyedScalarsActions->Length() == kScalarActionsArrayHighWaterMark) {
-    TelemetryIPCAccumulator::DispatchToMainThread(NS_NewRunnableFunction([]() -> void {
-      TelemetryIPCAccumulator::IPCTimerFired(nullptr, nullptr);
-    }));
+    DispatchIPCTimerFired();
   }
   // Store the action.
   gChildKeyedScalarsActions->AppendElement(
     KeyedScalarAction{aId, aAction, NS_ConvertUTF16toUTF8(aKey), Some(aValue)});
   ArmIPCTimer(locker);
 }
 
 void
@@ -199,19 +201,17 @@ TelemetryIPCAccumulator::RecordChildEven
 {
   StaticMutexAutoLock locker(gTelemetryIPCAccumulatorMutex);
 
   if (!gChildEvents) {
     gChildEvents = new nsTArray<ChildEventData>();
   }
 
   if (gChildEvents->Length() == kEventsArrayHighWaterMark) {
-    TelemetryIPCAccumulator::DispatchToMainThread(NS_NewRunnableFunction([]() -> void {
-      TelemetryIPCAccumulator::IPCTimerFired(nullptr, nullptr);
-    }));
+    DispatchIPCTimerFired();
   }
 
   // Store the event.
   gChildEvents->AppendElement(ChildEventData{timestamp, nsCString(category),
                                              nsCString(method), nsCString(object),
                                              value,
                                              nsTArray<mozilla::Telemetry::EventExtraEntry>(extra)});
   ArmIPCTimer(locker);
--- a/xpcom/threads/nsThreadSyncDispatch.h
+++ b/xpcom/threads/nsThreadSyncDispatch.h
@@ -12,17 +12,18 @@
 
 #include "nsThreadUtils.h"
 #include "LeakRefPtr.h"
 
 class nsThreadSyncDispatch : public mozilla::Runnable
 {
 public:
   nsThreadSyncDispatch(nsIThread* aOrigin, already_AddRefed<nsIRunnable>&& aTask)
-    : mOrigin(aOrigin)
+    : Runnable("nsThreadSyncDispatch")
+    , mOrigin(aOrigin)
     , mSyncTask(mozilla::Move(aTask))
     , mIsPending(true)
   {
   }
 
   bool IsPending()
   {
     // This is an atomic acquire on the origin thread.