Bug 1142841: Convert all nsRefPtr<nsIRunnable> to nsCOMPtr<nsIRunnable>. r=ehsan
authorDaniel Holbert <dholbert@cs.stanford.edu>
Tue, 17 Mar 2015 09:29:17 -0700
changeset 262962 7542e92bf99c5cfcc3912ecad3b4e5d97c22162b
parent 262961 c96a700ca7768bcb42f1b870bbecea60251f9f81
child 262963 6e8d11d20bb2010bc150c9f5c45bf47ca48631f9
push idunknown
push userunknown
push dateunknown
reviewersehsan
bugs1142841
milestone39.0a1
Bug 1142841: Convert all nsRefPtr<nsIRunnable> to nsCOMPtr<nsIRunnable>. r=ehsan This patch was generated by a script. Here's the source of the script for future reference: find . \( -iname "*.cpp" -o -iname "*.h" \) | \ xargs -n 1 sed -i "s/nsRefPtr<nsIRunnable>/nsCOMPtr<nsIRunnable>/g"
docshell/shistory/src/nsSHistory.cpp
dom/base/nsDocument.cpp
dom/base/nsFrameLoader.cpp
dom/base/nsFrameMessageManager.cpp
dom/base/nsGlobalWindow.cpp
dom/cache/FetchPut.cpp
dom/camera/CameraPreviewMediaStream.cpp
dom/media/MediaDecoder.cpp
dom/media/MediaRecorder.cpp
dom/media/MediaStreamGraph.cpp
dom/media/eme/CDMCallbackProxy.cpp
dom/media/eme/CDMCaps.h
dom/media/eme/CDMProxy.cpp
dom/media/fmp4/MP4Decoder.cpp
dom/media/fmp4/apple/AppleDecoderModule.cpp
dom/media/fmp4/gmp/MediaDataDecoderProxy.cpp
dom/media/gmp/GMPService.cpp
dom/media/gtest/TestGMPCrossOrigin.cpp
dom/media/mediasource/MediaSource.cpp
dom/media/mediasource/MediaSourceDecoder.cpp
dom/media/mediasource/SourceBuffer.cpp
dom/media/webaudio/AudioNode.cpp
dom/promise/Promise.cpp
dom/workers/ServiceWorkerManager.cpp
gfx/gl/AndroidSurfaceTexture.h
layout/ipc/VsyncParent.cpp
media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.h
media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp
media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h
netwerk/base/NetworkActivityMonitor.cpp
netwerk/base/OfflineObserver.cpp
netwerk/base/Tickler.cpp
netwerk/base/nsAsyncRedirectVerifyHelper.cpp
netwerk/cache/nsCacheEntryDescriptor.cpp
netwerk/cache/nsDiskCacheDeviceSQL.cpp
netwerk/cache2/CacheIOThread.cpp
netwerk/cache2/CacheIOThread.h
netwerk/protocol/http/nsHttpActivityDistributor.cpp
netwerk/protocol/http/nsHttpConnectionMgr.cpp
widget/android/AndroidJNIWrapper.cpp
xpcom/base/AvailableMemoryTracker.cpp
xpcom/base/CycleCollectedJSRuntime.cpp
xpcom/base/CycleCollectedJSRuntime.h
xpcom/glue/nsProxyRelease.cpp
xpcom/io/nsInputStreamTee.cpp
xpcom/threads/nsEventQueue.cpp
xpcom/threads/nsThread.cpp
xpcom/threads/nsThreadPool.cpp
--- a/docshell/shistory/src/nsSHistory.cpp
+++ b/docshell/shistory/src/nsSHistory.cpp
@@ -1401,17 +1401,17 @@ nsSHistory::RemoveEntries(nsTArray<uint6
   bool didRemove = false;
   while (index > minIndex) {
     if (index != mIndex) {
       didRemove = RemoveDuplicate(index, index < mIndex) || didRemove;
     }
     --index;
   }
   if (didRemove && mRootDocShell) {
-    nsRefPtr<nsIRunnable> ev =
+    nsCOMPtr<nsIRunnable> ev =
       NS_NewRunnableMethod(static_cast<nsDocShell*>(mRootDocShell),
                            &nsDocShell::FireDummyOnLocationChange);
     NS_DispatchToCurrentThread(ev);
   }
 }
 
 void
 nsSHistory::RemoveDynEntries(int32_t aOldIndex, int32_t aNewIndex)
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -4407,17 +4407,17 @@ nsDocument::SetStyleSheetApplicableState
   if (StyleSheetChangeEventsEnabled()) {
     DO_STYLESHEET_NOTIFICATION(StyleSheetApplicableStateChangeEvent,
                                "StyleSheetApplicableStateChanged",
                                mApplicable,
                                aApplicable);
   }
 
   if (!mSSApplicableStateNotificationPending) {
-    nsRefPtr<nsIRunnable> notification = NS_NewRunnableMethod(this,
+    nsCOMPtr<nsIRunnable> notification = NS_NewRunnableMethod(this,
       &nsDocument::NotifyStyleSheetApplicableStateChanged);
     mSSApplicableStateNotificationPending =
       NS_SUCCEEDED(NS_DispatchToCurrentThread(notification));
   }
 }
 
 void
 nsDocument::NotifyStyleSheetApplicableStateChanged()
@@ -5227,17 +5227,17 @@ nsDocument::UnblockDOMContentLoaded()
   MOZ_ASSERT(mBlockDOMContentLoaded);
   if (--mBlockDOMContentLoaded != 0 || mDidFireDOMContentLoaded) {
     return;
   }
   mDidFireDOMContentLoaded = true;
 
   MOZ_ASSERT(mReadyState == READYSTATE_INTERACTIVE);
   if (!mSynchronousDOMContentLoaded) {
-    nsRefPtr<nsIRunnable> ev =
+    nsCOMPtr<nsIRunnable> ev =
       NS_NewRunnableMethod(this, &nsDocument::DispatchContentLoadedEvents);
     NS_DispatchToCurrentThread(ev);
   } else {
     DispatchContentLoadedEvents();
   }
 }
 
 void
--- a/dom/base/nsFrameLoader.cpp
+++ b/dom/base/nsFrameLoader.cpp
@@ -2355,17 +2355,17 @@ nsFrameLoader::DoSendAsyncMessage(JSCont
     if (aCpows && !cp->GetCPOWManager()->Wrap(aCx, aCpows, &cpows)) {
       return false;
     }
     return tabParent->SendAsyncMessage(nsString(aMessage), data, cpows,
                                        IPC::Principal(aPrincipal));
   }
 
   if (mChildMessageManager) {
-    nsRefPtr<nsIRunnable> ev = new nsAsyncMessageToChild(aCx, this, aMessage,
+    nsCOMPtr<nsIRunnable> ev = new nsAsyncMessageToChild(aCx, this, aMessage,
                                                          aData, aCpows,
                                                          aPrincipal);
     NS_DispatchToCurrentThread(ev);
     return true;
   }
 
   // We don't have any targets to send our asynchronous message to.
   return false;
--- a/dom/base/nsFrameMessageManager.cpp
+++ b/dom/base/nsFrameMessageManager.cpp
@@ -1747,17 +1747,17 @@ public:
   }
 
   virtual bool DoSendAsyncMessage(JSContext* aCx,
                                   const nsAString& aMessage,
                                   const StructuredCloneData& aData,
                                   JS::Handle<JSObject *> aCpows,
                                   nsIPrincipal* aPrincipal) MOZ_OVERRIDE
   {
-    nsRefPtr<nsIRunnable> ev =
+    nsCOMPtr<nsIRunnable> ev =
       new nsAsyncMessageToSameProcessChild(aCx, aMessage, aData, aCpows,
                                            aPrincipal);
     NS_DispatchToCurrentThread(ev);
     return true;
   }
 
   bool CheckPermission(const nsAString& aPermission) MOZ_OVERRIDE
   {
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -8892,17 +8892,17 @@ private:
   uint64_t mID;
   nsCString mTopic;
   nsWeakPtr mWindow;
 };
 
 void
 nsGlobalWindow::NotifyWindowIDDestroyed(const char* aTopic)
 {
-  nsRefPtr<nsIRunnable> runnable = new WindowDestroyedEvent(this, mWindowID, aTopic);
+  nsCOMPtr<nsIRunnable> runnable = new WindowDestroyedEvent(this, mWindowID, aTopic);
   nsresult rv = NS_DispatchToCurrentThread(runnable);
   if (NS_SUCCEEDED(rv)) {
     mNotifiedIDDestroyed = true;
   }
 }
 
 // static
 void
--- a/dom/cache/FetchPut.cpp
+++ b/dom/cache/FetchPut.cpp
@@ -157,17 +157,17 @@ FetchPut::~FetchPut()
   mManager->ReleaseCacheId(mCacheId);
 }
 
 nsresult
 FetchPut::DispatchToMainThread()
 {
   MOZ_ASSERT(!mRunnable);
 
-  nsRefPtr<nsIRunnable> runnable = new Runnable(this);
+  nsCOMPtr<nsIRunnable> runnable = new Runnable(this);
 
   nsresult rv = NS_DispatchToMainThread(runnable, nsIThread::DISPATCH_NORMAL);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   MOZ_ASSERT(!mRunnable);
   mRunnable = runnable.forget();
--- a/dom/camera/CameraPreviewMediaStream.cpp
+++ b/dom/camera/CameraPreviewMediaStream.cpp
@@ -19,17 +19,17 @@ using namespace mozilla::dom;
 
 namespace mozilla {
 
 static const TrackID TRACK_VIDEO = 2;
 
 void
 FakeMediaStreamGraph::DispatchToMainThreadAfterStreamStateUpdate(already_AddRefed<nsIRunnable> aRunnable)
 {
-  nsRefPtr<nsIRunnable> task = aRunnable;
+  nsCOMPtr<nsIRunnable> task = aRunnable;
   NS_DispatchToMainThread(task);
 }
 
 CameraPreviewMediaStream::CameraPreviewMediaStream(DOMMediaStream* aWrapper)
   : MediaStream(aWrapper)
   , mMutex("mozilla::camera::CameraPreviewMediaStream")
   , mInvalidatePending(0)
   , mDiscardedFrames(0)
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -363,17 +363,17 @@ class MediaDecoder::OutputStreamListener
 public:
   OutputStreamListener(MediaDecoder* aDecoder, MediaStream* aStream)
     : mDecoder(aDecoder), mStream(aStream) {}
 
   virtual void NotifyEvent(
       MediaStreamGraph* aGraph,
       MediaStreamListener::MediaStreamGraphEvent event) MOZ_OVERRIDE {
     if (event == EVENT_FINISHED) {
-      nsRefPtr<nsIRunnable> r = NS_NewRunnableMethod(
+      nsCOMPtr<nsIRunnable> r = NS_NewRunnableMethod(
           this, &OutputStreamListener::DoNotifyFinished);
       aGraph->DispatchToMainThreadAfterStreamStateUpdate(r.forget());
     }
   }
 
   void Forget() {
     MOZ_ASSERT(NS_IsMainThread());
     mDecoder = nullptr;
--- a/dom/media/MediaRecorder.cpp
+++ b/dom/media/MediaRecorder.cpp
@@ -261,17 +261,17 @@ class MediaRecorder::Session: public nsI
 
     NS_IMETHODIMP Run()
     {
       MOZ_ASSERT(NS_GetCurrentThread() == mSession->mReadThread);
 
       LOG(PR_LOG_DEBUG, ("Session.ExtractRunnable shutdown = %d", mSession->mEncoder->IsShutdown()));
       if (!mSession->mEncoder->IsShutdown()) {
         mSession->Extract(false);
-        nsRefPtr<nsIRunnable> event = new ExtractRunnable(mSession);
+        nsCOMPtr<nsIRunnable> event = new ExtractRunnable(mSession);
         if (NS_FAILED(NS_DispatchToCurrentThread(event))) {
           NS_WARNING("Failed to dispatch ExtractRunnable to encoder thread");
         }
       } else {
         // Flush out remaining encoded data.
         mSession->Extract(true);
         if (mSession->mIsRegisterProfiler)
            profiler_unregister_thread();
@@ -607,17 +607,17 @@ private:
         return;
       }
     }
 
     // In case source media stream does not notify track end, recieve
     // shutdown notification and stop Read Thread.
     nsContentUtils::RegisterShutdownObserver(this);
 
-    nsRefPtr<nsIRunnable> event = new ExtractRunnable(this);
+    nsCOMPtr<nsIRunnable> event = new ExtractRunnable(this);
     if (NS_FAILED(mReadThread->Dispatch(event, NS_DISPATCH_NORMAL))) {
       NS_WARNING("Failed to dispatch ExtractRunnable at beginning");
     }
   }
   // application should get blob and onstop event
   void DoSessionEndTask(nsresult rv)
   {
     MOZ_ASSERT(NS_IsMainThread());
--- a/dom/media/MediaStreamGraph.cpp
+++ b/dom/media/MediaStreamGraph.cpp
@@ -2229,17 +2229,17 @@ MediaStream::RunAfterPendingUpdates(alre
     virtual void RunDuringShutdown() MOZ_OVERRIDE
     {
       // Don't run mRunnable now as it may call AppendMessage() which would
       // assume that there are no remaining controlMessagesToRunDuringShutdown.
       MOZ_ASSERT(NS_IsMainThread());
       NS_DispatchToCurrentThread(mRunnable);
     }
   private:
-    nsRefPtr<nsIRunnable> mRunnable;
+    nsCOMPtr<nsIRunnable> mRunnable;
   };
 
   graph->AppendMessage(new Message(this, runnable.forget()));
 }
 
 void
 MediaStream::SetTrackEnabledImpl(TrackID aTrackID, bool aEnabled)
 {
--- a/dom/media/eme/CDMCallbackProxy.cpp
+++ b/dom/media/eme/CDMCallbackProxy.cpp
@@ -45,17 +45,17 @@ public:
 };
 
 void
 CDMCallbackProxy::SetSessionId(uint32_t aToken,
                                const nsCString& aSessionId)
 {
   MOZ_ASSERT(mProxy->IsOnGMPThread());
 
-  nsRefPtr<nsIRunnable> task(new SetSessionIdTask(mProxy,
+  nsCOMPtr<nsIRunnable> task(new SetSessionIdTask(mProxy,
                                                   aToken,
                                                   aSessionId));
   NS_DispatchToMainThread(task);
 }
 
 class LoadSessionTask : public nsRunnable {
 public:
   LoadSessionTask(CDMProxy* aProxy,
@@ -77,17 +77,17 @@ public:
   bool mSuccess;
 };
 
 void
 CDMCallbackProxy::ResolveLoadSessionPromise(uint32_t aPromiseId, bool aSuccess)
 {
   MOZ_ASSERT(mProxy->IsOnGMPThread());
 
-  nsRefPtr<nsIRunnable> task(new LoadSessionTask(mProxy,
+  nsCOMPtr<nsIRunnable> task(new LoadSessionTask(mProxy,
                                                  aPromiseId,
                                                  aSuccess));
   NS_DispatchToMainThread(task);
 }
 
 void
 CDMCallbackProxy::ResolvePromise(uint32_t aPromiseId)
 {
@@ -124,17 +124,17 @@ public:
 
 void
 CDMCallbackProxy::RejectPromise(uint32_t aPromiseId,
                                 nsresult aException,
                                 const nsCString& aMessage)
 {
   MOZ_ASSERT(mProxy->IsOnGMPThread());
 
-  nsRefPtr<nsIRunnable> task;
+  nsCOMPtr<nsIRunnable> task;
   task = new RejectPromiseTask(mProxy,
                                aPromiseId,
                                aException,
                                aMessage);
   NS_DispatchToMainThread(task);
 }
 
 class SessionMessageTask : public nsRunnable {
@@ -164,17 +164,17 @@ public:
 
 void
 CDMCallbackProxy::SessionMessage(const nsCString& aSessionId,
                                  GMPSessionMessageType aMessageType,
                                  const nsTArray<uint8_t>& aMessage)
 {
   MOZ_ASSERT(mProxy->IsOnGMPThread());
 
-  nsRefPtr<nsIRunnable> task;
+  nsCOMPtr<nsIRunnable> task;
   task = new SessionMessageTask(mProxy,
                                 aSessionId,
                                 aMessageType,
                                 aMessage);
   NS_DispatchToMainThread(task);
 }
 
 class ExpirationChangeTask : public nsRunnable {
@@ -198,29 +198,29 @@ public:
 };
 
 void
 CDMCallbackProxy::ExpirationChange(const nsCString& aSessionId,
                                    GMPTimestamp aExpiryTime)
 {
   MOZ_ASSERT(mProxy->IsOnGMPThread());
 
-  nsRefPtr<nsIRunnable> task;
+  nsCOMPtr<nsIRunnable> task;
   task = new ExpirationChangeTask(mProxy,
                                   aSessionId,
                                   aExpiryTime);
   NS_DispatchToMainThread(task);
 }
 
 void
 CDMCallbackProxy::SessionClosed(const nsCString& aSessionId)
 {
   MOZ_ASSERT(mProxy->IsOnGMPThread());
 
-  nsRefPtr<nsIRunnable> task;
+  nsCOMPtr<nsIRunnable> task;
   task = NS_NewRunnableMethodWithArg<nsString>(mProxy,
                                                &CDMProxy::OnSessionClosed,
                                                NS_ConvertUTF8toUTF16(aSessionId));
   NS_DispatchToMainThread(task);
 }
 
 class SessionErrorTask : public nsRunnable {
 public:
@@ -252,17 +252,17 @@ public:
 void
 CDMCallbackProxy::SessionError(const nsCString& aSessionId,
                                nsresult aException,
                                uint32_t aSystemCode,
                                const nsCString& aMessage)
 {
   MOZ_ASSERT(mProxy->IsOnGMPThread());
 
-  nsRefPtr<nsIRunnable> task;
+  nsCOMPtr<nsIRunnable> task;
   task = new SessionErrorTask(mProxy,
                               aSessionId,
                               aException,
                               aSystemCode,
                               aMessage);
   NS_DispatchToMainThread(task);
 }
 
@@ -276,17 +276,17 @@ CDMCallbackProxy::KeyStatusChanged(const
   bool keyStatusesChange = false;
   {
     CDMCaps::AutoLock caps(mProxy->Capabilites());
     keyStatusesChange = caps.SetKeyStatus(aKeyId,
                                           NS_ConvertUTF8toUTF16(aSessionId),
                                           aStatus);
   }
   if (keyStatusesChange) {
-    nsRefPtr<nsIRunnable> task;
+    nsCOMPtr<nsIRunnable> task;
     task = NS_NewRunnableMethodWithArg<nsString>(mProxy,
                                                  &CDMProxy::OnKeyStatusesChange,
                                                  NS_ConvertUTF8toUTF16(aSessionId));
     NS_DispatchToMainThread(task);
   }
 }
 
 void
@@ -307,13 +307,13 @@ CDMCallbackProxy::Decrypted(uint32_t aId
 
   mProxy->gmp_Decrypted(aId, aResult, aDecryptedData);
 }
 
 void
 CDMCallbackProxy::Terminated()
 {
   MOZ_ASSERT(mProxy->IsOnGMPThread());
-  nsRefPtr<nsIRunnable> task = NS_NewRunnableMethod(mProxy, &CDMProxy::Terminated);
+  nsCOMPtr<nsIRunnable> task = NS_NewRunnableMethod(mProxy, &CDMProxy::Terminated);
   NS_DispatchToMainThread(task);
 }
 
 } // namespace mozilla
--- a/dom/media/eme/CDMCaps.h
+++ b/dom/media/eme/CDMCaps.h
@@ -104,17 +104,17 @@ private:
   };
 
   Monitor mMonitor;
 
   nsTArray<KeyStatus> mKeyStatuses;
 
   nsTArray<WaitForKeys> mWaitForKeys;
 
-  nsTArray<nsRefPtr<nsIRunnable>> mWaitForCaps;
+  nsTArray<nsCOMPtr<nsIRunnable>> mWaitForCaps;
   uint64_t mCaps;
 
   // It is not safe to copy this object.
   CDMCaps(const CDMCaps&) = delete;
   CDMCaps& operator=(const CDMCaps&) = delete;
 };
 
 } // namespace mozilla
--- a/dom/media/eme/CDMProxy.cpp
+++ b/dom/media/eme/CDMProxy.cpp
@@ -62,17 +62,17 @@ CDMProxy::Init(PromiseId aPromiseId,
       return;
     }
   }
   nsAutoPtr<InitData> data(new InitData());
   data->mPromiseId = aPromiseId;
   data->mOrigin = aOrigin;
   data->mTopLevelOrigin = aTopLevelOrigin;
   data->mInPrivateBrowsing = aInPrivateBrowsing;
-  nsRefPtr<nsIRunnable> task(
+  nsCOMPtr<nsIRunnable> task(
     NS_NewRunnableMethodWithArg<nsAutoPtr<InitData>>(this,
                                                      &CDMProxy::gmp_Init,
                                                      data));
   mGMPThread->Dispatch(task, NS_DISPATCH_NORMAL);
 }
 
 #ifdef DEBUG
 bool
@@ -113,17 +113,17 @@ CDMProxy::gmp_Init(nsAutoPtr<InitData> a
   nsTArray<nsCString> tags;
   tags.AppendElement(NS_ConvertUTF16toUTF8(mKeySystem));
   rv = mps->GetGMPDecryptor(&tags, GetNodeId(), &mCDM);
   if (NS_FAILED(rv) || !mCDM) {
     RejectPromise(aData->mPromiseId, NS_ERROR_DOM_INVALID_STATE_ERR);
   } else {
     mCallback = new CDMCallbackProxy(this);
     mCDM->Init(mCallback);
-    nsRefPtr<nsIRunnable> task(
+    nsCOMPtr<nsIRunnable> task(
       NS_NewRunnableMethodWithArg<uint32_t>(this,
                                             &CDMProxy::OnCDMCreated,
                                             aData->mPromiseId));
     NS_DispatchToMainThread(task);
   }
 }
 
 void
@@ -149,17 +149,17 @@ CDMProxy::CreateSession(uint32_t aCreate
 
   nsAutoPtr<CreateSessionData> data(new CreateSessionData());
   data->mSessionType = aSessionType;
   data->mCreateSessionToken = aCreateSessionToken;
   data->mPromiseId = aPromiseId;
   data->mInitDataType = NS_ConvertUTF16toUTF8(aInitDataType);
   data->mInitData = Move(aInitData);
 
-  nsRefPtr<nsIRunnable> task(
+  nsCOMPtr<nsIRunnable> task(
     NS_NewRunnableMethodWithArg<nsAutoPtr<CreateSessionData>>(this, &CDMProxy::gmp_CreateSession, data));
   mGMPThread->Dispatch(task, NS_DISPATCH_NORMAL);
 }
 
 GMPSessionType
 ToGMPSessionType(dom::SessionType aSessionType) {
   switch (aSessionType) {
     case dom::SessionType::Temporary: return kGMPTemporySession;
@@ -188,17 +188,17 @@ CDMProxy::LoadSession(PromiseId aPromise
                       const nsAString& aSessionId)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(mGMPThread);
 
   nsAutoPtr<SessionOpData> data(new SessionOpData());
   data->mPromiseId = aPromiseId;
   data->mSessionId = NS_ConvertUTF16toUTF8(aSessionId);
-  nsRefPtr<nsIRunnable> task(
+  nsCOMPtr<nsIRunnable> task(
     NS_NewRunnableMethodWithArg<nsAutoPtr<SessionOpData>>(this, &CDMProxy::gmp_LoadSession, data));
   mGMPThread->Dispatch(task, NS_DISPATCH_NORMAL);
 }
 
 void
 CDMProxy::gmp_LoadSession(nsAutoPtr<SessionOpData> aData)
 {
   MOZ_ASSERT(IsOnGMPThread());
@@ -215,17 +215,17 @@ CDMProxy::SetServerCertificate(PromiseId
                                nsTArray<uint8_t>& aCert)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(mGMPThread);
 
   nsAutoPtr<SetServerCertificateData> data;
   data->mPromiseId = aPromiseId;
   data->mCert = Move(aCert);
-  nsRefPtr<nsIRunnable> task(
+  nsCOMPtr<nsIRunnable> task(
     NS_NewRunnableMethodWithArg<nsAutoPtr<SetServerCertificateData>>(this, &CDMProxy::gmp_SetServerCertificate, data));
   mGMPThread->Dispatch(task, NS_DISPATCH_NORMAL);
 }
 
 void
 CDMProxy::gmp_SetServerCertificate(nsAutoPtr<SetServerCertificateData> aData)
 {
   MOZ_ASSERT(IsOnGMPThread());
@@ -244,17 +244,17 @@ CDMProxy::UpdateSession(const nsAString&
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(mGMPThread);
   NS_ENSURE_TRUE_VOID(!mKeys.IsNull());
 
   nsAutoPtr<UpdateSessionData> data(new UpdateSessionData());
   data->mPromiseId = aPromiseId;
   data->mSessionId = NS_ConvertUTF16toUTF8(aSessionId);
   data->mResponse = Move(aResponse);
-  nsRefPtr<nsIRunnable> task(
+  nsCOMPtr<nsIRunnable> task(
     NS_NewRunnableMethodWithArg<nsAutoPtr<UpdateSessionData>>(this, &CDMProxy::gmp_UpdateSession, data));
   mGMPThread->Dispatch(task, NS_DISPATCH_NORMAL);
 }
 
 void
 CDMProxy::gmp_UpdateSession(nsAutoPtr<UpdateSessionData> aData)
 {
   MOZ_ASSERT(IsOnGMPThread());
@@ -272,17 +272,17 @@ CDMProxy::CloseSession(const nsAString& 
                        PromiseId aPromiseId)
 {
   MOZ_ASSERT(NS_IsMainThread());
   NS_ENSURE_TRUE_VOID(!mKeys.IsNull());
 
   nsAutoPtr<SessionOpData> data(new SessionOpData());
   data->mPromiseId = aPromiseId;
   data->mSessionId = NS_ConvertUTF16toUTF8(aSessionId);
-  nsRefPtr<nsIRunnable> task(
+  nsCOMPtr<nsIRunnable> task(
     NS_NewRunnableMethodWithArg<nsAutoPtr<SessionOpData>>(this, &CDMProxy::gmp_CloseSession, data));
   mGMPThread->Dispatch(task, NS_DISPATCH_NORMAL);
 }
 
 void
 CDMProxy::gmp_CloseSession(nsAutoPtr<SessionOpData> aData)
 {
   MOZ_ASSERT(IsOnGMPThread());
@@ -298,17 +298,17 @@ CDMProxy::RemoveSession(const nsAString&
                         PromiseId aPromiseId)
 {
   MOZ_ASSERT(NS_IsMainThread());
   NS_ENSURE_TRUE_VOID(!mKeys.IsNull());
 
   nsAutoPtr<SessionOpData> data(new SessionOpData());
   data->mPromiseId = aPromiseId;
   data->mSessionId = NS_ConvertUTF16toUTF8(aSessionId);
-  nsRefPtr<nsIRunnable> task(
+  nsCOMPtr<nsIRunnable> task(
     NS_NewRunnableMethodWithArg<nsAutoPtr<SessionOpData>>(this, &CDMProxy::gmp_RemoveSession, data));
   mGMPThread->Dispatch(task, NS_DISPATCH_NORMAL);
 }
 
 void
 CDMProxy::gmp_RemoveSession(nsAutoPtr<SessionOpData> aData)
 {
   MOZ_ASSERT(IsOnGMPThread());
@@ -320,17 +320,17 @@ CDMProxy::gmp_RemoveSession(nsAutoPtr<Se
 }
 
 void
 CDMProxy::Shutdown()
 {
   MOZ_ASSERT(NS_IsMainThread());
   mKeys.Clear();
   // Note: This may end up being the last owning reference to the CDMProxy.
-  nsRefPtr<nsIRunnable> task(NS_NewRunnableMethod(this, &CDMProxy::gmp_Shutdown));
+  nsCOMPtr<nsIRunnable> task(NS_NewRunnableMethod(this, &CDMProxy::gmp_Shutdown));
   if (mGMPThread) {
     mGMPThread->Dispatch(task, NS_DISPATCH_NORMAL);
   }
 }
 
 void
 CDMProxy::gmp_Shutdown()
 {
@@ -352,32 +352,32 @@ CDMProxy::gmp_Shutdown()
 void
 CDMProxy::RejectPromise(PromiseId aId, nsresult aCode)
 {
   if (NS_IsMainThread()) {
     if (!mKeys.IsNull()) {
       mKeys->RejectPromise(aId, aCode);
     }
   } else {
-    nsRefPtr<nsIRunnable> task(new RejectPromiseTask(this, aId, aCode));
+    nsCOMPtr<nsIRunnable> task(new RejectPromiseTask(this, aId, aCode));
     NS_DispatchToMainThread(task);
   }
 }
 
 void
 CDMProxy::ResolvePromise(PromiseId aId)
 {
   if (NS_IsMainThread()) {
     if (!mKeys.IsNull()) {
       mKeys->ResolvePromise(aId);
     } else {
       NS_WARNING("CDMProxy unable to resolve promise!");
     }
   } else {
-    nsRefPtr<nsIRunnable> task;
+    nsCOMPtr<nsIRunnable> task;
     task = NS_NewRunnableMethodWithArg<PromiseId>(this,
                                                   &CDMProxy::ResolvePromise,
                                                   aId);
     NS_DispatchToMainThread(task);
   }
 }
 
 const nsCString&
@@ -520,17 +520,17 @@ CDMProxy::Capabilites() {
   return mCapabilites;
 }
 
 void
 CDMProxy::Decrypt(mp4_demuxer::MP4Sample* aSample,
                   DecryptionClient* aClient)
 {
   nsAutoPtr<DecryptJob> job(new DecryptJob(aSample, aClient));
-  nsRefPtr<nsIRunnable> task(
+  nsCOMPtr<nsIRunnable> task(
     NS_NewRunnableMethodWithArg<nsAutoPtr<DecryptJob>>(this, &CDMProxy::gmp_Decrypt, job));
   mGMPThread->Dispatch(task, NS_DISPATCH_NORMAL);
 }
 
 void
 CDMProxy::gmp_Decrypt(nsAutoPtr<DecryptJob> aJob)
 {
   MOZ_ASSERT(IsOnGMPThread());
--- a/dom/media/fmp4/MP4Decoder.cpp
+++ b/dom/media/fmp4/MP4Decoder.cpp
@@ -42,17 +42,17 @@ MP4Decoder::SetCDMProxy(CDMProxy* aProxy
 {
   nsresult rv = MediaDecoder::SetCDMProxy(aProxy);
   NS_ENSURE_SUCCESS(rv, rv);
   {
     // The MP4Reader can't decrypt EME content until it has a CDMProxy,
     // and the CDMProxy knows the capabilities of the CDM. The MP4Reader
     // remains in "waiting for resources" state until then.
     CDMCaps::AutoLock caps(aProxy->Capabilites());
-    nsRefPtr<nsIRunnable> task(
+    nsCOMPtr<nsIRunnable> task(
       NS_NewRunnableMethod(this, &MediaDecoder::NotifyWaitingForResourcesStatusChanged));
     caps.CallOnMainThreadWhenCapsAvailable(task);
   }
   return NS_OK;
 }
 #endif
 
 static bool
--- a/dom/media/fmp4/apple/AppleDecoderModule.cpp
+++ b/dom/media/fmp4/apple/AppleDecoderModule.cpp
@@ -91,17 +91,17 @@ public:
 /* static */
 nsresult
 AppleDecoderModule::CanDecode()
 {
   if (!sInitialized) {
     if (NS_IsMainThread()) {
       Init();
     } else {
-      nsRefPtr<nsIRunnable> task(new InitTask());
+      nsCOMPtr<nsIRunnable> task(new InitTask());
       NS_DispatchToMainThread(task, NS_DISPATCH_SYNC);
     }
   }
 
   return (sIsVDAAvailable || sIsVTAvailable) ? NS_OK : NS_ERROR_NO_INTERFACE;
 }
 
 class LinkTask : public nsRunnable {
@@ -122,17 +122,17 @@ public:
 
 nsresult
 AppleDecoderModule::Startup()
 {
   if (!sIsVDAAvailable && !sIsVTAvailable) {
     return NS_ERROR_FAILURE;
   }
 
-  nsRefPtr<nsIRunnable> task(new LinkTask());
+  nsCOMPtr<nsIRunnable> task(new LinkTask());
   NS_DispatchToMainThread(task, NS_DISPATCH_SYNC);
 
   return NS_OK;
 }
 
 class UnlinkTask : public nsRunnable {
 public:
   NS_IMETHOD Run() MOZ_OVERRIDE {
@@ -147,17 +147,17 @@ public:
     }
     return NS_OK;
   }
 };
 
 nsresult
 AppleDecoderModule::Shutdown()
 {
-  nsRefPtr<nsIRunnable> task(new UnlinkTask());
+  nsCOMPtr<nsIRunnable> task(new UnlinkTask());
   NS_DispatchToMainThread(task);
   return NS_OK;
 }
 
 already_AddRefed<MediaDataDecoder>
 AppleDecoderModule::CreateVideoDecoder(const mp4_demuxer::VideoDecoderConfig& aConfig,
                                        layers::LayersBackend aLayersBackend,
                                        layers::ImageContainer* aImageContainer,
--- a/dom/media/fmp4/gmp/MediaDataDecoderProxy.cpp
+++ b/dom/media/fmp4/gmp/MediaDataDecoderProxy.cpp
@@ -33,63 +33,63 @@ MediaDataDecoderProxy::Init()
 }
 
 nsresult
 MediaDataDecoderProxy::Input(mp4_demuxer::MP4Sample* aSample)
 {
   MOZ_ASSERT(!IsOnProxyThread());
   MOZ_ASSERT(!mIsShutdown);
 
-  nsRefPtr<nsIRunnable> task(new InputTask(mProxyDecoder, aSample));
+  nsCOMPtr<nsIRunnable> task(new InputTask(mProxyDecoder, aSample));
   nsresult rv = mProxyThread->Dispatch(task, NS_DISPATCH_NORMAL);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
 nsresult
 MediaDataDecoderProxy::Flush()
 {
   MOZ_ASSERT(!IsOnProxyThread());
   MOZ_ASSERT(!mIsShutdown);
 
   mFlushComplete.Set(false);
 
-  nsRefPtr<nsIRunnable> task;
+  nsCOMPtr<nsIRunnable> task;
   task = NS_NewRunnableMethod(mProxyDecoder, &MediaDataDecoder::Flush);
   nsresult rv = mProxyThread->Dispatch(task, NS_DISPATCH_NORMAL);
   NS_ENSURE_SUCCESS(rv, rv);
 
   mFlushComplete.WaitUntil(true);
 
   return NS_OK;
 }
 
 nsresult
 MediaDataDecoderProxy::Drain()
 {
   MOZ_ASSERT(!IsOnProxyThread());
   MOZ_ASSERT(!mIsShutdown);
 
-  nsRefPtr<nsIRunnable> task;
+  nsCOMPtr<nsIRunnable> task;
   task = NS_NewRunnableMethod(mProxyDecoder, &MediaDataDecoder::Drain);
   nsresult rv = mProxyThread->Dispatch(task, NS_DISPATCH_NORMAL);
   NS_ENSURE_SUCCESS(rv, rv);
   return NS_OK;
 }
 
 nsresult
 MediaDataDecoderProxy::Shutdown()
 {
   // Note that this *may* be called from the proxy thread also.
   MOZ_ASSERT(!mIsShutdown);
 #if defined(DEBUG)
   mIsShutdown = true;
 #endif
-  nsRefPtr<nsIRunnable> task;
+  nsCOMPtr<nsIRunnable> task;
   task = NS_NewRunnableMethod(mProxyDecoder, &MediaDataDecoder::Shutdown);
   nsresult rv = mProxyThread->Dispatch(task, NS_DISPATCH_SYNC);
   NS_ENSURE_SUCCESS(rv, rv);
   return NS_OK;
 }
 
 void
 MediaDataDecoderProxy::FlushComplete()
--- a/dom/media/gmp/GMPService.cpp
+++ b/dom/media/gmp/GMPService.cpp
@@ -553,17 +553,17 @@ GeckoMediaPluginService::AsyncShutdownCo
 {
   LOGD(("%s::%s %p", __CLASS__, __FUNCTION__, aParent));
   MOZ_ASSERT(NS_GetCurrentThread() == mGMPThread);
 
   mAsyncShutdownPlugins.RemoveElement(aParent);
   if (mAsyncShutdownPlugins.IsEmpty() && mShuttingDownOnGMPThread) {
     // The main thread may be waiting for async shutdown of plugins,
     // which has completed. Break the main thread out of its waiting loop.
-    nsRefPtr<nsIRunnable> task(NS_NewRunnableMethod(
+    nsCOMPtr<nsIRunnable> task(NS_NewRunnableMethod(
       this, &GeckoMediaPluginService::SetAsyncShutdownComplete));
     NS_DispatchToMainThread(task);
   }
 }
 
 void
 GeckoMediaPluginService::SetAsyncShutdownComplete()
 {
@@ -587,17 +587,17 @@ GeckoMediaPluginService::UnloadPlugins()
     // shutting down when all the plugins have unloaded.
     for (size_t i = 0; i < mPlugins.Length(); i++) {
       mPlugins[i]->CloseActive(true);
     }
     mPlugins.Clear();
   }
 
   if (mAsyncShutdownPlugins.IsEmpty()) {
-    nsRefPtr<nsIRunnable> task(NS_NewRunnableMethod(
+    nsCOMPtr<nsIRunnable> task(NS_NewRunnableMethod(
       this, &GeckoMediaPluginService::SetAsyncShutdownComplete));
     NS_DispatchToMainThread(task);
   }
 }
 
 void
 GeckoMediaPluginService::CrashPlugins()
 {
--- a/dom/media/gtest/TestGMPCrossOrigin.cpp
+++ b/dom/media/gtest/TestGMPCrossOrigin.cpp
@@ -216,18 +216,18 @@ public:
       nsCOMPtr<nsIThread> thread(GetGMPThread());
       thread->Dispatch(mContinuation, NS_DISPATCH_NORMAL);
     }
     return NS_OK;
   }
 
 private:
   virtual ~GMPShutdownObserver() {}
-  nsRefPtr<nsIRunnable> mShutdownTask;
-  nsRefPtr<nsIRunnable> mContinuation;
+  nsCOMPtr<nsIRunnable> mShutdownTask;
+  nsCOMPtr<nsIRunnable> mContinuation;
   const nsString mNodeId;
 };
 
 NS_IMPL_ISUPPORTS(GMPShutdownObserver, nsIRunnable, nsIObserver)
 
 class NotifyObserversTask : public nsRunnable {
 public:
   explicit NotifyObserversTask(const char* aTopic)
@@ -285,17 +285,17 @@ public:
       observerService->RemoveObserver(this, "gmp-clear-storage-complete");
       mTarget->Dispatch(mContinuation, NS_DISPATCH_NORMAL);
     }
     return NS_OK;
   }
 
 private:
   virtual ~ClearGMPStorageTask() {}
-  nsRefPtr<nsIRunnable> mContinuation;
+  nsCOMPtr<nsIRunnable> mContinuation;
   nsCOMPtr<nsIThread> mTarget;
   const PRTime mSince;
 };
 
 NS_IMPL_ISUPPORTS(ClearGMPStorageTask, nsIRunnable, nsIObserver)
 
 static void
 ClearGMPStorage(nsIRunnable* aContinuation,
@@ -1088,17 +1088,17 @@ class GMPStorageTest : public GMPDecrypt
   {
     MonitorAutoLock mon(mMonitor);
 
     nsCString msg((const char*)aMessage.Elements(), aMessage.Length());
     EXPECT_TRUE(mExpected.Length() > 0);
     bool matches = mExpected[0].mMessage.Equals(msg);
     EXPECT_STREQ(mExpected[0].mMessage.get(), msg.get());
     if (mExpected.Length() > 0 && matches) {
-      nsRefPtr<nsIRunnable> continuation = mExpected[0].mContinuation;
+      nsCOMPtr<nsIRunnable> continuation = mExpected[0].mContinuation;
       mExpected.RemoveElementAt(0);
       if (continuation) {
         NS_DispatchToCurrentThread(continuation);
       }
     }
   }
 
   virtual void SetSessionId(uint32_t aCreateSessionToken,
@@ -1129,17 +1129,17 @@ private:
   ~GMPStorageTest() { }
 
   struct ExpectedMessage {
     ExpectedMessage(const nsCString& aMessage, nsIRunnable* aContinuation)
       : mMessage(aMessage)
       , mContinuation(aContinuation)
     {}
     nsCString mMessage;
-    nsRefPtr<nsIRunnable> mContinuation;
+    nsCOMPtr<nsIRunnable> mContinuation;
   };
 
   nsTArray<ExpectedMessage> mExpected;
 
   GMPDecryptorProxy* mDecryptor;
   Monitor mMonitor;
   Atomic<bool> mFinished;
   nsCString mNodeId;
--- a/dom/media/mediasource/MediaSource.cpp
+++ b/dom/media/mediasource/MediaSource.cpp
@@ -502,17 +502,17 @@ void
 MediaSource::QueueInitializationEvent()
 {
   MOZ_ASSERT(NS_IsMainThread());
   if (mFirstSourceBufferInitialized) {
     return;
   }
   mFirstSourceBufferInitialized = true;
   MSE_DEBUG("");
-  nsRefPtr<nsIRunnable> task =
+  nsCOMPtr<nsIRunnable> task =
     NS_NewRunnableMethod(this, &MediaSource::InitializationEvent);
   NS_DispatchToMainThread(task);
 }
 
 void
 MediaSource::InitializationEvent()
 {
   MOZ_ASSERT(NS_IsMainThread());
--- a/dom/media/mediasource/MediaSourceDecoder.cpp
+++ b/dom/media/mediasource/MediaSourceDecoder.cpp
@@ -256,17 +256,17 @@ MediaSourceDecoder::ScheduleDurationChan
       nsCOMPtr<nsIRunnable> task =
         NS_NewRunnableMethod(this, &MediaDecoder::DurationChanged);
       NS_DispatchToMainThread(task);
     }
   } else {
     if (NS_IsMainThread()) {
       DurationChanged(aOldDuration, aNewDuration);
     } else {
-      nsRefPtr<nsIRunnable> task =
+      nsCOMPtr<nsIRunnable> task =
         new DurationChangedRunnable(this, aOldDuration, aNewDuration);
       NS_DispatchToMainThread(task);
     }
   }
 }
 
 double
 MediaSourceDecoder::GetMediaSourceDuration()
--- a/dom/media/mediasource/SourceBuffer.cpp
+++ b/dom/media/mediasource/SourceBuffer.cpp
@@ -263,26 +263,26 @@ SourceBuffer::Remove(double aStart, doub
     aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
     return;
   }
   if (mMediaSource->ReadyState() == MediaSourceReadyState::Ended) {
     mMediaSource->SetReadyState(MediaSourceReadyState::Open);
   }
 
   StartUpdating();
-  nsRefPtr<nsIRunnable> task = new RangeRemovalRunnable(this, aStart, aEnd);
+  nsCOMPtr<nsIRunnable> task = new RangeRemovalRunnable(this, aStart, aEnd);
   NS_DispatchToMainThread(task);
 }
 
 void
 SourceBuffer::RangeRemoval(double aStart, double aEnd)
 {
   StartUpdating();
   DoRangeRemoval(aStart, aEnd);
-  nsRefPtr<nsIRunnable> task =
+  nsCOMPtr<nsIRunnable> task =
     NS_NewRunnableMethod(this, &SourceBuffer::StopUpdating);
   NS_DispatchToMainThread(task);
 }
 
 void
 SourceBuffer::DoRangeRemoval(double aStart, double aEnd)
 {
   MSE_DEBUG("DoRangeRemoval(%f, %f)", aStart, aEnd);
@@ -427,17 +427,17 @@ SourceBuffer::AppendData(const uint8_t* 
   nsRefPtr<LargeDataBuffer> data = PrepareAppend(aData, aLength, aRv);
   if (!data) {
     return;
   }
   StartUpdating();
 
   MOZ_ASSERT(mAppendMode == SourceBufferAppendMode::Segments,
              "We don't handle timestampOffset for sequence mode yet");
-  nsRefPtr<nsIRunnable> task =
+  nsCOMPtr<nsIRunnable> task =
     new AppendDataRunnable(this, data, mTimestampOffset, mUpdateID);
   NS_DispatchToMainThread(task);
 }
 
 void
 SourceBuffer::AppendData(LargeDataBuffer* aData, double aTimestampOffset,
                          uint32_t aUpdateID)
 {
--- a/dom/media/webaudio/AudioNode.cpp
+++ b/dom/media/webaudio/AudioNode.cpp
@@ -346,17 +346,17 @@ AudioNode::Disconnect(uint32_t aOutput, 
       if (input.mInputNode == this && input.mOutputPort == aOutput) {
         // Destroying the InputNode here sends a message to the graph thread
         // to disconnect the streams, which should be sent before the
         // RunAfterPendingUpdates() call below.
         dest->mInputNodes.RemoveElementAt(j);
         // Remove one instance of 'dest' from mOutputNodes. There could be
         // others, and it's not correct to remove them all since some of them
         // could be for different output ports.
-        nsRefPtr<nsIRunnable> runnable =
+        nsCOMPtr<nsIRunnable> runnable =
           new RunnableRelease(mOutputNodes[i].forget());
         mOutputNodes.RemoveElementAt(i);
         mStream->RunAfterPendingUpdates(runnable.forget());
         break;
       }
     }
   }
 
--- a/dom/promise/Promise.cpp
+++ b/dom/promise/Promise.cpp
@@ -414,25 +414,25 @@ void
 Promise::MaybeReject(const nsRefPtr<MediaStreamError>& aArg) {
   MaybeSomething(aArg, &Promise::MaybeReject);
 }
 
 bool
 Promise::PerformMicroTaskCheckpoint()
 {
   CycleCollectedJSRuntime* runtime = CycleCollectedJSRuntime::Get();
-  nsTArray<nsRefPtr<nsIRunnable>>& microtaskQueue =
+  nsTArray<nsCOMPtr<nsIRunnable>>& microtaskQueue =
     runtime->GetPromiseMicroTaskQueue();
 
   if (microtaskQueue.IsEmpty()) {
     return false;
   }
 
   do {
-    nsRefPtr<nsIRunnable> runnable = microtaskQueue.ElementAt(0);
+    nsCOMPtr<nsIRunnable> runnable = microtaskQueue.ElementAt(0);
     MOZ_ASSERT(runnable);
 
     // This function can re-enter, so we remove the element before calling.
     microtaskQueue.RemoveElementAt(0);
     runnable->Run();
   } while (!microtaskQueue.IsEmpty());
 
   return true;
@@ -1060,17 +1060,17 @@ private:
 };
 
 /* static */ void
 Promise::DispatchToMicroTask(nsIRunnable* aRunnable)
 {
   MOZ_ASSERT(aRunnable);
 
   CycleCollectedJSRuntime* runtime = CycleCollectedJSRuntime::Get();
-  nsTArray<nsRefPtr<nsIRunnable>>& microtaskQueue =
+  nsTArray<nsCOMPtr<nsIRunnable>>& microtaskQueue =
     runtime->GetPromiseMicroTaskQueue();
 
   microtaskQueue.AppendElement(aRunnable);
 }
 
 void
 Promise::MaybeReportRejected()
 {
--- a/dom/workers/ServiceWorkerManager.cpp
+++ b/dom/workers/ServiceWorkerManager.cpp
@@ -1292,17 +1292,17 @@ ServiceWorkerManager::GetRegistrations(n
 
   nsCOMPtr<nsIGlobalObject> sgo = do_QueryInterface(window);
   ErrorResult result;
   nsRefPtr<Promise> promise = Promise::Create(sgo, result);
   if (result.Failed()) {
     return result.ErrorCode();
   }
 
-  nsRefPtr<nsIRunnable> runnable =
+  nsCOMPtr<nsIRunnable> runnable =
     new GetRegistrationsRunnable(window, promise);
   promise.forget(aPromise);
   return NS_DispatchToCurrentThread(runnable);
 }
 
 /*
  * Implements the async aspects of the getRegistration algorithm.
  */
@@ -1393,17 +1393,17 @@ ServiceWorkerManager::GetRegistration(ns
 
   nsCOMPtr<nsIGlobalObject> sgo = do_QueryInterface(window);
   ErrorResult result;
   nsRefPtr<Promise> promise = Promise::Create(sgo, result);
   if (result.Failed()) {
     return result.ErrorCode();
   }
 
-  nsRefPtr<nsIRunnable> runnable =
+  nsCOMPtr<nsIRunnable> runnable =
     new GetRegistrationRunnable(window, promise, aDocumentURL);
   promise.forget(aPromise);
   return NS_DispatchToCurrentThread(runnable);
 }
 
 class GetReadyPromiseRunnable : public nsRunnable
 {
   nsCOMPtr<nsPIDOMWindow> mWindow;
@@ -1459,17 +1459,17 @@ ServiceWorkerManager::GetReadyPromise(ns
 
   nsCOMPtr<nsIGlobalObject> sgo = do_QueryInterface(window);
   ErrorResult result;
   nsRefPtr<Promise> promise = Promise::Create(sgo, result);
   if (result.Failed()) {
     return result.ErrorCode();
   }
 
-  nsRefPtr<nsIRunnable> runnable =
+  nsCOMPtr<nsIRunnable> runnable =
     new GetReadyPromiseRunnable(window, promise);
   promise.forget(aPromise);
   return NS_DispatchToCurrentThread(runnable);
 }
 
 NS_IMETHODIMP
 ServiceWorkerManager::RemoveReadyPromise(nsIDOMWindow* aWindow)
 {
--- a/gfx/gl/AndroidSurfaceTexture.h
+++ b/gfx/gl/AndroidSurfaceTexture.h
@@ -104,17 +104,17 @@ private:
   widget::sdk::Surface::GlobalRef mSurface;
 
   Monitor mMonitor;
   GLContext* mAttachedContext;
   bool mCanDetach;
 
   RefPtr<AndroidNativeWindow> mNativeWindow;
   int mID;
-  nsRefPtr<nsIRunnable> mFrameAvailableCallback;
+  nsCOMPtr<nsIRunnable> mFrameAvailableCallback;
 };
 
 }
 }
 
 
 #endif
 #endif
--- a/layout/ipc/VsyncParent.cpp
+++ b/layout/ipc/VsyncParent.cpp
@@ -44,17 +44,17 @@ VsyncParent::~VsyncParent()
   // VsyncParent is always released on the background thread.
 }
 
 bool
 VsyncParent::NotifyVsync(TimeStamp aTimeStamp)
 {
   // Called on hardware vsync thread. We should post to current ipc thread.
   MOZ_ASSERT(!IsOnBackgroundThread());
-  nsRefPtr<nsIRunnable> vsyncEvent =
+  nsCOMPtr<nsIRunnable> vsyncEvent =
     NS_NewRunnableMethodWithArg<TimeStamp>(this,
                                            &VsyncParent::DispatchVsyncEvent,
                                            aTimeStamp);
   MOZ_ALWAYS_TRUE(NS_SUCCEEDED(mBackgroundThread->Dispatch(vsyncEvent, NS_DISPATCH_NORMAL)));
   return true;
 }
 
 void
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.h
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.h
@@ -89,17 +89,17 @@ private:
 
   // We cannot form offers/answers properly until the Gecko Media Plugin stuff
   // has been initted, which is a complicated mess of thread dispatches,
   // including sync dispatches to main. So, we need to be able to queue up
   // offer creation (or SetRemote, when we're the answerer) until all of this is
   // ready to go, since blocking on this init is just begging for deadlock.
   nsCOMPtr<mozIGeckoMediaPluginService> mGMPService;
   bool mGMPReady;
-  nsTArray<nsRefPtr<nsIRunnable>> mQueuedJSEPOperations;
+  nsTArray<nsCOMPtr<nsIRunnable>> mQueuedJSEPOperations;
 
   static PeerConnectionCtx *gInstance;
 public:
   static nsIThread *gMainThread;
   static mozilla::StaticRefPtr<mozilla::PeerConnectionCtxShutdown> gPeerConnectionCtxShutdown;
 };
 
 }  // namespace mozilla
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp
@@ -386,17 +386,17 @@ PeerConnectionMedia::StartIceChecks(cons
     } else {
       CSFLogDebug(logTag, "Transport %s has %u components",
                           transport->mTransportId.c_str(),
                           static_cast<unsigned>(transport->mComponents));
       numComponentsByLevel.push_back(transport->mComponents);
     }
   }
 
-  nsRefPtr<nsIRunnable> runnable(
+  nsCOMPtr<nsIRunnable> runnable(
       WrapRunnable(
         RefPtr<PeerConnectionMedia>(this),
         &PeerConnectionMedia::StartIceChecks_s,
         session.IsIceControlling(),
         session.RemoteIsIceLite(),
         // Copy, just in case API changes to return a ref
         std::vector<std::string>(session.GetIceOptions()),
         numComponentsByLevel));
@@ -511,17 +511,17 @@ PeerConnectionMedia::PerformOrEnqueueIce
     mQueuedIceCtxOperations.push_back(runnable);
   }
 }
 
 void
 PeerConnectionMedia::GatherIfReady() {
   ASSERT_ON_THREAD(mMainThread);
 
-  nsRefPtr<nsIRunnable> runnable(WrapRunnable(
+  nsCOMPtr<nsIRunnable> runnable(WrapRunnable(
         RefPtr<PeerConnectionMedia>(this),
         &PeerConnectionMedia::EnsureIceGathering_s));
 
   PerformOrEnqueueIceCtxOperation(runnable);
 }
 
 void
 PeerConnectionMedia::EnsureIceGathering_s() {
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h
@@ -495,17 +495,17 @@ class PeerConnectionMedia : public sigsl
 
   // The STS thread.
   nsCOMPtr<nsIEventTarget> mSTSThread;
 
   // Used whenever we need to dispatch a runnable to STS to tweak something
   // on our ICE ctx, but are not ready to do so at the moment (eg; we are
   // waiting to get a callback with our http proxy config before we start
   // gathering or start checking)
-  std::vector<nsRefPtr<nsIRunnable>> mQueuedIceCtxOperations;
+  std::vector<nsCOMPtr<nsIRunnable>> mQueuedIceCtxOperations;
 
   // Used to cancel any ongoing proxy request.
   nsCOMPtr<nsICancelable> mProxyRequest;
 
   // Used to track the state of the request.
   bool mProxyResolveCompleted;
 
   // Used to store the result of the request.
--- a/netwerk/base/NetworkActivityMonitor.cpp
+++ b/netwerk/base/NetworkActivityMonitor.cpp
@@ -291,11 +291,11 @@ NetworkActivityMonitor::DataInOut(Direct
   }
 
   return NS_OK;
 }
 
 void
 NetworkActivityMonitor::PostNotification(Direction direction)
 {
-  nsRefPtr<nsIRunnable> ev = new NotifyNetworkActivity(direction);
+  nsCOMPtr<nsIRunnable> ev = new NotifyNetworkActivity(direction);
   NS_DispatchToMainThread(ev);
 }
--- a/netwerk/base/OfflineObserver.cpp
+++ b/netwerk/base/OfflineObserver.cpp
@@ -16,29 +16,29 @@ namespace net {
 NS_IMPL_ISUPPORTS(OfflineObserver, nsIObserver)
 
 void
 OfflineObserver::RegisterOfflineObserver()
 {
   if (NS_IsMainThread()) {
     RegisterOfflineObserverMainThread();
   } else {
-    nsRefPtr<nsIRunnable> event =
+    nsCOMPtr<nsIRunnable> event =
       NS_NewRunnableMethod(this, &OfflineObserver::RegisterOfflineObserverMainThread);
     NS_DispatchToMainThread(event);
   }
 }
 
 void
 OfflineObserver::RemoveOfflineObserver()
 {
   if (NS_IsMainThread()) {
     RemoveOfflineObserverMainThread();
   } else {
-    nsRefPtr<nsIRunnable> event =
+    nsCOMPtr<nsIRunnable> event =
       NS_NewRunnableMethod(this, &OfflineObserver::RemoveOfflineObserverMainThread);
     NS_DispatchToMainThread(event);
   }
 }
 
 void
 OfflineObserver::RegisterOfflineObserverMainThread()
 {
--- a/netwerk/base/Tickler.cpp
+++ b/netwerk/base/Tickler.cpp
@@ -54,17 +54,17 @@ private:
 Tickler::~Tickler()
 {
   // non main thread uses of the tickler should hold weak
   // references to it if they must hold a reference at all
   MOZ_ASSERT(NS_IsMainThread());
 
   // Shutting down a thread can spin the event loop - which is a surprising
   // thing to do from a dtor. Running it on its own event is safer.
-  nsRefPtr<nsIRunnable> event = new TicklerThreadDestructor(mThread);
+  nsCOMPtr<nsIRunnable> event = new TicklerThreadDestructor(mThread);
   if (NS_FAILED(NS_DispatchToCurrentThread(event))) {
     mThread->Shutdown();
   }
   mThread = nullptr;
 
   if (mTimer)
     mTimer->Cancel();
   if (mFD)
--- a/netwerk/base/nsAsyncRedirectVerifyHelper.cpp
+++ b/netwerk/base/nsAsyncRedirectVerifyHelper.cpp
@@ -177,17 +177,17 @@ nsAsyncRedirectVerifyHelper::ExplicitCal
              "callback=%p mCallbackThread=%p", callback.get(), mCallbackThread.get()));
         return;
     }
 
     mCallbackInitiated = false;  // reset to ensure only one callback
     mWaitingForRedirectCallback = false;
 
     // Now, dispatch the callback on the event-target which called Init()
-    nsRefPtr<nsIRunnable> event =
+    nsCOMPtr<nsIRunnable> event =
         new nsAsyncVerifyRedirectCallbackEvent(callback, result);
     if (!event) {
         NS_WARNING("nsAsyncRedirectVerifyHelper::ExplicitCallback() "
                    "failed creating callback event!");
         return;
     }
     nsresult rv = mCallbackThread->Dispatch(event, NS_DISPATCH_NORMAL);
     if (NS_FAILED(rv)) {
--- a/netwerk/cache/nsCacheEntryDescriptor.cpp
+++ b/netwerk/cache/nsCacheEntryDescriptor.cpp
@@ -531,17 +531,17 @@ nsCacheEntryDescriptor::AsyncDoom(nsICac
                 new nsNotifyDoomListener(listener, NS_ERROR_NOT_AVAILABLE));
             if (NS_SUCCEEDED(rv))
                 NS_IF_ADDREF(listener);
             return rv;
         }
         return NS_OK;
     }
 
-    nsRefPtr<nsIRunnable> event = new nsAsyncDoomEvent(this, listener);
+    nsCOMPtr<nsIRunnable> event = new nsAsyncDoomEvent(this, listener);
     return nsCacheService::DispatchToCacheIOThread(event);
 }
 
 
 NS_IMETHODIMP
 nsCacheEntryDescriptor::MarkValid()
 {
     nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHEENTRYDESCRIPTOR_MARKVALID));
--- a/netwerk/cache/nsDiskCacheDeviceSQL.cpp
+++ b/netwerk/cache/nsDiskCacheDeviceSQL.cpp
@@ -752,17 +752,17 @@ nsApplicationCache::Activate()
 NS_IMETHODIMP
 nsApplicationCache::Discard()
 {
   NS_ENSURE_TRUE(mValid, NS_ERROR_NOT_AVAILABLE);
   NS_ENSURE_TRUE(mDevice, NS_ERROR_NOT_AVAILABLE);
 
   mValid = false;
 
-  nsRefPtr<nsIRunnable> ev =
+  nsCOMPtr<nsIRunnable> ev =
     new nsOfflineCacheDiscardCache(mDevice, mGroup, mClientID);
   nsresult rv = nsCacheService::DispatchToCacheIOThread(ev);
   return rv;
 }
 
 NS_IMETHODIMP
 nsApplicationCache::MarkEntry(const nsACString &key,
                               uint32_t typeBits)
--- a/netwerk/cache2/CacheIOThread.cpp
+++ b/netwerk/cache2/CacheIOThread.cpp
@@ -259,17 +259,17 @@ static const char* const sLevelTraceName
   "net::cache::io::level(12)"
 };
 
 void CacheIOThread::LoopOneLevel(uint32_t aLevel)
 {
   eventtracer::AutoEventTracer tracer(this, eventtracer::eExec, eventtracer::eDone,
     sLevelTraceName[aLevel]);
 
-  nsTArray<nsRefPtr<nsIRunnable> > events;
+  nsTArray<nsCOMPtr<nsIRunnable> > events;
   events.SwapElements(mEventQueue[aLevel]);
   uint32_t length = events.Length();
 
   mCurrentlyExecutingLevel = aLevel;
 
   bool returnEvents = false;
   uint32_t index;
   {
--- a/netwerk/cache2/CacheIOThread.h
+++ b/netwerk/cache2/CacheIOThread.h
@@ -84,17 +84,17 @@ private:
 
   static CacheIOThread* sSelf;
 
   mozilla::Monitor mMonitor;
   PRThread* mThread;
   nsCOMPtr<nsIThread> mXPCOMThread;
   uint32_t mLowestLevelWaiting;
   uint32_t mCurrentlyExecutingLevel;
-  nsTArray<nsRefPtr<nsIRunnable> > mEventQueue[LAST_LEVEL];
+  nsTArray<nsCOMPtr<nsIRunnable> > mEventQueue[LAST_LEVEL];
 
   bool mHasXPCOMEvents;
   bool mRerunCurrentEvent;
   bool mShutdown;
 };
 
 } // net
 } // mozilla
--- a/netwerk/protocol/http/nsHttpActivityDistributor.cpp
+++ b/netwerk/protocol/http/nsHttpActivityDistributor.cpp
@@ -77,17 +77,17 @@ nsHttpActivityDistributor::~nsHttpActivi
 NS_IMETHODIMP
 nsHttpActivityDistributor::ObserveActivity(nsISupports *aHttpChannel,
                                            uint32_t aActivityType,
                                            uint32_t aActivitySubtype,
                                            PRTime aTimestamp,
                                            uint64_t aExtraSizeData,
                                            const nsACString & aExtraStringData)
 {
-    nsRefPtr<nsIRunnable> event;
+    nsCOMPtr<nsIRunnable> event;
     {
         MutexAutoLock lock(mLock);
 
         if (!mObservers.Length())
             return NS_OK;
 
         event = new nsHttpActivityEvent(aHttpChannel, aActivityType,
                                         aActivitySubtype, aTimestamp,
--- a/netwerk/protocol/http/nsHttpConnectionMgr.cpp
+++ b/netwerk/protocol/http/nsHttpConnectionMgr.cpp
@@ -190,17 +190,17 @@ nsHttpConnectionMgr::PostEvent(nsConnEve
     ReentrantMonitorAutoEnter mon(mReentrantMonitor);
 
     nsresult rv;
     if (!mSocketThreadTarget) {
         NS_WARNING("cannot post event if not initialized");
         rv = NS_ERROR_NOT_INITIALIZED;
     }
     else {
-        nsRefPtr<nsIRunnable> event = new nsConnEvent(this, handler, iparam, vparam);
+        nsCOMPtr<nsIRunnable> event = new nsConnEvent(this, handler, iparam, vparam);
         rv = mSocketThreadTarget->Dispatch(event, NS_DISPATCH_NORMAL);
     }
     return rv;
 }
 
 void
 nsHttpConnectionMgr::PruneDeadConnectionsAfter(uint32_t timeInSeconds)
 {
@@ -2371,17 +2371,17 @@ nsHttpConnectionMgr::OnMsgShutdown(int32
       mTimer = nullptr;
     }
     if (mTrafficTimer) {
       mTrafficTimer->Cancel();
       mTrafficTimer = nullptr;
     }
 
     // signal shutdown complete
-    nsRefPtr<nsIRunnable> runnable =
+    nsCOMPtr<nsIRunnable> runnable =
         new nsConnEvent(this, &nsHttpConnectionMgr::OnMsgShutdownConfirm,
                         0, param);
     NS_DispatchToMainThread(runnable);
 }
 
 void
 nsHttpConnectionMgr::OnMsgShutdownConfirm(int32_t priority, void *param)
 {
--- a/widget/android/AndroidJNIWrapper.cpp
+++ b/widget/android/AndroidJNIWrapper.cpp
@@ -55,17 +55,17 @@ extern "C" {
   __attribute__ ((visibility("default")))
   jclass
   jsjni_GetGlobalClassRef(const char *className) {
     nsCOMPtr<nsIThread> mainThread;
     mozilla::DebugOnly<nsresult> rv = NS_GetMainThread(getter_AddRefs(mainThread));
     MOZ_ASSERT(NS_SUCCEEDED(rv));
 
     jclass foundClass;
-    nsRefPtr<nsIRunnable> runnable_ref(new GetGlobalClassRefRunnable(className,
+    nsCOMPtr<nsIRunnable> runnable_ref(new GetGlobalClassRefRunnable(className,
                                                                      &foundClass));
     mainThread->Dispatch(runnable_ref, NS_DISPATCH_SYNC);
     if (!foundClass)
       return nullptr;
 
     return foundClass;
   }
 
--- a/xpcom/base/AvailableMemoryTracker.cpp
+++ b/xpcom/base/AvailableMemoryTracker.cpp
@@ -464,17 +464,17 @@ nsMemoryPressureWatcher::Init()
  */
 NS_IMETHODIMP
 nsMemoryPressureWatcher::Observe(nsISupports* aSubject, const char* aTopic,
                                  const char16_t* aData)
 {
   MOZ_ASSERT(!strcmp(aTopic, "memory-pressure"), "Unknown topic");
 
   if (sFreeDirtyPages) {
-    nsRefPtr<nsIRunnable> runnable = new nsJemallocFreeDirtyPagesRunnable();
+    nsCOMPtr<nsIRunnable> runnable = new nsJemallocFreeDirtyPagesRunnable();
 
     NS_DispatchToMainThread(runnable);
   }
 
   return NS_OK;
 }
 
 } // anonymous namespace
--- a/xpcom/base/CycleCollectedJSRuntime.cpp
+++ b/xpcom/base/CycleCollectedJSRuntime.cpp
@@ -932,17 +932,17 @@ CycleCollectedJSRuntime::GetPendingExcep
 }
 
 void
 CycleCollectedJSRuntime::SetPendingException(nsIException* aException)
 {
   mPendingException = aException;
 }
 
-nsTArray<nsRefPtr<nsIRunnable>>&
+nsTArray<nsCOMPtr<nsIRunnable>>&
 CycleCollectedJSRuntime::GetPromiseMicroTaskQueue()
 {
   return mPromiseMicroTaskQueue;
 }
 
 nsCycleCollectionParticipant*
 CycleCollectedJSRuntime::GCThingParticipant()
 {
--- a/xpcom/base/CycleCollectedJSRuntime.h
+++ b/xpcom/base/CycleCollectedJSRuntime.h
@@ -254,17 +254,17 @@ public:
 #ifdef DEBUG
   bool IsJSHolder(void* aHolder);
   void AssertNoObjectsToTrace(void* aPossibleJSHolder);
 #endif
 
   already_AddRefed<nsIException> GetPendingException() const;
   void SetPendingException(nsIException* aException);
 
-  nsTArray<nsRefPtr<nsIRunnable>>& GetPromiseMicroTaskQueue();
+  nsTArray<nsCOMPtr<nsIRunnable>>& GetPromiseMicroTaskQueue();
 
   nsCycleCollectionParticipant* GCThingParticipant();
   nsCycleCollectionParticipant* ZoneParticipant();
 
   nsresult TraverseRoots(nsCycleCollectionNoteRootCallback& aCb);
   bool UsefulToMergeZones() const;
   void FixWeakMappingGrayBits() const;
   bool AreGCGrayBitsValid() const;
@@ -304,17 +304,17 @@ private:
   typedef nsDataHashtable<nsFuncPtrHashKey<DeferredFinalizeFunction>, void*>
     DeferredFinalizerTable;
   DeferredFinalizerTable mDeferredFinalizerTable;
 
   nsRefPtr<IncrementalFinalizeRunnable> mFinalizeRunnable;
 
   nsCOMPtr<nsIException> mPendingException;
 
-  nsTArray<nsRefPtr<nsIRunnable>> mPromiseMicroTaskQueue;
+  nsTArray<nsCOMPtr<nsIRunnable>> mPromiseMicroTaskQueue;
 
   OOMState mOutOfMemoryState;
   OOMState mLargeAllocationFailureState;
 };
 
 void TraceScriptHolder(nsISupports* aHolder, JSTracer* aTracer);
 
 // Returns true if the JSGCTraceKind is one the cycle collector cares about.
--- a/xpcom/glue/nsProxyRelease.cpp
+++ b/xpcom/glue/nsProxyRelease.cpp
@@ -43,17 +43,17 @@ NS_ProxyRelease(nsIEventTarget* aTarget,
     bool onCurrentThread = false;
     rv = aTarget->IsOnCurrentThread(&onCurrentThread);
     if (NS_SUCCEEDED(rv) && onCurrentThread) {
       NS_RELEASE(aDoomed);
       return NS_OK;
     }
   }
 
-  nsRefPtr<nsIRunnable> ev = new nsProxyReleaseEvent(aDoomed);
+  nsCOMPtr<nsIRunnable> ev = new nsProxyReleaseEvent(aDoomed);
   if (!ev) {
     // we do not release aDoomed here since it may cause a delete on the
     // wrong thread.  better to leak than crash.
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   rv = aTarget->Dispatch(ev, NS_DISPATCH_NORMAL);
   if (NS_FAILED(rv)) {
--- a/xpcom/io/nsInputStreamTee.cpp
+++ b/xpcom/io/nsInputStreamTee.cpp
@@ -167,17 +167,17 @@ nsInputStreamTee::TeeSegment(const char*
   if (!mSink) {
     return NS_OK;  // nothing to do
   }
   if (mLock) { // asynchronous case
     NS_ASSERTION(mEventTarget, "mEventTarget is null, mLock is not null.");
     if (!SinkIsValid()) {
       return NS_OK; // nothing to do
     }
-    nsRefPtr<nsIRunnable> event =
+    nsCOMPtr<nsIRunnable> event =
       new nsInputStreamTeeWriteEvent(aBuf, aCount, mSink, this);
     LOG(("nsInputStreamTee::TeeSegment [%p] dispatching write %u bytes\n",
          this, aCount));
     return mEventTarget->Dispatch(event, NS_DISPATCH_NORMAL);
   } else { // synchronous case
     NS_ASSERTION(!mEventTarget, "mEventTarget is not null, mLock is null.");
     nsresult rv;
     uint32_t totalBytesWritten = 0;
--- a/xpcom/threads/nsEventQueue.cpp
+++ b/xpcom/threads/nsEventQueue.cpp
@@ -83,17 +83,17 @@ nsEventQueue::GetEvent(bool aMayWait, ns
 
   return true;
 }
 
 void
 nsEventQueue::PutEvent(nsIRunnable* aRunnable)
 {
   // Avoid calling AddRef+Release while holding our monitor.
-  nsRefPtr<nsIRunnable> event(aRunnable);
+  nsCOMPtr<nsIRunnable> event(aRunnable);
 
   if (ChaosMode::isActive(ChaosMode::ThreadScheduling)) {
     // With probability 0.5, yield so other threads have a chance to
     // dispatch events to this queue first.
     if (ChaosMode::randomUint32LessThan(2)) {
       PR_Sleep(PR_INTERVAL_NO_WAIT);
     }
   }
--- a/xpcom/threads/nsThread.cpp
+++ b/xpcom/threads/nsThread.cpp
@@ -545,17 +545,17 @@ nsThread::DispatchInternal(nsIRunnable* 
     return NS_ERROR_INVALID_ARG;
   }
 
   if (gXPCOMThreadsShutDown && MAIN_THREAD != mIsMainThread && !aTarget) {
     return NS_ERROR_ILLEGAL_DURING_SHUTDOWN;
   }
 
 #ifdef MOZ_TASK_TRACER
-  nsRefPtr<nsIRunnable> tracedRunnable = CreateTracedRunnable(aEvent);
+  nsCOMPtr<nsIRunnable> tracedRunnable = CreateTracedRunnable(aEvent);
   aEvent = tracedRunnable;
 #endif
 
   if (aFlags & DISPATCH_SYNC) {
     nsThread* thread = nsThreadManager::get()->GetCurrentThread();
     if (NS_WARN_IF(!thread)) {
       return NS_ERROR_NOT_AVAILABLE;
     }
--- a/xpcom/threads/nsThreadPool.cpp
+++ b/xpcom/threads/nsThreadPool.cpp
@@ -117,17 +117,17 @@ nsThreadPool::PutEvent(nsIRunnable* aEve
   LOG(("THRD-P(%p) put [%p kill=%d]\n", this, thread.get(), killThread));
   if (killThread) {
     // Pending events are processed on the current thread during
     // nsIThread::Shutdown() execution, so if nsThreadPool::Dispatch() is called
     // under caller's lock then deadlock could occur. This happens e.g. in case
     // of nsStreamCopier. To prevent this situation, dispatch a shutdown event
     // to the current thread instead of calling nsIThread::Shutdown() directly.
 
-    nsRefPtr<nsIRunnable> r = NS_NewRunnableMethod(thread,
+    nsCOMPtr<nsIRunnable> r = NS_NewRunnableMethod(thread,
                                                    &nsIThread::Shutdown);
     NS_DispatchToCurrentThread(r);
   } else {
     thread->Dispatch(this, NS_DISPATCH_NORMAL);
   }
 
   return NS_OK;
 }
@@ -137,17 +137,17 @@ nsThreadPool::ShutdownThread(nsIThread* 
 {
   LOG(("THRD-P(%p) shutdown async [%p]\n", this, aThread));
 
   // This method is responsible for calling Shutdown on |aThread|.  This must be
   // done from some other thread, so we use the main thread of the application.
 
   MOZ_ASSERT(!NS_IsMainThread(), "wrong thread");
 
-  nsRefPtr<nsIRunnable> r = NS_NewRunnableMethod(aThread, &nsIThread::Shutdown);
+  nsCOMPtr<nsIRunnable> r = NS_NewRunnableMethod(aThread, &nsIThread::Shutdown);
   NS_DispatchToMainThread(r);
 }
 
 NS_IMETHODIMP
 nsThreadPool::Run()
 {
   LOG(("THRD-P(%p) enter\n", this));
   mThreadNaming.SetThreadPoolName(mName);