Bug 1331804 - Add more runnable names (r=ehsan)
authorBill McCloskey <billm@mozilla.com>
Tue, 17 Jan 2017 16:50:34 -0800
changeset 377594 e402c75016e08dc30b0399dbb1029c37cf330905
parent 377593 60fa55d96e2ca201c0025cbc3b69d6527729bb75
child 377595 28998c282974c480171faf6039d4f924264cf406
push id7198
push userjlorenzo@mozilla.com
push dateTue, 18 Apr 2017 12:07:49 +0000
treeherdermozilla-beta@d57aa49c3948 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1331804
milestone54.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 1331804 - Add more runnable names (r=ehsan) MozReview-Commit-ID: 1QBmqfgY6WI
dom/workers/RuntimeService.cpp
ipc/glue/BackgroundImpl.cpp
ipc/glue/MessageChannel.cpp
ipc/glue/MessageChannel.h
netwerk/base/nsTransportUtils.cpp
netwerk/cache2/CacheEntry.h
netwerk/dns/DNSListenerProxy.h
parser/html/nsHtml5SVGLoadDispatcher.cpp
storage/mozStorageAsyncStatementExecution.cpp
storage/mozStorageConnection.cpp
storage/mozStorageConnection.h
widget/nsBaseAppShell.cpp
xpcom/io/nsStreamUtils.cpp
xpcom/threads/nsProxyRelease.h
xpcom/threads/nsThread.cpp
xpcom/threads/nsThreadUtils.cpp
xpcom/threads/nsThreadUtils.h
--- a/dom/workers/RuntimeService.cpp
+++ b/dom/workers/RuntimeService.cpp
@@ -1187,17 +1187,18 @@ class WorkerThreadPrimaryRunnable final 
   JSContext* mParentContext;
 
   class FinishedRunnable final : public Runnable
   {
     RefPtr<WorkerThread> mThread;
 
   public:
     explicit FinishedRunnable(already_AddRefed<WorkerThread> aThread)
-    : mThread(aThread)
+    : Runnable("WorkerThreadPrimaryRunnable::FinishedRunnable")
+    , mThread(aThread)
     {
       MOZ_ASSERT(mThread);
     }
 
     NS_DECL_ISUPPORTS_INHERITED
 
   private:
     ~FinishedRunnable()
--- a/ipc/glue/BackgroundImpl.cpp
+++ b/ipc/glue/BackgroundImpl.cpp
@@ -745,17 +745,18 @@ class ChildImpl::OpenMainProcessActorRun
   RefPtr<ChildImpl> mActor;
   RefPtr<ParentImpl> mParentActor;
   MessageLoop* mParentMessageLoop;
 
 public:
   OpenMainProcessActorRunnable(already_AddRefed<ChildImpl>&& aChildActor,
                                already_AddRefed<ParentImpl> aParentActor,
                                MessageLoop* aParentMessageLoop)
-  : mActor(aChildActor), mParentActor(aParentActor),
+  : Runnable("ChildImpl::OpenMainProcessActorRunnable"),
+    mActor(aChildActor), mParentActor(aParentActor),
     mParentMessageLoop(aParentMessageLoop)
   {
     AssertIsOnMainThread();
     MOZ_ASSERT(mParentActor);
     MOZ_ASSERT(aParentMessageLoop);
   }
 
 private:
--- a/ipc/glue/MessageChannel.cpp
+++ b/ipc/glue/MessageChannel.cpp
@@ -1586,16 +1586,24 @@ MessageChannel::RunMessage(MessageTask& 
         return;
     }
 
     DispatchMessage(Move(msg));
 }
 
 NS_IMPL_ISUPPORTS_INHERITED(MessageChannel::MessageTask, CancelableRunnable, nsIRunnablePriority)
 
+MessageChannel::MessageTask::MessageTask(MessageChannel* aChannel, Message&& aMessage)
+  : CancelableRunnable(StringFromIPCMessageType(aMessage.type()))
+  , mChannel(aChannel)
+  , mMessage(Move(aMessage))
+  , mScheduled(false)
+{
+}
+
 nsresult
 MessageChannel::MessageTask::Run()
 {
     if (!mChannel) {
         return NS_OK;
     }
 
     mChannel->AssertWorkerThread();
--- a/ipc/glue/MessageChannel.h
+++ b/ipc/glue/MessageChannel.h
@@ -450,19 +450,17 @@ class MessageChannel : HasResultCodes
 
   private:
     class MessageTask :
         public CancelableRunnable,
         public LinkedListElement<RefPtr<MessageTask>>,
         public nsIRunnablePriority
     {
     public:
-        explicit MessageTask(MessageChannel* aChannel, Message&& aMessage)
-          : mChannel(aChannel), mMessage(Move(aMessage)), mScheduled(false)
-        {}
+        explicit MessageTask(MessageChannel* aChannel, Message&& aMessage);
 
         NS_DECL_ISUPPORTS_INHERITED
 
         NS_IMETHOD Run() override;
         nsresult Cancel() override;
         NS_IMETHOD GetPriority(uint32_t* aPriority) override;
         void Post();
         void Clear();
--- a/netwerk/base/nsTransportUtils.cpp
+++ b/netwerk/base/nsTransportUtils.cpp
@@ -50,17 +50,18 @@ public:
 class nsTransportStatusEvent : public Runnable
 {
 public:
     nsTransportStatusEvent(nsTransportEventSinkProxy *proxy,
                            nsITransport *transport,
                            nsresult status,
                            int64_t progress,
                            int64_t progressMax)
-        : mProxy(proxy)
+        : Runnable("nsTransportStatusEvent")
+        , mProxy(proxy)
         , mTransport(transport)
         , mStatus(status)
         , mProgress(progress)
         , mProgressMax(progressMax)
     {}
 
     ~nsTransportStatusEvent() {}
 
--- a/netwerk/cache2/CacheEntry.h
+++ b/netwerk/cache2/CacheEntry.h
@@ -181,17 +181,18 @@ private:
 
   // Since OnCacheEntryAvailable must be invoked on the main thread
   // we need a runnable for it...
   class AvailableCallbackRunnable : public Runnable
   {
   public:
     AvailableCallbackRunnable(CacheEntry* aEntry,
                               Callback const &aCallback)
-      : mEntry(aEntry)
+      : Runnable("CacheEntry::AvailableCallbackRunnable")
+      , mEntry(aEntry)
       , mCallback(aCallback)
     {}
 
   private:
     NS_IMETHOD Run() override
     {
       mEntry->InvokeAvailableCallback(mCallback);
       return NS_OK;
--- a/netwerk/dns/DNSListenerProxy.h
+++ b/netwerk/dns/DNSListenerProxy.h
@@ -38,17 +38,18 @@ public:
 
   class OnLookupCompleteRunnable : public Runnable
   {
   public:
     OnLookupCompleteRunnable(const nsMainThreadPtrHandle<nsIDNSListener>& aListener,
                              nsICancelable* aRequest,
                              nsIDNSRecord* aRecord,
                              nsresult aStatus)
-      : mListener(aListener)
+      : Runnable("DNSListenerProxy::OnLookupCompleteRunnable")
+      , mListener(aListener)
       , mRequest(aRequest)
       , mRecord(aRecord)
       , mStatus(aStatus)
     { }
 
     NS_DECL_NSIRUNNABLE
 
   private:
--- a/parser/html/nsHtml5SVGLoadDispatcher.cpp
+++ b/parser/html/nsHtml5SVGLoadDispatcher.cpp
@@ -7,17 +7,18 @@
 #include "nsIPresShell.h"
 #include "mozilla/BasicEvents.h"
 #include "mozilla/EventDispatcher.h"
 #include "nsIDocument.h"
 
 using namespace mozilla;
 
 nsHtml5SVGLoadDispatcher::nsHtml5SVGLoadDispatcher(nsIContent* aElement)
-  : mElement(aElement)
+  : Runnable("nsHtml5SVGLoadDispatcher")
+  , mElement(aElement)
   , mDocument(mElement->OwnerDoc())
 {
   mDocument->BlockOnload();
 }
 
 NS_IMETHODIMP
 nsHtml5SVGLoadDispatcher::Run()
 {
--- a/storage/mozStorageAsyncStatementExecution.cpp
+++ b/storage/mozStorageAsyncStatementExecution.cpp
@@ -51,17 +51,18 @@ typedef AsyncExecuteStatements::Statemen
  * Notifies a callback with a result set.
  */
 class CallbackResultNotifier : public Runnable
 {
 public:
   CallbackResultNotifier(mozIStorageStatementCallback *aCallback,
                          mozIStorageResultSet *aResults,
                          AsyncExecuteStatements *aEventStatus) :
-      mCallback(aCallback)
+      Runnable("storage::CallbackResultNotifier")
+    , mCallback(aCallback)
     , mResults(aResults)
     , mEventStatus(aEventStatus)
   {
   }
 
   NS_IMETHOD Run() override
   {
     NS_ASSERTION(mCallback, "Trying to notify about results without a callback!");
@@ -88,17 +89,18 @@ private:
  * Notifies the calling thread that an error has occurred.
  */
 class ErrorNotifier : public Runnable
 {
 public:
   ErrorNotifier(mozIStorageStatementCallback *aCallback,
                 mozIStorageError *aErrorObj,
                 AsyncExecuteStatements *aEventStatus) :
-      mCallback(aCallback)
+      Runnable("storage::ErrorNotifier")
+    , mCallback(aCallback)
     , mErrorObj(aErrorObj)
     , mEventStatus(aEventStatus)
   {
   }
 
   NS_IMETHOD Run() override
   {
     if (mEventStatus->shouldNotify() && mCallback) {
@@ -128,17 +130,18 @@ class CompletionNotifier : public Runnab
 public:
   /**
    * This takes ownership of the callback and the StatementData.  They are
    * released on the thread this is dispatched to (which should always be the
    * calling thread).
    */
   CompletionNotifier(mozIStorageStatementCallback *aCallback,
                      ExecutionState aReason)
-    : mCallback(aCallback)
+    : Runnable("storage::CompletionNotifier")
+    , mCallback(aCallback)
     , mReason(aReason)
   {
   }
 
   NS_IMETHOD Run() override
   {
     if (mCallback) {
       (void)mCallback->HandleCompletion(mReason);
--- a/storage/mozStorageConnection.cpp
+++ b/storage/mozStorageConnection.cpp
@@ -441,17 +441,18 @@ public:
    * @param aCallback A callback to trigger once initialization
    *                  is complete. This event will be called on
    *                  aClone->threadOpenedOn.
    */
   AsyncInitializeClone(Connection* aConnection,
                        Connection* aClone,
                        const bool aReadOnly,
                        mozIStorageCompletionCallback* aCallback)
-    : mConnection(aConnection)
+    : Runnable("storage::AsyncInitializeClone")
+    , mConnection(aConnection)
     , mClone(aClone)
     , mReadOnly(aReadOnly)
     , mCallback(aCallback)
   {
     MOZ_ASSERT(NS_IsMainThread());
   }
 
   NS_IMETHOD Run() override {
--- a/storage/mozStorageConnection.h
+++ b/storage/mozStorageConnection.h
@@ -393,17 +393,18 @@ public:
    * @param aValue The result to pass to the callback. It must
    *               already be owned by the main thread.
    * @param aCallback The callback. It must already be owned by the
    *                  main thread.
    */
   CallbackComplete(nsresult aStatus,
                    nsISupports* aValue,
                    already_AddRefed<mozIStorageCompletionCallback> aCallback)
-    : mStatus(aStatus)
+    : Runnable("storage::CallbackComplete")
+    , mStatus(aStatus)
     , mValue(aValue)
     , mCallback(aCallback)
   {
   }
 
   NS_IMETHOD Run() override {
     MOZ_ASSERT(NS_IsMainThread());
     nsresult rv = mCallback->Complete(mStatus, mValue);
--- a/widget/nsBaseAppShell.cpp
+++ b/widget/nsBaseAppShell.cpp
@@ -303,17 +303,17 @@ nsBaseAppShell::OnProcessNextEvent(nsITh
 }
 
 bool
 nsBaseAppShell::DispatchDummyEvent(nsIThread* aTarget)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
   if (!mDummyEvent)
-    mDummyEvent = new mozilla::Runnable();
+    mDummyEvent = new mozilla::Runnable("DummyEvent");
 
   return NS_SUCCEEDED(aTarget->Dispatch(mDummyEvent, NS_DISPATCH_NORMAL));
 }
 
 void
 nsBaseAppShell::IncrementEventloopNestingLevel()
 {
   ++mEventloopNestingLevel;
--- a/xpcom/io/nsStreamUtils.cpp
+++ b/xpcom/io/nsStreamUtils.cpp
@@ -33,17 +33,18 @@ class nsInputStreamReadyEvent final
   : public CancelableRunnable
   , public nsIInputStreamCallback
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
 
   nsInputStreamReadyEvent(nsIInputStreamCallback* aCallback,
                           nsIEventTarget* aTarget)
-    : mCallback(aCallback)
+    : CancelableRunnable("nsInputStreamReadyEvent")
+    , mCallback(aCallback)
     , mTarget(aTarget)
   {
   }
 
 private:
   ~nsInputStreamReadyEvent()
   {
     if (!mCallback) {
@@ -123,17 +124,18 @@ class nsOutputStreamReadyEvent final
   : public CancelableRunnable
   , public nsIOutputStreamCallback
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
 
   nsOutputStreamReadyEvent(nsIOutputStreamCallback* aCallback,
                            nsIEventTarget* aTarget)
-    : mCallback(aCallback)
+    : CancelableRunnable("nsOutputStreamReadyEvent")
+    , mCallback(aCallback)
     , mTarget(aTarget)
   {
   }
 
 private:
   ~nsOutputStreamReadyEvent()
   {
     if (!mCallback) {
@@ -236,17 +238,18 @@ class nsAStreamCopier
   : public nsIInputStreamCallback
   , public nsIOutputStreamCallback
   , public CancelableRunnable
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
 
   nsAStreamCopier()
-    : mLock("nsAStreamCopier.mLock")
+    : CancelableRunnable("nsAStreamCopier")
+    , mLock("nsAStreamCopier.mLock")
     , mCallback(nullptr)
     , mProgressCallback(nullptr)
     , mClosure(nullptr)
     , mChunkSize(0)
     , mEventInProcess(false)
     , mEventIsPending(false)
     , mCloseSource(true)
     , mCloseSink(true)
--- a/xpcom/threads/nsProxyRelease.h
+++ b/xpcom/threads/nsProxyRelease.h
@@ -24,17 +24,17 @@
 
 namespace detail {
 
 template<typename T>
 class ProxyReleaseEvent : public mozilla::Runnable
 {
 public:
   explicit ProxyReleaseEvent(already_AddRefed<T> aDoomed)
-  : mDoomed(aDoomed.take()) {}
+  : Runnable("ProxyReleaseEvent"), mDoomed(aDoomed.take()) {}
 
   NS_IMETHOD Run() override
   {
     NS_IF_RELEASE(mDoomed);
     return NS_OK;
   }
 
 private:
--- a/xpcom/threads/nsThread.cpp
+++ b/xpcom/threads/nsThread.cpp
@@ -190,17 +190,18 @@ NS_IMPL_CI_INTERFACE_GETTER(nsThread, ns
                             nsIEventTarget, nsISupportsPriority)
 
 //-----------------------------------------------------------------------------
 
 class nsThreadStartupEvent : public Runnable
 {
 public:
   nsThreadStartupEvent()
-    : mMon("nsThreadStartupEvent.mMon")
+    : Runnable("nsThreadStartupEvent")
+    , mMon("nsThreadStartupEvent.mMon")
     , mInitialized(false)
   {
   }
 
   // This method does not return until the thread startup object is in the
   // completion state.
   void Wait()
   {
@@ -329,17 +330,18 @@ struct nsThreadShutdownContext
 // This event is responsible for notifying nsThread::Shutdown that it is time
 // to call PR_JoinThread. It implements nsICancelableRunnable so that it can
 // run on a DOM Worker thread (where all events must implement
 // nsICancelableRunnable.)
 class nsThreadShutdownAckEvent : public CancelableRunnable
 {
 public:
   explicit nsThreadShutdownAckEvent(NotNull<nsThreadShutdownContext*> aCtx)
-    : mShutdownContext(aCtx)
+    : CancelableRunnable("nsThreadShutdownAckEvent")
+    , mShutdownContext(aCtx)
   {
   }
   NS_IMETHOD Run() override
   {
     mShutdownContext->mTerminatingThread->ShutdownComplete(mShutdownContext);
     return NS_OK;
   }
   nsresult Cancel() override
@@ -353,17 +355,18 @@ private:
 };
 
 // This event is responsible for setting mShutdownContext
 class nsThreadShutdownEvent : public Runnable
 {
 public:
   nsThreadShutdownEvent(NotNull<nsThread*> aThr,
                         NotNull<nsThreadShutdownContext*> aCtx)
-    : mThread(aThr)
+    : Runnable("nsThreadShutdownEvent")
+    , mThread(aThr)
     , mShutdownContext(aCtx)
   {
   }
   NS_IMETHOD Run() override
   {
     mThread->mShutdownContext = mShutdownContext;
     MessageLoop::current()->Quit();
     return NS_OK;
--- a/xpcom/threads/nsThreadUtils.cpp
+++ b/xpcom/threads/nsThreadUtils.cpp
@@ -52,17 +52,21 @@ Runnable::Run()
 }
 
 NS_IMETHODIMP
 Runnable::GetName(nsACString& aName)
 {
 #ifdef RELEASE_OR_BETA
   aName.Truncate();
 #else
-  aName.AssignASCII(mName);
+  if (mName) {
+    aName.AssignASCII(mName);
+  } else {
+    aName.Truncate();
+  }
 #endif
   return NS_OK;
 }
 
 nsresult
 Runnable::SetName(const char* aName)
 {
 #ifndef RELEASE_OR_BETA
--- a/xpcom/threads/nsThreadUtils.h
+++ b/xpcom/threads/nsThreadUtils.h
@@ -232,16 +232,22 @@ class Runnable : public nsIRunnable, pub
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIRUNNABLE
   NS_DECL_NSINAMED
 
   Runnable() {}
 
+#ifdef RELEASE_OR_BETA
+  explicit Runnable(const char* aName) {}
+#else
+  explicit Runnable(const char* aName) : mName(aName) {}
+#endif
+
 protected:
   virtual ~Runnable() {}
 private:
   Runnable(const Runnable&) = delete;
   Runnable& operator=(const Runnable&) = delete;
   Runnable& operator=(const Runnable&&) = delete;
 
 #ifndef RELEASE_OR_BETA
@@ -254,16 +260,17 @@ class CancelableRunnable : public Runnab
                            public nsICancelableRunnable
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
   // nsICancelableRunnable
   virtual nsresult Cancel() override;
 
   CancelableRunnable() {}
+  explicit CancelableRunnable(const char* aName) : Runnable(aName) {}
 
 protected:
   virtual ~CancelableRunnable() {}
 private:
   CancelableRunnable(const CancelableRunnable&) = delete;
   CancelableRunnable& operator=(const CancelableRunnable&) = delete;
   CancelableRunnable& operator=(const CancelableRunnable&&) = delete;
 };