From 941ab1f522464cda27bc78f49a32915a3388d88c Mon Sep 17 00:00:00 2001 From: Kyle Huey Date: Thu, 5 May 2016 01:45:00 -0700 Subject: [PATCH] Bug 1268313: Part 7 - Move NS_NewRunnableMethod and friends to mozilla::NewRunnableMethod. r=froydnj --- docshell/shistory/nsSHistory.cpp | 6 +- dom/animation/Animation.cpp | 2 +- dom/archivereader/ArchiveEvent.cpp | 3 +- dom/base/Element.cpp | 2 +- dom/base/EventSource.cpp | 21 +--- dom/base/ScreenOrientation.cpp | 4 +- dom/base/nsContentSink.cpp | 2 +- dom/base/nsContentUtils.cpp | 17 ++- dom/base/nsContentUtils.h | 1 + dom/base/nsDOMWindowUtils.cpp | 14 +-- dom/base/nsDocument.cpp | 20 ++-- dom/base/nsGlobalWindow.cpp | 10 +- dom/base/nsScriptLoader.cpp | 14 +-- dom/base/nsTextNode.cpp | 3 +- dom/cache/Context.cpp | 9 +- dom/cache/Manager.cpp | 6 +- dom/camera/CameraPreviewMediaStream.cpp | 8 +- dom/camera/DOMCameraControl.cpp | 6 +- dom/camera/DOMCameraManager.cpp | 6 +- dom/devicestorage/DeviceStorageStatics.cpp | 4 +- dom/events/EventListenerService.cpp | 5 +- dom/fetch/FetchDriver.cpp | 4 +- dom/html/HTMLCanvasElement.cpp | 4 +- dom/html/HTMLImageElement.cpp | 4 +- dom/html/HTMLInputElement.cpp | 2 +- dom/html/HTMLLinkElement.cpp | 4 +- dom/html/HTMLMediaElement.cpp | 22 ++-- dom/html/HTMLObjectElement.cpp | 2 +- dom/html/HTMLSharedObjectElement.cpp | 2 +- dom/html/HTMLStyleElement.cpp | 2 +- dom/html/HTMLTrackElement.cpp | 6 +- dom/html/ImageDocument.cpp | 4 +- dom/html/nsHTMLDocument.cpp | 2 +- dom/indexedDB/ActorsParent.cpp | 6 +- dom/indexedDB/FileSnapshot.cpp | 2 +- dom/indexedDB/IDBDatabase.cpp | 6 +- dom/ipc/Blob.cpp | 16 +-- dom/ipc/ContentBridgeChild.cpp | 3 +- dom/ipc/ContentBridgeParent.cpp | 6 +- dom/ipc/ContentBridgeParent.h | 2 +- dom/ipc/ContentParent.cpp | 16 +-- dom/ipc/PreallocatedProcessManager.cpp | 6 +- dom/ipc/ProcessHangMonitor.cpp | 72 +++++------- dom/jsurl/nsJSProtocolHandler.cpp | 3 +- dom/media/AbstractMediaDecoder.h | 7 +- dom/media/DOMMediaStream.cpp | 8 +- dom/media/MediaDecoderReader.cpp | 3 +- dom/media/MediaDecoderReaderWrapper.cpp | 6 +- dom/media/MediaDecoderStateMachine.cpp | 15 +-- dom/media/MediaFormatReader.cpp | 14 +-- dom/media/MediaFormatReader.h | 2 +- dom/media/MediaManager.h | 4 +- dom/media/MediaRecorder.cpp | 6 +- dom/media/MediaResource.cpp | 7 +- dom/media/MediaStreamTrack.cpp | 2 +- dom/media/MediaTimer.cpp | 8 +- dom/media/RtspMediaResource.cpp | 4 +- dom/media/eme/CDMCallbackProxy.cpp | 16 +-- dom/media/eme/CDMProxy.cpp | 34 +++--- dom/media/gmp/GMPContentParent.cpp | 4 +- dom/media/gmp/GMPContentParent.h | 2 +- dom/media/gmp/GMPDecryptorChild.cpp | 10 +- dom/media/gmp/GMPParent.cpp | 4 +- dom/media/gmp/GMPPlatform.cpp | 9 +- dom/media/gmp/GMPProcessParent.cpp | 3 +- dom/media/gmp/GMPService.cpp | 11 +- dom/media/gmp/GMPService.h | 1 + dom/media/gmp/GMPServiceParent.cpp | 14 +-- dom/media/gmp/GMPVideoDecoderChild.cpp | 4 +- dom/media/gmp/GMPVideoEncoderChild.cpp | 4 +- dom/media/gtest/GMPTestMonitor.h | 4 +- dom/media/gtest/TestGMPCrossOrigin.cpp | 108 +++++++++--------- dom/media/gtest/TestGMPRemoveAndDelete.cpp | 8 +- dom/media/gtest/TestMP4Reader.cpp | 6 +- dom/media/mediasink/DecodedStream.cpp | 6 +- dom/media/mediasource/MediaSourceDemuxer.cpp | 4 +- dom/media/mediasource/TrackBuffersManager.cpp | 17 +-- dom/media/omx/AudioOffloadPlayer.cpp | 17 ++- dom/media/platforms/agnostic/OpusDecoder.cpp | 12 +- dom/media/platforms/agnostic/VPXDecoder.cpp | 12 +- .../platforms/agnostic/VorbisDecoder.cpp | 12 +- dom/media/platforms/agnostic/WAVDecoder.cpp | 14 +-- .../agnostic/eme/SamplesWaitingForKey.cpp | 2 +- .../agnostic/gmp/MediaDataDecoderProxy.cpp | 14 +-- .../android/AndroidDecoderModule.cpp | 5 +- dom/media/platforms/apple/AppleATDecoder.cpp | 2 +- dom/media/platforms/apple/AppleVDADecoder.cpp | 8 +- dom/media/platforms/apple/AppleVTDecoder.cpp | 2 +- .../platforms/ffmpeg/FFmpegAudioDecoder.cpp | 2 +- .../platforms/ffmpeg/FFmpegDataDecoder.cpp | 6 +- .../platforms/ffmpeg/FFmpegVideoDecoder.cpp | 2 +- dom/media/platforms/omx/OmxDataDecoder.cpp | 16 +-- .../platforms/wmf/WMFMediaDataDecoder.cpp | 16 +-- .../platforms/wrappers/FuzzingWrapper.cpp | 22 +--- .../MediaSystemResourceManager.cpp | 28 ++--- dom/media/webaudio/AudioDestinationNode.cpp | 5 +- dom/media/webaudio/MediaBufferDecoder.cpp | 2 +- dom/media/webaudio/blink/ReverbConvolver.cpp | 4 +- dom/media/webspeech/synth/nsSpeechTask.cpp | 6 +- .../webspeech/synth/pico/nsPicoService.cpp | 4 +- .../synth/speechd/SpeechDispatcherService.cpp | 10 +- .../synth/test/nsFakeSynthServices.cpp | 2 +- dom/notification/Notification.cpp | 6 +- dom/plugins/base/nsNPAPIPluginInstance.cpp | 2 +- dom/plugins/ipc/PluginInstanceChild.cpp | 4 +- dom/plugins/ipc/PluginInstanceParent.cpp | 2 +- dom/plugins/ipc/PluginProcessParent.cpp | 3 +- dom/presentation/PresentationAvailability.cpp | 9 +- .../PresentationDeviceManager.cpp | 2 +- dom/presentation/PresentationSessionInfo.cpp | 12 +- .../PresentationTCPSessionTransport.cpp | 16 +-- .../provider/MulticastDNSDeviceProvider.cpp | 2 +- dom/quota/ActorsParent.cpp | 16 +-- dom/storage/DOMStorageCache.cpp | 9 +- dom/storage/DOMStorageDBThread.cpp | 2 +- dom/svg/SVGFEImageElement.cpp | 2 +- dom/svg/SVGImageElement.cpp | 2 +- dom/svg/SVGStyleElement.cpp | 2 +- dom/tv/TVSource.cpp | 18 +-- dom/tv/TVTuner.cpp | 6 +- dom/workers/ScriptLoader.cpp | 8 +- dom/workers/ServiceWorkerEvents.cpp | 5 +- dom/workers/ServiceWorkerJob.cpp | 2 +- dom/workers/ServiceWorkerPrivate.cpp | 4 +- dom/workers/ServiceWorkerRegistrar.cpp | 6 +- dom/workers/ServiceWorkerRegistrationInfo.cpp | 15 ++- dom/workers/ServiceWorkerUpdateJob.cpp | 4 +- dom/xbl/nsBindingManager.cpp | 2 +- .../XMLStylesheetProcessingInstruction.cpp | 2 +- dom/xml/nsXMLContentSink.cpp | 2 +- dom/xml/nsXMLPrettyPrinter.cpp | 2 +- dom/xul/XULDocument.cpp | 4 +- dom/xul/templates/nsXULTemplateBuilder.cpp | 8 +- editor/libeditor/nsHTMLEditRules.cpp | 2 +- editor/libeditor/nsHTMLEditor.cpp | 4 +- .../WebBrowserPersistDocumentParent.cpp | 2 +- .../WebBrowserPersistResourcesParent.cpp | 2 +- .../WebBrowserPersistSerializeParent.cpp | 2 +- .../webbrowserpersist/nsWebBrowserPersist.cpp | 8 +- gfx/gl/AndroidSurfaceTexture.cpp | 3 +- gfx/layers/apz/src/APZCTreeManager.cpp | 7 +- gfx/layers/apz/src/AsyncPanZoomController.cpp | 42 +++---- gfx/layers/apz/src/GestureEventListener.cpp | 8 +- gfx/layers/apz/src/InputQueue.cpp | 8 +- gfx/layers/apz/util/ActiveElementManager.cpp | 6 +- .../apz/util/ChromeProcessController.cpp | 63 +++++----- gfx/layers/ipc/CompositorBridgeParent.cpp | 55 ++++----- gfx/layers/ipc/ImageBridgeParent.cpp | 3 +- gfx/layers/ipc/RemoteContentController.cpp | 97 +++++++--------- gfx/thebes/SoftwareVsyncSource.cpp | 18 +-- gfx/vr/ipc/VRManagerParent.cpp | 3 +- image/DecodePool.cpp | 4 +- image/RasterImage.cpp | 4 +- image/VectorImage.cpp | 4 +- image/imgRequestProxy.cpp | 4 +- ipc/glue/BackgroundImpl.cpp | 25 ++-- ipc/glue/GeckoChildProcessHost.cpp | 31 ++--- ipc/glue/MessageChannel.cpp | 18 ++- ipc/glue/MessageLink.cpp | 17 +-- layout/base/ZoomConstraintsClient.cpp | 2 +- layout/base/nsPresContext.cpp | 10 +- layout/base/nsPresShell.cpp | 6 +- layout/base/nsRefreshDriver.cpp | 8 +- layout/ipc/VsyncParent.cpp | 6 +- layout/style/FontFaceSet.cpp | 2 +- .../src/mediapipeline/MediaPipeline.cpp | 2 +- modules/libjar/nsJARChannel.cpp | 9 +- netwerk/base/BackgroundFileSaver.cpp | 22 ++-- netwerk/base/Dashboard.cpp | 77 ++++++------- netwerk/base/OfflineObserver.cpp | 10 +- netwerk/base/Tickler.cpp | 4 +- netwerk/base/nsAsyncStreamCopier.cpp | 5 +- netwerk/base/nsInputStreamPump.cpp | 2 +- netwerk/base/nsPACMan.cpp | 8 +- netwerk/base/nsServerSocket.cpp | 7 +- netwerk/base/nsSocketTransportService2.cpp | 8 +- netwerk/base/nsUDPSocket.cpp | 6 +- netwerk/cache/nsCacheService.cpp | 4 +- netwerk/cache2/CacheEntry.cpp | 11 +- netwerk/cache2/CacheFileChunk.cpp | 4 +- netwerk/cache2/CacheFileContextEvictor.cpp | 2 +- netwerk/cache2/CacheFileIOManager.cpp | 25 ++-- netwerk/cache2/CacheIndex.cpp | 2 +- netwerk/cache2/CacheObserver.cpp | 6 +- netwerk/cache2/CacheStorageService.cpp | 6 +- netwerk/dns/DNSRequestChild.cpp | 4 +- .../mdns/libmdns/MDNSResponderOperator.cpp | 11 +- netwerk/ipc/ChannelEventQueue.cpp | 8 +- netwerk/protocol/about/nsAboutCache.cpp | 4 +- netwerk/protocol/file/nsFileChannel.cpp | 2 +- netwerk/protocol/ftp/FTPChannelParent.cpp | 2 +- netwerk/protocol/http/HttpBaseChannel.cpp | 2 +- netwerk/protocol/http/HttpBaseChannel.h | 4 +- netwerk/protocol/http/HttpChannelParent.cpp | 2 +- netwerk/protocol/http/PackagedAppVerifier.cpp | 12 +- netwerk/protocol/http/nsHttpHandler.cpp | 4 +- .../protocol/websocket/WebSocketChannel.cpp | 16 +-- .../websocket/WebSocketChannelChild.cpp | 6 +- netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp | 2 +- parser/html/nsHtml5TreeOpExecutor.cpp | 7 +- security/manager/ssl/DataStorage.cpp | 16 +-- security/manager/ssl/PSMContentListener.cpp | 2 +- storage/mozStorageConnection.cpp | 2 +- storage/mozStorageService.cpp | 4 +- .../filewatcher/NativeFileWatcherWin.cpp | 10 +- .../components/places/AsyncFaviconHelpers.cpp | 2 +- toolkit/components/places/History.cpp | 4 +- .../satchel/nsFormFillController.cpp | 2 +- toolkit/components/telemetry/Telemetry.cpp | 2 +- .../url-classifier/nsUrlClassifierProxies.cpp | 25 ++-- toolkit/xre/nsUpdateDriver.cpp | 10 +- uriloader/prefetch/nsOfflineCacheUpdate.cpp | 6 +- widget/ScreenProxy.cpp | 4 +- widget/VsyncDispatcher.cpp | 7 +- widget/android/AndroidContentController.cpp | 2 +- widget/gtk/nsDeviceContextSpecG.cpp | 8 +- widget/gtk/nsWindow.cpp | 6 +- widget/nsBaseWidget.cpp | 39 +++---- widget/nsScreenManagerProxy.cpp | 4 +- widget/qt/nsWindow.h | 2 +- widget/windows/AudioSession.cpp | 2 +- widget/windows/LSPAnnotator.cpp | 2 +- widget/windows/nsWindow.cpp | 4 +- widget/windows/nsWindowGfx.cpp | 2 +- xpcom/base/nsDumpUtils.cpp | 3 +- xpcom/base/nsDumpUtils.h | 4 +- xpcom/base/nsMemoryReporterManager.cpp | 5 +- xpcom/ds/nsObserverService.cpp | 4 +- xpcom/glue/nsThreadUtils.h | 90 ++++++++------- xpcom/glue/tests/gtest/TestThreadUtils.cpp | 82 ++++++------- xpcom/tests/TestThreadUtils.cpp | 28 ++--- xpcom/threads/AbstractThread.cpp | 2 +- xpcom/threads/LazyIdleThread.cpp | 8 +- xpcom/threads/SharedThreadPool.cpp | 5 +- xpcom/threads/StateMirroring.h | 17 ++- xpcom/threads/StateWatching.h | 3 +- xpcom/threads/nsProcessCommon.cpp | 4 +- xpcom/threads/nsThreadPool.cpp | 5 +- 238 files changed, 1046 insertions(+), 1279 deletions(-) diff --git a/docshell/shistory/nsSHistory.cpp b/docshell/shistory/nsSHistory.cpp index 5bfac6bc9f68..ff81a3a3ab96 100644 --- a/docshell/shistory/nsSHistory.cpp +++ b/docshell/shistory/nsSHistory.cpp @@ -1383,10 +1383,8 @@ nsSHistory::RemoveEntries(nsTArray& aIDs, int32_t aStartIndex) --index; } if (didRemove && mRootDocShell) { - nsCOMPtr ev = - NS_NewRunnableMethod(static_cast(mRootDocShell), - &nsDocShell::FireDummyOnLocationChange); - NS_DispatchToCurrentThread(ev); + NS_DispatchToCurrentThread(NewRunnableMethod(static_cast(mRootDocShell), + &nsDocShell::FireDummyOnLocationChange)); } } diff --git a/dom/animation/Animation.cpp b/dom/animation/Animation.cpp index c4299a19f060..c24fe0c99a5b 100644 --- a/dom/animation/Animation.cpp +++ b/dom/animation/Animation.cpp @@ -1236,7 +1236,7 @@ Animation::DoFinishNotification(SyncNotifyFlag aSyncNotifyFlag) DoFinishNotificationImmediately(); } else if (!mFinishNotificationTask.IsPending()) { RefPtr> runnable = - NS_NewRunnableMethod(this, &Animation::DoFinishNotificationImmediately); + NewRunnableMethod(this, &Animation::DoFinishNotificationImmediately); runtime->DispatchToMicroTask(runnable); mFinishNotificationTask = runnable; } diff --git a/dom/archivereader/ArchiveEvent.cpp b/dom/archivereader/ArchiveEvent.cpp index 164a03eb2d4d..b1b3dcd82384 100644 --- a/dom/archivereader/ArchiveEvent.cpp +++ b/dom/archivereader/ArchiveEvent.cpp @@ -86,8 +86,7 @@ ArchiveReaderEvent::RunShare(nsresult aStatus) { mStatus = aStatus; - nsCOMPtr event = NS_NewRunnableMethod(this, &ArchiveReaderEvent::ShareMainThread); - NS_DispatchToMainThread(event); + NS_DispatchToMainThread(NewRunnableMethod(this, &ArchiveReaderEvent::ShareMainThread)); return NS_OK; } diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index 1378bdb621b1..ba841376cf52 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -517,7 +517,7 @@ Element::WrapObject(JSContext *aCx, JS::Handle aGivenProto) } else { nsContentUtils::AddScriptRunner( - NS_NewRunnableMethod(binding, &nsXBLBinding::ExecuteAttachedHandler)); + NewRunnableMethod(binding, &nsXBLBinding::ExecuteAttachedHandler)); } } } diff --git a/dom/base/EventSource.cpp b/dom/base/EventSource.cpp index 58421cdbf75c..fe13f6ae708c 100644 --- a/dom/base/EventSource.cpp +++ b/dom/base/EventSource.cpp @@ -364,11 +364,7 @@ EventSource::OnStartRequest(nsIRequest *aRequest, return NS_ERROR_ABORT; } - nsCOMPtr event = - NS_NewRunnableMethod(this, &EventSource::AnnounceConnection); - NS_ENSURE_STATE(event); - - rv = NS_DispatchToMainThread(event); + rv = NS_DispatchToMainThread(NewRunnableMethod(this, &EventSource::AnnounceConnection)); NS_ENSURE_SUCCESS(rv, rv); mStatus = PARSE_STATE_BEGIN_OF_STREAM; @@ -474,11 +470,7 @@ EventSource::OnStopRequest(nsIRequest *aRequest, ClearFields(); - nsCOMPtr event = - NS_NewRunnableMethod(this, &EventSource::ReestablishConnection); - NS_ENSURE_STATE(event); - - rv = NS_DispatchToMainThread(event); + rv = NS_DispatchToMainThread(NewRunnableMethod(this, &EventSource::ReestablishConnection)); NS_ENSURE_SUCCESS(rv, rv); return NS_OK; @@ -900,11 +892,8 @@ EventSource::ConsoleError() nsresult EventSource::DispatchFailConnection() { - nsCOMPtr event = - NS_NewRunnableMethod(this, &EventSource::FailConnection); - NS_ENSURE_STATE(event); - return NS_DispatchToMainThread(event); + return NS_DispatchToMainThread(NewRunnableMethod(this, &EventSource::FailConnection)); } void @@ -978,7 +967,7 @@ EventSource::Thaw() nsresult rv; if (!mGoingToDispatchAllMessages && mMessagesToDispatch.GetSize() > 0) { nsCOMPtr event = - NS_NewRunnableMethod(this, &EventSource::DispatchAllMessageEvents); + NewRunnableMethod(this, &EventSource::DispatchAllMessageEvents); NS_ENSURE_STATE(event); mGoingToDispatchAllMessages = true; @@ -1038,7 +1027,7 @@ EventSource::DispatchCurrentMessageEvent() if (!mGoingToDispatchAllMessages) { nsCOMPtr event = - NS_NewRunnableMethod(this, &EventSource::DispatchAllMessageEvents); + NewRunnableMethod(this, &EventSource::DispatchAllMessageEvents); NS_ENSURE_STATE(event); mGoingToDispatchAllMessages = true; diff --git a/dom/base/ScreenOrientation.cpp b/dom/base/ScreenOrientation.cpp index 42990759fbf7..5ed7a825e007 100644 --- a/dom/base/ScreenOrientation.cpp +++ b/dom/base/ScreenOrientation.cpp @@ -540,7 +540,7 @@ ScreenOrientation::Notify(const hal::ScreenConfiguration& aConfiguration) doc->SetOrientationPendingPromise(nullptr); } - nsCOMPtr runnable = NS_NewRunnableMethod(this, + nsCOMPtr runnable = NewRunnableMethod(this, &ScreenOrientation::DispatchChangeEvent); rv = NS_DispatchToMainThread(runnable); NS_WARN_IF(NS_FAILED(rv)); @@ -615,7 +615,7 @@ ScreenOrientation::VisibleEventListener::HandleEvent(nsIDOMEvent* aEvent) doc->SetOrientationPendingPromise(nullptr); } - nsCOMPtr runnable = NS_NewRunnableMethod(orientation, + nsCOMPtr runnable = NewRunnableMethod(orientation, &ScreenOrientation::DispatchChangeEvent); rv = NS_DispatchToMainThread(runnable); if (NS_WARN_IF(rv.Failed())) { diff --git a/dom/base/nsContentSink.cpp b/dom/base/nsContentSink.cpp index 3e6aacf9cdfd..cf5dbc0d119a 100644 --- a/dom/base/nsContentSink.cpp +++ b/dom/base/nsContentSink.cpp @@ -265,7 +265,7 @@ nsContentSink::ProcessHTTPHeaders(nsIChannel* aChannel) "Already dispatched an event?"); mProcessLinkHeaderEvent = - NS_NewNonOwningRunnableMethod(this, + NewNonOwningRunnableMethod(this, &nsContentSink::DoProcessLinkHeader); rv = NS_DispatchToCurrentThread(mProcessLinkHeaderEvent.get()); if (NS_FAILED(rv)) { diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index e1280846796e..4f819133839f 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -5040,22 +5040,29 @@ nsContentUtils::WarnScriptWasIgnored(nsIDocument* aDocument) /* static */ bool -nsContentUtils::AddScriptRunner(nsIRunnable* aRunnable) +nsContentUtils::AddScriptRunner(already_AddRefed aRunnable) { - if (!aRunnable) { + nsCOMPtr runnable = aRunnable; + if (!runnable) { return false; } if (sScriptBlockerCount) { - return sBlockedScriptRunners->AppendElement(aRunnable) != nullptr; + return sBlockedScriptRunners->AppendElement(runnable.forget()) != nullptr; } - nsCOMPtr run = aRunnable; - run->Run(); + runnable->Run(); return true; } +/* static */ +bool +nsContentUtils::AddScriptRunner(nsIRunnable* aRunnable) { + nsCOMPtr runnable = aRunnable; + return AddScriptRunner(runnable.forget()); +} + /* static */ void nsContentUtils::RunInStableState(already_AddRefed aRunnable) diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h index 775b6a7b168c..890287ac8fba 100644 --- a/dom/base/nsContentUtils.h +++ b/dom/base/nsContentUtils.h @@ -1608,6 +1608,7 @@ public: * has not yet been AddRefed. * @return false on out of memory, true otherwise. */ + static bool AddScriptRunner(already_AddRefed aRunnable); static bool AddScriptRunner(nsIRunnable* aRunnable); /** diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index 145d880c1cf7..ba86e3f42fa0 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -1008,7 +1008,7 @@ nsDOMWindowUtils::SendNativeKeyEvent(int32_t aNativeKeyboardLayout, if (!widget) return NS_ERROR_FAILURE; - NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs + NS_DispatchToMainThread(NewRunnableMethod (widget, &nsIWidget::SynthesizeNativeKeyEvent, aNativeKeyboardLayout, aNativeKeyCode, aModifiers, aCharacters, aUnmodifiedCharacters, aObserver)); @@ -1028,7 +1028,7 @@ nsDOMWindowUtils::SendNativeMouseEvent(int32_t aScreenX, if (!widget) return NS_ERROR_FAILURE; - NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs + NS_DispatchToMainThread(NewRunnableMethod (widget, &nsIWidget::SynthesizeNativeMouseEvent, LayoutDeviceIntPoint(aScreenX, aScreenY), aNativeMessage, aModifierFlags, @@ -1047,7 +1047,7 @@ nsDOMWindowUtils::SendNativeMouseMove(int32_t aScreenX, if (!widget) return NS_ERROR_FAILURE; - NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs + NS_DispatchToMainThread(NewRunnableMethod (widget, &nsIWidget::SynthesizeNativeMouseMove, LayoutDeviceIntPoint(aScreenX, aScreenY), aObserver)); @@ -1072,7 +1072,7 @@ nsDOMWindowUtils::SendNativeMouseScrollEvent(int32_t aScreenX, return NS_ERROR_FAILURE; } - NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs + NS_DispatchToMainThread(NewRunnableMethod (widget, &nsIWidget::SynthesizeNativeMouseScrollEvent, LayoutDeviceIntPoint(aScreenX, aScreenY), aNativeMessage, aDeltaX, aDeltaY, @@ -1098,7 +1098,7 @@ nsDOMWindowUtils::SendNativeTouchPoint(uint32_t aPointerId, return NS_ERROR_INVALID_ARG; } - NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs + NS_DispatchToMainThread(NewRunnableMethod (widget, &nsIWidget::SynthesizeNativeTouchPoint, aPointerId, (nsIWidget::TouchPointerState)aTouchState, @@ -1118,7 +1118,7 @@ nsDOMWindowUtils::SendNativeTouchTap(int32_t aScreenX, return NS_ERROR_FAILURE; } - NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs + NS_DispatchToMainThread(NewRunnableMethod (widget, &nsIWidget::SynthesizeNativeTouchTap, LayoutDeviceIntPoint(aScreenX, aScreenY), aLongTap, aObserver)); @@ -1133,7 +1133,7 @@ nsDOMWindowUtils::ClearNativeTouchSequence(nsIObserver* aObserver) return NS_ERROR_FAILURE; } - NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs + NS_DispatchToMainThread(NewRunnableMethod (widget, &nsIWidget::ClearNativeTouchSequence, aObserver)); return NS_OK; } diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index 85cec876cdc3..f50d16e3e5bc 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -4369,7 +4369,7 @@ nsDocument::SetStyleSheetApplicableState(StyleSheetHandle aSheet, } if (!mSSApplicableStateNotificationPending) { - nsCOMPtr notification = NS_NewRunnableMethod(this, + nsCOMPtr notification = NewRunnableMethod(this, &nsDocument::NotifyStyleSheetApplicableStateChanged); mSSApplicableStateNotificationPending = NS_SUCCEEDED(NS_DispatchToCurrentThread(notification)); @@ -4978,7 +4978,7 @@ nsDocument::MaybeEndOutermostXBLUpdate() BindingManager()->EndOutermostUpdate(); } else if (!mInDestructor) { nsContentUtils::AddScriptRunner( - NS_NewRunnableMethod(this, &nsDocument::MaybeEndOutermostXBLUpdate)); + NewRunnableMethod(this, &nsDocument::MaybeEndOutermostXBLUpdate)); } } } @@ -5296,7 +5296,7 @@ nsDocument::UnblockDOMContentLoaded() MOZ_ASSERT(mReadyState == READYSTATE_INTERACTIVE); if (!mSynchronousDOMContentLoaded) { nsCOMPtr ev = - NS_NewRunnableMethod(this, &nsDocument::DispatchContentLoadedEvents); + NewRunnableMethod(this, &nsDocument::DispatchContentLoadedEvents); NS_DispatchToCurrentThread(ev); } else { DispatchContentLoadedEvents(); @@ -7279,7 +7279,7 @@ nsDocument::NotifyPossibleTitleChange(bool aBoundTitleElement) return; RefPtr > event = - NS_NewNonOwningRunnableMethod(this, + NewNonOwningRunnableMethod(this, &nsDocument::DoNotifyPossibleTitleChange); nsresult rv = NS_DispatchToCurrentThread(event); if (NS_SUCCEEDED(rv)) { @@ -7428,7 +7428,7 @@ nsDocument::InitializeFrameLoader(nsFrameLoader* aLoader) mInitializableFrameLoaders.AppendElement(aLoader); if (!mFrameLoaderRunner) { mFrameLoaderRunner = - NS_NewRunnableMethod(this, &nsDocument::MaybeInitializeFinalizeFrameLoaders); + NewRunnableMethod(this, &nsDocument::MaybeInitializeFinalizeFrameLoaders); NS_ENSURE_TRUE(mFrameLoaderRunner, NS_ERROR_OUT_OF_MEMORY); nsContentUtils::AddScriptRunner(mFrameLoaderRunner); } @@ -7446,7 +7446,7 @@ nsDocument::FinalizeFrameLoader(nsFrameLoader* aLoader, nsIRunnable* aFinalizer) mFrameLoaderFinalizers.AppendElement(aFinalizer); if (!mFrameLoaderRunner) { mFrameLoaderRunner = - NS_NewRunnableMethod(this, &nsDocument::MaybeInitializeFinalizeFrameLoaders); + NewRunnableMethod(this, &nsDocument::MaybeInitializeFinalizeFrameLoaders); NS_ENSURE_TRUE(mFrameLoaderRunner, NS_ERROR_OUT_OF_MEMORY); nsContentUtils::AddScriptRunner(mFrameLoaderRunner); } @@ -7470,7 +7470,7 @@ nsDocument::MaybeInitializeFinalizeFrameLoaders() (mInitializableFrameLoaders.Length() || mFrameLoaderFinalizers.Length())) { mFrameLoaderRunner = - NS_NewRunnableMethod(this, &nsDocument::MaybeInitializeFinalizeFrameLoaders); + NewRunnableMethod(this, &nsDocument::MaybeInitializeFinalizeFrameLoaders); nsContentUtils::AddScriptRunner(mFrameLoaderRunner); } return; @@ -9081,7 +9081,7 @@ nsDocument::BlockOnload() ++mAsyncOnloadBlockCount; if (mAsyncOnloadBlockCount == 1) { bool success = nsContentUtils::AddScriptRunner( - NS_NewRunnableMethod(this, &nsDocument::AsyncBlockOnload)); + NewRunnableMethod(this, &nsDocument::AsyncBlockOnload)); // The script runner shouldn't fail to add. But if somebody broke // something and it does, we'll thrash at 100% cpu forever. The best @@ -12797,7 +12797,7 @@ nsDocument::GetVisibilityState() const nsDocument::PostVisibilityUpdateEvent() { nsCOMPtr event = - NS_NewRunnableMethod(this, &nsDocument::UpdateVisibilityState); + NewRunnableMethod(this, &nsDocument::UpdateVisibilityState); NS_DispatchToMainThread(event); } @@ -13528,7 +13528,7 @@ nsIDocument::RebuildUserFontSet() // change reflow). if (!mPostedFlushUserFontSet) { nsCOMPtr ev = - NS_NewRunnableMethod(this, &nsIDocument::HandleRebuildUserFontSet); + NewRunnableMethod(this, &nsIDocument::HandleRebuildUserFontSet); if (NS_SUCCEEDED(NS_DispatchToCurrentThread(ev))) { mPostedFlushUserFontSet = true; } diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index d4043c982784..6a5f9b9450d7 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -2679,7 +2679,7 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument, under normal circumstances, but bug 49615 describes a case.) */ nsContentUtils::AddScriptRunner( - NS_NewRunnableMethod(this, &nsGlobalWindow::ClearStatus)); + NewRunnableMethod(this, &nsGlobalWindow::ClearStatus)); // Sometimes, WouldReuseInnerWindow() returns true even if there's no inner // window (see bug 776497). Be safe. @@ -2985,8 +2985,8 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument, // up with the outer. See bug 969156. if (createdInnerWindow) { nsContentUtils::AddScriptRunner( - NS_NewRunnableMethod(newInnerWindow, - &nsGlobalWindow::FireOnNewGlobalObject)); + NewRunnableMethod(newInnerWindow, + &nsGlobalWindow::FireOnNewGlobalObject)); } if (newInnerWindow && !newInnerWindow->mHasNotifiedGlobalCreated && mDoc) { @@ -2999,7 +2999,7 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument, nsContentUtils::IsSystemPrincipal(mDoc->NodePrincipal())) { newInnerWindow->mHasNotifiedGlobalCreated = true; nsContentUtils::AddScriptRunner( - NS_NewRunnableMethod(this, &nsGlobalWindow::DispatchDOMWindowCreated)); + NewRunnableMethod(this, &nsGlobalWindow::DispatchDOMWindowCreated)); } } @@ -11728,7 +11728,7 @@ public: ~AutoUnblockScriptClosing() { void (nsGlobalWindow::*run)() = &nsGlobalWindow::UnblockScriptedClosing; - NS_DispatchToCurrentThread(NS_NewRunnableMethod(mWin, run)); + NS_DispatchToCurrentThread(NewRunnableMethod(mWin, run)); } }; diff --git a/dom/base/nsScriptLoader.cpp b/dom/base/nsScriptLoader.cpp index cfd5a53fc6de..0941be418648 100644 --- a/dom/base/nsScriptLoader.cpp +++ b/dom/base/nsScriptLoader.cpp @@ -497,8 +497,8 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement) if (!scriptURI) { // Asynchronously report the failure to create a URI object NS_DispatchToCurrentThread( - NS_NewRunnableMethod(aElement, - &nsIScriptElement::FireErrorEvent)); + NewRunnableMethod(aElement, + &nsIScriptElement::FireErrorEvent)); return false; } @@ -564,8 +564,8 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement) if (NS_FAILED(rv)) { // Asynchronously report the load failure NS_DispatchToCurrentThread( - NS_NewRunnableMethod(aElement, - &nsIScriptElement::FireErrorEvent)); + NewRunnableMethod(aElement, + &nsIScriptElement::FireErrorEvent)); return false; } } @@ -1144,10 +1144,8 @@ void nsScriptLoader::ProcessPendingRequestsAsync() { if (mParserBlockingRequest || !mPendingChildLoaders.IsEmpty()) { - nsCOMPtr ev = NS_NewRunnableMethod(this, - &nsScriptLoader::ProcessPendingRequests); - - NS_DispatchToCurrentThread(ev); + NS_DispatchToCurrentThread(NewRunnableMethod(this, + &nsScriptLoader::ProcessPendingRequests)); } } diff --git a/dom/base/nsTextNode.cpp b/dom/base/nsTextNode.cpp index 2ee7b82b158b..25c2d3525678 100644 --- a/dom/base/nsTextNode.cpp +++ b/dom/base/nsTextNode.cpp @@ -273,8 +273,7 @@ nsAttributeTextNode::AttributeChanged(nsIDocument* aDocument, // that if we get unbound while the event is up that's ok -- we'll just // have no grandparent when it fires, and will do nothing. void (nsAttributeTextNode::*update)() = &nsAttributeTextNode::UpdateText; - nsCOMPtr ev = NS_NewRunnableMethod(this, update); - nsContentUtils::AddScriptRunner(ev); + nsContentUtils::AddScriptRunner(NewRunnableMethod(this, update)); } } diff --git a/dom/cache/Context.cpp b/dom/cache/Context.cpp index 4c778c3aa1fa..a27287af82f9 100644 --- a/dom/cache/Context.cpp +++ b/dom/cache/Context.cpp @@ -740,7 +740,7 @@ Context::ThreadsafeHandle::AllowToClose() // Dispatch is guaranteed to succeed here because we block shutdown until // all Contexts have been destroyed. nsCOMPtr runnable = - NS_NewRunnableMethod(this, &ThreadsafeHandle::AllowToCloseOnOwningThread); + NewRunnableMethod(this, &ThreadsafeHandle::AllowToCloseOnOwningThread); MOZ_ALWAYS_SUCCEEDS( mOwningThread->Dispatch(runnable, nsIThread::DISPATCH_NORMAL)); } @@ -756,7 +756,7 @@ Context::ThreadsafeHandle::InvalidateAndAllowToClose() // Dispatch is guaranteed to succeed here because we block shutdown until // all Contexts have been destroyed. nsCOMPtr runnable = - NS_NewRunnableMethod(this, &ThreadsafeHandle::InvalidateAndAllowToCloseOnOwningThread); + NewRunnableMethod(this, &ThreadsafeHandle::InvalidateAndAllowToCloseOnOwningThread); MOZ_ALWAYS_SUCCEEDS( mOwningThread->Dispatch(runnable, nsIThread::DISPATCH_NORMAL)); } @@ -780,10 +780,7 @@ Context::ThreadsafeHandle::~ThreadsafeHandle() // Dispatch is guaranteed to succeed here because we block shutdown until // all Contexts have been destroyed. - nsCOMPtr runnable = - NS_NewNonOwningRunnableMethod(mStrongRef.forget().take(), &Context::Release); - MOZ_ALWAYS_SUCCEEDS( - mOwningThread->Dispatch(runnable, nsIThread::DISPATCH_NORMAL)); + NS_ProxyRelease(mOwningThread, mStrongRef.forget()); } void diff --git a/dom/cache/Manager.cpp b/dom/cache/Manager.cpp index 7eff4a057f79..c60ccb901ef6 100644 --- a/dom/cache/Manager.cpp +++ b/dom/cache/Manager.cpp @@ -912,7 +912,7 @@ private: // May be on any thread, including STS event target. Non-owning runnable // here since we are guaranteed the Action will survive until // CompleteOnInitiatingThread is called. - nsCOMPtr runnable = NS_NewNonOwningRunnableMethodWithArgs( + nsCOMPtr runnable = NewNonOwningRunnableMethod( this, &CachePutAllAction::OnAsyncCopyComplete, aRv); MOZ_ALWAYS_SUCCEEDS( mTargetThread->Dispatch(runnable, nsIThread::DISPATCH_NORMAL)); @@ -1761,9 +1761,7 @@ Manager::~Manager() // Don't spin the event loop in the destructor waiting for the thread to // shutdown. Defer this to the main thread, instead. - nsCOMPtr runnable = - NS_NewRunnableMethod(ioThread, &nsIThread::Shutdown); - MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(runnable)); + MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(NewRunnableMethod(ioThread, &nsIThread::Shutdown))); } void diff --git a/dom/camera/CameraPreviewMediaStream.cpp b/dom/camera/CameraPreviewMediaStream.cpp index 32af686eac3a..0233c5e518f3 100644 --- a/dom/camera/CameraPreviewMediaStream.cpp +++ b/dom/camera/CameraPreviewMediaStream.cpp @@ -171,9 +171,7 @@ CameraPreviewMediaStream::SetCurrentFrame(const gfx::IntSize& aIntrinsicSize, Im ++mInvalidatePending; } - nsCOMPtr event = - NS_NewRunnableMethod(this, &CameraPreviewMediaStream::Invalidate); - NS_DispatchToMainThread(event); + NS_DispatchToMainThread(NewRunnableMethod(this, &CameraPreviewMediaStream::Invalidate)); } void @@ -184,9 +182,7 @@ CameraPreviewMediaStream::ClearCurrentFrame() for (nsTArray >::size_type i = 0; i < mVideoOutputs.Length(); ++i) { VideoFrameContainer* output = mVideoOutputs[i]; output->ClearCurrentFrame(); - nsCOMPtr event = - NS_NewRunnableMethod(output, &VideoFrameContainer::Invalidate); - NS_DispatchToMainThread(event); + NS_DispatchToMainThread(NewRunnableMethod(output, &VideoFrameContainer::Invalidate)); } } diff --git a/dom/camera/DOMCameraControl.cpp b/dom/camera/DOMCameraControl.cpp index f34055b22275..2505bf28d07c 100755 --- a/dom/camera/DOMCameraControl.cpp +++ b/dom/camera/DOMCameraControl.cpp @@ -73,10 +73,8 @@ public: TrackID aInputTrackID) override { if (aTrackEvents & TRACK_EVENT_CREATED) { - nsCOMPtr runnable = - NS_NewRunnableMethodWithArgs( - this, &TrackCreatedListener::DoNotifyTrackCreated, aID); - aGraph->DispatchToMainThreadAfterStreamStateUpdate(runnable.forget()); + aGraph->DispatchToMainThreadAfterStreamStateUpdate(NewRunnableMethod( + this, &TrackCreatedListener::DoNotifyTrackCreated, aID)); } } diff --git a/dom/camera/DOMCameraManager.cpp b/dom/camera/DOMCameraManager.cpp index 8583494c104d..68054dc5db7d 100644 --- a/dom/camera/DOMCameraManager.cpp +++ b/dom/camera/DOMCameraManager.cpp @@ -233,11 +233,11 @@ CameraPermissionRequest::DispatchCallback(uint32_t aPermission) { nsCOMPtr callbackRunnable; if (aPermission == nsIPermissionManager::ALLOW_ACTION) { - callbackRunnable = NS_NewRunnableMethod(this, &CameraPermissionRequest::CallAllow); + callbackRunnable = NewRunnableMethod(this, &CameraPermissionRequest::CallAllow); } else { - callbackRunnable = NS_NewRunnableMethod(this, &CameraPermissionRequest::CallCancel); + callbackRunnable = NewRunnableMethod(this, &CameraPermissionRequest::CallCancel); } - return NS_DispatchToMainThread(callbackRunnable); + return NS_DispatchToMainThread(callbackRunnable.forget()); } void diff --git a/dom/devicestorage/DeviceStorageStatics.cpp b/dom/devicestorage/DeviceStorageStatics.cpp index f02d904fdce5..b8de88f5ff70 100644 --- a/dom/devicestorage/DeviceStorageStatics.cpp +++ b/dom/devicestorage/DeviceStorageStatics.cpp @@ -488,7 +488,7 @@ DeviceStorageStatics::AddListener(nsDOMDeviceStorage* aListener) MOZ_ASSERT(sInstance->mInitialized); if (sInstance->mListeners.IsEmpty()) { NS_DispatchToMainThread( - NS_NewRunnableMethod(sInstance.get(), &DeviceStorageStatics::Register)); + NewRunnableMethod(sInstance.get(), &DeviceStorageStatics::Register)); } RefPtr wrapper = @@ -519,7 +519,7 @@ DeviceStorageStatics::RemoveListener(nsDOMDeviceStorage* aListener) if (removed && sInstance->mListeners.IsEmpty()) { NS_DispatchToMainThread( - NS_NewRunnableMethod(sInstance.get(), &DeviceStorageStatics::Deregister)); + NewRunnableMethod(sInstance.get(), &DeviceStorageStatics::Deregister)); } } diff --git a/dom/events/EventListenerService.cpp b/dom/events/EventListenerService.cpp index dee437b4223f..9b154d4ed228 100644 --- a/dom/events/EventListenerService.cpp +++ b/dom/events/EventListenerService.cpp @@ -371,9 +371,8 @@ EventListenerService::NotifyAboutMainThreadListenerChangeInternal(dom::EventTarg if (!mPendingListenerChanges) { mPendingListenerChanges = nsArrayBase::Create(); - nsCOMPtr runnable = NS_NewRunnableMethod(this, - &EventListenerService::NotifyPendingChanges); - NS_DispatchToCurrentThread(runnable); + NS_DispatchToCurrentThread(NewRunnableMethod(this, + &EventListenerService::NotifyPendingChanges)); } RefPtr changes = mPendingListenerChangesSet.Get(aTarget); diff --git a/dom/fetch/FetchDriver.cpp b/dom/fetch/FetchDriver.cpp index e036346894d3..4c4eb08b10a9 100644 --- a/dom/fetch/FetchDriver.cpp +++ b/dom/fetch/FetchDriver.cpp @@ -83,9 +83,7 @@ FetchDriver::Fetch(FetchDriverObserver* aObserver) MOZ_RELEASE_ASSERT(!mRequest->IsSynchronous(), "Synchronous fetch not supported"); - nsCOMPtr r = - NS_NewRunnableMethod(this, &FetchDriver::ContinueFetch); - return NS_DispatchToCurrentThread(r); + return NS_DispatchToCurrentThread(NewRunnableMethod(this, &FetchDriver::ContinueFetch)); } nsresult diff --git a/dom/html/HTMLCanvasElement.cpp b/dom/html/HTMLCanvasElement.cpp index 835a114f6e89..d61fbd8ae36e 100644 --- a/dom/html/HTMLCanvasElement.cpp +++ b/dom/html/HTMLCanvasElement.cpp @@ -223,7 +223,7 @@ HTMLCanvasPrintState::Done() mCanvas->InvalidateCanvas(); } RefPtr > doneEvent = - NS_NewRunnableMethod(this, &HTMLCanvasPrintState::NotifyDone); + NewRunnableMethod(this, &HTMLCanvasPrintState::NotifyDone); if (NS_SUCCEEDED(NS_DispatchToCurrentThread(doneEvent))) { mPendingNotify = true; } @@ -503,7 +503,7 @@ HTMLCanvasElement::DispatchPrintCallback(nsITimerCallback* aCallback) mPrintState = new HTMLCanvasPrintState(this, mCurrentContext, aCallback); RefPtr > renderEvent = - NS_NewRunnableMethod(this, &HTMLCanvasElement::CallPrintCallback); + NewRunnableMethod(this, &HTMLCanvasElement::CallPrintCallback); return NS_DispatchToCurrentThread(renderEvent); } diff --git a/dom/html/HTMLImageElement.cpp b/dom/html/HTMLImageElement.cpp index 5758473570cd..b2f06a5ef005 100644 --- a/dom/html/HTMLImageElement.cpp +++ b/dom/html/HTMLImageElement.cpp @@ -619,7 +619,7 @@ HTMLImageElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, // loading. if (LoadingEnabled()) { nsContentUtils::AddScriptRunner( - NS_NewRunnableMethod(this, &HTMLImageElement::MaybeLoadImage)); + NewRunnableMethod(this, &HTMLImageElement::MaybeLoadImage)); } } @@ -816,7 +816,7 @@ HTMLImageElement::CopyInnerTo(Element* aDest) if (!dest->InResponsiveMode() && dest->HasAttr(kNameSpaceID_None, nsGkAtoms::src)) { nsContentUtils::AddScriptRunner( - NS_NewRunnableMethod(dest, &HTMLImageElement::MaybeLoadImage)); + NewRunnableMethod(dest, &HTMLImageElement::MaybeLoadImage)); } } diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp index fae89d3aa64f..d6a3bd04d075 100644 --- a/dom/html/HTMLInputElement.cpp +++ b/dom/html/HTMLInputElement.cpp @@ -4354,7 +4354,7 @@ HTMLInputElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, ClearBrokenState(); RemoveStatesSilently(NS_EVENT_STATE_BROKEN); nsContentUtils::AddScriptRunner( - NS_NewRunnableMethod(this, &HTMLInputElement::MaybeLoadImage)); + NewRunnableMethod(this, &HTMLInputElement::MaybeLoadImage)); } } diff --git a/dom/html/HTMLLinkElement.cpp b/dom/html/HTMLLinkElement.cpp index 3db1ac85256e..08ae4dbeadf5 100644 --- a/dom/html/HTMLLinkElement.cpp +++ b/dom/html/HTMLLinkElement.cpp @@ -185,10 +185,10 @@ HTMLLinkElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, } void (HTMLLinkElement::*update)() = &HTMLLinkElement::UpdateStyleSheetInternal; - nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, update)); + nsContentUtils::AddScriptRunner(NewRunnableMethod(this, update)); void (HTMLLinkElement::*updateImport)() = &HTMLLinkElement::UpdateImport; - nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, updateImport)); + nsContentUtils::AddScriptRunner(NewRunnableMethod(this, updateImport)); CreateAndDispatchEvent(aDocument, NS_LITERAL_STRING("DOMLinkAdded")); diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp index 9d50efb1d503..e31bf69fbc7e 100644 --- a/dom/html/HTMLMediaElement.cpp +++ b/dom/html/HTMLMediaElement.cpp @@ -842,8 +842,8 @@ void HTMLMediaElement::QueueLoadFromSourceTask() { ChangeDelayLoadStatus(true); ChangeNetworkState(nsIDOMHTMLMediaElement::NETWORK_LOADING); - RunInStableState( - NS_NewRunnableMethod(this, &HTMLMediaElement::LoadFromSourceChildren)); + RefPtr r = NewRunnableMethod(this, &HTMLMediaElement::LoadFromSourceChildren); + RunInStableState(r); } void HTMLMediaElement::QueueSelectResourceTask() @@ -853,8 +853,8 @@ void HTMLMediaElement::QueueSelectResourceTask() return; mHaveQueuedSelectResource = true; ChangeNetworkState(nsIDOMHTMLMediaElement::NETWORK_NO_SOURCE); - RunInStableState( - NS_NewRunnableMethod(this, &HTMLMediaElement::SelectResourceWrapper)); + RefPtr r = NewRunnableMethod(this, &HTMLMediaElement::SelectResourceWrapper); + RunInStableState(r); } NS_IMETHODIMP HTMLMediaElement::Load() @@ -3171,9 +3171,9 @@ public: { nsCOMPtr event; if (aBlocked == BLOCKED) { - event = NS_NewRunnableMethod(this, &StreamListener::DoNotifyBlocked); + event = NewRunnableMethod(this, &StreamListener::DoNotifyBlocked); } else { - event = NS_NewRunnableMethod(this, &StreamListener::DoNotifyUnblocked); + event = NewRunnableMethod(this, &StreamListener::DoNotifyUnblocked); } aGraph->DispatchToMainThreadAfterStreamStateUpdate(event.forget()); } @@ -3182,7 +3182,7 @@ public: { if (event == EVENT_FINISHED) { nsCOMPtr event = - NS_NewRunnableMethod(this, &StreamListener::DoNotifyFinished); + NewRunnableMethod(this, &StreamListener::DoNotifyFinished); aGraph->DispatchToMainThreadAfterStreamStateUpdate(event.forget()); } } @@ -3190,7 +3190,7 @@ public: { MutexAutoLock lock(mMutex); nsCOMPtr event = - NS_NewRunnableMethod(this, &StreamListener::DoNotifyHaveCurrentData); + NewRunnableMethod(this, &StreamListener::DoNotifyHaveCurrentData); aGraph->DispatchToMainThreadAfterStreamStateUpdate(event.forget()); } virtual void NotifyOutput(MediaStreamGraph* aGraph, @@ -3201,7 +3201,7 @@ public: return; mPendingNotifyOutput = true; nsCOMPtr event = - NS_NewRunnableMethod(this, &StreamListener::DoNotifyOutput); + NewRunnableMethod(this, &StreamListener::DoNotifyOutput); aGraph->DispatchToMainThreadAfterStreamStateUpdate(event.forget()); } @@ -3253,7 +3253,7 @@ public: if (c->mFrame.GetIntrinsicSize() != gfx::IntSize(0,0)) { mInitialSizeFound = true; nsCOMPtr event = - NS_NewRunnableMethodWithArgs( + NewRunnableMethod( this, &StreamSizeListener::ReceivedSize, c->mFrame.GetIntrinsicSize()); aGraph->DispatchToMainThreadAfterStreamStateUpdate(event.forget()); @@ -4594,7 +4594,7 @@ void HTMLMediaElement::AddRemoveSelfReference() // Dispatch Release asynchronously so that we don't destroy this object // inside a call stack of method calls on this object nsCOMPtr event = - NS_NewRunnableMethod(this, &HTMLMediaElement::DoRemoveSelfReference); + NewRunnableMethod(this, &HTMLMediaElement::DoRemoveSelfReference); NS_DispatchToMainThread(event); } } diff --git a/dom/html/HTMLObjectElement.cpp b/dom/html/HTMLObjectElement.cpp index 543c5dc09367..1f2fda346d12 100644 --- a/dom/html/HTMLObjectElement.cpp +++ b/dom/html/HTMLObjectElement.cpp @@ -280,7 +280,7 @@ HTMLObjectElement::BindToTree(nsIDocument *aDocument, // If we already have all the children, start the load. if (mIsDoneAddingChildren && !pluginDoc) { void (HTMLObjectElement::*start)() = &HTMLObjectElement::StartObjectLoad; - nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, start)); + nsContentUtils::AddScriptRunner(NewRunnableMethod(this, start)); } return NS_OK; diff --git a/dom/html/HTMLSharedObjectElement.cpp b/dom/html/HTMLSharedObjectElement.cpp index 9d28b4816510..6d591d1894d3 100644 --- a/dom/html/HTMLSharedObjectElement.cpp +++ b/dom/html/HTMLSharedObjectElement.cpp @@ -153,7 +153,7 @@ HTMLSharedObjectElement::BindToTree(nsIDocument *aDocument, if (mIsDoneAddingChildren && !pluginDoc) { void (HTMLSharedObjectElement::*start)() = &HTMLSharedObjectElement::StartObjectLoad; - nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, start)); + nsContentUtils::AddScriptRunner(NewRunnableMethod(this, start)); } return NS_OK; diff --git a/dom/html/HTMLStyleElement.cpp b/dom/html/HTMLStyleElement.cpp index ec690fc0b4d1..ba44c9600cf8 100644 --- a/dom/html/HTMLStyleElement.cpp +++ b/dom/html/HTMLStyleElement.cpp @@ -147,7 +147,7 @@ HTMLStyleElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, NS_ENSURE_SUCCESS(rv, rv); void (HTMLStyleElement::*update)() = &HTMLStyleElement::UpdateStyleSheetInternal; - nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, update)); + nsContentUtils::AddScriptRunner(NewRunnableMethod(this, update)); return rv; } diff --git a/dom/html/HTMLTrackElement.cpp b/dom/html/HTMLTrackElement.cpp index 5a660b1d35f3..7f2982688afa 100644 --- a/dom/html/HTMLTrackElement.cpp +++ b/dom/html/HTMLTrackElement.cpp @@ -260,8 +260,8 @@ HTMLTrackElement::BindToTree(nsIDocument* aDocument, media->NotifyAddedSource(); LOG(LogLevel::Debug, ("Track element sent notification to parent.")); - mMediaParent->RunInStableState( - NS_NewRunnableMethod(this, &HTMLTrackElement::LoadResource)); + RefPtr r = NewRunnableMethod(this, &HTMLTrackElement::LoadResource); + mMediaParent->RunInStableState(r); } return NS_OK; @@ -314,7 +314,7 @@ void HTMLTrackElement::DispatchTrackRunnable(const nsString& aEventName) { nsCOMPtr runnable = - NS_NewRunnableMethodWithArg + NewRunnableMethod (this, &HTMLTrackElement::DispatchTrustedEvent, aEventName); diff --git a/dom/html/ImageDocument.cpp b/dom/html/ImageDocument.cpp index 2087bf56756c..11d55a8e78dd 100644 --- a/dom/html/ImageDocument.cpp +++ b/dom/html/ImageDocument.cpp @@ -491,7 +491,7 @@ ImageDocument::Notify(imgIRequest* aRequest, int32_t aType, const nsIntRect* aDa // come during painting and this will trigger invalidation. if (aType == imgINotificationObserver::HAS_TRANSPARENCY) { nsCOMPtr runnable = - NS_NewRunnableMethod(this, &ImageDocument::OnHasTransparency); + NewRunnableMethod(this, &ImageDocument::OnHasTransparency); nsContentUtils::AddScriptRunner(runnable); } @@ -554,7 +554,7 @@ ImageDocument::OnSizeAvailable(imgIRequest* aRequest, imgIContainer* aImage) aImage->GetHeight(&mImageHeight); nsCOMPtr runnable = - NS_NewRunnableMethod(this, &ImageDocument::DefaultCheckOverflowing); + NewRunnableMethod(this, &ImageDocument::DefaultCheckOverflowing); nsContentUtils::AddScriptRunner(runnable); UpdateTitleAndCharset(); diff --git a/dom/html/nsHTMLDocument.cpp b/dom/html/nsHTMLDocument.cpp index fb8c2eeb5260..a22286f98ae7 100644 --- a/dom/html/nsHTMLDocument.cpp +++ b/dom/html/nsHTMLDocument.cpp @@ -2505,7 +2505,7 @@ nsHTMLDocument::MaybeEditingStateChanged() EditingStateChanged(); } else if (!mInDestructor) { nsContentUtils::AddScriptRunner( - NS_NewRunnableMethod(this, &nsHTMLDocument::MaybeEditingStateChanged)); + NewRunnableMethod(this, &nsHTMLDocument::MaybeEditingStateChanged)); } } } diff --git a/dom/indexedDB/ActorsParent.cpp b/dom/indexedDB/ActorsParent.cpp index 1c3510686a3a..fa0653dcb82e 100644 --- a/dom/indexedDB/ActorsParent.cpp +++ b/dom/indexedDB/ActorsParent.cpp @@ -11823,7 +11823,7 @@ ConnectionPool::ShutdownThread(ThreadInfo& aThreadInfo) MOZ_ALWAYS_SUCCEEDS(thread->Dispatch(runnable, NS_DISPATCH_NORMAL)); nsCOMPtr shutdownRunnable = - NS_NewRunnableMethod(thread, &nsIThread::Shutdown); + NewRunnableMethod(thread, &nsIThread::Shutdown); MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(shutdownRunnable)); mTotalThreadCount--; @@ -13668,7 +13668,7 @@ Database::MaybeCloseConnection() IsClosed() && mDirectoryLock) { nsCOMPtr callback = - NS_NewRunnableMethod(this, &Database::ConnectionClosedCallback); + NewRunnableMethod(this, &Database::ConnectionClosedCallback); RefPtr helper = new WaitForTransactionsHelper(Id(), callback); @@ -21414,7 +21414,7 @@ OpenDatabaseOp::SendResults() mDatabase = nullptr; } else if (mDirectoryLock) { nsCOMPtr callback = - NS_NewRunnableMethod(this, &OpenDatabaseOp::ConnectionClosedCallback); + NewRunnableMethod(this, &OpenDatabaseOp::ConnectionClosedCallback); RefPtr helper = new WaitForTransactionsHelper(mDatabaseId, callback); diff --git a/dom/indexedDB/FileSnapshot.cpp b/dom/indexedDB/FileSnapshot.cpp index 3faecdd62e24..f4f0d6dd57c3 100644 --- a/dom/indexedDB/FileSnapshot.cpp +++ b/dom/indexedDB/FileSnapshot.cpp @@ -87,7 +87,7 @@ private: } nsCOMPtr destroyRunnable = - NS_NewNonOwningRunnableMethod(this, &StreamWrapper::Destroy); + NewNonOwningRunnableMethod(this, &StreamWrapper::Destroy); MOZ_ALWAYS_SUCCEEDS(mOwningThread->Dispatch(destroyRunnable, NS_DISPATCH_NORMAL)); diff --git a/dom/indexedDB/IDBDatabase.cpp b/dom/indexedDB/IDBDatabase.cpp index 63d1fe15d679..ec750ec628d1 100644 --- a/dom/indexedDB/IDBDatabase.cpp +++ b/dom/indexedDB/IDBDatabase.cpp @@ -1036,9 +1036,9 @@ IDBDatabase::DelayedMaybeExpireFileActors() } nsCOMPtr runnable = - NS_NewRunnableMethodWithArg(this, - &IDBDatabase::ExpireFileActors, - /* aExpireAll */ false); + NewRunnableMethod(this, + &IDBDatabase::ExpireFileActors, + /* aExpireAll */ false); MOZ_ASSERT(runnable); if (!NS_IsMainThread()) { diff --git a/dom/ipc/Blob.cpp b/dom/ipc/Blob.cpp index 1701609e9b5c..994113912278 100644 --- a/dom/ipc/Blob.cpp +++ b/dom/ipc/Blob.cpp @@ -293,7 +293,7 @@ ReleaseOnTarget(SmartPtr& aDoomed, nsIEventTarget* aTarget) auto* doomedSupports = static_cast(doomedRaw); nsCOMPtr releaseRunnable = - NS_NewNonOwningRunnableMethod(doomedSupports, &nsISupports::Release); + NewNonOwningRunnableMethod(doomedSupports, &nsISupports::Release); MOZ_ASSERT(releaseRunnable); if (aTarget) { @@ -1600,11 +1600,7 @@ private: NS_WARN_IF_FALSE(NS_SUCCEEDED(stream->Close()), "Failed to close stream!"); - nsCOMPtr shutdownRunnable = - NS_NewRunnableMethod(ioTarget, &nsIThread::Shutdown); - MOZ_ASSERT(shutdownRunnable); - - MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(shutdownRunnable)); + MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(NewRunnableMethod(ioTarget, &nsIThread::Shutdown))); return NS_OK; } @@ -2138,7 +2134,7 @@ RemoteBlobImpl::Destroy() } nsCOMPtr destroyRunnable = - NS_NewNonOwningRunnableMethod(this, &RemoteBlobImpl::Destroy); + NewNonOwningRunnableMethod(this, &RemoteBlobImpl::Destroy); if (mActorTarget) { destroyRunnable = @@ -2566,7 +2562,7 @@ RemoteBlobImpl::Destroy() } nsCOMPtr destroyRunnable = - NS_NewNonOwningRunnableMethod(this, &RemoteBlobImpl::Destroy); + NewNonOwningRunnableMethod(this, &RemoteBlobImpl::Destroy); if (mActorTarget) { destroyRunnable = @@ -3422,7 +3418,7 @@ BlobChild::NoteDyingRemoteBlobImpl() // on the owning thread, so we proxy here if necessary. if (!IsOnOwningThread()) { nsCOMPtr runnable = - NS_NewNonOwningRunnableMethod(this, &BlobChild::NoteDyingRemoteBlobImpl); + NewNonOwningRunnableMethod(this, &BlobChild::NoteDyingRemoteBlobImpl); if (mEventTarget) { runnable = new CancelableRunnableWrapper(runnable, mEventTarget); @@ -4001,7 +3997,7 @@ BlobParent::NoteDyingRemoteBlobImpl() // on the main thread, so we proxy here if necessary. if (!IsOnOwningThread()) { nsCOMPtr runnable = - NS_NewNonOwningRunnableMethod(this, &BlobParent::NoteDyingRemoteBlobImpl); + NewNonOwningRunnableMethod(this, &BlobParent::NoteDyingRemoteBlobImpl); if (mEventTarget) { runnable = new CancelableRunnableWrapper(runnable, mEventTarget); diff --git a/dom/ipc/ContentBridgeChild.cpp b/dom/ipc/ContentBridgeChild.cpp index 6d6b4f44bb2b..d40d9d5a2d66 100644 --- a/dom/ipc/ContentBridgeChild.cpp +++ b/dom/ipc/ContentBridgeChild.cpp @@ -34,8 +34,7 @@ ContentBridgeChild::~ContentBridgeChild() void ContentBridgeChild::ActorDestroy(ActorDestroyReason aWhy) { - RefPtr runnable = NS_NewRunnableMethod(this, &ContentBridgeChild::DeferredDestroy); - MessageLoop::current()->PostTask(runnable.forget()); + MessageLoop::current()->PostTask(NewRunnableMethod(this, &ContentBridgeChild::DeferredDestroy)); } /*static*/ ContentBridgeChild* diff --git a/dom/ipc/ContentBridgeParent.cpp b/dom/ipc/ContentBridgeParent.cpp index 7fd22c7a51a6..e71febd056f3 100644 --- a/dom/ipc/ContentBridgeParent.cpp +++ b/dom/ipc/ContentBridgeParent.cpp @@ -37,8 +37,7 @@ ContentBridgeParent::ActorDestroy(ActorDestroyReason aWhy) if (os) { os->RemoveObserver(this, "content-child-shutdown"); } - RefPtr runnable = NS_NewRunnableMethod(this, &ContentBridgeParent::DeferredDestroy); - MessageLoop::current()->PostTask(runnable.forget()); + MessageLoop::current()->PostTask(NewRunnableMethod(this, &ContentBridgeParent::DeferredDestroy)); } /*static*/ ContentBridgeParent* @@ -168,8 +167,7 @@ ContentBridgeParent::NotifyTabDestroyed() { int32_t numLiveTabs = ManagedPBrowserParent().Count(); if (numLiveTabs == 1) { - RefPtr runnable = NS_NewRunnableMethod(this, &ContentBridgeParent::Close); - MessageLoop::current()->PostTask(runnable.forget()); + MessageLoop::current()->PostTask(NewRunnableMethod(this, &ContentBridgeParent::Close)); } } diff --git a/dom/ipc/ContentBridgeParent.h b/dom/ipc/ContentBridgeParent.h index abff80392b20..18c46d4325ea 100644 --- a/dom/ipc/ContentBridgeParent.h +++ b/dom/ipc/ContentBridgeParent.h @@ -81,7 +81,7 @@ protected: void Close() { - // Trick NS_NewRunnableMethod + // Trick NewRunnableMethod PContentBridgeParent::Close(); } diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index aa14767ba337..b646b5aa27b5 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -2180,10 +2180,10 @@ ContentParent::ActorDestroy(ActorDestroyReason why) // Destroy any processes created by this ContentParent for(uint32_t i = 0; i < childIDArray.Length(); i++) { ContentParent* cp = cpm->GetContentProcessById(childIDArray[i]); - RefPtr runnable = - NS_NewRunnableMethodWithArgs(cp, &ContentParent::ShutDownProcess, - SEND_SHUTDOWN_MESSAGE); - MessageLoop::current()->PostTask(runnable.forget()); + MessageLoop::current()->PostTask(NewRunnableMethod + (cp, + &ContentParent::ShutDownProcess, + SEND_SHUTDOWN_MESSAGE)); } cpm->RemoveContentProcess(this->ChildID()); @@ -2264,10 +2264,10 @@ ContentParent::NotifyTabDestroyed(const TabId& aTabId, if (tabIds.Length() == 1) { // In the case of normal shutdown, send a shutdown message to child to // allow it to perform shutdown tasks. - RefPtr runnable = - NS_NewRunnableMethodWithArgs(this, &ContentParent::ShutDownProcess, - SEND_SHUTDOWN_MESSAGE); - MessageLoop::current()->PostTask(runnable.forget()); + MessageLoop::current()->PostTask(NewRunnableMethod + (this, + &ContentParent::ShutDownProcess, + SEND_SHUTDOWN_MESSAGE)); } } diff --git a/dom/ipc/PreallocatedProcessManager.cpp b/dom/ipc/PreallocatedProcessManager.cpp index dcfab5a31cf9..6ba07bd0ccb1 100644 --- a/dom/ipc/PreallocatedProcessManager.cpp +++ b/dom/ipc/PreallocatedProcessManager.cpp @@ -204,9 +204,8 @@ PreallocatedProcessManagerImpl::AllocateAfterDelay() return; } - RefPtr runnable = NS_NewRunnableMethod(this, &PreallocatedProcessManagerImpl::AllocateOnIdle); MessageLoop::current()->PostDelayedTask( - runnable.forget(), + NewRunnableMethod(this, &PreallocatedProcessManagerImpl::AllocateOnIdle), Preferences::GetUint("dom.ipc.processPrelaunch.delayMs", DEFAULT_ALLOCATE_DELAY)); } @@ -218,8 +217,7 @@ PreallocatedProcessManagerImpl::AllocateOnIdle() return; } - RefPtr runnable = NS_NewRunnableMethod(this, &PreallocatedProcessManagerImpl::AllocateNow); - MessageLoop::current()->PostIdleTask(runnable.forget()); + MessageLoop::current()->PostIdleTask(NewRunnableMethod(this, &PreallocatedProcessManagerImpl::AllocateNow)); } void diff --git a/dom/ipc/ProcessHangMonitor.cpp b/dom/ipc/ProcessHangMonitor.cpp index c26436cdcdfa..c7171ee78f4f 100644 --- a/dom/ipc/ProcessHangMonitor.cpp +++ b/dom/ipc/ProcessHangMonitor.cpp @@ -287,8 +287,7 @@ HangMonitorChild::ActorDestroy(ActorDestroyReason aWhy) // We use a task here to ensure that IPDL is finished with this // HangMonitorChild before it gets deleted on the main thread. - RefPtr runnable = NS_NewNonOwningRunnableMethod(this, &HangMonitorChild::ShutdownOnThread); - MonitorLoop()->PostTask(runnable.forget()); + MonitorLoop()->PostTask(NewNonOwningRunnableMethod(this, &HangMonitorChild::ShutdownOnThread)); } bool @@ -374,14 +373,10 @@ HangMonitorChild::NotifySlowScript(nsITabChild* aTabChild, } nsAutoCString filename(aFileName); - RefPtr runnable = - NS_NewNonOwningRunnableMethodWithArgs(this, - &HangMonitorChild::NotifySlowScriptAsync, - id, filename, aLineNo); - MonitorLoop()->PostTask(runnable.forget()); - + MonitorLoop()->PostTask(NewNonOwningRunnableMethod + (this, + &HangMonitorChild::NotifySlowScriptAsync, + id, filename, aLineNo)); return SlowScriptAction::Continue; } @@ -409,11 +404,9 @@ HangMonitorChild::NotifyPluginHang(uint32_t aPluginId) mSentReport = true; // bounce to background thread - RefPtr runnable = - NS_NewNonOwningRunnableMethodWithArgs(this, - &HangMonitorChild::NotifyPluginHangAsync, - aPluginId); - MonitorLoop()->PostTask(runnable.forget()); + MonitorLoop()->PostTask(NewNonOwningRunnableMethod(this, + &HangMonitorChild::NotifyPluginHangAsync, + aPluginId)); } void @@ -435,8 +428,7 @@ HangMonitorChild::ClearHang() if (mSentReport) { // bounce to background thread - RefPtr runnable = NS_NewNonOwningRunnableMethod(this, &HangMonitorChild::ClearHangAsync); - MonitorLoop()->PostTask(runnable.forget()); + MonitorLoop()->PostTask(NewNonOwningRunnableMethod(this, &HangMonitorChild::ClearHangAsync)); MonitorAutoLock lock(mMonitor); mSentReport = false; @@ -501,8 +493,8 @@ HangMonitorParent::Shutdown() mProcess = nullptr; } - RefPtr runnable = NS_NewNonOwningRunnableMethod(this, &HangMonitorParent::ShutdownOnThread); - MonitorLoop()->PostTask(runnable.forget()); + MonitorLoop()->PostTask(NewNonOwningRunnableMethod(this, + &HangMonitorParent::ShutdownOnThread)); while (!mShutdownDone) { mMonitor.Wait(); @@ -822,8 +814,8 @@ HangMonitoredProcess::TerminateScript() return NS_ERROR_UNEXPECTED; } - RefPtr runnable = NS_NewNonOwningRunnableMethod(mActor, &HangMonitorParent::TerminateScript); - ProcessHangMonitor::Get()->MonitorLoop()->PostTask(runnable.forget()); + ProcessHangMonitor::Get()->MonitorLoop()->PostTask(NewNonOwningRunnableMethod(mActor, + &HangMonitorParent::TerminateScript)); return NS_OK; } @@ -839,8 +831,8 @@ HangMonitoredProcess::BeginStartingDebugger() return NS_ERROR_UNEXPECTED; } - RefPtr runnable = NS_NewNonOwningRunnableMethod(mActor, &HangMonitorParent::BeginStartingDebugger); - ProcessHangMonitor::Get()->MonitorLoop()->PostTask(runnable.forget()); + ProcessHangMonitor::Get()->MonitorLoop()->PostTask(NewNonOwningRunnableMethod(mActor, + &HangMonitorParent::BeginStartingDebugger)); return NS_OK; } @@ -856,8 +848,8 @@ HangMonitoredProcess::EndStartingDebugger() return NS_ERROR_UNEXPECTED; } - RefPtr runnable = NS_NewNonOwningRunnableMethod(mActor, &HangMonitorParent::EndStartingDebugger); - ProcessHangMonitor::Get()->MonitorLoop()->PostTask(runnable.forget()); + ProcessHangMonitor::Get()->MonitorLoop()->PostTask(NewNonOwningRunnableMethod(mActor, + &HangMonitorParent::EndStartingDebugger)); return NS_OK; } @@ -1035,14 +1027,13 @@ mozilla::CreateHangMonitorParent(ContentParent* aContentParent, HangMonitoredProcess* process = new HangMonitoredProcess(parent, aContentParent); parent->SetProcess(process); - RefPtr runnable = - NS_NewNonOwningRunnableMethodWithArgs(parent, - &HangMonitorParent::Open, - aTransport, aOtherPid, - XRE_GetIOMessageLoop()); - monitor->MonitorLoop()->PostTask(runnable.forget()); + monitor->MonitorLoop()->PostTask(NewNonOwningRunnableMethod + (parent, + &HangMonitorParent::Open, + aTransport, aOtherPid, + XRE_GetIOMessageLoop())); return parent; } @@ -1056,14 +1047,13 @@ mozilla::CreateHangMonitorChild(mozilla::ipc::Transport* aTransport, ProcessHangMonitor* monitor = ProcessHangMonitor::GetOrCreate(); HangMonitorChild* child = new HangMonitorChild(monitor); - RefPtr runnable = - NS_NewNonOwningRunnableMethodWithArgs(child, - &HangMonitorChild::Open, - aTransport, aOtherPid, - XRE_GetIOMessageLoop()); - monitor->MonitorLoop()->PostTask(runnable.forget()); + monitor->MonitorLoop()->PostTask(NewNonOwningRunnableMethod + (child, + &HangMonitorChild::Open, + aTransport, aOtherPid, + XRE_GetIOMessageLoop())); return child; } diff --git a/dom/jsurl/nsJSProtocolHandler.cpp b/dom/jsurl/nsJSProtocolHandler.cpp index 9a753d0872bf..543a1785732a 100644 --- a/dom/jsurl/nsJSProtocolHandler.cpp +++ b/dom/jsurl/nsJSProtocolHandler.cpp @@ -659,8 +659,7 @@ nsJSChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *aContext) method = &nsJSChannel::NotifyListener; } - nsCOMPtr ev = NS_NewRunnableMethod(this, method); - nsresult rv = NS_DispatchToCurrentThread(ev); + nsresult rv = NS_DispatchToCurrentThread(mozilla::NewRunnableMethod(this, method)); if (NS_FAILED(rv)) { loadGroup->RemoveRequest(this, nullptr, rv); diff --git a/dom/media/AbstractMediaDecoder.h b/dom/media/AbstractMediaDecoder.h index f4764bbbd3f6..c4d2ed02cf9c 100644 --- a/dom/media/AbstractMediaDecoder.h +++ b/dom/media/AbstractMediaDecoder.h @@ -74,10 +74,9 @@ protected: public: void DispatchUpdateEstimatedMediaDuration(int64_t aDuration) { - nsCOMPtr r = - NS_NewRunnableMethodWithArg(this, &AbstractMediaDecoder::UpdateEstimatedMediaDuration, - aDuration); - NS_DispatchToMainThread(r); + NS_DispatchToMainThread(NewRunnableMethod(this, + &AbstractMediaDecoder::UpdateEstimatedMediaDuration, + aDuration)); } virtual VideoFrameContainer* GetVideoFrameContainer() = 0; diff --git a/dom/media/DOMMediaStream.cpp b/dom/media/DOMMediaStream.cpp index c557663f9245..a42f08553c9f 100644 --- a/dom/media/DOMMediaStream.cpp +++ b/dom/media/DOMMediaStream.cpp @@ -191,13 +191,13 @@ public: { if (aTrackEvents & TRACK_EVENT_CREATED) { nsCOMPtr runnable = - NS_NewRunnableMethodWithArgs( + NewRunnableMethod( this, &OwnedStreamListener::DoNotifyTrackCreated, aID, aQueuedMedia.GetType(), aInputStream, aInputTrackID); aGraph->DispatchToMainThreadAfterStreamStateUpdate(runnable.forget()); } else if (aTrackEvents & TRACK_EVENT_ENDED) { nsCOMPtr runnable = - NS_NewRunnableMethodWithArgs( + NewRunnableMethod( this, &OwnedStreamListener::DoNotifyTrackEnded, aInputStream, aInputTrackID); aGraph->DispatchToMainThreadAfterStreamStateUpdate(runnable.forget()); @@ -281,7 +281,7 @@ public: { if (aTrackEvents & TRACK_EVENT_ENDED) { nsCOMPtr runnable = - NS_NewRunnableMethodWithArgs, TrackID>( + NewRunnableMethod, TrackID>( this, &PlaybackStreamListener::DoNotifyTrackEnded, aInputStream, aInputTrackID); aGraph->DispatchToMainThreadAfterStreamStateUpdate(runnable.forget()); } @@ -290,7 +290,7 @@ public: void NotifyFinishedTrackCreation(MediaStreamGraph* aGraph) override { nsCOMPtr runnable = - NS_NewRunnableMethod(this, &PlaybackStreamListener::DoNotifyFinishedTrackCreation); + NewRunnableMethod(this, &PlaybackStreamListener::DoNotifyFinishedTrackCreation); aGraph->DispatchToMainThreadAfterStreamStateUpdate(runnable.forget()); } diff --git a/dom/media/MediaDecoderReader.cpp b/dom/media/MediaDecoderReader.cpp index 65a06c57f699..17db94596375 100644 --- a/dom/media/MediaDecoderReader.cpp +++ b/dom/media/MediaDecoderReader.cpp @@ -85,8 +85,7 @@ MediaDecoderReader::MediaDecoderReader(AbstractMediaDecoder* aDecoder) } // Dispatch initialization that needs to happen on that task queue. - nsCOMPtr r = NS_NewRunnableMethod(this, &MediaDecoderReader::InitializationTask); - mTaskQueue->Dispatch(r.forget()); + mTaskQueue->Dispatch(NewRunnableMethod(this, &MediaDecoderReader::InitializationTask)); } void diff --git a/dom/media/MediaDecoderReaderWrapper.cpp b/dom/media/MediaDecoderReaderWrapper.cpp index 4bed533f1cca..e96186e06996 100644 --- a/dom/media/MediaDecoderReaderWrapper.cpp +++ b/dom/media/MediaDecoderReaderWrapper.cpp @@ -316,7 +316,7 @@ MediaDecoderReaderWrapper::ReleaseMediaResources() { MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn()); nsCOMPtr r = - NS_NewRunnableMethod(mReader, &MediaDecoderReader::ReleaseMediaResources); + NewRunnableMethod(mReader, &MediaDecoderReader::ReleaseMediaResources); mReader->OwnerThread()->Dispatch(r.forget()); } @@ -325,7 +325,7 @@ MediaDecoderReaderWrapper::SetIdle() { MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn()); nsCOMPtr r = - NS_NewRunnableMethod(mReader, &MediaDecoderReader::SetIdle); + NewRunnableMethod(mReader, &MediaDecoderReader::SetIdle); mReader->OwnerThread()->Dispatch(r.forget()); } @@ -338,7 +338,7 @@ MediaDecoderReaderWrapper::ResetDecode() mVideoDataRequest.DisconnectIfExists(); nsCOMPtr r = - NS_NewRunnableMethod(mReader, &MediaDecoderReader::ResetDecode); + NewRunnableMethod(mReader, &MediaDecoderReader::ResetDecode); mReader->OwnerThread()->Dispatch(r.forget()); } diff --git a/dom/media/MediaDecoderStateMachine.cpp b/dom/media/MediaDecoderStateMachine.cpp index c733a2443892..ee9113662bfc 100644 --- a/dom/media/MediaDecoderStateMachine.cpp +++ b/dom/media/MediaDecoderStateMachine.cpp @@ -894,7 +894,7 @@ nsresult MediaDecoderStateMachine::Init(MediaDecoder* aDecoder) MOZ_ASSERT(NS_IsMainThread()); // Dispatch initialization that needs to happen on that task queue. - nsCOMPtr r = NS_NewRunnableMethodWithArg>( + nsCOMPtr r = NewRunnableMethod>( this, &MediaDecoderStateMachine::InitializationTask, aDecoder); mTaskQueue->Dispatch(r.forget()); @@ -917,8 +917,7 @@ nsresult MediaDecoderStateMachine::Init(MediaDecoder* aDecoder) nsresult rv = mReader->Init(); NS_ENSURE_SUCCESS(rv, rv); - r = NS_NewRunnableMethod(this, &MediaDecoderStateMachine::ReadMetadata); - OwnerThread()->Dispatch(r.forget()); + OwnerThread()->Dispatch(NewRunnableMethod(this, &MediaDecoderStateMachine::ReadMetadata)); return NS_OK; } @@ -1119,7 +1118,7 @@ void MediaDecoderStateMachine::RecomputeDuration() void MediaDecoderStateMachine::DispatchSetDormant(bool aDormant) { - nsCOMPtr r = NS_NewRunnableMethodWithArg( + nsCOMPtr r = NewRunnableMethod( this, &MediaDecoderStateMachine::SetDormant, aDormant); OwnerThread()->Dispatch(r.forget()); } @@ -2445,9 +2444,7 @@ MediaDecoderStateMachine::ScheduleStateMachine() } mDispatchedStateMachine = true; - nsCOMPtr task = - NS_NewRunnableMethod(this, &MediaDecoderStateMachine::RunStateMachine); - OwnerThread()->Dispatch(task.forget()); + OwnerThread()->Dispatch(NewRunnableMethod(this, &MediaDecoderStateMachine::RunStateMachine)); } void @@ -2706,7 +2703,7 @@ void MediaDecoderStateMachine::AddOutputStream(ProcessedMediaStream* aStream, MOZ_ASSERT(NS_IsMainThread()); DECODER_LOG("AddOutputStream aStream=%p!", aStream); mOutputStreamManager->Add(aStream, aFinishWhenEnded); - nsCOMPtr r = NS_NewRunnableMethodWithArg( + nsCOMPtr r = NewRunnableMethod( this, &MediaDecoderStateMachine::SetAudioCaptured, true); OwnerThread()->Dispatch(r.forget()); } @@ -2717,7 +2714,7 @@ void MediaDecoderStateMachine::RemoveOutputStream(MediaStream* aStream) DECODER_LOG("RemoveOutputStream=%p!", aStream); mOutputStreamManager->Remove(aStream); if (mOutputStreamManager->IsEmpty()) { - nsCOMPtr r = NS_NewRunnableMethodWithArg( + nsCOMPtr r = NewRunnableMethod( this, &MediaDecoderStateMachine::SetAudioCaptured, false); OwnerThread()->Dispatch(r.forget()); } diff --git a/dom/media/MediaFormatReader.cpp b/dom/media/MediaFormatReader.cpp index e7c9ea13307c..55a5d1f8fa7c 100644 --- a/dom/media/MediaFormatReader.cpp +++ b/dom/media/MediaFormatReader.cpp @@ -771,7 +771,7 @@ MediaFormatReader::ScheduleUpdate(TrackType aTrack) LOGV("SchedulingUpdate(%s)", TrackTypeToStr(aTrack)); decoder.mUpdateScheduled = true; RefPtr task( - NS_NewRunnableMethodWithArg(this, &MediaFormatReader::Update, aTrack)); + NewRunnableMethod(this, &MediaFormatReader::Update, aTrack)); OwnerThread()->Dispatch(task.forget()); } @@ -1322,7 +1322,7 @@ MediaFormatReader::Output(TrackType aTrack, MediaData* aSample) } RefPtr task = - NS_NewRunnableMethodWithArgs( + NewRunnableMethod( this, &MediaFormatReader::NotifyNewOutput, aTrack, aSample); OwnerThread()->Dispatch(task.forget()); } @@ -1331,7 +1331,7 @@ void MediaFormatReader::DrainComplete(TrackType aTrack) { RefPtr task = - NS_NewRunnableMethodWithArg( + NewRunnableMethod( this, &MediaFormatReader::NotifyDrainComplete, aTrack); OwnerThread()->Dispatch(task.forget()); } @@ -1340,7 +1340,7 @@ void MediaFormatReader::InputExhausted(TrackType aTrack) { RefPtr task = - NS_NewRunnableMethodWithArg( + NewRunnableMethod( this, &MediaFormatReader::NotifyInputExhausted, aTrack); OwnerThread()->Dispatch(task.forget()); } @@ -1349,7 +1349,7 @@ void MediaFormatReader::Error(TrackType aTrack) { RefPtr task = - NS_NewRunnableMethodWithArg( + NewRunnableMethod( this, &MediaFormatReader::NotifyError, aTrack); OwnerThread()->Dispatch(task.forget()); } @@ -1469,9 +1469,7 @@ MediaFormatReader::Seek(SeekTarget aTarget, int64_t aUnused) RefPtr p = mSeekPromise.Ensure(__func__); - RefPtr task( - NS_NewRunnableMethod(this, &MediaFormatReader::AttemptSeek)); - OwnerThread()->Dispatch(task.forget()); + OwnerThread()->Dispatch(NewRunnableMethod(this, &MediaFormatReader::AttemptSeek)); return p; } diff --git a/dom/media/MediaFormatReader.h b/dom/media/MediaFormatReader.h index 6ad136e830b4..d03a04c2cd44 100644 --- a/dom/media/MediaFormatReader.h +++ b/dom/media/MediaFormatReader.h @@ -82,7 +82,7 @@ public: mDemuxOnly = aDemuxedOnly; return; } - nsCOMPtr r = NS_NewRunnableMethodWithArg( + nsCOMPtr r = NewRunnableMethod( this, &MediaDecoderReader::SetDemuxOnly, aDemuxedOnly); OwnerThread()->Dispatch(r.forget()); } diff --git a/dom/media/MediaManager.h b/dom/media/MediaManager.h index e8d5db855331..7aa3b10bb3fa 100644 --- a/dom/media/MediaManager.h +++ b/dom/media/MediaManager.h @@ -277,11 +277,11 @@ public: switch (aEvent) { case EVENT_FINISHED: NS_DispatchToMainThread( - NS_NewRunnableMethod(this, &GetUserMediaCallbackMediaStreamListener::NotifyFinished)); + NewRunnableMethod(this, &GetUserMediaCallbackMediaStreamListener::NotifyFinished)); break; case EVENT_REMOVED: NS_DispatchToMainThread( - NS_NewRunnableMethod(this, &GetUserMediaCallbackMediaStreamListener::NotifyRemoved)); + NewRunnableMethod(this, &GetUserMediaCallbackMediaStreamListener::NotifyRemoved)); break; case EVENT_HAS_DIRECT_LISTENERS: NotifyDirectListeners(aGraph, true); diff --git a/dom/media/MediaRecorder.cpp b/dom/media/MediaRecorder.cpp index b366681cef26..2d25a7570074 100644 --- a/dom/media/MediaRecorder.cpp +++ b/dom/media/MediaRecorder.cpp @@ -819,10 +819,8 @@ private: new DispatchStartEventRunnable(this, NS_LITERAL_STRING("start"))); if (NS_FAILED(rv)) { - nsCOMPtr runnable = - NS_NewRunnableMethodWithArg(mRecorder, - &MediaRecorder::NotifyError, rv); - NS_DispatchToMainThread(runnable); + NS_DispatchToMainThread(NewRunnableMethod(mRecorder, + &MediaRecorder::NotifyError, rv)); } if (NS_FAILED(NS_DispatchToMainThread(new EncoderErrorNotifierRunnable(this)))) { MOZ_ASSERT(false, "NS_DispatchToMainThread EncoderErrorNotifierRunnable failed"); diff --git a/dom/media/MediaResource.cpp b/dom/media/MediaResource.cpp index 66cd7a01f580..b5b47bc23e71 100644 --- a/dom/media/MediaResource.cpp +++ b/dom/media/MediaResource.cpp @@ -56,9 +56,8 @@ MediaResource::Destroy() delete this; return; } - nsCOMPtr destroyRunnable = - NS_NewNonOwningRunnableMethod(this, &MediaResource::Destroy); - MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(destroyRunnable)); + MOZ_ALWAYS_SUCCEEDS( + NS_DispatchToMainThread(NewNonOwningRunnableMethod(this, &MediaResource::Destroy))); } NS_IMPL_ADDREF(MediaResource) @@ -871,7 +870,7 @@ ChannelMediaResource::CacheClientNotifyDataReceived() return; mDataReceivedEvent = - NS_NewNonOwningRunnableMethod(this, &ChannelMediaResource::DoNotifyDataReceived); + NewNonOwningRunnableMethod(this, &ChannelMediaResource::DoNotifyDataReceived); NS_DispatchToMainThread(mDataReceivedEvent.get()); } diff --git a/dom/media/MediaStreamTrack.cpp b/dom/media/MediaStreamTrack.cpp index ff364e7fce6f..ee5f6028be22 100644 --- a/dom/media/MediaStreamTrack.cpp +++ b/dom/media/MediaStreamTrack.cpp @@ -89,7 +89,7 @@ public: const PrincipalHandle& aNewPrincipalHandle) override { nsCOMPtr runnable = - NS_NewRunnableMethodWithArgs>( + NewRunnableMethod>( this, &PrincipalHandleListener::DoNotifyPrincipalHandleChanged, aNewPrincipalHandle); aGraph->DispatchToMainThreadAfterStreamStateUpdate(runnable.forget()); } diff --git a/dom/media/MediaTimer.cpp b/dom/media/MediaTimer.cpp index 89b14e26a845..1420d6aca1bc 100644 --- a/dom/media/MediaTimer.cpp +++ b/dom/media/MediaTimer.cpp @@ -38,12 +38,12 @@ MediaTimer::MediaTimer() void MediaTimer::DispatchDestroy() { - nsCOMPtr task = NS_NewNonOwningRunnableMethod(this, &MediaTimer::Destroy); // Hold a strong reference to the thread so that it doesn't get deleted in // Destroy(), which may run completely before the stack if Dispatch() begins // to unwind. nsCOMPtr thread = mThread; - nsresult rv = thread->Dispatch(task, NS_DISPATCH_NORMAL); + nsresult rv = thread->Dispatch(NewNonOwningRunnableMethod(this, &MediaTimer::Destroy), + NS_DISPATCH_NORMAL); MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv)); (void) rv; } @@ -97,8 +97,8 @@ MediaTimer::ScheduleUpdate() } mUpdateScheduled = true; - nsCOMPtr task = NS_NewRunnableMethod(this, &MediaTimer::Update); - nsresult rv = mThread->Dispatch(task, NS_DISPATCH_NORMAL); + nsresult rv = mThread->Dispatch(NewRunnableMethod(this, &MediaTimer::Update), + NS_DISPATCH_NORMAL); MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv)); (void) rv; } diff --git a/dom/media/RtspMediaResource.cpp b/dom/media/RtspMediaResource.cpp index 42a8c53bb80d..818857967005 100644 --- a/dom/media/RtspMediaResource.cpp +++ b/dom/media/RtspMediaResource.cpp @@ -525,8 +525,8 @@ void RtspMediaResource::SetSuspend(bool aIsSuspend) RTSPMLOG("SetSuspend %d",aIsSuspend); nsCOMPtr runnable = - NS_NewRunnableMethodWithArg(this, &RtspMediaResource::NotifySuspend, - aIsSuspend); + NewRunnableMethod(this, &RtspMediaResource::NotifySuspend, + aIsSuspend); NS_DispatchToMainThread(runnable); } diff --git a/dom/media/eme/CDMCallbackProxy.cpp b/dom/media/eme/CDMCallbackProxy.cpp index 51366299fb12..fb69a8086940 100644 --- a/dom/media/eme/CDMCallbackProxy.cpp +++ b/dom/media/eme/CDMCallbackProxy.cpp @@ -222,16 +222,16 @@ CDMCallbackProxy::SessionClosed(const nsCString& aSessionId) } if (keyStatusesChange) { nsCOMPtr task; - task = NS_NewRunnableMethodWithArg(mProxy, + task = NewRunnableMethod(mProxy, &CDMProxy::OnKeyStatusesChange, NS_ConvertUTF8toUTF16(aSessionId)); NS_DispatchToMainThread(task); } nsCOMPtr task; - task = NS_NewRunnableMethodWithArg(mProxy, - &CDMProxy::OnSessionClosed, - NS_ConvertUTF8toUTF16(aSessionId)); + task = NewRunnableMethod(mProxy, + &CDMProxy::OnSessionClosed, + NS_ConvertUTF8toUTF16(aSessionId)); NS_DispatchToMainThread(task); } @@ -295,9 +295,9 @@ CDMCallbackProxy::KeyStatusChanged(const nsCString& aSessionId, } if (keyStatusesChange) { nsCOMPtr task; - task = NS_NewRunnableMethodWithArg(mProxy, - &CDMProxy::OnKeyStatusesChange, - NS_ConvertUTF8toUTF16(aSessionId)); + task = NewRunnableMethod(mProxy, + &CDMProxy::OnKeyStatusesChange, + NS_ConvertUTF8toUTF16(aSessionId)); NS_DispatchToMainThread(task); } } @@ -325,7 +325,7 @@ void CDMCallbackProxy::Terminated() { MOZ_ASSERT(mProxy->IsOnGMPThread()); - nsCOMPtr task = NS_NewRunnableMethod(mProxy, &CDMProxy::Terminated); + nsCOMPtr task = NewRunnableMethod(mProxy, &CDMProxy::Terminated); NS_DispatchToMainThread(task); } diff --git a/dom/media/eme/CDMProxy.cpp b/dom/media/eme/CDMProxy.cpp index 625aa14df459..9603374eb92f 100644 --- a/dom/media/eme/CDMProxy.cpp +++ b/dom/media/eme/CDMProxy.cpp @@ -83,9 +83,9 @@ CDMProxy::Init(PromiseId aPromiseId, data->mGMPName = aGMPName; data->mInPrivateBrowsing = aInPrivateBrowsing; nsCOMPtr task( - NS_NewRunnableMethodWithArg>(this, - &CDMProxy::gmp_Init, - Move(data))); + NewRunnableMethod>(this, + &CDMProxy::gmp_Init, + Move(data))); mGMPThread->Dispatch(task, NS_DISPATCH_NORMAL); } @@ -119,9 +119,9 @@ CDMProxy::gmp_InitDone(GMPDecryptorProxy* aCDM, nsAutoPtr&& aData) mCallback = new CDMCallbackProxy(this); mCDM->Init(mCallback); nsCOMPtr task( - NS_NewRunnableMethodWithArg(this, - &CDMProxy::OnCDMCreated, - aData->mPromiseId)); + NewRunnableMethod(this, + &CDMProxy::OnCDMCreated, + aData->mPromiseId)); NS_DispatchToMainThread(task); } @@ -270,7 +270,7 @@ CDMProxy::CreateSession(uint32_t aCreateSessionToken, data->mInitData = Move(aInitData); nsCOMPtr task( - NS_NewRunnableMethodWithArg>(this, &CDMProxy::gmp_CreateSession, data)); + NewRunnableMethod>(this, &CDMProxy::gmp_CreateSession, data)); mGMPThread->Dispatch(task, NS_DISPATCH_NORMAL); } @@ -310,7 +310,7 @@ CDMProxy::LoadSession(PromiseId aPromiseId, data->mPromiseId = aPromiseId; data->mSessionId = NS_ConvertUTF16toUTF8(aSessionId); nsCOMPtr task( - NS_NewRunnableMethodWithArg>(this, &CDMProxy::gmp_LoadSession, data)); + NewRunnableMethod>(this, &CDMProxy::gmp_LoadSession, data)); mGMPThread->Dispatch(task, NS_DISPATCH_NORMAL); } @@ -338,7 +338,7 @@ CDMProxy::SetServerCertificate(PromiseId aPromiseId, data->mPromiseId = aPromiseId; data->mCert = Move(aCert); nsCOMPtr task( - NS_NewRunnableMethodWithArg>(this, &CDMProxy::gmp_SetServerCertificate, data)); + NewRunnableMethod>(this, &CDMProxy::gmp_SetServerCertificate, data)); mGMPThread->Dispatch(task, NS_DISPATCH_NORMAL); } @@ -368,7 +368,7 @@ CDMProxy::UpdateSession(const nsAString& aSessionId, data->mSessionId = NS_ConvertUTF16toUTF8(aSessionId); data->mResponse = Move(aResponse); nsCOMPtr task( - NS_NewRunnableMethodWithArg>(this, &CDMProxy::gmp_UpdateSession, data)); + NewRunnableMethod>(this, &CDMProxy::gmp_UpdateSession, data)); mGMPThread->Dispatch(task, NS_DISPATCH_NORMAL); } @@ -397,7 +397,7 @@ CDMProxy::CloseSession(const nsAString& aSessionId, data->mPromiseId = aPromiseId; data->mSessionId = NS_ConvertUTF16toUTF8(aSessionId); nsCOMPtr task( - NS_NewRunnableMethodWithArg>(this, &CDMProxy::gmp_CloseSession, data)); + NewRunnableMethod>(this, &CDMProxy::gmp_CloseSession, data)); mGMPThread->Dispatch(task, NS_DISPATCH_NORMAL); } @@ -424,7 +424,7 @@ CDMProxy::RemoveSession(const nsAString& aSessionId, data->mPromiseId = aPromiseId; data->mSessionId = NS_ConvertUTF16toUTF8(aSessionId); nsCOMPtr task( - NS_NewRunnableMethodWithArg>(this, &CDMProxy::gmp_RemoveSession, data)); + NewRunnableMethod>(this, &CDMProxy::gmp_RemoveSession, data)); mGMPThread->Dispatch(task, NS_DISPATCH_NORMAL); } @@ -446,7 +446,7 @@ CDMProxy::Shutdown() MOZ_ASSERT(NS_IsMainThread()); mKeys.Clear(); // Note: This may end up being the last owning reference to the CDMProxy. - nsCOMPtr task(NS_NewRunnableMethod(this, &CDMProxy::gmp_Shutdown)); + nsCOMPtr task(NewRunnableMethod(this, &CDMProxy::gmp_Shutdown)); if (mGMPThread) { mGMPThread->Dispatch(task, NS_DISPATCH_NORMAL); } @@ -498,9 +498,9 @@ CDMProxy::ResolvePromise(PromiseId aId) } } else { nsCOMPtr task; - task = NS_NewRunnableMethodWithArg(this, - &CDMProxy::ResolvePromise, - aId); + task = NewRunnableMethod(this, + &CDMProxy::ResolvePromise, + aId); NS_DispatchToMainThread(task); } } @@ -659,7 +659,7 @@ CDMProxy::Decrypt(MediaRawData* aSample) RefPtr promise(job->Ensure()); nsCOMPtr task( - NS_NewRunnableMethodWithArg>(this, &CDMProxy::gmp_Decrypt, job)); + NewRunnableMethod>(this, &CDMProxy::gmp_Decrypt, job)); mGMPThread->Dispatch(task, NS_DISPATCH_NORMAL); return promise; } diff --git a/dom/media/gmp/GMPContentParent.cpp b/dom/media/gmp/GMPContentParent.cpp index 83d523c91a3f..4eea05ae2d3c 100644 --- a/dom/media/gmp/GMPContentParent.cpp +++ b/dom/media/gmp/GMPContentParent.cpp @@ -134,8 +134,8 @@ GMPContentParent::CloseIfUnused() GeckoMediaPluginServiceChild::GetSingleton()); gmp->RemoveGMPContentParent(toClose); } - NS_DispatchToCurrentThread(NS_NewRunnableMethod(toClose, - &GMPContentParent::Close)); + NS_DispatchToCurrentThread(NewRunnableMethod(toClose, + &GMPContentParent::Close)); } } diff --git a/dom/media/gmp/GMPContentParent.h b/dom/media/gmp/GMPContentParent.h index 0003b5e1afb2..38fd775f7c8f 100644 --- a/dom/media/gmp/GMPContentParent.h +++ b/dom/media/gmp/GMPContentParent.h @@ -79,7 +79,7 @@ private: bool DeallocPGMPAudioDecoderParent(PGMPAudioDecoderParent* aActor) override; void CloseIfUnused(); - // Needed because NS_NewRunnableMethod tried to use the class that the method + // Needed because NewRunnableMethod tried to use the class that the method // lives on to store the receiver, but PGMPContentParent isn't refcounted. void Close() { diff --git a/dom/media/gmp/GMPDecryptorChild.cpp b/dom/media/gmp/GMPDecryptorChild.cpp index 1999165d76f4..ebecf239e8a7 100644 --- a/dom/media/gmp/GMPDecryptorChild.cpp +++ b/dom/media/gmp/GMPDecryptorChild.cpp @@ -171,12 +171,10 @@ GMPDecryptorChild::Decrypted(GMPBuffer* aBuffer, GMPErr aResult) if (!ON_GMP_THREAD()) { // We should run this whole method on the GMP thread since the buffer needs // to be deleted after the SendDecrypted call. - RefPtr t = - NS_NewRunnableMethodWithArgs(this, - &GMPDecryptorChild::Decrypted, - aBuffer, aResult); - mPlugin->GMPMessageLoop()->PostTask(t.forget()); + mPlugin->GMPMessageLoop()->PostTask(NewRunnableMethod + (this, + &GMPDecryptorChild::Decrypted, + aBuffer, aResult)); return; } diff --git a/dom/media/gmp/GMPParent.cpp b/dom/media/gmp/GMPParent.cpp index cdbeb195d119..d019c5f9fc6d 100644 --- a/dom/media/gmp/GMPParent.cpp +++ b/dom/media/gmp/GMPParent.cpp @@ -503,7 +503,7 @@ GMPParent::ChildTerminated() // removed so there is no harm in not trying to remove it again. LOGD("%s::%s: GMPThread() returned nullptr.", __CLASS__, __FUNCTION__); } else { - gmpThread->Dispatch(NS_NewRunnableMethodWithArg>( + gmpThread->Dispatch(NewRunnableMethod>( mService, &GeckoMediaPluginServiceParent::PluginTerminated, self), @@ -522,7 +522,7 @@ GMPParent::DeleteProcess() mState = GMPStateClosing; Close(); } - mProcess->Delete(NS_NewRunnableMethod(this, &GMPParent::ChildTerminated)); + mProcess->Delete(NewRunnableMethod(this, &GMPParent::ChildTerminated)); LOGD("%s: Shut down process", __FUNCTION__); mProcess = nullptr; mState = GMPStateNotLoaded; diff --git a/dom/media/gmp/GMPPlatform.cpp b/dom/media/gmp/GMPPlatform.cpp index 306e2ce66cb1..4746795700d4 100644 --- a/dom/media/gmp/GMPPlatform.cpp +++ b/dom/media/gmp/GMPPlatform.cpp @@ -73,8 +73,7 @@ public: // main thread tries to do a sync call back to the calling thread. MOZ_ASSERT(!IsOnChildMainThread()); - RefPtr runnable = NS_NewRunnableMethod(this, &GMPSyncRunnable::Run); - mMessageLoop->PostTask(runnable.forget()); + mMessageLoop->PostTask(NewRunnableMethod(this, &GMPSyncRunnable::Run)); MonitorAutoLock lock(mMonitor); while (!mDone) { lock.Wait(); @@ -122,8 +121,7 @@ RunOnMainThread(GMPTask* aTask) } RefPtr r = new GMPRunnable(aTask); - RefPtr runnable = NS_NewRunnableMethod(r, &GMPRunnable::Run); - sMainLoop->PostTask(runnable.forget()); + sMainLoop->PostTask(NewRunnableMethod(r, &GMPRunnable::Run)); return GMPNoErr; } @@ -255,8 +253,7 @@ GMPThreadImpl::Post(GMPTask* aTask) } RefPtr r = new GMPRunnable(aTask); - RefPtr runnable = NS_NewRunnableMethod(r.get(), &GMPRunnable::Run); - mThread.message_loop()->PostTask(runnable.forget()); + mThread.message_loop()->PostTask(NewRunnableMethod(r.get(), &GMPRunnable::Run)); } void diff --git a/dom/media/gmp/GMPProcessParent.cpp b/dom/media/gmp/GMPProcessParent.cpp index 9a7a45a792e8..ed1903bce46a 100644 --- a/dom/media/gmp/GMPProcessParent.cpp +++ b/dom/media/gmp/GMPProcessParent.cpp @@ -78,8 +78,7 @@ void GMPProcessParent::Delete(nsCOMPtr aCallback) { mDeletedCallback = aCallback; - RefPtr task = NS_NewNonOwningRunnableMethod(this, &GMPProcessParent::DoDelete); - XRE_GetIOMessageLoop()->PostTask(task.forget()); + XRE_GetIOMessageLoop()->PostTask(NewNonOwningRunnableMethod(this, &GMPProcessParent::DoDelete)); } void diff --git a/dom/media/gmp/GMPService.cpp b/dom/media/gmp/GMPService.cpp index 683f8aeb7ec5..72ce9deadc8a 100644 --- a/dom/media/gmp/GMPService.cpp +++ b/dom/media/gmp/GMPService.cpp @@ -326,7 +326,16 @@ GeckoMediaPluginService::ShutdownGMPThread() } nsresult -GeckoMediaPluginService::GMPDispatch(nsIRunnable* event, uint32_t flags) +GeckoMediaPluginService::GMPDispatch(nsIRunnable* event, + uint32_t flags) +{ + nsCOMPtr r(event); + return GMPDispatch(r.forget()); +} + +nsresult +GeckoMediaPluginService::GMPDispatch(already_AddRefed event, + uint32_t flags) { nsCOMPtr r(event); nsCOMPtr thread; diff --git a/dom/media/gmp/GMPService.h b/dom/media/gmp/GMPService.h index 2bda87777da5..6b5113621ec5 100644 --- a/dom/media/gmp/GMPService.h +++ b/dom/media/gmp/GMPService.h @@ -90,6 +90,7 @@ protected: UniquePtr&& aCallback) = 0; nsresult GMPDispatch(nsIRunnable* event, uint32_t flags = NS_DISPATCH_NORMAL); + nsresult GMPDispatch(already_AddRefed event, uint32_t flags = NS_DISPATCH_NORMAL); void ShutdownGMPThread(); Mutex mMutex; // Protects mGMPThread and mGMPThreadShutdown and some members diff --git a/dom/media/gmp/GMPServiceParent.cpp b/dom/media/gmp/GMPServiceParent.cpp index b9e75fb78fde..cd76485c42cf 100644 --- a/dom/media/gmp/GMPServiceParent.cpp +++ b/dom/media/gmp/GMPServiceParent.cpp @@ -419,8 +419,8 @@ GeckoMediaPluginServiceParent::Observe(nsISupports* aSubject, NS_LITERAL_CSTRING("Dispatching UnloadPlugins")); #endif gmpThread->Dispatch( - NS_NewRunnableMethod(this, - &GeckoMediaPluginServiceParent::UnloadPlugins), + NewRunnableMethod(this, + &GeckoMediaPluginServiceParent::UnloadPlugins), NS_DISPATCH_NORMAL); #ifdef MOZ_CRASHREPORTER @@ -493,7 +493,7 @@ GeckoMediaPluginServiceParent::Observe(nsISupports* aSubject, } else if (!strcmp("browser:purge-session-history", aTopic)) { // Clear everything! if (!aSomeData || nsDependentString(aSomeData).IsEmpty()) { - return GMPDispatch(NS_NewRunnableMethod( + return GMPDispatch(NewRunnableMethod( this, &GeckoMediaPluginServiceParent::ClearStorage)); } @@ -503,7 +503,7 @@ GeckoMediaPluginServiceParent::Observe(nsISupports* aSubject, if (NS_FAILED(rv)) { return rv; } - return GMPDispatch(NS_NewRunnableMethodWithArg( + return GMPDispatch(NewRunnableMethod( this, &GeckoMediaPluginServiceParent::ClearRecentHistoryOnGMPThread, t)); } @@ -605,7 +605,7 @@ GeckoMediaPluginServiceParent::AsyncShutdownComplete(GMPParent* aParent) if (mShuttingDownOnGMPThread) { // The main thread may be waiting for async shutdown of plugins, // one of which has completed. Wake up the main thread by sending a task. - nsCOMPtr task(NS_NewRunnableMethod( + nsCOMPtr task(NewRunnableMethod( this, &GeckoMediaPluginServiceParent::NotifyAsyncShutdownComplete)); NS_DispatchToMainThread(task); } @@ -737,7 +737,7 @@ GeckoMediaPluginServiceParent::UnloadPlugins() SetAsyncShutdownPluginState(nullptr, '3', NS_LITERAL_CSTRING("Dispatching sync-shutdown-complete")); #endif - nsCOMPtr task(NS_NewRunnableMethod( + nsCOMPtr task(NewRunnableMethod( this, &GeckoMediaPluginServiceParent::NotifySyncShutdownComplete)); NS_DispatchToMainThread(task); } @@ -1749,7 +1749,7 @@ NS_IMETHODIMP GeckoMediaPluginServiceParent::ForgetThisSite(const nsAString& aSite) { MOZ_ASSERT(NS_IsMainThread()); - return GMPDispatch(NS_NewRunnableMethodWithArg( + return GMPDispatch(NewRunnableMethod( this, &GeckoMediaPluginServiceParent::ForgetThisSiteOnGMPThread, NS_ConvertUTF16toUTF8(aSite))); } diff --git a/dom/media/gmp/GMPVideoDecoderChild.cpp b/dom/media/gmp/GMPVideoDecoderChild.cpp index 1eb3e53df44b..259690628776 100644 --- a/dom/media/gmp/GMPVideoDecoderChild.cpp +++ b/dom/media/gmp/GMPVideoDecoderChild.cpp @@ -226,8 +226,8 @@ GMPVideoDecoderChild::Alloc(size_t aSize, rv = CallNeedShmem(aSize, aMem); --mNeedShmemIntrCount; if (mPendingDecodeComplete) { - RefPtr runnable = NS_NewRunnableMethod(this, &GMPVideoDecoderChild::RecvDecodingComplete); - mPlugin->GMPMessageLoop()->PostTask(runnable.forget()); + mPlugin->GMPMessageLoop()->PostTask( + NewRunnableMethod(this, &GMPVideoDecoderChild::RecvDecodingComplete)); } #else #ifdef GMP_SAFE_SHMEM diff --git a/dom/media/gmp/GMPVideoEncoderChild.cpp b/dom/media/gmp/GMPVideoEncoderChild.cpp index d10a677789da..fa139cef4900 100644 --- a/dom/media/gmp/GMPVideoEncoderChild.cpp +++ b/dom/media/gmp/GMPVideoEncoderChild.cpp @@ -207,8 +207,8 @@ GMPVideoEncoderChild::Alloc(size_t aSize, rv = CallNeedShmem(aSize, aMem); --mNeedShmemIntrCount; if (mPendingEncodeComplete) { - RefPtr runnable = NS_NewRunnableMethod(this, &GMPVideoEncoderChild::RecvEncodingComplete); - mPlugin->GMPMessageLoop()->PostTask(runnable.forget()); + mPlugin->GMPMessageLoop()->PostTask( + NewRunnableMethod(this, &GMPVideoEncoderChild::RecvEncodingComplete)); } #else #ifdef GMP_SAFE_SHMEM diff --git a/dom/media/gtest/GMPTestMonitor.h b/dom/media/gtest/GMPTestMonitor.h index d5b6d59c15fb..8ce6f8ddd83b 100644 --- a/dom/media/gtest/GMPTestMonitor.h +++ b/dom/media/gtest/GMPTestMonitor.h @@ -36,8 +36,8 @@ private: public: void SetFinished() { - NS_DispatchToMainThread(NS_NewNonOwningRunnableMethod(this, - &GMPTestMonitor::MarkFinished)); + NS_DispatchToMainThread(mozilla::NewNonOwningRunnableMethod(this, + &GMPTestMonitor::MarkFinished)); } private: diff --git a/dom/media/gtest/TestGMPCrossOrigin.cpp b/dom/media/gtest/TestGMPCrossOrigin.cpp index 16a9f549e2c9..ead44cf6edbd 100644 --- a/dom/media/gtest/TestGMPCrossOrigin.cpp +++ b/dom/media/gtest/TestGMPCrossOrigin.cpp @@ -304,8 +304,8 @@ EnumerateGMPStorageDir(const nsACString& aDir, T&& aDirIter) class GMPShutdownObserver : public nsIRunnable , public nsIObserver { public: - GMPShutdownObserver(nsIRunnable* aShutdownTask, - nsIRunnable* Continuation, + GMPShutdownObserver(already_AddRefed aShutdownTask, + already_AddRefed Continuation, const nsACString& aNodeId) : mShutdownTask(aShutdownTask) , mContinuation(Continuation) @@ -371,7 +371,7 @@ public: class ClearGMPStorageTask : public nsIRunnable , public nsIObserver { public: - ClearGMPStorageTask(nsIRunnable* Continuation, + ClearGMPStorageTask(already_AddRefed Continuation, nsIThread* aTarget, PRTime aSince) : mContinuation(Continuation) , mTarget(aTarget) @@ -421,11 +421,11 @@ private: NS_IMPL_ISUPPORTS(ClearGMPStorageTask, nsIRunnable, nsIObserver) static void -ClearGMPStorage(nsIRunnable* aContinuation, +ClearGMPStorage(already_AddRefed aContinuation, nsIThread* aTarget, PRTime aSince = -1) { RefPtr task( - new ClearGMPStorageTask(aContinuation, aTarget, aSince)); + new ClearGMPStorageTask(Move(aContinuation), aTarget, aSince)); NS_DispatchToMainThread(task, NS_DISPATCH_NORMAL); } @@ -516,7 +516,7 @@ class GMPStorageTest : public GMPDecryptorProxyCallback void DoTest(void (GMPStorageTest::*aTestMethod)()) { EnsureNSSInitializedChromeOrContent(); nsCOMPtr thread(GetGMPThread()); - ClearGMPStorage(NS_NewRunnableMethod(this, aTestMethod), thread); + ClearGMPStorage(NewRunnableMethod(this, aTestMethod), thread); AwaitFinished(); } @@ -569,7 +569,7 @@ class GMPStorageTest : public GMPDecryptorProxyCallback EXPECT_TRUE(!PBnodeId2.Equals(nodeId2)); nsCOMPtr thread(GetGMPThread()); - ClearGMPStorage(NS_NewRunnableMethodWithArg( + ClearGMPStorage(NewRunnableMethod( this, &GMPStorageTest::TestGetNodeId_Continuation, nodeId1), thread); } @@ -681,7 +681,7 @@ class GMPStorageTest : public GMPDecryptorProxyCallback // It sends us a "test-storage complete" message when its passed, or // some other message if its tests fail. Expect(NS_LITERAL_CSTRING("test-storage complete"), - NS_NewRunnableMethod(this, &GMPStorageTest::SetFinished)); + NewRunnableMethod(this, &GMPStorageTest::SetFinished)); CreateDecryptor(NS_LITERAL_STRING("http://example1.com"), NS_LITERAL_STRING("http://example2.com"), @@ -700,9 +700,9 @@ class GMPStorageTest : public GMPDecryptorProxyCallback EXPECT_TRUE(IsGMPStorageIsEmpty()); // Generate storage data for some site. - nsCOMPtr r = NS_NewRunnableMethod( + nsCOMPtr r = NewRunnableMethod( this, &GMPStorageTest::TestForgetThisSite_AnotherSite); - Expect(NS_LITERAL_CSTRING("test-storage complete"), r); + Expect(NS_LITERAL_CSTRING("test-storage complete"), r.forget()); CreateDecryptor(NS_LITERAL_STRING("http://example1.com"), NS_LITERAL_STRING("http://example2.com"), @@ -714,9 +714,9 @@ class GMPStorageTest : public GMPDecryptorProxyCallback Shutdown(); // Generate storage data for another site. - nsCOMPtr r = NS_NewRunnableMethod( + nsCOMPtr r = NewRunnableMethod( this, &GMPStorageTest::TestForgetThisSite_CollectSiteInfo); - Expect(NS_LITERAL_CSTRING("test-storage complete"), r); + Expect(NS_LITERAL_CSTRING("test-storage complete"), r.forget()); CreateDecryptor(NS_LITERAL_STRING("http://example3.com"), NS_LITERAL_STRING("http://example4.com"), @@ -751,7 +751,7 @@ class GMPStorageTest : public GMPDecryptorProxyCallback // Collect nodeIds that are expected to remain for later comparison. EnumerateGMPStorageDir(NS_LITERAL_CSTRING("id"), NodeIdCollector(siteInfo)); // Invoke "Forget this site" on the main thread. - NS_DispatchToMainThread(NS_NewRunnableMethodWithArg>( + NS_DispatchToMainThread(NewRunnableMethod>( this, &GMPStorageTest::TestForgetThisSite_Forget, siteInfo)); } @@ -763,11 +763,11 @@ class GMPStorageTest : public GMPDecryptorProxyCallback nsCOMPtr thread; service->GetThread(getter_AddRefs(thread)); - nsCOMPtr r = NS_NewRunnableMethodWithArg>( + nsCOMPtr r = NewRunnableMethod>( this, &GMPStorageTest::TestForgetThisSite_Verify, aSiteInfo); thread->Dispatch(r, NS_DISPATCH_NORMAL); - nsCOMPtr f = NS_NewRunnableMethod( + nsCOMPtr f = NewRunnableMethod( this, &GMPStorageTest::SetFinished); thread->Dispatch(f, NS_DISPATCH_NORMAL); } @@ -833,9 +833,9 @@ class GMPStorageTest : public GMPDecryptorProxyCallback EXPECT_TRUE(IsGMPStorageIsEmpty()); // Generate storage data for some site. - nsCOMPtr r = NS_NewRunnableMethod( + nsCOMPtr r = NewRunnableMethod( this, &GMPStorageTest::TestClearRecentHistory1_Clear); - Expect(NS_LITERAL_CSTRING("test-storage complete"), r); + Expect(NS_LITERAL_CSTRING("test-storage complete"), r.forget()); CreateDecryptor(NS_LITERAL_STRING("http://example1.com"), NS_LITERAL_STRING("http://example2.com"), @@ -855,9 +855,9 @@ class GMPStorageTest : public GMPDecryptorProxyCallback EXPECT_TRUE(IsGMPStorageIsEmpty()); // Generate storage data for some site. - nsCOMPtr r = NS_NewRunnableMethod( + nsCOMPtr r = NewRunnableMethod( this, &GMPStorageTest::TestClearRecentHistory2_Clear); - Expect(NS_LITERAL_CSTRING("test-storage complete"), r); + Expect(NS_LITERAL_CSTRING("test-storage complete"), r.forget()); CreateDecryptor(NS_LITERAL_STRING("http://example1.com"), NS_LITERAL_STRING("http://example2.com"), @@ -877,9 +877,9 @@ class GMPStorageTest : public GMPDecryptorProxyCallback EXPECT_TRUE(IsGMPStorageIsEmpty()); // Generate storage data for some site. - nsCOMPtr r = NS_NewRunnableMethod( + nsCOMPtr r = NewRunnableMethod( this, &GMPStorageTest::TestClearRecentHistory3_Clear); - Expect(NS_LITERAL_CSTRING("test-storage complete"), r); + Expect(NS_LITERAL_CSTRING("test-storage complete"), r.forget()); CreateDecryptor(NS_LITERAL_STRING("http://example1.com"), NS_LITERAL_STRING("http://example2.com"), @@ -908,10 +908,10 @@ class GMPStorageTest : public GMPDecryptorProxyCallback nsresult rv = EnumerateGMPStorageDir(NS_LITERAL_CSTRING("id"), f); EXPECT_TRUE(NS_SUCCEEDED(rv)); - nsCOMPtr r = NS_NewRunnableMethod( + nsCOMPtr r = NewRunnableMethod( this, &GMPStorageTest::TestClearRecentHistory_CheckEmpty); nsCOMPtr t(GetGMPThread()); - ClearGMPStorage(r, t, f.GetResult()); + ClearGMPStorage(r.forget(), t, f.GetResult()); } void TestClearRecentHistory2_Clear() { @@ -919,10 +919,10 @@ class GMPStorageTest : public GMPDecryptorProxyCallback nsresult rv = EnumerateGMPStorageDir(NS_LITERAL_CSTRING("storage"), f); EXPECT_TRUE(NS_SUCCEEDED(rv)); - nsCOMPtr r = NS_NewRunnableMethod( + nsCOMPtr r = NewRunnableMethod( this, &GMPStorageTest::TestClearRecentHistory_CheckEmpty); nsCOMPtr t(GetGMPThread()); - ClearGMPStorage(r, t, f.GetResult()); + ClearGMPStorage(r.forget(), t, f.GetResult()); } void TestClearRecentHistory3_Clear() { @@ -930,10 +930,10 @@ class GMPStorageTest : public GMPDecryptorProxyCallback nsresult rv = EnumerateGMPStorageDir(NS_LITERAL_CSTRING("storage"), f); EXPECT_TRUE(NS_SUCCEEDED(rv)); - nsCOMPtr r = NS_NewRunnableMethod( + nsCOMPtr r = NewRunnableMethod( this, &GMPStorageTest::TestClearRecentHistory_CheckNonEmpty); nsCOMPtr t(GetGMPThread()); - ClearGMPStorage(r, t, f.GetResult() + 1); + ClearGMPStorage(r.forget(), t, f.GetResult() + 1); } class FileCounter { @@ -987,7 +987,7 @@ class GMPStorageTest : public GMPDecryptorProxyCallback auto t = time(0); nsCString response("stored crossOriginTestRecordId "); response.AppendInt((int64_t)t); - Expect(response, NS_NewRunnableMethod(this, + Expect(response, NewRunnableMethod(this, &GMPStorageTest::TestCrossOriginStorage_RecordStoredContinuation)); nsCString update("store crossOriginTestRecordId "); @@ -1007,7 +1007,7 @@ class GMPStorageTest : public GMPDecryptorProxyCallback Shutdown(); Expect(NS_LITERAL_CSTRING("retrieve crossOriginTestRecordId succeeded (length 0 bytes)"), - NS_NewRunnableMethod(this, &GMPStorageTest::SetFinished)); + NewRunnableMethod(this, &GMPStorageTest::SetFinished)); CreateDecryptor(NS_LITERAL_STRING("http://example5.com"), NS_LITERAL_STRING("http://example6.com"), @@ -1019,7 +1019,7 @@ class GMPStorageTest : public GMPDecryptorProxyCallback // Send the decryptor the message "store recordid $time" // Wait for the decrytor to send us "stored recordid $time" nsCString response("stored pbdata test-pb-data"); - Expect(response, NS_NewRunnableMethod(this, + Expect(response, NewRunnableMethod(this, &GMPStorageTest::TestPBStorage_RecordStoredContinuation)); // Open decryptor on one, origin, write a record, close decryptor, @@ -1036,7 +1036,7 @@ class GMPStorageTest : public GMPDecryptorProxyCallback Shutdown(); Expect(NS_LITERAL_CSTRING("retrieve pbdata succeeded (length 12 bytes)"), - NS_NewRunnableMethod(this, + NewRunnableMethod(this, &GMPStorageTest::TestPBStorage_RecordRetrievedContinuation)); CreateDecryptor(NS_LITERAL_STRING("http://pb1.com"), @@ -1050,7 +1050,7 @@ class GMPStorageTest : public GMPDecryptorProxyCallback SimulatePBModeExit(); Expect(NS_LITERAL_CSTRING("retrieve pbdata succeeded (length 0 bytes)"), - NS_NewRunnableMethod(this, + NewRunnableMethod(this, &GMPStorageTest::SetFinished)); CreateDecryptor(NS_LITERAL_STRING("http://pb1.com"), @@ -1073,10 +1073,10 @@ class GMPStorageTest : public GMPDecryptorProxyCallback const nsAString& aOrigin2, void (GMPStorageTest::*aCallback)()) { nsCOMPtr continuation( - NS_NewRunnableMethodWithArg>( + NewRunnableMethod>( this, &GMPStorageTest::NextAsyncShutdownTimeoutTest, - NS_NewRunnableMethod(this, aCallback))); + NewRunnableMethod(this, aCallback))); CreateDecryptor(aOrigin1, aOrigin2, false, continuation); } @@ -1115,7 +1115,7 @@ class GMPStorageTest : public GMPDecryptorProxyCallback // the token. nsCString response("shutdown-token received "); response.Append(token); - Expect(response, NS_NewRunnableMethodWithArg(this, + Expect(response, NewRunnableMethod(this, &GMPStorageTest::TestAsyncShutdownStorage_ReceivedShutdownToken, token)); // Test that a GMP can write to storage during shutdown, and retrieve @@ -1127,7 +1127,7 @@ class GMPStorageTest : public GMPDecryptorProxyCallback } void TestAsyncShutdownStorage_ReceivedShutdownToken(const nsCString& aToken) { - ShutdownThen(NS_NewRunnableMethodWithArg(this, + ShutdownThen(NewRunnableMethod(this, &GMPStorageTest::TestAsyncShutdownStorage_AsyncShutdownComplete, aToken)); } @@ -1137,7 +1137,7 @@ class GMPStorageTest : public GMPDecryptorProxyCallback nsCString response("retrieved shutdown-token "); response.Append(aToken); Expect(response, - NS_NewRunnableMethod(this, &GMPStorageTest::SetFinished)); + NewRunnableMethod(this, &GMPStorageTest::SetFinished)); CreateDecryptor(NS_LITERAL_STRING("http://example13.com"), NS_LITERAL_STRING("http://example14.com"), @@ -1150,7 +1150,7 @@ class GMPStorageTest : public GMPDecryptorProxyCallback Shutdown(); Expect(NS_LITERAL_CSTRING("OP tests completed"), - NS_NewRunnableMethod(this, &GMPStorageTest::SetFinished)); + NewRunnableMethod(this, &GMPStorageTest::SetFinished)); CreateDecryptor(NS_LITERAL_STRING("http://example15.com"), NS_LITERAL_STRING("http://example16.com"), @@ -1161,7 +1161,7 @@ class GMPStorageTest : public GMPDecryptorProxyCallback void TestPluginVoucher() { Expect(NS_LITERAL_CSTRING("retrieved plugin-voucher: gmp-fake placeholder voucher"), - NS_NewRunnableMethod(this, &GMPStorageTest::SetFinished)); + NewRunnableMethod(this, &GMPStorageTest::SetFinished)); CreateDecryptor(NS_LITERAL_STRING("http://example17.com"), NS_LITERAL_STRING("http://example18.com"), @@ -1205,12 +1205,12 @@ class GMPStorageTest : public GMPDecryptorProxyCallback update.AppendLiteral(" test-data"); AppendIntPadded(update, i); - nsIRunnable* continuation = nullptr; + nsCOMPtr continuation; if (i + 1 == num) { continuation = - NS_NewRunnableMethod(this, &GMPStorageTest::TestGetRecordNames_QueryNames); + NewRunnableMethod(this, &GMPStorageTest::TestGetRecordNames_QueryNames); } - Expect(response, continuation); + Expect(response, continuation.forget()); } CreateDecryptor(NS_LITERAL_STRING("http://foo.com"), @@ -1223,7 +1223,7 @@ class GMPStorageTest : public GMPDecryptorProxyCallback nsCString response("record-names "); response.Append(mRecordNames); Expect(response, - NS_NewRunnableMethod(this, &GMPStorageTest::SetFinished)); + NewRunnableMethod(this, &GMPStorageTest::SetFinished)); Update(NS_LITERAL_CSTRING("retrieve-record-names")); } @@ -1260,7 +1260,7 @@ class GMPStorageTest : public GMPDecryptorProxyCallback response.Append(longRecordName); response.AppendLiteral(" "); response.Append(data); - Expect(response, NS_NewRunnableMethod(this, &GMPStorageTest::SetFinished)); + Expect(response, NewRunnableMethod(this, &GMPStorageTest::SetFinished)); nsCString update("store "); update.Append(longRecordName); @@ -1272,8 +1272,8 @@ class GMPStorageTest : public GMPDecryptorProxyCallback update); } - void Expect(const nsCString& aMessage, nsIRunnable* aContinuation) { - mExpected.AppendElement(ExpectedMessage(aMessage, aContinuation)); + void Expect(const nsCString& aMessage, already_AddRefed aContinuation) { + mExpected.AppendElement(ExpectedMessage(aMessage, Move(aContinuation))); } void AwaitFinished() { @@ -1283,15 +1283,15 @@ class GMPStorageTest : public GMPDecryptorProxyCallback mFinished = false; } - void ShutdownThen(nsIRunnable* aContinuation) { + void ShutdownThen(already_AddRefed aContinuation) { EXPECT_TRUE(!!mDecryptor); if (!mDecryptor) { return; } EXPECT_FALSE(mNodeId.IsEmpty()); RefPtr task( - new GMPShutdownObserver(NS_NewRunnableMethod(this, &GMPStorageTest::Shutdown), - aContinuation, mNodeId)); + new GMPShutdownObserver(NewRunnableMethod(this, &GMPStorageTest::Shutdown), + Move(aContinuation), mNodeId)); NS_DispatchToMainThread(task, NS_DISPATCH_NORMAL); } @@ -1309,7 +1309,7 @@ class GMPStorageTest : public GMPDecryptorProxyCallback void SetFinished() { mFinished = true; Shutdown(); - NS_DispatchToMainThread(NS_NewRunnableMethod(this, &GMPStorageTest::Dummy)); + NS_DispatchToMainThread(NewRunnableMethod(this, &GMPStorageTest::Dummy)); } void SessionMessage(const nsCString& aSessionId, @@ -1364,7 +1364,7 @@ private: ~GMPStorageTest() { } struct ExpectedMessage { - ExpectedMessage(const nsCString& aMessage, nsIRunnable* aContinuation) + ExpectedMessage(const nsCString& aMessage, already_AddRefed aContinuation) : mMessage(aMessage) , mContinuation(aContinuation) {} @@ -1386,9 +1386,9 @@ GMPTestRunner::DoTest(void (GMPTestRunner::*aTestMethod)(GMPTestMonitor&)) nsCOMPtr thread(GetGMPThread()); GMPTestMonitor monitor; - thread->Dispatch(NS_NewRunnableMethodWithArg(this, - aTestMethod, - monitor), + thread->Dispatch(NewRunnableMethod(this, + aTestMethod, + monitor), NS_DISPATCH_NORMAL); monitor.AwaitFinished(); } diff --git a/dom/media/gtest/TestGMPRemoveAndDelete.cpp b/dom/media/gtest/TestGMPRemoveAndDelete.cpp index ef6b8b22d181..ffedf4d30efe 100644 --- a/dom/media/gtest/TestGMPRemoveAndDelete.cpp +++ b/dom/media/gtest/TestGMPRemoveAndDelete.cpp @@ -260,7 +260,7 @@ GMPRemoveTest::CreateVideoDecoder(nsCString aNodeId) GMPVideoDecoderProxy* decoder = nullptr; mGMPThread->Dispatch( - NS_NewNonOwningRunnableMethodWithArgs( + NewNonOwningRunnableMethod( this, &GMPRemoveTest::gmp_GetVideoDecoder, aNodeId, &decoder, &host), NS_DISPATCH_NORMAL); @@ -276,7 +276,7 @@ GMPRemoveTest::CreateVideoDecoder(nsCString aNodeId) nsTArray empty; mGMPThread->Dispatch( - NS_NewNonOwningRunnableMethodWithArgs&, GMPVideoDecoderCallbackProxy*, int32_t>( + NewNonOwningRunnableMethod&, GMPVideoDecoderCallbackProxy*, int32_t>( decoder, &GMPVideoDecoderProxy::InitDecode, codec, empty, this, 1 /* core count */), NS_DISPATCH_SYNC); @@ -328,7 +328,7 @@ void GMPRemoveTest::CloseVideoDecoder() { mGMPThread->Dispatch( - NS_NewNonOwningRunnableMethod(mDecoder, &GMPVideoDecoderProxy::Close), + NewNonOwningRunnableMethod(mDecoder, &GMPVideoDecoderProxy::Close), NS_DISPATCH_SYNC); mDecoder = nullptr; @@ -345,7 +345,7 @@ GMPErr GMPRemoveTest::Decode() { mGMPThread->Dispatch( - NS_NewNonOwningRunnableMethod(this, &GMPRemoveTest::gmp_Decode), + NewNonOwningRunnableMethod(this, &GMPRemoveTest::gmp_Decode), NS_DISPATCH_NORMAL); mTestMonitor.AwaitFinished(); diff --git a/dom/media/gtest/TestMP4Reader.cpp b/dom/media/gtest/TestMP4Reader.cpp index c0120c12a3ea..f08f7a40da3c 100644 --- a/dom/media/gtest/TestMP4Reader.cpp +++ b/dom/media/gtest/TestMP4Reader.cpp @@ -43,8 +43,8 @@ public: void Init() { nsCOMPtr thread; - nsresult rv = NS_NewThread(getter_AddRefs(thread), - NS_NewRunnableMethod(this, &TestBinding::ReadMetadata)); + nsCOMPtr r = NewRunnableMethod(this, &TestBinding::ReadMetadata); + nsresult rv = NS_NewThread(getter_AddRefs(thread), r); EXPECT_EQ(NS_OK, rv); thread->Shutdown(); } @@ -54,7 +54,7 @@ private: { { RefPtr queue = reader->OwnerThread(); - nsCOMPtr task = NS_NewRunnableMethod(reader, &MP4Reader::Shutdown); + nsCOMPtr task = NewRunnableMethod(reader, &MP4Reader::Shutdown); // Hackily bypass the tail dispatcher so that we can AwaitShutdownAndIdle. // In production code we'd use BeginShutdown + promises. queue->Dispatch(task.forget(), AbstractThread::AssertDispatchSuccess, diff --git a/dom/media/mediasink/DecodedStream.cpp b/dom/media/mediasink/DecodedStream.cpp index 1acd2779f8c4..ac82f074f0ae 100644 --- a/dom/media/mediasink/DecodedStream.cpp +++ b/dom/media/mediasink/DecodedStream.cpp @@ -54,7 +54,7 @@ public: { if (event == EVENT_FINISHED) { nsCOMPtr event = - NS_NewRunnableMethod(this, &DecodedStreamGraphListener::DoNotifyFinished); + NewRunnableMethod(this, &DecodedStreamGraphListener::DoNotifyFinished); aGraph->DispatchToMainThreadAfterStreamStateUpdate(event.forget()); } } @@ -99,9 +99,9 @@ UpdateStreamSuspended(MediaStream* aStream, bool aBlocking) } else { nsCOMPtr r; if (aBlocking) { - r = NS_NewRunnableMethod(aStream, &MediaStream::Suspend); + r = NewRunnableMethod(aStream, &MediaStream::Suspend); } else { - r = NS_NewRunnableMethod(aStream, &MediaStream::Resume); + r = NewRunnableMethod(aStream, &MediaStream::Resume); } AbstractThread::MainThread()->Dispatch(r.forget()); } diff --git a/dom/media/mediasource/MediaSourceDemuxer.cpp b/dom/media/mediasource/MediaSourceDemuxer.cpp index 715dc9858eb2..6ffb65527795 100644 --- a/dom/media/mediasource/MediaSourceDemuxer.cpp +++ b/dom/media/mediasource/MediaSourceDemuxer.cpp @@ -177,7 +177,7 @@ void MediaSourceDemuxer::AttachSourceBuffer(TrackBuffersManager* aSourceBuffer) { nsCOMPtr task = - NS_NewRunnableMethodWithArg( + NewRunnableMethod( this, &MediaSourceDemuxer::DoAttachSourceBuffer, aSourceBuffer); GetTaskQueue()->Dispatch(task.forget()); @@ -195,7 +195,7 @@ void MediaSourceDemuxer::DetachSourceBuffer(TrackBuffersManager* aSourceBuffer) { nsCOMPtr task = - NS_NewRunnableMethodWithArg( + NewRunnableMethod( this, &MediaSourceDemuxer::DoDetachSourceBuffer, aSourceBuffer); GetTaskQueue()->Dispatch(task.forget()); diff --git a/dom/media/mediasource/TrackBuffersManager.cpp b/dom/media/mediasource/TrackBuffersManager.cpp index bb7efe035504..404692b4f7a6 100644 --- a/dom/media/mediasource/TrackBuffersManager.cpp +++ b/dom/media/mediasource/TrackBuffersManager.cpp @@ -201,9 +201,7 @@ TrackBuffersManager::ProcessTasks() NS_WARNING("Invalid Task"); } } - nsCOMPtr task = - NS_NewRunnableMethod(this, &TrackBuffersManager::ProcessTasks); - GetTaskQueue()->Dispatch(task.forget()); + GetTaskQueue()->Dispatch(NewRunnableMethod(this, &TrackBuffersManager::ProcessTasks)); } // A PromiseHolder will assert upon destruction if it has a pending promise @@ -793,9 +791,7 @@ TrackBuffersManager::ScheduleSegmentParserLoop() if (mDetached) { return; } - nsCOMPtr task = - NS_NewRunnableMethod(this, &TrackBuffersManager::SegmentParserLoop); - GetTaskQueue()->Dispatch(task.forget()); + GetTaskQueue()->Dispatch(NewRunnableMethod(this, &TrackBuffersManager::SegmentParserLoop)); } void @@ -971,11 +967,10 @@ TrackBuffersManager::OnDemuxerInitDone(nsresult) int64_t duration = std::max(videoDuration, audioDuration); // 1. Update the duration attribute if it currently equals NaN. // Those steps are performed by the MediaSourceDecoder::SetInitialDuration - nsCOMPtr task = - NS_NewRunnableMethodWithArg(mParentDecoder, - &MediaSourceDecoder::SetInitialDuration, - duration ? duration : -1); - AbstractThread::MainThread()->Dispatch(task.forget()); + AbstractThread::MainThread()->Dispatch(NewRunnableMethod + (mParentDecoder, + &MediaSourceDecoder::SetInitialDuration, + duration ? duration : -1)); // 2. If the initialization segment has no audio, video, or text tracks, then // run the append error algorithm with the decode error parameter set to true diff --git a/dom/media/omx/AudioOffloadPlayer.cpp b/dom/media/omx/AudioOffloadPlayer.cpp index 05e5a45e67ae..ccdd82ba846c 100644 --- a/dom/media/omx/AudioOffloadPlayer.cpp +++ b/dom/media/omx/AudioOffloadPlayer.cpp @@ -354,7 +354,7 @@ status_t AudioOffloadPlayer::DoSeek() if (!mSeekPromise.IsEmpty()) { nsCOMPtr nsEvent = - NS_NewRunnableMethodWithArg( + NewRunnableMethod( mObserver, &MediaDecoder::SeekingStarted, mSeekTarget.mEventVisibility); @@ -425,16 +425,14 @@ void AudioOffloadPlayer::NotifyAudioEOS() MediaDecoder::SeekResolveValue val(mReachedEOS, mSeekTarget.mEventVisibility); mSeekPromise.Resolve(val, __func__); } - nsCOMPtr nsEvent = NS_NewRunnableMethod(mObserver, - &MediaDecoder::PlaybackEnded); - NS_DispatchToMainThread(nsEvent); + NS_DispatchToMainThread(NewRunnableMethod(mObserver, + &MediaDecoder::PlaybackEnded)); } void AudioOffloadPlayer::NotifyPositionChanged() { - nsCOMPtr nsEvent = - NS_NewRunnableMethod(mObserver, &MediaOmxCommonDecoder::NotifyOffloadPlayerPositionChanged); - NS_DispatchToMainThread(nsEvent); + NS_DispatchToMainThread(NewRunnableMethod(mObserver, + &MediaOmxCommonDecoder::NotifyOffloadPlayerPositionChanged)); } void AudioOffloadPlayer::NotifyAudioTearDown() @@ -448,9 +446,8 @@ void AudioOffloadPlayer::NotifyAudioTearDown() MediaDecoder::SeekResolveValue val(mReachedEOS, mSeekTarget.mEventVisibility); mSeekPromise.Resolve(val, __func__); } - nsCOMPtr nsEvent = NS_NewRunnableMethod(mObserver, - &MediaOmxCommonDecoder::AudioOffloadTearDown); - NS_DispatchToMainThread(nsEvent); + NS_DispatchToMainThread(NewRunnableMethod(mObserver, + &MediaOmxCommonDecoder::AudioOffloadTearDown)); } // static diff --git a/dom/media/platforms/agnostic/OpusDecoder.cpp b/dom/media/platforms/agnostic/OpusDecoder.cpp index e2cbba313921..d5a71e7b6068 100644 --- a/dom/media/platforms/agnostic/OpusDecoder.cpp +++ b/dom/media/platforms/agnostic/OpusDecoder.cpp @@ -132,11 +132,9 @@ OpusDataDecoder::DecodeHeader(const unsigned char* aData, size_t aLength) nsresult OpusDataDecoder::Input(MediaRawData* aSample) { - nsCOMPtr runnable( - NS_NewRunnableMethodWithArg>( - this, &OpusDataDecoder::Decode, - RefPtr(aSample))); - mTaskQueue->Dispatch(runnable.forget()); + mTaskQueue->Dispatch(NewRunnableMethod>( + this, &OpusDataDecoder::Decode, + RefPtr(aSample))); return NS_OK; } @@ -309,9 +307,7 @@ OpusDataDecoder::DoDrain() nsresult OpusDataDecoder::Drain() { - RefPtr runnable( - NS_NewRunnableMethod(this, &OpusDataDecoder::DoDrain)); - mTaskQueue->Dispatch(runnable.forget()); + mTaskQueue->Dispatch(NewRunnableMethod(this, &OpusDataDecoder::DoDrain)); return NS_OK; } diff --git a/dom/media/platforms/agnostic/VPXDecoder.cpp b/dom/media/platforms/agnostic/VPXDecoder.cpp index 644361ecaa53..6b1f5ad2ceed 100644 --- a/dom/media/platforms/agnostic/VPXDecoder.cpp +++ b/dom/media/platforms/agnostic/VPXDecoder.cpp @@ -186,11 +186,9 @@ VPXDecoder::DecodeFrame(MediaRawData* aSample) nsresult VPXDecoder::Input(MediaRawData* aSample) { - nsCOMPtr runnable( - NS_NewRunnableMethodWithArg>( - this, &VPXDecoder::DecodeFrame, - RefPtr(aSample))); - mTaskQueue->Dispatch(runnable.forget()); + mTaskQueue->Dispatch(NewRunnableMethod>( + this, &VPXDecoder::DecodeFrame, + RefPtr(aSample))); return NS_OK; } @@ -204,9 +202,7 @@ VPXDecoder::DoDrain() nsresult VPXDecoder::Drain() { - nsCOMPtr runnable( - NS_NewRunnableMethod(this, &VPXDecoder::DoDrain)); - mTaskQueue->Dispatch(runnable.forget()); + mTaskQueue->Dispatch(NewRunnableMethod(this, &VPXDecoder::DoDrain)); return NS_OK; } diff --git a/dom/media/platforms/agnostic/VorbisDecoder.cpp b/dom/media/platforms/agnostic/VorbisDecoder.cpp index 259df44d7834..ed7217c4573a 100644 --- a/dom/media/platforms/agnostic/VorbisDecoder.cpp +++ b/dom/media/platforms/agnostic/VorbisDecoder.cpp @@ -129,11 +129,9 @@ VorbisDataDecoder::DecodeHeader(const unsigned char* aData, size_t aLength) nsresult VorbisDataDecoder::Input(MediaRawData* aSample) { - nsCOMPtr runnable( - NS_NewRunnableMethodWithArg>( - this, &VorbisDataDecoder::Decode, - RefPtr(aSample))); - mTaskQueue->Dispatch(runnable.forget()); + mTaskQueue->Dispatch(NewRunnableMethod>( + this, &VorbisDataDecoder::Decode, + RefPtr(aSample))); return NS_OK; } @@ -265,9 +263,7 @@ VorbisDataDecoder::DoDrain() nsresult VorbisDataDecoder::Drain() { - nsCOMPtr runnable( - NS_NewRunnableMethod(this, &VorbisDataDecoder::DoDrain)); - mTaskQueue->Dispatch(runnable.forget()); + mTaskQueue->Dispatch(NewRunnableMethod(this, &VorbisDataDecoder::DoDrain)); return NS_OK; } diff --git a/dom/media/platforms/agnostic/WAVDecoder.cpp b/dom/media/platforms/agnostic/WAVDecoder.cpp index 677e68b43616..d31d514379c9 100644 --- a/dom/media/platforms/agnostic/WAVDecoder.cpp +++ b/dom/media/platforms/agnostic/WAVDecoder.cpp @@ -70,11 +70,9 @@ WaveDataDecoder::Init() nsresult WaveDataDecoder::Input(MediaRawData* aSample) { - nsCOMPtr runnable( - NS_NewRunnableMethodWithArg>( - this, &WaveDataDecoder::Decode, - RefPtr(aSample))); - mTaskQueue->Dispatch(runnable.forget()); + mTaskQueue->Dispatch(NewRunnableMethod>( + this, &WaveDataDecoder::Decode, + RefPtr(aSample))); return NS_OK; } @@ -158,9 +156,7 @@ WaveDataDecoder::DoDrain() nsresult WaveDataDecoder::Drain() { - nsCOMPtr runnable( - NS_NewRunnableMethod(this, &WaveDataDecoder::DoDrain)); - mTaskQueue->Dispatch(runnable.forget()); + mTaskQueue->Dispatch(NewRunnableMethod(this, &WaveDataDecoder::DoDrain)); return NS_OK; } @@ -186,4 +182,4 @@ WaveDataDecoder::IsWave(const nsACString& aMimeType) } } // namespace mozilla -#undef LOG \ No newline at end of file +#undef LOG diff --git a/dom/media/platforms/agnostic/eme/SamplesWaitingForKey.cpp b/dom/media/platforms/agnostic/eme/SamplesWaitingForKey.cpp index e15cda20b251..1b0fba23b0a0 100644 --- a/dom/media/platforms/agnostic/eme/SamplesWaitingForKey.cpp +++ b/dom/media/platforms/agnostic/eme/SamplesWaitingForKey.cpp @@ -52,7 +52,7 @@ SamplesWaitingForKey::NotifyUsable(const CencKeyId& aKeyId) while (i < mSamples.Length()) { if (aKeyId == mSamples[i]->mCrypto.mKeyId) { RefPtr task; - task = NS_NewRunnableMethodWithArg>(mDecoder, + task = NewRunnableMethod>(mDecoder, &MediaDataDecoder::Input, RefPtr(mSamples[i])); mSamples.RemoveElementAt(i); diff --git a/dom/media/platforms/agnostic/gmp/MediaDataDecoderProxy.cpp b/dom/media/platforms/agnostic/gmp/MediaDataDecoderProxy.cpp index 8808ff23b993..503de5380fbd 100644 --- a/dom/media/platforms/agnostic/gmp/MediaDataDecoderProxy.cpp +++ b/dom/media/platforms/agnostic/gmp/MediaDataDecoderProxy.cpp @@ -58,9 +58,7 @@ MediaDataDecoderProxy::Flush() mFlushComplete.Set(false); - nsCOMPtr task; - task = NS_NewRunnableMethod(mProxyDecoder, &MediaDataDecoder::Flush); - mProxyThread->Dispatch(task.forget()); + mProxyThread->Dispatch(NewRunnableMethod(mProxyDecoder, &MediaDataDecoder::Flush)); mFlushComplete.WaitUntil(true); @@ -73,9 +71,7 @@ MediaDataDecoderProxy::Drain() MOZ_ASSERT(!IsOnProxyThread()); MOZ_ASSERT(!mIsShutdown); - nsCOMPtr task; - task = NS_NewRunnableMethod(mProxyDecoder, &MediaDataDecoder::Drain); - mProxyThread->Dispatch(task.forget()); + mProxyThread->Dispatch(NewRunnableMethod(mProxyDecoder, &MediaDataDecoder::Drain)); return NS_OK; } @@ -87,9 +83,9 @@ MediaDataDecoderProxy::Shutdown() #if defined(DEBUG) mIsShutdown = true; #endif - nsCOMPtr task; - task = NS_NewRunnableMethod(mProxyDecoder, &MediaDataDecoder::Shutdown); - nsresult rv = mProxyThread->AsXPCOMThread()->Dispatch(task, NS_DISPATCH_SYNC); + nsresult rv = mProxyThread->AsXPCOMThread()->Dispatch(NewRunnableMethod(mProxyDecoder, + &MediaDataDecoder::Shutdown), + NS_DISPATCH_SYNC); NS_ENSURE_SUCCESS(rv, rv); return NS_OK; } diff --git a/dom/media/platforms/android/AndroidDecoderModule.cpp b/dom/media/platforms/android/AndroidDecoderModule.cpp index cc09d2c228c1..f878f493549f 100644 --- a/dom/media/platforms/android/AndroidDecoderModule.cpp +++ b/dom/media/platforms/android/AndroidDecoderModule.cpp @@ -389,9 +389,8 @@ MediaCodecDataDecoder::InitDecoder(Surface::Param aSurface) NS_ENSURE_SUCCESS(rv = ResetInputBuffers(), rv); NS_ENSURE_SUCCESS(rv = ResetOutputBuffers(), rv); - rv = NS_NewNamedThread( - "MC Decoder", getter_AddRefs(mThread), - NS_NewRunnableMethod(this, &MediaCodecDataDecoder::DecoderLoop)); + nsCOMPtr r = NewRunnableMethod(this, &MediaCodecDataDecoder::DecoderLoop); + rv = NS_NewNamedThread("MC Decoder", getter_AddRefs(mThread), r); return rv; } diff --git a/dom/media/platforms/apple/AppleATDecoder.cpp b/dom/media/platforms/apple/AppleATDecoder.cpp index 6d364c25d9ce..a5da492aa16a 100644 --- a/dom/media/platforms/apple/AppleATDecoder.cpp +++ b/dom/media/platforms/apple/AppleATDecoder.cpp @@ -74,7 +74,7 @@ AppleATDecoder::Input(MediaRawData* aSample) // Queue a task to perform the actual decoding on a separate thread. nsCOMPtr runnable = - NS_NewRunnableMethodWithArg>( + NewRunnableMethod>( this, &AppleATDecoder::SubmitSample, RefPtr(aSample)); diff --git a/dom/media/platforms/apple/AppleVDADecoder.cpp b/dom/media/platforms/apple/AppleVDADecoder.cpp index 89b5e66c8d19..2c9610040109 100644 --- a/dom/media/platforms/apple/AppleVDADecoder.cpp +++ b/dom/media/platforms/apple/AppleVDADecoder.cpp @@ -100,7 +100,7 @@ AppleVDADecoder::Shutdown() mIsShutDown = true; if (mTaskQueue) { nsCOMPtr runnable = - NS_NewRunnableMethod(this, &AppleVDADecoder::ProcessShutdown); + NewRunnableMethod(this, &AppleVDADecoder::ProcessShutdown); mTaskQueue->Dispatch(runnable.forget()); } else { ProcessShutdown(); @@ -133,7 +133,7 @@ AppleVDADecoder::Input(MediaRawData* aSample) mInputIncoming++; nsCOMPtr runnable = - NS_NewRunnableMethodWithArg>( + NewRunnableMethod>( this, &AppleVDADecoder::SubmitFrame, RefPtr(aSample)); @@ -148,7 +148,7 @@ AppleVDADecoder::Flush() mIsFlushing = true; mTaskQueue->Flush(); nsCOMPtr runnable = - NS_NewRunnableMethod(this, &AppleVDADecoder::ProcessFlush); + NewRunnableMethod(this, &AppleVDADecoder::ProcessFlush); MonitorAutoLock mon(mMonitor); mTaskQueue->Dispatch(runnable.forget()); while (mIsFlushing) { @@ -163,7 +163,7 @@ AppleVDADecoder::Drain() { MOZ_ASSERT(mCallback->OnReaderTaskQueue()); nsCOMPtr runnable = - NS_NewRunnableMethod(this, &AppleVDADecoder::ProcessDrain); + NewRunnableMethod(this, &AppleVDADecoder::ProcessDrain); mTaskQueue->Dispatch(runnable.forget()); return NS_OK; } diff --git a/dom/media/platforms/apple/AppleVTDecoder.cpp b/dom/media/platforms/apple/AppleVTDecoder.cpp index 000f95c6389d..d3e444688cea 100644 --- a/dom/media/platforms/apple/AppleVTDecoder.cpp +++ b/dom/media/platforms/apple/AppleVTDecoder.cpp @@ -107,7 +107,7 @@ AppleVTDecoder::Input(MediaRawData* aSample) mInputIncoming++; nsCOMPtr runnable = - NS_NewRunnableMethodWithArg>( + NewRunnableMethod>( this, &AppleVTDecoder::SubmitFrame, aSample); mTaskQueue->Dispatch(runnable.forget()); return NS_OK; diff --git a/dom/media/platforms/ffmpeg/FFmpegAudioDecoder.cpp b/dom/media/platforms/ffmpeg/FFmpegAudioDecoder.cpp index eb8698b714dc..8fcacb935008 100644 --- a/dom/media/platforms/ffmpeg/FFmpegAudioDecoder.cpp +++ b/dom/media/platforms/ffmpeg/FFmpegAudioDecoder.cpp @@ -175,7 +175,7 @@ FFmpegAudioDecoder::DecodePacket(MediaRawData* aSample) nsresult FFmpegAudioDecoder::Input(MediaRawData* aSample) { - nsCOMPtr runnable(NS_NewRunnableMethodWithArg>( + nsCOMPtr runnable(NewRunnableMethod>( this, &FFmpegAudioDecoder::DecodePacket, RefPtr(aSample))); mTaskQueue->Dispatch(runnable.forget()); return NS_OK; diff --git a/dom/media/platforms/ffmpeg/FFmpegDataDecoder.cpp b/dom/media/platforms/ffmpeg/FFmpegDataDecoder.cpp index 46c01d719f87..c10ba26d1b54 100644 --- a/dom/media/platforms/ffmpeg/FFmpegDataDecoder.cpp +++ b/dom/media/platforms/ffmpeg/FFmpegDataDecoder.cpp @@ -104,7 +104,7 @@ FFmpegDataDecoder::Shutdown() { if (mTaskQueue) { nsCOMPtr runnable = - NS_NewRunnableMethod(this, &FFmpegDataDecoder::ProcessShutdown); + NewRunnableMethod(this, &FFmpegDataDecoder::ProcessShutdown); mTaskQueue->Dispatch(runnable.forget()); } else { ProcessShutdown(); @@ -119,7 +119,7 @@ FFmpegDataDecoder::Flush() mIsFlushing = true; mTaskQueue->Flush(); nsCOMPtr runnable = - NS_NewRunnableMethod(this, &FFmpegDataDecoder::ProcessFlush); + NewRunnableMethod(this, &FFmpegDataDecoder::ProcessFlush); MonitorAutoLock mon(mMonitor); mTaskQueue->Dispatch(runnable.forget()); while (mIsFlushing) { @@ -133,7 +133,7 @@ FFmpegDataDecoder::Drain() { MOZ_ASSERT(mCallback->OnReaderTaskQueue()); nsCOMPtr runnable = - NS_NewRunnableMethod(this, &FFmpegDataDecoder::ProcessDrain); + NewRunnableMethod(this, &FFmpegDataDecoder::ProcessDrain); mTaskQueue->Dispatch(runnable.forget()); return NS_OK; } diff --git a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp index 3c0cd0850f06..203457386545 100644 --- a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp +++ b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp @@ -331,7 +331,7 @@ nsresult FFmpegVideoDecoder::Input(MediaRawData* aSample) { nsCOMPtr runnable( - NS_NewRunnableMethodWithArg>( + NewRunnableMethod>( this, &FFmpegVideoDecoder::DecodeFrame, RefPtr(aSample))); mTaskQueue->Dispatch(runnable.forget()); diff --git a/dom/media/platforms/omx/OmxDataDecoder.cpp b/dom/media/platforms/omx/OmxDataDecoder.cpp index 2f90ff5fd2b6..59768b00ac65 100644 --- a/dom/media/platforms/omx/OmxDataDecoder.cpp +++ b/dom/media/platforms/omx/OmxDataDecoder.cpp @@ -114,9 +114,7 @@ OmxDataDecoder::OmxDataDecoder(const TrackInfo& aTrackInfo, LOG(""); mOmxLayer = new OmxPromiseLayer(mOmxTaskQueue, this, aImageContainer); - nsCOMPtr r = - NS_NewRunnableMethod(this, &OmxDataDecoder::InitializationTask); - mOmxTaskQueue->Dispatch(r.forget()); + mOmxTaskQueue->Dispatch(NewRunnableMethod(this, &OmxDataDecoder::InitializationTask)); } OmxDataDecoder::~OmxDataDecoder() @@ -209,9 +207,7 @@ OmxDataDecoder::Flush() mFlushing = true; - nsCOMPtr r = - NS_NewRunnableMethod(this, &OmxDataDecoder::DoFlush); - mOmxTaskQueue->Dispatch(r.forget()); + mOmxTaskQueue->Dispatch(NewRunnableMethod(this, &OmxDataDecoder::DoFlush)); // According to the definition of Flush() in PDM: // "the decoder must be ready to accept new input for decoding". @@ -229,9 +225,7 @@ OmxDataDecoder::Drain() { LOG(""); - nsCOMPtr r = - NS_NewRunnableMethod(this, &OmxDataDecoder::SendEosBuffer); - mOmxTaskQueue->Dispatch(r.forget()); + mOmxTaskQueue->Dispatch(NewRunnableMethod(this, &OmxDataDecoder::SendEosBuffer)); return NS_OK; } @@ -243,9 +237,7 @@ OmxDataDecoder::Shutdown() mShuttingDown = true; - nsCOMPtr r = - NS_NewRunnableMethod(this, &OmxDataDecoder::DoAsyncShutdown); - mOmxTaskQueue->Dispatch(r.forget()); + mOmxTaskQueue->Dispatch(NewRunnableMethod(this, &OmxDataDecoder::DoAsyncShutdown)); { // DoAsyncShutdown() will be running for a while, it could be still running diff --git a/dom/media/platforms/wmf/WMFMediaDataDecoder.cpp b/dom/media/platforms/wmf/WMFMediaDataDecoder.cpp index 48cc4f6e535b..3fd48f7a8592 100644 --- a/dom/media/platforms/wmf/WMFMediaDataDecoder.cpp +++ b/dom/media/platforms/wmf/WMFMediaDataDecoder.cpp @@ -79,9 +79,7 @@ WMFMediaDataDecoder::Shutdown() MOZ_DIAGNOSTIC_ASSERT(!mIsShutDown); if (mTaskQueue) { - nsCOMPtr runnable = - NS_NewRunnableMethod(this, &WMFMediaDataDecoder::ProcessShutdown); - mTaskQueue->Dispatch(runnable.forget()); + mTaskQueue->Dispatch(NewRunnableMethod(this, &WMFMediaDataDecoder::ProcessShutdown)); } else { ProcessShutdown(); } @@ -109,7 +107,7 @@ WMFMediaDataDecoder::Input(MediaRawData* aSample) MOZ_DIAGNOSTIC_ASSERT(!mIsShutDown); nsCOMPtr runnable = - NS_NewRunnableMethodWithArg>( + NewRunnableMethod>( this, &WMFMediaDataDecoder::ProcessDecode, RefPtr(aSample)); @@ -185,11 +183,9 @@ WMFMediaDataDecoder::Flush() MOZ_ASSERT(mCallback->OnReaderTaskQueue()); MOZ_DIAGNOSTIC_ASSERT(!mIsShutDown); - nsCOMPtr runnable = - NS_NewRunnableMethod(this, &WMFMediaDataDecoder::ProcessFlush); MonitorAutoLock mon(mMonitor); mIsFlushing = true; - mTaskQueue->Dispatch(runnable.forget()); + mTaskQueue->Dispatch(NewRunnableMethod(this, &WMFMediaDataDecoder::ProcessFlush)); while (mIsFlushing) { mon.Wait(); } @@ -219,9 +215,7 @@ WMFMediaDataDecoder::Drain() MOZ_ASSERT(mCallback->OnReaderTaskQueue()); MOZ_DIAGNOSTIC_ASSERT(!mIsShutDown); - nsCOMPtr runnable = - NS_NewRunnableMethod(this, &WMFMediaDataDecoder::ProcessDrain); - mTaskQueue->Dispatch(runnable.forget()); + mTaskQueue->Dispatch(NewRunnableMethod(this, &WMFMediaDataDecoder::ProcessDrain)); return NS_OK; } @@ -238,7 +232,7 @@ WMFMediaDataDecoder::ConfigurationChanged(const TrackInfo& aConfig) MOZ_ASSERT(mCallback->OnReaderTaskQueue()); nsCOMPtr runnable = - NS_NewRunnableMethodWithArg&&>( + NewRunnableMethod&&>( this, &WMFMediaDataDecoder::ProcessConfigurationChanged, aConfig.Clone()); diff --git a/dom/media/platforms/wrappers/FuzzingWrapper.cpp b/dom/media/platforms/wrappers/FuzzingWrapper.cpp index 0cb776c582ea..3e4081f19d39 100644 --- a/dom/media/platforms/wrappers/FuzzingWrapper.cpp +++ b/dom/media/platforms/wrappers/FuzzingWrapper.cpp @@ -136,7 +136,7 @@ DecoderCallbackFuzzingWrapper::Output(MediaData* aData) { if (!mTaskQueue->IsCurrentThreadIn()) { nsCOMPtr task = - NS_NewRunnableMethodWithArg>( + NewRunnableMethod>( this, &DecoderCallbackFuzzingWrapper::Output, aData); mTaskQueue->Dispatch(task.forget()); return; @@ -176,9 +176,7 @@ void DecoderCallbackFuzzingWrapper::Error() { if (!mTaskQueue->IsCurrentThreadIn()) { - nsCOMPtr task = - NS_NewRunnableMethod(this, &DecoderCallbackFuzzingWrapper::Error); - mTaskQueue->Dispatch(task.forget()); + mTaskQueue->Dispatch(NewRunnableMethod(this, &DecoderCallbackFuzzingWrapper::Error)); return; } CFW_LOGV(""); @@ -191,9 +189,7 @@ void DecoderCallbackFuzzingWrapper::InputExhausted() { if (!mTaskQueue->IsCurrentThreadIn()) { - nsCOMPtr task = - NS_NewRunnableMethod(this, &DecoderCallbackFuzzingWrapper::InputExhausted); - mTaskQueue->Dispatch(task.forget()); + mTaskQueue->Dispatch(NewRunnableMethod(this, &DecoderCallbackFuzzingWrapper::InputExhausted)); return; } if (!mDontDelayInputExhausted && !mDelayedOutput.empty()) { @@ -212,9 +208,7 @@ void DecoderCallbackFuzzingWrapper::DrainComplete() { if (!mTaskQueue->IsCurrentThreadIn()) { - nsCOMPtr task = - NS_NewRunnableMethod(this, &DecoderCallbackFuzzingWrapper::DrainComplete); - mTaskQueue->Dispatch(task.forget()); + mTaskQueue->Dispatch(NewRunnableMethod(this, &DecoderCallbackFuzzingWrapper::DrainComplete)); return; } MOZ_ASSERT(mCallback); @@ -233,9 +227,7 @@ void DecoderCallbackFuzzingWrapper::ReleaseMediaResources() { if (!mTaskQueue->IsCurrentThreadIn()) { - nsCOMPtr task = - NS_NewRunnableMethod(this, &DecoderCallbackFuzzingWrapper::ReleaseMediaResources); - mTaskQueue->Dispatch(task.forget()); + mTaskQueue->Dispatch(NewRunnableMethod(this, &DecoderCallbackFuzzingWrapper::ReleaseMediaResources)); return; } CFW_LOGV(""); @@ -317,9 +309,7 @@ DecoderCallbackFuzzingWrapper::ClearDelayedOutput() { if (!mTaskQueue->IsCurrentThreadIn()) { DFW_LOGV("(dispatching self)"); - nsCOMPtr task = - NS_NewRunnableMethod(this, &DecoderCallbackFuzzingWrapper::ClearDelayedOutput); - mTaskQueue->Dispatch(task.forget()); + mTaskQueue->Dispatch(NewRunnableMethod(this, &DecoderCallbackFuzzingWrapper::ClearDelayedOutput)); return; } DFW_LOGV(""); diff --git a/dom/media/systemservices/MediaSystemResourceManager.cpp b/dom/media/systemservices/MediaSystemResourceManager.cpp index 2da48288f37a..88dcc7080e12 100644 --- a/dom/media/systemservices/MediaSystemResourceManager.cpp +++ b/dom/media/systemservices/MediaSystemResourceManager.cpp @@ -198,12 +198,11 @@ MediaSystemResourceManager::Acquire(MediaSystemResourceClient* aClient) return; } aClient->mResourceState = MediaSystemResourceClient::RESOURCE_STATE_WAITING; - RefPtr runnable = - NS_NewRunnableMethodWithArgs( + ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask( + NewRunnableMethod( this, &MediaSystemResourceManager::DoAcquire, - aClient->mId); - ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(runnable.forget()); + aClient->mId)); } bool @@ -242,12 +241,11 @@ MediaSystemResourceManager::AcquireSyncNoWait(MediaSystemResourceClient* aClient aClient->mResourceState = MediaSystemResourceClient::RESOURCE_STATE_WAITING; } - RefPtr runnable = - NS_NewRunnableMethodWithArgs( + ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask( + NewRunnableMethod( this, &MediaSystemResourceManager::DoAcquire, - aClient->mId); - ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(runnable.forget()); + aClient->mId)); // should stop the thread until done. while (!done) { @@ -310,12 +308,11 @@ MediaSystemResourceManager::ReleaseResource(MediaSystemResourceClient* aClient) aClient->mResourceState = MediaSystemResourceClient::RESOURCE_STATE_END; - RefPtr runnable = - NS_NewRunnableMethodWithArgs( + ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask( + NewRunnableMethod( this, &MediaSystemResourceManager::DoRelease, - aClient->mId); - ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(runnable.forget()); + aClient->mId)); } } @@ -339,13 +336,12 @@ void MediaSystemResourceManager::HandleAcquireResult(uint32_t aId, bool aSuccess) { if (!InImageBridgeChildThread()) { - RefPtr runnable = - NS_NewRunnableMethodWithArgs( + ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask( + NewRunnableMethod( this, &MediaSystemResourceManager::HandleAcquireResult, aId, - aSuccess); - ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(runnable.forget()); + aSuccess)); return; } diff --git a/dom/media/webaudio/AudioDestinationNode.cpp b/dom/media/webaudio/AudioDestinationNode.cpp index e354db03f833..ff1d343e58f2 100644 --- a/dom/media/webaudio/AudioDestinationNode.cpp +++ b/dom/media/webaudio/AudioDestinationNode.cpp @@ -405,9 +405,8 @@ AudioDestinationNode::NotifyMainThreadStreamFinished() MOZ_ASSERT(mStream->IsFinished()); if (mIsOffline) { - nsCOMPtr runnable = - NS_NewRunnableMethod(this, &AudioDestinationNode::FireOfflineCompletionEvent); - NS_DispatchToCurrentThread(runnable); + NS_DispatchToCurrentThread(NewRunnableMethod(this, + &AudioDestinationNode::FireOfflineCompletionEvent)); } } diff --git a/dom/media/webaudio/MediaBufferDecoder.cpp b/dom/media/webaudio/MediaBufferDecoder.cpp index 262395bb9e0d..97fcbd70f6f8 100644 --- a/dom/media/webaudio/MediaBufferDecoder.cpp +++ b/dom/media/webaudio/MediaBufferDecoder.cpp @@ -122,7 +122,7 @@ private: mDecodeJob.OnFailure(aErrorCode); } else { // Take extra care to cleanup on the main thread - NS_DispatchToMainThread(NS_NewRunnableMethod(this, &MediaDecodeTask::Cleanup)); + NS_DispatchToMainThread(NewRunnableMethod(this, &MediaDecodeTask::Cleanup)); nsCOMPtr event = new ReportResultTask(mDecodeJob, &WebAudioDecodeJob::OnFailure, aErrorCode); diff --git a/dom/media/webaudio/blink/ReverbConvolver.cpp b/dom/media/webaudio/blink/ReverbConvolver.cpp index 7167394030af..e739400aee35 100644 --- a/dom/media/webaudio/blink/ReverbConvolver.cpp +++ b/dom/media/webaudio/blink/ReverbConvolver.cpp @@ -151,8 +151,8 @@ ReverbConvolver::ReverbConvolver(const float* impulseResponseData, NS_WARNING("Cannot start convolver thread."); return; } - RefPtr runnable = NS_NewNonOwningRunnableMethod(this, &ReverbConvolver::backgroundThreadEntry); - m_backgroundThread.message_loop()->PostTask(runnable.forget()); + m_backgroundThread.message_loop()->PostTask(NewNonOwningRunnableMethod(this, + &ReverbConvolver::backgroundThreadEntry)); } } diff --git a/dom/media/webspeech/synth/nsSpeechTask.cpp b/dom/media/webspeech/synth/nsSpeechTask.cpp index f5a66efaa37a..117e3e0bb0da 100644 --- a/dom/media/webspeech/synth/nsSpeechTask.cpp +++ b/dom/media/webspeech/synth/nsSpeechTask.cpp @@ -61,12 +61,12 @@ public: if (!mStarted) { mStarted = true; nsCOMPtr startRunnable = - NS_NewRunnableMethod(this, &SynthStreamListener::DoNotifyStarted); + NewRunnableMethod(this, &SynthStreamListener::DoNotifyStarted); aGraph->DispatchToMainThreadAfterStreamStateUpdate(startRunnable.forget()); } nsCOMPtr endRunnable = - NS_NewRunnableMethod(this, &SynthStreamListener::DoNotifyFinished); + NewRunnableMethod(this, &SynthStreamListener::DoNotifyFinished); aGraph->DispatchToMainThreadAfterStreamStateUpdate(endRunnable.forget()); } break; @@ -85,7 +85,7 @@ public: if (aBlocked == MediaStreamListener::UNBLOCKED && !mStarted) { mStarted = true; nsCOMPtr event = - NS_NewRunnableMethod(this, &SynthStreamListener::DoNotifyStarted); + NewRunnableMethod(this, &SynthStreamListener::DoNotifyStarted); aGraph->DispatchToMainThreadAfterStreamStateUpdate(event.forget()); } } diff --git a/dom/media/webspeech/synth/pico/nsPicoService.cpp b/dom/media/webspeech/synth/pico/nsPicoService.cpp index b52c4181ae9a..6f31509b6c63 100644 --- a/dom/media/webspeech/synth/pico/nsPicoService.cpp +++ b/dom/media/webspeech/synth/pico/nsPicoService.cpp @@ -469,7 +469,7 @@ nsPicoService::Observe(nsISupports* aSubject, const char* aTopic, DebugOnly rv = NS_NewNamedThread("Pico Worker", getter_AddRefs(mThread)); MOZ_ASSERT(NS_SUCCEEDED(rv)); return mThread->Dispatch( - NS_NewRunnableMethod(this, &nsPicoService::Init), NS_DISPATCH_NORMAL); + NewRunnableMethod(this, &nsPicoService::Init), NS_DISPATCH_NORMAL); } // nsISpeechService @@ -579,7 +579,7 @@ nsPicoService::Init() rv = dirIterator->HasMoreElements(&hasMoreElements); } - NS_DispatchToMainThread(NS_NewRunnableMethod(this, &nsPicoService::RegisterVoices)); + NS_DispatchToMainThread(NewRunnableMethod(this, &nsPicoService::RegisterVoices)); } void diff --git a/dom/media/webspeech/synth/speechd/SpeechDispatcherService.cpp b/dom/media/webspeech/synth/speechd/SpeechDispatcherService.cpp index 7b54e01e2fb7..47154df34677 100644 --- a/dom/media/webspeech/synth/speechd/SpeechDispatcherService.cpp +++ b/dom/media/webspeech/synth/speechd/SpeechDispatcherService.cpp @@ -274,7 +274,7 @@ speechd_cb(size_t msg_id, size_t client_id, SPDNotificationType state) if (service) { NS_DispatchToMainThread( - NS_NewRunnableMethodWithArgs( + NewRunnableMethod( service, &SpeechDispatcherService::EventNotify, static_cast(msg_id), state)); } @@ -311,7 +311,7 @@ SpeechDispatcherService::Init() getter_AddRefs(mInitThread)); MOZ_ASSERT(NS_SUCCEEDED(rv)); rv = mInitThread->Dispatch( - NS_NewRunnableMethod(this, &SpeechDispatcherService::Setup), NS_DISPATCH_NORMAL); + NewRunnableMethod(this, &SpeechDispatcherService::Setup), NS_DISPATCH_NORMAL); MOZ_ASSERT(NS_SUCCEEDED(rv)); } @@ -412,7 +412,7 @@ SpeechDispatcherService::Setup() } } - NS_DispatchToMainThread(NS_NewRunnableMethod(this, &SpeechDispatcherService::RegisterVoices)); + NS_DispatchToMainThread(NewRunnableMethod(this, &SpeechDispatcherService::RegisterVoices)); //mInitialized = true; } @@ -518,10 +518,10 @@ SpeechDispatcherService::Speak(const nsAString& aText, const nsAString& aUri, // Speech dispatcher does not work well with empty strings. // In that case, don't send empty string to speechd, // and just emulate a speechd start and end event. - NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs( + NS_DispatchToMainThread(NewRunnableMethod( callback, &SpeechDispatcherCallback::OnSpeechEvent, SPD_EVENT_BEGIN)); - NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs( + NS_DispatchToMainThread(NewRunnableMethod( callback, &SpeechDispatcherCallback::OnSpeechEvent, SPD_EVENT_END)); } diff --git a/dom/media/webspeech/synth/test/nsFakeSynthServices.cpp b/dom/media/webspeech/synth/test/nsFakeSynthServices.cpp index 4e34e7200809..582ff35510af 100644 --- a/dom/media/webspeech/synth/test/nsFakeSynthServices.cpp +++ b/dom/media/webspeech/synth/test/nsFakeSynthServices.cpp @@ -356,7 +356,7 @@ nsFakeSynthServices::Observe(nsISupports* aSubject, const char* aTopic, } if (Preferences::GetBool("media.webspeech.synth.test")) { - NS_DispatchToMainThread(NS_NewRunnableMethod(this, &nsFakeSynthServices::Init)); + NS_DispatchToMainThread(NewRunnableMethod(this, &nsFakeSynthServices::Init)); } return NS_OK; diff --git a/dom/notification/Notification.cpp b/dom/notification/Notification.cpp index 553af9c353f5..26d8bca8b267 100644 --- a/dom/notification/Notification.cpp +++ b/dom/notification/Notification.cpp @@ -46,6 +46,7 @@ #include "nsProxyRelease.h" #include "nsServiceManagerUtils.h" #include "nsStructuredCloneContainer.h" +#include "nsThreadUtils.h" #include "nsToolkitCompsCID.h" #include "nsXULAppAPI.h" #include "ServiceWorkerManager.h" @@ -646,9 +647,8 @@ NotificationPermissionRequest::GetRequester(nsIContentPermissionRequester** aReq inline nsresult NotificationPermissionRequest::DispatchResolvePromise() { - nsCOMPtr resolveRunnable = NS_NewRunnableMethod(this, - &NotificationPermissionRequest::ResolvePromise); - return NS_DispatchToMainThread(resolveRunnable); + return NS_DispatchToMainThread(NewRunnableMethod(this, + &NotificationPermissionRequest::ResolvePromise)); } nsresult diff --git a/dom/plugins/base/nsNPAPIPluginInstance.cpp b/dom/plugins/base/nsNPAPIPluginInstance.cpp index bfad82ceb57a..3b38ac9bb386 100644 --- a/dom/plugins/base/nsNPAPIPluginInstance.cpp +++ b/dom/plugins/base/nsNPAPIPluginInstance.cpp @@ -891,7 +891,7 @@ already_AddRefed nsNPAPIPluginInstance::CreateSurfaceText return nullptr; } - nsCOMPtr frameCallback = NS_NewRunnableMethod(this, &nsNPAPIPluginInstance::OnSurfaceTextureFrameAvailable); + nsCOMPtr frameCallback = NewRunnableMethod(this, &nsNPAPIPluginInstance::OnSurfaceTextureFrameAvailable); surface->SetFrameAvailableCallback(frameCallback); return surface.forget(); } diff --git a/dom/plugins/ipc/PluginInstanceChild.cpp b/dom/plugins/ipc/PluginInstanceChild.cpp index a35fe3dc1ffe..a6ed968bde2b 100644 --- a/dom/plugins/ipc/PluginInstanceChild.cpp +++ b/dom/plugins/ipc/PluginInstanceChild.cpp @@ -3292,7 +3292,7 @@ PluginInstanceChild::RecvAsyncSetWindow(const gfxSurfaceType& aSurfaceType, // RPC call, and both Flash and Java don't expect to receive setwindow calls // at arbitrary times. mCurrentAsyncSetWindowTask = - NS_NewNonOwningCancelableRunnableMethodWithArgs + NewNonOwningCancelableRunnableMethod (this, &PluginInstanceChild::DoAsyncSetWindow, aSurfaceType, aWindow, true); RefPtr addrefedTask = mCurrentAsyncSetWindowTask; MessageLoop::current()->PostTask(addrefedTask.forget()); @@ -4213,7 +4213,7 @@ PluginInstanceChild::AsyncShowPluginFrame(void) } mCurrentInvalidateTask = - NS_NewNonOwningCancelableRunnableMethod(this, &PluginInstanceChild::InvalidateRectDelayed); + NewNonOwningCancelableRunnableMethod(this, &PluginInstanceChild::InvalidateRectDelayed); RefPtr addrefedTask = mCurrentInvalidateTask; MessageLoop::current()->PostTask(addrefedTask.forget()); } diff --git a/dom/plugins/ipc/PluginInstanceParent.cpp b/dom/plugins/ipc/PluginInstanceParent.cpp index 7fc52b653223..ddfcd31cb968 100644 --- a/dom/plugins/ipc/PluginInstanceParent.cpp +++ b/dom/plugins/ipc/PluginInstanceParent.cpp @@ -1216,7 +1216,7 @@ PluginInstanceParent::ScheduleScrollCapture(int aTimeout) } CAPTURE_LOG("delayed scroll capture requested."); mCaptureRefreshTask = - NS_NewNonOwningCancelableRunnableMethod(this, &PluginInstanceParent::ScheduledUpdateScrollCaptureCallback); + NewNonOwningCancelableRunnableMethod(this, &PluginInstanceParent::ScheduledUpdateScrollCaptureCallback); RefPtr addrefedTask = mCaptureRefreshTask; MessageLoop::current()->PostDelayedTask(addrefedTask.forget(), kScrollCaptureDelayMs); diff --git a/dom/plugins/ipc/PluginProcessParent.cpp b/dom/plugins/ipc/PluginProcessParent.cpp index 3b99f3a606b0..6331470325cb 100644 --- a/dom/plugins/ipc/PluginProcessParent.cpp +++ b/dom/plugins/ipc/PluginProcessParent.cpp @@ -195,8 +195,7 @@ PluginProcessParent::Delete() return; } - RefPtr runnable = NS_NewNonOwningRunnableMethod(this, &PluginProcessParent::Delete); - ioLoop->PostTask(runnable.forget()); + ioLoop->PostTask(NewNonOwningRunnableMethod(this, &PluginProcessParent::Delete)); } void diff --git a/dom/presentation/PresentationAvailability.cpp b/dom/presentation/PresentationAvailability.cpp index f599d9195775..4195b450397a 100644 --- a/dom/presentation/PresentationAvailability.cpp +++ b/dom/presentation/PresentationAvailability.cpp @@ -107,11 +107,10 @@ PresentationAvailability::Value() const NS_IMETHODIMP PresentationAvailability::NotifyAvailableChange(bool aIsAvailable) { - nsCOMPtr runnable = - NS_NewRunnableMethodWithArg(this, - &PresentationAvailability::UpdateAvailabilityAndDispatchEvent, - aIsAvailable); - return NS_DispatchToCurrentThread(runnable); + return NS_DispatchToCurrentThread(NewRunnableMethod + (this, + &PresentationAvailability::UpdateAvailabilityAndDispatchEvent, + aIsAvailable)); } void diff --git a/dom/presentation/PresentationDeviceManager.cpp b/dom/presentation/PresentationDeviceManager.cpp index 474c83b73ff3..ce8c6fde9cd8 100644 --- a/dom/presentation/PresentationDeviceManager.cpp +++ b/dom/presentation/PresentationDeviceManager.cpp @@ -155,7 +155,7 @@ PresentationDeviceManager::GetAvailableDevices(nsIArray** aRetVal) // Bug 1194049: some providers may discontinue discovery after timeout. // Call |ForceDiscovery()| here to make sure device lists are updated. NS_DispatchToMainThread( - NS_NewRunnableMethod(this, &PresentationDeviceManager::ForceDiscovery)); + NewRunnableMethod(this, &PresentationDeviceManager::ForceDiscovery)); nsCOMPtr devices = do_CreateInstance(NS_ARRAY_CONTRACTID); for (uint32_t i = 0; i < mDevices.Length(); ++i) { diff --git a/dom/presentation/PresentationSessionInfo.cpp b/dom/presentation/PresentationSessionInfo.cpp index 030dd2a95004..8d1a6678be68 100644 --- a/dom/presentation/PresentationSessionInfo.cpp +++ b/dom/presentation/PresentationSessionInfo.cpp @@ -112,9 +112,9 @@ PresentationNetworkHelper::OnGetWifiIPAddress(const nsACString& aIPAddress) MOZ_ASSERT(mFunc); NS_DispatchToMainThread( - NS_NewRunnableMethodWithArg(mInfo, - mFunc, - aIPAddress)); + NewRunnableMethod(mInfo, + mFunc, + aIPAddress)); return NS_OK; } @@ -550,7 +550,7 @@ PresentationControllingInfo::GetAddress() // To make consistent code sequence, following function call is dispatched // into main thread instead of calling it directly. NS_DispatchToMainThread( - NS_NewRunnableMethodWithArg( + NewRunnableMethod( this, &PresentationControllingInfo::OnGetAddress, NS_ConvertUTF16toUTF8(ip))); @@ -570,7 +570,7 @@ PresentationControllingInfo::GetAddress() #elif defined(MOZ_MULET) // In simulator,we need to use the "127.0.0.1" as target address. NS_DispatchToMainThread( - NS_NewRunnableMethodWithArg( + NewRunnableMethod( this, &PresentationControllingInfo::OnGetAddress, "127.0.0.1")); @@ -579,7 +579,7 @@ PresentationControllingInfo::GetAddress() // TODO Get host IP via other platforms. NS_DispatchToMainThread( - NS_NewRunnableMethodWithArg( + NewRunnableMethod( this, &PresentationControllingInfo::OnGetAddress, EmptyCString())); diff --git a/dom/presentation/PresentationTCPSessionTransport.cpp b/dom/presentation/PresentationTCPSessionTransport.cpp index a2cd9b3a0b61..111242f4d7c4 100644 --- a/dom/presentation/PresentationTCPSessionTransport.cpp +++ b/dom/presentation/PresentationTCPSessionTransport.cpp @@ -111,18 +111,18 @@ PresentationTCPSessionTransport::BuildTCPSenderTransport(nsISocketTransport* aTr nsCOMPtr sessionTransport = do_QueryObject(this); nsCOMPtr onSessionTransportRunnable = - NS_NewRunnableMethodWithArgs + NewRunnableMethod (mListener, &nsIPresentationSessionTransportBuilderListener::OnSessionTransport, sessionTransport); - NS_DispatchToCurrentThread(onSessionTransportRunnable); + NS_DispatchToCurrentThread(onSessionTransportRunnable.forget()); nsCOMPtr setReadyStateRunnable = - NS_NewRunnableMethodWithArgs(this, - &PresentationTCPSessionTransport::SetReadyState, - ReadyState::OPEN); - return NS_DispatchToCurrentThread(setReadyStateRunnable); + NewRunnableMethod(this, + &PresentationTCPSessionTransport::SetReadyState, + ReadyState::OPEN); + return NS_DispatchToCurrentThread(setReadyStateRunnable.forget()); } NS_IMETHODIMP @@ -193,11 +193,11 @@ PresentationTCPSessionTransport::BuildTCPReceiverTransport(nsIPresentationChanne nsCOMPtr sessionTransport = do_QueryObject(this); nsCOMPtr runnable = - NS_NewRunnableMethodWithArgs + NewRunnableMethod (mListener, &nsIPresentationSessionTransportBuilderListener::OnSessionTransport, sessionTransport); - return NS_DispatchToCurrentThread(runnable); + return NS_DispatchToCurrentThread(runnable.forget()); } nsresult diff --git a/dom/presentation/provider/MulticastDNSDeviceProvider.cpp b/dom/presentation/provider/MulticastDNSDeviceProvider.cpp index 0880c83b3811..07f6710fc810 100644 --- a/dom/presentation/provider/MulticastDNSDeviceProvider.cpp +++ b/dom/presentation/provider/MulticastDNSDeviceProvider.cpp @@ -721,7 +721,7 @@ MulticastDNSDeviceProvider::OnRegistrationFailed(nsIDNSServiceInfo* aServiceInfo if (aErrorCode == nsIDNSRegistrationListener::ERROR_SERVICE_NOT_RUNNING) { return NS_DispatchToMainThread( - NS_NewRunnableMethod(this, &MulticastDNSDeviceProvider::RegisterService)); + NewRunnableMethod(this, &MulticastDNSDeviceProvider::RegisterService)); } return NS_OK; diff --git a/dom/quota/ActorsParent.cpp b/dom/quota/ActorsParent.cpp index 15ba4c243322..4e02495d13f3 100644 --- a/dom/quota/ActorsParent.cpp +++ b/dom/quota/ActorsParent.cpp @@ -3084,13 +3084,15 @@ QuotaManager::Shutdown() NS_WARNING("Failed to cancel shutdown timer!"); } - // Give clients a chance to cleanup IO thread only objects. - nsCOMPtr runnable = - NS_NewRunnableMethod(this, &QuotaManager::ReleaseIOThreadObjects); - if (!runnable) { - NS_WARNING("Failed to create runnable!"); - } + // NB: It's very important that runnable is destroyed on this thread + // (i.e. after we join the IO thread) because we can't release the + // QuotaManager on the IO thread. This should probably use + // NewNonOwningRunnableMethod ... + RefPtr runnable = + NewRunnableMethod(this, &QuotaManager::ReleaseIOThreadObjects); + MOZ_ASSERT(runnable); + // Give clients a chance to cleanup IO thread only objects. if (NS_FAILED(mIOThread->Dispatch(runnable, NS_DISPATCH_NORMAL))) { NS_WARNING("Failed to dispatch runnable!"); } @@ -5313,7 +5315,7 @@ Quota::RecvStartIdleMaintenance() QuotaManager* quotaManager = QuotaManager::Get(); if (!quotaManager) { nsCOMPtr callback = - NS_NewRunnableMethod(this, &Quota::StartIdleMaintenance); + NewRunnableMethod(this, &Quota::StartIdleMaintenance); QuotaManager::GetOrCreate(callback); return true; diff --git a/dom/storage/DOMStorageCache.cpp b/dom/storage/DOMStorageCache.cpp index 82c6ddcae924..6c7aed5b3258 100644 --- a/dom/storage/DOMStorageCache.cpp +++ b/dom/storage/DOMStorageCache.cpp @@ -110,8 +110,8 @@ DOMStorageCache::Release(void) } RefPtr > event = - NS_NewNonOwningRunnableMethod(static_cast(this), - &DOMStorageCacheBridge::Release); + NewNonOwningRunnableMethod(static_cast(this), + &DOMStorageCacheBridge::Release); nsresult rv = NS_DispatchToMainThread(event); if (NS_FAILED(rv)) { @@ -281,10 +281,7 @@ DOMStorageCache::KeepAlive() if (!NS_IsMainThread()) { // Timer and the holder must be initialized on the main thread. - RefPtr > event = - NS_NewRunnableMethod(this, &DOMStorageCache::KeepAlive); - - NS_DispatchToMainThread(event); + NS_DispatchToMainThread(NewRunnableMethod(this, &DOMStorageCache::KeepAlive)); return; } diff --git a/dom/storage/DOMStorageDBThread.cpp b/dom/storage/DOMStorageDBThread.cpp index 945b4407b229..95e461c9f6fe 100644 --- a/dom/storage/DOMStorageDBThread.cpp +++ b/dom/storage/DOMStorageDBThread.cpp @@ -721,7 +721,7 @@ DOMStorageDBThread::NotifyFlushCompletion() #ifdef DOM_STORAGE_TESTS if (!NS_IsMainThread()) { RefPtr > event = - NS_NewNonOwningRunnableMethod(this, &DOMStorageDBThread::NotifyFlushCompletion); + NewNonOwningRunnableMethod(this, &DOMStorageDBThread::NotifyFlushCompletion); NS_DispatchToMainThread(event); return; } diff --git a/dom/svg/SVGFEImageElement.cpp b/dom/svg/SVGFEImageElement.cpp index e085f00895ed..b2ebfbe0fd56 100644 --- a/dom/svg/SVGFEImageElement.cpp +++ b/dom/svg/SVGFEImageElement.cpp @@ -155,7 +155,7 @@ SVGFEImageElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, ClearBrokenState(); RemoveStatesSilently(NS_EVENT_STATE_BROKEN); nsContentUtils::AddScriptRunner( - NS_NewRunnableMethod(this, &SVGFEImageElement::MaybeLoadSVGImage)); + NewRunnableMethod(this, &SVGFEImageElement::MaybeLoadSVGImage)); } return rv; diff --git a/dom/svg/SVGImageElement.cpp b/dom/svg/SVGImageElement.cpp index 144e375f2dc8..6d5af4128ee4 100644 --- a/dom/svg/SVGImageElement.cpp +++ b/dom/svg/SVGImageElement.cpp @@ -183,7 +183,7 @@ SVGImageElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, ClearBrokenState(); RemoveStatesSilently(NS_EVENT_STATE_BROKEN); nsContentUtils::AddScriptRunner( - NS_NewRunnableMethod(this, &SVGImageElement::MaybeLoadSVGImage)); + NewRunnableMethod(this, &SVGImageElement::MaybeLoadSVGImage)); } return rv; diff --git a/dom/svg/SVGStyleElement.cpp b/dom/svg/SVGStyleElement.cpp index 33437f7ba712..22fb204dff95 100644 --- a/dom/svg/SVGStyleElement.cpp +++ b/dom/svg/SVGStyleElement.cpp @@ -78,7 +78,7 @@ SVGStyleElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, NS_ENSURE_SUCCESS(rv, rv); void (SVGStyleElement::*update)() = &SVGStyleElement::UpdateStyleSheetInternal; - nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, update)); + nsContentUtils::AddScriptRunner(NewRunnableMethod(this, update)); return rv; } diff --git a/dom/tv/TVSource.cpp b/dom/tv/TVSource.cpp index 869315e650ed..1b78fdf0b66d 100644 --- a/dom/tv/TVSource.cpp +++ b/dom/tv/TVSource.cpp @@ -372,9 +372,9 @@ TVSource::DispatchCurrentChannelChangedEvent(TVChannel* aChannel) NS_LITERAL_STRING("currentchannelchanged"), init); nsCOMPtr runnable = - NS_NewRunnableMethodWithArg>(this, - &TVSource::DispatchTVEvent, - event); + NewRunnableMethod>(this, + &TVSource::DispatchTVEvent, + event); return NS_DispatchToCurrentThread(runnable); } @@ -390,9 +390,9 @@ TVSource::DispatchScanningStateChangedEvent(TVScanningState aState, NS_LITERAL_STRING("scanningstatechanged"), init); nsCOMPtr runnable = - NS_NewRunnableMethodWithArg>(this, - &TVSource::DispatchTVEvent, - event); + NewRunnableMethod>(this, + &TVSource::DispatchTVEvent, + event); return NS_DispatchToCurrentThread(runnable); } @@ -406,9 +406,9 @@ TVSource::DispatchEITBroadcastedEvent(const Sequence>& NS_LITERAL_STRING("eitbroadcasted"), init); nsCOMPtr runnable = - NS_NewRunnableMethodWithArg>(this, - &TVSource::DispatchTVEvent, - event); + NewRunnableMethod>(this, + &TVSource::DispatchTVEvent, + event); return NS_DispatchToCurrentThread(runnable); } diff --git a/dom/tv/TVTuner.cpp b/dom/tv/TVTuner.cpp index e1e4412ddca8..35f53eb9ac5c 100644 --- a/dom/tv/TVTuner.cpp +++ b/dom/tv/TVTuner.cpp @@ -315,9 +315,9 @@ TVTuner::DispatchCurrentSourceChangedEvent(TVSource* aSource) NS_LITERAL_STRING("currentsourcechanged"), init); nsCOMPtr runnable = - NS_NewRunnableMethodWithArg>(this, - &TVTuner::DispatchTVEvent, - event); + NewRunnableMethod>(this, + &TVTuner::DispatchTVEvent, + event); return NS_DispatchToCurrentThread(runnable); } diff --git a/dom/workers/ScriptLoader.cpp b/dom/workers/ScriptLoader.cpp index 79db69341c7f..c6730300b049 100644 --- a/dom/workers/ScriptLoader.cpp +++ b/dom/workers/ScriptLoader.cpp @@ -716,11 +716,9 @@ private: if (aStatus >= Terminating && !mCanceled) { mCanceled = true; - nsCOMPtr runnable = - NS_NewRunnableMethod(this, - &ScriptLoaderRunnable::CancelMainThreadWithBindingAborted); - NS_ASSERTION(runnable, "This should never fail!"); - MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(runnable)); + MOZ_ALWAYS_SUCCEEDS( + NS_DispatchToMainThread(NewRunnableMethod(this, + &ScriptLoaderRunnable::CancelMainThreadWithBindingAborted))); } return true; diff --git a/dom/workers/ServiceWorkerEvents.cpp b/dom/workers/ServiceWorkerEvents.cpp index f79105c00a89..5d86cd1f3019 100644 --- a/dom/workers/ServiceWorkerEvents.cpp +++ b/dom/workers/ServiceWorkerEvents.cpp @@ -853,9 +853,8 @@ public: mColumn = column; } - nsCOMPtr runnable = - NS_NewRunnableMethod(this, &WaitUntilHandler::ReportOnMainThread); - MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(runnable.forget())); + MOZ_ALWAYS_SUCCEEDS( + NS_DispatchToMainThread(NewRunnableMethod(this, &WaitUntilHandler::ReportOnMainThread))); } void diff --git a/dom/workers/ServiceWorkerJob.cpp b/dom/workers/ServiceWorkerJob.cpp index c634fb915480..73716fab615b 100644 --- a/dom/workers/ServiceWorkerJob.cpp +++ b/dom/workers/ServiceWorkerJob.cpp @@ -95,7 +95,7 @@ ServiceWorkerJob::Start(Callback* aFinalCallback) mState = State::Started; nsCOMPtr runnable = - NS_NewRunnableMethod(this, &ServiceWorkerJob::AsyncExecute); + NewRunnableMethod(this, &ServiceWorkerJob::AsyncExecute); // We may have to wait for the PBackground actor to be initialized // before proceeding. We should always be able to get a ServiceWorkerManager, diff --git a/dom/workers/ServiceWorkerPrivate.cpp b/dom/workers/ServiceWorkerPrivate.cpp index 3ada307db781..ba13cf17ef1d 100644 --- a/dom/workers/ServiceWorkerPrivate.cpp +++ b/dom/workers/ServiceWorkerPrivate.cpp @@ -622,7 +622,7 @@ public: return; } nsCOMPtr runnable = - NS_NewRunnableMethodWithArg(this, + NewRunnableMethod(this, &PushErrorReporter::ReportOnMainThread, aReason); MOZ_ALWAYS_TRUE(NS_SUCCEEDED( NS_DispatchToMainThread(runnable.forget()))); @@ -1457,7 +1457,7 @@ ServiceWorkerPrivate::SendFetchEvent(nsIInterceptedChannel* aChannel, // if the ServiceWorker script fails to load for some reason, just resume // the original channel. nsCOMPtr failRunnable = - NS_NewRunnableMethod(aChannel, &nsIInterceptedChannel::ResetInterception); + NewRunnableMethod(aChannel, &nsIInterceptedChannel::ResetInterception); nsresult rv = SpawnWorkerIfNeeded(FetchEvent, failRunnable, aLoadGroup); NS_ENSURE_SUCCESS(rv, rv); diff --git a/dom/workers/ServiceWorkerRegistrar.cpp b/dom/workers/ServiceWorkerRegistrar.cpp index a9609aae3d31..54ab9b4d586a 100644 --- a/dom/workers/ServiceWorkerRegistrar.cpp +++ b/dom/workers/ServiceWorkerRegistrar.cpp @@ -540,7 +540,7 @@ public: service->SaveData(); RefPtr runnable = - NS_NewRunnableMethod(service, &ServiceWorkerRegistrar::DataSaved); + NewRunnableMethod(service, &ServiceWorkerRegistrar::DataSaved); nsresult rv = mThread->Dispatch(runnable, NS_DISPATCH_NORMAL); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; @@ -614,7 +614,7 @@ ServiceWorkerRegistrar::MaybeScheduleShutdownCompleted() } RefPtr runnable = - NS_NewRunnableMethod(this, &ServiceWorkerRegistrar::ShutdownCompleted); + NewRunnableMethod(this, &ServiceWorkerRegistrar::ShutdownCompleted); nsresult rv = NS_DispatchToMainThread(runnable); if (NS_WARN_IF(NS_FAILED(rv))) { return; @@ -744,7 +744,7 @@ ServiceWorkerRegistrar::ProfileStarted() MOZ_ASSERT(target, "Must have stream transport service"); nsCOMPtr runnable = - NS_NewRunnableMethod(this, &ServiceWorkerRegistrar::LoadData); + NewRunnableMethod(this, &ServiceWorkerRegistrar::LoadData); rv = target->Dispatch(runnable, NS_DISPATCH_NORMAL); if (NS_FAILED(rv)) { NS_WARNING("Failed to dispatch the LoadDataRunnable."); diff --git a/dom/workers/ServiceWorkerRegistrationInfo.cpp b/dom/workers/ServiceWorkerRegistrationInfo.cpp index aeb96a44780b..3bf6348e6219 100644 --- a/dom/workers/ServiceWorkerRegistrationInfo.cpp +++ b/dom/workers/ServiceWorkerRegistrationInfo.cpp @@ -201,10 +201,9 @@ ServiceWorkerRegistrationInfo::GetServiceWorkerInfoById(uint64_t aId) void ServiceWorkerRegistrationInfo::TryToActivateAsync() { - nsCOMPtr r = - NS_NewRunnableMethod(this, - &ServiceWorkerRegistrationInfo::TryToActivate); - MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(r)); + MOZ_ALWAYS_SUCCEEDS( + NS_DispatchToMainThread(NewRunnableMethod(this, + &ServiceWorkerRegistrationInfo::TryToActivate))); } /* @@ -236,14 +235,14 @@ ServiceWorkerRegistrationInfo::Activate() // "Queue a task to fire a simple event named controllerchange..." nsCOMPtr controllerChangeRunnable = - NS_NewRunnableMethodWithArg>( + NewRunnableMethod>( swm, &ServiceWorkerManager::FireControllerChange, this); NS_DispatchToMainThread(controllerChangeRunnable); nsCOMPtr failRunnable = - NS_NewRunnableMethodWithArg(this, - &ServiceWorkerRegistrationInfo::FinishActivate, - false /* success */); + NewRunnableMethod(this, + &ServiceWorkerRegistrationInfo::FinishActivate, + false /* success */); nsMainThreadPtrHandle handle( new nsMainThreadPtrHolder(this)); diff --git a/dom/workers/ServiceWorkerUpdateJob.cpp b/dom/workers/ServiceWorkerUpdateJob.cpp index d1f20a3452d9..337c3dca365e 100644 --- a/dom/workers/ServiceWorkerUpdateJob.cpp +++ b/dom/workers/ServiceWorkerUpdateJob.cpp @@ -489,7 +489,7 @@ ServiceWorkerUpdateJob::Install() // fire the updatefound event nsCOMPtr upr = - NS_NewRunnableMethodWithArg>( + NewRunnableMethod>( swm, &ServiceWorkerManager::FireUpdateFoundOnServiceWorkerRegistrations, mRegistration); @@ -497,7 +497,7 @@ ServiceWorkerUpdateJob::Install() // Call ContinueAfterInstallEvent(false) on main thread if the SW // script fails to load. - nsCOMPtr failRunnable = NS_NewRunnableMethodWithArgs + nsCOMPtr failRunnable = NewRunnableMethod (this, &ServiceWorkerUpdateJob::ContinueAfterInstallEvent, false); nsMainThreadPtrHandle handle( diff --git a/dom/xbl/nsBindingManager.cpp b/dom/xbl/nsBindingManager.cpp index 9e2bb527713a..b3ee9b121af4 100644 --- a/dom/xbl/nsBindingManager.cpp +++ b/dom/xbl/nsBindingManager.cpp @@ -347,7 +347,7 @@ void nsBindingManager::PostProcessAttachedQueueEvent() { mProcessAttachedQueueEvent = - NS_NewRunnableMethod(this, &nsBindingManager::DoProcessAttachedQueue); + NewRunnableMethod(this, &nsBindingManager::DoProcessAttachedQueue); nsresult rv = NS_DispatchToCurrentThread(mProcessAttachedQueueEvent); if (NS_SUCCEEDED(rv) && mDocument) { mDocument->BlockOnload(); diff --git a/dom/xml/XMLStylesheetProcessingInstruction.cpp b/dom/xml/XMLStylesheetProcessingInstruction.cpp index cc5734c6a490..3d94e179b48a 100644 --- a/dom/xml/XMLStylesheetProcessingInstruction.cpp +++ b/dom/xml/XMLStylesheetProcessingInstruction.cpp @@ -63,7 +63,7 @@ XMLStylesheetProcessingInstruction::BindToTree(nsIDocument* aDocument, void (XMLStylesheetProcessingInstruction::*update)() = &XMLStylesheetProcessingInstruction::UpdateStyleSheetInternal; - nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, update)); + nsContentUtils::AddScriptRunner(NewRunnableMethod(this, update)); return rv; } diff --git a/dom/xml/nsXMLContentSink.cpp b/dom/xml/nsXMLContentSink.cpp index 1bc56506c46d..e33c48d0360d 100644 --- a/dom/xml/nsXMLContentSink.cpp +++ b/dom/xml/nsXMLContentSink.cpp @@ -1553,7 +1553,7 @@ nsXMLContentSink::ContinueInterruptedParsingIfEnabled() void nsXMLContentSink::ContinueInterruptedParsingAsync() { - nsCOMPtr ev = NS_NewRunnableMethod(this, + nsCOMPtr ev = NewRunnableMethod(this, &nsXMLContentSink::ContinueInterruptedParsingIfEnabled); NS_DispatchToCurrentThread(ev); diff --git a/dom/xml/nsXMLPrettyPrinter.cpp b/dom/xml/nsXMLPrettyPrinter.cpp index ee50cd0ac3cb..2e086dde0bee 100644 --- a/dom/xml/nsXMLPrettyPrinter.cpp +++ b/dom/xml/nsXMLPrettyPrinter.cpp @@ -194,7 +194,7 @@ nsXMLPrettyPrinter::MaybeUnhook(nsIContent* aContent) // synchronously mUnhookPending = true; nsContentUtils::AddScriptRunner( - NS_NewRunnableMethod(this, &nsXMLPrettyPrinter::Unhook)); + NewRunnableMethod(this, &nsXMLPrettyPrinter::Unhook)); } } diff --git a/dom/xul/XULDocument.cpp b/dom/xul/XULDocument.cpp index 6e6262d91216..50ba10c233a8 100644 --- a/dom/xul/XULDocument.cpp +++ b/dom/xul/XULDocument.cpp @@ -1015,7 +1015,7 @@ XULDocument::AttributeChanged(nsIDocument* aDocument, if (ShouldPersistAttribute(aElement, aAttribute) && !persist.IsEmpty() && // XXXldb This should check that it's a token, not just a substring. persist.Find(nsDependentAtomString(aAttribute)) >= 0) { - nsContentUtils::AddScriptRunner(NS_NewRunnableMethodWithArgs + nsContentUtils::AddScriptRunner(NewRunnableMethod (this, &XULDocument::DoPersist, aElement, kNameSpaceID_None, aAttribute)); @@ -3135,7 +3135,7 @@ XULDocument::MaybeBroadcast() if (!nsContentUtils::IsSafeToRunScript()) { if (!mInDestructor) { nsContentUtils::AddScriptRunner( - NS_NewRunnableMethod(this, &XULDocument::MaybeBroadcast)); + NewRunnableMethod(this, &XULDocument::MaybeBroadcast)); } return; } diff --git a/dom/xul/templates/nsXULTemplateBuilder.cpp b/dom/xul/templates/nsXULTemplateBuilder.cpp index 632afcd06400..2ae794944cad 100644 --- a/dom/xul/templates/nsXULTemplateBuilder.cpp +++ b/dom/xul/templates/nsXULTemplateBuilder.cpp @@ -1096,13 +1096,13 @@ nsXULTemplateBuilder::AttributeChanged(nsIDocument* aDocument, // beneath the element. if (aAttribute == nsGkAtoms::ref) nsContentUtils::AddScriptRunner( - NS_NewRunnableMethod(this, &nsXULTemplateBuilder::RunnableRebuild)); + NewRunnableMethod(this, &nsXULTemplateBuilder::RunnableRebuild)); // Check for a change to the 'datasources' attribute. If so, setup // mDB by parsing the new value and rebuild. else if (aAttribute == nsGkAtoms::datasources) { nsContentUtils::AddScriptRunner( - NS_NewRunnableMethod(this, &nsXULTemplateBuilder::RunnableLoadAndRebuild)); + NewRunnableMethod(this, &nsXULTemplateBuilder::RunnableLoadAndRebuild)); } } } @@ -1122,7 +1122,7 @@ nsXULTemplateBuilder::ContentRemoved(nsIDocument* aDocument, // Pass false to Uninit since content is going away anyway nsContentUtils::AddScriptRunner( - NS_NewRunnableMethod(this, &nsXULTemplateBuilder::UninitFalse)); + NewRunnableMethod(this, &nsXULTemplateBuilder::UninitFalse)); MOZ_ASSERT(aDocument == mObservedDocument); StopObserving(); @@ -1161,7 +1161,7 @@ nsXULTemplateBuilder::NodeWillBeDestroyed(const nsINode* aNode) mCompDB = nullptr; nsContentUtils::AddScriptRunner( - NS_NewRunnableMethod(this, &nsXULTemplateBuilder::UninitTrue)); + NewRunnableMethod(this, &nsXULTemplateBuilder::UninitTrue)); } diff --git a/editor/libeditor/nsHTMLEditRules.cpp b/editor/libeditor/nsHTMLEditRules.cpp index 803d6710ca99..55c0d77d7240 100644 --- a/editor/libeditor/nsHTMLEditRules.cpp +++ b/editor/libeditor/nsHTMLEditRules.cpp @@ -8731,7 +8731,7 @@ nsHTMLEditRules::WillRelativeChangeZIndex(Selection* aSelection, NS_IMETHODIMP nsHTMLEditRules::DocumentModified() { - nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, &nsHTMLEditRules::DocumentModifiedWorker)); + nsContentUtils::AddScriptRunner(NewRunnableMethod(this, &nsHTMLEditRules::DocumentModifiedWorker)); return NS_OK; } diff --git a/editor/libeditor/nsHTMLEditor.cpp b/editor/libeditor/nsHTMLEditor.cpp index b8d700ba7316..bb3e5c83eeab 100644 --- a/editor/libeditor/nsHTMLEditor.cpp +++ b/editor/libeditor/nsHTMLEditor.cpp @@ -3204,7 +3204,7 @@ nsHTMLEditor::DoContentInserted(nsIDocument* aDocument, nsIContent* aContainer, nsCOMPtr kungFuDeathGrip(this); if (ShouldReplaceRootElement()) { - nsContentUtils::AddScriptRunner(NS_NewRunnableMethod( + nsContentUtils::AddScriptRunner(NewRunnableMethod( this, &nsHTMLEditor::ResetRootElementAndEventTarget)); } // We don't need to handle our own modifications @@ -3246,7 +3246,7 @@ nsHTMLEditor::ContentRemoved(nsIDocument *aDocument, nsIContent* aContainer, nsCOMPtr kungFuDeathGrip(this); if (SameCOMIdentity(aChild, mRootElement)) { - nsContentUtils::AddScriptRunner(NS_NewRunnableMethod( + nsContentUtils::AddScriptRunner(NewRunnableMethod( this, &nsHTMLEditor::ResetRootElementAndEventTarget)); } // We don't need to handle our own modifications diff --git a/embedding/components/webbrowserpersist/WebBrowserPersistDocumentParent.cpp b/embedding/components/webbrowserpersist/WebBrowserPersistDocumentParent.cpp index 35a62918755d..248b05b9b0cc 100644 --- a/embedding/components/webbrowserpersist/WebBrowserPersistDocumentParent.cpp +++ b/embedding/components/webbrowserpersist/WebBrowserPersistDocumentParent.cpp @@ -43,7 +43,7 @@ WebBrowserPersistDocumentParent::ActorDestroy(ActorDestroyReason aWhy) // dropping the last reference to another document's // WebBrowserPersistRemoteDocument. To avoid that, defer the // callback until after the entire subtree is destroyed. - nsCOMPtr errorLater = NS_NewRunnableMethodWithArg + nsCOMPtr errorLater = NewRunnableMethod (mOnReady, &nsIWebBrowserPersistDocumentReceiver::OnError, NS_ERROR_FAILURE); NS_DispatchToCurrentThread(errorLater); diff --git a/embedding/components/webbrowserpersist/WebBrowserPersistResourcesParent.cpp b/embedding/components/webbrowserpersist/WebBrowserPersistResourcesParent.cpp index 13c1f7f65e6f..195cabb58b9d 100644 --- a/embedding/components/webbrowserpersist/WebBrowserPersistResourcesParent.cpp +++ b/embedding/components/webbrowserpersist/WebBrowserPersistResourcesParent.cpp @@ -33,7 +33,7 @@ WebBrowserPersistResourcesParent::ActorDestroy(ActorDestroyReason aWhy) if (aWhy != Deletion && mVisitor) { // See comment in WebBrowserPersistDocumentParent::ActorDestroy // (or bug 1202887) for why this is deferred. - nsCOMPtr errorLater = NS_NewRunnableMethodWithArgs + nsCOMPtr errorLater = NewRunnableMethod , nsresult> (mVisitor, &nsIWebBrowserPersistResourceVisitor::EndVisit, mDocument, NS_ERROR_FAILURE); diff --git a/embedding/components/webbrowserpersist/WebBrowserPersistSerializeParent.cpp b/embedding/components/webbrowserpersist/WebBrowserPersistSerializeParent.cpp index 348ba3418ae1..2f76ffb332a8 100644 --- a/embedding/components/webbrowserpersist/WebBrowserPersistSerializeParent.cpp +++ b/embedding/components/webbrowserpersist/WebBrowserPersistSerializeParent.cpp @@ -77,7 +77,7 @@ WebBrowserPersistSerializeParent::ActorDestroy(ActorDestroyReason aWhy) MOZ_ASSERT(aWhy != Deletion); // See comment in WebBrowserPersistDocumentParent::ActorDestroy // (or bug 1202887) for why this is deferred. - nsCOMPtr errorLater = NS_NewRunnableMethodWithArgs + nsCOMPtr errorLater = NewRunnableMethod , nsCOMPtr, nsCString, nsresult> (mFinish, &nsIWebBrowserPersistWriteCompletion::OnFinish, diff --git a/embedding/components/webbrowserpersist/nsWebBrowserPersist.cpp b/embedding/components/webbrowserpersist/nsWebBrowserPersist.cpp index 0b1ae126a924..6cf3e7751861 100644 --- a/embedding/components/webbrowserpersist/nsWebBrowserPersist.cpp +++ b/embedding/components/webbrowserpersist/nsWebBrowserPersist.cpp @@ -672,7 +672,7 @@ nsWebBrowserPersist::SerializeNextFile() // Finish and clean things up. Defer this because the caller // may have been expecting to use the listeners that that // method will clear. - NS_DispatchToCurrentThread(NS_NewRunnableMethod(this, + NS_DispatchToCurrentThread(NewRunnableMethod(this, &nsWebBrowserPersist::FinishDownload)); return; } @@ -784,7 +784,7 @@ nsWebBrowserPersist::OnWrite::OnFinish(nsIWebBrowserPersistDocument* aDoc, return NS_OK; } } - NS_DispatchToCurrentThread(NS_NewRunnableMethod(mParent, + NS_DispatchToCurrentThread(NewRunnableMethod(mParent, &nsWebBrowserPersist::SerializeNextFile)); return NS_OK; } @@ -1794,8 +1794,8 @@ nsWebBrowserPersist::FinishSaveDocumentInternal(nsIURI* aFile, typedef StoreCopyPassByRRef WalkStorage; auto saveMethod = &nsWebBrowserPersist::SaveDocumentDeferred; nsCOMPtr saveLater = - NS_NewRunnableMethodWithArg(this, saveMethod, - mozilla::Move(toWalk)); + NewRunnableMethod(this, saveMethod, + mozilla::Move(toWalk)); NS_DispatchToCurrentThread(saveLater); } else { // Done walking DOMs; on to the serialization phase. diff --git a/gfx/gl/AndroidSurfaceTexture.cpp b/gfx/gl/AndroidSurfaceTexture.cpp index 08d880c7ca14..02aa2fc9577f 100644 --- a/gfx/gl/AndroidSurfaceTexture.cpp +++ b/gfx/gl/AndroidSurfaceTexture.cpp @@ -293,8 +293,7 @@ AndroidSurfaceTexture::NotifyFrameAvailable() // Proxy to main thread if we aren't on it if (!NS_IsMainThread()) { // Proxy to main thread - nsCOMPtr event = NS_NewRunnableMethod(this, &AndroidSurfaceTexture::NotifyFrameAvailable); - NS_DispatchToCurrentThread(event); + NS_DispatchToCurrentThread(NewRunnableMethod(this, &AndroidSurfaceTexture::NotifyFrameAvailable)); } else { mFrameAvailableCallback->Run(); } diff --git a/gfx/layers/apz/src/APZCTreeManager.cpp b/gfx/layers/apz/src/APZCTreeManager.cpp index b41969251198..7680d572be4c 100644 --- a/gfx/layers/apz/src/APZCTreeManager.cpp +++ b/gfx/layers/apz/src/APZCTreeManager.cpp @@ -649,8 +649,8 @@ APZCTreeManager::FlushApzRepaints(uint64_t aLayersId) const CompositorBridgeParent::LayerTreeState* state = CompositorBridgeParent::GetIndirectShadowTree(aLayersId); MOZ_ASSERT(state && state->mController); - NS_DispatchToMainThread(NS_NewRunnableMethod( - state->mController.get(), &GeckoContentController::NotifyFlushComplete)); + NS_DispatchToMainThread(NewRunnableMethod( + state->mController, &GeckoContentController::NotifyFlushComplete)); } nsEventStatus @@ -1345,8 +1345,7 @@ APZCTreeManager::ClearTree() // Ensure that no references to APZCs are alive in any lingering input // blocks. This breaks cycles from InputBlockState::mTargetApzc back to // the InputQueue. - RefPtr runnable = NS_NewRunnableMethod(mInputQueue.get(), &InputQueue::Clear); - APZThreadUtils::RunOnControllerThread(runnable.forget()); + APZThreadUtils::RunOnControllerThread(NewRunnableMethod(mInputQueue, &InputQueue::Clear)); MutexAutoLock lock(mTreeLock); diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index 6af6ff985ac7..68a22c354459 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -516,9 +516,9 @@ public: // is this one, then the SetState(NOTHING) in UpdateAnimation will // stomp on the SetState(SNAP_BACK) it does. mDeferredTasks.AppendElement( - NS_NewRunnableMethodWithArg(mOverscrollHandoffChain.get(), - &OverscrollHandoffChain::SnapBackOverscrolledApzc, - &mApzc)); + NewRunnableMethod(mOverscrollHandoffChain.get(), + &OverscrollHandoffChain::SnapBackOverscrolledApzc, + &mApzc)); return false; } @@ -568,13 +568,13 @@ public: // called after mMonitor is released. APZC_LOG("%p fling went into overscroll, handing off with velocity %s\n", &mApzc, Stringify(velocity).c_str()); mDeferredTasks.AppendElement( - NS_NewRunnableMethodWithArgs, - RefPtr>(&mApzc, - &AsyncPanZoomController::HandleFlingOverscroll, - velocity, - mOverscrollHandoffChain, - mScrolledApzc)); + NewRunnableMethod, + RefPtr>(&mApzc, + &AsyncPanZoomController::HandleFlingOverscroll, + velocity, + mOverscrollHandoffChain, + mScrolledApzc)); // If there is a remaining velocity on this APZC, continue this fling // as well. (This fling and the handed-off fling will run concurrently.) @@ -702,7 +702,7 @@ public: // The scroll snapping is done in a deferred task, otherwise the state // change to NOTHING caused by the overscroll animation ending would // clobber a possible state change to SMOOTH_SCROLL in ScrollSnap(). - mDeferredTasks.AppendElement(NS_NewRunnableMethod(&mApzc, &AsyncPanZoomController::ScrollSnap)); + mDeferredTasks.AppendElement(NewRunnableMethod(&mApzc, &AsyncPanZoomController::ScrollSnap)); return false; } return true; @@ -819,9 +819,9 @@ public: // the lock ordering. Instead we schedule HandleSmoothScrollOverscroll() to be // called after mMonitor is released. mDeferredTasks.AppendElement( - NS_NewRunnableMethodWithArgs(&mApzc, - &AsyncPanZoomController::HandleSmoothScrollOverscroll, - velocity)); + NewRunnableMethod(&mApzc, + &AsyncPanZoomController::HandleSmoothScrollOverscroll, + velocity)); return false; } @@ -2181,11 +2181,11 @@ nsEventStatus AsyncPanZoomController::GenerateSingleTap(const ScreenIntPoint& aP // schedule the singletap message to run on the next spin of the event loop. // See bug 965381 for the issue this was causing. RefPtr runnable = - NS_NewRunnableMethodWithArgs(controller, &GeckoContentController::HandleSingleTap, - geckoScreenPoint, aModifiers, - GetGuid()); + NewRunnableMethod(controller, &GeckoContentController::HandleSingleTap, + geckoScreenPoint, aModifiers, + GetGuid()); controller->PostDelayedTask(runnable.forget(), 0); return nsEventStatus_eConsumeNoDefault; @@ -2995,7 +2995,7 @@ void AsyncPanZoomController::RequestContentRepaint() { // use the local variable to resolve the function overload. auto func = static_cast (&AsyncPanZoomController::RequestContentRepaint); - NS_DispatchToMainThread(NS_NewRunnableMethod(this, func)); + NS_DispatchToMainThread(NewRunnableMethod(this, func)); return; } @@ -3728,7 +3728,7 @@ void AsyncPanZoomController::ZoomToRect(CSSRect aRect, const uint32_t aFlags) { auto func = static_cast (&AsyncPanZoomController::RequestContentRepaint); NS_DispatchToMainThread( - NS_NewRunnableMethodWithArgs( + NewRunnableMethod( this, func, endZoomToMetrics, velocity)); } } diff --git a/gfx/layers/apz/src/GestureEventListener.cpp b/gfx/layers/apz/src/GestureEventListener.cpp index c3c6f8b0d73f..b81ddc10efe1 100644 --- a/gfx/layers/apz/src/GestureEventListener.cpp +++ b/gfx/layers/apz/src/GestureEventListener.cpp @@ -498,7 +498,7 @@ void GestureEventListener::CancelLongTapTimeoutTask() void GestureEventListener::CreateLongTapTimeoutTask() { RefPtr task = - NS_NewCancelableRunnableMethod(this, &GestureEventListener::HandleInputTimeoutLongTap); + NewCancelableRunnableMethod(this, &GestureEventListener::HandleInputTimeoutLongTap); mLongTapTimeoutTask = task; mAsyncPanZoomController->PostDelayedTask( @@ -525,9 +525,9 @@ void GestureEventListener::CreateMaxTapTimeoutTask() TouchBlockState* block = mAsyncPanZoomController->GetInputQueue()->CurrentTouchBlock(); RefPtr task = - NS_NewCancelableRunnableMethodWithArgs(this, - &GestureEventListener::HandleInputTimeoutMaxTap, - block->IsDuringFastFling()); + NewCancelableRunnableMethod(this, + &GestureEventListener::HandleInputTimeoutMaxTap, + block->IsDuringFastFling()); mMaxTapTimeoutTask = task; mAsyncPanZoomController->PostDelayedTask( diff --git a/gfx/layers/apz/src/InputQueue.cpp b/gfx/layers/apz/src/InputQueue.cpp index 1fe5606da344..c267b097b26e 100644 --- a/gfx/layers/apz/src/InputQueue.cpp +++ b/gfx/layers/apz/src/InputQueue.cpp @@ -570,10 +570,10 @@ InputQueue::ScheduleMainThreadTimeout(const RefPtr& aTar CancelableBlockState* aBlock) { INPQ_LOG("scheduling main thread timeout for target %p\n", aTarget.get()); aBlock->StartContentResponseTimer(); - RefPtr runnable = - NS_NewRunnableMethodWithArgs(this, &InputQueue::MainThreadTimeout, aBlock->GetBlockId()); - aTarget->PostDelayedTask(runnable.forget(), - gfxPrefs::APZContentResponseTimeout()); + aTarget->PostDelayedTask(NewRunnableMethod(this, + &InputQueue::MainThreadTimeout, + aBlock->GetBlockId()), + gfxPrefs::APZContentResponseTimeout()); } void diff --git a/gfx/layers/apz/util/ActiveElementManager.cpp b/gfx/layers/apz/util/ActiveElementManager.cpp index fa4aa6b8d0ec..20d34aa2bb1a 100644 --- a/gfx/layers/apz/util/ActiveElementManager.cpp +++ b/gfx/layers/apz/util/ActiveElementManager.cpp @@ -95,9 +95,9 @@ ActiveElementManager::TriggerElementActivation() MOZ_ASSERT(mSetActiveTask == nullptr); RefPtr task = - NS_NewCancelableRunnableMethodWithArgs>(this, - &ActiveElementManager::SetActiveTask, - mTarget); + NewCancelableRunnableMethod>(this, + &ActiveElementManager::SetActiveTask, + mTarget); mSetActiveTask = task; MessageLoop::current()->PostDelayedTask(task.forget(), sActivationDelayMs); AEM_LOG("Scheduling mSetActiveTask %p\n", mSetActiveTask); diff --git a/gfx/layers/apz/util/ChromeProcessController.cpp b/gfx/layers/apz/util/ChromeProcessController.cpp index 54950bd04d43..19ec6ac26973 100644 --- a/gfx/layers/apz/util/ChromeProcessController.cpp +++ b/gfx/layers/apz/util/ChromeProcessController.cpp @@ -36,8 +36,7 @@ ChromeProcessController::ChromeProcessController(nsIWidget* aWidget, MOZ_ASSERT(aAPZEventState); MOZ_ASSERT(aAPZCTreeManager); - RefPtr runnable = NS_NewRunnableMethod(this, &ChromeProcessController::InitializeRoot); - mUILoop->PostTask(runnable.forget()); + mUILoop->PostTask(NewRunnableMethod(this, &ChromeProcessController::InitializeRoot)); } ChromeProcessController::~ChromeProcessController() {} @@ -71,8 +70,7 @@ void ChromeProcessController::Destroy() { if (MessageLoop::current() != mUILoop) { - RefPtr runnable = NS_NewRunnableMethod(this, &ChromeProcessController::Destroy); - mUILoop->PostTask(runnable.forget()); + mUILoop->PostTask(NewRunnableMethod(this, &ChromeProcessController::Destroy)); return; } @@ -121,12 +119,12 @@ ChromeProcessController::HandleDoubleTap(const mozilla::CSSPoint& aPoint, const ScrollableLayerGuid& aGuid) { if (MessageLoop::current() != mUILoop) { - RefPtr runnable = - NS_NewRunnableMethodWithArgs(this, &ChromeProcessController::HandleDoubleTap, - aPoint, aModifiers, aGuid); - mUILoop->PostTask(runnable.forget()); + mUILoop->PostTask(NewRunnableMethod + (this, + &ChromeProcessController::HandleDoubleTap, + aPoint, aModifiers, aGuid)); return; } @@ -161,12 +159,12 @@ ChromeProcessController::HandleSingleTap(const CSSPoint& aPoint, const ScrollableLayerGuid& aGuid) { if (MessageLoop::current() != mUILoop) { - RefPtr runnable = - NS_NewRunnableMethodWithArgs(this, &ChromeProcessController::HandleSingleTap, - aPoint, aModifiers, aGuid); - mUILoop->PostTask(runnable.forget()); + mUILoop->PostTask(NewRunnableMethod + (this, + &ChromeProcessController::HandleSingleTap, + aPoint, aModifiers, aGuid)); return; } @@ -179,13 +177,12 @@ ChromeProcessController::HandleLongTap(const mozilla::CSSPoint& aPoint, Modifier uint64_t aInputBlockId) { if (MessageLoop::current() != mUILoop) { - RefPtr runnable = - NS_NewRunnableMethodWithArgs(this, &ChromeProcessController::HandleLongTap, - aPoint, aModifiers, aGuid, aInputBlockId); - mUILoop->PostTask(runnable.forget()); + mUILoop->PostTask(NewRunnableMethod + (this, &ChromeProcessController::HandleLongTap, + aPoint, aModifiers, aGuid, aInputBlockId)); return; } @@ -199,12 +196,11 @@ ChromeProcessController::NotifyAPZStateChange(const ScrollableLayerGuid& aGuid, int aArg) { if (MessageLoop::current() != mUILoop) { - RefPtr runnable = - NS_NewRunnableMethodWithArgs(this, &ChromeProcessController::NotifyAPZStateChange, - aGuid, aChange, aArg); - mUILoop->PostTask(runnable.forget()); + mUILoop->PostTask(NewRunnableMethod + (this, &ChromeProcessController::NotifyAPZStateChange, + aGuid, aChange, aArg)); return; } @@ -215,11 +211,10 @@ void ChromeProcessController::NotifyMozMouseScrollEvent(const FrameMetrics::ViewID& aScrollId, const nsString& aEvent) { if (MessageLoop::current() != mUILoop) { - RefPtr runnable = - NS_NewRunnableMethodWithArgs(this, &ChromeProcessController::NotifyMozMouseScrollEvent, - aScrollId, aEvent); - mUILoop->PostTask(runnable.forget()); + mUILoop->PostTask(NewRunnableMethod + (this, &ChromeProcessController::NotifyMozMouseScrollEvent, + aScrollId, aEvent)); return; } diff --git a/gfx/layers/ipc/CompositorBridgeParent.cpp b/gfx/layers/ipc/CompositorBridgeParent.cpp index 684123c0a9ee..e1fa15f7b18e 100644 --- a/gfx/layers/ipc/CompositorBridgeParent.cpp +++ b/gfx/layers/ipc/CompositorBridgeParent.cpp @@ -361,7 +361,7 @@ CompositorVsyncScheduler::SetDisplay(bool aDisplayEnable) MOZ_ASSERT(NS_IsMainThread()); MonitorAutoLock lock(mSetDisplayMonitor); RefPtr task = - NS_NewCancelableRunnableMethodWithArgs(this, &CompositorVsyncScheduler::SetDisplay, aDisplayEnable); + NewCancelableRunnableMethod(this, &CompositorVsyncScheduler::SetDisplay, aDisplayEnable); mSetDisplayTask = task; ScheduleTask(task.forget(), 0); return; @@ -426,8 +426,8 @@ CompositorVsyncScheduler::PostCompositeTask(TimeStamp aCompositeTimestamp) MonitorAutoLock lock(mCurrentCompositeTaskMonitor); if (mCurrentCompositeTask == nullptr) { RefPtr task = - NS_NewCancelableRunnableMethodWithArgs(this, &CompositorVsyncScheduler::Composite, - aCompositeTimestamp); + NewCancelableRunnableMethod(this, &CompositorVsyncScheduler::Composite, + aCompositeTimestamp); mCurrentCompositeTask = task; ScheduleTask(task.forget(), 0); } @@ -480,7 +480,7 @@ CompositorVsyncScheduler::SetNeedsComposite() if (!CompositorBridgeParent::IsInCompositorThread()) { MonitorAutoLock lock(mSetNeedsCompositeMonitor); RefPtr task = - NS_NewCancelableRunnableMethod(this, &CompositorVsyncScheduler::SetNeedsComposite); + NewCancelableRunnableMethod(this, &CompositorVsyncScheduler::SetNeedsComposite); mSetNeedsCompositeTask = task; ScheduleTask(task.forget(), 0); return; @@ -980,8 +980,7 @@ CompositorBridgeParent::ActorDestroy(ActorDestroyReason why) // We must keep the compositor parent alive untill the code handling message // reception is finished on this thread. mSelfRef = this; - RefPtr runnable = NS_NewRunnableMethod(this, &CompositorBridgeParent::DeferredDestroy); - MessageLoop::current()->PostTask(runnable.forget()); + MessageLoop::current()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::DeferredDestroy)); } @@ -989,16 +988,14 @@ void CompositorBridgeParent::ScheduleRenderOnCompositorThread() { MOZ_ASSERT(CompositorLoop()); - RefPtr runnable = NS_NewRunnableMethod(this, &CompositorBridgeParent::ScheduleComposition); - CompositorLoop()->PostTask(runnable.forget()); + CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::ScheduleComposition)); } void CompositorBridgeParent::InvalidateOnCompositorThread() { MOZ_ASSERT(CompositorLoop()); - RefPtr runnable = NS_NewRunnableMethod(this, &CompositorBridgeParent::Invalidate); - CompositorLoop()->PostTask(runnable.forget()); + CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::Invalidate)); } void @@ -1089,8 +1086,7 @@ CompositorBridgeParent::SchedulePauseOnCompositorThread() MonitorAutoLock lock(mPauseCompositionMonitor); MOZ_ASSERT(CompositorLoop()); - RefPtr runnable = NS_NewRunnableMethod(this, &CompositorBridgeParent::PauseComposition); - CompositorLoop()->PostTask(runnable.forget()); + CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::PauseComposition)); // Wait until the pause has actually been processed by the compositor thread lock.Wait(); @@ -1102,8 +1098,7 @@ CompositorBridgeParent::ScheduleResumeOnCompositorThread() MonitorAutoLock lock(mResumeCompositionMonitor); MOZ_ASSERT(CompositorLoop()); - RefPtr runnable = NS_NewRunnableMethod(this, &CompositorBridgeParent::ResumeComposition); - CompositorLoop()->PostTask(runnable.forget()); + CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::ResumeComposition)); // Wait until the resume has actually been processed by the compositor thread lock.Wait(); @@ -1117,10 +1112,10 @@ CompositorBridgeParent::ScheduleResumeOnCompositorThread(int width, int height) MonitorAutoLock lock(mResumeCompositionMonitor); MOZ_ASSERT(CompositorLoop()); - RefPtr runnable = - NS_NewRunnableMethodWithArgs(this, &CompositorBridgeParent::ResumeCompositionAndResize, - width, height); - CompositorLoop()->PostTask(runnable.forget()); + CompositorLoop()->PostTask(NewRunnableMethod + (this, + &CompositorBridgeParent::ResumeCompositionAndResize, + width, height)); // Wait until the resume has actually been processed by the compositor thread lock.Wait(); @@ -1372,7 +1367,7 @@ CompositorBridgeParent::ScheduleRotationOnCompositorThread(const TargetConfig& a mForceCompositionTask->Cancel(); } RefPtr task = - NS_NewCancelableRunnableMethod(this, &CompositorBridgeParent::ForceComposition); + NewCancelableRunnableMethod(this, &CompositorBridgeParent::ForceComposition); mForceCompositionTask = task; ScheduleTask(task.forget(), gfxPrefs::OrientationSyncMillis()); } @@ -2113,13 +2108,12 @@ CompositorBridgeParent::ResetCompositor(const nsTArray& aBackendH { MonitorAutoLock lock(mResetCompositorMonitor); - RefPtr runnable = - NS_NewRunnableMethodWithArgs>, - Maybe*>(this, - &CompositorBridgeParent::ResetCompositorTask, - aBackendHints, - &newIdentifier); - CompositorLoop()->PostTask(runnable.forget()); + CompositorLoop()->PostTask(NewRunnableMethod + >, + Maybe*>(this, + &CompositorBridgeParent::ResetCompositorTask, + aBackendHints, + &newIdentifier)); mResetCompositorMonitor.Wait(); } @@ -2287,8 +2281,7 @@ CrossProcessCompositorBridgeParent::ActorDestroy(ActorDestroyReason aWhy) // We must keep this object alive untill the code handling message // reception is finished on this thread. - RefPtr runnable = NS_NewRunnableMethod(this, &CrossProcessCompositorBridgeParent::DeferredDestroy); - MessageLoop::current()->PostTask(runnable.forget()); + MessageLoop::current()->PostTask(NewRunnableMethod(this, &CrossProcessCompositorBridgeParent::DeferredDestroy)); } PLayerTransactionParent* @@ -2535,8 +2528,7 @@ void CompositorBridgeParent::ScheduleShowAllPluginWindows() { MOZ_ASSERT(CompositorLoop()); - RefPtr runnable = NS_NewRunnableMethod(this, &CompositorBridgeParent::ShowAllPluginWindows); - CompositorLoop()->PostTask(runnable.forget()); + CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::ShowAllPluginWindows)); } void @@ -2551,8 +2543,7 @@ void CompositorBridgeParent::ScheduleHideAllPluginWindows() { MOZ_ASSERT(CompositorLoop()); - RefPtr runnable = NS_NewRunnableMethod(this, &CompositorBridgeParent::HideAllPluginWindows); - CompositorLoop()->PostTask(runnable.forget()); + CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::HideAllPluginWindows)); } void diff --git a/gfx/layers/ipc/ImageBridgeParent.cpp b/gfx/layers/ipc/ImageBridgeParent.cpp index 1dff5588a843..72353dca8269 100644 --- a/gfx/layers/ipc/ImageBridgeParent.cpp +++ b/gfx/layers/ipc/ImageBridgeParent.cpp @@ -106,8 +106,7 @@ ImageBridgeParent::ActorDestroy(ActorDestroyReason aWhy) mSubprocess = nullptr; } - RefPtr runnable = NS_NewRunnableMethod(this, &ImageBridgeParent::DeferredDestroy); - MessageLoop::current()->PostTask(runnable.forget()); + MessageLoop::current()->PostTask(NewRunnableMethod(this, &ImageBridgeParent::DeferredDestroy)); // It is very important that this method gets called at shutdown (be it a clean // or an abnormal shutdown), because DeferredDestroy is what clears mSelfRef. diff --git a/gfx/layers/ipc/RemoteContentController.cpp b/gfx/layers/ipc/RemoteContentController.cpp index d86593476154..7756c6b7412d 100644 --- a/gfx/layers/ipc/RemoteContentController.cpp +++ b/gfx/layers/ipc/RemoteContentController.cpp @@ -58,12 +58,11 @@ RemoteContentController::HandleDoubleTap(const CSSPoint& aPoint, if (MessageLoop::current() != mUILoop) { // We have to send this message from the "UI thread" (main // thread). - RefPtr runnable = - NS_NewRunnableMethodWithArgs(this, &RemoteContentController::HandleDoubleTap, - aPoint, aModifiers, aGuid); - mUILoop->PostTask(runnable.forget()); + mUILoop->PostTask(NewRunnableMethod(this, + &RemoteContentController::HandleDoubleTap, + aPoint, aModifiers, aGuid)); return; } if (CanSend()) { @@ -80,12 +79,11 @@ RemoteContentController::HandleSingleTap(const CSSPoint& aPoint, if (MessageLoop::current() != mUILoop) { // We have to send this message from the "UI thread" (main // thread). - RefPtr runnable = - NS_NewRunnableMethodWithArgs(this, &RemoteContentController::HandleSingleTap, - aPoint, aModifiers, aGuid); - mUILoop->PostTask(runnable.forget()); + mUILoop->PostTask(NewRunnableMethod(this, + &RemoteContentController::HandleSingleTap, + aPoint, aModifiers, aGuid)); return; } @@ -116,13 +114,12 @@ RemoteContentController::HandleLongTap(const CSSPoint& aPoint, if (MessageLoop::current() != mUILoop) { // We have to send this message from the "UI thread" (main // thread). - RefPtr runnable = - NS_NewRunnableMethodWithArgs(this, &RemoteContentController::HandleLongTap, - aPoint, aModifiers, aGuid, aInputBlockId); - mUILoop->PostTask(runnable.forget()); + mUILoop->PostTask(NewRunnableMethod(this, + &RemoteContentController::HandleLongTap, + aPoint, aModifiers, aGuid, aInputBlockId)); return; } if (CanSend()) { @@ -160,12 +157,11 @@ RemoteContentController::NotifyAPZStateChange(const ScrollableLayerGuid& aGuid, int aArg) { if (MessageLoop::current() != mUILoop) { - RefPtr runnable = - NS_NewRunnableMethodWithArgs(this, &RemoteContentController::NotifyAPZStateChange, - aGuid, aChange, aArg); - mUILoop->PostTask(runnable.forget()); + mUILoop->PostTask(NewRunnableMethod(this, + &RemoteContentController::NotifyAPZStateChange, + aGuid, aChange, aArg)); return; } if (CanSend()) { @@ -178,11 +174,10 @@ RemoteContentController::NotifyMozMouseScrollEvent(const FrameMetrics::ViewID& a const nsString& aEvent) { if (MessageLoop::current() != mUILoop) { - RefPtr runnable = - NS_NewRunnableMethodWithArgs(this, &RemoteContentController::NotifyMozMouseScrollEvent, - aScrollId, aEvent); - mUILoop->PostTask(runnable.forget()); + mUILoop->PostTask(NewRunnableMethod(this, + &RemoteContentController::NotifyMozMouseScrollEvent, + aScrollId, aEvent)); return; } @@ -232,12 +227,10 @@ RemoteContentController::RecvContentReceivedInputBlock(const ScrollableLayerGuid return false; } if (RefPtr apzcTreeManager = GetApzcTreeManager()) { - RefPtr runnable = - NS_NewRunnableMethodWithArgs(apzcTreeManager, - &APZCTreeManager::ContentReceivedInputBlock, - aInputBlockId, aPreventDefault); - APZThreadUtils::RunOnControllerThread(runnable.forget()); + APZThreadUtils::RunOnControllerThread(NewRunnableMethod(apzcTreeManager, + &APZCTreeManager::ContentReceivedInputBlock, + aInputBlockId, aPreventDefault)); } return true; @@ -250,12 +243,11 @@ RemoteContentController::RecvStartScrollbarDrag(const AsyncDragMetrics& aDragMet ScrollableLayerGuid guid(mLayersId, aDragMetrics.mPresShellId, aDragMetrics.mViewId); - RefPtr runnable = - NS_NewRunnableMethodWithArgs(apzcTreeManager, - &APZCTreeManager::StartScrollbarDrag, - guid, aDragMetrics); - APZThreadUtils::RunOnControllerThread(runnable.forget()); + APZThreadUtils::RunOnControllerThread(NewRunnableMethod + (apzcTreeManager, + &APZCTreeManager::StartScrollbarDrag, + guid, aDragMetrics)); } return true; } @@ -275,11 +267,10 @@ RemoteContentController::RecvSetTargetAPZC(const uint64_t& aInputBlockId, // need a local var to disambiguate between the SetTargetAPZC overloads. void (APZCTreeManager::*setTargetApzcFunc)(uint64_t, const nsTArray&) = &APZCTreeManager::SetTargetAPZC; - RefPtr runnable = - NS_NewRunnableMethodWithArgs>>(apzcTreeManager, setTargetApzcFunc, - aInputBlockId, aTargets); - APZThreadUtils::RunOnControllerThread(runnable.forget()); + APZThreadUtils::RunOnControllerThread(NewRunnableMethod + >> + (apzcTreeManager, setTargetApzcFunc, aInputBlockId, aTargets)); } return true; @@ -290,12 +281,12 @@ RemoteContentController::RecvSetAllowedTouchBehavior(const uint64_t& aInputBlock nsTArray&& aFlags) { if (RefPtr apzcTreeManager = GetApzcTreeManager()) { - RefPtr runnable = - NS_NewRunnableMethodWithArgs>>(apzcTreeManager, - &APZCTreeManager::SetAllowedTouchBehavior, - aInputBlockId, Move(aFlags)); - APZThreadUtils::RunOnControllerThread(runnable.forget()); + APZThreadUtils::RunOnControllerThread(NewRunnableMethod + >> + (apzcTreeManager, + &APZCTreeManager::SetAllowedTouchBehavior, + aInputBlockId, Move(aFlags))); } return true; } diff --git a/gfx/thebes/SoftwareVsyncSource.cpp b/gfx/thebes/SoftwareVsyncSource.cpp index aa01013dc0fb..d86ff9bbd2b9 100644 --- a/gfx/thebes/SoftwareVsyncSource.cpp +++ b/gfx/thebes/SoftwareVsyncSource.cpp @@ -9,6 +9,8 @@ #include "gfxPlatform.h" #include "nsThreadUtils.h" +using namespace mozilla; + SoftwareVsyncSource::SoftwareVsyncSource() { MOZ_ASSERT(NS_IsMainThread()); @@ -45,8 +47,8 @@ SoftwareDisplay::EnableVsync() } mVsyncEnabled = true; - RefPtr runnable = NS_NewRunnableMethod(this, &SoftwareDisplay::EnableVsync); - mVsyncThread->message_loop()->PostTask(runnable.forget()); + mVsyncThread->message_loop()->PostTask( + NewRunnableMethod(this, &SoftwareDisplay::EnableVsync)); return; } @@ -64,8 +66,8 @@ SoftwareDisplay::DisableVsync() } mVsyncEnabled = false; - RefPtr runnable = NS_NewRunnableMethod(this, &SoftwareDisplay::DisableVsync); - mVsyncThread->message_loop()->PostTask(runnable.forget()); + mVsyncThread->message_loop()->PostTask( + NewRunnableMethod(this, &SoftwareDisplay::DisableVsync)); return; } @@ -129,11 +131,11 @@ SoftwareDisplay::ScheduleNextVsync(mozilla::TimeStamp aVsyncTimestamp) } mCurrentVsyncTask = - NS_NewCancelableRunnableMethodWithArgs(this, - &SoftwareDisplay::NotifyVsync, - nextVsync); + NewCancelableRunnableMethod(this, + &SoftwareDisplay::NotifyVsync, + nextVsync); - RefPtr addrefedTask = mCurrentVsyncTask; + RefPtr addrefedTask = mCurrentVsyncTask; mVsyncThread->message_loop()->PostDelayedTask( addrefedTask.forget(), delay.ToMilliseconds()); diff --git a/gfx/vr/ipc/VRManagerParent.cpp b/gfx/vr/ipc/VRManagerParent.cpp index f64119066bf8..352fe020977b 100644 --- a/gfx/vr/ipc/VRManagerParent.cpp +++ b/gfx/vr/ipc/VRManagerParent.cpp @@ -112,8 +112,7 @@ void VRManagerParent::ActorDestroy(ActorDestroyReason why) { UnregisterFromManager(); - RefPtr runnable = NS_NewRunnableMethod(this, &VRManagerParent::DeferredDestroy); - MessageLoop::current()->PostTask(runnable.forget()); + MessageLoop::current()->PostTask(NewRunnableMethod(this, &VRManagerParent::DeferredDestroy)); } mozilla::ipc::IToplevelProtocol* diff --git a/image/DecodePool.cpp b/image/DecodePool.cpp index 7aebb0d45351..6df722567317 100644 --- a/image/DecodePool.cpp +++ b/image/DecodePool.cpp @@ -173,9 +173,7 @@ public: { // Threads have to be shut down from another thread, so we'll ask the // main thread to do it for us. - nsCOMPtr runnable = - NS_NewRunnableMethod(aThisThread, &nsIThread::Shutdown); - NS_DispatchToMainThread(runnable); + NS_DispatchToMainThread(NewRunnableMethod(aThisThread, &nsIThread::Shutdown)); } /** diff --git a/image/RasterImage.cpp b/image/RasterImage.cpp index d08aaaf5ce0d..97a3e1b6144b 100644 --- a/image/RasterImage.cpp +++ b/image/RasterImage.cpp @@ -438,9 +438,7 @@ RasterImage::OnSurfaceDiscarded() { MOZ_ASSERT(mProgressTracker); - nsCOMPtr runnable = - NS_NewRunnableMethod(mProgressTracker, &ProgressTracker::OnDiscard); - NS_DispatchToMainThread(runnable); + NS_DispatchToMainThread(NewRunnableMethod(mProgressTracker, &ProgressTracker::OnDiscard)); } //****************************************************************************** diff --git a/image/VectorImage.cpp b/image/VectorImage.cpp index 3f08dd4310d4..b8d8950433c3 100644 --- a/image/VectorImage.cpp +++ b/image/VectorImage.cpp @@ -1063,9 +1063,7 @@ VectorImage::OnSurfaceDiscarded() { MOZ_ASSERT(mProgressTracker); - nsCOMPtr runnable = - NS_NewRunnableMethod(mProgressTracker, &ProgressTracker::OnDiscard); - NS_DispatchToMainThread(runnable); + NS_DispatchToMainThread(NewRunnableMethod(mProgressTracker, &ProgressTracker::OnDiscard)); } //****************************************************************************** diff --git a/image/imgRequestProxy.cpp b/image/imgRequestProxy.cpp index d8750cd563df..923d7a2ccfc2 100644 --- a/image/imgRequestProxy.cpp +++ b/image/imgRequestProxy.cpp @@ -349,9 +349,7 @@ imgRequestProxy::CancelAndForgetObserver(nsresult aStatus) mIsInLoadGroup = oldIsInLoadGroup; if (mIsInLoadGroup) { - nsCOMPtr ev = - NS_NewRunnableMethod(this, &imgRequestProxy::DoRemoveFromLoadGroup); - NS_DispatchToCurrentThread(ev); + NS_DispatchToCurrentThread(NewRunnableMethod(this, &imgRequestProxy::DoRemoveFromLoadGroup)); } NullOutListener(); diff --git a/ipc/glue/BackgroundImpl.cpp b/ipc/glue/BackgroundImpl.cpp index 3b7235613f3d..5a77e436dc61 100644 --- a/ipc/glue/BackgroundImpl.cpp +++ b/ipc/glue/BackgroundImpl.cpp @@ -433,9 +433,8 @@ private: ChildImpl* actor; threadLocalInfo->mActor.forget(&actor); - nsCOMPtr releaser = - NS_NewNonOwningRunnableMethod(actor, &ChildImpl::Release); - MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(releaser)); + MOZ_ALWAYS_SUCCEEDS( + NS_DispatchToMainThread(NewNonOwningRunnableMethod(actor, &ChildImpl::Release))); } } delete threadLocalInfo; @@ -1003,11 +1002,8 @@ ParentImpl::GetContentParent(PBackgroundParent* aBackgroundActor) // it for us. This is safe since we are guaranteed that our AddRef runnable // will run before the reference we hand out can be released, and the // ContentParent can't die as long as the existing reference is maintained. - nsCOMPtr runnable = - NS_NewNonOwningRunnableMethod(actor->mContent, &ContentParent::AddRef); - MOZ_ASSERT(runnable); - - MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(runnable)); + MOZ_ALWAYS_SUCCEEDS( + NS_DispatchToMainThread(NewNonOwningRunnableMethod(actor->mContent, &ContentParent::AddRef))); } return already_AddRefed(actor->mContent.get()); @@ -1271,11 +1267,8 @@ ParentImpl::Destroy() AssertIsInMainProcess(); - nsCOMPtr destroyRunnable = - NS_NewNonOwningRunnableMethod(this, &ParentImpl::MainThreadActorDestroy); - MOZ_ASSERT(destroyRunnable); - - MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(destroyRunnable)); + MOZ_ALWAYS_SUCCEEDS( + NS_DispatchToMainThread(NewNonOwningRunnableMethod(this, &ParentImpl::MainThreadActorDestroy))); } void @@ -1363,11 +1356,9 @@ ParentImpl::ActorDestroy(ActorDestroyReason aWhy) // IPDL is about to call MessageChannel::Clear() on this thread! To avoid // racing with the main thread we must ensure that the MessageChannel lives // long enough to be cleared in this call stack. - nsCOMPtr destroyRunnable = - NS_NewNonOwningRunnableMethod(this, &ParentImpl::Destroy); - MOZ_ASSERT(destroyRunnable); - MOZ_ALWAYS_SUCCEEDS(NS_DispatchToCurrentThread(destroyRunnable)); + MOZ_ALWAYS_SUCCEEDS( + NS_DispatchToCurrentThread(NewNonOwningRunnableMethod(this, &ParentImpl::Destroy))); } NS_IMPL_ISUPPORTS(ParentImpl::ShutdownObserver, nsIObserver) diff --git a/ipc/glue/GeckoChildProcessHost.cpp b/ipc/glue/GeckoChildProcessHost.cpp index d1777f878b7c..0a2296c41d6a 100644 --- a/ipc/glue/GeckoChildProcessHost.cpp +++ b/ipc/glue/GeckoChildProcessHost.cpp @@ -344,12 +344,10 @@ GeckoChildProcessHost::SyncLaunch(std::vector aExtraOpts, int aTime MessageLoop* ioLoop = XRE_GetIOMessageLoop(); NS_ASSERTION(MessageLoop::current() != ioLoop, "sync launch from the IO thread NYI"); - RefPtr runnable = - NS_NewNonOwningRunnableMethodWithArgs, - base::ProcessArchitecture>(this, - &GeckoChildProcessHost::RunPerformAsyncLaunch, - aExtraOpts, arch); - ioLoop->PostTask(runnable.forget()); + ioLoop->PostTask(NewNonOwningRunnableMethod + , base::ProcessArchitecture> + (this, &GeckoChildProcessHost::RunPerformAsyncLaunch, + aExtraOpts, arch)); return WaitUntilConnected(aTimeoutMs); } @@ -362,12 +360,10 @@ GeckoChildProcessHost::AsyncLaunch(std::vector aExtraOpts, MessageLoop* ioLoop = XRE_GetIOMessageLoop(); - RefPtr runnable = - NS_NewNonOwningRunnableMethodWithArgs, - base::ProcessArchitecture>(this, - &GeckoChildProcessHost::RunPerformAsyncLaunch, - aExtraOpts, arch); - ioLoop->PostTask(runnable.forget()); + ioLoop->PostTask(NewNonOwningRunnableMethod + , base::ProcessArchitecture> + (this, &GeckoChildProcessHost::RunPerformAsyncLaunch, + aExtraOpts, arch)); // This may look like the sync launch wait, but we only delay as // long as it takes to create the channel. @@ -423,13 +419,10 @@ GeckoChildProcessHost::LaunchAndWaitForProcessHandle(StringVector aExtraOpts) PrepareLaunch(); MessageLoop* ioLoop = XRE_GetIOMessageLoop(); - RefPtr runnable = - NS_NewNonOwningRunnableMethodWithArgs, - base::ProcessArchitecture>(this, - &GeckoChildProcessHost::RunPerformAsyncLaunch, - aExtraOpts, - base::GetCurrentProcessArchitecture()); - ioLoop->PostTask(runnable.forget()); + ioLoop->PostTask(NewNonOwningRunnableMethod + , base::ProcessArchitecture> + (this, &GeckoChildProcessHost::RunPerformAsyncLaunch, + aExtraOpts, base::GetCurrentProcessArchitecture())); MonitorAutoLock lock(mMonitor); while (mProcessState < PROCESS_CREATED) { diff --git a/ipc/glue/MessageChannel.cpp b/ipc/glue/MessageChannel.cpp index 63e64d0ebba5..d3f361eccec4 100644 --- a/ipc/glue/MessageChannel.cpp +++ b/ipc/glue/MessageChannel.cpp @@ -496,11 +496,10 @@ MessageChannel::MessageChannel(MessageListener *aListener) #endif RefPtr runnable = - NS_NewNonOwningCancelableRunnableMethod(this, &MessageChannel::OnMaybeDequeueOne); + NewNonOwningCancelableRunnableMethod(this, &MessageChannel::OnMaybeDequeueOne); mDequeueOneTask = new RefCountedTask(runnable.forget()); - runnable = NS_NewNonOwningCancelableRunnableMethod(this, &MessageChannel::DispatchOnChannelConnected); - + runnable = NewNonOwningCancelableRunnableMethod(this, &MessageChannel::DispatchOnChannelConnected); mOnChannelConnectedTask = new RefCountedTask(runnable.forget()); #ifdef OS_WIN @@ -693,11 +692,10 @@ MessageChannel::Open(MessageChannel *aTargetChan, MessageLoop *aTargetLoop, Side MonitorAutoLock lock(*mMonitor); mChannelState = ChannelOpening; - RefPtr runnable = - NS_NewNonOwningRunnableMethodWithArgs(aTargetChan, - &MessageChannel::OnOpenAsSlave, - this, oppSide); - aTargetLoop->PostTask(runnable.forget()); + aTargetLoop->PostTask(NewNonOwningRunnableMethod + (aTargetChan, + &MessageChannel::OnOpenAsSlave, + this, oppSide)); while (ChannelOpening == mChannelState) mMonitor->Wait(); @@ -2097,7 +2095,7 @@ MessageChannel::OnNotifyMaybeChannelError() if (IsOnCxxStack()) { mChannelErrorTask = - NS_NewNonOwningCancelableRunnableMethod(this, &MessageChannel::OnNotifyMaybeChannelError); + NewNonOwningCancelableRunnableMethod(this, &MessageChannel::OnNotifyMaybeChannelError); RefPtr task = mChannelErrorTask; // 10 ms delay is completely arbitrary mWorkerLoop->PostDelayedTask(task.forget(), 10); @@ -2117,7 +2115,7 @@ MessageChannel::PostErrorNotifyTask() // This must be the last code that runs on this thread! mChannelErrorTask = - NS_NewNonOwningCancelableRunnableMethod(this, &MessageChannel::OnNotifyMaybeChannelError); + NewNonOwningCancelableRunnableMethod(this, &MessageChannel::OnNotifyMaybeChannelError); RefPtr task = mChannelErrorTask; mWorkerLoop->PostTask(task.forget()); } diff --git a/ipc/glue/MessageLink.cpp b/ipc/glue/MessageLink.cpp index c3b20b347a97..1dc56687c912 100644 --- a/ipc/glue/MessageLink.cpp +++ b/ipc/glue/MessageLink.cpp @@ -118,14 +118,12 @@ ProcessLink::Open(mozilla::ipc::Transport* aTransport, MessageLoop *aIOLoop, Sid // Transport::Connect() has not been called. Call it so // we start polling our pipe and processing outgoing // messages. - RefPtr runnable = NS_NewNonOwningRunnableMethod(this, &ProcessLink::OnChannelOpened); - mIOLoop->PostTask(runnable.forget()); + mIOLoop->PostTask(NewNonOwningRunnableMethod(this, &ProcessLink::OnChannelOpened)); } else { // Transport::Connect() has already been called. Take // over the channel from the previous listener and process // any queued messages. - RefPtr runnable = NS_NewNonOwningRunnableMethod(this, &ProcessLink::OnTakeConnectedChannel); - mIOLoop->PostTask(runnable.forget()); + mIOLoop->PostTask(NewNonOwningRunnableMethod(this, &ProcessLink::OnTakeConnectedChannel)); } #ifdef MOZ_NUWA_PROCESS @@ -152,9 +150,7 @@ ProcessLink::EchoMessage(Message *msg) mChan->AssertWorkerThread(); mChan->mMonitor->AssertCurrentThreadOwns(); - RefPtr runnable = - NS_NewNonOwningRunnableMethodWithArgs(this, &ProcessLink::OnEchoMessage, msg); - mIOLoop->PostTask(runnable.forget()); + mIOLoop->PostTask(NewNonOwningRunnableMethod(this, &ProcessLink::OnEchoMessage, msg)); // OnEchoMessage takes ownership of |msg| } @@ -200,9 +196,7 @@ ProcessLink::SendMessage(Message *msg) #endif #endif - RefPtr runnable = - NS_NewNonOwningRunnableMethodWithArgs(mTransport, &Transport::Send, msg); - mIOLoop->PostTask(runnable.forget()); + mIOLoop->PostTask(NewNonOwningRunnableMethod(mTransport, &Transport::Send, msg)); } void @@ -211,8 +205,7 @@ ProcessLink::SendClose() mChan->AssertWorkerThread(); mChan->mMonitor->AssertCurrentThreadOwns(); - RefPtr runnable = NS_NewNonOwningRunnableMethod(this, &ProcessLink::OnCloseChannel); - mIOLoop->PostTask(runnable.forget()); + mIOLoop->PostTask(NewNonOwningRunnableMethod(this, &ProcessLink::OnCloseChannel)); } ThreadLink::ThreadLink(MessageChannel *aChan, MessageChannel *aTargetChan) diff --git a/layout/base/ZoomConstraintsClient.cpp b/layout/base/ZoomConstraintsClient.cpp index ef1db18081ce..c76f971c39ac 100644 --- a/layout/base/ZoomConstraintsClient.cpp +++ b/layout/base/ZoomConstraintsClient.cpp @@ -152,7 +152,7 @@ ZoomConstraintsClient::Observe(nsISupports* aSubject, const char* aTopic, const // We need to run this later because all the pref change listeners need // to execute before we can be guaranteed that gfxPrefs::ForceUserScalable() // returns the updated value. - NS_DispatchToMainThread(NS_NewRunnableMethod( + NS_DispatchToMainThread(NewRunnableMethod( this, &ZoomConstraintsClient::RefreshZoomConstraints)); } return NS_OK; diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index f11c4dda2490..0a8ac6cfae54 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -1590,7 +1590,7 @@ nsPresContext::ThemeChanged() sThemeChanged = true; nsCOMPtr ev = - NS_NewRunnableMethod(this, &nsPresContext::ThemeChangedInternal); + NewRunnableMethod(this, &nsPresContext::ThemeChangedInternal); if (NS_SUCCEEDED(NS_DispatchToCurrentThread(ev))) { mPendingThemeChanged = true; } @@ -1649,7 +1649,7 @@ nsPresContext::SysColorChanged() if (!mPendingSysColorChanged) { sLookAndFeelChanged = true; nsCOMPtr ev = - NS_NewRunnableMethod(this, &nsPresContext::SysColorChangedInternal); + NewRunnableMethod(this, &nsPresContext::SysColorChangedInternal); if (NS_SUCCEEDED(NS_DispatchToCurrentThread(ev))) { mPendingSysColorChanged = true; } @@ -1681,7 +1681,7 @@ nsPresContext::UIResolutionChanged() { if (!mPendingUIResolutionChanged) { nsCOMPtr ev = - NS_NewRunnableMethod(this, &nsPresContext::UIResolutionChangedInternal); + NewRunnableMethod(this, &nsPresContext::UIResolutionChangedInternal); if (NS_SUCCEEDED(NS_DispatchToCurrentThread(ev))) { mPendingUIResolutionChanged = true; } @@ -1932,7 +1932,7 @@ nsPresContext::PostMediaFeatureValuesChangedEvent() // need to track whether it's been added). if (!mPendingMediaFeatureValuesChanged) { nsCOMPtr ev = - NS_NewRunnableMethod(this, &nsPresContext::HandleMediaFeatureValuesChangedEvent); + NewRunnableMethod(this, &nsPresContext::HandleMediaFeatureValuesChangedEvent); if (NS_SUCCEEDED(NS_DispatchToCurrentThread(ev))) { mPendingMediaFeatureValuesChanged = true; mDocument->SetNeedStyleFlush(); @@ -2123,7 +2123,7 @@ nsPresContext::RebuildCounterStyles() mDocument->SetNeedStyleFlush(); if (!mPostedFlushCounterStyles) { nsCOMPtr ev = - NS_NewRunnableMethod(this, &nsPresContext::HandleRebuildCounterStyles); + NewRunnableMethod(this, &nsPresContext::HandleRebuildCounterStyles); if (NS_SUCCEEDED(NS_DispatchToCurrentThread(ev))) { mPostedFlushCounterStyles = true; } diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 8d1b3ee317b4..49227e0d4107 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -1910,7 +1910,7 @@ PresShell::ResizeReflowIgnoreOverride(nscoord aWidth, nscoord aHeight) } } else { RefPtr > resizeEvent = - NS_NewRunnableMethod(this, &PresShell::FireResizeEvent); + NewRunnableMethod(this, &PresShell::FireResizeEvent); if (NS_SUCCEEDED(NS_DispatchToCurrentThread(resizeEvent))) { mResizeEvent = resizeEvent; mDocument->SetNeedStyleFlush(); @@ -6091,7 +6091,7 @@ PresShell::ScheduleApproximateFrameVisibilityUpdateNow() } RefPtr > ev = - NS_NewRunnableMethod(this, &PresShell::UpdateApproximateFrameVisibility); + NewRunnableMethod(this, &PresShell::UpdateApproximateFrameVisibility); if (NS_SUCCEEDED(NS_DispatchToCurrentThread(ev))) { mUpdateApproximateFrameVisibilityEvent = ev; } @@ -6374,7 +6374,7 @@ PresShell::Paint(nsView* aViewToPaint, // since this is happening during a paint and updating the visible // regions triggers a recomposite. RefPtr> event = - NS_NewRunnableMethod(this, &PresShell::NotifyCompositorOfVisibleRegionsChange); + NewRunnableMethod(this, &PresShell::NotifyCompositorOfVisibleRegionsChange); if (NS_SUCCEEDED(NS_DispatchToMainThread(event))) { mNotifyCompositorOfVisibleRegionsChangeEvent = event; } diff --git a/layout/base/nsRefreshDriver.cpp b/layout/base/nsRefreshDriver.cpp index 91fd04b13686..a070f4c92f07 100644 --- a/layout/base/nsRefreshDriver.cpp +++ b/layout/base/nsRefreshDriver.cpp @@ -417,9 +417,9 @@ private: } nsCOMPtr vsyncEvent = - NS_NewRunnableMethodWithArg(this, - &RefreshDriverVsyncObserver::TickRefreshDriver, - aVsyncTimestamp); + NewRunnableMethod(this, + &RefreshDriverVsyncObserver::TickRefreshDriver, + aVsyncTimestamp); NS_DispatchToMainThread(vsyncEvent); } else { TickRefreshDriver(aVsyncTimestamp); @@ -1975,7 +1975,7 @@ nsRefreshDriver::Thaw() // updates our mMostRecentRefresh, but the DoRefresh call won't run // and notify our observers until we get back to the event loop. // Thus MostRecentRefresh() will lie between now and the DoRefresh. - NS_DispatchToCurrentThread(NS_NewRunnableMethod(this, &nsRefreshDriver::DoRefresh)); + NS_DispatchToCurrentThread(NewRunnableMethod(this, &nsRefreshDriver::DoRefresh)); EnsureTimerStarted(); } } diff --git a/layout/ipc/VsyncParent.cpp b/layout/ipc/VsyncParent.cpp index 9fdb8511d610..6de114f60357 100644 --- a/layout/ipc/VsyncParent.cpp +++ b/layout/ipc/VsyncParent.cpp @@ -50,9 +50,9 @@ VsyncParent::NotifyVsync(TimeStamp aTimeStamp) // Called on hardware vsync thread. We should post to current ipc thread. MOZ_ASSERT(!IsOnBackgroundThread()); nsCOMPtr vsyncEvent = - NS_NewRunnableMethodWithArg(this, - &VsyncParent::DispatchVsyncEvent, - aTimeStamp); + NewRunnableMethod(this, + &VsyncParent::DispatchVsyncEvent, + aTimeStamp); MOZ_ALWAYS_SUCCEEDS(mBackgroundThread->Dispatch(vsyncEvent, NS_DISPATCH_NORMAL)); return true; } diff --git a/layout/style/FontFaceSet.cpp b/layout/style/FontFaceSet.cpp index 942f9648f7c3..bf4ad3b24442 100644 --- a/layout/style/FontFaceSet.cpp +++ b/layout/style/FontFaceSet.cpp @@ -1471,7 +1471,7 @@ FontFaceSet::OnFontFaceStatusChanged(FontFace* aFontFace) if (!mDelayedLoadCheck) { mDelayedLoadCheck = true; nsCOMPtr checkTask = - NS_NewRunnableMethod(this, &FontFaceSet::CheckLoadingFinishedAfterDelay); + NewRunnableMethod(this, &FontFaceSet::CheckLoadingFinishedAfterDelay); NS_DispatchToMainThread(checkTask); } } diff --git a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp index c262fab71407..618858ae46ea 100644 --- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp +++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp @@ -192,7 +192,7 @@ public: ++mLength; // Atomic nsCOMPtr runnable = - NS_NewRunnableMethodWithArgs, bool>( + NewRunnableMethod, bool>( this, &VideoFrameConverter::ProcessVideoFrame, aChunk.mFrame.GetImage(), forceBlack); mTaskQueue->Dispatch(runnable.forget()); diff --git a/modules/libjar/nsJARChannel.cpp b/modules/libjar/nsJARChannel.cpp index bdc1c7f32584..34cb1fc140db 100644 --- a/modules/libjar/nsJARChannel.cpp +++ b/modules/libjar/nsJARChannel.cpp @@ -1204,11 +1204,10 @@ nsJARChannel::OnDataAvailable(nsIRequest *req, nsISupports *ctx, if (NS_IsMainThread()) { FireOnProgress(offset + count); } else { - nsCOMPtr runnable = - NS_NewRunnableMethodWithArg(this, - &nsJARChannel::FireOnProgress, - offset + count); - NS_DispatchToMainThread(runnable); + NS_DispatchToMainThread(NewRunnableMethod + (this, + &nsJARChannel::FireOnProgress, + offset + count)); } } diff --git a/netwerk/base/BackgroundFileSaver.cpp b/netwerk/base/BackgroundFileSaver.cpp index 6c5745e3c354..c6690661c6d9 100644 --- a/netwerk/base/BackgroundFileSaver.cpp +++ b/netwerk/base/BackgroundFileSaver.cpp @@ -327,11 +327,9 @@ BackgroundFileSaver::GetWorkerThreadAttention(bool aShouldInterruptCopy) if (!mAsyncCopyContext) { // Copy is not in progress, post an event to handle the change manually. - nsCOMPtr event = - NS_NewRunnableMethod(this, &BackgroundFileSaver::ProcessAttention); - NS_ENSURE_TRUE(event, NS_ERROR_FAILURE); - - rv = mWorkerThread->Dispatch(event, NS_DISPATCH_NORMAL); + rv = mWorkerThread->Dispatch(NewRunnableMethod(this, + &BackgroundFileSaver::ProcessAttention), + NS_DISPATCH_NORMAL); NS_ENSURE_SUCCESS(rv, rv); } else if (aShouldInterruptCopy) { // Interrupt the copy. The copy will be resumed, if needed, by the @@ -749,10 +747,9 @@ BackgroundFileSaver::CheckCompletion() } // Post an event to notify that the operation completed. - nsCOMPtr event = - NS_NewRunnableMethod(this, &BackgroundFileSaver::NotifySaveComplete); - if (!event || - NS_FAILED(mControlThread->Dispatch(event, NS_DISPATCH_NORMAL))) { + if (NS_FAILED(mControlThread->Dispatch(NewRunnableMethod(this, + &BackgroundFileSaver::NotifySaveComplete), + NS_DISPATCH_NORMAL))) { NS_WARNING("Unable to post completion event to the control thread."); } @@ -1156,10 +1153,9 @@ BackgroundFileSaverStreamListener::AsyncCopyProgressCallback(void *aClosure, self->mReceivedTooMuchData = false; // Post an event to verify if the request should be resumed. - nsCOMPtr event = NS_NewRunnableMethod(self, - &BackgroundFileSaverStreamListener::NotifySuspendOrResume); - if (!event || NS_FAILED(self->mControlThread->Dispatch(event, - NS_DISPATCH_NORMAL))) { + if (NS_FAILED(self->mControlThread->Dispatch(NewRunnableMethod(self, + &BackgroundFileSaverStreamListener::NotifySuspendOrResume), + NS_DISPATCH_NORMAL))) { NS_WARNING("Unable to post resume event to the control thread."); } } diff --git a/netwerk/base/Dashboard.cpp b/netwerk/base/Dashboard.cpp index 398758aef326..9fbc7b44a6e9 100644 --- a/netwerk/base/Dashboard.cpp +++ b/netwerk/base/Dashboard.cpp @@ -175,10 +175,9 @@ ConnectionData::OnTransportStatus(nsITransport *aTransport, nsresult aStatus, } GetErrorString(aStatus, mStatus); - nsCOMPtr event = - NS_NewRunnableMethodWithArg > - (mDashboard, &Dashboard::GetConnectionStatus, this); - mThread->Dispatch(event, NS_DISPATCH_NORMAL); + mThread->Dispatch(NewRunnableMethod> + (mDashboard, &Dashboard::GetConnectionStatus, this), + NS_DISPATCH_NORMAL); return NS_OK; } @@ -197,10 +196,9 @@ ConnectionData::Notify(nsITimer *aTimer) mTimer = nullptr; mStatus.AssignLiteral(MOZ_UTF16("NS_ERROR_NET_TIMEOUT")); - nsCOMPtr event = - NS_NewRunnableMethodWithArg > - (mDashboard, &Dashboard::GetConnectionStatus, this); - mThread->Dispatch(event, NS_DISPATCH_NORMAL); + mThread->Dispatch(NewRunnableMethod> + (mDashboard, &Dashboard::GetConnectionStatus, this), + NS_DISPATCH_NORMAL); return NS_OK; } @@ -287,10 +285,9 @@ LookupHelper::OnLookupComplete(nsICancelable *aRequest, mStatus = aStatus; RefPtr arg = new LookupArgument(aRecord, this); - nsCOMPtr event = - NS_NewRunnableMethodWithArg >( - this, &LookupHelper::ConstructAnswer, arg); - mThread->Dispatch(event, NS_DISPATCH_NORMAL); + mThread->Dispatch(NewRunnableMethod> + (this, &LookupHelper::ConstructAnswer, arg), + NS_DISPATCH_NORMAL); return NS_OK; } @@ -354,10 +351,9 @@ Dashboard::RequestSockets(NetDashboardCallback *aCallback) socketData->mCallback = new nsMainThreadPtrHolder(aCallback, true); socketData->mThread = NS_GetCurrentThread(); - nsCOMPtr event = - NS_NewRunnableMethodWithArg > - (this, &Dashboard::GetSocketsDispatch, socketData); - gSocketTransportService->Dispatch(event, NS_DISPATCH_NORMAL); + gSocketTransportService->Dispatch(NewRunnableMethod> + (this, &Dashboard::GetSocketsDispatch, socketData), + NS_DISPATCH_NORMAL); return NS_OK; } @@ -370,10 +366,9 @@ Dashboard::GetSocketsDispatch(SocketData *aSocketData) socketData->mTotalSent = gSocketTransportService->GetSentBytes(); socketData->mTotalRecv = gSocketTransportService->GetReceivedBytes(); } - nsCOMPtr event = - NS_NewRunnableMethodWithArg > - (this, &Dashboard::GetSockets, socketData); - socketData->mThread->Dispatch(event, NS_DISPATCH_NORMAL); + socketData->mThread->Dispatch(NewRunnableMethod> + (this, &Dashboard::GetSockets, socketData), + NS_DISPATCH_NORMAL); return NS_OK; } @@ -426,10 +421,9 @@ Dashboard::RequestHttpConnections(NetDashboardCallback *aCallback) new nsMainThreadPtrHolder(aCallback, true); httpData->mThread = NS_GetCurrentThread(); - nsCOMPtr event = - NS_NewRunnableMethodWithArg > - (this, &Dashboard::GetHttpDispatch, httpData); - gSocketTransportService->Dispatch(event, NS_DISPATCH_NORMAL); + gSocketTransportService->Dispatch(NewRunnableMethod> + (this, &Dashboard::GetHttpDispatch, httpData), + NS_DISPATCH_NORMAL); return NS_OK; } @@ -438,10 +432,9 @@ Dashboard::GetHttpDispatch(HttpData *aHttpData) { RefPtr httpData = aHttpData; HttpInfo::GetHttpConnectionData(&httpData->mData); - nsCOMPtr event = - NS_NewRunnableMethodWithArg > - (this, &Dashboard::GetHttpConnections, httpData); - httpData->mThread->Dispatch(event, NS_DISPATCH_NORMAL); + httpData->mThread->Dispatch(NewRunnableMethod> + (this, &Dashboard::GetHttpConnections, httpData), + NS_DISPATCH_NORMAL); return NS_OK; } @@ -604,10 +597,9 @@ Dashboard::RequestWebsocketConnections(NetDashboardCallback *aCallback) new nsMainThreadPtrHolder(aCallback, true); wsRequest->mThread = NS_GetCurrentThread(); - nsCOMPtr event = - NS_NewRunnableMethodWithArg > - (this, &Dashboard::GetWebSocketConnections, wsRequest); - wsRequest->mThread->Dispatch(event, NS_DISPATCH_NORMAL); + wsRequest->mThread->Dispatch(NewRunnableMethod> + (this, &Dashboard::GetWebSocketConnections, wsRequest), + NS_DISPATCH_NORMAL); return NS_OK; } @@ -666,10 +658,9 @@ Dashboard::RequestDNSInfo(NetDashboardCallback *aCallback) } } - nsCOMPtr event = - NS_NewRunnableMethodWithArg > - (this, &Dashboard::GetDnsInfoDispatch, dnsData); - gSocketTransportService->Dispatch(event, NS_DISPATCH_NORMAL); + gSocketTransportService->Dispatch(NewRunnableMethod> + (this, &Dashboard::GetDnsInfoDispatch, dnsData), + NS_DISPATCH_NORMAL); return NS_OK; } @@ -680,10 +671,9 @@ Dashboard::GetDnsInfoDispatch(DnsData *aDnsData) if (mDnsService) { mDnsService->GetDNSCacheEntries(&dnsData->mData); } - nsCOMPtr event = - NS_NewRunnableMethodWithArg > - (this, &Dashboard::GetDNSCacheEntries, dnsData); - dnsData->mThread->Dispatch(event, NS_DISPATCH_NORMAL); + dnsData->mThread->Dispatch(NewRunnableMethod> + (this, &Dashboard::GetDNSCacheEntries, dnsData), + NS_DISPATCH_NORMAL); return NS_OK; } @@ -810,10 +800,9 @@ Dashboard::RequestConnection(const nsACString& aHost, uint32_t aPort, rv = TestNewConnection(connectionData); if (NS_FAILED(rv)) { mozilla::net::GetErrorString(rv, connectionData->mStatus); - nsCOMPtr event = - NS_NewRunnableMethodWithArg > - (this, &Dashboard::GetConnectionStatus, connectionData); - connectionData->mThread->Dispatch(event, NS_DISPATCH_NORMAL); + connectionData->mThread->Dispatch(NewRunnableMethod> + (this, &Dashboard::GetConnectionStatus, connectionData), + NS_DISPATCH_NORMAL); return rv; } diff --git a/netwerk/base/OfflineObserver.cpp b/netwerk/base/OfflineObserver.cpp index 1cdc838ea758..286173e98e12 100644 --- a/netwerk/base/OfflineObserver.cpp +++ b/netwerk/base/OfflineObserver.cpp @@ -21,9 +21,8 @@ OfflineObserver::RegisterOfflineObserver() if (NS_IsMainThread()) { RegisterOfflineObserverMainThread(); } else { - nsCOMPtr event = - NS_NewRunnableMethod(this, &OfflineObserver::RegisterOfflineObserverMainThread); - NS_DispatchToMainThread(event); + NS_DispatchToMainThread(NewRunnableMethod(this, + &OfflineObserver::RegisterOfflineObserverMainThread)); } } @@ -33,9 +32,8 @@ OfflineObserver::RemoveOfflineObserver() if (NS_IsMainThread()) { RemoveOfflineObserverMainThread(); } else { - nsCOMPtr event = - NS_NewRunnableMethod(this, &OfflineObserver::RemoveOfflineObserverMainThread); - NS_DispatchToMainThread(event); + NS_DispatchToMainThread(NewRunnableMethod(this, + &OfflineObserver::RemoveOfflineObserverMainThread)); } } diff --git a/netwerk/base/Tickler.cpp b/netwerk/base/Tickler.cpp index 5d42440dcaef..a705104ba3cf 100644 --- a/netwerk/base/Tickler.cpp +++ b/netwerk/base/Tickler.cpp @@ -130,7 +130,7 @@ void Tickler::Tickle() void Tickler::PostCheckTickler() { mLock.AssertCurrentThreadOwns(); - mThread->Dispatch(NS_NewRunnableMethod(this, &Tickler::CheckTickler), + mThread->Dispatch(NewRunnableMethod(this, &Tickler::CheckTickler), NS_DISPATCH_NORMAL); return; } @@ -146,7 +146,7 @@ void Tickler::MaybeStartTickler() mLock.AssertCurrentThreadOwns(); if (!NS_IsMainThread()) { NS_DispatchToMainThread( - NS_NewRunnableMethod(this, &Tickler::MaybeStartTicklerUnlocked)); + NewRunnableMethod(this, &Tickler::MaybeStartTicklerUnlocked)); return; } diff --git a/netwerk/base/nsAsyncStreamCopier.cpp b/netwerk/base/nsAsyncStreamCopier.cpp index 331dcc65a9e0..0a1473a9fe5e 100644 --- a/netwerk/base/nsAsyncStreamCopier.cpp +++ b/netwerk/base/nsAsyncStreamCopier.cpp @@ -44,8 +44,9 @@ public: return NS_OK; } - nsCOMPtr event = NS_NewRunnableMethod(mCopier, &nsAsyncStreamCopier::AsyncCopyInternal); - rv = mTarget->Dispatch(event, NS_DISPATCH_NORMAL); + rv = mTarget->Dispatch(NewRunnableMethod(mCopier, + &nsAsyncStreamCopier::AsyncCopyInternal), + NS_DISPATCH_NORMAL); MOZ_ASSERT(NS_SUCCEEDED(rv)); if (NS_FAILED(rv)) { diff --git a/netwerk/base/nsInputStreamPump.cpp b/netwerk/base/nsInputStreamPump.cpp index 1096c10f012d..998961c1e74f 100644 --- a/netwerk/base/nsInputStreamPump.cpp +++ b/netwerk/base/nsInputStreamPump.cpp @@ -679,7 +679,7 @@ nsInputStreamPump::OnStateStop() MOZ_ASSERT(NS_IsMainThread(), "OnStateStop should only be called on the main thread."); nsresult rv = NS_DispatchToMainThread( - NS_NewRunnableMethod(this, &nsInputStreamPump::CallOnStateStop)); + NewRunnableMethod(this, &nsInputStreamPump::CallOnStateStop)); NS_ENSURE_SUCCESS(rv, STATE_IDLE); return STATE_IDLE; } diff --git a/netwerk/base/nsPACMan.cpp b/netwerk/base/nsPACMan.cpp index 169c3b51fad8..c52854cf5bd4 100644 --- a/netwerk/base/nsPACMan.cpp +++ b/netwerk/base/nsPACMan.cpp @@ -415,10 +415,8 @@ nsPACMan::LoadPACFromURI(const nsCString &spec) // queries the enter between now and when we actually load the PAC file. if (!mLoadPending) { - nsCOMPtr event = - NS_NewRunnableMethod(this, &nsPACMan::StartLoading); nsresult rv; - if (NS_FAILED(rv = NS_DispatchToCurrentThread(event))) + if (NS_FAILED(rv = NS_DispatchToCurrentThread(NewRunnableMethod(this, &nsPACMan::StartLoading)))) return rv; mLoadPending = true; } @@ -784,9 +782,9 @@ nsPACMan::Init(nsISystemProxySettings *systemProxySettings) if (NS_FAILED(rv)) return rv; - nsCOMPtr event = NS_NewRunnableMethod(this, &nsPACMan::NamePACThread); // don't check return value as it is not a big deal for this to fail. - mPACThread->Dispatch(event, nsIEventTarget::DISPATCH_NORMAL); + mPACThread->Dispatch(NewRunnableMethod(this, &nsPACMan::NamePACThread), + nsIEventTarget::DISPATCH_NORMAL); return NS_OK; } diff --git a/netwerk/base/nsServerSocket.cpp b/netwerk/base/nsServerSocket.cpp index 3822448263e1..a074bc7e0ec7 100644 --- a/netwerk/base/nsServerSocket.cpp +++ b/netwerk/base/nsServerSocket.cpp @@ -30,10 +30,7 @@ typedef void (nsServerSocket:: *nsServerSocketFunc)(void); static nsresult PostEvent(nsServerSocket *s, nsServerSocketFunc func) { - nsCOMPtr ev = NS_NewRunnableMethod(s, func); - if (!ev) - return NS_ERROR_OUT_OF_MEMORY; - + nsCOMPtr ev = NewRunnableMethod(s, func); if (!gSocketTransportService) return NS_ERROR_FAILURE; @@ -129,7 +126,7 @@ nsServerSocket::TryAttach() if (!gSocketTransportService->CanAttachSocket()) { nsCOMPtr event = - NS_NewRunnableMethod(this, &nsServerSocket::OnMsgAttach); + NewRunnableMethod(this, &nsServerSocket::OnMsgAttach); if (!event) return NS_ERROR_OUT_OF_MEMORY; diff --git a/netwerk/base/nsSocketTransportService2.cpp b/netwerk/base/nsSocketTransportService2.cpp index 08f3ffe03b5d..1544fd441bb8 100644 --- a/netwerk/base/nsSocketTransportService2.cpp +++ b/netwerk/base/nsSocketTransportService2.cpp @@ -919,7 +919,7 @@ nsSocketTransportService::Run() mRawThread->HasPendingEvents(&pendingEvents); if (pendingEvents) { if (!mServingPendingQueue) { - nsresult rv = Dispatch(NS_NewRunnableMethod(this, + nsresult rv = Dispatch(NewRunnableMethod(this, &nsSocketTransportService::MarkTheLastElementOfPendingQueue), nsIEventTarget::DISPATCH_NORMAL); if (NS_FAILED(rv)) { @@ -1261,7 +1261,7 @@ nsSocketTransportService::OnKeepaliveEnabledPrefChange() // Dispatch to socket thread if we're not executing there. if (PR_GetCurrentThread() != gSocketThread) { gSocketTransportService->Dispatch( - NS_NewRunnableMethod( + NewRunnableMethod( this, &nsSocketTransportService::OnKeepaliveEnabledPrefChange), NS_DISPATCH_NORMAL); return; @@ -1313,8 +1313,8 @@ nsSocketTransportService::Observe(nsISupports *subject, if (!strcmp(topic, "last-pb-context-exited")) { nsCOMPtr ev = - NS_NewRunnableMethod(this, - &nsSocketTransportService::ClosePrivateConnections); + NewRunnableMethod(this, + &nsSocketTransportService::ClosePrivateConnections); nsresult rv = Dispatch(ev, nsIEventTarget::DISPATCH_NORMAL); NS_ENSURE_SUCCESS(rv, rv); } diff --git a/netwerk/base/nsUDPSocket.cpp b/netwerk/base/nsUDPSocket.cpp index 26e3d10f900f..1002d28ddf34 100644 --- a/netwerk/base/nsUDPSocket.cpp +++ b/netwerk/base/nsUDPSocket.cpp @@ -48,12 +48,10 @@ typedef void (nsUDPSocket:: *nsUDPSocketFunc)(void); static nsresult PostEvent(nsUDPSocket *s, nsUDPSocketFunc func) { - nsCOMPtr ev = NS_NewRunnableMethod(s, func); - if (!gSocketTransportService) return NS_ERROR_FAILURE; - return gSocketTransportService->Dispatch(ev, NS_DISPATCH_NORMAL); + return gSocketTransportService->Dispatch(NewRunnableMethod(s, func), NS_DISPATCH_NORMAL); } static nsresult @@ -347,7 +345,7 @@ nsUDPSocket::TryAttach() if (!gSocketTransportService->CanAttachSocket()) { nsCOMPtr event = - NS_NewRunnableMethod(this, &nsUDPSocket::OnMsgAttach); + NewRunnableMethod(this, &nsUDPSocket::OnMsgAttach); nsresult rv = gSocketTransportService->NotifyWhenCanAttachSocket(event); if (NS_FAILED(rv)) diff --git a/netwerk/cache/nsCacheService.cpp b/netwerk/cache/nsCacheService.cpp index c1a27baed12c..70cd4bd9e306 100644 --- a/netwerk/cache/nsCacheService.cpp +++ b/netwerk/cache/nsCacheService.cpp @@ -1525,8 +1525,8 @@ nsresult nsCacheService::EvictEntriesInternal(nsCacheStoragePolicy storagePolicy if (storagePolicy == nsICache::STORE_ANYWHERE) { // if not called on main thread, dispatch the notification to the main thread to notify observers if (!NS_IsMainThread()) { - nsCOMPtr event = NS_NewRunnableMethod(this, - &nsCacheService::FireClearNetworkCacheStoredAnywhereNotification); + nsCOMPtr event = NewRunnableMethod(this, + &nsCacheService::FireClearNetworkCacheStoredAnywhereNotification); NS_DispatchToMainThread(event); } else { // else you're already on main thread - notify observers diff --git a/netwerk/cache2/CacheEntry.cpp b/netwerk/cache2/CacheEntry.cpp index 6a312e073dc0..b1441ae9ff56 100644 --- a/netwerk/cache2/CacheEntry.cpp +++ b/netwerk/cache2/CacheEntry.cpp @@ -668,10 +668,9 @@ bool CacheEntry::InvokeCallbacks(bool aReadOnly) if (NS_SUCCEEDED(rv) && !onCheckThread) { // Redispatch to the target thread - RefPtr > event = - NS_NewRunnableMethod(this, &CacheEntry::InvokeCallbacksLock); - - rv = mCallbacks[i].mTargetThread->Dispatch(event, nsIEventTarget::DISPATCH_NORMAL); + rv = mCallbacks[i].mTargetThread->Dispatch(NewRunnableMethod(this, + &CacheEntry::InvokeCallbacksLock), + nsIEventTarget::DISPATCH_NORMAL); if (NS_SUCCEEDED(rv)) { LOG((" re-dispatching to target thread")); return false; @@ -1739,9 +1738,7 @@ void CacheEntry::BackgroundOp(uint32_t aOperations, bool aForceAsync) // Because CacheFile::Set*() are not thread-safe to use (uses WeakReference that // is not thread-safe) we must post to the main thread... - RefPtr > event = - NS_NewRunnableMethodWithArg(this, &CacheEntry::StoreFrecency, mFrecency); - NS_DispatchToMainThread(event); + NS_DispatchToMainThread(NewRunnableMethod(this, &CacheEntry::StoreFrecency, mFrecency)); } if (aOperations & Ops::REGISTER) { diff --git a/netwerk/cache2/CacheFileChunk.cpp b/netwerk/cache2/CacheFileChunk.cpp index d0bda85604d2..da3770f7e0f6 100644 --- a/netwerk/cache2/CacheFileChunk.cpp +++ b/netwerk/cache2/CacheFileChunk.cpp @@ -54,9 +54,7 @@ CacheFileChunk::DispatchRelease() return false; } - RefPtr > event = - NS_NewNonOwningRunnableMethod(this, &CacheFileChunk::Release); - NS_DispatchToMainThread(event); + NS_DispatchToMainThread(NewNonOwningRunnableMethod(this, &CacheFileChunk::Release)); return true; } diff --git a/netwerk/cache2/CacheFileContextEvictor.cpp b/netwerk/cache2/CacheFileContextEvictor.cpp index b92dcacf7d9c..79966927c373 100644 --- a/netwerk/cache2/CacheFileContextEvictor.cpp +++ b/netwerk/cache2/CacheFileContextEvictor.cpp @@ -522,7 +522,7 @@ CacheFileContextEvictor::StartEvicting() } nsCOMPtr ev; - ev = NS_NewRunnableMethod(this, &CacheFileContextEvictor::EvictEntries); + ev = NewRunnableMethod(this, &CacheFileContextEvictor::EvictEntries); RefPtr ioThread = CacheFileIOManager::IOThread(); diff --git a/netwerk/cache2/CacheFileIOManager.cpp b/netwerk/cache2/CacheFileIOManager.cpp index 5cae1060852d..a7f93d202411 100644 --- a/netwerk/cache2/CacheFileIOManager.cpp +++ b/netwerk/cache2/CacheFileIOManager.cpp @@ -68,9 +68,10 @@ CacheFileHandle::DispatchRelease() return false; } - RefPtr > event = - NS_NewNonOwningRunnableMethod(this, &CacheFileHandle::Release); - nsresult rv = ioTarget->Dispatch(event, nsIEventTarget::DISPATCH_NORMAL); + nsresult rv = + ioTarget->Dispatch(NewNonOwningRunnableMethod(this, + &CacheFileHandle::Release), + nsIEventTarget::DISPATCH_NORMAL); if (NS_FAILED(rv)) { return false; } @@ -2639,8 +2640,8 @@ CacheFileIOManager::EvictIfOverLimit() } nsCOMPtr ev; - ev = NS_NewRunnableMethod(ioMan, - &CacheFileIOManager::EvictIfOverLimitInternal); + ev = NewRunnableMethod(ioMan, + &CacheFileIOManager::EvictIfOverLimitInternal); rv = ioMan->mIOThread->Dispatch(ev, CacheIOThread::EVICT); NS_ENSURE_SUCCESS(rv, rv); @@ -2700,8 +2701,8 @@ CacheFileIOManager::EvictIfOverLimitInternal() cacheUsage, cacheLimit)); nsCOMPtr ev; - ev = NS_NewRunnableMethod(this, - &CacheFileIOManager::OverLimitEvictionInternal); + ev = NewRunnableMethod(this, + &CacheFileIOManager::OverLimitEvictionInternal); rv = mIOThread->Dispatch(ev, CacheIOThread::EVICT); NS_ENSURE_SUCCESS(rv, rv); @@ -2840,7 +2841,7 @@ CacheFileIOManager::EvictAll() } nsCOMPtr ev; - ev = NS_NewRunnableMethod(ioMan, &CacheFileIOManager::EvictAllInternal); + ev = NewRunnableMethod(ioMan, &CacheFileIOManager::EvictAllInternal); rv = ioMan->mIOThread->DispatchAfterPendingOpens(ev); if (NS_WARN_IF(NS_FAILED(rv))) { @@ -2958,7 +2959,7 @@ CacheFileIOManager::EvictByContext(nsILoadContextInfo *aLoadContextInfo, bool aP } nsCOMPtr ev; - ev = NS_NewRunnableMethodWithArgs, bool> + ev = NewRunnableMethod, bool> (ioMan, &CacheFileIOManager::EvictByContextInternal, aLoadContextInfo, aPinned); rv = ioMan->mIOThread->DispatchAfterPendingOpens(ev); @@ -3077,7 +3078,7 @@ CacheFileIOManager::CacheIndexStateChanged() // We have to re-distatch even if we are on IO thread to prevent reentering // the lock in CacheIndex nsCOMPtr ev; - ev = NS_NewRunnableMethod( + ev = NewRunnableMethod( gInstance, &CacheFileIOManager::CacheIndexStateChangedInternal); nsCOMPtr ioTarget = IOTarget(); @@ -3252,8 +3253,8 @@ CacheFileIOManager::StartRemovingTrash() } nsCOMPtr ev; - ev = NS_NewRunnableMethod(this, - &CacheFileIOManager::RemoveTrashInternal); + ev = NewRunnableMethod(this, + &CacheFileIOManager::RemoveTrashInternal); rv = mIOThread->Dispatch(ev, CacheIOThread::EVICT); NS_ENSURE_SUCCESS(rv, rv); diff --git a/netwerk/cache2/CacheIndex.cpp b/netwerk/cache2/CacheIndex.cpp index 3e5114303657..3ea6beed985c 100644 --- a/netwerk/cache2/CacheIndex.cpp +++ b/netwerk/cache2/CacheIndex.cpp @@ -346,7 +346,7 @@ CacheIndex::PreShutdown() } nsCOMPtr event; - event = NS_NewRunnableMethod(index, &CacheIndex::PreShutdownInternal); + event = NewRunnableMethod(index, &CacheIndex::PreShutdownInternal); RefPtr ioThread = CacheFileIOManager::IOThread(); MOZ_ASSERT(ioThread); diff --git a/netwerk/cache2/CacheObserver.cpp b/netwerk/cache2/CacheObserver.cpp index e20bb942a144..5b3d59a8cb3a 100644 --- a/netwerk/cache2/CacheObserver.cpp +++ b/netwerk/cache2/CacheObserver.cpp @@ -323,7 +323,7 @@ CacheObserver::SetDiskCacheCapacity(uint32_t aCapacity) sSelf->StoreDiskCacheCapacity(); } else { nsCOMPtr event = - NS_NewRunnableMethod(sSelf, &CacheObserver::StoreDiskCacheCapacity); + NewRunnableMethod(sSelf, &CacheObserver::StoreDiskCacheCapacity); NS_DispatchToMainThread(event); } } @@ -349,7 +349,7 @@ CacheObserver::SetCacheFSReported() sSelf->StoreCacheFSReported(); } else { nsCOMPtr event = - NS_NewRunnableMethod(sSelf, &CacheObserver::StoreCacheFSReported); + NewRunnableMethod(sSelf, &CacheObserver::StoreCacheFSReported); NS_DispatchToMainThread(event); } } @@ -375,7 +375,7 @@ CacheObserver::SetHashStatsReported() sSelf->StoreHashStatsReported(); } else { nsCOMPtr event = - NS_NewRunnableMethod(sSelf, &CacheObserver::StoreHashStatsReported); + NewRunnableMethod(sSelf, &CacheObserver::StoreHashStatsReported); NS_DispatchToMainThread(event); } } diff --git a/netwerk/cache2/CacheStorageService.cpp b/netwerk/cache2/CacheStorageService.cpp index bb9e45687991..03292b2e282f 100644 --- a/netwerk/cache2/CacheStorageService.cpp +++ b/netwerk/cache2/CacheStorageService.cpp @@ -143,7 +143,7 @@ void CacheStorageService::Shutdown() mShutdown = true; nsCOMPtr event = - NS_NewRunnableMethod(this, &CacheStorageService::ShutdownBackground); + NewRunnableMethod(this, &CacheStorageService::ShutdownBackground); Dispatch(event); mozilla::MutexAutoLock lock(mLock); @@ -1212,7 +1212,7 @@ CacheStorageService::OnMemoryConsumptionChange(CacheMemoryConsumer* aConsumer, // Dispatch as a priority task, we want to set the purge timer // ASAP to prevent vain redispatch of this event. nsCOMPtr event = - NS_NewRunnableMethod(this, &CacheStorageService::SchedulePurgeOverMemoryLimit); + NewRunnableMethod(this, &CacheStorageService::SchedulePurgeOverMemoryLimit); cacheIOTarget->Dispatch(event, nsIEventTarget::DISPATCH_NORMAL); } @@ -1252,7 +1252,7 @@ CacheStorageService::Notify(nsITimer* aTimer) mPurgeTimer = nullptr; nsCOMPtr event = - NS_NewRunnableMethod(this, &CacheStorageService::PurgeOverMemoryLimit); + NewRunnableMethod(this, &CacheStorageService::PurgeOverMemoryLimit); Dispatch(event); } diff --git a/netwerk/dns/DNSRequestChild.cpp b/netwerk/dns/DNSRequestChild.cpp index 44b27eb8fefe..431fc8fbe67c 100644 --- a/netwerk/dns/DNSRequestChild.cpp +++ b/netwerk/dns/DNSRequestChild.cpp @@ -207,7 +207,7 @@ DNSRequestChild::StartRequest() // we can only do IPDL on the main thread if (!NS_IsMainThread()) { NS_DispatchToMainThread( - NS_NewRunnableMethod(this, &DNSRequestChild::StartRequest)); + NewRunnableMethod(this, &DNSRequestChild::StartRequest)); return; } @@ -260,7 +260,7 @@ DNSRequestChild::RecvLookupCompleted(const DNSRequestResponse& reply) CallOnLookupComplete(); } else { nsCOMPtr event = - NS_NewRunnableMethod(this, &DNSRequestChild::CallOnLookupComplete); + NewRunnableMethod(this, &DNSRequestChild::CallOnLookupComplete); mTarget->Dispatch(event, NS_DISPATCH_NORMAL); } diff --git a/netwerk/dns/mdns/libmdns/MDNSResponderOperator.cpp b/netwerk/dns/mdns/libmdns/MDNSResponderOperator.cpp index 5b205f925ba6..d66c3f571d98 100644 --- a/netwerk/dns/mdns/libmdns/MDNSResponderOperator.cpp +++ b/netwerk/dns/mdns/libmdns/MDNSResponderOperator.cpp @@ -74,9 +74,8 @@ public: PR_Close(mFD); mFD = nullptr; - nsCOMPtr ev = - NS_NewRunnableMethod(this, &ServiceWatcher::Deallocate); - mThread->Dispatch(ev, NS_DISPATCH_NORMAL); + mThread->Dispatch(NewRunnableMethod(this, &ServiceWatcher::Deallocate), + NS_DISPATCH_NORMAL); } virtual void IsLocal(bool *aIsLocal) override { *aIsLocal = true; } @@ -154,8 +153,8 @@ private: nsresult PostEvent(void(ServiceWatcher::*func)(void)) { - nsCOMPtr ev = NS_NewRunnableMethod(this, func); - return gSocketTransportService->Dispatch(ev, NS_DISPATCH_NORMAL); + return gSocketTransportService->Dispatch(NewRunnableMethod(this, func), + NS_DISPATCH_NORMAL); } void OnMsgClose() @@ -219,7 +218,7 @@ private: // if (!gSocketTransportService->CanAttachSocket()) { nsCOMPtr event = - NS_NewRunnableMethod(this, &ServiceWatcher::OnMsgAttach); + NewRunnableMethod(this, &ServiceWatcher::OnMsgAttach); nsresult rv = gSocketTransportService->NotifyWhenCanAttachSocket(event); if (NS_FAILED(rv)) { diff --git a/netwerk/ipc/ChannelEventQueue.cpp b/netwerk/ipc/ChannelEventQueue.cpp index d0511e2d61e8..ae55ebd032bf 100644 --- a/netwerk/ipc/ChannelEventQueue.cpp +++ b/netwerk/ipc/ChannelEventQueue.cpp @@ -67,13 +67,13 @@ ChannelEventQueue::Resume() } if (!--mSuspendCount) { - RefPtr > event = - NS_NewRunnableMethod(this, &ChannelEventQueue::CompleteResume); + RefPtr event = + NewRunnableMethod(this, &ChannelEventQueue::CompleteResume); if (mTargetThread) { - mTargetThread->Dispatch(event, NS_DISPATCH_NORMAL); + mTargetThread->Dispatch(event.forget(), NS_DISPATCH_NORMAL); } else { MOZ_RELEASE_ASSERT(NS_IsMainThread()); - NS_WARN_IF(NS_FAILED(NS_DispatchToCurrentThread(event))); + NS_WARN_IF(NS_FAILED(NS_DispatchToCurrentThread(event.forget()))); } } } diff --git a/netwerk/protocol/about/nsAboutCache.cpp b/netwerk/protocol/about/nsAboutCache.cpp index 31f4a02c82fe..2ab2e719d52f 100644 --- a/netwerk/protocol/about/nsAboutCache.cpp +++ b/netwerk/protocol/about/nsAboutCache.cpp @@ -179,9 +179,7 @@ nsAboutCache::VisitNextStorage() // from visitor callback. The cache v1 service doesn't like it. // TODO - mayhemer, bug 913828, remove this dispatch and call // directly. - nsCOMPtr event = - NS_NewRunnableMethod(this, &nsAboutCache::FireVisitStorage); - return NS_DispatchToMainThread(event); + return NS_DispatchToMainThread(mozilla::NewRunnableMethod(this, &nsAboutCache::FireVisitStorage)); } void diff --git a/netwerk/protocol/file/nsFileChannel.cpp b/netwerk/protocol/file/nsFileChannel.cpp index 8368161a0140..38b59af4b608 100644 --- a/netwerk/protocol/file/nsFileChannel.cpp +++ b/netwerk/protocol/file/nsFileChannel.cpp @@ -232,7 +232,7 @@ nsFileUploadContentStream::AsyncWait(nsIInputStreamCallback *callback, if (IsNonBlocking()) { nsCOMPtr callback = - NS_NewRunnableMethod(this, &nsFileUploadContentStream::OnCopyComplete); + NewRunnableMethod(this, &nsFileUploadContentStream::OnCopyComplete); mCopyEvent->Dispatch(callback, mSink, target); } diff --git a/netwerk/protocol/ftp/FTPChannelParent.cpp b/netwerk/protocol/ftp/FTPChannelParent.cpp index cd2013c6024e..fbe3addde21b 100644 --- a/netwerk/protocol/ftp/FTPChannelParent.cpp +++ b/netwerk/protocol/ftp/FTPChannelParent.cpp @@ -740,7 +740,7 @@ FTPChannelParent::DivertTo(nsIStreamListener *aListener) // Call OnStartRequest and SendDivertMessages asynchronously to avoid // reentering client context. NS_DispatchToCurrentThread( - NS_NewRunnableMethod(this, &FTPChannelParent::StartDiversion)); + NewRunnableMethod(this, &FTPChannelParent::StartDiversion)); return; } diff --git a/netwerk/protocol/http/HttpBaseChannel.cpp b/netwerk/protocol/http/HttpBaseChannel.cpp index ae27fca97636..2aaa56bae55d 100644 --- a/netwerk/protocol/http/HttpBaseChannel.cpp +++ b/netwerk/protocol/http/HttpBaseChannel.cpp @@ -666,7 +666,7 @@ void CopyComplete(void* aClosure, nsresult aStatus) { // Called on the STS thread by NS_AsyncCopy auto channel = static_cast(aClosure); - nsCOMPtr runnable = NS_NewRunnableMethodWithArg( + nsCOMPtr runnable = NewRunnableMethod( channel, &HttpBaseChannel::EnsureUploadStreamIsCloneableComplete, aStatus); NS_DispatchToMainThread(runnable.forget()); } diff --git a/netwerk/protocol/http/HttpBaseChannel.h b/netwerk/protocol/http/HttpBaseChannel.h index 20083217cf68..0bd97a9686ce 100644 --- a/netwerk/protocol/http/HttpBaseChannel.h +++ b/netwerk/protocol/http/HttpBaseChannel.h @@ -582,11 +582,11 @@ inline void HttpAsyncAborter::HandleAsyncAbort() template nsresult HttpAsyncAborter::AsyncCall(void (T::*funcPtr)(), - nsRunnableMethod **retval) + nsRunnableMethod **retval) { nsresult rv; - RefPtr > event = NS_NewRunnableMethod(mThis, funcPtr); + RefPtr> event = NewRunnableMethod(mThis, funcPtr); rv = NS_DispatchToCurrentThread(event); if (NS_SUCCEEDED(rv) && retval) { *retval = event; diff --git a/netwerk/protocol/http/HttpChannelParent.cpp b/netwerk/protocol/http/HttpChannelParent.cpp index c6bed6cd925f..c10370b79fef 100644 --- a/netwerk/protocol/http/HttpChannelParent.cpp +++ b/netwerk/protocol/http/HttpChannelParent.cpp @@ -1437,7 +1437,7 @@ HttpChannelParent::DivertTo(nsIStreamListener *aListener) // Call OnStartRequest and SendDivertMessages asynchronously to avoid // reentering client context. NS_DispatchToCurrentThread( - NS_NewRunnableMethod(this, &HttpChannelParent::StartDiversion)); + NewRunnableMethod(this, &HttpChannelParent::StartDiversion)); return; } diff --git a/netwerk/protocol/http/PackagedAppVerifier.cpp b/netwerk/protocol/http/PackagedAppVerifier.cpp index b520eab3fcb1..c0dac5f42843 100644 --- a/netwerk/protocol/http/PackagedAppVerifier.cpp +++ b/netwerk/protocol/http/PackagedAppVerifier.cpp @@ -248,13 +248,13 @@ PackagedAppVerifier::FireVerifiedEvent(bool aForManifest, bool aSuccess) nsCOMPtr r; if (aForManifest) { - r = NS_NewRunnableMethodWithArgs(this, - &PackagedAppVerifier::OnManifestVerified, - aSuccess); + r = NewRunnableMethod(this, + &PackagedAppVerifier::OnManifestVerified, + aSuccess); } else { - r = NS_NewRunnableMethodWithArgs(this, - &PackagedAppVerifier::OnResourceVerified, - aSuccess); + r = NewRunnableMethod(this, + &PackagedAppVerifier::OnResourceVerified, + aSuccess); } NS_DispatchToMainThread(r); diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp index 1c4fa807a90b..f2c1b77a3c9e 100644 --- a/netwerk/protocol/http/nsHttpHandler.cpp +++ b/netwerk/protocol/http/nsHttpHandler.cpp @@ -2165,8 +2165,8 @@ nsHttpHandler::Observe(nsISupports *subject, if (mConnMgr) { if (gSocketTransportService) { nsCOMPtr event = - NS_NewRunnableMethod(mConnMgr, - &nsHttpConnectionMgr::ClearConnectionHistory); + NewRunnableMethod(mConnMgr, + &nsHttpConnectionMgr::ClearConnectionHistory); gSocketTransportService->Dispatch(event, NS_DISPATCH_NORMAL); } mConnMgr->ClearAltServiceMappings(); diff --git a/netwerk/protocol/websocket/WebSocketChannel.cpp b/netwerk/protocol/websocket/WebSocketChannel.cpp index 5465426388ea..c081035cda73 100644 --- a/netwerk/protocol/websocket/WebSocketChannel.cpp +++ b/netwerk/protocol/websocket/WebSocketChannel.cpp @@ -1248,7 +1248,7 @@ WebSocketChannel::Observe(nsISupports *subject, // Next we check mDataStarted, which we need to do on mTargetThread. if (!IsOnTargetThread()) { mTargetThread->Dispatch( - NS_NewRunnableMethod(this, &WebSocketChannel::OnNetworkChanged), + NewRunnableMethod(this, &WebSocketChannel::OnNetworkChanged), NS_DISPATCH_NORMAL); } else { OnNetworkChanged(); @@ -1272,7 +1272,7 @@ WebSocketChannel::OnNetworkChanged() } return mSocketThread->Dispatch( - NS_NewRunnableMethod(this, &WebSocketChannel::OnNetworkChanged), + NewRunnableMethod(this, &WebSocketChannel::OnNetworkChanged), NS_DISPATCH_NORMAL); } @@ -1359,7 +1359,7 @@ WebSocketChannel::BeginOpen(bool aCalledFromAdmissionManager) // When called from nsWSAdmissionManager post an event to avoid potential // re-entering of nsWSAdmissionManager and its lock. NS_DispatchToMainThread( - NS_NewRunnableMethod(this, &WebSocketChannel::BeginOpenInternal), + NewRunnableMethod(this, &WebSocketChannel::BeginOpenInternal), NS_DISPATCH_NORMAL); } else { BeginOpenInternal(); @@ -2795,7 +2795,7 @@ WebSocketChannel::StartWebsocketData() if (!IsOnTargetThread()) { return mTargetThread->Dispatch( - NS_NewRunnableMethod(this, &WebSocketChannel::StartWebsocketData), + NewRunnableMethod(this, &WebSocketChannel::StartWebsocketData), NS_DISPATCH_NORMAL); } @@ -2808,15 +2808,15 @@ WebSocketChannel::StartWebsocketData() LOG(("WebSocketChannel::StartWebsocketData mSocketIn->AsyncWait() failed " "with error 0x%08x", rv)); return mSocketThread->Dispatch( - NS_NewRunnableMethodWithArgs(this, - &WebSocketChannel::AbortSession, - rv), + NewRunnableMethod(this, + &WebSocketChannel::AbortSession, + rv), NS_DISPATCH_NORMAL); } if (mPingInterval) { rv = mSocketThread->Dispatch( - NS_NewRunnableMethod(this, &WebSocketChannel::StartPinging), + NewRunnableMethod(this, &WebSocketChannel::StartPinging), NS_DISPATCH_NORMAL); if (NS_FAILED(rv)) { LOG(("WebSocketChannel::StartWebsocketData Could not start pinging, " diff --git a/netwerk/protocol/websocket/WebSocketChannelChild.cpp b/netwerk/protocol/websocket/WebSocketChannelChild.cpp index d98167db75ab..b88a4698aa29 100644 --- a/netwerk/protocol/websocket/WebSocketChannelChild.cpp +++ b/netwerk/protocol/websocket/WebSocketChannelChild.cpp @@ -107,9 +107,9 @@ WebSocketChannelChild::MaybeReleaseIPCObject() } if (!NS_IsMainThread()) { - nsCOMPtr runnable = - NS_NewRunnableMethod(this, &WebSocketChannelChild::MaybeReleaseIPCObject); - MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(runnable)); + MOZ_ALWAYS_SUCCEEDS( + NS_DispatchToMainThread(NewRunnableMethod(this, + &WebSocketChannelChild::MaybeReleaseIPCObject))); return; } diff --git a/netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp b/netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp index c73bf4287d69..7f1a4313173f 100644 --- a/netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp +++ b/netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp @@ -700,7 +700,7 @@ nsWyciwygChannel::OnCacheEntryAvailable(nsICacheEntry *aCacheEntry, if (!aNew) { // Since OnCacheEntryAvailable can be called directly from AsyncOpen // we must dispatch. - NS_DispatchToCurrentThread(NS_NewRunnableMethod( + NS_DispatchToCurrentThread(mozilla::NewRunnableMethod( this, &nsWyciwygChannel::NotifyListener)); } } diff --git a/parser/html/nsHtml5TreeOpExecutor.cpp b/parser/html/nsHtml5TreeOpExecutor.cpp index d3d8c8e34a4c..3a260e6ebb78 100644 --- a/parser/html/nsHtml5TreeOpExecutor.cpp +++ b/parser/html/nsHtml5TreeOpExecutor.cpp @@ -233,11 +233,8 @@ nsHtml5TreeOpExecutor::MarkAsBroken(nsresult aReason) // works out so that we get to terminate and clean up the parser from // a safer point. if (mParser) { // can mParser ever be null here? - nsCOMPtr terminator = - NS_NewRunnableMethod(GetParser(), &nsHtml5Parser::Terminate); - if (NS_FAILED(NS_DispatchToMainThread(terminator))) { - NS_WARNING("failed to dispatch executor flush event"); - } + MOZ_ALWAYS_SUCCEEDS( + NS_DispatchToMainThread(NewRunnableMethod(GetParser(), &nsHtml5Parser::Terminate))); } return aReason; } diff --git a/security/manager/ssl/DataStorage.cpp b/security/manager/ssl/DataStorage.cpp index 72c9717a85ac..2059bb5f8d72 100644 --- a/security/manager/ssl/DataStorage.cpp +++ b/security/manager/ssl/DataStorage.cpp @@ -193,9 +193,9 @@ DataStorage::Reader::~Reader() // This is for tests. nsCOMPtr job = - NS_NewRunnableMethodWithArg(mDataStorage, - &DataStorage::NotifyObservers, - "data-storage-ready"); + NewRunnableMethod(mDataStorage, + &DataStorage::NotifyObservers, + "data-storage-ready"); nsresult rv = NS_DispatchToMainThread(job, NS_DISPATCH_NORMAL); Unused << NS_WARN_IF(NS_FAILED(rv)); } @@ -686,9 +686,9 @@ DataStorage::Writer::Run() // Observed by tests. nsCOMPtr job = - NS_NewRunnableMethodWithArg(mDataStorage, - &DataStorage::NotifyObservers, - "data-storage-written"); + NewRunnableMethod(mDataStorage, + &DataStorage::NotifyObservers, + "data-storage-written"); rv = NS_DispatchToMainThread(job, NS_DISPATCH_NORMAL); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; @@ -777,7 +777,7 @@ DataStorage::AsyncSetTimer(const MutexAutoLock& /*aProofOfLock*/) mPendingWrite = true; nsCOMPtr job = - NS_NewRunnableMethod(this, &DataStorage::SetTimer); + NewRunnableMethod(this, &DataStorage::SetTimer); nsresult rv = mWorkerThread->Dispatch(job, NS_DISPATCH_NORMAL); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; @@ -827,7 +827,7 @@ DataStorage::DispatchShutdownTimer(const MutexAutoLock& /*aProofOfLock*/) MOZ_ASSERT(XRE_IsParentProcess()); nsCOMPtr job = - NS_NewRunnableMethod(this, &DataStorage::ShutdownTimer); + NewRunnableMethod(this, &DataStorage::ShutdownTimer); nsresult rv = mWorkerThread->Dispatch(job, NS_DISPATCH_NORMAL); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; diff --git a/security/manager/ssl/PSMContentListener.cpp b/security/manager/ssl/PSMContentListener.cpp index bc6c4c98ecd6..295264c53916 100644 --- a/security/manager/ssl/PSMContentListener.cpp +++ b/security/manager/ssl/PSMContentListener.cpp @@ -152,7 +152,7 @@ PSMContentStreamListener::OnStopRequest(nsIRequest* request, // Because importing the cert can spin the event loop (via alerts), we can't // do it here. Do it off the event loop instead. nsCOMPtr r = - NS_NewRunnableMethod(this, &PSMContentStreamListener::ImportCertificate); + NewRunnableMethod(this, &PSMContentStreamListener::ImportCertificate); MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(r)); return NS_OK; diff --git a/storage/mozStorageConnection.cpp b/storage/mozStorageConnection.cpp index b7a16c6697da..ef7bba350db4 100644 --- a/storage/mozStorageConnection.cpp +++ b/storage/mozStorageConnection.cpp @@ -367,7 +367,7 @@ public: MOZ_ASSERT(onAsyncThread); #endif // DEBUG - nsCOMPtr event = NS_NewRunnableMethodWithArg> + nsCOMPtr event = NewRunnableMethod> (mConnection, &Connection::shutdownAsyncThread, mAsyncExecutionThread); (void)NS_DispatchToMainThread(event); diff --git a/storage/mozStorageService.cpp b/storage/mozStorageService.cpp index 9283cf9b0f68..2d175f7f421e 100644 --- a/storage/mozStorageService.cpp +++ b/storage/mozStorageService.cpp @@ -383,7 +383,7 @@ Service::minimizeMemory() // We are on the wrong thread, the query should be executed on the // opener thread, so we must dispatch to it. nsCOMPtr event = - NS_NewRunnableMethodWithArg( + NewRunnableMethod( conn, &Connection::ExecuteSimpleSQL, shrinkPragma); conn->threadOpenedOn->Dispatch(event, NS_DISPATCH_NORMAL); } @@ -702,7 +702,7 @@ public: : mConnection->initialize(); if (NS_FAILED(rv)) { nsCOMPtr closeRunnable = - NS_NewRunnableMethodWithArg( + NewRunnableMethod( mConnection.get(), &Connection::AsyncClose, nullptr); diff --git a/toolkit/components/filewatcher/NativeFileWatcherWin.cpp b/toolkit/components/filewatcher/NativeFileWatcherWin.cpp index ac9a7654d08d..21385b03bf9a 100644 --- a/toolkit/components/filewatcher/NativeFileWatcherWin.cpp +++ b/toolkit/components/filewatcher/NativeFileWatcherWin.cpp @@ -1311,7 +1311,7 @@ NativeFileWatcherService::AddPath(const nsAString& aPathToWatch, nsMainThreadPtrHandle successCallbackHandle( new nsMainThreadPtrHolder(aOnSuccess)); - // Wrap the path and the callbacks in order to pass them using NS_NewRunnableMethodWithArg. + // Wrap the path and the callbacks in order to pass them using NewRunnableMethod. UniquePtr wrappedCallbacks( new PathRunnablesParametersWrapper( aPathToWatch, @@ -1322,7 +1322,7 @@ NativeFileWatcherService::AddPath(const nsAString& aPathToWatch, // Since this function does a bit of I/O stuff , run it in the IO thread. nsresult rv = mIOThread->Dispatch( - NS_NewRunnableMethodWithArg( + NewRunnableMethod( static_cast(mWorkerIORunnable.get()), &NativeFileWatcherIOTask::AddPathRunnableMethod, wrappedCallbacks.get()), @@ -1381,7 +1381,7 @@ NativeFileWatcherService::RemovePath(const nsAString& aPathToRemove, nsMainThreadPtrHandle successCallbackHandle( new nsMainThreadPtrHolder(aOnSuccess)); - // Wrap the path and the callbacks in order to pass them using NS_NewRunnableMethodWithArg. + // Wrap the path and the callbacks in order to pass them using NewRunnableMethod. UniquePtr wrappedCallbacks( new PathRunnablesParametersWrapper( aPathToRemove, @@ -1392,7 +1392,7 @@ NativeFileWatcherService::RemovePath(const nsAString& aPathToRemove, // Since this function does a bit of I/O stuff, run it in the IO thread. nsresult rv = mIOThread->Dispatch( - NS_NewRunnableMethodWithArg( + NewRunnableMethod( static_cast(mWorkerIORunnable.get()), &NativeFileWatcherIOTask::RemovePathRunnableMethod, wrappedCallbacks.get()), @@ -1441,7 +1441,7 @@ NativeFileWatcherService::Uninit() // in the IO thread. nsresult rv = ioThread->Dispatch( - NS_NewRunnableMethod( + NewRunnableMethod( static_cast(mWorkerIORunnable.get()), &NativeFileWatcherIOTask::DeactivateRunnableMethod), nsIEventTarget::DISPATCH_NORMAL); diff --git a/toolkit/components/places/AsyncFaviconHelpers.cpp b/toolkit/components/places/AsyncFaviconHelpers.cpp index f53fd9ac29d4..200a51838e57 100644 --- a/toolkit/components/places/AsyncFaviconHelpers.cpp +++ b/toolkit/components/places/AsyncFaviconHelpers.cpp @@ -488,7 +488,7 @@ AsyncFetchAndSetIconForPage::Run() // Fetch the icon from the network, the request starts from the main-thread. // When done this will associate the icon to the page and notify. nsCOMPtr event = - NS_NewRunnableMethod(this, &AsyncFetchAndSetIconForPage::FetchFromNetwork); + NewRunnableMethod(this, &AsyncFetchAndSetIconForPage::FetchFromNetwork); return NS_DispatchToMainThread(event); } diff --git a/toolkit/components/places/History.cpp b/toolkit/components/places/History.cpp index a3c2f77acfeb..73c330972122 100644 --- a/toolkit/components/places/History.cpp +++ b/toolkit/components/places/History.cpp @@ -504,9 +504,7 @@ public: RefPtr cb = new VisitedQuery(aURI, callback, true); NS_ENSURE_TRUE(cb, NS_ERROR_OUT_OF_MEMORY); // As per IHistory contract, we must notify asynchronously. - nsCOMPtr event = - NS_NewRunnableMethod(cb, &VisitedQuery::NotifyVisitedStatus); - NS_DispatchToMainThread(event); + NS_DispatchToMainThread(NewRunnableMethod(cb, &VisitedQuery::NotifyVisitedStatus)); return NS_OK; } diff --git a/toolkit/components/satchel/nsFormFillController.cpp b/toolkit/components/satchel/nsFormFillController.cpp index 775386fab5bd..73c79cd9dc8b 100644 --- a/toolkit/components/satchel/nsFormFillController.cpp +++ b/toolkit/components/satchel/nsFormFillController.cpp @@ -119,7 +119,7 @@ nsFormFillController::AttributeChanged(nsIDocument* aDocument, // to avoid ending up in an endless loop due to re-registering our // mutation observer (which would notify us again for *this* event). nsCOMPtr event = - NS_NewRunnableMethodWithArg> + mozilla::NewRunnableMethod> (this, &nsFormFillController::MaybeStartControllingInput, focusedInput); NS_DispatchToCurrentThread(event); } diff --git a/toolkit/components/telemetry/Telemetry.cpp b/toolkit/components/telemetry/Telemetry.cpp index 23f2a4d285fb..6b9c9ffb26c5 100644 --- a/toolkit/components/telemetry/Telemetry.cpp +++ b/toolkit/components/telemetry/Telemetry.cpp @@ -1756,7 +1756,7 @@ public: ReadLastShutdownDuration(mShutdownTimeFilename); mTelemetry->ReadLateWritesStacks(mProfileDir); nsCOMPtr e = - NS_NewRunnableMethod(this, &nsFetchTelemetryData::MainThread); + NewRunnableMethod(this, &nsFetchTelemetryData::MainThread); NS_ENSURE_STATE(e); NS_DispatchToMainThread(e); return NS_OK; diff --git a/toolkit/components/url-classifier/nsUrlClassifierProxies.cpp b/toolkit/components/url-classifier/nsUrlClassifierProxies.cpp index 96fdfea720ee..f0be4f2000c0 100644 --- a/toolkit/components/url-classifier/nsUrlClassifierProxies.cpp +++ b/toolkit/components/url-classifier/nsUrlClassifierProxies.cpp @@ -9,6 +9,7 @@ #include "mozilla/SyncRunnable.h" using namespace mozilla::safebrowsing; +using mozilla::NewRunnableMethod; static nsresult DispatchToWorkerThread(nsIRunnable* r) @@ -113,8 +114,8 @@ NS_IMETHODIMP UrlClassifierDBServiceWorkerProxy::FinishStream() { nsCOMPtr r = - NS_NewRunnableMethod(mTarget, - &nsIUrlClassifierDBServiceWorker::FinishStream); + NewRunnableMethod(mTarget, + &nsIUrlClassifierDBServiceWorker::FinishStream); return DispatchToWorkerThread(r); } @@ -147,8 +148,8 @@ NS_IMETHODIMP UrlClassifierDBServiceWorkerProxy::FinishUpdate() { nsCOMPtr r = - NS_NewRunnableMethod(mTarget, - &nsIUrlClassifierDBServiceWorker::FinishUpdate); + NewRunnableMethod(mTarget, + &nsIUrlClassifierDBServiceWorker::FinishUpdate); return DispatchToWorkerThread(r); } @@ -156,8 +157,8 @@ NS_IMETHODIMP UrlClassifierDBServiceWorkerProxy::CancelUpdate() { nsCOMPtr r = - NS_NewRunnableMethod(mTarget, - &nsIUrlClassifierDBServiceWorker::CancelUpdate); + NewRunnableMethod(mTarget, + &nsIUrlClassifierDBServiceWorker::CancelUpdate); return DispatchToWorkerThread(r); } @@ -165,8 +166,8 @@ NS_IMETHODIMP UrlClassifierDBServiceWorkerProxy::ResetDatabase() { nsCOMPtr r = - NS_NewRunnableMethod(mTarget, - &nsIUrlClassifierDBServiceWorker::ResetDatabase); + NewRunnableMethod(mTarget, + &nsIUrlClassifierDBServiceWorker::ResetDatabase); return DispatchToWorkerThread(r); } @@ -174,8 +175,8 @@ NS_IMETHODIMP UrlClassifierDBServiceWorkerProxy::OpenDb() { nsCOMPtr r = - NS_NewRunnableMethod(mTarget, - &nsIUrlClassifierDBServiceWorker::OpenDb); + NewRunnableMethod(mTarget, + &nsIUrlClassifierDBServiceWorker::OpenDb); return DispatchToWorkerThread(r); } @@ -183,8 +184,8 @@ NS_IMETHODIMP UrlClassifierDBServiceWorkerProxy::CloseDb() { nsCOMPtr r = - NS_NewRunnableMethod(mTarget, - &nsIUrlClassifierDBServiceWorker::CloseDb); + NewRunnableMethod(mTarget, + &nsIUrlClassifierDBServiceWorker::CloseDb); return DispatchToWorkerThread(r); } diff --git a/toolkit/xre/nsUpdateDriver.cpp b/toolkit/xre/nsUpdateDriver.cpp index 83002ca02243..cc8b87ef6377 100644 --- a/toolkit/xre/nsUpdateDriver.cpp +++ b/toolkit/xre/nsUpdateDriver.cpp @@ -1204,8 +1204,8 @@ nsUpdateProcessor::ProcessUpdate(nsIUpdate* aUpdate) #endif MOZ_ASSERT(NS_IsMainThread(), "not main thread"); - return NS_NewThread(getter_AddRefs(mProcessWatcher), - NS_NewRunnableMethod(this, &nsUpdateProcessor::StartStagedUpdate)); + nsCOMPtr r = NewRunnableMethod(this, &nsUpdateProcessor::StartStagedUpdate); + return NS_NewThread(getter_AddRefs(mProcessWatcher), r); } @@ -1229,13 +1229,13 @@ nsUpdateProcessor::StartStagedUpdate() if (mUpdaterPID) { // Track the state of the updater process while it is staging an update. - rv = NS_DispatchToCurrentThread(NS_NewRunnableMethod(this, &nsUpdateProcessor::WaitForProcess)); + rv = NS_DispatchToCurrentThread(NewRunnableMethod(this, &nsUpdateProcessor::WaitForProcess)); NS_ENSURE_SUCCESS_VOID(rv); } else { // Failed to launch the updater process for some reason. // We need to shutdown the current thread as there isn't anything more for // us to do... - rv = NS_DispatchToMainThread(NS_NewRunnableMethod(this, &nsUpdateProcessor::ShutdownWatcherThread)); + rv = NS_DispatchToMainThread(NewRunnableMethod(this, &nsUpdateProcessor::ShutdownWatcherThread)); NS_ENSURE_SUCCESS_VOID(rv); } } @@ -1253,7 +1253,7 @@ nsUpdateProcessor::WaitForProcess() { MOZ_ASSERT(!NS_IsMainThread(), "main thread"); ::WaitForProcess(mUpdaterPID); - NS_DispatchToMainThread(NS_NewRunnableMethod(this, &nsUpdateProcessor::UpdateDone)); + NS_DispatchToMainThread(NewRunnableMethod(this, &nsUpdateProcessor::UpdateDone)); } void diff --git a/uriloader/prefetch/nsOfflineCacheUpdate.cpp b/uriloader/prefetch/nsOfflineCacheUpdate.cpp index 96d960842a6e..746a447499c8 100644 --- a/uriloader/prefetch/nsOfflineCacheUpdate.cpp +++ b/uriloader/prefetch/nsOfflineCacheUpdate.cpp @@ -1733,10 +1733,8 @@ nsOfflineCacheUpdate::Begin() mItemsInProgress = 0; if (mState == STATE_CANCELLED) { - RefPtr > errorNotification = - NS_NewRunnableMethod(this, - &nsOfflineCacheUpdate::AsyncFinishWithError); - nsresult rv = NS_DispatchToMainThread(errorNotification); + nsresult rv = NS_DispatchToMainThread(NewRunnableMethod(this, + &nsOfflineCacheUpdate::AsyncFinishWithError)); NS_ENSURE_SUCCESS(rv, rv); return NS_OK; diff --git a/widget/ScreenProxy.cpp b/widget/ScreenProxy.cpp index cf774a6e9a50..5257eb68ab23 100644 --- a/widget/ScreenProxy.cpp +++ b/widget/ScreenProxy.cpp @@ -174,9 +174,7 @@ ScreenProxy::InvalidateCacheOnNextTick() mCacheWillInvalidate = true; - nsCOMPtr r = - NS_NewRunnableMethod(this, &ScreenProxy::InvalidateCache); - nsContentUtils::RunInStableState(r.forget()); + nsContentUtils::RunInStableState(NewRunnableMethod(this, &ScreenProxy::InvalidateCache)); } void diff --git a/widget/VsyncDispatcher.cpp b/widget/VsyncDispatcher.cpp index b57c71136d72..04ad7410b124 100644 --- a/widget/VsyncDispatcher.cpp +++ b/widget/VsyncDispatcher.cpp @@ -89,7 +89,7 @@ CompositorVsyncDispatcher::SetCompositorVsyncObserver(VsyncObserver* aVsyncObser } bool observeVsync = aVsyncObserver != nullptr; - nsCOMPtr vsyncControl = NS_NewRunnableMethodWithArg(this, + nsCOMPtr vsyncControl = NewRunnableMethod(this, &CompositorVsyncDispatcher::ObserveVsync, observeVsync); NS_DispatchToMainThread(vsyncControl); @@ -180,9 +180,8 @@ void RefreshTimerVsyncDispatcher::UpdateVsyncStatus() { if (!NS_IsMainThread()) { - nsCOMPtr vsyncControl = NS_NewRunnableMethod(this, - &RefreshTimerVsyncDispatcher::UpdateVsyncStatus); - NS_DispatchToMainThread(vsyncControl); + NS_DispatchToMainThread(NewRunnableMethod(this, + &RefreshTimerVsyncDispatcher::UpdateVsyncStatus)); return; } diff --git a/widget/android/AndroidContentController.cpp b/widget/android/AndroidContentController.cpp index 0090396a8b50..655cec69dad1 100644 --- a/widget/android/AndroidContentController.cpp +++ b/widget/android/AndroidContentController.cpp @@ -34,7 +34,7 @@ AndroidContentController::NotifyDefaultPrevented(APZCTreeManager* aManager, // The notification must reach the APZ on the Java UI thread (aka the // APZ "controller" thread) but we get it from the Gecko thread, so we // have to throw it onto the other thread. - AndroidBridge::Bridge()->PostTaskToUiThread(NewRunnableMethod( + AndroidBridge::Bridge()->PostTaskToUiThread(NewRunnableMethod( aManager, &APZCTreeManager::ContentReceivedInputBlock, aInputBlockId, aDefaultPrevented), 0); return; diff --git a/widget/gtk/nsDeviceContextSpecG.cpp b/widget/gtk/nsDeviceContextSpecG.cpp index 0c69a907af79..dbbddebb132f 100644 --- a/widget/gtk/nsDeviceContextSpecG.cpp +++ b/widget/gtk/nsDeviceContextSpecG.cpp @@ -269,9 +269,7 @@ gboolean nsDeviceContextSpecGTK::PrinterEnumerator(GtkPrinter *aPrinter, // misunderstanding what the capabilities of the printer are due to a // GTK bug (https://bugzilla.gnome.org/show_bug.cgi?id=753041). We // sidestep this by deferring the print to the next tick. - nsCOMPtr event = - NS_NewRunnableMethod(spec, &nsDeviceContextSpecGTK::StartPrintJob); - NS_DispatchToCurrentThread(event); + NS_DispatchToCurrentThread(NewRunnableMethod(spec, &nsDeviceContextSpecGTK::StartPrintJob)); return TRUE; } } @@ -329,9 +327,7 @@ NS_IMETHODIMP nsDeviceContextSpecGTK::EndDocument() } else { // We don't have a printer. We have to enumerate the printers and find // one with a matching name. - nsCOMPtr event = - NS_NewRunnableMethod(this, &nsDeviceContextSpecGTK::EnumeratePrinters); - NS_DispatchToCurrentThread(event); + NS_DispatchToCurrentThread(NewRunnableMethod(this, &nsDeviceContextSpecGTK::EnumeratePrinters)); } } else { // Handle print-to-file ourselves for the benefit of embedders diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp index d16231f3294d..08915ab80ad5 100644 --- a/widget/gtk/nsWindow.cpp +++ b/widget/gtk/nsWindow.cpp @@ -2482,9 +2482,7 @@ nsWindow::OnSizeAllocate(GtkAllocation *aAllocation) // GtkWindow callers of gtk_widget_size_allocate expect the signal // handlers to return sometime in the near future. mNeedsDispatchResized = true; - nsCOMPtr r = - NS_NewRunnableMethod(this, &nsWindow::MaybeDispatchResized); - NS_DispatchToCurrentThread(r.forget()); + NS_DispatchToCurrentThread(NewRunnableMethod(this, &nsWindow::MaybeDispatchResized)); } void @@ -4641,7 +4639,7 @@ nsWindow::GrabPointer(guint32 aTime) // popups don't rollup while potentially adjusting the grab for // this popup. nsCOMPtr event = - NS_NewRunnableMethod(this, &nsWindow::CheckForRollupDuringGrab); + NewRunnableMethod(this, &nsWindow::CheckForRollupDuringGrab); NS_DispatchToCurrentThread(event.forget()); } } diff --git a/widget/nsBaseWidget.cpp b/widget/nsBaseWidget.cpp index b5d24a7e012d..bb6f6092fe39 100644 --- a/widget/nsBaseWidget.cpp +++ b/widget/nsBaseWidget.cpp @@ -981,10 +981,11 @@ void nsBaseWidget::ConfigureAPZCTreeManager() bool aPreventDefault) { MOZ_ASSERT(NS_IsMainThread()); - RefPtr runnable = - NS_NewRunnableMethodWithArgs(treeManager, &APZCTreeManager::ContentReceivedInputBlock, - aInputBlockId, aPreventDefault); - APZThreadUtils::RunOnControllerThread(runnable.forget()); + APZThreadUtils::RunOnControllerThread(NewRunnableMethod + (treeManager, + &APZCTreeManager::ContentReceivedInputBlock, + aInputBlockId, + aPreventDefault)); }); mAPZEventState = new APZEventState(this, mozilla::Move(callback)); @@ -992,12 +993,11 @@ void nsBaseWidget::ConfigureAPZCTreeManager() const nsTArray& aFlags) { MOZ_ASSERT(NS_IsMainThread()); - RefPtr runnable = - NS_NewRunnableMethodWithArgs>>(treeManager, - &APZCTreeManager::SetAllowedTouchBehavior, - aInputBlockId, aFlags); - APZThreadUtils::RunOnControllerThread(runnable.forget()); + APZThreadUtils::RunOnControllerThread(NewRunnableMethod + >>(treeManager, + &APZCTreeManager::SetAllowedTouchBehavior, + aInputBlockId, aFlags)); }; mRootContentController = CreateRootContentController(); @@ -1028,12 +1028,10 @@ nsBaseWidget::SetConfirmedTargetAPZC(uint64_t aInputBlockId, // Need to specifically bind this since it's overloaded. void (APZCTreeManager::*setTargetApzcFunc)(uint64_t, const nsTArray&) = &APZCTreeManager::SetTargetAPZC; - RefPtr runnable = - NS_NewRunnableMethodWithArgs>>(mAPZC, - setTargetApzcFunc, - aInputBlockId, aTargets); - APZThreadUtils::RunOnControllerThread(runnable.forget()); + APZThreadUtils::RunOnControllerThread(NewRunnableMethod + >>(mAPZC, + setTargetApzcFunc, + aInputBlockId, aTargets)); } void @@ -1921,11 +1919,10 @@ nsBaseWidget::StartAsyncScrollbarDrag(const AsyncDragMetrics& aDragMetrics) int layersId = mCompositorBridgeParent->RootLayerTreeId();; ScrollableLayerGuid guid(layersId, aDragMetrics.mPresShellId, aDragMetrics.mViewId); - RefPtr runnable = - NS_NewRunnableMethodWithArgs(mAPZC, &APZCTreeManager::StartScrollbarDrag, - guid, aDragMetrics); - APZThreadUtils::RunOnControllerThread(runnable.forget()); + APZThreadUtils::RunOnControllerThread(NewRunnableMethod + (mAPZC, + &APZCTreeManager::StartScrollbarDrag, + guid, aDragMetrics)); } already_AddRefed diff --git a/widget/nsScreenManagerProxy.cpp b/widget/nsScreenManagerProxy.cpp index 18661451b40d..a4448b25667e 100644 --- a/widget/nsScreenManagerProxy.cpp +++ b/widget/nsScreenManagerProxy.cpp @@ -199,9 +199,7 @@ nsScreenManagerProxy::InvalidateCacheOnNextTick() mCacheWillInvalidate = true; - nsCOMPtr r = - NS_NewRunnableMethod(this, &nsScreenManagerProxy::InvalidateCache); - nsContentUtils::RunInStableState(r.forget()); + nsContentUtils::RunInStableState(NewRunnableMethod(this, &nsScreenManagerProxy::InvalidateCache)); } void diff --git a/widget/qt/nsWindow.h b/widget/qt/nsWindow.h index 3943018b28b2..53a7b20ff5e9 100644 --- a/widget/qt/nsWindow.h +++ b/widget/qt/nsWindow.h @@ -312,7 +312,7 @@ private: void DispatchMotionToMainThread() { if (!mTimerStarted) { nsCOMPtr event = - NS_NewRunnableMethod(this, &nsWindow::ProcessMotionEvent); + mozilla::NewRunnableMethod(this, &nsWindow::ProcessMotionEvent); NS_DispatchToMainThread(event); mTimerStarted = true; } diff --git a/widget/windows/AudioSession.cpp b/widget/windows/AudioSession.cpp index f75cfa49e01f..f0288da3fe7e 100644 --- a/widget/windows/AudioSession.cpp +++ b/widget/windows/AudioSession.cpp @@ -409,7 +409,7 @@ AudioSession::OnSessionDisconnected(AudioSessionDisconnectReason aReason) // Run our code asynchronously. Per MSDN we can't do anything interesting // in this callback. nsCOMPtr runnable = - NS_NewRunnableMethod(this, &AudioSession::OnSessionDisconnectedInternal); + NewRunnableMethod(this, &AudioSession::OnSessionDisconnectedInternal); NS_DispatchToMainThread(runnable); return S_OK; } diff --git a/widget/windows/LSPAnnotator.cpp b/widget/windows/LSPAnnotator.cpp index bbe55563e5a0..de4a40d2ac83 100644 --- a/widget/windows/LSPAnnotator.cpp +++ b/widget/windows/LSPAnnotator.cpp @@ -145,7 +145,7 @@ LSPAnnotationGatherer::Run() } mString = str; - NS_DispatchToMainThread(NS_NewRunnableMethod(this, &LSPAnnotationGatherer::Annotate)); + NS_DispatchToMainThread(NewRunnableMethod(this, &LSPAnnotationGatherer::Annotate)); return NS_OK; } diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index 335063297257..5c820cac955e 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -4940,9 +4940,7 @@ nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam, if (wParam == TRUE && !gfxEnv::DisableForcePresent() && gfxWindowsPlatform::GetPlatform()->DwmCompositionEnabled()) { - nsCOMPtr event = - NS_NewRunnableMethod(this, &nsWindow::ForcePresent); - NS_DispatchToMainThread(event); + NS_DispatchToMainThread(NewRunnableMethod(this, &nsWindow::ForcePresent)); } // let the dwm handle nc painting on glass diff --git a/widget/windows/nsWindowGfx.cpp b/widget/windows/nsWindowGfx.cpp index 9e028bf55a1e..d2829dfc8002 100644 --- a/widget/windows/nsWindowGfx.cpp +++ b/widget/windows/nsWindowGfx.cpp @@ -389,7 +389,7 @@ bool nsWindow::OnPaint(HDC aDC, uint32_t aNestingLevel) this, LayoutDeviceIntRegion::FromUnknownRegion(region)); if (!gfxEnv::DisableForcePresent() && gfxWindowsPlatform::GetPlatform()->DwmCompositionEnabled()) { nsCOMPtr event = - NS_NewRunnableMethod(this, &nsWindow::ForcePresent); + NewRunnableMethod(this, &nsWindow::ForcePresent); NS_DispatchToMainThread(event); } } diff --git a/xpcom/base/nsDumpUtils.cpp b/xpcom/base/nsDumpUtils.cpp index d2c33d5ccdb3..33dceb47c66a 100644 --- a/xpcom/base/nsDumpUtils.cpp +++ b/xpcom/base/nsDumpUtils.cpp @@ -74,8 +74,7 @@ FdWatcher::Init() nsCOMPtr os = services::GetObserverService(); os->AddObserver(this, "xpcom-shutdown", /* ownsWeak = */ false); - RefPtr runnable = NS_NewRunnableMethod(this, &FdWatcher::StartWatching); - XRE_GetIOMessageLoop()->PostTask(runnable.forget()); + XRE_GetIOMessageLoop()->PostTask(NewRunnableMethod(this, &FdWatcher::StartWatching)); } // Implementations may call this function multiple times if they ensure that diff --git a/xpcom/base/nsDumpUtils.h b/xpcom/base/nsDumpUtils.h index 1d9c8cfb90f2..12a99da18dc9 100644 --- a/xpcom/base/nsDumpUtils.h +++ b/xpcom/base/nsDumpUtils.h @@ -89,9 +89,7 @@ public: MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(!strcmp(aTopic, "xpcom-shutdown")); - RefPtr runnable = - NS_NewRunnableMethod(this, &FdWatcher::StopWatching); - XRE_GetIOMessageLoop()->PostTask(runnable.forget()); + XRE_GetIOMessageLoop()->PostTask(mozilla::NewRunnableMethod(this, &FdWatcher::StopWatching)); return NS_OK; } diff --git a/xpcom/base/nsMemoryReporterManager.cpp b/xpcom/base/nsMemoryReporterManager.cpp index 7c319e667678..054060cd2ecd 100644 --- a/xpcom/base/nsMemoryReporterManager.cpp +++ b/xpcom/base/nsMemoryReporterManager.cpp @@ -1693,8 +1693,9 @@ nsMemoryReporterManager::GetReportsExtended( aDMDDumpIdent); if (aMinimize) { - rv = MinimizeMemoryUsage(NS_NewRunnableMethod( - this, &nsMemoryReporterManager::StartGettingReports)); + nsCOMPtr callback = + NewRunnableMethod(this, &nsMemoryReporterManager::StartGettingReports); + rv = MinimizeMemoryUsage(callback); } else { rv = StartGettingReports(); } diff --git a/xpcom/ds/nsObserverService.cpp b/xpcom/ds/nsObserverService.cpp index 42bcff58be80..455764811ed1 100644 --- a/xpcom/ds/nsObserverService.cpp +++ b/xpcom/ds/nsObserverService.cpp @@ -200,9 +200,7 @@ nsObserverService::Create(nsISupports* aOuter, const nsIID& aIID, // The memory reporter can not be immediately registered here because // the nsMemoryReporterManager may attempt to get the nsObserverService // during initialization, causing a recursive GetService. - RefPtr> registerRunnable = - NS_NewRunnableMethod(os, &nsObserverService::RegisterReporter); - NS_DispatchToCurrentThread(registerRunnable); + NS_DispatchToCurrentThread(NewRunnableMethod(os, &nsObserverService::RegisterReporter)); return os->QueryInterface(aIID, aInstancePtr); } diff --git a/xpcom/glue/nsThreadUtils.h b/xpcom/glue/nsThreadUtils.h index c5b1cbf0773c..0cf96b621913 100644 --- a/xpcom/glue/nsThreadUtils.h +++ b/xpcom/glue/nsThreadUtils.h @@ -753,99 +753,91 @@ public: // Use this template function like so: // // nsCOMPtr event = -// NS_NewRunnableMethod(myObject, &MyClass::HandleEvent); +// mozilla::NewRunnableMethod(myObject, &MyClass::HandleEvent); // NS_DispatchToCurrentThread(event); // // Statically enforced constraints: // - myObject must be of (or implicitly convertible to) type MyClass // - MyClass must defined AddRef and Release methods // + +namespace mozilla { + template -typename nsRunnableMethodTraits::base_type* -NS_NewRunnableMethod(PtrType aPtr, Method aMethod) +already_AddRefed::base_type> +NewRunnableMethod(PtrType aPtr, Method aMethod) { - return new nsRunnableMethodImpl(aPtr, aMethod); + return do_AddRef(new nsRunnableMethodImpl(aPtr, aMethod)); } template -typename nsRunnableMethodTraits::base_type* -NS_NewCancelableRunnableMethod(PtrType aPtr, Method aMethod) +already_AddRefed::base_type> +NewCancelableRunnableMethod(PtrType aPtr, Method aMethod) { - return new nsRunnableMethodImpl(aPtr, aMethod); + return do_AddRef(new nsRunnableMethodImpl(aPtr, aMethod)); } template -typename nsRunnableMethodTraits::base_type* -NS_NewNonOwningRunnableMethod(PtrType&& aPtr, Method aMethod) +already_AddRefed::base_type> +NewNonOwningRunnableMethod(PtrType&& aPtr, Method aMethod) { - return new nsRunnableMethodImpl(aPtr, aMethod); + return do_AddRef(new nsRunnableMethodImpl(aPtr, aMethod)); } template -typename nsRunnableMethodTraits::base_type* -NS_NewNonOwningCancelableRunnableMethod(PtrType&& aPtr, Method aMethod) +already_AddRefed::base_type> +NewNonOwningCancelableRunnableMethod(PtrType&& aPtr, Method aMethod) { - return new nsRunnableMethodImpl(aPtr, aMethod); + return do_AddRef(new nsRunnableMethodImpl(aPtr, aMethod)); } -// Similar to NS_NewRunnableMethod. Call like so: +// Similar to NewRunnableMethod. Call like so: // nsCOMPtr event = -// NS_NewRunnableMethodWithArg(myObject, &MyClass::HandleEvent, myArg); -// 'Type' is the stored type for the argument, see ParameterStorage for details. -template -typename nsRunnableMethodTraits::base_type* -NS_NewRunnableMethodWithArg(PtrType&& aPtr, Method aMethod, Arg&& aArg) -{ - return new nsRunnableMethodImpl( - aPtr, aMethod, mozilla::Forward(aArg)); -} - -// Similar to NS_NewRunnableMethod. Call like so: -// nsCOMPtr event = -// NS_NewRunnableMethodWithArg(myObject, &MyClass::HandleEvent, myArg1,...); +// NewRunnableMethod(myObject, &MyClass::HandleEvent, myArg1,...); // 'Types' are the stored type for each argument, see ParameterStorage for details. template -typename nsRunnableMethodTraits::base_type* -NS_NewRunnableMethodWithArgs(PtrType&& aPtr, Method aMethod, Args&&... aArgs) +already_AddRefed::base_type> +NewRunnableMethod(PtrType&& aPtr, Method aMethod, Args&&... aArgs) { static_assert(sizeof...(Storages) == sizeof...(Args), " size should be equal to number of arguments"); - return new nsRunnableMethodImpl( - aPtr, aMethod, mozilla::Forward(aArgs)...); + return do_AddRef(new nsRunnableMethodImpl( + aPtr, aMethod, mozilla::Forward(aArgs)...)); } template -typename nsRunnableMethodTraits::base_type* -NS_NewNonOwningRunnableMethodWithArgs(PtrType&& aPtr, Method aMethod, - Args&&... aArgs) +already_AddRefed::base_type> +NewNonOwningRunnableMethod(PtrType&& aPtr, Method aMethod, Args&&... aArgs) { static_assert(sizeof...(Storages) == sizeof...(Args), " size should be equal to number of arguments"); - return new nsRunnableMethodImpl( - aPtr, aMethod, mozilla::Forward(aArgs)...); + return do_AddRef(new nsRunnableMethodImpl( + aPtr, aMethod, mozilla::Forward(aArgs)...)); } template -typename nsRunnableMethodTraits::base_type* -NS_NewCancelableRunnableMethodWithArgs(PtrType&& aPtr, Method aMethod, Args&&... aArgs) +already_AddRefed::base_type> +NewCancelableRunnableMethod(PtrType&& aPtr, Method aMethod, Args&&... aArgs) { static_assert(sizeof...(Storages) == sizeof...(Args), " size should be equal to number of arguments"); - return new nsRunnableMethodImpl( - aPtr, aMethod, mozilla::Forward(aArgs)...); + return do_AddRef(new nsRunnableMethodImpl( + aPtr, aMethod, mozilla::Forward(aArgs)...)); } template -typename nsRunnableMethodTraits::base_type* -NS_NewNonOwningCancelableRunnableMethodWithArgs(PtrType&& aPtr, Method aMethod, +already_AddRefed::base_type> +NewNonOwningCancelableRunnableMethod(PtrType&& aPtr, Method aMethod, Args&&... aArgs) { static_assert(sizeof...(Storages) == sizeof...(Args), " size should be equal to number of arguments"); - return new nsRunnableMethodImpl( - aPtr, aMethod, mozilla::Forward(aArgs)...); + return do_AddRef(new nsRunnableMethodImpl( + aPtr, aMethod, mozilla::Forward(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 @@ -909,6 +901,16 @@ public: return *this; } + const nsRevocableEventPtr& operator=(already_AddRefed aEvent) + { + RefPtr event = aEvent; + if (mEvent != event) { + Revoke(); + mEvent = event.forget(); + } + return *this; + } + void Revoke() { if (mEvent) { diff --git a/xpcom/glue/tests/gtest/TestThreadUtils.cpp b/xpcom/glue/tests/gtest/TestThreadUtils.cpp index ac4b9ef0d831..728bae612a5c 100644 --- a/xpcom/glue/tests/gtest/TestThreadUtils.cpp +++ b/xpcom/glue/tests/gtest/TestThreadUtils.cpp @@ -290,18 +290,18 @@ TEST(ThreadUtils, main) // Test legacy functions. nsCOMPtr r1 = - NS_NewRunnableMethod(rpt, &ThreadUtilsObject::Test0); + NewRunnableMethod(rpt, &ThreadUtilsObject::Test0); r1->Run(); EXPECT_EQ(count += 1, rpt->mCount); - r1 = NS_NewRunnableMethodWithArg(rpt, &ThreadUtilsObject::Test1i, 11); + r1 = NewRunnableMethod(rpt, &ThreadUtilsObject::Test1i, 11); r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); EXPECT_EQ(11, rpt->mA0); // Test variadic function with simple POD arguments. - r1 = NS_NewRunnableMethodWithArgs(rpt, &ThreadUtilsObject::Test0); + r1 = NewRunnableMethod(rpt, &ThreadUtilsObject::Test0); r1->Run(); EXPECT_EQ(count += 1, rpt->mCount); @@ -314,19 +314,19 @@ TEST(ThreadUtils, main) StoreCopyPassByValue>::value, "detail::ParameterStorage>::Type should be StoreCopyPassByValue"); - r1 = NS_NewRunnableMethodWithArgs(rpt, &ThreadUtilsObject::Test1i, 12); + r1 = NewRunnableMethod(rpt, &ThreadUtilsObject::Test1i, 12); r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); EXPECT_EQ(12, rpt->mA0); - r1 = NS_NewRunnableMethodWithArgs( + r1 = NewRunnableMethod( rpt, &ThreadUtilsObject::Test2i, 21, 22); r1->Run(); EXPECT_EQ(count += 3, rpt->mCount); EXPECT_EQ(21, rpt->mA0); EXPECT_EQ(22, rpt->mA1); - r1 = NS_NewRunnableMethodWithArgs( + r1 = NewRunnableMethod( rpt, &ThreadUtilsObject::Test3i, 31, 32, 33); r1->Run(); EXPECT_EQ(count += 4, rpt->mCount); @@ -334,7 +334,7 @@ TEST(ThreadUtils, main) EXPECT_EQ(32, rpt->mA1); EXPECT_EQ(33, rpt->mA2); - r1 = NS_NewRunnableMethodWithArgs( + r1 = NewRunnableMethod( rpt, &ThreadUtilsObject::Test4i, 41, 42, 43, 44); r1->Run(); EXPECT_EQ(count += 5, rpt->mCount); @@ -347,7 +347,7 @@ TEST(ThreadUtils, main) // Passing a short to make sure forwarding works with an inexact type match. short int si = 11; - r1 = NS_NewRunnableMethodWithArgs(rpt, &ThreadUtilsObject::Test1i, si); + r1 = NewRunnableMethod(rpt, &ThreadUtilsObject::Test1i, si); r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); EXPECT_EQ(si, rpt->mA0); @@ -373,7 +373,7 @@ TEST(ThreadUtils, main) "detail::ParameterStorage::Type::passed_type should be int*"); { int i = 12; - r1 = NS_NewRunnableMethodWithArgs(rpt, &ThreadUtilsObject::Test1pi, &i); + r1 = NewRunnableMethod(rpt, &ThreadUtilsObject::Test1pi, &i); r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); EXPECT_EQ(i, rpt->mA0); @@ -400,7 +400,7 @@ TEST(ThreadUtils, main) "detail::ParameterStorage::Type::passed_type should be const int*"); { int i = 1201; - r1 = NS_NewRunnableMethodWithArgs(rpt, &ThreadUtilsObject::Test1pci, &i); + r1 = NewRunnableMethod(rpt, &ThreadUtilsObject::Test1pci, &i); r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); EXPECT_EQ(i, rpt->mA0); @@ -415,7 +415,7 @@ TEST(ThreadUtils, main) "StoreCopyPassByPtr::passed_type should be int*"); { int i = 1202; - r1 = NS_NewRunnableMethodWithArgs>( + r1 = NewRunnableMethod>( rpt, &ThreadUtilsObject::Test1pi, i); r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); @@ -431,7 +431,7 @@ TEST(ThreadUtils, main) "StoreCopyPassByConstPtr::passed_type should be const int*"); { int i = 1203; - r1 = NS_NewRunnableMethodWithArgs>( + r1 = NewRunnableMethod>( rpt, &ThreadUtilsObject::Test1pci, i); r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); @@ -491,7 +491,7 @@ TEST(ThreadUtils, main) "ParameterStorage::Type::passed_type should be int&"); { int i = 13; - r1 = NS_NewRunnableMethodWithArgs(rpt, &ThreadUtilsObject::Test1ri, i); + r1 = NewRunnableMethod(rpt, &ThreadUtilsObject::Test1ri, i); r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); EXPECT_EQ(i, rpt->mA0); @@ -512,7 +512,7 @@ TEST(ThreadUtils, main) "ParameterStorage::Type::passed_type should be int&&"); { int i = 14; - r1 = NS_NewRunnableMethodWithArgs( + r1 = NewRunnableMethod( rpt, &ThreadUtilsObject::Test1rri, mozilla::Move(i)); } r1->Run(); @@ -534,7 +534,7 @@ TEST(ThreadUtils, main) "ParameterStorage&&>::Type::passed_type should be UniquePtr&&"); { mozilla::UniquePtr upi; - r1 = NS_NewRunnableMethodWithArgs&&>( + r1 = NewRunnableMethod&&>( rpt, &ThreadUtilsObject::Test1upi, mozilla::Move(upi)); } r1->Run(); @@ -557,7 +557,7 @@ TEST(ThreadUtils, main) "ParameterStorage>>::Type::passed_type should be UniquePtr&&"); { mozilla::UniquePtr upi; - r1 = NS_NewRunnableMethodWithArgs + r1 = NewRunnableMethod >>( rpt, &ThreadUtilsObject::Test1upi, mozilla::Move(upi)); } @@ -568,7 +568,7 @@ TEST(ThreadUtils, main) // Unique pointer as xvalue. { mozilla::UniquePtr upi = mozilla::MakeUnique(1); - r1 = NS_NewRunnableMethodWithArgs&&>( + r1 = NewRunnableMethod&&>( rpt, &ThreadUtilsObject::Test1upi, mozilla::Move(upi)); } r1->Run(); @@ -577,7 +577,7 @@ TEST(ThreadUtils, main) { mozilla::UniquePtr upi = mozilla::MakeUnique(1); - r1 = NS_NewRunnableMethodWithArgs + r1 = NewRunnableMethod >> (rpt, &ThreadUtilsObject::Test1upi, mozilla::Move(upi)); } @@ -586,7 +586,7 @@ TEST(ThreadUtils, main) EXPECT_EQ(1, rpt->mA0); // Unique pointer as prvalue. - r1 = NS_NewRunnableMethodWithArgs&&>( + r1 = NewRunnableMethod&&>( rpt, &ThreadUtilsObject::Test1upi, mozilla::MakeUnique(2)); r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); @@ -595,7 +595,7 @@ TEST(ThreadUtils, main) // Unique pointer as lvalue to lref. { mozilla::UniquePtr upi; - r1 = NS_NewRunnableMethodWithArgs&>( + r1 = NewRunnableMethod&>( rpt, &ThreadUtilsObject::Test1rupi, upi); // Passed as lref, so Run() must be called while local upi is still alive! r1->Run(); @@ -614,8 +614,8 @@ TEST(ThreadUtils, main) Spy s(10); EXPECT_EQ(1, gConstructions); EXPECT_EQ(1, gAlive); - if (gDebug) { printf("%d - r2 = NS_NewRunnableMethodWithArgs>(&TestByValue, s)\n", __LINE__); } - r2 = NS_NewRunnableMethodWithArgs>( + if (gDebug) { printf("%d - r2 = NewRunnableMethod>(&TestByValue, s)\n", __LINE__); } + r2 = NewRunnableMethod>( rpt, &ThreadUtilsObject::TestByValue, s); EXPECT_EQ(2, gAlive); EXPECT_LE(1, gCopyConstructions); // At least 1 copy-construction. @@ -641,9 +641,9 @@ TEST(ThreadUtils, main) Spy::ClearAll(); if (gDebug) { printf("%d - Test: Store copy from prvalue, pass by value\n", __LINE__); } { - if (gDebug) { printf("%d - r3 = NS_NewRunnableMethodWithArgs>(&TestByValue, Spy(11))\n", __LINE__); } + if (gDebug) { printf("%d - r3 = NewRunnableMethod>(&TestByValue, Spy(11))\n", __LINE__); } nsCOMPtr r3 = - NS_NewRunnableMethodWithArgs>( + NewRunnableMethod>( rpt, &ThreadUtilsObject::TestByValue, Spy(11)); EXPECT_EQ(1, gAlive); EXPECT_EQ(1, gConstructions); @@ -670,7 +670,7 @@ TEST(ThreadUtils, main) EXPECT_EQ(1, gConstructions); EXPECT_EQ(1, gAlive); Spy::ClearActions(); - r4 = NS_NewRunnableMethodWithArgs>( + r4 = NewRunnableMethod>( rpt, &ThreadUtilsObject::TestByValue, mozilla::Move(s)); EXPECT_LE(1, gMoveConstructions); EXPECT_EQ(1, gAlive); @@ -701,8 +701,8 @@ TEST(ThreadUtils, main) Spy s(20); EXPECT_EQ(1, gConstructions); EXPECT_EQ(1, gAlive); - if (gDebug) { printf("%d - r5 = NS_NewRunnableMethodWithArgs>(&TestByConstLRef, s)\n", __LINE__); } - r5 = NS_NewRunnableMethodWithArgs>( + if (gDebug) { printf("%d - r5 = NewRunnableMethod>(&TestByConstLRef, s)\n", __LINE__); } + r5 = NewRunnableMethod>( rpt, &ThreadUtilsObject::TestByConstLRef, s); EXPECT_EQ(2, gAlive); EXPECT_LE(1, gCopyConstructions); // At least 1 copy-construction. @@ -728,9 +728,9 @@ TEST(ThreadUtils, main) Spy::ClearAll(); if (gDebug) { printf("%d - Test: Store copy from prvalue, pass by const lvalue ref\n", __LINE__); } { - if (gDebug) { printf("%d - r6 = NS_NewRunnableMethodWithArgs>(&TestByConstLRef, Spy(21))\n", __LINE__); } + if (gDebug) { printf("%d - r6 = NewRunnableMethod>(&TestByConstLRef, Spy(21))\n", __LINE__); } nsCOMPtr r6 = - NS_NewRunnableMethodWithArgs>( + NewRunnableMethod>( rpt, &ThreadUtilsObject::TestByConstLRef, Spy(21)); EXPECT_EQ(1, gAlive); EXPECT_EQ(1, gConstructions); @@ -758,8 +758,8 @@ TEST(ThreadUtils, main) Spy s(30); EXPECT_EQ(1, gConstructions); EXPECT_EQ(1, gAlive); - if (gDebug) { printf("%d - r7 = NS_NewRunnableMethodWithArgs>(&TestByRRef, s)\n", __LINE__); } - r7 = NS_NewRunnableMethodWithArgs>( + if (gDebug) { printf("%d - r7 = NewRunnableMethod>(&TestByRRef, s)\n", __LINE__); } + r7 = NewRunnableMethod>( rpt, &ThreadUtilsObject::TestByRRef, s); EXPECT_EQ(2, gAlive); EXPECT_LE(1, gCopyConstructions); // At least 1 copy-construction. @@ -786,9 +786,9 @@ TEST(ThreadUtils, main) Spy::ClearAll(); if (gDebug) { printf("%d - Test: Store copy from prvalue, pass by rvalue ref\n", __LINE__); } { - if (gDebug) { printf("%d - r8 = NS_NewRunnableMethodWithArgs>(&TestByRRef, Spy(31))\n", __LINE__); } + if (gDebug) { printf("%d - r8 = NewRunnableMethod>(&TestByRRef, Spy(31))\n", __LINE__); } nsCOMPtr r8 = - NS_NewRunnableMethodWithArgs>( + NewRunnableMethod>( rpt, &ThreadUtilsObject::TestByRRef, Spy(31)); EXPECT_EQ(1, gAlive); EXPECT_EQ(1, gConstructions); @@ -816,9 +816,9 @@ TEST(ThreadUtils, main) EXPECT_EQ(1, gConstructions); EXPECT_EQ(1, gAlive); Spy::ClearActions(); - if (gDebug) { printf("%d - r9 = NS_NewRunnableMethodWithArgs(&TestByLRef, s)\n", __LINE__); } + if (gDebug) { printf("%d - r9 = NewRunnableMethod(&TestByLRef, s)\n", __LINE__); } nsCOMPtr r9 = - NS_NewRunnableMethodWithArgs( + NewRunnableMethod( rpt, &ThreadUtilsObject::TestByLRef, s); EXPECT_EQ(0, gAllConstructions); EXPECT_EQ(0, gDestructions); @@ -849,8 +849,8 @@ TEST(ThreadUtils, main) ptr = s.get(); EXPECT_EQ(1, gConstructions); EXPECT_EQ(1, gAlive); - if (gDebug) { printf("%d - r10 = NS_NewRunnableMethodWithArgs>(&TestByRRef, s.get())\n", __LINE__); } - r10 = NS_NewRunnableMethodWithArgs>( + if (gDebug) { printf("%d - r10 = NewRunnableMethod>(&TestByRRef, s.get())\n", __LINE__); } + r10 = NewRunnableMethod>( rpt, &ThreadUtilsObject::TestByPointer, s.get()); EXPECT_LE(0, gAllConstructions); EXPECT_EQ(1, gAlive); @@ -882,9 +882,9 @@ TEST(ThreadUtils, main) EXPECT_EQ(1, gConstructions); EXPECT_EQ(1, gAlive); Spy::ClearActions(); - if (gDebug) { printf("%d - r11 = NS_NewRunnableMethodWithArgs(&TestByPointer, s)\n", __LINE__); } + if (gDebug) { printf("%d - r11 = NewRunnableMethod(&TestByPointer, s)\n", __LINE__); } nsCOMPtr r11 = - NS_NewRunnableMethodWithArgs( + NewRunnableMethod( rpt, &ThreadUtilsObject::TestByPointer, &s); EXPECT_EQ(0, gAllConstructions); EXPECT_EQ(0, gDestructions); @@ -912,9 +912,9 @@ TEST(ThreadUtils, main) EXPECT_EQ(1, gConstructions); EXPECT_EQ(1, gAlive); Spy::ClearActions(); - if (gDebug) { printf("%d - r12 = NS_NewRunnableMethodWithArgs(&TestByPointer, s)\n", __LINE__); } + if (gDebug) { printf("%d - r12 = NewRunnableMethod(&TestByPointer, s)\n", __LINE__); } nsCOMPtr r12 = - NS_NewRunnableMethodWithArgs( + NewRunnableMethod( rpt, &ThreadUtilsObject::TestByPointerToConst, &s); EXPECT_EQ(0, gAllConstructions); EXPECT_EQ(0, gDestructions); diff --git a/xpcom/tests/TestThreadUtils.cpp b/xpcom/tests/TestThreadUtils.cpp index 494aa4c3e980..521933827555 100644 --- a/xpcom/tests/TestThreadUtils.cpp +++ b/xpcom/tests/TestThreadUtils.cpp @@ -5,6 +5,8 @@ #include "TestHarness.h" #include "nsThreadUtils.h" +using namespace mozilla; + enum { TEST_CALL_VOID_ARG_VOID_RETURN, TEST_CALL_VOID_ARG_VOID_RETURN_CONST, @@ -133,24 +135,24 @@ int main(int argc, char** argv) // Read only string. Dereferencing in runnable method to check this works. char* message = (char*)"Test message"; - NS_DispatchToMainThread(NS_NewRunnableMethod(bar, &nsBar::DoBar1)); - NS_DispatchToMainThread(NS_NewRunnableMethod(constBar, &nsBar::DoBar1Const)); - NS_DispatchToMainThread(NS_NewRunnableMethod(bar, &nsBar::DoBar2)); - NS_DispatchToMainThread(NS_NewRunnableMethodWithArg< RefPtr > + NS_DispatchToMainThread(NewRunnableMethod(bar, &nsBar::DoBar1)); + NS_DispatchToMainThread(NewRunnableMethod(constBar, &nsBar::DoBar1Const)); + NS_DispatchToMainThread(NewRunnableMethod(bar, &nsBar::DoBar2)); + NS_DispatchToMainThread(NewRunnableMethod> (bar, &nsBar::DoBar3, foo)); - NS_DispatchToMainThread(NS_NewRunnableMethodWithArg< RefPtr > + NS_DispatchToMainThread(NewRunnableMethod> (bar, &nsBar::DoBar4, foo)); - NS_DispatchToMainThread(NS_NewRunnableMethodWithArg(bar, &nsBar::DoBar5, rawFoo)); - NS_DispatchToMainThread(NS_NewRunnableMethodWithArg(bar, &nsBar::DoBar6, message)); + NS_DispatchToMainThread(NewRunnableMethod(bar, &nsBar::DoBar5, rawFoo)); + NS_DispatchToMainThread(NewRunnableMethod(bar, &nsBar::DoBar6, message)); #ifdef HAVE_STDCALL - NS_DispatchToMainThread(NS_NewRunnableMethod(bar, &nsBar::DoBar1std)); - NS_DispatchToMainThread(NS_NewRunnableMethod(bar, &nsBar::DoBar2std)); - NS_DispatchToMainThread(NS_NewRunnableMethodWithArg< RefPtr > + NS_DispatchToMainThread(NewRunnableMethod(bar, &nsBar::DoBar1std)); + NS_DispatchToMainThread(NewRunnableMethod(bar, &nsBar::DoBar2std)); + NS_DispatchToMainThread(NewRunnableMethod> (bar, &nsBar::DoBar3std, foo)); - NS_DispatchToMainThread(NS_NewRunnableMethodWithArg< RefPtr > + NS_DispatchToMainThread(NewRunnableMethod> (bar, &nsBar::DoBar4std, foo)); - NS_DispatchToMainThread(NS_NewRunnableMethodWithArg(bar, &nsBar::DoBar5std, rawFoo)); - NS_DispatchToMainThread(NS_NewRunnableMethodWithArg(bar, &nsBar::DoBar6std, message)); + NS_DispatchToMainThread(NewRunnableMethod(bar, &nsBar::DoBar5std, rawFoo)); + NS_DispatchToMainThread(NewRunnableMethod(bar, &nsBar::DoBar6std, message)); #endif } diff --git a/xpcom/threads/AbstractThread.cpp b/xpcom/threads/AbstractThread.cpp index 1aa8b4bd4dc1..4a78a742f57c 100644 --- a/xpcom/threads/AbstractThread.cpp +++ b/xpcom/threads/AbstractThread.cpp @@ -88,7 +88,7 @@ public: if (!mTailDispatcher.isSome()) { mTailDispatcher.emplace(/* aIsTailDispatcher = */ true); - nsCOMPtr event = NS_NewRunnableMethod(this, &XPCOMThreadWrapper::FireTailDispatcher); + nsCOMPtr event = NewRunnableMethod(this, &XPCOMThreadWrapper::FireTailDispatcher); nsContentUtils::RunInStableState(event.forget()); } diff --git a/xpcom/threads/LazyIdleThread.cpp b/xpcom/threads/LazyIdleThread.cpp index 43d8857aa190..535a48a8e4aa 100644 --- a/xpcom/threads/LazyIdleThread.cpp +++ b/xpcom/threads/LazyIdleThread.cpp @@ -163,7 +163,7 @@ LazyIdleThread::EnsureThread() } nsCOMPtr runnable = - NS_NewRunnableMethod(this, &LazyIdleThread::InitThread); + NewRunnableMethod(this, &LazyIdleThread::InitThread); if (NS_WARN_IF(!runnable)) { return NS_ERROR_UNEXPECTED; } @@ -291,7 +291,7 @@ LazyIdleThread::ShutdownThread() #endif nsCOMPtr runnable = - NS_NewRunnableMethod(this, &LazyIdleThread::CleanupThread); + NewRunnableMethod(this, &LazyIdleThread::CleanupThread); if (NS_WARN_IF(!runnable)) { return NS_ERROR_UNEXPECTED; } @@ -368,7 +368,7 @@ LazyIdleThread::Release() mRefCnt = 1; nsCOMPtr runnable = - NS_NewNonOwningRunnableMethod(this, &LazyIdleThread::SelfDestruct); + NewNonOwningRunnableMethod(this, &LazyIdleThread::SelfDestruct); NS_WARN_IF_FALSE(runnable, "Couldn't make runnable!"); if (NS_FAILED(NS_DispatchToCurrentThread(runnable))) { @@ -561,7 +561,7 @@ LazyIdleThread::AfterProcessNextEvent(nsIThreadInternal* /* aThread */, if (shouldNotifyIdle) { nsCOMPtr runnable = - NS_NewRunnableMethod(this, &LazyIdleThread::ScheduleTimer); + NewRunnableMethod(this, &LazyIdleThread::ScheduleTimer); if (NS_WARN_IF(!runnable)) { return NS_ERROR_UNEXPECTED; } diff --git a/xpcom/threads/SharedThreadPool.cpp b/xpcom/threads/SharedThreadPool.cpp index 4944e6fc684c..004a352135a3 100644 --- a/xpcom/threads/SharedThreadPool.cpp +++ b/xpcom/threads/SharedThreadPool.cpp @@ -141,10 +141,9 @@ NS_IMETHODIMP_(MozExternalRefCountType) SharedThreadPool::Release(void) MOZ_ASSERT(!sPools->Get(mName)); // Dispatch an event to the main thread to call Shutdown() on - // the nsIThreadPool. The Runnable here will add a refcount to the pool, + // the nsIThreadPool. The Runnable here will add a refcount to the pool, // and when the Runnable releases the nsIThreadPool it will be deleted. - nsCOMPtr r = NS_NewRunnableMethod(mPool, &nsIThreadPool::Shutdown); - NS_DispatchToMainThread(r); + NS_DispatchToMainThread(NewRunnableMethod(mPool, &nsIThreadPool::Shutdown)); // Stabilize refcount, so that if something in the dtor QIs, it won't explode. mRefCnt = 1; diff --git a/xpcom/threads/StateMirroring.h b/xpcom/threads/StateMirroring.h index bcb65fea381d..d004b6983ad0 100644 --- a/xpcom/threads/StateMirroring.h +++ b/xpcom/threads/StateMirroring.h @@ -152,9 +152,9 @@ private: { MIRROR_LOG("%s [%p] Disconnecting all mirrors", mName, this); for (size_t i = 0; i < mMirrors.Length(); ++i) { - nsCOMPtr r = - NS_NewRunnableMethod(mMirrors[i], &AbstractMirror::NotifyDisconnected); - mMirrors[i]->OwnerThread()->Dispatch(r.forget(), AbstractThread::DontAssertDispatchSuccess); + mMirrors[i]->OwnerThread()->Dispatch(NewRunnableMethod(mMirrors[i], + &AbstractMirror::NotifyDisconnected), + AbstractThread::DontAssertDispatchSuccess); } mMirrors.Clear(); } @@ -191,8 +191,7 @@ private: // we can avoid sending multiple updates, and possibly avoid sending any // updates at all if the value ends up where it started. if (!alreadyNotifying) { - nsCOMPtr r = NS_NewRunnableMethod(this, &Impl::DoNotify); - AbstractThread::DispatchDirectTask(r.forget()); + AbstractThread::DispatchDirectTask(NewRunnableMethod(this, &Impl::DoNotify)); } } @@ -223,9 +222,7 @@ private: already_AddRefed MakeNotifier(AbstractMirror* aMirror) { - nsCOMPtr r = - NS_NewRunnableMethodWithArg(aMirror, &AbstractMirror::UpdateValue, mValue); - return r.forget(); + return NewRunnableMethod(aMirror, &AbstractMirror::UpdateValue, mValue);; } T mValue; @@ -328,7 +325,7 @@ private: MOZ_ASSERT(!IsConnected()); MOZ_ASSERT(OwnerThread()->RequiresTailDispatch(aCanonical->OwnerThread()), "Can't get coherency without tail dispatch"); - nsCOMPtr r = NS_NewRunnableMethodWithArg>> + nsCOMPtr r = NewRunnableMethod>> (aCanonical, &AbstractCanonical::AddMirror, this); aCanonical->OwnerThread()->Dispatch(r.forget(), AbstractThread::DontAssertDispatchSuccess); mCanonical = aCanonical; @@ -343,7 +340,7 @@ private: } MIRROR_LOG("%s [%p] Disconnecting from %p", mName, this, mCanonical.get()); - nsCOMPtr r = NS_NewRunnableMethodWithArg>> + nsCOMPtr r = NewRunnableMethod>> (mCanonical, &AbstractCanonical::RemoveMirror, this); mCanonical->OwnerThread()->Dispatch(r.forget(), AbstractThread::DontAssertDispatchSuccess); mCanonical = nullptr; diff --git a/xpcom/threads/StateWatching.h b/xpcom/threads/StateWatching.h index 3ad8c2184051..a5543120b610 100644 --- a/xpcom/threads/StateWatching.h +++ b/xpcom/threads/StateWatching.h @@ -255,8 +255,7 @@ private: mStrongRef = mOwner; // Hold the owner alive while notifying. // Queue up our notification jobs to run in a stable state. - nsCOMPtr r = NS_NewRunnableMethod(this, &PerCallbackWatcher::DoNotify); - mOwnerThread->TailDispatcher().AddDirectTask(r.forget()); + mOwnerThread->TailDispatcher().AddDirectTask(NewRunnableMethod(this, &PerCallbackWatcher::DoNotify)); } bool CallbackMethodIs(CallbackMethod aMethod) const diff --git a/xpcom/threads/nsProcessCommon.cpp b/xpcom/threads/nsProcessCommon.cpp index efb5d4a138fd..9e714b40a794 100644 --- a/xpcom/threads/nsProcessCommon.cpp +++ b/xpcom/threads/nsProcessCommon.cpp @@ -301,9 +301,7 @@ nsProcess::Monitor(void* aArg) if (NS_IsMainThread()) { process->ProcessComplete(); } else { - nsCOMPtr event = - NS_NewRunnableMethod(process, &nsProcess::ProcessComplete); - NS_DispatchToMainThread(event); + NS_DispatchToMainThread(NewRunnableMethod(process, &nsProcess::ProcessComplete)); } } diff --git a/xpcom/threads/nsThreadPool.cpp b/xpcom/threads/nsThreadPool.cpp index 8be613d57823..0b4ac6047aac 100644 --- a/xpcom/threads/nsThreadPool.cpp +++ b/xpcom/threads/nsThreadPool.cpp @@ -146,9 +146,8 @@ nsThreadPool::ShutdownThread(nsIThread* aThread) // shutdown requires this thread have an event loop (and it may not, see bug // 10204784). The simplest way to cover all cases is to asynchronously // shutdown aThread from the main thread. - nsCOMPtr r = NS_NewRunnableMethod(aThread, - &nsIThread::AsyncShutdown); - NS_DispatchToMainThread(r); + NS_DispatchToMainThread(NewRunnableMethod(aThread, + &nsIThread::AsyncShutdown)); } NS_IMETHODIMP