Bug 1378930 - Part 1: Remove nsINamed::SetName(). r=billm
authorBevis Tseng <btseng@mozilla.com>
Fri, 21 Jul 2017 11:50:43 +0800
changeset 420042 c6bc36c3b43c05b1f50f454a04b563a2cc6c1569
parent 420041 484096481587c8c66e27a4d834ec62f596ae55f3
child 420043 0acc77eb92c6372cb73f441d2753c77068d87c2f
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs1378930
milestone56.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 1378930 - Part 1: Remove nsINamed::SetName(). r=billm MozReview-Commit-ID: 7aM1yJRsfPH
dom/base/TimeoutExecutor.cpp
dom/base/nsContentSink.cpp
dom/base/nsGlobalWindow.cpp
dom/events/EventStateManager.cpp
dom/file/nsHostObjectProtocolHandler.cpp
dom/media/DecoderDoctorDiagnostics.cpp
dom/security/nsCSPContext.cpp
dom/workers/ScriptLoader.cpp
dom/workers/WorkerPrivate.cpp
dom/xhr/XMLHttpRequestMainThread.cpp
gfx/layers/apz/util/APZThreadUtils.h
gfx/layers/ipc/ShadowLayers.cpp
layout/xul/nsMenuFrame.cpp
netwerk/base/nsAsyncRedirectVerifyHelper.cpp
toolkit/components/perfmonitoring/nsPerformanceStats.cpp
xpcom/threads/SchedulerGroup.cpp
xpcom/threads/nsINamed.idl
xpcom/threads/nsThreadUtils.cpp
xpcom/threads/nsThreadUtils.h
--- a/dom/base/TimeoutExecutor.cpp
+++ b/dom/base/TimeoutExecutor.cpp
@@ -239,16 +239,10 @@ TimeoutExecutor::Notify(nsITimer* aTimer
 
 NS_IMETHODIMP
 TimeoutExecutor::GetName(nsACString& aNameOut)
 {
   aNameOut.AssignLiteral("TimeoutExecutor Runnable");
   return NS_OK;
 }
 
-NS_IMETHODIMP
-TimeoutExecutor::SetName(const char* aName)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
 } // namespace dom
 } // namespace mozilla
--- a/dom/base/nsContentSink.cpp
+++ b/dom/base/nsContentSink.cpp
@@ -1654,14 +1654,8 @@ nsContentSink::NotifyDocElementCreated(n
 }
 
 NS_IMETHODIMP
 nsContentSink::GetName(nsACString& aName)
 {
   aName.AssignASCII("nsContentSink_timer");
   return NS_OK;
 }
-
-NS_IMETHODIMP
-nsContentSink::SetName(const char* aName)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -689,22 +689,16 @@ 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/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -232,22 +232,16 @@ UITimerCallback::Notify(nsITimer* aTimer
 
 NS_IMETHODIMP
 UITimerCallback::GetName(nsACString& aName)
 {
   aName.AssignASCII("UITimerCallback_timer");
   return NS_OK;
 }
 
-NS_IMETHODIMP
-UITimerCallback::SetName(const char* aName)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
 /******************************************************************/
 /* mozilla::OverOutElementsWrapper                                */
 /******************************************************************/
 
 OverOutElementsWrapper::OverOutElementsWrapper()
   : mLastOverFrame(nullptr)
 {
 }
--- a/dom/file/nsHostObjectProtocolHandler.cpp
+++ b/dom/file/nsHostObjectProtocolHandler.cpp
@@ -464,23 +464,16 @@ public:
 
   NS_IMETHOD
   GetName(nsACString& aName) override
   {
     aName.AssignLiteral("ReleasingTimerHolder");
     return NS_OK;
   }
 
-  NS_IMETHOD
-  SetName(const char* aName) override
-  {
-    MOZ_CRASH("The name shall never be set!");
-    return NS_OK;
-  }
-
 private:
   explicit ReleasingTimerHolder(nsTArray<nsWeakPtr>&& aArray)
     : mURIs(aArray)
   {}
 
   ~ReleasingTimerHolder()
   {}
 
--- a/dom/media/DecoderDoctorDiagnostics.cpp
+++ b/dom/media/DecoderDoctorDiagnostics.cpp
@@ -821,22 +821,16 @@ DecoderDoctorDocumentWatcher::Notify(nsI
 
 NS_IMETHODIMP
 DecoderDoctorDocumentWatcher::GetName(nsACString& aName)
 {
   aName.AssignASCII("DecoderDoctorDocumentWatcher_timer");
   return NS_OK;
 }
 
-NS_IMETHODIMP
-DecoderDoctorDocumentWatcher::SetName(const char* aName)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
 void
 DecoderDoctorDiagnostics::StoreFormatDiagnostics(nsIDocument* aDocument,
                                                  const nsAString& aFormat,
                                                  bool aCanPlay,
                                                  const char* aCallSite)
 {
   MOZ_ASSERT(NS_IsMainThread());
   // Make sure we only store once.
--- a/dom/security/nsCSPContext.cpp
+++ b/dom/security/nsCSPContext.cpp
@@ -1209,19 +1209,16 @@ nsCSPContext::AsyncReportViolation(nsISu
                                 aObserverSubject,
                                 aSourceFile,
                                 aScriptSample,
                                 aLineNum,
                                 this);
 
   if (XRE_IsContentProcess()) {
     if (mEventTarget) {
-      if (nsCOMPtr<nsINamed> named = do_QueryInterface(task)) {
-        named->SetName("CSPReportSenderRunnable");
-      }
       mEventTarget->Dispatch(task.forget(), NS_DISPATCH_NORMAL);
       return NS_OK;
     }
   }
 
   NS_DispatchToMainThread(task.forget());
   return NS_OK;
 }
--- a/dom/workers/ScriptLoader.cpp
+++ b/dom/workers/ScriptLoader.cpp
@@ -612,22 +612,16 @@ private:
 
   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;
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -5197,21 +5197,17 @@ WorkerPrivate::DispatchToMainThread(nsIR
   nsCOMPtr<nsIRunnable> r = aRunnable;
   return DispatchToMainThread(r.forget(), aFlags);
 }
 
 nsresult
 WorkerPrivate::DispatchToMainThread(already_AddRefed<nsIRunnable> aRunnable,
                                     uint32_t aFlags)
 {
-  nsCOMPtr<nsIRunnable> runnable = aRunnable;
-  if (nsCOMPtr<nsINamed> named = do_QueryInterface(runnable)) {
-    named->SetName("WorkerRunnable");
-  }
-  return mMainThreadEventTarget->Dispatch(runnable.forget(), aFlags);
+  return mMainThreadEventTarget->Dispatch(Move(aRunnable), aFlags);
 }
 
 nsISerialEventTarget*
 WorkerPrivate::ControlEventTarget()
 {
   return mWorkerControlEventTarget;
 }
 
--- a/dom/xhr/XMLHttpRequestMainThread.cpp
+++ b/dom/xhr/XMLHttpRequestMainThread.cpp
@@ -3949,22 +3949,16 @@ XMLHttpRequestMainThread::BlobStoreCompl
 
 NS_IMETHODIMP
 XMLHttpRequestMainThread::GetName(nsACString& aName)
 {
   aName.AssignLiteral("XMLHttpRequest");
   return NS_OK;
 }
 
-NS_IMETHODIMP
-XMLHttpRequestMainThread::SetName(const char* aName)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
 // nsXMLHttpRequestXPCOMifier implementation
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsXMLHttpRequestXPCOMifier)
   NS_INTERFACE_MAP_ENTRY(nsIStreamListener)
   NS_INTERFACE_MAP_ENTRY(nsIRequestObserver)
   NS_INTERFACE_MAP_ENTRY(nsIChannelEventSink)
   NS_INTERFACE_MAP_ENTRY(nsIAsyncVerifyRedirectCallback)
   NS_INTERFACE_MAP_ENTRY(nsIProgressEventSink)
   NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
--- a/gfx/layers/apz/util/APZThreadUtils.h
+++ b/gfx/layers/apz/util/APZThreadUtils.h
@@ -92,22 +92,16 @@ public:
   }
 
   NS_IMETHOD GetName(nsACString& aName) override
   {
     aName = mName;
     return NS_OK;
   }
 
-  NS_IMETHOD SetName(const char * aName) override
-  {
-    mName.Assign(aName);
-    return NS_OK;
-  }
-
 private:
   Function mFunction;
   nsCString mName;
 };
 
 // Convenience function for constructing a GenericNamedTimerCallback.
 // Returns a raw pointer, suitable for passing directly as an argument to
 // nsITimer::InitWithCallback(). The intention is to enable the following
--- a/gfx/layers/ipc/ShadowLayers.cpp
+++ b/gfx/layers/ipc/ShadowLayers.cpp
@@ -240,17 +240,16 @@ ShadowLayerForwarder::~ShadowLayerForwar
       }
     }
   }
 
   if (!NS_IsMainThread()) {
     RefPtr<ReleaseOnMainThreadTask<ActiveResourceTracker>> event =
       new ReleaseOnMainThreadTask<ActiveResourceTracker>(mActiveResourceTracker);
     if (mEventTarget) {
-      event->SetName("ActiveResourceTracker::~ActiveResourceTracker");
       mEventTarget->Dispatch(event.forget(), nsIEventTarget::DISPATCH_NORMAL);
     } else {
       NS_DispatchToMainThread(event);
     }
   }
 }
 
 void
--- a/layout/xul/nsMenuFrame.cpp
+++ b/layout/xul/nsMenuFrame.cpp
@@ -1527,19 +1527,8 @@ void nsMenuTimerMediator::ClearFrame()
  * @param aName the name to return
  */
 NS_IMETHODIMP
 nsMenuTimerMediator::GetName(nsACString& aName)
 {
   aName.AssignLiteral("nsMenuTimerMediator");
   return NS_OK;
 }
-
-/**
- * Set the name to this timer callback.
- * @param aName the name to set
- */
-NS_IMETHODIMP
-nsMenuTimerMediator::SetName(const char* aName)
-{
-  // We don't need to change the name for nsMenuTimerMediator.
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
--- a/netwerk/base/nsAsyncRedirectVerifyHelper.cpp
+++ b/netwerk/base/nsAsyncRedirectVerifyHelper.cpp
@@ -236,22 +236,16 @@ nsAsyncRedirectVerifyHelper::InitCallbac
 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/toolkit/components/perfmonitoring/nsPerformanceStats.cpp
+++ b/toolkit/components/perfmonitoring/nsPerformanceStats.cpp
@@ -590,22 +590,16 @@ PendingAlertsCollector::Notify(nsITimer*
 
 NS_IMETHODIMP
 PendingAlertsCollector::GetName(nsACString& aName)
 {
   aName.AssignASCII("PendingAlertsCollector_timer");
   return NS_OK;
 }
 
-NS_IMETHODIMP
-PendingAlertsCollector::SetName(const char* aName)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
 nsresult
 PendingAlertsCollector::Start(uint32_t timerDelayMS) {
   if (mPending) {
     // Collector is already started.
     return NS_OK;
   }
 
   if (!mTimer) {
--- a/xpcom/threads/SchedulerGroup.cpp
+++ b/xpcom/threads/SchedulerGroup.cpp
@@ -168,26 +168,20 @@ SchedulerEventTarget::IsOnCurrentThreadI
   return NS_IsMainThread();
 }
 
 /* static */ nsresult
 SchedulerGroup::UnlabeledDispatch(const char* aName,
                                   TaskCategory aCategory,
                                   already_AddRefed<nsIRunnable>&& aRunnable)
 {
-  nsCOMPtr<nsIRunnable> runnable(aRunnable);
-  if (aName) {
-    if (nsCOMPtr<nsINamed> named = do_QueryInterface(runnable)) {
-      named->SetName(aName);
-    }
-  }
   if (NS_IsMainThread()) {
-    return NS_DispatchToCurrentThread(runnable.forget());
+    return NS_DispatchToCurrentThread(Move(aRunnable));
   } else {
-    return NS_DispatchToMainThread(runnable.forget());
+    return NS_DispatchToMainThread(Move(aRunnable));
   }
 }
 
 /* static */ void
 SchedulerGroup::MarkVsyncReceived()
 {
   if (gEarliestUnprocessedVsync) {
     // If we've seen a vsync already, but haven't handled it, keep the
--- a/xpcom/threads/nsINamed.idl
+++ b/xpcom/threads/nsINamed.idl
@@ -16,17 +16,9 @@ interface nsINamed : nsISupports
      * A string describing the purpose of the runnable/timer/whatever. Useful
      * for debugging. This attribute is read-only, but you can change it to a
      * compile-time string literal with setName.
      *
      * WARNING: This attribute will be included in telemetry, so it should
      * never contain privacy sensitive information.
      */
     readonly attribute ACString name;
-
-    /*
-     * Note: The string you pass in should be a compile-time literal.
-     *
-     * WARNING: This value will be included in telemetry, so it should
-     * never contain privacy sensitive information.
-     */
-    [noscript] void setName(in string aName);
 };
--- a/xpcom/threads/nsThreadUtils.cpp
+++ b/xpcom/threads/nsThreadUtils.cpp
@@ -60,25 +60,16 @@ Runnable::GetName(nsACString& aName)
     aName.AssignASCII(mName);
   } else {
     aName.Truncate();
   }
 #endif
   return NS_OK;
 }
 
-nsresult
-Runnable::SetName(const char* aName)
-{
-#ifndef RELEASE_OR_BETA
-  mName = aName;
-#endif
-  return NS_OK;
-}
-
 NS_IMPL_ISUPPORTS_INHERITED(CancelableRunnable, Runnable,
                             nsICancelableRunnable)
 
 nsresult
 CancelableRunnable::Cancel()
 {
   // Do nothing
   return NS_OK;
--- a/xpcom/threads/nsThreadUtils.h
+++ b/xpcom/threads/nsThreadUtils.h
@@ -511,18 +511,18 @@ namespace detail {
 // An event that can be used to call a C++11 functions or function objects,
 // including lambdas. The function must have no required arguments, and must
 // return void.
 template<typename StoredFunction>
 class RunnableFunction : public Runnable
 {
 public:
   template <typename F>
-  explicit RunnableFunction(F&& aFunction)
-    : Runnable("RunnableFunction")
+  explicit RunnableFunction(const char* aName, F&& aFunction)
+    : Runnable(aName)
     , mFunction(Forward<F>(aFunction))
   { }
 
   NS_IMETHOD Run() override {
     static_assert(IsVoid<decltype(mFunction())>::value,
                   "The lambda must return void!");
     mFunction();
     return NS_OK;
@@ -531,31 +531,16 @@ private:
   StoredFunction mFunction;
 };
 
 // Type alias for NS_NewRunnableFunction
 template<typename Function>
 using RunnableFunctionImpl =
   // Make sure we store a non-reference in nsRunnableFunction.
   typename detail::RunnableFunction<typename RemoveReference<Function>::Type>;
-
-template <typename T>
-inline already_AddRefed<T>
-SetRunnableName(const char* aName, T* aObj)
-{
-#ifdef RELEASE_OR_BETA
-  return do_AddRef(aObj);
-#else
-  MOZ_RELEASE_ASSERT(aName);
-  RefPtr<T> ref(aObj);
-  ref->SetName(aName);
-  return ref.forget();
-#endif
-}
-
 } // namespace detail
 
 namespace detail {
 
 template<typename CVRemoved>
 struct IsRefcountedSmartPointerHelper : FalseType {};
 
 template<typename Pointee>
@@ -640,20 +625,19 @@ ToSupports(mozilla::Runnable *p)
 }
 
 template<typename Function>
 already_AddRefed<mozilla::Runnable>
 NS_NewRunnableFunction(const char* aName, Function&& aFunction)
 {
   // We store a non-reference in RunnableFunction, but still forward aFunction
   // to move if possible.
-  return mozilla::detail::SetRunnableName(
-    aName,
+  return do_AddRef(
     new mozilla::detail::RunnableFunctionImpl<Function>(
-      mozilla::Forward<Function>(aFunction)));
+      aName, mozilla::Forward<Function>(aFunction)));
 }
 
 namespace mozilla {
 namespace detail {
 
 already_AddRefed<nsITimer> CreateTimer();
 
 template <RunnableKind Kind>
@@ -717,17 +701,17 @@ class nsRunnableMethod
 {
   using BaseType = typename mozilla::Conditional<Kind == mozilla::Standard,
                                                  mozilla::Runnable,
                                                  typename mozilla::Conditional<
                                                    Kind == mozilla::Cancelable,
                                                    mozilla::CancelableRunnable,
                                                    mozilla::IdleRunnable>::Type>::Type;
 public:
-  nsRunnableMethod() : BaseType("nsRunnableMethod") {}
+  nsRunnableMethod(const char* aName) : BaseType(aName) {}
 
   virtual void Revoke() = 0;
 
   // These ReturnTypeEnforcer classes set up a blacklist for return types that
   // we know are not safe. The default ReturnTypeEnforcer compiles just fine but
   // already_AddRefed will not.
   template<typename OtherReturnType>
   class ReturnTypeEnforcer
@@ -1186,19 +1170,20 @@ private:
     static_assert(IsIdle(Kind), "Don't use me!");
     RefPtr<IdleRunnable> r = static_cast<IdleRunnable*>(aClosure);
     r->SetDeadline(TimeStamp());
     r->Run();
     r->Cancel();
   }
 public:
   template<typename ForwardedPtrType, typename... Args>
-  explicit RunnableMethodImpl(ForwardedPtrType&& aObj, Method aMethod,
-                              Args&&... aArgs)
-    : mReceiver(Forward<ForwardedPtrType>(aObj))
+  explicit RunnableMethodImpl(const char* aName, ForwardedPtrType&& aObj,
+                              Method aMethod, Args&&... aArgs)
+    : BaseType(aName)
+    , mReceiver(Forward<ForwardedPtrType>(aObj))
     , mMethod(aMethod)
     , mArgs(Forward<Args>(aArgs)...)
   {
     static_assert(sizeof...(Storages) == sizeof...(Args), "Storages and Args should have equal sizes");
   }
   NS_IMETHOD Run()
   {
     CancelTimer();
@@ -1397,188 +1382,174 @@ using NonOwningIdleRunnableMethodWithTim
 // that do not take a `const char*` as their first parameter; you may see
 // these in older code.  The `const char*` overload is preferred and
 // should be used in new code exclusively.
 
 template<typename PtrType, typename Method>
 already_AddRefed<detail::OwningRunnableMethod<PtrType, Method>>
 NewRunnableMethod(const char* aName, PtrType&& aPtr, Method aMethod)
 {
-  return detail::SetRunnableName(
-    aName,
+  return do_AddRef(
     new detail::OwningRunnableMethodImpl<PtrType, Method>(
-      Forward<PtrType>(aPtr), aMethod));
+      aName, Forward<PtrType>(aPtr), aMethod));
 }
 
 template<typename PtrType, typename Method>
 already_AddRefed<detail::CancelableRunnableMethod<PtrType, Method>>
 NewCancelableRunnableMethod(const char* aName, PtrType&& aPtr, Method aMethod)
 {
-  return detail::SetRunnableName(
-    aName,
+  return do_AddRef(
     new detail::CancelableRunnableMethodImpl<PtrType, Method>(
-      Forward<PtrType>(aPtr), aMethod));
+      aName, Forward<PtrType>(aPtr), aMethod));
 }
 
 template<typename PtrType, typename Method>
 already_AddRefed<detail::IdleRunnableMethod<PtrType, Method>>
 NewIdleRunnableMethod(const char* aName, PtrType&& aPtr, Method aMethod)
 {
-  return detail::SetRunnableName(
-    aName,
+  return do_AddRef(
     new detail::IdleRunnableMethodImpl<PtrType, Method>(
-      Forward<PtrType>(aPtr), aMethod));
+      aName, Forward<PtrType>(aPtr), aMethod));
 }
 
 template<typename PtrType, typename Method>
 already_AddRefed<detail::IdleRunnableMethodWithTimer<PtrType, Method>>
 NewIdleRunnableMethodWithTimer(const char* aName,
                                PtrType&& aPtr,
                                Method aMethod)
 {
-  return detail::SetRunnableName(
-    aName,
+  return do_AddRef(
     new detail::IdleRunnableMethodWithTimerImpl<PtrType, Method>(
-      Forward<PtrType>(aPtr), aMethod));
+      aName, Forward<PtrType>(aPtr), aMethod));
 }
 
 template<typename PtrType, typename Method>
 already_AddRefed<detail::NonOwningRunnableMethod<PtrType, Method>>
 NewNonOwningRunnableMethod(const char* aName, PtrType&& aPtr, Method aMethod)
 {
-  return detail::SetRunnableName(
-    aName,
+  return do_AddRef(
     new detail::NonOwningRunnableMethodImpl<PtrType, Method>(
-      Forward<PtrType>(aPtr), aMethod));
+      aName, Forward<PtrType>(aPtr), aMethod));
 }
 
 template<typename PtrType, typename Method>
 already_AddRefed<detail::NonOwningCancelableRunnableMethod<PtrType, Method>>
 NewNonOwningCancelableRunnableMethod(const char* aName, PtrType&& aPtr,
                                      Method aMethod)
 {
-  return detail::SetRunnableName(
-    aName,
+  return do_AddRef(
     new detail::NonOwningCancelableRunnableMethodImpl<PtrType, Method>(
-      Forward<PtrType>(aPtr), aMethod));
+      aName, Forward<PtrType>(aPtr), aMethod));
 }
 
 template<typename PtrType, typename Method>
 already_AddRefed<detail::NonOwningIdleRunnableMethod<PtrType, Method>>
 NewNonOwningIdleRunnableMethod(const char* aName,
                                PtrType&& aPtr,
                                Method aMethod)
 {
-  return detail::SetRunnableName(
-    aName,
+  return do_AddRef(
     new detail::NonOwningIdleRunnableMethodImpl<PtrType, Method>(
-      Forward<PtrType>(aPtr), aMethod));
+      aName, Forward<PtrType>(aPtr), aMethod));
 }
 
 template<typename PtrType, typename Method>
 already_AddRefed<detail::NonOwningIdleRunnableMethodWithTimer<PtrType, Method>>
 NewNonOwningIdleRunnableMethodWithTimer(const char* aName,
                                         PtrType&& aPtr,
                                         Method aMethod)
 {
-  return detail::SetRunnableName(
-    aName,
+  return do_AddRef(
     new detail::NonOwningIdleRunnableMethodWithTimerImpl<PtrType, Method>(
-      Forward<PtrType>(aPtr), aMethod));
+      aName, Forward<PtrType>(aPtr), aMethod));
 }
 
 // Similar to NewRunnableMethod. Call like so:
 // nsCOMPtr<nsIRunnable> event =
 //   NewRunnableMethod<Types,...>(myObject, &MyClass::HandleEvent, myArg1,...);
 // 'Types' are the stored type for each argument, see ParameterStorage for details.
 template<typename... Storages, typename PtrType, typename Method, typename... Args>
 already_AddRefed<detail::OwningRunnableMethod<PtrType, Method>>
 NewRunnableMethod(const char* aName, PtrType&& aPtr, Method aMethod, Args&&... aArgs)
 {
   static_assert(sizeof...(Storages) == sizeof...(Args),
                 "<Storages...> size should be equal to number of arguments");
-  return detail::SetRunnableName(
-    aName,
+  return do_AddRef(
     new detail::OwningRunnableMethodImpl<PtrType, Method, Storages...>(
-      Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...));
+      aName, Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...));
 }
 
 template<typename... Storages, typename PtrType, typename Method, typename... Args>
 already_AddRefed<detail::NonOwningRunnableMethod<PtrType, Method>>
 NewNonOwningRunnableMethod(const char* aName, PtrType&& aPtr, Method aMethod,
                            Args&&... aArgs)
 {
   static_assert(sizeof...(Storages) == sizeof...(Args),
                 "<Storages...> size should be equal to number of arguments");
-  return detail::SetRunnableName(
-    aName,
+  return do_AddRef(
     new detail::NonOwningRunnableMethodImpl<PtrType, Method, Storages...>(
-      Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...));
+      aName, Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...));
 }
 
 template<typename... Storages, typename PtrType, typename Method, typename... Args>
 already_AddRefed<detail::CancelableRunnableMethod<PtrType, Method>>
 NewCancelableRunnableMethod(const char* aName, PtrType&& aPtr, Method aMethod,
                             Args&&... aArgs)
 {
   static_assert(sizeof...(Storages) == sizeof...(Args),
                 "<Storages...> size should be equal to number of arguments");
-  return detail::SetRunnableName(
-    aName,
+  return do_AddRef(
     new detail::CancelableRunnableMethodImpl<PtrType, Method, Storages...>(
-      Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...));
+      aName, Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...));
 }
 
 template<typename... Storages, typename PtrType, typename Method, typename... Args>
 already_AddRefed<detail::NonOwningCancelableRunnableMethod<PtrType, Method>>
 NewNonOwningCancelableRunnableMethod(const char* aName, PtrType&& aPtr,
                                      Method aMethod, Args&&... aArgs)
 {
   static_assert(sizeof...(Storages) == sizeof...(Args),
                 "<Storages...> size should be equal to number of arguments");
-  return detail::SetRunnableName(
-    aName,
+  return do_AddRef(
     new detail::NonOwningCancelableRunnableMethodImpl<PtrType, Method, Storages...>(
-      Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...));
+      aName, Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...));
 }
 
 template<typename... Storages,
          typename PtrType,
          typename Method,
          typename... Args>
 already_AddRefed<detail::IdleRunnableMethod<PtrType, Method>>
 NewIdleRunnableMethod(const char* aName,
                       PtrType&& aPtr,
                       Method aMethod,
                       Args&&... aArgs)
 {
   static_assert(sizeof...(Storages) == sizeof...(Args),
                 "<Storages...> size should be equal to number of arguments");
-  return detail::SetRunnableName(
-    aName,
+  return do_AddRef(
     new detail::IdleRunnableMethodImpl<PtrType, Method, Storages...>(
-      Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...));
+      aName, Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...));
 }
 
 template<typename... Storages,
          typename PtrType,
          typename Method,
          typename... Args>
 already_AddRefed<detail::NonOwningIdleRunnableMethod<PtrType, Method>>
 NewNonOwningIdleRunnableMethod(const char* aName,
                                PtrType&& aPtr,
                                Method aMethod,
                                Args&&... aArgs)
 {
   static_assert(sizeof...(Storages) == sizeof...(Args),
                 "<Storages...> size should be equal to number of arguments");
-  return detail::SetRunnableName(
-    aName,
+  return do_AddRef(
     new detail::NonOwningIdleRunnableMethodImpl<PtrType, Method, Storages...>(
-      Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...));
+      aName, Forward<PtrType>(aPtr), aMethod, mozilla::Forward<Args>(aArgs)...));
 }
 
 } // namespace mozilla
 
 #endif  // XPCOM_GLUE_AVOID_NSPR
 
 // This class is designed to be used when you have an event class E that has a
 // pointer back to resource class R.  If R goes away while E is still pending,