Bug 1339289 - Make sure labeled runnables have names (r=ehsan)
authorBill McCloskey <billm@mozilla.com>
Tue, 14 Feb 2017 13:42:53 -0800
changeset 343188 daa7da2c260e302602d6f79cd35964fb02221399
parent 343187 c64f0271649030394d2a29872513c9ec36521fa0
child 343189 02ccacdbbb93b26120032ad128273ce68705a3cd
push id31372
push usercbook@mozilla.com
push dateThu, 16 Feb 2017 12:16:10 +0000
treeherdermozilla-central@2737f66ad6ac [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1339289
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 1339289 - Make sure labeled runnables have names (r=ehsan) MozReview-Commit-ID: C6w8Q4NPBtt
xpcom/threads/Dispatcher.cpp
--- a/xpcom/threads/Dispatcher.cpp
+++ b/xpcom/threads/Dispatcher.cpp
@@ -17,16 +17,31 @@
 using namespace mozilla;
 
 class ValidatingDispatcher::Runnable final : public mozilla::Runnable
 {
 public:
   Runnable(already_AddRefed<nsIRunnable>&& aRunnable,
            ValidatingDispatcher* aDispatcher);
 
+  NS_IMETHODIMP
+  GetName(nsACString& aName) override
+  {
+    mozilla::Runnable::GetName(aName);
+    if (aName.IsEmpty()) {
+      // Try to get a name from the underlying runnable.
+      nsCOMPtr<nsINamed> named = do_QueryInterface(mRunnable);
+      if (named) {
+        named->GetName(aName);
+      }
+    }
+    aName.AppendASCII("(labeled)");
+    return NS_OK;
+  }
+
   NS_DECL_NSIRUNNABLE
 
 private:
   nsCOMPtr<nsIRunnable> mRunnable;
   RefPtr<ValidatingDispatcher> mDispatcher;
 };
 
 /* DispatcherEventTarget */