From 67e8af4720a739342a2eb80055b1dcc6d9edd9df Mon Sep 17 00:00:00 2001 From: Bill McCloskey Date: Mon, 12 Jun 2017 12:34:10 -0700 Subject: [PATCH] Bug 1372405 - Provide names for all runnables in the tree (r=froydnj) MozReview-Commit-ID: DKR6ROiHRS7 --- accessible/generic/Accessible.cpp | 9 +- accessible/generic/DocAccessible.cpp | 9 +- accessible/ipc/win/HandlerProvider.cpp | 9 +- accessible/windows/msaa/AccessibleWrap.cpp | 3 +- accessible/windows/msaa/LazyInstantiator.cpp | 7 +- accessible/xpcom/xpcAccessibilityService.cpp | 8 +- docshell/base/nsDocShell.cpp | 43 ++- docshell/base/nsDocShell.h | 6 +- docshell/base/nsDocShellTreeOwner.cpp | 8 +- docshell/shistory/nsSHEntryShared.cpp | 3 +- dom/animation/Animation.cpp | 4 +- dom/asmjscache/AsmJSCache.cpp | 11 +- dom/audiochannel/AudioChannelService.cpp | 36 +- dom/base/CustomElementRegistry.cpp | 5 +- dom/base/CustomElementRegistry.h | 7 +- dom/base/DOMRequest.cpp | 16 +- dom/base/Element.cpp | 16 +- dom/base/EventSource.cpp | 39 +- dom/base/ImageEncoder.cpp | 6 +- dom/base/PostMessageEvent.cpp | 18 +- dom/base/ScreenOrientation.cpp | 12 +- dom/base/Selection.h | 12 +- dom/base/WebSocket.cpp | 12 +- dom/base/nsContentSink.cpp | 5 +- dom/base/nsContentUtils.cpp | 14 +- dom/base/nsDOMMutationObserver.cpp | 1 + dom/base/nsDOMWindowUtils.cpp | 107 ++++-- .../nsDocElementCreatedNotificationRunner.h | 3 +- dom/base/nsDocument.cpp | 75 +++- dom/base/nsFocusManager.cpp | 31 +- dom/base/nsFrameLoader.cpp | 14 +- dom/base/nsFrameMessageManager.cpp | 1 + dom/base/nsGlobalWindow.cpp | 85 +++-- dom/base/nsIGlobalObject.cpp | 1 + dom/base/nsInProcessTabChildGlobal.cpp | 12 +- dom/base/nsJSEnvironment.cpp | 12 +- dom/base/nsJSEnvironment.h | 3 +- dom/base/nsObjectLoadingContent.cpp | 6 +- dom/base/nsReferencedElement.h | 8 +- dom/base/nsTextNode.cpp | 3 +- dom/cache/Context.cpp | 13 +- dom/cache/Manager.cpp | 8 +- dom/cache/PrincipalVerifier.cpp | 3 +- dom/cache/ReadStream.cpp | 6 +- dom/canvas/CanvasRenderingContext2D.cpp | 5 +- dom/canvas/ImageBitmap.cpp | 18 +- dom/canvas/WebGLContext.cpp | 7 +- dom/canvas/WebGLQuery.cpp | 15 +- dom/events/AsyncEventDispatcher.cpp | 5 +- dom/events/AsyncEventDispatcher.h | 21 +- dom/events/DataTransferItem.cpp | 7 +- dom/events/EventStateManager.cpp | 9 +- dom/events/TextComposition.cpp | 13 +- dom/events/TextComposition.h | 4 +- dom/events/WheelHandlingHelper.cpp | 7 +- dom/fetch/Fetch.cpp | 6 +- dom/fetch/FetchConsumer.cpp | 3 +- dom/fetch/FetchDriver.cpp | 3 +- dom/file/MutableBlobStorage.cpp | 30 +- dom/file/ipc/IPCBlobInputStream.cpp | 3 +- dom/file/ipc/IPCBlobInputStreamChild.cpp | 15 +- dom/file/ipc/IPCBlobInputStreamThread.cpp | 5 +- dom/filehandle/ActorsParent.cpp | 12 +- dom/filesystem/FileSystemRequestParent.cpp | 3 +- dom/filesystem/FileSystemTaskBase.cpp | 10 +- dom/filesystem/GetFilesHelper.cpp | 1 + dom/flyweb/HttpServer.cpp | 35 +- dom/gamepad/cocoa/CocoaGamepad.cpp | 2 +- dom/gamepad/ipc/GamepadEventChannelChild.cpp | 21 +- dom/gamepad/ipc/GamepadEventChannelParent.cpp | 13 +- dom/gamepad/windows/WindowsGamepad.cpp | 8 +- dom/geolocation/nsGeolocation.cpp | 13 +- dom/html/HTMLCanvasElement.cpp | 35 +- dom/html/HTMLFormElement.h | 3 +- dom/html/HTMLImageElement.cpp | 27 +- dom/html/HTMLInputElement.cpp | 4 +- dom/html/HTMLLinkElement.cpp | 3 +- dom/html/HTMLMediaElement.cpp | 147 ++++---- dom/html/HTMLObjectElement.cpp | 7 +- dom/html/HTMLSharedObjectElement.cpp | 3 +- dom/html/HTMLStyleElement.cpp | 3 +- dom/html/HTMLTrackElement.cpp | 15 +- dom/html/ImageDocument.cpp | 8 +- dom/html/TextTrackManager.cpp | 41 ++- dom/html/nsGenericHTMLElement.cpp | 6 +- dom/html/nsHTMLDocument.cpp | 11 +- dom/html/nsTextEditorState.cpp | 16 +- dom/indexedDB/ActorsParent.cpp | 52 ++- dom/indexedDB/FileInfo.cpp | 3 +- dom/indexedDB/IDBDatabase.cpp | 6 +- dom/indexedDB/ScriptErrorHelper.cpp | 6 +- dom/ipc/ContentBridgeChild.cpp | 5 +- dom/ipc/ContentBridgeParent.cpp | 8 +- dom/ipc/ContentChild.cpp | 10 +- dom/ipc/ContentParent.cpp | 37 +- dom/ipc/FilePickerParent.cpp | 7 +- dom/ipc/PreallocatedProcessManager.cpp | 9 +- dom/ipc/ProcessHangMonitor.cpp | 75 ++-- dom/ipc/TabParent.cpp | 9 +- dom/jsurl/nsJSProtocolHandler.cpp | 3 +- dom/media/Benchmark.cpp | 14 +- dom/media/CanvasCaptureMediaStream.cpp | 6 +- dom/media/CubebUtils.cpp | 3 +- dom/media/DOMMediaStream.cpp | 52 ++- dom/media/EncodedBufferCache.cpp | 4 +- dom/media/FileBlockCache.cpp | 56 +-- dom/media/GraphDriver.cpp | 26 +- dom/media/Latency.cpp | 28 +- dom/media/MediaDecoder.cpp | 60 ++-- dom/media/MediaDecoderReader.cpp | 11 +- dom/media/MediaDecoderReaderWrapper.cpp | 11 +- dom/media/MediaDecoderStateMachine.cpp | 45 ++- dom/media/MediaDecoderStateMachine.h | 20 +- dom/media/MediaEventSource.h | 8 +- dom/media/MediaFormatReader.cpp | 34 +- dom/media/MediaManager.cpp | 97 +++-- dom/media/MediaManager.h | 10 +- dom/media/MediaRecorder.cpp | 33 +- dom/media/MediaResource.cpp | 9 +- dom/media/MediaStreamGraph.cpp | 7 +- dom/media/MediaStreamTrack.cpp | 6 +- dom/media/MediaTimer.cpp | 11 +- dom/media/TextTrack.cpp | 10 +- dom/media/TextTrackList.cpp | 3 +- dom/media/VideoUtils.cpp | 4 +- dom/media/VideoUtils.h | 13 +- dom/media/android/AndroidMediaPluginHost.cpp | 2 +- .../android/AndroidMediaResourceServer.cpp | 11 +- dom/media/eme/mediadrm/MediaDrmCDMProxy.cpp | 21 +- dom/media/eme/mediadrm/MediaDrmCDMProxy.h | 3 +- dom/media/gmp/ChromiumCDMParent.cpp | 35 +- dom/media/gmp/ChromiumCDMProxy.cpp | 57 +-- dom/media/gmp/GMPCDMCallbackProxy.cpp | 132 +++---- dom/media/gmp/GMPCDMProxy.cpp | 35 +- dom/media/gmp/GMPCDMProxy.h | 3 +- dom/media/gmp/GMPContentParent.cpp | 7 +- dom/media/gmp/GMPCrashHelper.cpp | 8 +- 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/GMPServiceChild.cpp | 5 +- dom/media/gmp/GMPServiceParent.cpp | 64 ++-- dom/media/gmp/GMPServiceParent.h | 9 +- dom/media/gmp/GMPTimerParent.cpp | 10 +- dom/media/gmp/GMPVideoDecoderChild.cpp | 4 +- dom/media/gmp/GMPVideoDecoderParent.cpp | 15 +- dom/media/gmp/GMPVideoEncoderChild.cpp | 4 +- dom/media/gtest/GMPTestMonitor.h | 3 +- dom/media/gtest/TestGMPCrossOrigin.cpp | 146 +++++--- dom/media/gtest/TestGMPRemoveAndDelete.cpp | 41 ++- dom/media/gtest/TestMP4Demuxer.cpp | 3 +- dom/media/hls/HLSDemuxer.cpp | 4 +- dom/media/imagecapture/CaptureTask.cpp | 5 +- dom/media/ipc/RemoteVideoDecoder.cpp | 35 +- dom/media/ipc/VideoDecoderChild.cpp | 35 +- dom/media/ipc/VideoDecoderManagerChild.cpp | 48 ++- dom/media/ipc/VideoDecoderManagerParent.cpp | 34 +- dom/media/mediasink/DecodedStream.cpp | 24 +- dom/media/mediasource/AsyncEventRunner.h | 3 +- dom/media/mediasource/AutoTaskQueue.h | 3 +- dom/media/mediasource/MediaSourceDemuxer.cpp | 45 +-- dom/media/mediasource/TrackBuffersManager.cpp | 49 ++- dom/media/ogg/OggDemuxer.cpp | 22 +- dom/media/platforms/PDMFactory.cpp | 2 +- .../platforms/android/RemoteDataDecoder.cpp | 12 +- dom/media/platforms/omx/OmxDataDecoder.cpp | 17 +- .../platforms/wmf/WMFAudioMFTManager.cpp | 3 +- .../platforms/wmf/WMFMediaDataDecoder.cpp | 4 +- .../platforms/wmf/WMFVideoMFTManager.cpp | 9 +- .../wrappers/MediaDataDecoderProxy.cpp | 1 + dom/media/systemservices/CamerasChild.cpp | 109 ++++-- dom/media/systemservices/CamerasParent.cpp | 31 +- .../MediaSystemResourceManager.cpp | 27 +- dom/media/systemservices/MediaTaskUtils.h | 7 +- dom/media/systemservices/MediaUtils.h | 7 +- dom/media/webaudio/AnalyserNode.cpp | 6 +- dom/media/webaudio/AudioBufferSourceNode.cpp | 5 +- dom/media/webaudio/AudioDestinationNode.cpp | 15 +- dom/media/webaudio/AudioNode.cpp | 5 +- dom/media/webaudio/ConstantSourceNode.cpp | 5 +- dom/media/webaudio/DynamicsCompressorNode.cpp | 3 +- dom/media/webaudio/MediaBufferDecoder.cpp | 28 +- dom/media/webaudio/OscillatorNode.cpp | 5 +- dom/media/webaudio/PlayingRefChangeHandler.h | 3 +- dom/media/webaudio/ScriptProcessorNode.cpp | 3 +- dom/media/webaudio/WebAudioUtils.cpp | 5 +- .../webaudio/blink/HRTFDatabaseLoader.cpp | 14 +- dom/media/webaudio/blink/ReverbConvolver.cpp | 6 +- dom/media/webrtc/MediaEngineTabVideoSource.h | 20 +- .../webspeech/recognition/SpeechRecognition.h | 16 +- .../cocoa/OSXSpeechSynthesizerService.mm | 6 +- dom/media/webspeech/synth/nsSpeechTask.cpp | 12 +- .../webspeech/synth/pico/nsPicoService.cpp | 5 +- .../synth/speechd/SpeechDispatcherService.cpp | 30 +- .../synth/test/nsFakeSynthServices.cpp | 26 +- dom/messagechannel/MessagePort.cpp | 3 +- dom/network/UDPSocket.cpp | 4 +- dom/notification/DesktopNotification.cpp | 3 +- dom/payments/ipc/PaymentRequestParent.cpp | 3 +- dom/performance/Performance.cpp | 3 +- dom/plugins/base/nsNPAPIPluginInstance.cpp | 9 +- dom/plugins/ipc/ChildAsyncCall.cpp | 6 +- dom/plugins/ipc/PluginInstanceChild.cpp | 17 +- dom/plugins/ipc/PluginProcessParent.cpp | 5 +- dom/plugins/ipc/PluginProcessParent.h | 7 +- dom/presentation/PresentationAvailability.cpp | 9 +- dom/presentation/PresentationCallbacks.cpp | 11 +- dom/presentation/PresentationConnection.cpp | 9 +- .../PresentationDeviceManager.cpp | 4 +- dom/presentation/PresentationReceiver.cpp | 7 +- dom/presentation/PresentationRequest.cpp | 12 +- dom/presentation/PresentationService.cpp | 13 +- dom/presentation/PresentationSessionInfo.cpp | 24 +- .../PresentationTCPSessionTransport.cpp | 27 +- .../ipc/PresentationIPCService.cpp | 14 +- .../provider/MulticastDNSDeviceProvider.cpp | 6 +- dom/promise/PromiseDebugging.cpp | 2 + dom/push/PushManager.cpp | 6 +- dom/push/PushSubscription.cpp | 6 +- dom/quota/ActorsParent.cpp | 37 +- dom/quota/QuotaManagerService.cpp | 3 +- dom/script/ScriptLoader.cpp | 21 +- dom/security/nsCSPContext.cpp | 3 +- dom/security/nsMixedContentBlocker.cpp | 9 +- dom/smil/nsSMILTimedElement.cpp | 6 +- dom/storage/LocalStorageCache.cpp | 8 +- dom/storage/StorageDBThread.cpp | 6 +- dom/storage/StorageIPC.cpp | 33 +- dom/svg/SVGFEImageElement.cpp | 4 +- dom/svg/SVGImageElement.cpp | 4 +- dom/svg/SVGStyleElement.cpp | 3 +- dom/system/nsDeviceSensors.cpp | 8 +- dom/u2f/U2F.cpp | 24 +- dom/url/URLMainThread.cpp | 4 +- dom/url/URLWorker.cpp | 3 +- dom/webauthn/U2FSoftTokenManager.cpp | 2 + .../WebBrowserPersistDocumentParent.cpp | 8 +- .../WebBrowserPersistResourcesParent.cpp | 11 +- .../WebBrowserPersistSerializeParent.cpp | 17 +- dom/webbrowserpersist/nsWebBrowserPersist.cpp | 20 +- dom/workers/RuntimeService.cpp | 5 +- dom/workers/ScriptLoader.cpp | 3 +- dom/workers/ServiceWorkerClient.cpp | 4 +- dom/workers/ServiceWorkerClients.cpp | 23 +- dom/workers/ServiceWorkerEvents.cpp | 16 +- dom/workers/ServiceWorkerInfo.cpp | 3 +- dom/workers/ServiceWorkerManager.cpp | 66 ++-- dom/workers/ServiceWorkerManagerParent.cpp | 9 +- dom/workers/ServiceWorkerManagerService.cpp | 19 +- dom/workers/ServiceWorkerPrivate.cpp | 38 +- dom/workers/ServiceWorkerPrivate.h | 2 + dom/workers/ServiceWorkerRegistrar.cpp | 14 +- dom/workers/ServiceWorkerRegistration.cpp | 20 +- dom/workers/ServiceWorkerRegistrationInfo.cpp | 28 +- dom/workers/ServiceWorkerUpdateJob.cpp | 9 +- dom/workers/ServiceWorkerWindowClient.cpp | 9 +- dom/workers/WorkerDebuggerManager.cpp | 8 +- dom/workers/WorkerPrivate.cpp | 33 +- dom/workers/WorkerRunnable.cpp | 16 +- dom/workers/WorkerScope.cpp | 6 +- dom/xbl/nsBindingManager.cpp | 8 +- dom/xhr/XMLHttpRequestMainThread.cpp | 14 +- dom/xhr/XMLHttpRequestWorker.cpp | 13 +- .../XMLStylesheetProcessingInstruction.cpp | 3 +- dom/xml/nsXMLContentSink.cpp | 6 +- dom/xml/nsXMLPrettyPrinter.cpp | 4 +- dom/xslt/xslt/txMozillaXSLTProcessor.cpp | 3 +- dom/xul/XULDocument.cpp | 18 +- dom/xul/nsXULElement.cpp | 69 ++-- dom/xul/templates/nsXULTemplateBuilder.cpp | 20 +- editor/composer/nsEditingSession.cpp | 10 +- editor/composer/nsEditorSpellCheck.cpp | 5 +- editor/libeditor/EditorBase.cpp | 3 +- editor/libeditor/HTMLEditRules.cpp | 4 +- editor/libeditor/HTMLEditor.cpp | 12 +- extensions/auth/nsHttpNegotiateAuth.cpp | 40 +-- .../spellcheck/src/mozPersonalDictionary.cpp | 15 +- gfx/ipc/GPUChild.cpp | 3 +- gfx/ipc/GPUParent.cpp | 7 +- gfx/ipc/VsyncBridgeChild.cpp | 15 +- gfx/ipc/VsyncBridgeParent.cpp | 9 +- gfx/ipc/VsyncIOThreadHolder.cpp | 3 +- gfx/layers/AsyncCanvasRenderer.cpp | 6 +- gfx/layers/ImageContainer.h | 14 +- gfx/layers/LayerScope.cpp | 7 +- gfx/layers/apz/src/APZCTreeManager.cpp | 25 +- gfx/layers/apz/src/AndroidAPZ.cpp | 3 +- .../apz/src/AndroidDynamicToolbarAnimator.cpp | 41 ++- gfx/layers/apz/src/AsyncPanZoomController.cpp | 48 ++- gfx/layers/apz/src/GenericFlingAnimation.h | 25 +- gfx/layers/apz/src/GestureEventListener.cpp | 15 +- gfx/layers/apz/src/InputQueue.cpp | 10 +- gfx/layers/apz/src/Overscroll.h | 5 +- gfx/layers/apz/util/ActiveElementManager.cpp | 8 +- .../apz/util/CheckerboardReportService.cpp | 7 +- .../apz/util/ChromeProcessController.cpp | 76 ++-- gfx/layers/basic/BasicCompositor.cpp | 6 +- gfx/layers/client/CompositableClient.cpp | 4 +- gfx/layers/client/TextureClient.cpp | 8 +- gfx/layers/client/TextureClient.h | 6 +- gfx/layers/client/TextureClientPool.cpp | 16 +- gfx/layers/d3d11/DeviceAttachmentsD3D11.cpp | 3 +- gfx/layers/ipc/APZCTreeManagerParent.cpp | 49 +-- gfx/layers/ipc/CompositorBridgeChild.cpp | 1 + gfx/layers/ipc/CompositorBridgeParent.cpp | 68 +++- gfx/layers/ipc/CompositorManagerParent.cpp | 1 + gfx/layers/ipc/CompositorVsyncScheduler.cpp | 14 +- .../CrossProcessCompositorBridgeParent.cpp | 5 +- gfx/layers/ipc/ImageBridgeChild.cpp | 6 +- gfx/layers/ipc/ImageBridgeParent.cpp | 15 +- gfx/layers/ipc/RemoteContentController.cpp | 68 ++-- gfx/layers/ipc/ShadowLayers.cpp | 7 +- ...SafeRefcountingWithMainThreadDestruction.h | 6 +- .../ipc/UiCompositorControllerChild.cpp | 20 +- .../ipc/UiCompositorControllerParent.cpp | 20 +- gfx/src/gfxCrashReporterUtils.cpp | 4 +- gfx/thebes/DeviceManagerDx.cpp | 3 +- gfx/thebes/SoftwareVsyncSource.cpp | 17 +- gfx/thebes/gfxFcPlatformFontList.cpp | 10 +- gfx/thebes/gfxFont.cpp | 10 +- gfx/thebes/gfxFontInfoLoader.cpp | 30 +- gfx/thebes/gfxPlatform.cpp | 23 +- gfx/thebes/gfxPlatformGtk.cpp | 11 +- gfx/thebes/gfxWindowsPlatform.cpp | 6 +- gfx/vr/gfxVROculus.cpp | 15 +- gfx/vr/gfxVROpenVR.cpp | 9 +- gfx/vr/ipc/VRManagerChild.cpp | 20 +- gfx/vr/ipc/VRManagerParent.cpp | 15 +- gfx/webrender_bindings/RenderThread.cpp | 27 +- image/DecodePool.cpp | 3 +- image/Image.cpp | 13 +- image/ProgressTracker.cpp | 3 +- image/RasterImage.cpp | 3 +- image/test/gtest/TestDecodeToSurface.cpp | 3 +- ipc/chromium/src/base/message_loop.h | 1 + ipc/chromium/src/base/object_watcher.cc | 2 + ipc/chromium/src/base/task.h | 36 +- ipc/chromium/src/base/thread.cc | 1 + ipc/chromium/src/base/timer.h | 7 +- .../common/process_watcher_posix_sigchld.cc | 4 +- .../src/chrome/common/process_watcher_win.cc | 2 +- ipc/glue/BackgroundImpl.cpp | 12 +- ipc/glue/BackgroundParentImpl.cpp | 6 +- ipc/glue/CrashReporterHost.cpp | 8 +- ipc/glue/GeckoChildProcessHost.cpp | 33 +- ipc/glue/IPCStreamDestination.cpp | 9 +- ipc/glue/MessageChannel.cpp | 36 +- ipc/glue/MessageLink.cpp | 29 +- ipc/glue/MessagePump.cpp | 3 +- ipc/glue/TaskFactory.h | 11 +- ipc/ipdl/test/cxx/TestCancel.cpp | 6 +- ipc/ipdl/test/cxx/TestDemon.cpp | 10 +- ipc/ipdl/test/cxx/TestEndpointBridgeMain.cpp | 4 +- ipc/ipdl/test/cxx/TestEndpointOpens.cpp | 8 +- ipc/ipdl/test/cxx/TestHangs.cpp | 4 +- ipc/ipdl/test/cxx/TestInterruptRaces.cpp | 16 +- .../test/cxx/TestInterruptShutdownRace.cpp | 7 +- ipc/ipdl/test/cxx/TestNestedLoops.cpp | 6 +- ipc/ipdl/test/cxx/TestUrgentHangs.cpp | 18 +- ipc/mscom/DispatchForwarder.cpp | 4 +- ipc/mscom/EnsureMTA.cpp | 3 +- ipc/mscom/EnsureMTA.h | 5 +- ipc/mscom/Interceptor.cpp | 2 +- ipc/mscom/InterceptorLog.cpp | 11 +- ipc/mscom/MainThreadHandoff.cpp | 5 +- ipc/mscom/MainThreadInvoker.h | 5 +- ipc/mscom/Ptr.h | 3 +- js/xpconnect/loader/ChromeScriptLoader.cpp | 14 +- js/xpconnect/loader/ScriptPreloader.cpp | 10 +- js/xpconnect/loader/mozJSSubScriptLoader.cpp | 8 +- js/xpconnect/src/XPCComponents.cpp | 6 +- js/xpconnect/src/XPCJSRuntime.cpp | 10 +- layout/base/AccessibleCaretEventHub.cpp | 16 +- layout/base/PresShell.cpp | 13 +- layout/base/ZoomConstraintsClient.cpp | 4 +- layout/base/nsLayoutUtils.cpp | 23 +- layout/base/nsPresContext.cpp | 24 +- layout/base/nsRefreshDriver.cpp | 38 +- layout/forms/nsComboboxControlFrame.cpp | 15 +- layout/forms/nsComboboxControlFrame.h | 6 +- layout/forms/nsDateTimeControlFrame.cpp | 4 +- layout/forms/nsDateTimeControlFrame.h | 3 +- layout/forms/nsFileControlFrame.h | 3 +- layout/forms/nsNumberControlFrame.cpp | 5 +- layout/forms/nsNumberControlFrame.h | 3 +- layout/forms/nsTextControlFrame.h | 14 +- layout/generic/nsGfxScrollFrame.cpp | 17 +- layout/generic/nsGfxScrollFrame.h | 12 +- layout/generic/nsPluginFrame.h | 9 +- layout/generic/nsSubDocumentFrame.cpp | 15 +- layout/generic/nsVideoFrame.cpp | 5 +- layout/ipc/VsyncParent.cpp | 3 +- layout/printing/nsPrintEngine.cpp | 6 +- layout/style/FontFaceSet.cpp | 4 +- layout/style/nsFontFaceLoader.cpp | 10 +- layout/style/nsStyleStruct.cpp | 4 +- layout/svg/SVGTextFrame.h | 6 +- layout/tables/nsTableFrame.cpp | 7 +- layout/xul/nsImageBoxFrame.cpp | 8 +- layout/xul/nsListBoxBodyFrame.h | 8 +- layout/xul/nsMenuBarFrame.cpp | 11 +- layout/xul/nsMenuFrame.cpp | 11 +- layout/xul/nsMenuPopupFrame.h | 6 +- layout/xul/nsProgressMeterFrame.cpp | 14 +- layout/xul/nsSliderFrame.cpp | 15 +- layout/xul/nsXULPopupManager.h | 50 +-- layout/xul/tree/nsTreeBodyFrame.cpp | 6 +- layout/xul/tree/nsTreeBodyFrame.h | 6 +- media/mtransport/nr_socket_prsock.cpp | 2 +- media/mtransport/runnable_utils.h | 2 + media/mtransport/test/TestSyncRunnable.cpp | 2 +- .../test/sockettransportservice_unittest.cpp | 4 +- .../src/media-conduit/WebrtcGmpVideoCodec.h | 1 + .../WebrtcMediaCodecVP8VideoCodec.cpp | 3 +- .../src/mediapipeline/MediaPipeline.cpp | 1 + .../src/mediapipeline/MediaPipeline.h | 1 + modules/libjar/nsJARChannel.cpp | 3 +- modules/libpref/Preferences.cpp | 11 +- netwerk/base/BackgroundFileSaver.cpp | 21 +- netwerk/base/Dashboard.cpp | 48 ++- netwerk/base/NetworkActivityMonitor.cpp | 3 +- netwerk/base/Predictor.cpp | 14 +- netwerk/base/TLSServerSocket.cpp | 10 +- netwerk/base/Tickler.cpp | 6 +- netwerk/base/nsAsyncStreamCopier.cpp | 10 +- netwerk/base/nsBaseChannel.cpp | 7 +- netwerk/base/nsBaseChannel.h | 4 +- netwerk/base/nsIOService.cpp | 13 +- netwerk/base/nsInputStreamPump.cpp | 4 +- netwerk/base/nsPACMan.cpp | 37 +- netwerk/base/nsPreloadedStream.cpp | 20 +- netwerk/base/nsRequestObserverProxy.cpp | 5 +- netwerk/base/nsServerSocket.cpp | 26 +- netwerk/base/nsSocketTransport2.cpp | 32 +- netwerk/base/nsSocketTransportService2.cpp | 42 ++- netwerk/base/nsStreamTransportService.cpp | 23 +- netwerk/base/nsUDPSocket.cpp | 43 ++- netwerk/cache/nsCacheEntryDescriptor.cpp | 1 + netwerk/cache/nsCacheService.cpp | 199 ++++++----- netwerk/cache/nsCacheService.h | 21 +- netwerk/cache/nsCacheUtils.cpp | 10 +- netwerk/cache/nsDeleteDir.cpp | 12 +- netwerk/cache/nsDiskCacheDevice.cpp | 34 +- netwerk/cache/nsDiskCacheDeviceSQL.cpp | 12 +- netwerk/cache/nsDiskCacheMap.cpp | 10 +- netwerk/cache2/CacheEntry.cpp | 12 +- netwerk/cache2/CacheEntry.h | 6 +- netwerk/cache2/CacheFile.cpp | 12 +- netwerk/cache2/CacheFileChunk.cpp | 10 +- netwerk/cache2/CacheFileContextEvictor.cpp | 4 +- netwerk/cache2/CacheFileIOManager.cpp | 156 +++++--- netwerk/cache2/CacheIndex.cpp | 30 +- netwerk/cache2/CacheIndex.h | 7 +- netwerk/cache2/CacheObserver.cpp | 12 +- netwerk/cache2/CacheStorageService.cpp | 37 +- netwerk/cache2/CacheStorageService.h | 13 +- netwerk/cache2/OldWrappers.cpp | 10 +- netwerk/dns/DNSRequestChild.cpp | 11 +- .../mdns/libmdns/MDNSResponderOperator.cpp | 17 +- .../dns/mdns/libmdns/MDNSResponderReply.cpp | 12 +- netwerk/dns/nsDNSService2.cpp | 7 +- netwerk/ipc/ChannelEventQueue.cpp | 3 +- netwerk/protocol/about/nsAboutCache.cpp | 5 +- netwerk/protocol/file/nsFileChannel.cpp | 12 +- netwerk/protocol/ftp/FTPChannelParent.cpp | 9 +- netwerk/protocol/ftp/nsFTPChannel.cpp | 18 +- .../protocol/ftp/nsFtpConnectionThread.cpp | 9 +- netwerk/protocol/ftp/nsFtpProtocolHandler.cpp | 10 +- netwerk/protocol/gio/nsGIOProtocolHandler.cpp | 6 +- netwerk/protocol/http/AlternateServices.cpp | 24 +- netwerk/protocol/http/Http2Push.cpp | 15 +- netwerk/protocol/http/Http2Session.cpp | 11 +- .../http/HttpBackgroundChannelChild.cpp | 55 ++- .../http/HttpBackgroundChannelParent.cpp | 98 +++-- netwerk/protocol/http/HttpBaseChannel.cpp | 5 +- netwerk/protocol/http/HttpBaseChannel.h | 3 +- netwerk/protocol/http/HttpChannelChild.cpp | 57 +-- netwerk/protocol/http/HttpChannelParent.cpp | 12 +- .../http/HttpChannelParentListener.cpp | 3 +- .../http/nsHttpActivityDistributor.cpp | 31 +- netwerk/protocol/http/nsHttpChannel.cpp | 15 +- netwerk/protocol/http/nsHttpConnection.cpp | 80 +++-- netwerk/protocol/http/nsHttpConnectionMgr.cpp | 25 +- netwerk/protocol/http/nsHttpHandler.cpp | 9 +- netwerk/protocol/http/nsHttpTransaction.cpp | 16 +- netwerk/protocol/http/nsHttpTransaction.h | 6 +- .../protocol/websocket/WebSocketChannel.cpp | 40 ++- .../websocket/WebSocketChannelChild.cpp | 25 +- .../websocket/WebSocketEventService.cpp | 6 +- netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp | 6 +- netwerk/sctp/datachannel/DataChannel.cpp | 24 +- netwerk/sctp/datachannel/DataChannel.h | 60 ++-- netwerk/socket/nsNamedPipeIOLayer.cpp | 4 +- netwerk/socket/nsNamedPipeService.cpp | 3 +- .../system/linux/nsNotifyAddrListener_Linux.h | 7 +- netwerk/system/win32/nsNotifyAddrListener.h | 6 +- parser/html/nsHtml5StreamParser.cpp | 12 +- parser/html/nsHtml5TreeOpExecutor.cpp | 6 +- parser/htmlparser/nsParser.cpp | 3 +- security/manager/ssl/CryptoTask.h | 5 +- security/manager/ssl/DataStorage.cpp | 25 +- security/manager/ssl/PSMContentListener.cpp | 4 +- security/manager/ssl/PSMRunnable.cpp | 3 +- security/manager/ssl/PSMRunnable.h | 3 +- .../manager/ssl/SSLServerCertVerification.cpp | 32 +- security/manager/ssl/nsNSSCallbacks.cpp | 4 +- security/manager/ssl/nsNSSComponent.cpp | 11 +- security/manager/ssl/nsNSSIOLayer.cpp | 3 +- security/manager/ssl/nsNSSModule.cpp | 8 +- .../linux/reporter/SandboxReporter.cpp | 5 +- .../component/IdentityCryptoService.cpp | 14 +- storage/StorageBaseStatementInternal.cpp | 18 +- storage/mozStorageConnection.cpp | 9 +- storage/mozStoragePrivateHelpers.cpp | 5 +- storage/mozStorageService.cpp | 4 +- storage/test/gtest/storage_test_harness.h | 7 +- .../test_service_init_background_thread.cpp | 1 + .../gtest/test_spinningSynchronousClose.cpp | 3 +- storage/test/gtest/test_unlock_notify.cpp | 7 +- .../filewatcher/NativeFileWatcherWin.cpp | 18 +- .../osfile/NativeOSFileInternals.cpp | 29 +- toolkit/components/places/FaviconHelpers.cpp | 64 ++-- toolkit/components/places/Helpers.cpp | 3 +- toolkit/components/places/Helpers.h | 10 +- toolkit/components/places/History.cpp | 100 +++--- toolkit/components/places/nsNavHistory.cpp | 11 +- .../tests/gtest/places_test_harness_tail.h | 1 + .../satchel/nsFormFillController.cpp | 7 +- toolkit/components/startup/nsAppStartup.cpp | 6 +- toolkit/components/telemetry/Telemetry.cpp | 25 +- .../components/telemetry/TelemetryCommon.cpp | 5 +- .../telemetry/tests/gtest/TestScalars.cpp | 8 +- .../components/url-classifier/Classifier.cpp | 34 +- .../nsUrlClassifierDBService.cpp | 60 ++-- .../url-classifier/nsUrlClassifierProxies.cpp | 24 +- .../url-classifier/nsUrlClassifierProxies.h | 97 +++-- .../url-classifier/tests/gtest/Common.cpp | 14 +- toolkit/crashreporter/InjectCrashReporter.cpp | 3 +- toolkit/crashreporter/nsExceptionHandler.cpp | 3 +- .../test/gtest/TestCrashThreadAnnotation.cpp | 32 +- toolkit/xre/ProfileReset.h | 12 +- toolkit/xre/nsEmbedFunctions.cpp | 8 +- toolkit/xre/nsNativeAppSupportUnix.cpp | 5 +- toolkit/xre/nsUpdateDriver.cpp | 26 +- tools/profiler/core/platform.cpp | 19 +- .../gecko/ChildProfilerController.cpp | 14 +- tools/profiler/gecko/ThreadResponsiveness.cpp | 3 +- tools/profiler/tests/gtest/GeckoProfiler.cpp | 77 ++-- uriloader/prefetch/nsOfflineCacheUpdate.cpp | 6 +- view/nsView.cpp | 6 +- widget/VsyncDispatcher.cpp | 14 +- widget/android/AndroidBridge.cpp | 2 +- widget/android/AndroidJNIWrapper.cpp | 1 + widget/android/AndroidUiThread.cpp | 6 +- widget/android/EventDispatcher.cpp | 2 +- widget/android/fennec/ThumbnailHelper.h | 2 +- widget/android/jni/Natives.h | 2 +- widget/android/nsAppShell.cpp | 1 + widget/android/nsScreenManagerAndroid.cpp | 2 + widget/android/nsWindow.cpp | 5 +- widget/cocoa/nsChildView.mm | 2 +- widget/gtk/nsDeviceContextSpecG.cpp | 10 +- widget/gtk/nsWindow.cpp | 7 +- widget/nsBaseFilePicker.cpp | 9 +- widget/nsBaseWidget.cpp | 62 ++-- widget/nsIdleService.cpp | 38 +- widget/windows/AudioSession.cpp | 3 +- widget/windows/LSPAnnotator.cpp | 4 +- widget/windows/WidgetTraceEvent.cpp | 2 +- widget/windows/nsColorPicker.cpp | 3 +- widget/windows/nsSound.cpp | 5 +- widget/windows/nsWindow.cpp | 3 +- widget/windows/nsWindowGfx.cpp | 2 +- xpcom/base/CycleCollectedJSContext.cpp | 7 +- xpcom/base/nsConsoleService.cpp | 7 +- xpcom/base/nsCycleCollector.cpp | 4 +- xpcom/base/nsDumpUtils.cpp | 3 +- xpcom/base/nsDumpUtils.h | 3 +- xpcom/base/nsMemoryInfoDumper.cpp | 9 +- xpcom/base/nsMemoryReporterManager.cpp | 19 +- xpcom/base/nsMessageLoop.cpp | 3 +- xpcom/base/nsStatusReporterManager.cpp | 1 + xpcom/ds/nsHashPropertyBag.cpp | 3 +- xpcom/ds/nsObserverService.cpp | 5 +- xpcom/io/nsInputStreamTee.cpp | 7 +- xpcom/io/nsLocalFileWin.cpp | 4 +- xpcom/tests/gtest/TestMozPromise.cpp | 11 +- xpcom/tests/gtest/TestRWLock.cpp | 3 +- .../tests/gtest/TestRacingServiceManager.cpp | 6 +- xpcom/tests/gtest/TestStateWatching.cpp | 11 +- xpcom/tests/gtest/TestTaskQueue.cpp | 53 +-- xpcom/tests/gtest/TestThreadPool.cpp | 14 +- xpcom/tests/gtest/TestThreadPoolListener.cpp | 2 +- xpcom/tests/gtest/TestThreadUtils.cpp | 337 ++++++++++++------ xpcom/tests/gtest/TestTimers.cpp | 23 +- xpcom/threads/AbstractThread.cpp | 11 +- xpcom/threads/BackgroundHangMonitor.cpp | 3 +- xpcom/threads/LazyIdleThread.cpp | 18 +- xpcom/threads/MozPromise.h | 24 +- xpcom/threads/SchedulerGroup.cpp | 5 +- xpcom/threads/SharedThreadPool.cpp | 3 +- xpcom/threads/StateMirroring.h | 33 +- xpcom/threads/StateWatching.h | 5 +- xpcom/threads/SyncRunnable.h | 6 +- xpcom/threads/TaskDispatcher.h | 6 +- xpcom/threads/TaskQueue.h | 3 +- xpcom/threads/ThrottledEventQueue.cpp | 3 +- xpcom/threads/TimerThread.cpp | 6 +- xpcom/threads/nsMemoryPressure.cpp | 2 +- xpcom/threads/nsProcessCommon.cpp | 3 +- xpcom/threads/nsThread.cpp | 9 +- xpcom/threads/nsThreadUtils.cpp | 7 +- xpcom/threads/nsThreadUtils.h | 83 +++-- xpfe/appshell/nsAppShellService.cpp | 7 +- xpfe/appshell/nsContentTreeOwner.cpp | 3 +- .../directory/nsDirectoryViewer.cpp | 34 +- 617 files changed, 6334 insertions(+), 3563 deletions(-) diff --git a/accessible/generic/Accessible.cpp b/accessible/generic/Accessible.cpp index 690d1608cec7..f08318ed180c 100644 --- a/accessible/generic/Accessible.cpp +++ b/accessible/generic/Accessible.cpp @@ -1799,8 +1799,13 @@ Accessible::DoCommand(nsIContent *aContent, uint32_t aActionIndex) class Runnable final : public mozilla::Runnable { public: - Runnable(Accessible* aAcc, nsIContent* aContent, uint32_t aIdx) : - mAcc(aAcc), mContent(aContent), mIdx(aIdx) { } + Runnable(Accessible* aAcc, nsIContent* aContent, uint32_t aIdx) + : mozilla::Runnable("Runnable") + , mAcc(aAcc) + , mContent(aContent) + , mIdx(aIdx) + { + } NS_IMETHOD Run() override { diff --git a/accessible/generic/DocAccessible.cpp b/accessible/generic/DocAccessible.cpp index ecba61c41549..0c21507711dd 100644 --- a/accessible/generic/DocAccessible.cpp +++ b/accessible/generic/DocAccessible.cpp @@ -649,9 +649,12 @@ DocAccessible::ScrollPositionDidChange(nscoord aX, nscoord aY) mScrollWatchTimer = do_CreateInstance("@mozilla.org/timer;1"); if (mScrollWatchTimer) { NS_ADDREF_THIS(); // Kung fu death grip - mScrollWatchTimer->InitWithFuncCallback(ScrollTimerCallback, this, - kScrollPosCheckWait, - nsITimer::TYPE_REPEATING_SLACK); + mScrollWatchTimer->InitWithNamedFuncCallback( + ScrollTimerCallback, + this, + kScrollPosCheckWait, + nsITimer::TYPE_REPEATING_SLACK, + "a11y::DocAccessible::ScrollPositionDidChange"); } } mScrollPositionChangedTicks = 1; diff --git a/accessible/ipc/win/HandlerProvider.cpp b/accessible/ipc/win/HandlerProvider.cpp index 0c76d5bba1b8..f359feff3b8c 100644 --- a/accessible/ipc/win/HandlerProvider.cpp +++ b/accessible/ipc/win/HandlerProvider.cpp @@ -95,7 +95,8 @@ HandlerProvider::GetAndSerializePayload(const MutexAutoLock&) IA2Payload payload{}; - if (!mscom::InvokeOnMainThread(this, &HandlerProvider::BuildIA2Data, + if (!mscom::InvokeOnMainThread("HandlerProvider::BuildIA2Data", + this, &HandlerProvider::BuildIA2Data, &payload.mData) || !payload.mData.mUniqueId) { return; @@ -236,7 +237,8 @@ HandlerProvider::put_HandlerControl(long aPid, IHandlerControl* aCtrl) auto ptrProxy = mscom::ToProxyUniquePtr(aCtrl); - if (!mscom::InvokeOnMainThread(this, + if (!mscom::InvokeOnMainThread("HandlerProvider::SetHandlerControlOnMainThread", + this, &HandlerProvider::SetHandlerControlOnMainThread, static_cast(aPid), Move(ptrProxy))) { return E_FAIL; @@ -250,7 +252,8 @@ HandlerProvider::Refresh(IA2Data* aOutData) { MOZ_ASSERT(mscom::IsCurrentThreadMTA()); - if (!mscom::InvokeOnMainThread(this, &HandlerProvider::BuildIA2Data, + if (!mscom::InvokeOnMainThread("HandlerProvider::BuildIA2Data", + this, &HandlerProvider::BuildIA2Data, aOutData)) { return E_FAIL; } diff --git a/accessible/windows/msaa/AccessibleWrap.cpp b/accessible/windows/msaa/AccessibleWrap.cpp index 00bbcc38de10..e3e09bb59b56 100644 --- a/accessible/windows/msaa/AccessibleWrap.cpp +++ b/accessible/windows/msaa/AccessibleWrap.cpp @@ -841,7 +841,8 @@ AccessibleWrap::accSelect( // is happening, so we dispatch TakeFocus from the main thread to // guarantee that we are outside any IPC. nsCOMPtr runnable = - mozilla::NewRunnableMethod(this, &Accessible::TakeFocus); + mozilla::NewRunnableMethod("Accessible::TakeFocus", + this, &Accessible::TakeFocus); NS_DispatchToMainThread(runnable, NS_DISPATCH_NORMAL); return S_OK; } diff --git a/accessible/windows/msaa/LazyInstantiator.cpp b/accessible/windows/msaa/LazyInstantiator.cpp index 04ce7d034c30..fffb611dc51e 100644 --- a/accessible/windows/msaa/LazyInstantiator.cpp +++ b/accessible/windows/msaa/LazyInstantiator.cpp @@ -251,7 +251,8 @@ LazyInstantiator::ShouldInstantiate(const DWORD aClientTid) // Call GatherTelemetry on a background thread because it does I/O on // the executable file to retrieve version information. nsCOMPtr runnable( - NewRunnableMethod>(this, + NewRunnableMethod>("LazyInstantiator::GatherTelemetry", + this, &LazyInstantiator::GatherTelemetry, clientExe)); NS_NewThread(getter_AddRefs(mTelemetryThread), runnable); @@ -327,7 +328,9 @@ LazyInstantiator::GatherTelemetry(nsIFile* aClientExe) // Now that we've (possibly) obtained version info, send the resulting // string back to the main thread to accumulate in telemetry. - NS_DispatchToMainThread(NewNonOwningRunnableMethod(this, + NS_DispatchToMainThread(NewNonOwningRunnableMethod( + "LazyInstantiator::AccumulateTelemetry", + this, &LazyInstantiator::AccumulateTelemetry, value)); } diff --git a/accessible/xpcom/xpcAccessibilityService.cpp b/accessible/xpcom/xpcAccessibilityService.cpp index 97c0d0e72124..49c5e1082501 100644 --- a/accessible/xpcom/xpcAccessibilityService.cpp +++ b/accessible/xpcom/xpcAccessibilityService.cpp @@ -79,8 +79,12 @@ xpcAccessibilityService::Release(void) if (count == 1 && !mShutdownTimer) { mShutdownTimer = do_CreateInstance(NS_TIMER_CONTRACTID); if (mShutdownTimer) { - mShutdownTimer->InitWithFuncCallback(ShutdownCallback, this, 100, - nsITimer::TYPE_ONE_SHOT); + mShutdownTimer->InitWithNamedFuncCallback( + ShutdownCallback, + this, + 100, + nsITimer::TYPE_ONE_SHOT, + "xpcAccessibilityService::Release"); } } diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 3d9689889cd0..2c4de02d89d3 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -454,9 +454,12 @@ nsPingListener::StartTimeout(DocGroup* aDocGroup) timer->SetTarget(aDocGroup->EventTargetFor(TaskCategory::Network)); if (timer) { - nsresult rv = timer->InitWithFuncCallback(OnPingTimeout, mLoadGroup, - PING_TIMEOUT, - nsITimer::TYPE_ONE_SHOT); + nsresult rv = + timer->InitWithNamedFuncCallback(OnPingTimeout, + mLoadGroup, + PING_TIMEOUT, + nsITimer::TYPE_ONE_SHOT, + "nsPingListener::StartTimeout"); if (NS_SUCCEEDED(rv)) { mTimer = timer; return NS_OK; @@ -1767,10 +1770,12 @@ nsDocShell::DispatchToTabGroup(const char* aName, NS_IMETHODIMP nsDocShell::DispatchLocationChangeEvent() { - return DispatchToTabGroup("nsDocShell::FireDummyOnLocationChange", - TaskCategory::Other, - NewRunnableMethod(this, - &nsDocShell::FireDummyOnLocationChange)); + return DispatchToTabGroup( + "nsDocShell::FireDummyOnLocationChange", + TaskCategory::Other, + NewRunnableMethod("nsDocShell::FireDummyOnLocationChange", + this, + &nsDocShell::FireDummyOnLocationChange)); } bool @@ -9644,13 +9649,20 @@ public: bool aLoadReplace, nsIURI* aReferrer, uint32_t aReferrerPolicy, nsIPrincipal* aTriggeringPrincipal, - nsIPrincipal* aPrincipalToInherit, uint32_t aFlags, - const char* aTypeHint, nsIInputStream* aPostData, - nsIInputStream* aHeadersData, uint32_t aLoadType, - nsISHEntry* aSHEntry, bool aFirstParty, - const nsAString& aSrcdoc, nsIDocShell* aSourceDocShell, - nsIURI* aBaseURI, bool aCheckForPrerender) - : mSrcdoc(aSrcdoc) + nsIPrincipal* aPrincipalToInherit, + uint32_t aFlags, + const char* aTypeHint, + nsIInputStream* aPostData, + nsIInputStream* aHeadersData, + uint32_t aLoadType, + nsISHEntry* aSHEntry, + bool aFirstParty, + const nsAString& aSrcdoc, + nsIDocShell* aSourceDocShell, + nsIURI* aBaseURI, + bool aCheckForPrerender) + : mozilla::Runnable("InternalLoadEvent") + , mSrcdoc(aSrcdoc) , mDocShell(aDocShell) , mURI(aURI) , mOriginalURI(aOriginalURI) @@ -14040,7 +14052,8 @@ OnLinkClickEvent::OnLinkClickEvent(nsDocShell* aHandler, bool aNoOpenerImplied, bool aIsTrusted, nsIPrincipal* aTriggeringPrincipal) - : mHandler(aHandler) + : mozilla::Runnable("OnLinkClickEvent") + , mHandler(aHandler) , mURI(aURI) , mTargetSpec(aTargetSpec) , mFileName(aFileName) diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h index 83c74efabe21..a48c0b9ce878 100644 --- a/docshell/base/nsDocShell.h +++ b/docshell/base/nsDocShell.h @@ -777,7 +777,11 @@ public: { public: NS_DECL_NSIRUNNABLE - explicit RestorePresentationEvent(nsDocShell* aDs) : mDocShell(aDs) {} + explicit RestorePresentationEvent(nsDocShell* aDs) + : mozilla::Runnable("nsDocShell::RestorePresentationEvent") + , mDocShell(aDs) + { + } void Revoke() { mDocShell = nullptr; } private: RefPtr mDocShell; diff --git a/docshell/base/nsDocShellTreeOwner.cpp b/docshell/base/nsDocShellTreeOwner.cpp index 5be73d5d34f2..4871e2df7af8 100644 --- a/docshell/base/nsDocShellTreeOwner.cpp +++ b/docshell/base/nsDocShellTreeOwner.cpp @@ -1260,10 +1260,12 @@ ChromeTooltipListener::MouseMove(nsIDOMEvent* aMouseEvent) } } if (mPossibleTooltipNode) { - nsresult rv = mTooltipTimer->InitWithFuncCallback( - sTooltipCallback, this, + nsresult rv = mTooltipTimer->InitWithNamedFuncCallback( + sTooltipCallback, + this, LookAndFeel::GetInt(LookAndFeel::eIntID_TooltipDelay, 500), - nsITimer::TYPE_ONE_SHOT); + nsITimer::TYPE_ONE_SHOT, + "ChromeTooltipListener::MouseMove"); if (NS_FAILED(rv)) { mPossibleTooltipNode = nullptr; } diff --git a/docshell/shistory/nsSHEntryShared.cpp b/docshell/shistory/nsSHEntryShared.cpp index 8625fe88efee..a469c8687667 100644 --- a/docshell/shistory/nsSHEntryShared.cpp +++ b/docshell/shistory/nsSHEntryShared.cpp @@ -185,7 +185,8 @@ class DestroyViewerEvent : public mozilla::Runnable { public: DestroyViewerEvent(nsIContentViewer* aViewer, nsIDocument* aDocument) - : mViewer(aViewer) + : mozilla::Runnable("DestroyViewerEvent") + , mViewer(aViewer) , mDocument(aDocument) { } diff --git a/dom/animation/Animation.cpp b/dom/animation/Animation.cpp index 846f21697f0c..60cd91de9e94 100644 --- a/dom/animation/Animation.cpp +++ b/dom/animation/Animation.cpp @@ -1453,7 +1453,9 @@ Animation::DoFinishNotification(SyncNotifyFlag aSyncNotifyFlag) DoFinishNotificationImmediately(); } else if (!mFinishNotificationTask.IsPending()) { RefPtr> runnable = - NewRunnableMethod(this, &Animation::DoFinishNotificationImmediately); + NewRunnableMethod("dom::Animation::DoFinishNotificationImmediately", + this, + &Animation::DoFinishNotificationImmediately); context->DispatchToMicroTask(do_AddRef(runnable)); mFinishNotificationTask = runnable.forget(); } diff --git a/dom/asmjscache/AsmJSCache.cpp b/dom/asmjscache/AsmJSCache.cpp index fa5a684e42ae..24cf08ad69d2 100644 --- a/dom/asmjscache/AsmJSCache.cpp +++ b/dom/asmjscache/AsmJSCache.cpp @@ -242,11 +242,12 @@ class FileDescriptorHolder : public Runnable { public: FileDescriptorHolder() - : mQuotaObject(nullptr), - mFileSize(INT64_MIN), - mFileDesc(nullptr), - mFileMap(nullptr), - mMappedMemory(nullptr) + : Runnable("dom::asmjscache::FileDescriptorHolder") + , mQuotaObject(nullptr) + , mFileSize(INT64_MIN) + , mFileDesc(nullptr) + , mFileMap(nullptr) + , mMappedMemory(nullptr) { } ~FileDescriptorHolder() override diff --git a/dom/audiochannel/AudioChannelService.cpp b/dom/audiochannel/AudioChannelService.cpp index a31934f5c0d9..4bf894c9dd6d 100644 --- a/dom/audiochannel/AudioChannelService.cpp +++ b/dom/audiochannel/AudioChannelService.cpp @@ -85,9 +85,11 @@ private: class AudioPlaybackRunnable final : public Runnable { public: - AudioPlaybackRunnable(nsPIDOMWindowOuter* aWindow, bool aActive, + AudioPlaybackRunnable(nsPIDOMWindowOuter* aWindow, + bool aActive, AudioChannelService::AudibleChangedReasons aReason) - : mWindow(aWindow) + : mozilla::Runnable("AudioPlaybackRunnable") + , mWindow(aWindow) , mActive(aActive) , mReason(aReason) {} @@ -874,7 +876,9 @@ AudioChannelService::AudioChannelWindow::NotifyMediaBlockStop(nsPIDOMWindowOuter mShouldSendBlockStopEvent = false; // Can't use raw pointer for lamba variable capturing, use smart ptr. nsCOMPtr window = aWindow; - NS_DispatchToCurrentThread(NS_NewRunnableFunction([window] () -> void { + NS_DispatchToCurrentThread(NS_NewRunnableFunction( + "dom::AudioChannelService::AudioChannelWindow::NotifyMediaBlockStop", + [window]() -> void { nsCOMPtr observerService = services::GetObserverService(); if (NS_WARN_IF(!observerService)) { @@ -884,8 +888,7 @@ AudioChannelService::AudioChannelWindow::NotifyMediaBlockStop(nsPIDOMWindowOuter observerService->NotifyObservers(ToSupports(window), "audio-playback", u"blockStop"); - }) - ); + })); } void @@ -1049,18 +1052,19 @@ AudioChannelService::AudioChannelWindow::MaybeNotifyMediaBlockStart(AudioChannel if (!mShouldSendBlockStopEvent) { mShouldSendBlockStopEvent = true; - NS_DispatchToCurrentThread(NS_NewRunnableFunction([window] () -> void { - nsCOMPtr observerService = - services::GetObserverService(); - if (NS_WARN_IF(!observerService)) { - return; - } + NS_DispatchToCurrentThread(NS_NewRunnableFunction( + "dom::AudioChannelService::AudioChannelWindow::" + "MaybeNotifyMediaBlockStart", + [window]() -> void { + nsCOMPtr observerService = + services::GetObserverService(); + if (NS_WARN_IF(!observerService)) { + return; + } - observerService->NotifyObservers(ToSupports(window), - "audio-playback", - u"blockStart"); - }) - ); + observerService->NotifyObservers( + ToSupports(window), "audio-playback", u"blockStart"); + })); } } diff --git a/dom/base/CustomElementRegistry.cpp b/dom/base/CustomElementRegistry.cpp index c6eff39f12a1..18bc269ce48f 100644 --- a/dom/base/CustomElementRegistry.cpp +++ b/dom/base/CustomElementRegistry.cpp @@ -454,8 +454,9 @@ CustomElementRegistry::EnqueueLifecycleCallback(nsIDocument::ElementCallbackType // should be invoked prior to returning control back to script. // Create a script runner to process the top of the processing // stack as soon as it is safe to run script. - nsCOMPtr runnable = - NS_NewRunnableFunction(&CustomElementRegistry::ProcessTopElementQueue); + nsCOMPtr runnable = NS_NewRunnableFunction( + "dom::CustomElementRegistry::EnqueueLifecycleCallback", + &CustomElementRegistry::ProcessTopElementQueue); nsContentUtils::AddScriptRunner(runnable); } } diff --git a/dom/base/CustomElementRegistry.h b/dom/base/CustomElementRegistry.h index 1faf0af488bf..6faf5c6463b8 100644 --- a/dom/base/CustomElementRegistry.h +++ b/dom/base/CustomElementRegistry.h @@ -243,8 +243,11 @@ private: private: class ProcessBackupQueueRunnable : public mozilla::Runnable { public: - explicit ProcessBackupQueueRunnable(CustomElementReactionsStack* aReactionStack) - : mReactionStack(aReactionStack) + explicit ProcessBackupQueueRunnable( + CustomElementReactionsStack* aReactionStack) + : Runnable( + "dom::CustomElementReactionsStack::ProcessBackupQueueRunnable") + , mReactionStack(aReactionStack) { MOZ_ASSERT(!mReactionStack->mIsBackupQueueProcessing, "mIsBackupQueueProcessing should be initially false"); diff --git a/dom/base/DOMRequest.cpp b/dom/base/DOMRequest.cpp index ce6cd1dcdeaa..d6eee12adb34 100644 --- a/dom/base/DOMRequest.cpp +++ b/dom/base/DOMRequest.cpp @@ -299,10 +299,10 @@ DOMRequestService::FireDetailedError(nsIDOMDOMRequest* aRequest, class FireSuccessAsyncTask : public mozilla::Runnable { - FireSuccessAsyncTask(DOMRequest* aRequest, - const JS::Value& aResult) : - mReq(aRequest), - mResult(RootingCx(), aResult) + FireSuccessAsyncTask(DOMRequest* aRequest, const JS::Value& aResult) + : mozilla::Runnable("FireSuccessAsyncTask") + , mReq(aRequest) + , mResult(RootingCx(), aResult) { } @@ -336,10 +336,10 @@ private: class FireErrorAsyncTask : public mozilla::Runnable { public: - FireErrorAsyncTask(DOMRequest* aRequest, - const nsAString& aError) : - mReq(aRequest), - mError(aError) + FireErrorAsyncTask(DOMRequest* aRequest, const nsAString& aError) + : mozilla::Runnable("FireErrorAsyncTask") + , mReq(aRequest) + , mError(aError) { } diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index 3c6b7a365575..33acbcb191c1 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -613,7 +613,9 @@ Element::WrapObject(JSContext *aCx, JS::Handle aGivenProto) binding->ExecuteAttachedHandler(); } else { nsContentUtils::AddScriptRunner( - NewRunnableMethod(binding, &nsXBLBinding::ExecuteAttachedHandler)); + NewRunnableMethod("nsXBLBinding::ExecuteAttachedHandler", + binding, + &nsXBLBinding::ExecuteAttachedHandler)); } } } @@ -1788,10 +1790,14 @@ Element::BindToTree(nsIDocument* aDocument, nsIContent* aParent, return NS_OK; } -RemoveFromBindingManagerRunnable::RemoveFromBindingManagerRunnable(nsBindingManager* aManager, - nsIContent* aContent, - nsIDocument* aDoc): - mManager(aManager), mContent(aContent), mDoc(aDoc) +RemoveFromBindingManagerRunnable::RemoveFromBindingManagerRunnable( + nsBindingManager* aManager, + nsIContent* aContent, + nsIDocument* aDoc) + : mozilla::Runnable("dom::RemoveFromBindingManagerRunnable") + , mManager(aManager) + , mContent(aContent) + , mDoc(aDoc) {} RemoveFromBindingManagerRunnable::~RemoveFromBindingManagerRunnable() {} diff --git a/dom/base/EventSource.cpp b/dom/base/EventSource.cpp index 518f048cf1cf..3911b71ba7bd 100644 --- a/dom/base/EventSource.cpp +++ b/dom/base/EventSource.cpp @@ -391,7 +391,9 @@ EventSourceImpl::Close() // Asynchronously call CloseInternal to prevent EventSourceImpl from being // synchronously destoryed while dispatching DOM event. DebugOnly rv = - Dispatch(NewRunnableMethod(this, &EventSourceImpl::CloseInternal), + Dispatch(NewRunnableMethod("dom::EventSourceImpl::CloseInternal", + this, + &EventSourceImpl::CloseInternal), NS_DISPATCH_NORMAL); MOZ_ASSERT(NS_SUCCEEDED(rv)); } @@ -683,7 +685,9 @@ EventSourceImpl::OnStartRequest(nsIRequest* aRequest, nsISupports* aCtxt) } } } - rv = Dispatch(NewRunnableMethod(this, &EventSourceImpl::AnnounceConnection), + rv = Dispatch(NewRunnableMethod("dom::EventSourceImpl::AnnounceConnection", + this, + &EventSourceImpl::AnnounceConnection), NS_DISPATCH_NORMAL); NS_ENSURE_SUCCESS(rv, rv); mStatus = PARSE_STATE_BEGIN_OF_STREAM; @@ -752,7 +756,8 @@ class DataAvailableRunnable final : public Runnable DataAvailableRunnable(EventSourceImpl* aEventSourceImpl, UniquePtr aData, uint32_t aLength) - : mEventSourceImpl(aEventSourceImpl) + : Runnable("dom::DataAvailableRunnable") + , mEventSourceImpl(aEventSourceImpl) , mData(Move(aData)) , mLength(aLength) { @@ -840,9 +845,10 @@ EventSourceImpl::OnStopRequest(nsIRequest* aRequest, nsresult rv = CheckHealthOfRequestCallback(aRequest); NS_ENSURE_SUCCESS(rv, rv); - rv = Dispatch( - NewRunnableMethod(this, &EventSourceImpl::ReestablishConnection), - NS_DISPATCH_NORMAL); + rv = Dispatch(NewRunnableMethod("dom::EventSourceImpl::ReestablishConnection", + this, + &EventSourceImpl::ReestablishConnection), + NS_DISPATCH_NORMAL); NS_ENSURE_SUCCESS(rv, rv); return NS_OK; @@ -1245,9 +1251,12 @@ EventSourceImpl::SetReconnectionTimeout() NS_ENSURE_STATE(mTimer); } - nsresult rv = mTimer->InitWithFuncCallback(TimerCallback, this, - mReconnectionTime, - nsITimer::TYPE_ONE_SHOT); + nsresult rv = mTimer->InitWithNamedFuncCallback( + TimerCallback, + this, + mReconnectionTime, + nsITimer::TYPE_ONE_SHOT, + "dom::EventSourceImpl::SetReconnectionTimeout"); NS_ENSURE_SUCCESS(rv, rv); return NS_OK; @@ -1341,7 +1350,9 @@ EventSourceImpl::DispatchFailConnection() if (NS_FAILED(rv)) { NS_WARNING("Failed to print to the console error"); } - rv = Dispatch(NewRunnableMethod(this, &EventSourceImpl::FailConnection), + rv = Dispatch(NewRunnableMethod("dom::EventSourceImpl::FailConnection", + this, + &EventSourceImpl::FailConnection), NS_DISPATCH_NORMAL); MOZ_ASSERT(NS_SUCCEEDED(rv)); } @@ -1407,7 +1418,9 @@ EventSourceImpl::Thaw() nsresult rv; if (!mGoingToDispatchAllMessages && mMessagesToDispatch.GetSize() > 0) { nsCOMPtr event = - NewRunnableMethod(this, &EventSourceImpl::DispatchAllMessageEvents); + NewRunnableMethod("dom::EventSourceImpl::DispatchAllMessageEvents", + this, + &EventSourceImpl::DispatchAllMessageEvents); NS_ENSURE_STATE(event); mGoingToDispatchAllMessages = true; @@ -1468,7 +1481,9 @@ EventSourceImpl::DispatchCurrentMessageEvent() if (!mGoingToDispatchAllMessages) { nsCOMPtr event = - NewRunnableMethod(this, &EventSourceImpl::DispatchAllMessageEvents); + NewRunnableMethod("dom::EventSourceImpl::DispatchAllMessageEvents", + this, + &EventSourceImpl::DispatchAllMessageEvents); NS_ENSURE_STATE(event); mGoingToDispatchAllMessages = true; diff --git a/dom/base/ImageEncoder.cpp b/dom/base/ImageEncoder.cpp index 8bed53cf7453..b263222ee751 100644 --- a/dom/base/ImageEncoder.cpp +++ b/dom/base/ImageEncoder.cpp @@ -552,9 +552,9 @@ ImageEncoder::EnsureThreadPool() sThreadPool = threadPool; if (!NS_IsMainThread()) { - NS_DispatchToMainThread(NS_NewRunnableFunction([]() -> void { - RegisterEncoderThreadPoolTerminatorObserver(); - })); + NS_DispatchToMainThread(NS_NewRunnableFunction( + "dom::ImageEncoder::EnsureThreadPool", + []() -> void { RegisterEncoderThreadPoolTerminatorObserver(); })); } else { RegisterEncoderThreadPoolTerminatorObserver(); } diff --git a/dom/base/PostMessageEvent.cpp b/dom/base/PostMessageEvent.cpp index 3d562859a14e..06b2b55e0e2e 100644 --- a/dom/base/PostMessageEvent.cpp +++ b/dom/base/PostMessageEvent.cpp @@ -35,14 +35,16 @@ PostMessageEvent::PostMessageEvent(nsGlobalWindow* aSource, nsIPrincipal* aProvidedPrincipal, nsIDocument* aSourceDocument, bool aTrustedCaller) -: StructuredCloneHolder(CloningSupported, TransferringSupported, - StructuredCloneScope::SameProcessSameThread), - mSource(aSource), - mCallerOrigin(aCallerOrigin), - mTargetWindow(aTargetWindow), - mProvidedPrincipal(aProvidedPrincipal), - mSourceDocument(aSourceDocument), - mTrustedCaller(aTrustedCaller) + : Runnable("dom::PostMessageEvent") + , StructuredCloneHolder(CloningSupported, + TransferringSupported, + StructuredCloneScope::SameProcessSameThread) + , mSource(aSource) + , mCallerOrigin(aCallerOrigin) + , mTargetWindow(aTargetWindow) + , mProvidedPrincipal(aProvidedPrincipal) + , mSourceDocument(aSourceDocument) + , mTrustedCaller(aTrustedCaller) { } diff --git a/dom/base/ScreenOrientation.cpp b/dom/base/ScreenOrientation.cpp index 644e5145dbaf..6d7d652120ac 100644 --- a/dom/base/ScreenOrientation.cpp +++ b/dom/base/ScreenOrientation.cpp @@ -553,8 +553,10 @@ ScreenOrientation::Notify(const hal::ScreenConfiguration& aConfiguration) doc->SetOrientationPendingPromise(nullptr); } - nsCOMPtr runnable = NewRunnableMethod(this, - &ScreenOrientation::DispatchChangeEvent); + nsCOMPtr runnable = + NewRunnableMethod("dom::ScreenOrientation::DispatchChangeEvent", + this, + &ScreenOrientation::DispatchChangeEvent); rv = NS_DispatchToMainThread(runnable); NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "NS_DispatchToMainThread failed"); } @@ -640,8 +642,10 @@ ScreenOrientation::VisibleEventListener::HandleEvent(nsIDOMEvent* aEvent) doc->SetOrientationPendingPromise(nullptr); } - nsCOMPtr runnable = NewRunnableMethod(orientation, - &ScreenOrientation::DispatchChangeEvent); + nsCOMPtr runnable = + NewRunnableMethod("dom::ScreenOrientation::DispatchChangeEvent", + orientation, + &ScreenOrientation::DispatchChangeEvent); rv = NS_DispatchToMainThread(runnable); if (NS_WARN_IF(rv.Failed())) { return rv.StealNSResult(); diff --git a/dom/base/Selection.h b/dom/base/Selection.h index da9a573d4daa..980b3939a1cd 100644 --- a/dom/base/Selection.h +++ b/dom/base/Selection.h @@ -323,11 +323,13 @@ private: nsIPresShell::ScrollAxis aVertical, nsIPresShell::ScrollAxis aHorizontal, int32_t aFlags) - : mSelection(aSelection), - mRegion(aRegion), - mVerticalScroll(aVertical), - mHorizontalScroll(aHorizontal), - mFlags(aFlags) { + : Runnable("dom::Selection::ScrollSelectionIntoViewEvent") + , mSelection(aSelection) + , mRegion(aRegion) + , mVerticalScroll(aVertical) + , mHorizontalScroll(aHorizontal) + , mFlags(aFlags) + { NS_ASSERTION(aSelection, "null parameter"); } void Revoke() { mSelection = nullptr; } diff --git a/dom/base/WebSocket.cpp b/dom/base/WebSocket.cpp index b7f2235a17bc..f98b09c2f5d2 100644 --- a/dom/base/WebSocket.cpp +++ b/dom/base/WebSocket.cpp @@ -268,7 +268,8 @@ class CallDispatchConnectionCloseEvents final : public CancelableRunnable { public: explicit CallDispatchConnectionCloseEvents(WebSocketImpl* aWebSocketImpl) - : mWebSocketImpl(aWebSocketImpl) + : CancelableRunnable("dom::CallDispatchConnectionCloseEvents") + , mWebSocketImpl(aWebSocketImpl) { aWebSocketImpl->AssertIsOnTargetThread(); } @@ -404,9 +405,11 @@ namespace { class CancelWebSocketRunnable final : public Runnable { public: - CancelWebSocketRunnable(nsIWebSocketChannel* aChannel, uint16_t aReasonCode, + CancelWebSocketRunnable(nsIWebSocketChannel* aChannel, + uint16_t aReasonCode, const nsACString& aReasonString) - : mChannel(aChannel) + : Runnable("dom::CancelWebSocketRunnable") + , mChannel(aChannel) , mReasonCode(aReasonCode) , mReasonString(aReasonString) {} @@ -458,7 +461,8 @@ public: CloseConnectionRunnable(WebSocketImpl* aImpl, uint16_t aReasonCode, const nsACString& aReasonString) - : mImpl(aImpl) + : Runnable("dom::CloseConnectionRunnable") + , mImpl(aImpl) , mReasonCode(aReasonCode) , mReasonString(aReasonString) {} diff --git a/dom/base/nsContentSink.cpp b/dom/base/nsContentSink.cpp index b98d89bfc9ce..c0d9fcc7df7c 100644 --- a/dom/base/nsContentSink.cpp +++ b/dom/base/nsContentSink.cpp @@ -285,8 +285,9 @@ nsContentSink::ProcessHTTPHeaders(nsIChannel* aChannel) "Already dispatched an event?"); mProcessLinkHeaderEvent = - NewNonOwningRunnableMethod(this, - &nsContentSink::DoProcessLinkHeader); + NewNonOwningRunnableMethod("nsContentSink::DoProcessLinkHeader", + this, + &nsContentSink::DoProcessLinkHeader); rv = NS_DispatchToCurrentThread(mProcessLinkHeaderEvent.get()); if (NS_FAILED(rv)) { mProcessLinkHeaderEvent.Forget(); diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index f97909b43115..e087282f2a1b 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -5322,12 +5322,16 @@ nsContentUtils::IsInSameAnonymousTree(const nsINode* aNode, class AnonymousContentDestroyer : public Runnable { public: - explicit AnonymousContentDestroyer(nsCOMPtr* aContent) { + explicit AnonymousContentDestroyer(nsCOMPtr* aContent) + : mozilla::Runnable("AnonymousContentDestroyer") + { mContent.swap(*aContent); mParent = mContent->GetParent(); mDoc = mContent->OwnerDoc(); } - explicit AnonymousContentDestroyer(nsCOMPtr* aElement) { + explicit AnonymousContentDestroyer(nsCOMPtr* aElement) + : mozilla::Runnable("AnonymousContentDestroyer") + { mContent = aElement->forget(); mParent = mContent->GetParent(); mDoc = mContent->OwnerDoc(); @@ -10560,9 +10564,9 @@ nsContentUtils::UserInteractionObserver::Init() // started yet. It will have started by the time we have the chance to spin // the event loop. RefPtr self = this; - NS_DispatchToMainThread(NS_NewRunnableFunction([=] () { - HangMonitor::RegisterAnnotator(*self); - })); + NS_DispatchToMainThread( + NS_NewRunnableFunction("nsContentUtils::UserInteractionObserver::Init", + [=]() { HangMonitor::RegisterAnnotator(*self); })); } void diff --git a/dom/base/nsDOMMutationObserver.cpp b/dom/base/nsDOMMutationObserver.cpp index cd6894821139..2798d2eeee8c 100644 --- a/dom/base/nsDOMMutationObserver.cpp +++ b/dom/base/nsDOMMutationObserver.cpp @@ -867,6 +867,7 @@ nsDOMMutationObserver::HandleMutation() class AsyncMutationHandler : public mozilla::Runnable { public: + AsyncMutationHandler() : mozilla::Runnable("AsyncMutationHandler") {} NS_IMETHOD Run() override { nsDOMMutationObserver::HandleMutations(); diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index df58093bcf21..7465ed8c0800 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -1109,10 +1109,21 @@ nsDOMWindowUtils::SendNativeKeyEvent(int32_t aNativeKeyboardLayout, if (!widget) return NS_ERROR_FAILURE; - NS_DispatchToMainThread(NewRunnableMethod - - (widget, &nsIWidget::SynthesizeNativeKeyEvent, aNativeKeyboardLayout, - aNativeKeyCode, aModifiers, aCharacters, aUnmodifiedCharacters, aObserver)); + NS_DispatchToMainThread( + NewRunnableMethod("nsIWidget::SynthesizeNativeKeyEvent", + widget, + &nsIWidget::SynthesizeNativeKeyEvent, + aNativeKeyboardLayout, + aNativeKeyCode, + aModifiers, + aCharacters, + aUnmodifiedCharacters, + aObserver)); return NS_OK; } @@ -1129,11 +1140,15 @@ nsDOMWindowUtils::SendNativeMouseEvent(int32_t aScreenX, if (!widget) return NS_ERROR_FAILURE; - NS_DispatchToMainThread(NewRunnableMethod - - (widget, &nsIWidget::SynthesizeNativeMouseEvent, - LayoutDeviceIntPoint(aScreenX, aScreenY), aNativeMessage, aModifierFlags, - aObserver)); + NS_DispatchToMainThread( + NewRunnableMethod( + "nsIWidget::SynthesizeNativeMouseEvent", + widget, + &nsIWidget::SynthesizeNativeMouseEvent, + LayoutDeviceIntPoint(aScreenX, aScreenY), + aNativeMessage, + aModifierFlags, + aObserver)); return NS_OK; } @@ -1148,10 +1163,12 @@ nsDOMWindowUtils::SendNativeMouseMove(int32_t aScreenX, if (!widget) return NS_ERROR_FAILURE; - NS_DispatchToMainThread(NewRunnableMethod - - (widget, &nsIWidget::SynthesizeNativeMouseMove, - LayoutDeviceIntPoint(aScreenX, aScreenY), aObserver)); + NS_DispatchToMainThread(NewRunnableMethod( + "nsIWidget::SynthesizeNativeMouseMove", + widget, + &nsIWidget::SynthesizeNativeMouseMove, + LayoutDeviceIntPoint(aScreenX, aScreenY), + aObserver)); return NS_OK; } @@ -1173,11 +1190,25 @@ nsDOMWindowUtils::SendNativeMouseScrollEvent(int32_t aScreenX, return NS_ERROR_FAILURE; } - NS_DispatchToMainThread(NewRunnableMethod - - (widget, &nsIWidget::SynthesizeNativeMouseScrollEvent, - LayoutDeviceIntPoint(aScreenX, aScreenY), aNativeMessage, aDeltaX, aDeltaY, - aDeltaZ, aModifierFlags, aAdditionalFlags, aObserver)); + NS_DispatchToMainThread(NewRunnableMethod( + "nsIWidget::SynthesizeNativeMouseScrollEvent", + widget, + &nsIWidget::SynthesizeNativeMouseScrollEvent, + LayoutDeviceIntPoint(aScreenX, aScreenY), + aNativeMessage, + aDeltaX, + aDeltaY, + aDeltaZ, + aModifierFlags, + aAdditionalFlags, + aObserver)); return NS_OK; } @@ -1199,12 +1230,21 @@ nsDOMWindowUtils::SendNativeTouchPoint(uint32_t aPointerId, return NS_ERROR_INVALID_ARG; } - NS_DispatchToMainThread(NewRunnableMethod - - (widget, &nsIWidget::SynthesizeNativeTouchPoint, aPointerId, - (nsIWidget::TouchPointerState)aTouchState, - LayoutDeviceIntPoint(aScreenX, aScreenY), - aPressure, aOrientation, aObserver)); + NS_DispatchToMainThread( + NewRunnableMethod("nsIWidget::SynthesizeNativeTouchPoint", + widget, + &nsIWidget::SynthesizeNativeTouchPoint, + aPointerId, + (nsIWidget::TouchPointerState)aTouchState, + LayoutDeviceIntPoint(aScreenX, aScreenY), + aPressure, + aOrientation, + aObserver)); return NS_OK; } @@ -1219,10 +1259,14 @@ nsDOMWindowUtils::SendNativeTouchTap(int32_t aScreenX, return NS_ERROR_FAILURE; } - NS_DispatchToMainThread(NewRunnableMethod - - (widget, &nsIWidget::SynthesizeNativeTouchTap, - LayoutDeviceIntPoint(aScreenX, aScreenY), aLongTap, aObserver)); + NS_DispatchToMainThread( + NewRunnableMethod( + "nsIWidget::SynthesizeNativeTouchTap", + widget, + &nsIWidget::SynthesizeNativeTouchTap, + LayoutDeviceIntPoint(aScreenX, aScreenY), + aLongTap, + aObserver)); return NS_OK; } @@ -1234,8 +1278,11 @@ nsDOMWindowUtils::ClearNativeTouchSequence(nsIObserver* aObserver) return NS_ERROR_FAILURE; } - NS_DispatchToMainThread(NewRunnableMethod - (widget, &nsIWidget::ClearNativeTouchSequence, aObserver)); + NS_DispatchToMainThread( + NewRunnableMethod("nsIWidget::ClearNativeTouchSequence", + widget, + &nsIWidget::ClearNativeTouchSequence, + aObserver)); return NS_OK; } diff --git a/dom/base/nsDocElementCreatedNotificationRunner.h b/dom/base/nsDocElementCreatedNotificationRunner.h index 1e53c3dd0ba7..5568a37bbdaf 100644 --- a/dom/base/nsDocElementCreatedNotificationRunner.h +++ b/dom/base/nsDocElementCreatedNotificationRunner.h @@ -18,7 +18,8 @@ class nsDocElementCreatedNotificationRunner : public mozilla::Runnable { public: explicit nsDocElementCreatedNotificationRunner(nsIDocument* aDoc) - : mDoc(aDoc) + : mozilla::Runnable("nsDocElementCreatedNotificationRunner") + , mDoc(aDoc) { } diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index 379e35ce1f67..57f80d4f200c 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -4434,8 +4434,10 @@ nsDocument::SetStyleSheetApplicableState(StyleSheet* aSheet, if (!mSSApplicableStateNotificationPending) { MOZ_RELEASE_ASSERT(NS_IsMainThread()); - nsCOMPtr notification = NewRunnableMethod(this, - &nsDocument::NotifyStyleSheetApplicableStateChanged); + nsCOMPtr notification = + NewRunnableMethod("nsDocument::NotifyStyleSheetApplicableStateChanged", + this, + &nsDocument::NotifyStyleSheetApplicableStateChanged); mSSApplicableStateNotificationPending = NS_SUCCEEDED( Dispatch("nsDocument::NotifyStyleSheetApplicableStateChanged", @@ -5050,7 +5052,9 @@ nsDocument::MaybeEndOutermostXBLUpdate() } else if (!mInDestructor) { if (!mMaybeEndOutermostXBLUpdateRunner) { mMaybeEndOutermostXBLUpdateRunner = - NewRunnableMethod(this, &nsDocument::MaybeEndOutermostXBLUpdate); + NewRunnableMethod("nsDocument::MaybeEndOutermostXBLUpdate", + this, + &nsDocument::MaybeEndOutermostXBLUpdate); } nsContentUtils::AddScriptRunner(mMaybeEndOutermostXBLUpdateRunner); } @@ -5381,7 +5385,9 @@ nsDocument::UnblockDOMContentLoaded() if (!mSynchronousDOMContentLoaded) { MOZ_RELEASE_ASSERT(NS_IsMainThread()); nsCOMPtr ev = - NewRunnableMethod(this, &nsDocument::DispatchContentLoadedEvents); + NewRunnableMethod("nsDocument::DispatchContentLoadedEvents", + this, + &nsDocument::DispatchContentLoadedEvents); Dispatch("nsDocument::DispatchContentLoadedEvents", TaskCategory::Other, ev.forget()); } else { DispatchContentLoadedEvents(); @@ -7019,7 +7025,9 @@ nsDocument::NotifyPossibleTitleChange(bool aBoundTitleElement) MOZ_RELEASE_ASSERT(NS_IsMainThread()); RefPtr> event = - NewNonOwningRunnableMethod(this, &nsDocument::DoNotifyPossibleTitleChange); + NewNonOwningRunnableMethod("nsDocument::DoNotifyPossibleTitleChange", + this, + &nsDocument::DoNotifyPossibleTitleChange); nsresult rv = Dispatch("nsDocument::DoNotifyPossibleTitleChange", TaskCategory::Other, do_AddRef(event)); if (NS_SUCCEEDED(rv)) { @@ -7169,7 +7177,9 @@ nsDocument::InitializeFrameLoader(nsFrameLoader* aLoader) mInitializableFrameLoaders.AppendElement(aLoader); if (!mFrameLoaderRunner) { mFrameLoaderRunner = - NewRunnableMethod(this, &nsDocument::MaybeInitializeFinalizeFrameLoaders); + NewRunnableMethod("nsDocument::MaybeInitializeFinalizeFrameLoaders", + this, + &nsDocument::MaybeInitializeFinalizeFrameLoaders); NS_ENSURE_TRUE(mFrameLoaderRunner, NS_ERROR_OUT_OF_MEMORY); nsContentUtils::AddScriptRunner(mFrameLoaderRunner); } @@ -7187,7 +7197,9 @@ nsDocument::FinalizeFrameLoader(nsFrameLoader* aLoader, nsIRunnable* aFinalizer) mFrameLoaderFinalizers.AppendElement(aFinalizer); if (!mFrameLoaderRunner) { mFrameLoaderRunner = - NewRunnableMethod(this, &nsDocument::MaybeInitializeFinalizeFrameLoaders); + NewRunnableMethod("nsDocument::MaybeInitializeFinalizeFrameLoaders", + this, + &nsDocument::MaybeInitializeFinalizeFrameLoaders); NS_ENSURE_TRUE(mFrameLoaderRunner, NS_ERROR_OUT_OF_MEMORY); nsContentUtils::AddScriptRunner(mFrameLoaderRunner); } @@ -7211,7 +7223,9 @@ nsDocument::MaybeInitializeFinalizeFrameLoaders() (mInitializableFrameLoaders.Length() || mFrameLoaderFinalizers.Length())) { mFrameLoaderRunner = - NewRunnableMethod(this, &nsDocument::MaybeInitializeFinalizeFrameLoaders); + NewRunnableMethod("nsDocument::MaybeInitializeFinalizeFrameLoaders", + this, + &nsDocument::MaybeInitializeFinalizeFrameLoaders); nsContentUtils::AddScriptRunner(mFrameLoaderRunner); } return; @@ -8788,8 +8802,8 @@ nsDocument::BlockOnload() // block onload only when there are no script blockers. ++mAsyncOnloadBlockCount; if (mAsyncOnloadBlockCount == 1) { - nsContentUtils::AddScriptRunner( - NewRunnableMethod(this, &nsDocument::AsyncBlockOnload)); + nsContentUtils::AddScriptRunner(NewRunnableMethod( + "nsDocument::AsyncBlockOnload", this, &nsDocument::AsyncBlockOnload)); } return; } @@ -8846,7 +8860,11 @@ nsDocument::UnblockOnload(bool aFireSync) class nsUnblockOnloadEvent : public Runnable { public: - explicit nsUnblockOnloadEvent(nsDocument* aDoc) : mDoc(aDoc) {} + explicit nsUnblockOnloadEvent(nsDocument* aDoc) + : mozilla::Runnable("nsUnblockOnloadEvent") + , mDoc(aDoc) + { + } NS_IMETHOD Run() override { mDoc->DoUnblockOnload(); return NS_OK; @@ -9728,6 +9746,7 @@ class nsDelayedEventDispatcher : public Runnable { public: explicit nsDelayedEventDispatcher(nsTArray>& aDocuments) + : mozilla::Runnable("nsDelayedEventDispatcher") { mDocuments.SwapElements(aDocuments); } @@ -9974,7 +9993,9 @@ nsIDocument::RegisterPendingLinkUpdate(Link* aLink) if (!mHasLinksToUpdateRunnable) { nsCOMPtr event = - NewRunnableMethod(this, &nsIDocument::FlushPendingLinkUpdatesFromRunnable); + NewRunnableMethod("nsIDocument::FlushPendingLinkUpdatesFromRunnable", + this, + &nsIDocument::FlushPendingLinkUpdatesFromRunnable); // Do this work in a second in the worst case. nsresult rv = NS_IdleDispatchToCurrentThread(event.forget(), 1000); @@ -10896,7 +10917,10 @@ class nsCallExitFullscreen : public Runnable { public: explicit nsCallExitFullscreen(nsIDocument* aDoc) - : mDoc(aDoc) {} + : mozilla::Runnable("nsCallExitFullscreen") + , mDoc(aDoc) + { + } NS_IMETHOD Run() override final { @@ -10976,7 +11000,10 @@ class ExitFullscreenScriptRunnable : public Runnable { public: explicit ExitFullscreenScriptRunnable(nsCOMArray&& aDocuments) - : mDocuments(Move(aDocuments)) { } + : mozilla::Runnable("ExitFullscreenScriptRunnable") + , mDocuments(Move(aDocuments)) + { + } NS_IMETHOD Run() override { @@ -11170,7 +11197,10 @@ class nsCallRequestFullScreen : public Runnable { public: explicit nsCallRequestFullScreen(UniquePtr&& aRequest) - : mRequest(Move(aRequest)) { } + : mozilla::Runnable("nsCallRequestFullScreen") + , mRequest(Move(aRequest)) + { + } NS_IMETHOD Run() override { @@ -11900,7 +11930,8 @@ class PointerLockRequest final : public Runnable { public: PointerLockRequest(Element* aElement, bool aUserInputOrChromeCaller) - : mElement(do_GetWeakReference(aElement)) + : mozilla::Runnable("PointerLockRequest") + , mElement(do_GetWeakReference(aElement)) , mDocument(do_GetWeakReference(aElement->OwnerDoc())) , mUserInputOrChromeCaller(aUserInputOrChromeCaller) {} @@ -12251,7 +12282,9 @@ nsDocument::GetVisibilityState() const nsDocument::PostVisibilityUpdateEvent() { nsCOMPtr event = - NewRunnableMethod(this, &nsDocument::UpdateVisibilityState); + NewRunnableMethod("nsDocument::UpdateVisibilityState", + this, + &nsDocument::UpdateVisibilityState); Dispatch("nsDocument::UpdateVisibilityState", TaskCategory::Other, event.forget()); } @@ -12796,7 +12829,9 @@ nsDocument::ScheduleIntersectionObserverNotification() } MOZ_RELEASE_ASSERT(NS_IsMainThread()); nsCOMPtr notification = - NewRunnableMethod(this, &nsDocument::NotifyIntersectionObservers); + NewRunnableMethod("nsDocument::NotifyIntersectionObservers", + this, + &nsDocument::NotifyIntersectionObservers); Dispatch("nsDocument::IntersectionObserverNotification", TaskCategory::Other, notification.forget()); } @@ -13086,7 +13121,9 @@ nsIDocument::RebuildUserFontSet() if (!mPostedFlushUserFontSet) { MOZ_RELEASE_ASSERT(NS_IsMainThread()); nsCOMPtr ev = - NewRunnableMethod(this, &nsIDocument::HandleRebuildUserFontSet); + NewRunnableMethod("nsIDocument::HandleRebuildUserFontSet", + this, + &nsIDocument::HandleRebuildUserFontSet); if (NS_SUCCEEDED(Dispatch("nsIDocument::HandleRebuildUserFontSet", TaskCategory::Other, ev.forget()))) { mPostedFlushUserFontSet = true; diff --git a/dom/base/nsFocusManager.cpp b/dom/base/nsFocusManager.cpp index 210b77a2ffa2..2d0839b9d1a3 100644 --- a/dom/base/nsFocusManager.cpp +++ b/dom/base/nsFocusManager.cpp @@ -2021,10 +2021,14 @@ nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow, class FocusBlurEvent : public Runnable { public: - FocusBlurEvent(nsISupports* aTarget, EventMessage aEventMessage, - nsPresContext* aContext, bool aWindowRaised, - bool aIsRefocus, EventTarget* aRelatedTarget) - : mTarget(aTarget) + FocusBlurEvent(nsISupports* aTarget, + EventMessage aEventMessage, + nsPresContext* aContext, + bool aWindowRaised, + bool aIsRefocus, + EventTarget* aRelatedTarget) + : mozilla::Runnable("FocusBlurEvent") + , mTarget(aTarget) , mContext(aContext) , mEventMessage(aEventMessage) , mWindowRaised(aWindowRaised) @@ -2055,12 +2059,14 @@ public: class FocusInOutEvent : public Runnable { public: - FocusInOutEvent(nsISupports* aTarget, EventMessage aEventMessage, - nsPresContext* aContext, - nsPIDOMWindowOuter* aOriginalFocusedWindow, - nsIContent* aOriginalFocusedContent, - EventTarget* aRelatedTarget) - : mTarget(aTarget) + FocusInOutEvent(nsISupports* aTarget, + EventMessage aEventMessage, + nsPresContext* aContext, + nsPIDOMWindowOuter* aOriginalFocusedWindow, + nsIContent* aOriginalFocusedContent, + EventTarget* aRelatedTarget) + : mozilla::Runnable("FocusInOutEvent") + , mTarget(aTarget) , mContext(aContext) , mEventMessage(aEventMessage) , mOriginalFocusedWindow(aOriginalFocusedWindow) @@ -2264,8 +2270,8 @@ nsFocusManager::RaiseWindow(nsPIDOMWindowOuter* aWindow) nsCOMPtr active(mActiveWindow); nsCOMPtr window(aWindow); RefPtr self(this); - NS_DispatchToCurrentThread( - NS_NewRunnableFunction([self, active, window] () -> void { + NS_DispatchToCurrentThread(NS_NewRunnableFunction( + "nsFocusManager::RaiseWindow", [self, active, window]() -> void { if (active) { self->WindowLowered(active); } @@ -3623,6 +3629,7 @@ class PointerUnlocker : public Runnable { public: PointerUnlocker() + : mozilla::Runnable("PointerUnlocker") { MOZ_ASSERT(!PointerUnlocker::sActiveUnlocker); PointerUnlocker::sActiveUnlocker = this; diff --git a/dom/base/nsFrameLoader.cpp b/dom/base/nsFrameLoader.cpp index 9857ba3a50fc..eca46e193bd7 100644 --- a/dom/base/nsFrameLoader.cpp +++ b/dom/base/nsFrameLoader.cpp @@ -1985,7 +1985,11 @@ class nsFrameLoaderDestroyRunnable : public Runnable public: explicit nsFrameLoaderDestroyRunnable(nsFrameLoader* aFrameLoader) - : mFrameLoader(aFrameLoader), mPhase(eDestroyDocShell) {} + : mozilla::Runnable("nsFrameLoaderDestroyRunnable") + , mFrameLoader(aFrameLoader) + , mPhase(eDestroyDocShell) + { + } NS_IMETHOD Run() override; }; @@ -2070,9 +2074,10 @@ nsFrameLoader::StartDestroy() nsCOMPtr groupedSHistory; GetGroupedSHistory(getter_AddRefs(groupedSHistory)); if (groupedSHistory) { - NS_DispatchToCurrentThread(NS_NewRunnableFunction([groupedSHistory] () { - groupedSHistory->CloseInactiveFrameLoaderOwners(); - })); + NS_DispatchToCurrentThread(NS_NewRunnableFunction( + "nsFrameLoader::StartDestroy", [groupedSHistory]() { + groupedSHistory->CloseInactiveFrameLoaderOwners(); + })); } } @@ -3167,6 +3172,7 @@ public: JS::Handle aCpows, nsFrameLoader* aFrameLoader) : nsSameProcessAsyncMessageBase(aRootingCx, aCpows) + , mozilla::Runnable("nsAsyncMessageToChild") , mFrameLoader(aFrameLoader) { } diff --git a/dom/base/nsFrameMessageManager.cpp b/dom/base/nsFrameMessageManager.cpp index 1047cf2fe4b5..18d6fc2e837e 100644 --- a/dom/base/nsFrameMessageManager.cpp +++ b/dom/base/nsFrameMessageManager.cpp @@ -1751,6 +1751,7 @@ public: nsAsyncMessageToSameProcessChild(JS::RootingContext* aRootingCx, JS::Handle aCpows) : nsSameProcessAsyncMessageBase(aRootingCx, aCpows) + , mozilla::Runnable("nsAsyncMessageToSameProcessChild") { } NS_IMETHOD Run() override { diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index fe6c250b2d69..9ec0de1ad074 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -3034,8 +3034,8 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument, happens, setting status isn't a big requirement, so don't. (Doesn't happen under normal circumstances, but bug 49615 describes a case.) */ - nsContentUtils::AddScriptRunner( - NewRunnableMethod(this, &nsGlobalWindow::ClearStatus)); + nsContentUtils::AddScriptRunner(NewRunnableMethod( + "nsGlobalWindow::ClearStatus", this, &nsGlobalWindow::ClearStatus)); // Sometimes, WouldReuseInnerWindow() returns true even if there's no inner // window (see bug 776497). Be safe. @@ -3345,7 +3345,8 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument, // up with the outer. See bug 969156. if (createdInnerWindow) { nsContentUtils::AddScriptRunner( - NewRunnableMethod(newInnerWindow, + NewRunnableMethod("nsGlobalWindow::FireOnNewGlobalObject", + newInnerWindow, &nsGlobalWindow::FireOnNewGlobalObject)); } @@ -3359,7 +3360,9 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument, nsContentUtils::IsSystemPrincipal(mDoc->NodePrincipal())) { newInnerWindow->mHasNotifiedGlobalCreated = true; nsContentUtils::AddScriptRunner( - NewRunnableMethod(this, &nsGlobalWindow::DispatchDOMWindowCreated)); + NewRunnableMethod("nsGlobalWindow::DispatchDOMWindowCreated", + this, + &nsGlobalWindow::DispatchDOMWindowCreated)); } } @@ -6870,10 +6873,13 @@ class FullscreenTransitionTask : public Runnable { public: FullscreenTransitionTask(const FullscreenTransitionDuration& aDuration, - nsGlobalWindow* aWindow, bool aFullscreen, - nsIWidget* aWidget, nsIScreen* aScreen, + nsGlobalWindow* aWindow, + bool aFullscreen, + nsIWidget* aWidget, + nsIScreen* aScreen, nsISupports* aTransitionData) - : mWindow(aWindow) + : mozilla::Runnable("FullscreenTransitionTask") + , mWindow(aWindow) , mWidget(aWidget) , mScreen(aScreen) , mTransitionData(aTransitionData) @@ -9209,8 +9215,9 @@ class nsCloseEvent : public Runnable { RefPtr mWindow; bool mIndirect; - nsCloseEvent(nsGlobalWindow *aWindow, bool aIndirect) - : mWindow(aWindow) + nsCloseEvent(nsGlobalWindow* aWindow, bool aIndirect) + : mozilla::Runnable("nsCloseEvent") + , mWindow(aWindow) , mIndirect(aIndirect) {} @@ -9639,11 +9646,11 @@ struct BrowserCompartmentMatcher : public js::CompartmentFilter { class WindowDestroyedEvent final : public Runnable { public: - WindowDestroyedEvent(nsIDOMWindow* aWindow, uint64_t aID, - const char* aTopic) : - mID(aID), - mPhase(Phase::Destroying), - mTopic(aTopic) + WindowDestroyedEvent(nsIDOMWindow* aWindow, uint64_t aID, const char* aTopic) + : mozilla::Runnable("WindowDestroyedEvent") + , mID(aID) + , mPhase(Phase::Destroying) + , mTopic(aTopic) { mWindow = do_GetWeakReference(aWindow); } @@ -10133,7 +10140,12 @@ public: ChildCommandDispatcher(nsGlobalWindow* aWindow, nsITabChild* aTabChild, const nsAString& aAction) - : mWindow(aWindow), mTabChild(aTabChild), mAction(aAction) {} + : mozilla::Runnable("ChildCommandDispatcher") + , mWindow(aWindow) + , mTabChild(aTabChild) + , mAction(aAction) + { + } NS_IMETHOD Run() override { @@ -10162,7 +10174,11 @@ class CommandDispatcher : public Runnable public: CommandDispatcher(nsIDOMXULCommandDispatcher* aDispatcher, const nsAString& aAction) - : mDispatcher(aDispatcher), mAction(aAction) {} + : mozilla::Runnable("CommandDispatcher") + , mDispatcher(aDispatcher) + , mAction(aAction) + { + } NS_IMETHOD Run() override { @@ -10954,10 +10970,11 @@ nsGlobalWindow::PageHidden() class HashchangeCallback : public Runnable { public: - HashchangeCallback(const nsAString &aOldURL, - const nsAString &aNewURL, + HashchangeCallback(const nsAString& aOldURL, + const nsAString& aNewURL, nsGlobalWindow* aWindow) - : mWindow(aWindow) + : mozilla::Runnable("HashchangeCallback") + , mWindow(aWindow) { MOZ_ASSERT(mWindow); MOZ_ASSERT(mWindow->IsInnerWindow()); @@ -11570,8 +11587,11 @@ public: uint32_t aTimeInS, bool aCallOnidle, nsGlobalWindow* aIdleWindow) - : mIdleObserver(aIdleObserver), mTimeInS(aTimeInS), mIdleWindow(aIdleWindow), - mCallOnidle(aCallOnidle) + : mozilla::Runnable("NotifyIdleObserverRunnable") + , mIdleObserver(aIdleObserver) + , mTimeInS(aTimeInS) + , mIdleWindow(aIdleWindow) + , mCallOnidle(aCallOnidle) { } NS_IMETHOD Run() override @@ -11679,10 +11699,12 @@ nsGlobalWindow::ScheduleNextIdleObserverCallback() } mIdleTimer->Cancel(); - rv = mIdleTimer->InitWithFuncCallback(IdleObserverTimerCallback, - this, - callbackTimeMS, - nsITimer::TYPE_ONE_SHOT); + rv = mIdleTimer->InitWithNamedFuncCallback( + IdleObserverTimerCallback, + this, + callbackTimeMS, + nsITimer::TYPE_ONE_SHOT, + "nsGlobalWindow::ScheduleNextIdleObserverCallback"); NS_ENSURE_SUCCESS(rv, rv); return NS_OK; @@ -11724,10 +11746,12 @@ nsGlobalWindow::ScheduleActiveTimerCallback() mIdleTimer->Cancel(); uint32_t fuzzFactorInMS = GetFuzzTimeMS(); - nsresult rv = mIdleTimer->InitWithFuncCallback(IdleActiveTimerCallback, - this, - fuzzFactorInMS, - nsITimer::TYPE_ONE_SHOT); + nsresult rv = mIdleTimer->InitWithNamedFuncCallback( + IdleActiveTimerCallback, + this, + fuzzFactorInMS, + nsITimer::TYPE_ONE_SHOT, + "nsGlobalWindow::ScheduleActiveTimerCallback"); NS_ENSURE_SUCCESS(rv, rv); return NS_OK; } @@ -12816,7 +12840,8 @@ public: ~AutoUnblockScriptClosing() { void (nsGlobalWindow::*run)() = &nsGlobalWindow::UnblockScriptedClosing; - nsCOMPtr caller = NewRunnableMethod(mWin, run); + nsCOMPtr caller = NewRunnableMethod( + "AutoUnblockScriptClosing::~AutoUnblockScriptClosing", mWin, run); mWin->Dispatch("nsGlobalWindow::UnblockScriptedClosing", TaskCategory::Other, caller.forget()); } diff --git a/dom/base/nsIGlobalObject.cpp b/dom/base/nsIGlobalObject.cpp index 6479c947b370..c3b5a51b922f 100644 --- a/dom/base/nsIGlobalObject.cpp +++ b/dom/base/nsIGlobalObject.cpp @@ -43,6 +43,7 @@ class UnlinkHostObjectURIsRunnable final : public mozilla::Runnable { public: explicit UnlinkHostObjectURIsRunnable(nsTArray& aURIs) + : mozilla::Runnable("UnlinkHostObjectURIsRunnable") { mURIs.SwapElements(aURIs); } diff --git a/dom/base/nsInProcessTabChildGlobal.cpp b/dom/base/nsInProcessTabChildGlobal.cpp index 2a0aeaf7b566..ad80392b05cc 100644 --- a/dom/base/nsInProcessTabChildGlobal.cpp +++ b/dom/base/nsInProcessTabChildGlobal.cpp @@ -309,9 +309,15 @@ nsInProcessTabChildGlobal::InitTabChildGlobal() class nsAsyncScriptLoad : public Runnable { public: - nsAsyncScriptLoad(nsInProcessTabChildGlobal* aTabChild, const nsAString& aURL, - bool aRunInGlobalScope) - : mTabChild(aTabChild), mURL(aURL), mRunInGlobalScope(aRunInGlobalScope) {} + nsAsyncScriptLoad(nsInProcessTabChildGlobal* aTabChild, + const nsAString& aURL, + bool aRunInGlobalScope) + : mozilla::Runnable("nsAsyncScriptLoad") + , mTabChild(aTabChild) + , mURL(aURL) + , mRunInGlobalScope(aRunInGlobalScope) + { + } NS_IMETHOD Run() override { diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index 0d8daf14bc18..ed331ceb5316 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -436,7 +436,8 @@ public: JS::RootingContext* aRootingCx, xpc::ErrorReport* aReport, JS::Handle aError) - : mWindow(aWindow) + : mozilla::Runnable("ScriptErrorEvent") + , mWindow(aWindow) , mReport(aReport) , mError(aRootingCx, aError) {} @@ -2219,7 +2220,11 @@ class NotifyGCEndRunnable : public Runnable nsString mMessage; public: - explicit NotifyGCEndRunnable(const nsString& aMessage) : mMessage(aMessage) {} + explicit NotifyGCEndRunnable(const nsString& aMessage) + : mozilla::Runnable("NotifyGCEndRunnable") + , mMessage(aMessage) + { + } NS_DECL_NSIRUNNABLE }; @@ -2545,7 +2550,8 @@ class AsyncTaskRunnable final : public Runnable public: explicit AsyncTaskRunnable(JS::AsyncTask* aTask) - : mTask(aTask) + : mozilla::Runnable("AsyncTaskRunnable") + , mTask(aTask) { MOZ_ASSERT(mTask); } diff --git a/dom/base/nsJSEnvironment.h b/dom/base/nsJSEnvironment.h index 65f09b3b8d94..4fa39a1977c3 100644 --- a/dom/base/nsJSEnvironment.h +++ b/dom/base/nsJSEnvironment.h @@ -179,7 +179,8 @@ class AsyncErrorReporter final : public mozilla::Runnable public: // aWindow may be null if this error report is not associated with a window explicit AsyncErrorReporter(xpc::ErrorReport* aReport) - : mReport(aReport) + : Runnable("dom::AsyncErrorReporter") + , mReport(aReport) {} NS_IMETHOD Run() override diff --git a/dom/base/nsObjectLoadingContent.cpp b/dom/base/nsObjectLoadingContent.cpp index 2c839a291353..79185173e085 100644 --- a/dom/base/nsObjectLoadingContent.cpp +++ b/dom/base/nsObjectLoadingContent.cpp @@ -279,7 +279,8 @@ public: } nsSimplePluginEvent(nsIDocument* aTarget, const nsAString& aEvent) - : mTarget(aTarget) + : mozilla::Runnable("nsSimplePluginEvent") + , mTarget(aTarget) , mDocument(aTarget) , mEvent(aEvent) { @@ -289,7 +290,8 @@ public: nsSimplePluginEvent(nsIContent* aTarget, nsIDocument* aDocument, const nsAString& aEvent) - : mTarget(aTarget) + : mozilla::Runnable("nsSimplePluginEvent") + , mTarget(aTarget) , mDocument(aDocument) , mEvent(aEvent) { diff --git a/dom/base/nsReferencedElement.h b/dom/base/nsReferencedElement.h index 730a19610058..9380d78da2c3 100644 --- a/dom/base/nsReferencedElement.h +++ b/dom/base/nsReferencedElement.h @@ -129,8 +129,12 @@ private: { public: ChangeNotification(nsReferencedElement* aTarget, - Element* aFrom, Element* aTo) - : Notification(aTarget), mFrom(aFrom), mTo(aTo) + Element* aFrom, + Element* aTo) + : mozilla::Runnable("nsReferencedElement::ChangeNotification") + , Notification(aTarget) + , mFrom(aFrom) + , mTo(aTo) {} NS_DECL_ISUPPORTS_INHERITED diff --git a/dom/base/nsTextNode.cpp b/dom/base/nsTextNode.cpp index 25c2d3525678..7bf2cfa2510d 100644 --- a/dom/base/nsTextNode.cpp +++ b/dom/base/nsTextNode.cpp @@ -273,7 +273,8 @@ 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; - nsContentUtils::AddScriptRunner(NewRunnableMethod(this, update)); + nsContentUtils::AddScriptRunner( + NewRunnableMethod("nsAttributeTextNode::AttributeChanged", this, update)); } } diff --git a/dom/cache/Context.cpp b/dom/cache/Context.cpp index 66f56a8bcfe3..ea49046f0c67 100644 --- a/dom/cache/Context.cpp +++ b/dom/cache/Context.cpp @@ -736,8 +736,10 @@ Context::ThreadsafeHandle::AllowToClose() // Dispatch is guaranteed to succeed here because we block shutdown until // all Contexts have been destroyed. - nsCOMPtr runnable = - NewRunnableMethod(this, &ThreadsafeHandle::AllowToCloseOnOwningThread); + nsCOMPtr runnable = NewRunnableMethod( + "dom::cache::Context::ThreadsafeHandle::AllowToCloseOnOwningThread", + this, + &ThreadsafeHandle::AllowToCloseOnOwningThread); MOZ_ALWAYS_SUCCEEDS( mOwningEventTarget->Dispatch(runnable.forget(), nsIThread::DISPATCH_NORMAL)); } @@ -752,8 +754,11 @@ Context::ThreadsafeHandle::InvalidateAndAllowToClose() // Dispatch is guaranteed to succeed here because we block shutdown until // all Contexts have been destroyed. - nsCOMPtr runnable = - NewRunnableMethod(this, &ThreadsafeHandle::InvalidateAndAllowToCloseOnOwningThread); + nsCOMPtr runnable = NewRunnableMethod( + "dom::cache::Context::ThreadsafeHandle::" + "InvalidateAndAllowToCloseOnOwningThread", + this, + &ThreadsafeHandle::InvalidateAndAllowToCloseOnOwningThread); MOZ_ALWAYS_SUCCEEDS( mOwningEventTarget->Dispatch(runnable.forget(), nsIThread::DISPATCH_NORMAL)); } diff --git a/dom/cache/Manager.cpp b/dom/cache/Manager.cpp index 357a8f0820e1..b06abb073686 100644 --- a/dom/cache/Manager.cpp +++ b/dom/cache/Manager.cpp @@ -912,7 +912,10 @@ private: // here since we are guaranteed the Action will survive until // CompleteOnInitiatingThread is called. nsCOMPtr runnable = NewNonOwningRunnableMethod( - this, &CachePutAllAction::OnAsyncCopyComplete, aRv); + "dom::cache::Manager::CachePutAllAction::OnAsyncCopyComplete", + this, + &CachePutAllAction::OnAsyncCopyComplete, + aRv); MOZ_ALWAYS_SUCCEEDS( mTarget->Dispatch(runnable.forget(), nsIThread::DISPATCH_NORMAL)); } @@ -1766,7 +1769,8 @@ Manager::~Manager() // Don't spin the event loop in the destructor waiting for the thread to // shutdown. Defer this to the main thread, instead. - MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(NewRunnableMethod(ioThread, &nsIThread::Shutdown))); + MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(NewRunnableMethod("nsIThread::Shutdown", + ioThread, &nsIThread::Shutdown))); } void diff --git a/dom/cache/PrincipalVerifier.cpp b/dom/cache/PrincipalVerifier.cpp index c92db4e788c2..be27134d2f43 100644 --- a/dom/cache/PrincipalVerifier.cpp +++ b/dom/cache/PrincipalVerifier.cpp @@ -65,7 +65,8 @@ PrincipalVerifier::RemoveListener(Listener* aListener) PrincipalVerifier::PrincipalVerifier(Listener* aListener, PBackgroundParent* aActor, const PrincipalInfo& aPrincipalInfo) - : mActor(BackgroundParent::GetContentParent(aActor)) + : Runnable("dom::cache::PrincipalVerifier") + , mActor(BackgroundParent::GetContentParent(aActor)) , mPrincipalInfo(aPrincipalInfo) , mInitiatingEventTarget(GetCurrentThreadSerialEventTarget()) , mResult(NS_OK) diff --git a/dom/cache/ReadStream.cpp b/dom/cache/ReadStream.cpp index 70e41b31eddf..e78377e953d6 100644 --- a/dom/cache/ReadStream.cpp +++ b/dom/cache/ReadStream.cpp @@ -132,7 +132,8 @@ class ReadStream::Inner::NoteClosedRunnable final : public CancelableRunnable { public: explicit NoteClosedRunnable(ReadStream::Inner* aStream) - : mStream(aStream) + : CancelableRunnable("dom::cache::ReadStream::Inner::NoteClosedRunnable") + , mStream(aStream) { } NS_IMETHOD Run() override @@ -167,7 +168,8 @@ class ReadStream::Inner::ForgetRunnable final : public CancelableRunnable { public: explicit ForgetRunnable(ReadStream::Inner* aStream) - : mStream(aStream) + : CancelableRunnable("dom::cache::ReadStream::Inner::ForgetRunnable") + , mStream(aStream) { } NS_IMETHOD Run() override diff --git a/dom/canvas/CanvasRenderingContext2D.cpp b/dom/canvas/CanvasRenderingContext2D.cpp index a1fff6e21ecf..55b3b6e8ab62 100644 --- a/dom/canvas/CanvasRenderingContext2D.cpp +++ b/dom/canvas/CanvasRenderingContext2D.cpp @@ -1576,8 +1576,9 @@ CanvasRenderingContext2D::ScheduleStableStateCallback() mHasPendingStableStateCallback = true; nsContentUtils::RunInStableState( - NewRunnableMethod(this, &CanvasRenderingContext2D::OnStableState) - ); + NewRunnableMethod("dom::CanvasRenderingContext2D::OnStableState", + this, + &CanvasRenderingContext2D::OnStableState)); } void diff --git a/dom/canvas/ImageBitmap.cpp b/dom/canvas/ImageBitmap.cpp index f6d5d86cf698..9af236548061 100644 --- a/dom/canvas/ImageBitmap.cpp +++ b/dom/canvas/ImageBitmap.cpp @@ -1076,7 +1076,8 @@ class FulfillImageBitmapPromiseTask final : public Runnable, { public: FulfillImageBitmapPromiseTask(Promise* aPromise, ImageBitmap* aImageBitmap) - : FulfillImageBitmapPromise(aPromise, aImageBitmap) + : Runnable("dom::FulfillImageBitmapPromiseTask") + , FulfillImageBitmapPromise(aPromise, aImageBitmap) { } @@ -1278,7 +1279,8 @@ public: nsIGlobalObject* aGlobal, Blob& aBlob, const Maybe& aCropRect) - :CreateImageBitmapFromBlob(aPromise, aGlobal, aBlob, aCropRect) + : Runnable("dom::CreateImageBitmapFromBlobTask") + , CreateImageBitmapFromBlob(aPromise, aGlobal, aBlob, aCropRect) { } @@ -1732,12 +1734,18 @@ class MapDataIntoBufferSourceTask final : public Runnable, { public: MapDataIntoBufferSourceTask(JSContext* aCx, - Promise *aPromise, - ImageBitmap *aImageBitmap, + Promise* aPromise, + ImageBitmap* aImageBitmap, const T& aBuffer, int32_t aOffset, ImageBitmapFormat aFormat) - : MapDataIntoBufferSource(aCx, aPromise, aImageBitmap, aBuffer, aOffset, aFormat) + : Runnable("dom::MapDataIntoBufferSourceTask") + , MapDataIntoBufferSource(aCx, + aPromise, + aImageBitmap, + aBuffer, + aOffset, + aFormat) { } diff --git a/dom/canvas/WebGLContext.cpp b/dom/canvas/WebGLContext.cpp index d8f998f7ebf4..cf1a8ff55816 100644 --- a/dom/canvas/WebGLContext.cpp +++ b/dom/canvas/WebGLContext.cpp @@ -1737,9 +1737,10 @@ class UpdateContextLossStatusTask : public CancelableRunnable RefPtr mWebGL; public: - explicit UpdateContextLossStatusTask(WebGLContext* webgl) - : mWebGL(webgl) - { + explicit UpdateContextLossStatusTask(WebGLContext* webgl) + : CancelableRunnable("UpdateContextLossStatusTask") + , mWebGL(webgl) + { } NS_IMETHOD Run() override { diff --git a/dom/canvas/WebGLQuery.cpp b/dom/canvas/WebGLQuery.cpp index c7cdaddfe2fe..f6cc7d54aac2 100644 --- a/dom/canvas/WebGLQuery.cpp +++ b/dom/canvas/WebGLQuery.cpp @@ -18,13 +18,16 @@ class AvailableRunnable final : public Runnable const RefPtr mQuery; public: - explicit AvailableRunnable(WebGLQuery* query) - : mQuery(query) - { } + explicit AvailableRunnable(WebGLQuery* query) + : Runnable("AvailableRunnable") + , mQuery(query) + { + } - NS_IMETHOD Run() override { - mQuery->mCanBeAvailable = true; - return NS_OK; + NS_IMETHOD Run() override + { + mQuery->mCanBeAvailable = true; + return NS_OK; } }; diff --git a/dom/events/AsyncEventDispatcher.cpp b/dom/events/AsyncEventDispatcher.cpp index 3dda3d6b0a7d..e8f702f9ac8a 100644 --- a/dom/events/AsyncEventDispatcher.cpp +++ b/dom/events/AsyncEventDispatcher.cpp @@ -22,8 +22,9 @@ using namespace dom; AsyncEventDispatcher::AsyncEventDispatcher(EventTarget* aTarget, WidgetEvent& aEvent) - : mTarget(aTarget), - mEventMessage(eUnidentifiedEvent) + : CancelableRunnable("AsyncEventDispatcher") + , mTarget(aTarget) + , mEventMessage(eUnidentifiedEvent) { MOZ_ASSERT(mTarget); RefPtr event = diff --git a/dom/events/AsyncEventDispatcher.h b/dom/events/AsyncEventDispatcher.h index 3387eb6224c0..70a623ef2753 100644 --- a/dom/events/AsyncEventDispatcher.h +++ b/dom/events/AsyncEventDispatcher.h @@ -34,9 +34,12 @@ public: * the event is dispatched to it, otherwise the dispatch path starts * at the first chrome ancestor of that target. */ - AsyncEventDispatcher(nsINode* aTarget, const nsAString& aEventType, - bool aBubbles, bool aOnlyChromeDispatch) - : mTarget(aTarget) + AsyncEventDispatcher(nsINode* aTarget, + const nsAString& aEventType, + bool aBubbles, + bool aOnlyChromeDispatch) + : CancelableRunnable("AsyncEventDispatcher") + , mTarget(aTarget) , mEventType(aEventType) , mEventMessage(eUnidentifiedEvent) , mBubbles(aBubbles) @@ -53,7 +56,8 @@ public: AsyncEventDispatcher(nsINode* aTarget, mozilla::EventMessage aEventMessage, bool aBubbles, bool aOnlyChromeDispatch) - : mTarget(aTarget) + : CancelableRunnable("AsyncEventDispatcher") + , mTarget(aTarget) , mEventMessage(aEventMessage) , mBubbles(aBubbles) , mOnlyChromeDispatch(aOnlyChromeDispatch) @@ -64,7 +68,8 @@ public: AsyncEventDispatcher(dom::EventTarget* aTarget, const nsAString& aEventType, bool aBubbles) - : mTarget(aTarget) + : CancelableRunnable("AsyncEventDispatcher") + , mTarget(aTarget) , mEventType(aEventType) , mEventMessage(eUnidentifiedEvent) , mBubbles(aBubbles) @@ -74,7 +79,8 @@ public: AsyncEventDispatcher(dom::EventTarget* aTarget, mozilla::EventMessage aEventMessage, bool aBubbles) - : mTarget(aTarget) + : CancelableRunnable("AsyncEventDispatcher") + , mTarget(aTarget) , mEventMessage(aEventMessage) , mBubbles(aBubbles) { @@ -83,7 +89,8 @@ public: } AsyncEventDispatcher(dom::EventTarget* aTarget, nsIDOMEvent* aEvent) - : mTarget(aTarget) + : CancelableRunnable("AsyncEventDispatcher") + , mTarget(aTarget) , mEvent(aEvent) , mEventMessage(eUnidentifiedEvent) { diff --git a/dom/events/DataTransferItem.cpp b/dom/events/DataTransferItem.cpp index 2bb8ed8ae150..36addf0d02fd 100644 --- a/dom/events/DataTransferItem.cpp +++ b/dom/events/DataTransferItem.cpp @@ -446,9 +446,10 @@ DataTransferItem::GetAsString(FunctionStringCallback* aCallback, class GASRunnable final : public Runnable { public: - GASRunnable(FunctionStringCallback* aCallback, - const nsAString& aStringData) - : mCallback(aCallback), mStringData(aStringData) + GASRunnable(FunctionStringCallback* aCallback, const nsAString& aStringData) + : mozilla::Runnable("GASRunnable") + , mCallback(aCallback) + , mStringData(aStringData) {} NS_IMETHOD Run() override diff --git a/dom/events/EventStateManager.cpp b/dom/events/EventStateManager.cpp index 9cddab077663..c3add0a51c4e 100644 --- a/dom/events/EventStateManager.cpp +++ b/dom/events/EventStateManager.cpp @@ -1412,9 +1412,12 @@ EventStateManager::CreateClickHoldTimer(nsPresContext* inPresContext, int32_t clickHoldDelay = Preferences::GetInt("ui.click_hold_context_menus.delay", 500); mClickHoldTimer->SetTarget(SystemGroup::EventTargetFor(TaskCategory::Other)); - mClickHoldTimer->InitWithFuncCallback(sClickHoldCallback, this, - clickHoldDelay, - nsITimer::TYPE_ONE_SHOT); + mClickHoldTimer->InitWithNamedFuncCallback( + sClickHoldCallback, + this, + clickHoldDelay, + nsITimer::TYPE_ONE_SHOT, + "EventStateManager::CreateClickHoldTimer"); } } // CreateClickHoldTimer diff --git a/dom/events/TextComposition.cpp b/dom/events/TextComposition.cpp index 425737606ff9..f17f2dc27a01 100644 --- a/dom/events/TextComposition.cpp +++ b/dom/events/TextComposition.cpp @@ -712,12 +712,13 @@ TextComposition::HasEditor() const ******************************************************************************/ TextComposition::CompositionEventDispatcher::CompositionEventDispatcher( - TextComposition* aComposition, - nsINode* aEventTarget, - EventMessage aEventMessage, - const nsAString& aData, - bool aIsSynthesizedEvent) - : mTextComposition(aComposition) + TextComposition* aComposition, + nsINode* aEventTarget, + EventMessage aEventMessage, + const nsAString& aData, + bool aIsSynthesizedEvent) + : Runnable("TextComposition::CompositionEventDispatcher") + , mTextComposition(aComposition) , mEventTarget(aEventTarget) , mData(aData) , mEventMessage(aEventMessage) diff --git a/dom/events/TextComposition.h b/dom/events/TextComposition.h index 1925a1c47d3d..4ca3fd0b35bd 100644 --- a/dom/events/TextComposition.h +++ b/dom/events/TextComposition.h @@ -433,7 +433,9 @@ private: EventMessage mEventMessage; bool mIsSynthesizedEvent; - CompositionEventDispatcher() : mIsSynthesizedEvent(false) {}; + CompositionEventDispatcher() + : Runnable("TextComposition::CompositionEventDispatcher") + , mIsSynthesizedEvent(false){}; }; /** diff --git a/dom/events/WheelHandlingHelper.cpp b/dom/events/WheelHandlingHelper.cpp index 301c1803f4c2..4f773009295d 100644 --- a/dom/events/WheelHandlingHelper.cpp +++ b/dom/events/WheelHandlingHelper.cpp @@ -332,8 +332,11 @@ WheelTransaction::SetTimeout() } sTimer->Cancel(); DebugOnly rv = - sTimer->InitWithFuncCallback(OnTimeout, nullptr, GetTimeoutTime(), - nsITimer::TYPE_ONE_SHOT); + sTimer->InitWithNamedFuncCallback(OnTimeout, + nullptr, + GetTimeoutTime(), + nsITimer::TYPE_ONE_SHOT, + "WheelTransaction::SetTimeout"); NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "nsITimer::InitWithFuncCallback failed"); } diff --git a/dom/fetch/Fetch.cpp b/dom/fetch/Fetch.cpp index 24fd3f92247a..6c7a556a3483 100644 --- a/dom/fetch/Fetch.cpp +++ b/dom/fetch/Fetch.cpp @@ -75,7 +75,8 @@ class FetchSignalProxy final : public FetchSignal::Follower public: explicit FetchSignalProxyRunnable(FetchSignalProxy* aProxy) - : mProxy(aProxy) + : Runnable("dom::FetchSignalProxy::FetchSignalProxyRunnable") + , mProxy(aProxy) {} NS_IMETHOD @@ -264,7 +265,8 @@ class MainThreadFetchRunnable : public Runnable public: MainThreadFetchRunnable(WorkerFetchResolver* aResolver, InternalRequest* aRequest) - : mResolver(aResolver) + : Runnable("dom::MainThreadFetchRunnable") + , mResolver(aResolver) , mRequest(aRequest) { MOZ_ASSERT(mResolver); diff --git a/dom/fetch/FetchConsumer.cpp b/dom/fetch/FetchConsumer.cpp index cd80c1f0c4a8..06f46070df14 100644 --- a/dom/fetch/FetchConsumer.cpp +++ b/dom/fetch/FetchConsumer.cpp @@ -58,7 +58,8 @@ class BeginConsumeBodyRunnable final : public Runnable public: explicit BeginConsumeBodyRunnable(FetchBodyConsumer* aConsumer) - : mFetchBodyConsumer(aConsumer) + : Runnable("BeginConsumeBodyRunnable") + , mFetchBodyConsumer(aConsumer) { } NS_IMETHOD diff --git a/dom/fetch/FetchDriver.cpp b/dom/fetch/FetchDriver.cpp index 4fccb249d093..8963f76ddc21 100644 --- a/dom/fetch/FetchDriver.cpp +++ b/dom/fetch/FetchDriver.cpp @@ -643,7 +643,8 @@ class DataAvailableRunnable final : public Runnable public: explicit DataAvailableRunnable(FetchDriverObserver* aObserver) - : mObserver(aObserver) + : Runnable("dom::DataAvailableRunnable") + , mObserver(aObserver) { MOZ_ASSERT(aObserver); } diff --git a/dom/file/MutableBlobStorage.cpp b/dom/file/MutableBlobStorage.cpp index 66dbfb51a47b..3823b9204b6a 100644 --- a/dom/file/MutableBlobStorage.cpp +++ b/dom/file/MutableBlobStorage.cpp @@ -31,7 +31,8 @@ public: MutableBlobStorageCallback* aCallback, Blob* aBlob, nsresult aRv) - : mBlobStorage(aBlobStorage) + : Runnable("dom::BlobCreationDoneRunnable") + , mBlobStorage(aBlobStorage) , mCallback(aCallback) , mBlob(aBlob) , mRv(aRv) @@ -79,7 +80,8 @@ class FileCreatedRunnable final : public Runnable { public: FileCreatedRunnable(MutableBlobStorage* aBlobStorage, PRFileDesc* aFD) - : mBlobStorage(aBlobStorage) + : Runnable("dom::FileCreatedRunnable") + , mBlobStorage(aBlobStorage) , mFD(aFD) { MOZ_ASSERT(aBlobStorage); @@ -114,7 +116,8 @@ class CreateTemporaryFileRunnable final : public Runnable { public: explicit CreateTemporaryFileRunnable(MutableBlobStorage* aBlobStorage) - : mBlobStorage(aBlobStorage) + : Runnable("dom::CreateTemporaryFileRunnable") + , mBlobStorage(aBlobStorage) { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(XRE_IsParentProcess()); @@ -148,7 +151,8 @@ class ErrorPropagationRunnable final : public Runnable { public: ErrorPropagationRunnable(MutableBlobStorage* aBlobStorage, nsresult aRv) - : mBlobStorage(aBlobStorage) + : Runnable("dom::ErrorPropagationRunnable") + , mBlobStorage(aBlobStorage) , mRv(aRv) {} @@ -217,9 +221,12 @@ public: } private: - WriteRunnable(MutableBlobStorage* aBlobStorage, PRFileDesc* aFD, - void* aData, uint32_t aLength) - : mBlobStorage(aBlobStorage) + WriteRunnable(MutableBlobStorage* aBlobStorage, + PRFileDesc* aFD, + void* aData, + uint32_t aLength) + : Runnable("dom::WriteRunnable") + , mBlobStorage(aBlobStorage) , mFD(aFD) , mData(aData) , mLength(aLength) @@ -247,7 +254,8 @@ class CloseFileRunnable final : public Runnable { public: explicit CloseFileRunnable(PRFileDesc* aFD) - : mFD(aFD) + : Runnable("dom::CloseFileRunnable") + , mFD(aFD) {} NS_IMETHOD @@ -279,7 +287,8 @@ public: already_AddRefed aParent, const nsACString& aContentType, already_AddRefed aCallback) - : mBlobStorage(aBlobStorage) + : Runnable("dom::CreateBlobRunnable") + , mBlobStorage(aBlobStorage) , mParent(aParent) , mContentType(aContentType) , mCallback(aCallback) @@ -327,7 +336,8 @@ public: nsISupports* aParent, const nsACString& aContentType, MutableBlobStorageCallback* aCallback) - : mBlobStorage(aBlobStorage) + : Runnable("dom::LastRunnable") + , mBlobStorage(aBlobStorage) , mParent(aParent) , mContentType(aContentType) , mCallback(aCallback) diff --git a/dom/file/ipc/IPCBlobInputStream.cpp b/dom/file/ipc/IPCBlobInputStream.cpp index 2bd24d1c53f5..b0afe07bfb61 100644 --- a/dom/file/ipc/IPCBlobInputStream.cpp +++ b/dom/file/ipc/IPCBlobInputStream.cpp @@ -46,7 +46,8 @@ public: private: CallbackRunnable(nsIInputStreamCallback* aCallback, IPCBlobInputStream* aStream) - : mCallback(aCallback) + : CancelableRunnable("dom::CallbackRunnable") + , mCallback(aCallback) , mStream(aStream) { MOZ_ASSERT(mCallback); diff --git a/dom/file/ipc/IPCBlobInputStreamChild.cpp b/dom/file/ipc/IPCBlobInputStreamChild.cpp index 4d107d2f0e58..06098a0b37ce 100644 --- a/dom/file/ipc/IPCBlobInputStreamChild.cpp +++ b/dom/file/ipc/IPCBlobInputStreamChild.cpp @@ -25,7 +25,8 @@ class ShutdownRunnable final : public CancelableRunnable { public: explicit ShutdownRunnable(IPCBlobInputStreamChild* aActor) - : mActor(aActor) + : CancelableRunnable("dom::ShutdownRunnable") + , mActor(aActor) {} NS_IMETHOD @@ -45,7 +46,8 @@ class StreamNeededRunnable final : public CancelableRunnable { public: explicit StreamNeededRunnable(IPCBlobInputStreamChild* aActor) - : mActor(aActor) + : CancelableRunnable("dom::StreamNeededRunnable") + , mActor(aActor) {} NS_IMETHOD @@ -70,7 +72,8 @@ class StreamReadyRunnable final : public CancelableRunnable public: StreamReadyRunnable(IPCBlobInputStream* aDestinationStream, nsIInputStream* aCreatedStream) - : mDestinationStream(aDestinationStream) + : CancelableRunnable("dom::StreamReadyRunnable") + , mDestinationStream(aDestinationStream) , mCreatedStream(aCreatedStream) { MOZ_ASSERT(mDestinationStream); @@ -102,8 +105,10 @@ public: class ReleaseWorkerHolderRunnable final : public CancelableRunnable { public: - explicit ReleaseWorkerHolderRunnable(UniquePtr&& aWorkerHolder) - : mWorkerHolder(Move(aWorkerHolder)) + explicit ReleaseWorkerHolderRunnable( + UniquePtr&& aWorkerHolder) + : CancelableRunnable("dom::ReleaseWorkerHolderRunnable") + , mWorkerHolder(Move(aWorkerHolder)) {} NS_IMETHOD diff --git a/dom/file/ipc/IPCBlobInputStreamThread.cpp b/dom/file/ipc/IPCBlobInputStreamThread.cpp index 29090da92ef1..6c40453a6f61 100644 --- a/dom/file/ipc/IPCBlobInputStreamThread.cpp +++ b/dom/file/ipc/IPCBlobInputStreamThread.cpp @@ -27,6 +27,8 @@ bool gShutdownHasStarted = false; class ThreadInitializeRunnable final : public Runnable { public: + ThreadInitializeRunnable() : Runnable("dom::ThreadInitializeRunnable") {} + NS_IMETHOD Run() override { @@ -44,7 +46,8 @@ public: NS_DECL_ISUPPORTS_INHERITED explicit MigrateActorRunnable(IPCBlobInputStreamChild* aActor) - : mActor(aActor) + : Runnable("dom::MigrateActorRunnable") + , mActor(aActor) { MOZ_ASSERT(mActor); } diff --git a/dom/filehandle/ActorsParent.cpp b/dom/filehandle/ActorsParent.cpp index 9895aeef38f9..3fbff0611c0f 100644 --- a/dom/filehandle/ActorsParent.cpp +++ b/dom/filehandle/ActorsParent.cpp @@ -588,7 +588,8 @@ public: ProgressRunnable(CopyFileHandleOp* aCopyFileHandleOp, uint64_t aProgress, uint64_t aProgressMax) - : mCopyFileHandleOp(aCopyFileHandleOp) + : Runnable("dom::CopyFileHandleOp::ProgressRunnable") + , mCopyFileHandleOp(aCopyFileHandleOp) , mProgress(aProgress) , mProgressMax(aProgressMax) { } @@ -1081,10 +1082,11 @@ FileHandleThreadPool::MaybeFireCallback(StoragesCompleteCallback* aCallback) return true; } -FileHandleThreadPool:: -FileHandleQueue::FileHandleQueue(FileHandleThreadPool* aFileHandleThreadPool, - FileHandle* aFileHandle) - : mOwningFileHandleThreadPool(aFileHandleThreadPool) +FileHandleThreadPool::FileHandleQueue::FileHandleQueue( + FileHandleThreadPool* aFileHandleThreadPool, + FileHandle* aFileHandle) + : Runnable("dom::FileHandleThreadPool::FileHandleQueue") + , mOwningFileHandleThreadPool(aFileHandleThreadPool) , mFileHandle(aFileHandle) , mShouldFinish(false) { diff --git a/dom/filesystem/FileSystemRequestParent.cpp b/dom/filesystem/FileSystemRequestParent.cpp index a7ff9ba39baf..4f234a03fd9f 100644 --- a/dom/filesystem/FileSystemRequestParent.cpp +++ b/dom/filesystem/FileSystemRequestParent.cpp @@ -82,7 +82,8 @@ public: FileSystemRequestParent* aActor, FileSystemTaskParentBase* aTask, const nsAString& aPath) - : mContentParent(aParent) + : Runnable("dom::CheckPermissionRunnable") + , mContentParent(aParent) , mActor(aActor) , mTask(aTask) , mPath(aPath) diff --git a/dom/filesystem/FileSystemTaskBase.cpp b/dom/filesystem/FileSystemTaskBase.cpp index 4b28529d7518..307e8648993c 100644 --- a/dom/filesystem/FileSystemTaskBase.cpp +++ b/dom/filesystem/FileSystemTaskBase.cpp @@ -231,10 +231,12 @@ FileSystemTaskChildBase::SetError(const nsresult& aErrorValue) * FileSystemTaskParentBase class */ -FileSystemTaskParentBase::FileSystemTaskParentBase(FileSystemBase* aFileSystem, - const FileSystemParams& aParam, - FileSystemRequestParent* aParent) - : mErrorValue(NS_OK) +FileSystemTaskParentBase::FileSystemTaskParentBase( + FileSystemBase* aFileSystem, + const FileSystemParams& aParam, + FileSystemRequestParent* aParent) + : Runnable("dom::FileSystemTaskParentBase") + , mErrorValue(NS_OK) , mFileSystem(aFileSystem) , mRequestParent(aParent) , mBackgroundEventTarget(GetCurrentThreadEventTarget()) diff --git a/dom/filesystem/GetFilesHelper.cpp b/dom/filesystem/GetFilesHelper.cpp index f2e0d5333c9b..7d77e241d2b6 100644 --- a/dom/filesystem/GetFilesHelper.cpp +++ b/dom/filesystem/GetFilesHelper.cpp @@ -61,6 +61,7 @@ private: nsTArray>& aCallbacks, Sequence>& aFiles, already_AddRefed aGlobal) + : Runnable("dom::ReleaseRunnable") { mPromises.SwapElements(aPromises); mCallbacks.SwapElements(aCallbacks); diff --git a/dom/flyweb/HttpServer.cpp b/dom/flyweb/HttpServer.cpp index 83ad916294ea..776d5b0ca43e 100644 --- a/dom/flyweb/HttpServer.cpp +++ b/dom/flyweb/HttpServer.cpp @@ -89,10 +89,9 @@ void HttpServer::NotifyStarted(nsresult aStatus) { RefPtr listener = mListener; - nsCOMPtr event = NS_NewRunnableFunction([listener, aStatus] () - { - listener->OnServerStarted(aStatus); - }); + nsCOMPtr event = NS_NewRunnableFunction( + "dom::HttpServer::NotifyStarted", + [listener, aStatus]() { listener->OnServerStarted(aStatus); }); NS_DispatchToCurrentThread(event); } @@ -288,12 +287,12 @@ HttpServer::TransportProvider::MaybeNotify() { if (mTransport && mListener) { RefPtr self = this; - nsCOMPtr event = NS_NewRunnableFunction([self, this] () - { - DebugOnly rv = mListener->OnTransportAvailable(mTransport, - mInput, mOutput); - MOZ_ASSERT(NS_SUCCEEDED(rv)); - }); + nsCOMPtr event = NS_NewRunnableFunction( + "dom::HttpServer::TransportProvider::MaybeNotify", [self, this]() { + DebugOnly rv = + mListener->OnTransportAvailable(mTransport, mInput, mOutput); + MOZ_ASSERT(NS_SUCCEEDED(rv)); + }); NS_DispatchToCurrentThread(event); } } @@ -633,11 +632,9 @@ HttpServer::Connection::ConsumeLine(const char* aBuffer, RefPtr listener = mServer->mListener; RefPtr request = mPendingWebSocketRequest; - nsCOMPtr event = - NS_NewRunnableFunction([listener, request] () - { - listener->OnWebSocket(request); - }); + nsCOMPtr event = NS_NewRunnableFunction( + "dom::HttpServer::Connection::ConsumeLine", + [listener, request]() { listener->OnWebSocket(request); }); NS_DispatchToCurrentThread(event); return NS_OK; @@ -702,11 +699,9 @@ HttpServer::Connection::ConsumeLine(const char* aBuffer, RefPtr listener = mServer->mListener; RefPtr request = mPendingReq.forget(); - nsCOMPtr event = - NS_NewRunnableFunction([listener, request] () - { - listener->OnRequest(request); - }); + nsCOMPtr event = NS_NewRunnableFunction( + "dom::HttpServer::Connection::ConsumeLine", + [listener, request]() { listener->OnRequest(request); }); NS_DispatchToCurrentThread(event); mPendingReqVersion = 0; diff --git a/dom/gamepad/cocoa/CocoaGamepad.cpp b/dom/gamepad/cocoa/CocoaGamepad.cpp index 9520ef454e84..76208303f811 100644 --- a/dom/gamepad/cocoa/CocoaGamepad.cpp +++ b/dom/gamepad/cocoa/CocoaGamepad.cpp @@ -235,7 +235,7 @@ class DarwinGamepadServiceStartupRunnable final : public Runnable DarwinGamepadService MOZ_NON_OWNING_REF *mService; public: explicit DarwinGamepadServiceStartupRunnable(DarwinGamepadService *service) - : mService(service) {} + : Runnable("DarwinGamepadServiceStartupRunnable"), mService(service) {} NS_IMETHOD Run() override { MOZ_ASSERT(mService); diff --git a/dom/gamepad/ipc/GamepadEventChannelChild.cpp b/dom/gamepad/ipc/GamepadEventChannelChild.cpp index a7e4e4ddc87c..efeb11505794 100644 --- a/dom/gamepad/ipc/GamepadEventChannelChild.cpp +++ b/dom/gamepad/ipc/GamepadEventChannelChild.cpp @@ -12,15 +12,18 @@ namespace { class GamepadUpdateRunnable final : public Runnable { public: - explicit GamepadUpdateRunnable(const GamepadChangeEvent& aGamepadEvent) - : mEvent(aGamepadEvent) {} - NS_IMETHOD Run() override - { - RefPtr svc(GamepadManager::GetService()); - if (svc) { - svc->Update(mEvent); - } - return NS_OK; + explicit GamepadUpdateRunnable(const GamepadChangeEvent& aGamepadEvent) + : Runnable("dom::GamepadUpdateRunnable") + , mEvent(aGamepadEvent) + { + } + NS_IMETHOD Run() override + { + RefPtr svc(GamepadManager::GetService()); + if (svc) { + svc->Update(mEvent); + } + return NS_OK; } protected: GamepadChangeEvent mEvent; diff --git a/dom/gamepad/ipc/GamepadEventChannelParent.cpp b/dom/gamepad/ipc/GamepadEventChannelParent.cpp index 9af3b8a3707b..c50ed7e68437 100644 --- a/dom/gamepad/ipc/GamepadEventChannelParent.cpp +++ b/dom/gamepad/ipc/GamepadEventChannelParent.cpp @@ -20,12 +20,13 @@ class SendGamepadUpdateRunnable final : public Runnable RefPtr mParent; GamepadChangeEvent mEvent; public: - SendGamepadUpdateRunnable(GamepadEventChannelParent* aParent, - GamepadChangeEvent aEvent) - : mEvent(aEvent) - { - MOZ_ASSERT(aParent); - mParent = aParent; + SendGamepadUpdateRunnable(GamepadEventChannelParent* aParent, + GamepadChangeEvent aEvent) + : Runnable("dom::SendGamepadUpdateRunnable") + , mEvent(aEvent) + { + MOZ_ASSERT(aParent); + mParent = aParent; } NS_IMETHOD Run() override { diff --git a/dom/gamepad/windows/WindowsGamepad.cpp b/dom/gamepad/windows/WindowsGamepad.cpp index 6a8b595e248b..bfe712b962c8 100644 --- a/dom/gamepad/windows/WindowsGamepad.cpp +++ b/dom/gamepad/windows/WindowsGamepad.cpp @@ -1002,7 +1002,9 @@ GamepadWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) class StartWindowsGamepadServiceRunnable final : public Runnable { public: - StartWindowsGamepadServiceRunnable() {} + StartWindowsGamepadServiceRunnable() + : Runnable("StartWindowsGamepadServiceRunnable") + {} NS_IMETHOD Run() override { @@ -1040,7 +1042,9 @@ private: class StopWindowsGamepadServiceRunnable final : public Runnable { public: - StopWindowsGamepadServiceRunnable() {} + StopWindowsGamepadServiceRunnable() + : Runnable("StopWindowsGamepadServiceRunnable") + {} NS_IMETHOD Run() override { diff --git a/dom/geolocation/nsGeolocation.cpp b/dom/geolocation/nsGeolocation.cpp index 2440015b51bd..50b3dd9620ff 100644 --- a/dom/geolocation/nsGeolocation.cpp +++ b/dom/geolocation/nsGeolocation.cpp @@ -147,7 +147,8 @@ class RequestPromptEvent : public Runnable { public: RequestPromptEvent(nsGeolocationRequest* aRequest, nsWeakPtr aWindow) - : mRequest(aRequest) + : mozilla::Runnable("RequestPromptEvent") + , mRequest(aRequest) , mWindow(aWindow) { } @@ -168,8 +169,9 @@ class RequestAllowEvent : public Runnable { public: RequestAllowEvent(int allow, nsGeolocationRequest* request) - : mAllow(allow), - mRequest(request) + : mozilla::Runnable("RequestAllowEvent") + , mAllow(allow) + , mRequest(request) { } @@ -192,8 +194,9 @@ class RequestSendLocationEvent : public Runnable public: RequestSendLocationEvent(nsIDOMGeoPosition* aPosition, nsGeolocationRequest* aRequest) - : mPosition(aPosition), - mRequest(aRequest) + : mozilla::Runnable("RequestSendLocationEvent") + , mPosition(aPosition) + , mRequest(aRequest) { } diff --git a/dom/html/HTMLCanvasElement.cpp b/dom/html/HTMLCanvasElement.cpp index 5daf4b67935e..d1f6f491ff65 100644 --- a/dom/html/HTMLCanvasElement.cpp +++ b/dom/html/HTMLCanvasElement.cpp @@ -241,8 +241,10 @@ HTMLCanvasPrintState::Done() if (mCanvas) { mCanvas->InvalidateCanvas(); } - RefPtr > doneEvent = - NewRunnableMethod(this, &HTMLCanvasPrintState::NotifyDone); + RefPtr> doneEvent = + NewRunnableMethod("dom::HTMLCanvasPrintState::NotifyDone", + this, + &HTMLCanvasPrintState::NotifyDone); if (NS_SUCCEEDED(NS_DispatchToCurrentThread(doneEvent))) { mPendingNotify = true; } @@ -521,8 +523,10 @@ HTMLCanvasElement::DispatchPrintCallback(nsITimerCallback* aCallback) } mPrintState = new HTMLCanvasPrintState(this, mCurrentContext, aCallback); - RefPtr > renderEvent = - NewRunnableMethod(this, &HTMLCanvasElement::CallPrintCallback); + RefPtr> renderEvent = + NewRunnableMethod("dom::HTMLCanvasElement::CallPrintCallback", + this, + &HTMLCanvasElement::CallPrintCallback); return OwnerDoc()->Dispatch("HTMLCanvasElement::CallPrintCallback", TaskCategory::Other, renderEvent.forget()); @@ -844,13 +848,16 @@ HTMLCanvasElement::ToBlob(JSContext* aCx, // According to spec, blob should return null if either its horizontal // dimension or its vertical dimension is zero. See link below. // https://html.spec.whatwg.org/multipage/scripting.html#dom-canvas-toblob - OwnerDoc()->Dispatch("FireNullBlobEvent", - TaskCategory::Other, - NewRunnableMethod( - &aCallback, - static_cast(&BlobCallback::Call), - nullptr, nullptr)); + OwnerDoc()->Dispatch( + "FireNullBlobEvent", + TaskCategory::Other, + NewRunnableMethod( + "dom::HTMLCanvasElement::ToBlob", + &aCallback, + static_cast( + &BlobCallback::Call), + nullptr, + nullptr)); return; } @@ -1353,7 +1360,8 @@ HTMLCanvasElement::OnVisibilityChange() { public: explicit Runnable(AsyncCanvasRenderer* aRenderer) - : mRenderer(aRenderer) + : mozilla::CancelableRunnable("Runnable") + , mRenderer(aRenderer) {} NS_IMETHOD Run() override @@ -1395,7 +1403,8 @@ HTMLCanvasElement::OnMemoryPressure() { public: explicit Runnable(AsyncCanvasRenderer* aRenderer) - : mRenderer(aRenderer) + : mozilla::CancelableRunnable("Runnable") + , mRenderer(aRenderer) {} NS_IMETHOD Run() override diff --git a/dom/html/HTMLFormElement.h b/dom/html/HTMLFormElement.h index 284d3a6925b7..74a993be7c19 100644 --- a/dom/html/HTMLFormElement.h +++ b/dom/html/HTMLFormElement.h @@ -426,7 +426,8 @@ protected: class RemoveElementRunnable : public Runnable { public: explicit RemoveElementRunnable(HTMLFormElement* aForm) - : mForm(aForm) + : Runnable("dom::HTMLFormElement::RemoveElementRunnable") + , mForm(aForm) {} NS_IMETHOD Run() override { diff --git a/dom/html/HTMLImageElement.cpp b/dom/html/HTMLImageElement.cpp index de50d2250008..13151bdc303c 100644 --- a/dom/html/HTMLImageElement.cpp +++ b/dom/html/HTMLImageElement.cpp @@ -79,9 +79,11 @@ namespace dom { class ImageLoadTask : public Runnable { public: - ImageLoadTask(HTMLImageElement *aElement, bool aAlwaysLoad, + ImageLoadTask(HTMLImageElement* aElement, + bool aAlwaysLoad, bool aUseUrgentStartForChannel) - : mElement(aElement) + : Runnable("dom::ImageLoadTask") + , mElement(aElement) , mAlwaysLoad(aAlwaysLoad) , mUseUrgentStartForChannel(aUseUrgentStartForChannel) { @@ -676,7 +678,10 @@ HTMLImageElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, if (LoadingEnabled() && OwnerDoc()->IsCurrentActiveDocument()) { nsContentUtils::AddScriptRunner( - NewRunnableMethod(this, &HTMLImageElement::MaybeLoadImage, false)); + NewRunnableMethod("dom::HTMLImageElement::MaybeLoadImage", + this, + &HTMLImageElement::MaybeLoadImage, + false)); } } @@ -769,9 +774,14 @@ HTMLImageElement::NodeInfoChanged(nsIDocument* aOldDoc) // Bug 1076583 - We still behave synchronously in the non-responsive case nsContentUtils::AddScriptRunner( (InResponsiveMode()) - ? NewRunnableMethod(this, &HTMLImageElement::QueueImageLoadTask, true) - : NewRunnableMethod(this, &HTMLImageElement::MaybeLoadImage, true) - ); + ? NewRunnableMethod("dom::HTMLImageElement::QueueImageLoadTask", + this, + &HTMLImageElement::QueueImageLoadTask, + true) + : NewRunnableMethod("dom::HTMLImageElement::MaybeLoadImage", + this, + &HTMLImageElement::MaybeLoadImage, + true)); } } @@ -894,7 +904,10 @@ HTMLImageElement::CopyInnerTo(Element* aDest, bool aPreallocateChildren) mUseUrgentStartForChannel = EventStateManager::IsHandlingUserInput(); nsContentUtils::AddScriptRunner( - NewRunnableMethod(dest, &HTMLImageElement::MaybeLoadImage, false)); + NewRunnableMethod("dom::HTMLImageElement::MaybeLoadImage", + dest, + &HTMLImageElement::MaybeLoadImage, + false)); } } diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp index 0f890531ca93..e9c3cf6f7dd3 100644 --- a/dom/html/HTMLInputElement.cpp +++ b/dom/html/HTMLInputElement.cpp @@ -4870,7 +4870,9 @@ HTMLInputElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, ClearBrokenState(); RemoveStatesSilently(NS_EVENT_STATE_BROKEN); nsContentUtils::AddScriptRunner( - NewRunnableMethod(this, &HTMLInputElement::MaybeLoadImage)); + NewRunnableMethod("dom::HTMLInputElement::MaybeLoadImage", + this, + &HTMLInputElement::MaybeLoadImage)); } } diff --git a/dom/html/HTMLLinkElement.cpp b/dom/html/HTMLLinkElement.cpp index a28d5f57c172..feba468c9196 100644 --- a/dom/html/HTMLLinkElement.cpp +++ b/dom/html/HTMLLinkElement.cpp @@ -171,7 +171,8 @@ HTMLLinkElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, } void (HTMLLinkElement::*update)() = &HTMLLinkElement::UpdateStyleSheetInternal; - nsContentUtils::AddScriptRunner(NewRunnableMethod(this, update)); + nsContentUtils::AddScriptRunner( + NewRunnableMethod("dom::HTMLLinkElement::BindToTree", this, update)); CreateAndDispatchEvent(aDocument, NS_LITERAL_STRING("DOMLinkAdded")); diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp index 3544bc57a8da..16da96903dde 100644 --- a/dom/html/HTMLMediaElement.cpp +++ b/dom/html/HTMLMediaElement.cpp @@ -232,10 +232,12 @@ RejectPromises(const nsTArray>& aPromises, nsresult aError) class nsMediaEvent : public Runnable { public: - - explicit nsMediaEvent(HTMLMediaElement* aElement) : - mElement(aElement), - mLoadID(mElement->GetCurrentLoadID()) {} + explicit nsMediaEvent(HTMLMediaElement* aElement) + : Runnable("dom::nsMediaEvent") + , mElement(aElement) + , mLoadID(mElement->GetCurrentLoadID()) + { + } ~nsMediaEvent() {} NS_IMETHOD Run() = 0; @@ -405,9 +407,11 @@ public: for (VideoSegment::ConstChunkIterator c(video); !c.IsEnded(); c.Next()) { if (c->mFrame.GetIntrinsicSize() != gfx::IntSize(0,0)) { mInitialSizeFound = true; - nsCOMPtr event = - NewRunnableMethod(this, &StreamSizeListener::ReceivedSize, - c->mFrame.GetIntrinsicSize()); + nsCOMPtr event = NewRunnableMethod( + "dom::HTMLMediaElement::StreamSizeListener::ReceivedSize", + this, + &StreamSizeListener::ReceivedSize, + c->mFrame.GetIntrinsicSize()); // This is fine to dispatch straight to main thread (instead of via // ...AfterStreamUpdate()) since it reflects state of the element, // not the stream. Events reflecting stream or track state should be @@ -970,24 +974,26 @@ private: } uint64_t windowID = mAudioChannelAgent->WindowID(); - NS_DispatchToMainThread(NS_NewRunnableFunction([windowID]() -> void { - nsCOMPtr observerService = - services::GetObserverService(); - if (NS_WARN_IF(!observerService)) { - return; - } + NS_DispatchToMainThread(NS_NewRunnableFunction( + "dom::HTMLMediaElement::AudioChannelAgentCallback::" + "MaybeNotifyMediaResumed", + [windowID]() -> void { + nsCOMPtr observerService = + services::GetObserverService(); + if (NS_WARN_IF(!observerService)) { + return; + } - nsCOMPtr wrapper = - do_CreateInstance(NS_SUPPORTS_PRUINT64_CONTRACTID); - if (NS_WARN_IF(!wrapper)) { - return; - } + nsCOMPtr wrapper = + do_CreateInstance(NS_SUPPORTS_PRUINT64_CONTRACTID); + if (NS_WARN_IF(!wrapper)) { + return; + } - wrapper->SetData(windowID); - observerService->NotifyObservers(wrapper, - "media-playback-resumed", - u"active"); - })); + wrapper->SetData(windowID); + observerService->NotifyObservers( + wrapper, "media-playback-resumed", u"active"); + })); } bool @@ -4090,8 +4096,12 @@ HTMLMediaElement::WakeLockBoolWrapper::UpdateWakeLock() int timeout = Preferences::GetInt("media.wakelock_timeout", 2000); mTimer = do_CreateInstance("@mozilla.org/timer;1"); if (mTimer) { - mTimer->InitWithFuncCallback(TimerCallback, this, timeout, - nsITimer::TYPE_ONE_SHOT); + mTimer->InitWithNamedFuncCallback( + TimerCallback, + this, + timeout, + nsITimer::TYPE_ONE_SHOT, + "dom::HTMLMediaElement::WakeLockBoolWrapper::UpdateWakeLock"); } } } @@ -4531,11 +4541,12 @@ void HTMLMediaElement::UnbindFromTree(bool aDeep, NotifyDecoderActivityChanges(); RefPtr self(this); - nsCOMPtr task = NS_NewRunnableFunction([self] () { - if (self->mUnboundFromTree) { - self->Pause(); - } - }); + nsCOMPtr task = + NS_NewRunnableFunction("dom::HTMLMediaElement::UnbindFromTree", [self]() { + if (self->mUnboundFromTree) { + self->Pause(); + } + }); RunInStableState(task); } @@ -4844,9 +4855,15 @@ public: { nsCOMPtr event; if (aBlocked == BLOCKED) { - event = NewRunnableMethod(this, &StreamListener::DoNotifyBlocked); + event = NewRunnableMethod( + "dom::HTMLMediaElement::StreamListener::DoNotifyBlocked", + this, + &StreamListener::DoNotifyBlocked); } else { - event = NewRunnableMethod(this, &StreamListener::DoNotifyUnblocked); + event = NewRunnableMethod( + "dom::HTMLMediaElement::StreamListener::DoNotifyUnblocked", + this, + &StreamListener::DoNotifyUnblocked); } aGraph->DispatchToMainThreadAfterStreamStateUpdate(mAbstractMainThread, event.forget()); @@ -4856,7 +4873,10 @@ public: MutexAutoLock lock(mMutex); aGraph->DispatchToMainThreadAfterStreamStateUpdate( mAbstractMainThread, - NewRunnableMethod(this, &StreamListener::DoNotifyHaveCurrentData)); + NewRunnableMethod( + "dom::HTMLMediaElement::StreamListener::DoNotifyHaveCurrentData", + this, + &StreamListener::DoNotifyHaveCurrentData)); } virtual void NotifyOutput(MediaStreamGraph* aGraph, GraphTime aCurrentTime) override @@ -4867,7 +4887,9 @@ public: mPendingNotifyOutput = true; aGraph->DispatchToMainThreadAfterStreamStateUpdate( mAbstractMainThread, - NewRunnableMethod(this, &StreamListener::DoNotifyOutput)); + NewRunnableMethod("dom::HTMLMediaElement::StreamListener::DoNotifyOutput", + this, + &StreamListener::DoNotifyOutput)); } private: @@ -6296,7 +6318,9 @@ 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 = - NewRunnableMethod(this, &HTMLMediaElement::DoRemoveSelfReference); + NewRunnableMethod("dom::HTMLMediaElement::DoRemoveSelfReference", + this, + &HTMLMediaElement::DoRemoveSelfReference); NS_DispatchToMainThread(event); } } @@ -7493,9 +7517,9 @@ HTMLMediaElement::AsyncResolveSeekDOMPromiseIfExists() MOZ_ASSERT(NS_IsMainThread()); if (mSeekDOMPromise) { RefPtr promise = mSeekDOMPromise.forget(); - nsCOMPtr r = NS_NewRunnableFunction([=] () { - promise->MaybeResolveWithUndefined(); - }); + nsCOMPtr r = NS_NewRunnableFunction( + "dom::HTMLMediaElement::AsyncResolveSeekDOMPromiseIfExists", + [=]() { promise->MaybeResolveWithUndefined(); }); mAbstractMainThread->Dispatch(r.forget()); mSeekDOMPromise = nullptr; } @@ -7507,9 +7531,9 @@ HTMLMediaElement::AsyncRejectSeekDOMPromiseIfExists() MOZ_ASSERT(NS_IsMainThread()); if (mSeekDOMPromise) { RefPtr promise = mSeekDOMPromise.forget(); - nsCOMPtr r = NS_NewRunnableFunction([=] () { - promise->MaybeReject(NS_ERROR_DOM_ABORT_ERR); - }); + nsCOMPtr r = NS_NewRunnableFunction( + "dom::HTMLMediaElement::AsyncRejectSeekDOMPromiseIfExists", + [=]() { promise->MaybeReject(NS_ERROR_DOM_ABORT_ERR); }); mAbstractMainThread->Dispatch(r.forget()); mSeekDOMPromise = nullptr; } @@ -7527,29 +7551,32 @@ HTMLMediaElement::ReportCanPlayTelemetry() } thread->Dispatch( - NS_NewRunnableFunction([thread]() { + NS_NewRunnableFunction( + "dom::HTMLMediaElement::ReportCanPlayTelemetry", + [thread]() { #if XP_WIN - // Windows Media Foundation requires MSCOM to be inited. - HRESULT hr = CoInitializeEx(0, COINIT_MULTITHREADED); - MOZ_ASSERT(hr == S_OK); + // Windows Media Foundation requires MSCOM to be inited. + HRESULT hr = CoInitializeEx(0, COINIT_MULTITHREADED); + MOZ_ASSERT(hr == S_OK); #endif - bool aac = MP4Decoder::IsSupportedType( - MediaContainerType(MEDIAMIMETYPE("audio/mp4")), nullptr); - bool h264 = MP4Decoder::IsSupportedType( - MediaContainerType(MEDIAMIMETYPE("video/mp4")), nullptr); + bool aac = MP4Decoder::IsSupportedType( + MediaContainerType(MEDIAMIMETYPE("audio/mp4")), nullptr); + bool h264 = MP4Decoder::IsSupportedType( + MediaContainerType(MEDIAMIMETYPE("video/mp4")), nullptr); #if XP_WIN - CoUninitialize(); + CoUninitialize(); #endif - AbstractThread::MainThread()->Dispatch( - NS_NewRunnableFunction([thread, aac, h264]() { - LOG(LogLevel::Debug, ("MediaTelemetry aac=%d h264=%d", aac, h264)); - Telemetry::Accumulate( - Telemetry::HistogramID::VIDEO_CAN_CREATE_AAC_DECODER, aac); - Telemetry::Accumulate( - Telemetry::HistogramID::VIDEO_CAN_CREATE_H264_DECODER, h264); - thread->AsyncShutdown(); - })); - }), + AbstractThread::MainThread()->Dispatch(NS_NewRunnableFunction( + "dom::HTMLMediaElement::ReportCanPlayTelemetry", + [thread, aac, h264]() { + LOG(LogLevel::Debug, ("MediaTelemetry aac=%d h264=%d", aac, h264)); + Telemetry::Accumulate( + Telemetry::HistogramID::VIDEO_CAN_CREATE_AAC_DECODER, aac); + Telemetry::Accumulate( + Telemetry::HistogramID::VIDEO_CAN_CREATE_H264_DECODER, h264); + thread->AsyncShutdown(); + })); + }), NS_DISPATCH_NORMAL); } diff --git a/dom/html/HTMLObjectElement.cpp b/dom/html/HTMLObjectElement.cpp index b06133d9b5b4..100f022ce9ce 100644 --- a/dom/html/HTMLObjectElement.cpp +++ b/dom/html/HTMLObjectElement.cpp @@ -131,7 +131,9 @@ class PluginFocusSetter : public Runnable { public: PluginFocusSetter(nsIWidget* aWidget, Element* aElement) - : mWidget(aWidget), mElement(aElement) + : Runnable("PluginFocusSetter") + , mWidget(aWidget) + , mElement(aElement) { } @@ -269,7 +271,8 @@ HTMLObjectElement::BindToTree(nsIDocument *aDocument, // If we already have all the children, start the load. if (mIsDoneAddingChildren && !pluginDoc) { void (HTMLObjectElement::*start)() = &HTMLObjectElement::StartObjectLoad; - nsContentUtils::AddScriptRunner(NewRunnableMethod(this, start)); + nsContentUtils::AddScriptRunner( + NewRunnableMethod("dom::HTMLObjectElement::BindToTree", this, start)); } return NS_OK; diff --git a/dom/html/HTMLSharedObjectElement.cpp b/dom/html/HTMLSharedObjectElement.cpp index 4897ee516393..1f02624f1679 100644 --- a/dom/html/HTMLSharedObjectElement.cpp +++ b/dom/html/HTMLSharedObjectElement.cpp @@ -139,7 +139,8 @@ HTMLSharedObjectElement::BindToTree(nsIDocument *aDocument, if (mIsDoneAddingChildren && !pluginDoc) { void (HTMLSharedObjectElement::*start)() = &HTMLSharedObjectElement::StartObjectLoad; - nsContentUtils::AddScriptRunner(NewRunnableMethod(this, start)); + nsContentUtils::AddScriptRunner(NewRunnableMethod( + "dom::HTMLSharedObjectElement::BindToTree", this, start)); } return NS_OK; diff --git a/dom/html/HTMLStyleElement.cpp b/dom/html/HTMLStyleElement.cpp index 743f4addb96e..908bf95895ff 100644 --- a/dom/html/HTMLStyleElement.cpp +++ b/dom/html/HTMLStyleElement.cpp @@ -146,7 +146,8 @@ HTMLStyleElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, NS_ENSURE_SUCCESS(rv, rv); void (HTMLStyleElement::*update)() = &HTMLStyleElement::UpdateStyleSheetInternal; - nsContentUtils::AddScriptRunner(NewRunnableMethod(this, update)); + nsContentUtils::AddScriptRunner( + NewRunnableMethod("dom::HTMLStyleElement::BindToTree", this, update)); return rv; } diff --git a/dom/html/HTMLTrackElement.cpp b/dom/html/HTMLTrackElement.cpp index 09b86398fef1..30fb5038fe30 100644 --- a/dom/html/HTMLTrackElement.cpp +++ b/dom/html/HTMLTrackElement.cpp @@ -265,7 +265,10 @@ void HTMLTrackElement::DispatchLoadResource() { if (!mLoadResourceDispatched) { - RefPtr r = NewRunnableMethod(this, &HTMLTrackElement::LoadResource); + RefPtr r = + NewRunnableMethod("dom::HTMLTrackElement::LoadResource", + this, + &HTMLTrackElement::LoadResource); nsContentUtils::RunInStableState(r.forget()); mLoadResourceDispatched = true; } @@ -437,11 +440,11 @@ HTMLTrackElement::DispatchTrackRunnable(const nsString& aEventName) if (!doc) { return; } - nsCOMPtr runnable = - NewRunnableMethod - (this, - &HTMLTrackElement::DispatchTrustedEvent, - aEventName); + nsCOMPtr runnable = NewRunnableMethod( + "dom::HTMLTrackElement::DispatchTrustedEvent", + this, + &HTMLTrackElement::DispatchTrustedEvent, + aEventName); doc->Dispatch("HTMLTrackElement::DispatchTrackRunnable", TaskCategory::Other, runnable.forget()); } diff --git a/dom/html/ImageDocument.cpp b/dom/html/ImageDocument.cpp index 4b7008e57583..4d3d3b841f82 100644 --- a/dom/html/ImageDocument.cpp +++ b/dom/html/ImageDocument.cpp @@ -493,7 +493,9 @@ 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 = - NewRunnableMethod(this, &ImageDocument::OnHasTransparency); + NewRunnableMethod("dom::ImageDocument::OnHasTransparency", + this, + &ImageDocument::OnHasTransparency); nsContentUtils::AddScriptRunner(runnable); } @@ -566,7 +568,9 @@ ImageDocument::OnSizeAvailable(imgIRequest* aRequest, imgIContainer* aImage) } nsCOMPtr runnable = - NewRunnableMethod(this, &ImageDocument::DefaultCheckOverflowing); + NewRunnableMethod("dom::ImageDocument::DefaultCheckOverflowing", + this, + &ImageDocument::DefaultCheckOverflowing); nsContentUtils::AddScriptRunner(runnable); UpdateTitleAndCharset(); diff --git a/dom/html/TextTrackManager.cpp b/dom/html/TextTrackManager.cpp index 4d3ccf365217..37009773e0da 100644 --- a/dom/html/TextTrackManager.cpp +++ b/dom/html/TextTrackManager.cpp @@ -170,8 +170,10 @@ TextTrackManager::AddTextTrack(TextTrackKind aKind, const nsAString& aLabel, ReportTelemetryForTrack(track); if (aTextTrackSource == TextTrackSource::Track) { - RefPtr task = - NewRunnableMethod(this, &TextTrackManager::HonorUserPreferencesForTrackSelection); + RefPtr task = NewRunnableMethod( + "dom::TextTrackManager::HonorUserPreferencesForTrackSelection", + this, + &TextTrackManager::HonorUserPreferencesForTrackSelection); nsContentUtils::RunInStableState(task.forget()); } @@ -190,8 +192,10 @@ TextTrackManager::AddTextTrack(TextTrack* aTextTrack) ReportTelemetryForTrack(aTextTrack); if (aTextTrack->GetTextTrackSource() == TextTrackSource::Track) { - RefPtr task = - NewRunnableMethod(this, &TextTrackManager::HonorUserPreferencesForTrackSelection); + RefPtr task = NewRunnableMethod( + "dom::TextTrackManager::HonorUserPreferencesForTrackSelection", + this, + &TextTrackManager::HonorUserPreferencesForTrackSelection); nsContentUtils::RunInStableState(task.forget()); } } @@ -483,12 +487,15 @@ class SimpleTextTrackEvent : public Runnable { public: friend class CompareSimpleTextTrackEvents; - SimpleTextTrackEvent(const nsAString& aEventName, double aTime, - TextTrack* aTrack, TextTrackCue* aCue) - : mName(aEventName), - mTime(aTime), - mTrack(aTrack), - mCue(aCue) + SimpleTextTrackEvent(const nsAString& aEventName, + double aTime, + TextTrack* aTrack, + TextTrackCue* aCue) + : Runnable("dom::SimpleTextTrackEvent") + , mName(aEventName) + , mTime(aTime) + , mTrack(aTrack) + , mCue(aCue) {} NS_IMETHOD Run() { @@ -624,8 +631,11 @@ TextTrackManager::DispatchUpdateCueDisplay() nsPIDOMWindowInner* win = mMediaElement->OwnerDoc()->GetInnerWindow(); if (win) { nsGlobalWindow::Cast(win)->Dispatch( - "TextTrackManager::UpdateCueDisplay", TaskCategory::Other, - NewRunnableMethod(this, &TextTrackManager::UpdateCueDisplay)); + "TextTrackManager::UpdateCueDisplay", + TaskCategory::Other, + NewRunnableMethod("dom::TextTrackManager::UpdateCueDisplay", + this, + &TextTrackManager::UpdateCueDisplay)); mUpdateCueDisplayDispatched = true; } } @@ -644,8 +654,11 @@ TextTrackManager::DispatchTimeMarchesOn() nsPIDOMWindowInner* win = mMediaElement->OwnerDoc()->GetInnerWindow(); if (win) { nsGlobalWindow::Cast(win)->Dispatch( - "TextTrackManager::TimeMarchesOn", TaskCategory::Other, - NewRunnableMethod(this, &TextTrackManager::TimeMarchesOn)); + "TextTrackManager::TimeMarchesOn", + TaskCategory::Other, + NewRunnableMethod("dom::TextTrackManager::TimeMarchesOn", + this, + &TextTrackManager::TimeMarchesOn)); mTimeMarchesOnDispatched = true; } } diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp index 4767e162860c..3f7bf997f54c 100644 --- a/dom/html/nsGenericHTMLElement.cpp +++ b/dom/html/nsGenericHTMLElement.cpp @@ -120,7 +120,11 @@ using namespace mozilla::dom; class nsAutoFocusEvent : public Runnable { public: - explicit nsAutoFocusEvent(nsGenericHTMLFormElement* aElement) : mElement(aElement) {} + explicit nsAutoFocusEvent(nsGenericHTMLFormElement* aElement) + : mozilla::Runnable("nsAutoFocusEvent") + , mElement(aElement) + { + } NS_IMETHOD Run() override { nsFocusManager* fm = nsFocusManager::GetFocusManager(); diff --git a/dom/html/nsHTMLDocument.cpp b/dom/html/nsHTMLDocument.cpp index 66e8eb6cc9b4..ac69848f9d12 100644 --- a/dom/html/nsHTMLDocument.cpp +++ b/dom/html/nsHTMLDocument.cpp @@ -2505,7 +2505,9 @@ nsHTMLDocument::MaybeEditingStateChanged() EditingStateChanged(); } else if (!mInDestructor) { nsContentUtils::AddScriptRunner( - NewRunnableMethod(this, &nsHTMLDocument::MaybeEditingStateChanged)); + NewRunnableMethod("nsHTMLDocument::MaybeEditingStateChanged", + this, + &nsHTMLDocument::MaybeEditingStateChanged)); } } } @@ -2536,9 +2538,10 @@ nsHTMLDocument::SetMayStartLayout(bool aMayStartLayout) class DeferredContentEditableCountChangeEvent : public Runnable { public: - DeferredContentEditableCountChangeEvent(nsHTMLDocument *aDoc, - nsIContent *aElement) - : mDoc(aDoc) + DeferredContentEditableCountChangeEvent(nsHTMLDocument* aDoc, + nsIContent* aElement) + : mozilla::Runnable("DeferredContentEditableCountChangeEvent") + , mDoc(aDoc) , mElement(aElement) { } diff --git a/dom/html/nsTextEditorState.cpp b/dom/html/nsTextEditorState.cpp index bdf7c560b752..58a7fcbd9894 100644 --- a/dom/html/nsTextEditorState.cpp +++ b/dom/html/nsTextEditorState.cpp @@ -86,9 +86,10 @@ private: class RestoreSelectionState : public Runnable { public: - RestoreSelectionState(nsTextEditorState *aState, nsTextControlFrame *aFrame) - : mFrame(aFrame), - mTextEditorState(aState) + RestoreSelectionState(nsTextEditorState* aState, nsTextControlFrame* aFrame) + : mozilla::Runnable("RestoreSelectionState") + , mFrame(aFrame) + , mTextEditorState(aState) { } @@ -1249,10 +1250,11 @@ nsTextEditorState::GetSelectionController() const // Helper class, used below in BindToFrame(). class PrepareEditorEvent : public Runnable { public: - PrepareEditorEvent(nsTextEditorState &aState, - nsIContent *aOwnerContent, - const nsAString &aCurrentValue) - : mState(&aState) + PrepareEditorEvent(nsTextEditorState& aState, + nsIContent* aOwnerContent, + const nsAString& aCurrentValue) + : mozilla::Runnable("PrepareEditorEvent") + , mState(&aState) , mOwnerContent(aOwnerContent) , mCurrentValue(aCurrentValue) { diff --git a/dom/indexedDB/ActorsParent.cpp b/dom/indexedDB/ActorsParent.cpp index 8e9522e92b10..1c34898becee 100644 --- a/dom/indexedDB/ActorsParent.cpp +++ b/dom/indexedDB/ActorsParent.cpp @@ -5994,7 +5994,8 @@ public: protected: DatabaseOperationBase(const nsID& aBackgroundChildLoggingId, uint64_t aLoggingSerialNumber) - : mOwningEventTarget(GetCurrentThreadEventTarget()) + : Runnable("dom::indexedDB::DatabaseOperationBase") + , mOwningEventTarget(GetCurrentThreadEventTarget()) , mBackgroundChildLoggingId(aBackgroundChildLoggingId) , mLoggingSerialNumber(aLoggingSerialNumber) , mResultCode(NS_OK) @@ -6350,7 +6351,8 @@ class WaitForTransactionsHelper final public: WaitForTransactionsHelper(const nsCString& aDatabaseId, nsIRunnable* aCallback) - : mDatabaseId(aDatabaseId) + : Runnable("dom::indexedDB::WaitForTransactionsHelper") + , mDatabaseId(aDatabaseId) , mCallback(aCallback) , mState(State::Initial) { @@ -8999,7 +9001,8 @@ public: const nsACString& aOrigin, const nsAString& aDatabaseName, int64_t aFileId) - : mPersistenceType(aPersistenceType) + : Runnable("dom::indexedDB::GetFileReferencesHelper") + , mPersistenceType(aPersistenceType) , mOrigin(aOrigin) , mDatabaseName(aDatabaseName) , mFileId(aFileId) @@ -9027,6 +9030,9 @@ private: class FlushPendingFileDeletionsRunnable final : public Runnable { +public: + FlushPendingFileDeletionsRunnable() : Runnable("FlushPendingFileDeletionsRunnable") {} + private: ~FlushPendingFileDeletionsRunnable() override = default; @@ -9365,7 +9371,8 @@ class Maintenance final public: explicit Maintenance(QuotaClient* aQuotaClient) - : mQuotaClient(aQuotaClient) + : Runnable("dom::indexedDB::Maintenance") + , mQuotaClient(aQuotaClient) , mStartTime(PR_Now()) , mResultCode(NS_OK) , mAborted(false) @@ -9581,7 +9588,8 @@ public: const nsCString& aGroup, const nsCString& aOrigin, const nsString& aDatabasePath) - : mMaintenance(aMaintenance) + : Runnable("dom::indexedDB::DatabaseMaintenance") + , mMaintenance(aMaintenance) , mGroup(aGroup) , mOrigin(aOrigin) , mDatabasePath(aDatabasePath) @@ -12631,7 +12639,7 @@ ConnectionPool::ShutdownThread(ThreadInfo& aThreadInfo) NS_DISPATCH_NORMAL)); MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread( - NewRunnableMethod(thread, &nsIThread::Shutdown))); + NewRunnableMethod("nsIThread::Shutdown", thread, &nsIThread::Shutdown))); mTotalThreadCount--; } @@ -12739,7 +12747,7 @@ ConnectionPool::ScheduleTransaction(TransactionInfo* aTransactionInfo, // We need a thread right now so force all idle processing to stop by // posting a dummy runnable to each thread that might be doing idle // maintenance. - nsCOMPtr runnable = new Runnable(); + nsCOMPtr runnable = new Runnable("IndexedDBDummyRunnable"); for (uint32_t index = mDatabasesPerformingIdleMaintenance.Length(); index > 0; @@ -13183,7 +13191,8 @@ ConnectionPool::CloseDatabaseWhenIdleInternal(const nsACString& aDatabaseId) ConnectionPool:: ConnectionRunnable::ConnectionRunnable(DatabaseInfo* aDatabaseInfo) - : mDatabaseInfo(aDatabaseInfo) + : Runnable("dom::indexedDB::ConnectionPool::ConnectionRunnable") + , mDatabaseInfo(aDatabaseInfo) , mOwningEventTarget(GetCurrentThreadEventTarget()) { AssertIsOnBackgroundThread(); @@ -13345,11 +13354,12 @@ DatabasesCompleteCallback::~DatabasesCompleteCallback() MOZ_COUNT_DTOR(ConnectionPool::DatabasesCompleteCallback); } -ConnectionPool:: -FinishCallbackWrapper::FinishCallbackWrapper(ConnectionPool* aConnectionPool, - uint64_t aTransactionId, - FinishCallback* aCallback) - : mConnectionPool(aConnectionPool) +ConnectionPool::FinishCallbackWrapper::FinishCallbackWrapper( + ConnectionPool* aConnectionPool, + uint64_t aTransactionId, + FinishCallback* aCallback) + : Runnable("dom::indexedDB::ConnectionPool::FinishCallbackWrapper") + , mConnectionPool(aConnectionPool) , mCallback(aCallback) , mOwningEventTarget(GetCurrentThreadEventTarget()) , mTransactionId(aTransactionId) @@ -13412,9 +13422,9 @@ FinishCallbackWrapper::Run() uint32_t ConnectionPool::ThreadRunnable::sNextSerialNumber = 0; -ConnectionPool:: -ThreadRunnable::ThreadRunnable() - : mSerialNumber(++sNextSerialNumber) +ConnectionPool::ThreadRunnable::ThreadRunnable() + : Runnable("dom::indexedDB::ConnectionPool::ThreadRunnable") + , mSerialNumber(++sNextSerialNumber) , mFirstRun(true) , mContinueRunning(true) { @@ -14477,7 +14487,9 @@ Database::MaybeCloseConnection() IsClosed() && mDirectoryLock) { nsCOMPtr callback = - NewRunnableMethod(this, &Database::ConnectionClosedCallback); + NewRunnableMethod("dom::indexedDB::Database::ConnectionClosedCallback", + this, + &Database::ConnectionClosedCallback); RefPtr helper = new WaitForTransactionsHelper(Id(), callback); @@ -22679,8 +22691,10 @@ OpenDatabaseOp::SendResults() // Make sure to release the database on this thread. mDatabase = nullptr; } else if (mDirectoryLock) { - nsCOMPtr callback = - NewRunnableMethod(this, &OpenDatabaseOp::ConnectionClosedCallback); + nsCOMPtr callback = NewRunnableMethod( + "dom::indexedDB::OpenDatabaseOp::ConnectionClosedCallback", + this, + &OpenDatabaseOp::ConnectionClosedCallback); RefPtr helper = new WaitForTransactionsHelper(mDatabaseId, callback); diff --git a/dom/indexedDB/FileInfo.cpp b/dom/indexedDB/FileInfo.cpp index 471007273a1e..f4f515c20ae6 100644 --- a/dom/indexedDB/FileInfo.cpp +++ b/dom/indexedDB/FileInfo.cpp @@ -60,7 +60,8 @@ public: DoCleanup(FileManager* aFileManager, int64_t aFileId); CleanupFileRunnable(FileManager* aFileManager, int64_t aFileId) - : mFileManager(aFileManager) + : Runnable("dom::indexedDB::CleanupFileRunnable") + , mFileManager(aFileManager) , mFileId(aFileId) { MOZ_ASSERT(aFileManager); diff --git a/dom/indexedDB/IDBDatabase.cpp b/dom/indexedDB/IDBDatabase.cpp index 2813c29c4142..5abbb1a874c8 100644 --- a/dom/indexedDB/IDBDatabase.cpp +++ b/dom/indexedDB/IDBDatabase.cpp @@ -73,9 +73,9 @@ class CancelableRunnableWrapper final nsCOMPtr mRunnable; public: - explicit - CancelableRunnableWrapper(nsIRunnable* aRunnable) - : mRunnable(aRunnable) + explicit CancelableRunnableWrapper(nsIRunnable* aRunnable) + : CancelableRunnable("dom::CancelableRunnableWrapper") + , mRunnable(aRunnable) { MOZ_ASSERT(aRunnable); } diff --git a/dom/indexedDB/ScriptErrorHelper.cpp b/dom/indexedDB/ScriptErrorHelper.cpp index 7a4740641753..b643154e9591 100644 --- a/dom/indexedDB/ScriptErrorHelper.cpp +++ b/dom/indexedDB/ScriptErrorHelper.cpp @@ -36,7 +36,8 @@ public: uint32_t aSeverityFlag, bool aIsChrome, uint64_t aInnerWindowID) - : mMessage(aMessage) + : mozilla::Runnable("ScriptErrorRunnable") + , mMessage(aMessage) , mFilename(aFilename) , mLineNumber(aLineNumber) , mColumnNumber(aColumnNumber) @@ -55,7 +56,8 @@ public: uint32_t aSeverityFlag, bool aIsChrome, uint64_t aInnerWindowID) - : mMessageName(aMessageName) + : mozilla::Runnable("ScriptErrorRunnable") + , mMessageName(aMessageName) , mFilename(aFilename) , mLineNumber(aLineNumber) , mColumnNumber(aColumnNumber) diff --git a/dom/ipc/ContentBridgeChild.cpp b/dom/ipc/ContentBridgeChild.cpp index 4f875a2deed9..740f8f04e881 100644 --- a/dom/ipc/ContentBridgeChild.cpp +++ b/dom/ipc/ContentBridgeChild.cpp @@ -32,7 +32,10 @@ ContentBridgeChild::~ContentBridgeChild() void ContentBridgeChild::ActorDestroy(ActorDestroyReason aWhy) { - MessageLoop::current()->PostTask(NewRunnableMethod(this, &ContentBridgeChild::DeferredDestroy)); + MessageLoop::current()->PostTask( + NewRunnableMethod("dom::ContentBridgeChild::DeferredDestroy", + this, + &ContentBridgeChild::DeferredDestroy)); } /*static*/ void diff --git a/dom/ipc/ContentBridgeParent.cpp b/dom/ipc/ContentBridgeParent.cpp index 3f8ee5ca8216..4cbc78f51545 100644 --- a/dom/ipc/ContentBridgeParent.cpp +++ b/dom/ipc/ContentBridgeParent.cpp @@ -36,7 +36,10 @@ ContentBridgeParent::ActorDestroy(ActorDestroyReason aWhy) if (os) { os->RemoveObserver(this, "content-child-shutdown"); } - MessageLoop::current()->PostTask(NewRunnableMethod(this, &ContentBridgeParent::DeferredDestroy)); + MessageLoop::current()->PostTask( + NewRunnableMethod("dom::ContentBridgeParent::DeferredDestroy", + this, + &ContentBridgeParent::DeferredDestroy)); } /*static*/ ContentBridgeParent* @@ -173,7 +176,8 @@ ContentBridgeParent::NotifyTabDestroyed() { int32_t numLiveTabs = ManagedPBrowserParent().Count(); if (numLiveTabs == 1) { - MessageLoop::current()->PostTask(NewRunnableMethod(this, &ContentBridgeParent::Close)); + MessageLoop::current()->PostTask(NewRunnableMethod( + "dom::ContentBridgeParent::Close", this, &ContentBridgeParent::Close)); } } diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 247b3c21960b..16fed34a73aa 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -2776,10 +2776,12 @@ ContentChild::StartForceKillTimer() if (timeoutSecs > 0) { mForceKillTimer = do_CreateInstance("@mozilla.org/timer;1"); MOZ_ASSERT(mForceKillTimer); - mForceKillTimer->InitWithFuncCallback(ContentChild::ForceKillTimerCallback, + mForceKillTimer->InitWithNamedFuncCallback( + ContentChild::ForceKillTimerCallback, this, timeoutSecs * 1000, - nsITimer::TYPE_ONE_SHOT); + nsITimer::TYPE_ONE_SHOT, + "dom::ContentChild::StartForceKillTimer"); } } @@ -2809,7 +2811,9 @@ ContentChild::RecvShutdown() // time (100ms) in the hopes that the event loop will have finished by // then. MessageLoop::current()->PostDelayedTask( - NewRunnableMethod(this, &ContentChild::RecvShutdown), 100); + NewRunnableMethod( + "dom::ContentChild::RecvShutdown", this, &ContentChild::RecvShutdown), + 100); return IPC_OK(); } } diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 35d37b608d10..c4bd1548f6c5 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -1711,7 +1711,11 @@ DelayedDeleteSubprocess(GeckoChildProcessHost* aSubprocess) // system. struct DelayedDeleteContentParentTask : public Runnable { - explicit DelayedDeleteContentParentTask(ContentParent* aObj) : mObj(aObj) { } + explicit DelayedDeleteContentParentTask(ContentParent* aObj) + : Runnable("dom::DelayedDeleteContentParentTask") + , mObj(aObj) + { + } // No-op NS_IMETHOD Run() override { return NS_OK; } @@ -1843,10 +1847,11 @@ 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]); - MessageLoop::current()->PostTask(NewRunnableMethod - (cp, - &ContentParent::ShutDownProcess, - SEND_SHUTDOWN_MESSAGE)); + MessageLoop::current()->PostTask( + NewRunnableMethod("dom::ContentParent::ShutDownProcess", + cp, + &ContentParent::ShutDownProcess, + SEND_SHUTDOWN_MESSAGE)); } cpm->RemoveContentProcess(this->ChildID()); @@ -1972,10 +1977,12 @@ ContentParent::StartForceKillTimer() if (timeoutSecs > 0) { mForceKillTimer = do_CreateInstance("@mozilla.org/timer;1"); MOZ_ASSERT(mForceKillTimer); - mForceKillTimer->InitWithFuncCallback(ContentParent::ForceKillTimerCallback, - this, - timeoutSecs * 1000, - nsITimer::TYPE_ONE_SHOT); + mForceKillTimer->InitWithNamedFuncCallback( + ContentParent::ForceKillTimerCallback, + this, + timeoutSecs * 1000, + nsITimer::TYPE_ONE_SHOT, + "dom::ContentParent::StartForceKillTimer"); } } @@ -2004,10 +2011,11 @@ ContentParent::NotifyTabDestroyed(const TabId& aTabId, if (tabIds.Length() == 1 && !ShouldKeepProcessAlive() && !TryToRecycle()) { // In the case of normal shutdown, send a shutdown message to child to // allow it to perform shutdown tasks. - MessageLoop::current()->PostTask(NewRunnableMethod - (this, - &ContentParent::ShutDownProcess, - SEND_SHUTDOWN_MESSAGE)); + MessageLoop::current()->PostTask( + NewRunnableMethod("dom::ContentParent::ShutDownProcess", + this, + &ContentParent::ShutDownProcess, + SEND_SHUTDOWN_MESSAGE)); } } @@ -4094,7 +4102,8 @@ class AnonymousTemporaryFileRequestor final : public Runnable { public: AnonymousTemporaryFileRequestor(ContentParent* aCP, const uint64_t& aID) - : mCP(aCP) + : Runnable("dom::AnonymousTemporaryFileRequestor") + , mCP(aCP) , mID(aID) , mRv(NS_OK) , mPRFD(nullptr) diff --git a/dom/ipc/FilePickerParent.cpp b/dom/ipc/FilePickerParent.cpp index ad1ff208be08..9448a1afd2dd 100644 --- a/dom/ipc/FilePickerParent.cpp +++ b/dom/ipc/FilePickerParent.cpp @@ -49,11 +49,12 @@ FilePickerParent::~FilePickerParent() // 2. The stream transport thread stat()s the file in Run() and then dispatches // the same runnable on the main thread. // 3. The main thread sends the results over IPC. -FilePickerParent::IORunnable::IORunnable(FilePickerParent *aFPParent, +FilePickerParent::IORunnable::IORunnable(FilePickerParent* aFPParent, nsTArray>& aFiles, bool aIsDirectory) - : mFilePickerParent(aFPParent) - , mIsDirectory(aIsDirectory) + : mozilla::Runnable("dom::FilePickerParent::IORunnable") + , mFilePickerParent(aFPParent) + , mIsDirectory(aIsDirectory) { mFiles.SwapElements(aFiles); MOZ_ASSERT_IF(aIsDirectory, mFiles.Length() == 1); diff --git a/dom/ipc/PreallocatedProcessManager.cpp b/dom/ipc/PreallocatedProcessManager.cpp index 39ba78d0b982..77fc8beb8269 100644 --- a/dom/ipc/PreallocatedProcessManager.cpp +++ b/dom/ipc/PreallocatedProcessManager.cpp @@ -206,7 +206,9 @@ PreallocatedProcessManagerImpl::AllocateAfterDelay() // message loop in practice never goes idle, that didn't work out well. // Let's just launch the process after the delay. NS_DelayedDispatchToCurrentThread( - NewRunnableMethod(this, &PreallocatedProcessManagerImpl::AllocateNow), + NewRunnableMethod("PreallocatedProcessManagerImpl::AllocateNow", + this, + &PreallocatedProcessManagerImpl::AllocateNow), Preferences::GetUint("dom.ipc.processPrelaunch.delayMs", DEFAULT_ALLOCATE_DELAY)); } @@ -218,7 +220,10 @@ PreallocatedProcessManagerImpl::AllocateOnIdle() return; } - NS_IdleDispatchToCurrentThread(NewRunnableMethod(this, &PreallocatedProcessManagerImpl::AllocateNow)); + NS_IdleDispatchToCurrentThread( + NewRunnableMethod("PreallocatedProcessManagerImpl::AllocateNow", + this, + &PreallocatedProcessManagerImpl::AllocateNow)); } void diff --git a/dom/ipc/ProcessHangMonitor.cpp b/dom/ipc/ProcessHangMonitor.cpp index 91f605cb8b0e..2f8fcfe2d256 100644 --- a/dom/ipc/ProcessHangMonitor.cpp +++ b/dom/ipc/ProcessHangMonitor.cpp @@ -369,7 +369,9 @@ 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. - Dispatch(NewNonOwningRunnableMethod(this, &HangMonitorChild::ShutdownOnThread)); + Dispatch(NewNonOwningRunnableMethod("HangMonitorChild::ShutdownOnThread", + this, + &HangMonitorChild::ShutdownOnThread)); } mozilla::ipc::IPCResult @@ -480,10 +482,12 @@ HangMonitorChild::NotifySlowScript(nsITabChild* aTabChild, } nsAutoCString filename(aFileName); - Dispatch(NewNonOwningRunnableMethod - (this, - &HangMonitorChild::NotifySlowScriptAsync, - id, filename)); + Dispatch(NewNonOwningRunnableMethod( + "HangMonitorChild::NotifySlowScriptAsync", + this, + &HangMonitorChild::NotifySlowScriptAsync, + id, + filename)); return SlowScriptAction::Continue; } @@ -511,9 +515,11 @@ HangMonitorChild::NotifyPluginHang(uint32_t aPluginId) mSentReport = true; // bounce to background thread - Dispatch(NewNonOwningRunnableMethod(this, - &HangMonitorChild::NotifyPluginHangAsync, - aPluginId)); + Dispatch(NewNonOwningRunnableMethod( + "HangMonitorChild::NotifyPluginHangAsync", + this, + &HangMonitorChild::NotifyPluginHangAsync, + aPluginId)); } void @@ -535,7 +541,9 @@ HangMonitorChild::ClearHang() if (mSentReport) { // bounce to background thread - Dispatch(NewNonOwningRunnableMethod(this, &HangMonitorChild::ClearHangAsync)); + Dispatch(NewNonOwningRunnableMethod("HangMonitorChild::ClearHangAsync", + this, + &HangMonitorChild::ClearHangAsync)); MonitorAutoLock lock(mMonitor); mSentReport = false; @@ -603,7 +611,8 @@ HangMonitorParent::Shutdown() mProcess = nullptr; } - Dispatch(NewNonOwningRunnableMethod(this, + Dispatch(NewNonOwningRunnableMethod("HangMonitorParent::ShutdownOnThread", + this, &HangMonitorParent::ShutdownOnThread)); while (!mShutdownDone) { @@ -634,8 +643,12 @@ HangMonitorParent::ForcePaint(dom::TabParent* aTab, uint64_t aLayerObserverEpoch MOZ_RELEASE_ASSERT(NS_IsMainThread()); if (sShouldForcePaint) { TabId id = aTab->GetTabId(); - Dispatch(NewNonOwningRunnableMethod - (this, &HangMonitorParent::ForcePaintOnThread, id, aLayerObserverEpoch)); + Dispatch(NewNonOwningRunnableMethod( + "HangMonitorParent::ForcePaintOnThread", + this, + &HangMonitorParent::ForcePaintOnThread, + id, + aLayerObserverEpoch)); } } @@ -944,8 +957,10 @@ HangMonitoredProcess::TerminateScript() return NS_ERROR_UNEXPECTED; } - ProcessHangMonitor::Get()->Dispatch(NewNonOwningRunnableMethod(mActor, - &HangMonitorParent::TerminateScript)); + ProcessHangMonitor::Get()->Dispatch( + NewNonOwningRunnableMethod("HangMonitorParent::TerminateScript", + mActor, + &HangMonitorParent::TerminateScript)); return NS_OK; } @@ -961,8 +976,10 @@ HangMonitoredProcess::BeginStartingDebugger() return NS_ERROR_UNEXPECTED; } - ProcessHangMonitor::Get()->Dispatch(NewNonOwningRunnableMethod(mActor, - &HangMonitorParent::BeginStartingDebugger)); + ProcessHangMonitor::Get()->Dispatch( + NewNonOwningRunnableMethod("HangMonitorParent::BeginStartingDebugger", + mActor, + &HangMonitorParent::BeginStartingDebugger)); return NS_OK; } @@ -978,8 +995,10 @@ HangMonitoredProcess::EndStartingDebugger() return NS_ERROR_UNEXPECTED; } - ProcessHangMonitor::Get()->Dispatch(NewNonOwningRunnableMethod(mActor, - &HangMonitorParent::EndStartingDebugger)); + ProcessHangMonitor::Get()->Dispatch( + NewNonOwningRunnableMethod("HangMonitorParent::EndStartingDebugger", + mActor, + &HangMonitorParent::EndStartingDebugger)); return NS_OK; } @@ -1159,10 +1178,12 @@ CreateHangMonitorParent(ContentParent* aContentParent, auto* process = new HangMonitoredProcess(parent, aContentParent); parent->SetProcess(process); - monitor->Dispatch(NewNonOwningRunnableMethod - &&>(parent, - &HangMonitorParent::Bind, - Move(aEndpoint))); + monitor->Dispatch( + NewNonOwningRunnableMethod&&>( + "HangMonitorParent::Bind", + parent, + &HangMonitorParent::Bind, + Move(aEndpoint))); return parent; } @@ -1178,10 +1199,12 @@ mozilla::CreateHangMonitorChild(Endpoint&& aEndpoint) ProcessHangMonitor* monitor = ProcessHangMonitor::GetOrCreate(); auto* child = new HangMonitorChild(monitor); - monitor->Dispatch(NewNonOwningRunnableMethod - &&>(child, - &HangMonitorChild::Bind, - Move(aEndpoint))); + monitor->Dispatch( + NewNonOwningRunnableMethod&&>( + "HangMonitorChild::Bind", + child, + &HangMonitorChild::Bind, + Move(aEndpoint))); } void diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index 093075f06f90..8870ef7f46cc 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -2781,8 +2781,13 @@ class LayerTreeUpdateRunnable final bool mActive; public: - explicit LayerTreeUpdateRunnable(uint64_t aLayersId, uint64_t aEpoch, bool aActive) - : mLayersId(aLayersId), mEpoch(aEpoch), mActive(aActive) + explicit LayerTreeUpdateRunnable(uint64_t aLayersId, + uint64_t aEpoch, + bool aActive) + : Runnable("dom::LayerTreeUpdateRunnable") + , mLayersId(aLayersId) + , mEpoch(aEpoch) + , mActive(aActive) { MOZ_ASSERT(!NS_IsMainThread()); } diff --git a/dom/jsurl/nsJSProtocolHandler.cpp b/dom/jsurl/nsJSProtocolHandler.cpp index beb8f30e6a1c..845fc2b8a158 100644 --- a/dom/jsurl/nsJSProtocolHandler.cpp +++ b/dom/jsurl/nsJSProtocolHandler.cpp @@ -663,7 +663,8 @@ nsJSChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *aContext) name = "nsJSChannel::NotifyListener"; } - nsresult rv = NS_DispatchToCurrentThread(mozilla::NewRunnableMethod(name, this, method)); + nsresult rv = NS_DispatchToCurrentThread( + mozilla::NewRunnableMethod(name, this, method)); if (NS_FAILED(rv)) { loadGroup->RemoveRequest(this, nullptr, rv); diff --git a/dom/media/Benchmark.cpp b/dom/media/Benchmark.cpp index 7a1782766584..2846a74470bb 100644 --- a/dom/media/Benchmark.cpp +++ b/dom/media/Benchmark.cpp @@ -111,8 +111,8 @@ Benchmark::Run() RefPtr p = mPromise.Ensure(__func__); RefPtr self = this; - mPlaybackState.Dispatch( - NS_NewRunnableFunction([self]() { self->mPlaybackState.DemuxSamples(); })); + mPlaybackState.Dispatch(NS_NewRunnableFunction( + "Benchmark::Run", [self]() { self->mPlaybackState.DemuxSamples(); })); return p; } @@ -196,7 +196,8 @@ BenchmarkPlayback::DemuxNextSample() && mSamples.Length() == (size_t)ref->mParameters.mStopAtFrame.ref()) { InitDecoder(Move(*mTrackDemuxer->GetInfo())); } else { - Dispatch(NS_NewRunnableFunction([this, ref]() { DemuxNextSample(); })); + Dispatch(NS_NewRunnableFunction("BenchmarkPlayback::DemuxNextSample", + [this, ref]() { DemuxNextSample(); })); } }, [this, ref](const MediaResult& aError) { @@ -291,9 +292,10 @@ BenchmarkPlayback::Output(const MediaDataDecoder::DecodedData& aResults) || mDrained)) { uint32_t decodeFps = frames / elapsedTime.ToSeconds(); MainThreadShutdown(); - ref->Dispatch(NS_NewRunnableFunction([ref, decodeFps]() { - ref->ReturnResult(decodeFps); - })); + ref->Dispatch( + NS_NewRunnableFunction("BenchmarkPlayback::Output", [ref, decodeFps]() { + ref->ReturnResult(decodeFps); + })); } } diff --git a/dom/media/CanvasCaptureMediaStream.cpp b/dom/media/CanvasCaptureMediaStream.cpp index c30f2f3f4351..2f24540d0a46 100644 --- a/dom/media/CanvasCaptureMediaStream.cpp +++ b/dom/media/CanvasCaptureMediaStream.cpp @@ -142,7 +142,11 @@ public: if (!mTimer) { return; } - mTimer->InitWithFuncCallback(&TimerTick, this, int(1000 / mFPS), nsITimer::TYPE_REPEATING_SLACK); + mTimer->InitWithNamedFuncCallback(&TimerTick, + this, + int(1000 / mFPS), + nsITimer::TYPE_REPEATING_SLACK, + "dom::TimerDriver::TimerDriver"); } static void TimerTick(nsITimer* aTimer, void* aClosure) diff --git a/dom/media/CubebUtils.cpp b/dom/media/CubebUtils.cpp index 29f8a870dad3..a885274cd325 100644 --- a/dom/media/CubebUtils.cpp +++ b/dom/media/CubebUtils.cpp @@ -421,7 +421,8 @@ void InitLibrary() Preferences::RegisterCallbackAndCall(PrefChanged, PREF_CUBEB_BACKEND); Preferences::RegisterCallbackAndCall(PrefChanged, PREF_CUBEB_LOG_LEVEL); #ifndef MOZ_WIDGET_ANDROID - NS_DispatchToMainThread(NS_NewRunnableFunction(&InitBrandName)); + NS_DispatchToMainThread( + NS_NewRunnableFunction("CubebUtils::InitLibrary", &InitBrandName)); #endif } diff --git a/dom/media/DOMMediaStream.cpp b/dom/media/DOMMediaStream.cpp index 0ad0e9aa4d6a..9afd2ec409ac 100644 --- a/dom/media/DOMMediaStream.cpp +++ b/dom/media/DOMMediaStream.cpp @@ -185,7 +185,10 @@ public: RefPtr newTrack = mStream->CreateDOMTrack(aTrackID, aType, source); NS_DispatchToMainThread(NewRunnableMethod>( - mStream, &DOMMediaStream::AddTrackInternal, newTrack)); + "DOMMediaStream::AddTrackInternal", + mStream, + &DOMMediaStream::AddTrackInternal, + newTrack)); } void DoNotifyTrackEnded(MediaStream* aInputStream, TrackID aInputTrackID, @@ -203,8 +206,10 @@ public: if (track) { LOG(LogLevel::Debug, ("DOMMediaStream %p MediaStreamTrack %p ended at the source. Marking it ended.", mStream, track.get())); - NS_DispatchToMainThread(NewRunnableMethod( - track, &MediaStreamTrack::OverrideEnded)); + NS_DispatchToMainThread( + NewRunnableMethod("dom::MediaStreamTrack::OverrideEnded", + track, + &MediaStreamTrack::OverrideEnded)); } } @@ -217,15 +222,27 @@ public: if (aTrackEvents & TrackEventCommand::TRACK_EVENT_CREATED) { aGraph->DispatchToMainThreadAfterStreamStateUpdate( mAbstractMainThread, - NewRunnableMethod, TrackID>( - this, &OwnedStreamListener::DoNotifyTrackCreated, - aID, aQueuedMedia.GetType(), aInputStream, aInputTrackID)); + NewRunnableMethod, + TrackID>( + "DOMMediaStream::OwnedStreamListener::DoNotifyTrackCreated", + this, + &OwnedStreamListener::DoNotifyTrackCreated, + aID, + aQueuedMedia.GetType(), + aInputStream, + aInputTrackID)); } else if (aTrackEvents & TrackEventCommand::TRACK_EVENT_ENDED) { aGraph->DispatchToMainThreadAfterStreamStateUpdate( mAbstractMainThread, NewRunnableMethod, TrackID, TrackID>( - this, &OwnedStreamListener::DoNotifyTrackEnded, - aInputStream, aInputTrackID, aID)); + "DOMMediaStream::OwnedStreamListener::DoNotifyTrackEnded", + this, + &OwnedStreamListener::DoNotifyTrackEnded, + aInputStream, + aInputTrackID, + aID)); } } @@ -266,7 +283,9 @@ public: // dispatch. We have to do the same to notify of created tracks to stay // in sync. (Or NotifyTracksCreated is called before tracks are added). NS_DispatchToMainThread( - NewRunnableMethod(mStream, &DOMMediaStream::NotifyTracksCreated)); + NewRunnableMethod("DOMMediaStream::NotifyTracksCreated", + mStream, + &DOMMediaStream::NotifyTracksCreated)); } void DoNotifyFinished() @@ -277,8 +296,9 @@ public: return; } - NS_DispatchToMainThread(NewRunnableMethod( - mStream, &DOMMediaStream::NotifyFinished)); + NS_DispatchToMainThread(NewRunnableMethod("DOMMediaStream::NotifyFinished", + mStream, + &DOMMediaStream::NotifyFinished)); } // The methods below are called on the MediaStreamGraph thread. @@ -287,7 +307,10 @@ public: { aGraph->DispatchToMainThreadAfterStreamStateUpdate( mAbstractMainThread, - NewRunnableMethod(this, &PlaybackStreamListener::DoNotifyFinishedTrackCreation)); + NewRunnableMethod( + "DOMMediaStream::PlaybackStreamListener::DoNotifyFinishedTrackCreation", + this, + &PlaybackStreamListener::DoNotifyFinishedTrackCreation)); } @@ -297,7 +320,10 @@ public: if (event == MediaStreamGraphEvent::EVENT_FINISHED) { aGraph->DispatchToMainThreadAfterStreamStateUpdate( mAbstractMainThread, - NewRunnableMethod(this, &PlaybackStreamListener::DoNotifyFinished)); + NewRunnableMethod( + "DOMMediaStream::PlaybackStreamListener::DoNotifyFinished", + this, + &PlaybackStreamListener::DoNotifyFinished)); } } diff --git a/dom/media/EncodedBufferCache.cpp b/dom/media/EncodedBufferCache.cpp index 31fb99dd8283..0e3c3ed46f00 100644 --- a/dom/media/EncodedBufferCache.cpp +++ b/dom/media/EncodedBufferCache.cpp @@ -50,7 +50,9 @@ EncodedBufferCache::AppendBuffer(nsTArray & aBuf) Monitor monitor("EncodeBufferCache::AppendBuffer"); RefPtr cc = dom::ContentChild::GetSingleton(); nsCOMPtr runnable = - NewRunnableMethod(cc, + NewRunnableMethod( + "dom::ContentChild::AsyncOpenAnonymousTemporaryFile", + cc, &dom::ContentChild::AsyncOpenAnonymousTemporaryFile, [&](PRFileDesc* aFile) { rv = aFile ? NS_OK : NS_ERROR_FAILURE; diff --git a/dom/media/FileBlockCache.cpp b/dom/media/FileBlockCache.cpp index a0d044703c08..cfeedefb7319 100644 --- a/dom/media/FileBlockCache.cpp +++ b/dom/media/FileBlockCache.cpp @@ -95,15 +95,18 @@ FileBlockCache::Init() if (XRE_IsParentProcess()) { RefPtr self = this; - rv = mThread->Dispatch(NS_NewRunnableFunction([self] { - PRFileDesc* fd = nullptr; - nsresult rv = NS_OpenAnonymousTemporaryFile(&fd); - if (NS_SUCCEEDED(rv)) { - self->SetCacheFile(fd); - } else { - self->Close(); - } - }), NS_DISPATCH_NORMAL); + rv = mThread->Dispatch( + NS_NewRunnableFunction("FileBlockCache::Init", + [self] { + PRFileDesc* fd = nullptr; + nsresult rv = NS_OpenAnonymousTemporaryFile(&fd); + if (NS_SUCCEEDED(rv)) { + self->SetCacheFile(fd); + } else { + self->Close(); + } + }), + NS_DISPATCH_NORMAL); } else { // We must request a temporary file descriptor from the parent process. RefPtr self = this; @@ -157,19 +160,28 @@ FileBlockCache::Close() // Let the thread close the FD, and then trigger its own shutdown. // Note that mThread is now empty, so no other task will be posted there. // Also mThread and mFD are empty and therefore can be reused immediately. - nsresult rv = thread->Dispatch(NS_NewRunnableFunction([thread, fd] { - if (fd) { - CloseFD(fd); - } - // We must shut down the thread in another runnable. This is called - // while we're shutting down the media cache, and nsIThread::Shutdown() - // can cause events to run before it completes, which could end up - // opening more streams, while the media cache is shutting down and - // releasing memory etc! - nsCOMPtr event = new ShutdownThreadEvent(thread); - SystemGroup::Dispatch( - "ShutdownThreadEvent", TaskCategory::Other, event.forget()); - }), NS_DISPATCH_NORMAL); + nsresult rv = thread->Dispatch( + NS_NewRunnableFunction("FileBlockCache::Close", + [thread, fd] { + if (fd) { + CloseFD(fd); + } + // We must shut down the thread in another + // runnable. This is called + // while we're shutting down the media cache, and + // nsIThread::Shutdown() + // can cause events to run before it completes, + // which could end up + // opening more streams, while the media cache is + // shutting down and + // releasing memory etc! + nsCOMPtr event = + new ShutdownThreadEvent(thread); + SystemGroup::Dispatch("ShutdownThreadEvent", + TaskCategory::Other, + event.forget()); + }), + NS_DISPATCH_NORMAL); NS_ENSURE_SUCCESS_VOID(rv); } diff --git a/dom/media/GraphDriver.cpp b/dom/media/GraphDriver.cpp index ee39c442fa56..a19bc1fbec2c 100644 --- a/dom/media/GraphDriver.cpp +++ b/dom/media/GraphDriver.cpp @@ -141,8 +141,10 @@ ThreadedDriver::ThreadedDriver(MediaStreamGraphImpl* aGraphImpl) class MediaStreamGraphShutdownThreadRunnable : public Runnable { public: - explicit MediaStreamGraphShutdownThreadRunnable(already_AddRefed aThread) - : mThread(aThread) + explicit MediaStreamGraphShutdownThreadRunnable( + already_AddRefed aThread) + : Runnable("MediaStreamGraphShutdownThreadRunnable") + , mThread(aThread) { } NS_IMETHOD Run() override @@ -173,7 +175,8 @@ ThreadedDriver::~ThreadedDriver() class MediaStreamGraphInitThreadRunnable : public Runnable { public: explicit MediaStreamGraphInitThreadRunnable(ThreadedDriver* aDriver) - : mDriver(aDriver) + : Runnable("MediaStreamGraphInitThreadRunnable") + , mDriver(aDriver) { } NS_IMETHOD Run() override @@ -467,10 +470,12 @@ OfflineClockDriver::WakeUp() MOZ_ASSERT(false, "An offline graph should not have to wake up."); } -AsyncCubebTask::AsyncCubebTask(AudioCallbackDriver* aDriver, AsyncCubebOperation aOperation) - : mDriver(aDriver), - mOperation(aOperation), - mShutdownGrip(aDriver->GraphImpl()) +AsyncCubebTask::AsyncCubebTask(AudioCallbackDriver* aDriver, + AsyncCubebOperation aOperation) + : Runnable("AsyncCubebTask") + , mDriver(aDriver) + , mOperation(aOperation) + , mShutdownGrip(aDriver->GraphImpl()) { NS_WARNING_ASSERTION(mDriver->mAudioStream || aOperation == INIT, "No audio stream!"); @@ -492,9 +497,10 @@ AsyncCubebTask::EnsureThread() // since we don't know the order that the shutdown-threads observers // will run. ClearOnShutdown guarantees it runs first. if (!NS_IsMainThread()) { - NS_DispatchToMainThread(NS_NewRunnableFunction([]() -> void { - ClearOnShutdown(&sThreadPool, ShutdownPhase::ShutdownThreads); - })); + NS_DispatchToMainThread( + NS_NewRunnableFunction("AsyncCubebTask::EnsureThread", []() -> void { + ClearOnShutdown(&sThreadPool, ShutdownPhase::ShutdownThreads); + })); } else { ClearOnShutdown(&sThreadPool, ShutdownPhase::ShutdownThreads); } diff --git a/dom/media/Latency.cpp b/dom/media/Latency.cpp index c42c3178aac0..cdc3af87c47e 100644 --- a/dom/media/Latency.cpp +++ b/dom/media/Latency.cpp @@ -47,18 +47,24 @@ GetLatencyLog() class LogEvent : public Runnable { public: - LogEvent(AsyncLatencyLogger::LatencyLogIndex aIndex, uint64_t aID, int64_t aValue, - TimeStamp aTimeStamp) : - mIndex(aIndex), - mID(aID), - mValue(aValue), - mTimeStamp(aTimeStamp) + LogEvent(AsyncLatencyLogger::LatencyLogIndex aIndex, + uint64_t aID, + int64_t aValue, + TimeStamp aTimeStamp) + : mozilla::Runnable("LogEvent") + , mIndex(aIndex) + , mID(aID) + , mValue(aValue) + , mTimeStamp(aTimeStamp) {} - LogEvent(AsyncLatencyLogger::LatencyLogIndex aIndex, uint64_t aID, int64_t aValue) : - mIndex(aIndex), - mID(aID), - mValue(aValue), - mTimeStamp(TimeStamp()) + LogEvent(AsyncLatencyLogger::LatencyLogIndex aIndex, + uint64_t aID, + int64_t aValue) + : mozilla::Runnable("LogEvent") + , mIndex(aIndex) + , mID(aID) + , mValue(aValue) + , mTimeStamp(TimeStamp()) {} ~LogEvent() {} diff --git a/dom/media/MediaDecoder.cpp b/dom/media/MediaDecoder.cpp index 9d13360d9e9e..69ee07216207 100644 --- a/dom/media/MediaDecoder.cpp +++ b/dom/media/MediaDecoder.cpp @@ -214,30 +214,36 @@ MediaDecoder::ResourceCallback::NotifyDataArrived() // calls to MediaDecoder::NotifyDataArrived() which will update the buffer // ranges of the reader. mTimerArmed = true; - mTimer->InitWithFuncCallback( - TimerCallback, this, sDelay, nsITimer::TYPE_ONE_SHOT); + mTimer->InitWithNamedFuncCallback( + TimerCallback, + this, + sDelay, + nsITimer::TYPE_ONE_SHOT, + "MediaDecoder::ResourceCallback::NotifyDataArrived"); } void MediaDecoder::ResourceCallback::NotifyDataEnded(nsresult aStatus) { RefPtr self = this; - nsCOMPtr r = NS_NewRunnableFunction([=] () { - if (!self->mDecoder) { - return; - } - self->mDecoder->NotifyDownloadEnded(aStatus); - if (NS_SUCCEEDED(aStatus)) { - MediaDecoderOwner* owner = self->GetMediaOwner(); - MOZ_ASSERT(owner); - owner->DownloadSuspended(); + nsCOMPtr r = NS_NewRunnableFunction( + "MediaDecoder::ResourceCallback::NotifyDataEnded", [=]() { + if (!self->mDecoder) { + return; + } + self->mDecoder->NotifyDownloadEnded(aStatus); + if (NS_SUCCEEDED(aStatus)) { + MediaDecoderOwner* owner = self->GetMediaOwner(); + MOZ_ASSERT(owner); + owner->DownloadSuspended(); - // NotifySuspendedStatusChanged will tell the element that download - // has been suspended "by the cache", which is true since we never - // download anything. The element can then transition to HAVE_ENOUGH_DATA. - self->mDecoder->NotifySuspendedStatusChanged(); - } - }); + // NotifySuspendedStatusChanged will tell the element that download + // has been suspended "by the cache", which is true since we never + // download anything. The element can then transition to + // HAVE_ENOUGH_DATA. + self->mDecoder->NotifySuspendedStatusChanged(); + } + }); mAbstractMainThread->Dispatch(r.forget()); } @@ -264,11 +270,12 @@ MediaDecoder::ResourceCallback::NotifyBytesConsumed(int64_t aBytes, int64_t aOffset) { RefPtr self = this; - nsCOMPtr r = NS_NewRunnableFunction([=] () { - if (self->mDecoder) { - self->mDecoder->NotifyBytesConsumed(aBytes, aOffset); - } - }); + nsCOMPtr r = NS_NewRunnableFunction( + "MediaDecoder::ResourceCallback::NotifyBytesConsumed", [=]() { + if (self->mDecoder) { + self->mDecoder->NotifyBytesConsumed(aBytes, aOffset); + } + }); mAbstractMainThread->Dispatch(r.forget()); } @@ -471,10 +478,11 @@ MediaDecoder::Shutdown() // Ensure we always unregister asynchronously in order not to disrupt // the hashtable iterating in MediaShutdownManager::Shutdown(). RefPtr self = this; - nsCOMPtr r = NS_NewRunnableFunction([self] () { - self->mVideoFrameContainer = nullptr; - MediaShutdownManager::Instance().Unregister(self); - }); + nsCOMPtr r = + NS_NewRunnableFunction("MediaDecoder::Shutdown", [self]() { + self->mVideoFrameContainer = nullptr; + MediaShutdownManager::Instance().Unregister(self); + }); mAbstractMainThread->Dispatch(r.forget()); } diff --git a/dom/media/MediaDecoderReader.cpp b/dom/media/MediaDecoderReader.cpp index d192ab5df2f3..b9133f8d367f 100644 --- a/dom/media/MediaDecoderReader.cpp +++ b/dom/media/MediaDecoderReader.cpp @@ -92,7 +92,10 @@ MediaDecoderReader::Init() mTaskQueue, this, &MediaDecoderReader::NotifyDataArrived); } // Dispatch initialization that needs to happen on that task queue. - mTaskQueue->Dispatch(NewRunnableMethod(this, &MediaDecoderReader::InitializationTask)); + mTaskQueue->Dispatch( + NewRunnableMethod("MediaDecoderReader::InitializationTask", + this, + &MediaDecoderReader::InitializationTask)); return InitInternal(); } @@ -244,7 +247,8 @@ class ReRequestVideoWithSkipTask : public Runnable public: ReRequestVideoWithSkipTask(MediaDecoderReader* aReader, const media::TimeUnit& aTimeThreshold) - : mReader(aReader) + : Runnable("ReRequestVideoWithSkipTask") + , mReader(aReader) , mTimeThreshold(aTimeThreshold) { } @@ -270,7 +274,8 @@ class ReRequestAudioTask : public Runnable { public: explicit ReRequestAudioTask(MediaDecoderReader* aReader) - : mReader(aReader) + : Runnable("ReRequestAudioTask") + , mReader(aReader) { } diff --git a/dom/media/MediaDecoderReaderWrapper.cpp b/dom/media/MediaDecoderReaderWrapper.cpp index 48a136707807..7e4b776dfa64 100644 --- a/dom/media/MediaDecoderReaderWrapper.cpp +++ b/dom/media/MediaDecoderReaderWrapper.cpp @@ -111,7 +111,9 @@ MediaDecoderReaderWrapper::ReleaseResources() { MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn()); nsCOMPtr r = - NewRunnableMethod(mReader, &MediaDecoderReader::ReleaseResources); + NewRunnableMethod("MediaDecoderReader::ReleaseResources", + mReader, + &MediaDecoderReader::ReleaseResources); mReader->OwnerThread()->Dispatch(r.forget()); } @@ -120,7 +122,8 @@ MediaDecoderReaderWrapper::ResetDecode(TrackSet aTracks) { MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn()); nsCOMPtr r = - NewRunnableMethod(mReader, + NewRunnableMethod("MediaDecoderReader::ResetDecode", + mReader, &MediaDecoderReader::ResetDecode, aTracks); mReader->OwnerThread()->Dispatch(r.forget()); @@ -161,7 +164,9 @@ MediaDecoderReaderWrapper::SetVideoBlankDecode(bool aIsBlankDecode) { MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn()); nsCOMPtr r = - NewRunnableMethod(mReader, &MediaDecoderReader::SetVideoNullDecode, + NewRunnableMethod("MediaDecoderReader::SetVideoNullDecode", + mReader, + &MediaDecoderReader::SetVideoNullDecode, aIsBlankDecode); mReader->OwnerThread()->Dispatch(r.forget()); } diff --git a/dom/media/MediaDecoderStateMachine.cpp b/dom/media/MediaDecoderStateMachine.cpp index 9292301a9692..0185f3a9d4b7 100644 --- a/dom/media/MediaDecoderStateMachine.cpp +++ b/dom/media/MediaDecoderStateMachine.cpp @@ -1663,7 +1663,9 @@ private: { public: explicit AysncNextFrameSeekTask(NextFrameSeekingState* aStateObject) - : mStateObj(aStateObject) + : Runnable("MediaDecoderStateMachine::NextFrameSeekingState::" + "AysncNextFrameSeekTask") + , mStateObj(aStateObject) { } @@ -2893,7 +2895,10 @@ nsresult MediaDecoderStateMachine::Init(MediaDecoder* aDecoder) // Dispatch initialization that needs to happen on that task queue. nsCOMPtr r = NewRunnableMethod>( - this, &MediaDecoderStateMachine::InitializationTask, aDecoder); + "MediaDecoderStateMachine::InitializationTask", + this, + &MediaDecoderStateMachine::InitializationTask, + aDecoder); mTaskQueue->DispatchStateChange(r.forget()); mAudioQueueListener = AudioQueue().PopEvent().Connect( @@ -3100,10 +3105,11 @@ void MediaDecoderStateMachine::PlayStateChanged() void MediaDecoderStateMachine::SetVideoDecodeMode(VideoDecodeMode aMode) { - nsCOMPtr r = - NewRunnableMethod(this, - &MediaDecoderStateMachine::SetVideoDecodeModeInternal, - aMode); + nsCOMPtr r = NewRunnableMethod( + "MediaDecoderStateMachine::SetVideoDecodeModeInternal", + this, + &MediaDecoderStateMachine::SetVideoDecodeModeInternal, + aMode); OwnerThread()->DispatchStateChange(r.forget()); } @@ -3652,7 +3658,9 @@ MediaDecoderStateMachine::ScheduleStateMachine() mDispatchedStateMachine = true; OwnerThread()->Dispatch( - NewRunnableMethod(this, &MediaDecoderStateMachine::RunStateMachine)); + NewRunnableMethod("MediaDecoderStateMachine::RunStateMachine", + this, + &MediaDecoderStateMachine::RunStateMachine)); } void @@ -3887,9 +3895,12 @@ MediaDecoderStateMachine::RequestDebugInfo() using PromiseType = MediaDecoder::DebugInfoPromise; RefPtr p = new PromiseType::Private(__func__); RefPtr self = this; - OwnerThread()->Dispatch(NS_NewRunnableFunction([self, p] () { - p->Resolve(self->GetDebugInfo(), __func__); - }), AbstractThread::AssertDispatchSuccess, AbstractThread::TailDispatch); + OwnerThread()->Dispatch( + NS_NewRunnableFunction( + "MediaDecoderStateMachine::RequestDebugInfo", + [self, p]() { p->Resolve(self->GetDebugInfo(), __func__); }), + AbstractThread::AssertDispatchSuccess, + AbstractThread::TailDispatch); return p.forget(); } @@ -3899,8 +3910,11 @@ void MediaDecoderStateMachine::AddOutputStream(ProcessedMediaStream* aStream, MOZ_ASSERT(NS_IsMainThread()); LOG("AddOutputStream aStream=%p!", aStream); mOutputStreamManager->Add(aStream, aFinishWhenEnded); - nsCOMPtr r = NewRunnableMethod( - this, &MediaDecoderStateMachine::SetAudioCaptured, true); + nsCOMPtr r = + NewRunnableMethod("MediaDecoderStateMachine::SetAudioCaptured", + this, + &MediaDecoderStateMachine::SetAudioCaptured, + true); OwnerThread()->Dispatch(r.forget()); } @@ -3910,8 +3924,11 @@ void MediaDecoderStateMachine::RemoveOutputStream(MediaStream* aStream) LOG("RemoveOutputStream=%p!", aStream); mOutputStreamManager->Remove(aStream); if (mOutputStreamManager->IsEmpty()) { - nsCOMPtr r = NewRunnableMethod( - this, &MediaDecoderStateMachine::SetAudioCaptured, false); + nsCOMPtr r = + NewRunnableMethod("MediaDecoderStateMachine::SetAudioCaptured", + this, + &MediaDecoderStateMachine::SetAudioCaptured, + false); OwnerThread()->Dispatch(r.forget()); } } diff --git a/dom/media/MediaDecoderStateMachine.h b/dom/media/MediaDecoderStateMachine.h index 17fdc126ba96..d911f57f16db 100644 --- a/dom/media/MediaDecoderStateMachine.h +++ b/dom/media/MediaDecoderStateMachine.h @@ -184,8 +184,11 @@ public: void DispatchSetPlaybackRate(double aPlaybackRate) { - OwnerThread()->DispatchStateChange(NewRunnableMethod( - this, &MediaDecoderStateMachine::SetPlaybackRate, aPlaybackRate)); + OwnerThread()->DispatchStateChange( + NewRunnableMethod("MediaDecoderStateMachine::SetPlaybackRate", + this, + &MediaDecoderStateMachine::SetPlaybackRate, + aPlaybackRate)); } RefPtr BeginShutdown(); @@ -194,11 +197,14 @@ public: void DispatchSetFragmentEndTime(const media::TimeUnit& aEndTime) { RefPtr self = this; - nsCOMPtr r = NS_NewRunnableFunction([self, aEndTime] () { - // A negative number means we don't have a fragment end time at all. - self->mFragmentEndTime = aEndTime >= media::TimeUnit::Zero() - ? aEndTime : media::TimeUnit::Invalid(); - }); + nsCOMPtr r = NS_NewRunnableFunction( + "MediaDecoderStateMachine::DispatchSetFragmentEndTime", + [self, aEndTime]() { + // A negative number means we don't have a fragment end time at all. + self->mFragmentEndTime = aEndTime >= media::TimeUnit::Zero() + ? aEndTime + : media::TimeUnit::Invalid(); + }); OwnerThread()->Dispatch(r.forget()); } diff --git a/dom/media/MediaEventSource.h b/dom/media/MediaEventSource.h index ee59ed689cc8..1c34a415597c 100644 --- a/dom/media/MediaEventSource.h +++ b/dom/media/MediaEventSource.h @@ -135,9 +135,13 @@ public: { if (CanTakeArgs()) { DispatchTask(NewRunnableMethod::Type&&...>( - this, &Listener::ApplyWithArgs, Forward(aEvents)...)); + "detail::Listener::ApplyWithArgs", + this, + &Listener::ApplyWithArgs, + Forward(aEvents)...)); } else { - DispatchTask(NewRunnableMethod(this, &Listener::ApplyWithNoArgs)); + DispatchTask(NewRunnableMethod( + "detail::Listener::ApplyWithNoArgs", this, &Listener::ApplyWithNoArgs)); } } diff --git a/dom/media/MediaFormatReader.cpp b/dom/media/MediaFormatReader.cpp index 4d2d81bcc8ed..00dc94f0400e 100644 --- a/dom/media/MediaFormatReader.cpp +++ b/dom/media/MediaFormatReader.cpp @@ -120,10 +120,9 @@ GlobalAllocPolicy::GlobalAllocPolicy() SystemGroup::Dispatch( "GlobalAllocPolicy::ClearOnShutdown", TaskCategory::Other, - NS_NewRunnableFunction([this] () { + NS_NewRunnableFunction("GlobalAllocPolicy::GlobalAllocPolicy", [this]() { ClearOnShutdown(this, ShutdownPhase::ShutdownThreads); - }) - ); + })); } GlobalAllocPolicy::~GlobalAllocPolicy() @@ -926,9 +925,9 @@ public: void Reset() override { RefPtr self = this; - mTaskQueue->Dispatch(NS_NewRunnableFunction([self]() { - self->mTrackDemuxer->Reset(); - })); + mTaskQueue->Dispatch( + NS_NewRunnableFunction("MediaFormatReader::DemuxerProxy::Wrapper::Reset", + [self]() { self->mTrackDemuxer->Reset(); })); } nsresult GetNextRandomAccessPoint(TimeUnit* aTime) override @@ -986,6 +985,7 @@ private: { RefPtr trackDemuxer = mTrackDemuxer.forget(); mTaskQueue->Dispatch(NS_NewRunnableFunction( + "MediaFormatReader::DemuxerProxy::Wrapper::~Wrapper", [trackDemuxer]() { trackDemuxer->BreakCycles(); })); } @@ -1268,7 +1268,8 @@ public: DispatchKeyNeededEvent(AbstractMediaDecoder* aDecoder, nsTArray& aInitData, const nsString& aInitDataType) - : mDecoder(aDecoder) + : Runnable("DispatchKeyNeededEvent") + , mDecoder(aDecoder) , mInitData(aInitData) , mInitDataType(aInitDataType) { @@ -1295,10 +1296,11 @@ MediaFormatReader::SetCDMProxy(CDMProxy* aProxy) { RefPtr proxy = aProxy; RefPtr self = this; - nsCOMPtr r = NS_NewRunnableFunction([=] () { - MOZ_ASSERT(self->OnTaskQueue()); - self->mCDMProxy = proxy; - }); + nsCOMPtr r = + NS_NewRunnableFunction("MediaFormatReader::SetCDMProxy", [=]() { + MOZ_ASSERT(self->OnTaskQueue()); + self->mCDMProxy = proxy; + }); OwnerThread()->Dispatch(r.forget()); } @@ -1467,7 +1469,7 @@ MediaFormatReader::OnDemuxerInitDone(const MediaResult& aResult) if (aResult != NS_OK && mDecoder) { RefPtr decoder = mDecoder; mDecoder->AbstractMainThread()->Dispatch(NS_NewRunnableFunction( - [decoder, aResult] () { + "MediaFormatReader::OnDemuxerInitDone", [decoder, aResult]() { if (decoder->GetOwner()) { decoder->GetOwner()->DecodeWarning(aResult); } @@ -1854,8 +1856,8 @@ MediaFormatReader::ScheduleUpdate(TrackType aTrack) } LOGV("SchedulingUpdate(%s)", TrackTypeToStr(aTrack)); decoder.mUpdateScheduled = true; - RefPtr task( - NewRunnableMethod(this, &MediaFormatReader::Update, aTrack)); + RefPtr task(NewRunnableMethod( + "MediaFormatReader::Update", this, &MediaFormatReader::Update, aTrack)); OwnerThread()->Dispatch(task.forget()); } @@ -2709,8 +2711,8 @@ MediaFormatReader::ScheduleSeek() return; } mSeekScheduled = true; - OwnerThread()->Dispatch( - NewRunnableMethod(this, &MediaFormatReader::AttemptSeek)); + OwnerThread()->Dispatch(NewRunnableMethod( + "MediaFormatReader::AttemptSeek", this, &MediaFormatReader::AttemptSeek)); } void diff --git a/dom/media/MediaManager.cpp b/dom/media/MediaManager.cpp index 697f44e4765d..45362ace508d 100644 --- a/dom/media/MediaManager.cpp +++ b/dom/media/MediaManager.cpp @@ -651,12 +651,12 @@ template class ErrorCallbackRunnable : public Runnable { public: - ErrorCallbackRunnable( - nsCOMPtr&& aOnSuccess, - nsCOMPtr&& aOnFailure, - MediaMgrError& aError, - uint64_t aWindowID) - : mError(&aError) + ErrorCallbackRunnable(nsCOMPtr&& aOnSuccess, + nsCOMPtr&& aOnFailure, + MediaMgrError& aError, + uint64_t aWindowID) + : Runnable("ErrorCallbackRunnable") + , mError(&aError) , mWindowID(aWindowID) , mManager(MediaManager::GetInstance()) { @@ -991,7 +991,8 @@ public: AudioDevice* aAudioDevice, VideoDevice* aVideoDevice, PeerIdentity* aPeerIdentity) - : mConstraints(aConstraints) + : Runnable("GetUserMediaStreamRunnable") + , mConstraints(aConstraints) , mAudioDevice(aAudioDevice) , mVideoDevice(aVideoDevice) , mWindowID(aWindowID) @@ -1290,7 +1291,8 @@ public: callback.forget(), self->mWindowID, self->mOnFailure.forget()))); - NS_DispatchToMainThread(NS_NewRunnableFunction([]() -> void { + NS_DispatchToMainThread(NS_NewRunnableFunction("MediaManager::SendPendingGUMRequest", + []() -> void { RefPtr manager = MediaManager::GetInstance(); manager->SendPendingGUMRequest(); })); @@ -1447,12 +1449,15 @@ public: const MediaStreamConstraints& aConstraints, already_AddRefed aOnSuccess, already_AddRefed aOnFailure, - uint64_t aWindowID, GetUserMediaWindowListener *aWindowListener, - SourceListener *aSourceListener, MediaEnginePrefs &aPrefs, + uint64_t aWindowID, + GetUserMediaWindowListener* aWindowListener, + SourceListener* aSourceListener, + MediaEnginePrefs& aPrefs, const ipc::PrincipalInfo& aPrincipalInfo, bool aIsChrome, MediaManager::SourceSet* aSourceSet) - : mConstraints(aConstraints) + : Runnable("GetUserMediaTask") + , mConstraints(aConstraints) , mOnSuccess(aOnSuccess) , mOnFailure(aOnFailure) , mWindowID(aWindowID) @@ -1483,7 +1488,10 @@ public: NS_DispatchToMainThread(errorRunnable.forget()); // Do after ErrorCallbackRunnable Run()s, as it checks active window list NS_DispatchToMainThread(NewRunnableMethod>( - mWindowListener, &GetUserMediaWindowListener::Remove, mSourceListener)); + "GetUserMediaWindowListener::Remove", + mWindowListener, + &GetUserMediaWindowListener::Remove, + mSourceListener)); } NS_IMETHOD @@ -1542,7 +1550,8 @@ public: Fail(NS_LITERAL_STRING("NotReadableError"), NS_ConvertUTF8toUTF16(errorMsg)); } - NS_DispatchToMainThread(NS_NewRunnableFunction([]() -> void { + NS_DispatchToMainThread(NS_NewRunnableFunction("MediaManager::SendPendingGUMRequest", + []() -> void { RefPtr manager = MediaManager::GetInstance(); manager->SendPendingGUMRequest(); })); @@ -1659,8 +1668,9 @@ class GetUserMediaRunnableWrapper : public Runnable { public: // This object must take ownership of task - GetUserMediaRunnableWrapper(GetUserMediaTask* task) : - mTask(task) { + GetUserMediaRunnableWrapper(GetUserMediaTask* task) + : Runnable("GetUserMediaRunnableWrapper") + , mTask(task) { } ~GetUserMediaRunnableWrapper() { @@ -2974,10 +2984,13 @@ MediaManager::Shutdown() class ShutdownTask : public Runnable { public: - ShutdownTask(MediaManager* aManager, - already_AddRefed aReply) - : mManager(aManager) - , mReply(aReply) {} + ShutdownTask(MediaManager* aManager, already_AddRefed aReply) + : mozilla::Runnable("ShutdownTask") + , mManager(aManager) + , mReply(aReply) + { + } + private: NS_IMETHOD Run() override @@ -3711,7 +3724,9 @@ SourceListener::NotifyEvent(MediaStreamGraph* aGraph, NotifyFinished(); return; } - target->Dispatch(NewRunnableMethod(this, &SourceListener::NotifyFinished), + target->Dispatch(NewRunnableMethod("SourceListener::NotifyFinished", + this, + &SourceListener::NotifyFinished), NS_DISPATCH_NORMAL); break; case MediaStreamGraphEvent::EVENT_REMOVED: @@ -3723,7 +3738,9 @@ SourceListener::NotifyEvent(MediaStreamGraph* aGraph, NotifyRemoved(); return; } - target->Dispatch(NewRunnableMethod(this, &SourceListener::NotifyRemoved), + target->Dispatch(NewRunnableMethod("SourceListener::NotifyRemoved", + this, + &SourceListener::NotifyRemoved), NS_DISPATCH_NORMAL); break; case MediaStreamGraphEvent::EVENT_HAS_DIRECT_LISTENERS: @@ -3972,7 +3989,9 @@ GetUserMediaWindowListener::NotifySourceTrackStopped() } nsCOMPtr runnable = - NewRunnableMethod(this, &GetUserMediaWindowListener::NotifyChromeOfTrackStops); + NewRunnableMethod("GetUserMediaWindowListener::NotifyChromeOfTrackStops", + this, + &GetUserMediaWindowListener::NotifyChromeOfTrackStops); nsContentUtils::RunInStableState(runnable.forget()); mChromeNotificationTaskPosted = true; } @@ -3988,21 +4007,29 @@ GetUserMediaWindowListener::NotifyChromeOfTrackStops() } GetUserMediaNotificationEvent::GetUserMediaNotificationEvent( - GetUserMediaStatus aStatus, - uint64_t aWindowID) -: mStatus(aStatus), mWindowID(aWindowID) {} + GetUserMediaStatus aStatus, + uint64_t aWindowID) + : Runnable("GetUserMediaNotificationEvent") + , mStatus(aStatus) + , mWindowID(aWindowID) +{ +} GetUserMediaNotificationEvent::GetUserMediaNotificationEvent( - GetUserMediaStatus aStatus, - already_AddRefed aStream, - already_AddRefed>> aOnTracksAvailableCallback, - uint64_t aWindowID, - already_AddRefed aError) -: mStream(aStream), - mOnTracksAvailableCallback(aOnTracksAvailableCallback), - mStatus(aStatus), - mWindowID(aWindowID), - mOnFailure(aError) {} + GetUserMediaStatus aStatus, + already_AddRefed aStream, + already_AddRefed>> + aOnTracksAvailableCallback, + uint64_t aWindowID, + already_AddRefed aError) + : Runnable("GetUserMediaNotificationEvent") + , mStream(aStream) + , mOnTracksAvailableCallback(aOnTracksAvailableCallback) + , mStatus(aStatus) + , mWindowID(aWindowID) + , mOnFailure(aError) +{ +} GetUserMediaNotificationEvent::~GetUserMediaNotificationEvent() { } diff --git a/dom/media/MediaManager.h b/dom/media/MediaManager.h index d02490830ba3..4136130c05c0 100644 --- a/dom/media/MediaManager.h +++ b/dom/media/MediaManager.h @@ -168,9 +168,13 @@ class ReleaseMediaOperationResource : public Runnable public: ReleaseMediaOperationResource( already_AddRefed aStream, - already_AddRefed>> aOnTracksAvailableCallback): - mStream(aStream), - mOnTracksAvailableCallback(aOnTracksAvailableCallback) {} + already_AddRefed>> + aOnTracksAvailableCallback) + : Runnable("ReleaseMediaOperationResource") + , mStream(aStream) + , mOnTracksAvailableCallback(aOnTracksAvailableCallback) + { + } NS_IMETHOD Run() override {return NS_OK;} private: RefPtr mStream; diff --git a/dom/media/MediaRecorder.cpp b/dom/media/MediaRecorder.cpp index ea8c93309b19..06e3191962b1 100644 --- a/dom/media/MediaRecorder.cpp +++ b/dom/media/MediaRecorder.cpp @@ -177,7 +177,8 @@ class MediaRecorder::Session: public nsIObserver, { public: explicit PushBlobRunnable(Session* aSession) - : mSession(aSession) + : Runnable("dom::MediaRecorder::Session::PushBlobRunnable") + , mSession(aSession) { } NS_IMETHOD Run() override @@ -207,7 +208,8 @@ class MediaRecorder::Session: public nsIObserver, { public: explicit EncoderErrorNotifierRunnable(Session* aSession) - : mSession(aSession) + : Runnable("dom::MediaRecorder::Session::EncoderErrorNotifierRunnable") + , mSession(aSession) { } NS_IMETHOD Run() override @@ -234,8 +236,9 @@ class MediaRecorder::Session: public nsIObserver, class DispatchStartEventRunnable : public Runnable { public: - DispatchStartEventRunnable(Session* aSession, const nsAString & aEventName) - : mSession(aSession) + DispatchStartEventRunnable(Session* aSession, const nsAString& aEventName) + : Runnable("dom::MediaRecorder::Session::DispatchStartEventRunnable") + , mSession(aSession) , mEventName(aEventName) { } @@ -264,7 +267,10 @@ class MediaRecorder::Session: public nsIObserver, { public: explicit ExtractRunnable(Session* aSession) - : mSession(aSession) {} + : Runnable("dom::MediaRecorder::Session::ExtractRunnable") + , mSession(aSession) + { + } ~ExtractRunnable() {} @@ -364,10 +370,16 @@ class MediaRecorder::Session: public nsIObserver, { public: explicit DestroyRunnable(Session* aSession) - : mSession(aSession) {} + : Runnable("dom::MediaRecorder::Session::DestroyRunnable") + , mSession(aSession) + { + } explicit DestroyRunnable(already_AddRefed aSession) - : mSession(aSession) {} + : Runnable("dom::MediaRecorder::Session::DestroyRunnable") + , mSession(aSession) + { + } NS_IMETHOD Run() override { @@ -800,8 +812,11 @@ private: new DispatchStartEventRunnable(this, NS_LITERAL_STRING("start"))); if (NS_FAILED(rv)) { - NS_DispatchToMainThread(NewRunnableMethod(mRecorder, - &MediaRecorder::NotifyError, rv)); + NS_DispatchToMainThread( + NewRunnableMethod("dom::MediaRecorder::NotifyError", + 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 045c43bba86a..316b850dfca6 100644 --- a/dom/media/MediaResource.cpp +++ b/dom/media/MediaResource.cpp @@ -67,10 +67,11 @@ MediaResource::Destroy() delete this; return; } - nsresult rv = - SystemGroup::Dispatch("MediaResource::Destroy", - TaskCategory::Other, - NewNonOwningRunnableMethod(this, &MediaResource::Destroy)); + nsresult rv = SystemGroup::Dispatch( + "MediaResource::Destroy", + TaskCategory::Other, + NewNonOwningRunnableMethod( + "MediaResource::Destroy", this, &MediaResource::Destroy)); MOZ_ALWAYS_SUCCEEDS(rv); } diff --git a/dom/media/MediaStreamGraph.cpp b/dom/media/MediaStreamGraph.cpp index 93939231628e..ba4719b58cb6 100644 --- a/dom/media/MediaStreamGraph.cpp +++ b/dom/media/MediaStreamGraph.cpp @@ -3638,9 +3638,10 @@ MediaStreamGraphImpl::CollectSizesForMemoryReport( { public: explicit FinishCollectRunnable( - already_AddRefed aHandleReport, - already_AddRefed aHandlerData) - : mHandleReport(aHandleReport) + already_AddRefed aHandleReport, + already_AddRefed aHandlerData) + : mozilla::Runnable("FinishCollectRunnable") + , mHandleReport(aHandleReport) , mHandlerData(aHandlerData) {} diff --git a/dom/media/MediaStreamTrack.cpp b/dom/media/MediaStreamTrack.cpp index 853f9159adce..1ec6df7a4ba5 100644 --- a/dom/media/MediaStreamTrack.cpp +++ b/dom/media/MediaStreamTrack.cpp @@ -111,7 +111,11 @@ public: aGraph->DispatchToMainThreadAfterStreamStateUpdate( mAbstractMainThread, NewRunnableMethod>( - this, &PrincipalHandleListener::DoNotifyPrincipalHandleChanged, aNewPrincipalHandle)); + "dom::MediaStreamTrack::PrincipalHandleListener::" + "DoNotifyPrincipalHandleChanged", + this, + &PrincipalHandleListener::DoNotifyPrincipalHandleChanged, + aNewPrincipalHandle)); } protected: diff --git a/dom/media/MediaTimer.cpp b/dom/media/MediaTimer.cpp index 4baab3114328..61b37c28eaaa 100644 --- a/dom/media/MediaTimer.cpp +++ b/dom/media/MediaTimer.cpp @@ -42,8 +42,10 @@ MediaTimer::DispatchDestroy() // Destroy(), which may run completely before the stack if Dispatch() begins // to unwind. nsCOMPtr thread = mThread; - nsresult rv = thread->Dispatch(NewNonOwningRunnableMethod(this, &MediaTimer::Destroy), - NS_DISPATCH_NORMAL); + nsresult rv = + thread->Dispatch(NewNonOwningRunnableMethod( + "MediaTimer::Destroy", this, &MediaTimer::Destroy), + NS_DISPATCH_NORMAL); MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv)); (void) rv; } @@ -97,8 +99,9 @@ MediaTimer::ScheduleUpdate() } mUpdateScheduled = true; - nsresult rv = mThread->Dispatch(NewRunnableMethod(this, &MediaTimer::Update), - NS_DISPATCH_NORMAL); + nsresult rv = mThread->Dispatch( + NewRunnableMethod("MediaTimer::Update", this, &MediaTimer::Update), + NS_DISPATCH_NORMAL); MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv)); (void) rv; } diff --git a/dom/media/TextTrack.cpp b/dom/media/TextTrack.cpp index 19c38a2597d9..7d0951eac463 100644 --- a/dom/media/TextTrack.cpp +++ b/dom/media/TextTrack.cpp @@ -337,11 +337,11 @@ TextTrack::DispatchAsyncTrustedEvent(const nsString& aEventName) } RefPtr self = this; nsGlobalWindow::Cast(win)->Dispatch( - "TextTrack::DispatchAsyncTrustedEvent", TaskCategory::Other, - NS_NewRunnableFunction([self, aEventName]() { - self->DispatchTrustedEvent(aEventName); - }) - ); + "TextTrack::DispatchAsyncTrustedEvent", + TaskCategory::Other, + NS_NewRunnableFunction( + "dom::TextTrack::DispatchAsyncTrustedEvent", + [self, aEventName]() { self->DispatchTrustedEvent(aEventName); })); } bool diff --git a/dom/media/TextTrackList.cpp b/dom/media/TextTrackList.cpp index 47daa6ca77de..abe6e5599d91 100644 --- a/dom/media/TextTrackList.cpp +++ b/dom/media/TextTrackList.cpp @@ -141,7 +141,8 @@ class TrackEventRunner : public Runnable { public: TrackEventRunner(TextTrackList* aList, nsIDOMEvent* aEvent) - : mList(aList) + : Runnable("dom::TrackEventRunner") + , mList(aList) , mEvent(aEvent) {} diff --git a/dom/media/VideoUtils.cpp b/dom/media/VideoUtils.cpp index 9b9e6f8b39fe..73eb65d3d04d 100644 --- a/dom/media/VideoUtils.cpp +++ b/dom/media/VideoUtils.cpp @@ -396,8 +396,8 @@ LogToBrowserConsole(const nsAString& aMsg) { if (!NS_IsMainThread()) { nsString msg(aMsg); - nsCOMPtr task = - NS_NewRunnableFunction([msg]() { LogToBrowserConsole(msg); }); + nsCOMPtr task = NS_NewRunnableFunction( + "LogToBrowserConsole", [msg]() { LogToBrowserConsole(msg); }); SystemGroup::Dispatch("LogToBrowserConsole", TaskCategory::Other, task.forget()); return; } diff --git a/dom/media/VideoUtils.h b/dom/media/VideoUtils.h index 2aeba950aaaf..4f7b88b93122 100644 --- a/dom/media/VideoUtils.h +++ b/dom/media/VideoUtils.h @@ -92,7 +92,11 @@ private: class ShutdownThreadEvent : public Runnable { public: - explicit ShutdownThreadEvent(nsIThread* aThread) : mThread(aThread) {} + explicit ShutdownThreadEvent(nsIThread* aThread) + : Runnable("ShutdownThreadEvent") + , mThread(aThread) + { + } ~ShutdownThreadEvent() {} NS_IMETHOD Run() override { mThread->Shutdown(); @@ -267,8 +271,11 @@ RefPtr InvokeUntil(Work aWork, Condition aCondition) { } else if (aLocalCondition()) { aPromise->Resolve(true, __func__); } else { - nsCOMPtr r = - NS_NewRunnableFunction([aPromise, aLocalWork, aLocalCondition] () { Iteration(aPromise, aLocalWork, aLocalCondition); }); + nsCOMPtr r = NS_NewRunnableFunction( + "InvokeUntil::Helper::Iteration", + [aPromise, aLocalWork, aLocalCondition]() { + Iteration(aPromise, aLocalWork, aLocalCondition); + }); AbstractThread::GetCurrent()->Dispatch(r.forget()); } } diff --git a/dom/media/android/AndroidMediaPluginHost.cpp b/dom/media/android/AndroidMediaPluginHost.cpp index c7088ce32661..9d8842daba54 100644 --- a/dom/media/android/AndroidMediaPluginHost.cpp +++ b/dom/media/android/AndroidMediaPluginHost.cpp @@ -46,7 +46,7 @@ static char* GetResource(Decoder *aDecoder) class GetIntPrefEvent : public Runnable { public: GetIntPrefEvent(const char* aPref, int32_t* aResult) - : mPref(aPref), mResult(aResult) {} + : Runnable("GetIntPrefEvent"), mPref(aPref), mResult(aResult) {} NS_IMETHOD Run() override { return Preferences::GetInt(mPref, mResult); } diff --git a/dom/media/android/AndroidMediaResourceServer.cpp b/dom/media/android/AndroidMediaResourceServer.cpp index 37681b26cc70..8fe7ba5e36e6 100644 --- a/dom/media/android/AndroidMediaResourceServer.cpp +++ b/dom/media/android/AndroidMediaResourceServer.cpp @@ -124,7 +124,11 @@ private: public: ServeResourceEvent(nsIInputStream* aInput, nsIOutputStream* aOutput, AndroidMediaResourceServer* aServer) - : mInput(aInput), mOutput(aOutput), mServer(aServer) {} + : Runnable("ServeResourceEvent") + , mInput(aInput) + , mOutput(aOutput) + , mServer(aServer) + {} // This method runs on the thread and exits when it has completed the // HTTP request. @@ -388,8 +392,9 @@ ResourceSocketListener::OnStopListening(nsIServerSocket* aServ, nsresult aStatus return NS_OK; } -AndroidMediaResourceServer::AndroidMediaResourceServer() : - mMutex("AndroidMediaResourceServer") +AndroidMediaResourceServer::AndroidMediaResourceServer() + : Runnable("AndroidMediaResourceServer") + , mMutex("AndroidMediaResourceServer") { } diff --git a/dom/media/eme/mediadrm/MediaDrmCDMProxy.cpp b/dom/media/eme/mediadrm/MediaDrmCDMProxy.cpp index c042219d5c08..c9b73809d65c 100644 --- a/dom/media/eme/mediadrm/MediaDrmCDMProxy.cpp +++ b/dom/media/eme/mediadrm/MediaDrmCDMProxy.cpp @@ -69,7 +69,8 @@ MediaDrmCDMProxy::Init(PromiseId aPromiseId, } mCDM = mozilla::MakeUnique(mKeySystem); - nsCOMPtr task(NewRunnableMethod(this, + nsCOMPtr task(NewRunnableMethod("MediaDrmCDMProxy::md_Init", + this, &MediaDrmCDMProxy::md_Init, aPromiseId)); mOwnerThread->Dispatch(task, NS_DISPATCH_NORMAL); @@ -93,7 +94,8 @@ MediaDrmCDMProxy::CreateSession(uint32_t aCreateSessionToken, data->mInitData = Move(aInitData); nsCOMPtr task( - NewRunnableMethod&&>(this, + NewRunnableMethod&&>("MediaDrmCDMProxy::md_CreateSession", + this, &MediaDrmCDMProxy::md_CreateSession, Move(data))); mOwnerThread->Dispatch(task, NS_DISPATCH_NORMAL); @@ -133,7 +135,8 @@ MediaDrmCDMProxy::UpdateSession(const nsAString& aSessionId, data->mResponse = Move(aResponse); nsCOMPtr task( - NewRunnableMethod&&>(this, + NewRunnableMethod&&>("MediaDrmCDMProxy::md_UpdateSession", + this, &MediaDrmCDMProxy::md_UpdateSession, Move(data))); mOwnerThread->Dispatch(task, NS_DISPATCH_NORMAL); @@ -152,7 +155,8 @@ MediaDrmCDMProxy::CloseSession(const nsAString& aSessionId, data->mSessionId = NS_ConvertUTF16toUTF8(aSessionId); nsCOMPtr task( - NewRunnableMethod&&>(this, + NewRunnableMethod&&>("MediaDrmCDMProxy::md_CloseSession", + this, &MediaDrmCDMProxy::md_CloseSession, Move(data))); mOwnerThread->Dispatch(task, NS_DISPATCH_NORMAL); @@ -173,7 +177,8 @@ MediaDrmCDMProxy::Shutdown() MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(mOwnerThread); nsCOMPtr task( - NewRunnableMethod(this, &MediaDrmCDMProxy::md_Shutdown)); + NewRunnableMethod("MediaDrmCDMProxy::md_Shutdown", + this, &MediaDrmCDMProxy::md_Shutdown)); mOwnerThread->Dispatch(task, NS_DISPATCH_NORMAL); mOwnerThread->Shutdown(); @@ -326,7 +331,8 @@ MediaDrmCDMProxy::ResolvePromise(PromiseId aId) } } else { nsCOMPtr task; - task = NewRunnableMethod(this, + task = NewRunnableMethod("MediaDrmCDMProxy::ResolvePromise", + this, &MediaDrmCDMProxy::ResolvePromise, aId); mMainThread->Dispatch(task.forget(), NS_DISPATCH_NORMAL); @@ -408,7 +414,8 @@ MediaDrmCDMProxy::md_Init(uint32_t aPromiseId) mCallback.reset(new MediaDrmCDMCallbackProxy(this)); mCDM->Init(mCallback.get()); nsCOMPtr task( - NewRunnableMethod(this, + NewRunnableMethod("MediaDrmCDMProxy::OnCDMCreated", + this, &MediaDrmCDMProxy::OnCDMCreated, aPromiseId)); mMainThread->Dispatch(task.forget(), NS_DISPATCH_NORMAL); diff --git a/dom/media/eme/mediadrm/MediaDrmCDMProxy.h b/dom/media/eme/mediadrm/MediaDrmCDMProxy.h index 2989f63165bc..23be97cc396f 100644 --- a/dom/media/eme/mediadrm/MediaDrmCDMProxy.h +++ b/dom/media/eme/mediadrm/MediaDrmCDMProxy.h @@ -151,7 +151,8 @@ private: PromiseId aId, nsresult aCode, const nsCString& aReason) - : mProxy(aProxy) + : Runnable("RejectPromiseTask") + , mProxy(aProxy) , mId(aId) , mCode(aCode) , mReason(aReason) diff --git a/dom/media/gmp/ChromiumCDMParent.cpp b/dom/media/gmp/ChromiumCDMParent.cpp index 57cbc9c80e44..92ccdf5278fe 100644 --- a/dom/media/gmp/ChromiumCDMParent.cpp +++ b/dom/media/gmp/ChromiumCDMParent.cpp @@ -287,7 +287,8 @@ ChromiumCDMParent::RecvOnResolveNewSessionPromise(const uint32_t& aPromiseId, } RefPtr task = - NewRunnableMethod(mProxy, + NewRunnableMethod("ChromiumCDMProxy::OnSetSessionId", + mProxy, &ChromiumCDMProxy::OnSetSessionId, token.value(), NS_ConvertUTF8toUTF16(aSessionId)); @@ -312,6 +313,7 @@ ChromiumCDMParent::RecvResolveLoadSessionPromise(const uint32_t& aPromiseId, } NS_DispatchToMainThread(NewRunnableMethod( + "ChromiumCDMProxy::OnResolveLoadSessionPromise", mProxy, &ChromiumCDMProxy::OnResolveLoadSessionPromise, aPromiseId, @@ -329,8 +331,11 @@ ChromiumCDMParent::ResolvePromise(uint32_t aPromiseId) if (!mProxy || mIsShutdown) { return; } - NS_DispatchToMainThread(NewRunnableMethod( - mProxy, &ChromiumCDMProxy::ResolvePromise, aPromiseId)); + NS_DispatchToMainThread( + NewRunnableMethod("ChromiumCDMProxy::ResolvePromise", + mProxy, + &ChromiumCDMProxy::ResolvePromise, + aPromiseId)); } ipc::IPCResult @@ -380,6 +385,7 @@ ChromiumCDMParent::RejectPromise(uint32_t aPromiseId, return; } NS_DispatchToMainThread(NewRunnableMethod( + "ChromiumCDMProxy::RejectPromise", mProxy, &ChromiumCDMProxy::RejectPromise, aPromiseId, @@ -428,9 +434,10 @@ ChromiumCDMParent::RecvOnSessionMessage(const nsCString& aSessionId, dom::MediaKeyMessageType messageType = ToDOMMessageType(aMessageType); nsTArray msg(Move(aMessage)); NS_DispatchToMainThread( - NS_NewRunnableFunction([proxy, sid, messageType, msg]() mutable { - proxy->OnSessionMessage(sid, messageType, msg); - })); + NS_NewRunnableFunction("gmp::ChromiumCDMParent::RecvOnSessionMessage", + [proxy, sid, messageType, msg]() mutable { + proxy->OnSessionMessage(sid, messageType, msg); + })); return IPC_OK(); } @@ -479,7 +486,8 @@ ChromiumCDMParent::RecvOnSessionKeysChange( } if (keyStatusesChange) { NS_DispatchToMainThread( - NewRunnableMethod(mProxy, + NewRunnableMethod("ChromiumCDMProxy::OnKeyStatusesChange", + mProxy, &ChromiumCDMProxy::OnKeyStatusesChange, NS_ConvertUTF8toUTF16(aSessionId))); } @@ -497,6 +505,7 @@ ChromiumCDMParent::RecvOnExpirationChange(const nsCString& aSessionId, return IPC_OK(); } NS_DispatchToMainThread(NewRunnableMethod( + "ChromiumCDMProxy::OnExpirationChange", mProxy, &ChromiumCDMProxy::OnExpirationChange, NS_ConvertUTF8toUTF16(aSessionId), @@ -512,7 +521,8 @@ ChromiumCDMParent::RecvOnSessionClosed(const nsCString& aSessionId) return IPC_OK(); } NS_DispatchToMainThread( - NewRunnableMethod(mProxy, + NewRunnableMethod("ChromiumCDMProxy::OnSessionClosed", + mProxy, &ChromiumCDMProxy::OnSessionClosed, NS_ConvertUTF8toUTF16(aSessionId))); return IPC_OK(); @@ -530,6 +540,7 @@ ChromiumCDMParent::RecvOnLegacySessionError(const nsCString& aSessionId, } NS_DispatchToMainThread( NewRunnableMethod( + "ChromiumCDMProxy::OnSessionError", mProxy, &ChromiumCDMProxy::OnSessionError, NS_ConvertUTF8toUTF16(aSessionId), @@ -894,8 +905,8 @@ ChromiumCDMParent::ActorDestroy(ActorDestroyReason aWhy) } bool abnormalShutdown = (aWhy == AbnormalShutdown); if (abnormalShutdown && proxy) { - RefPtr task = - NewRunnableMethod(proxy, &ChromiumCDMProxy::Terminated); + RefPtr task = NewRunnableMethod( + "ChromiumCDMProxy::Terminated", proxy, &ChromiumCDMProxy::Terminated); NS_DispatchToMainThread(task); } MaybeDisconnect(abnormalShutdown); @@ -1126,8 +1137,8 @@ ChromiumCDMParent::Shutdown() // collection, and that will not shut down cleanly as the GMP thread will be // shutdown by then. if (mProxy) { - RefPtr task = - NewRunnableMethod(mProxy, &ChromiumCDMProxy::Shutdown); + RefPtr task = NewRunnableMethod( + "ChromiumCDMProxy::Shutdown", mProxy, &ChromiumCDMProxy::Shutdown); NS_DispatchToMainThread(task.forget()); } diff --git a/dom/media/gmp/ChromiumCDMProxy.cpp b/dom/media/gmp/ChromiumCDMProxy.cpp index 8b78e82b5b6c..7fa79a5120d8 100644 --- a/dom/media/gmp/ChromiumCDMProxy.cpp +++ b/dom/media/gmp/ChromiumCDMProxy.cpp @@ -74,6 +74,7 @@ ChromiumCDMProxy::Init(PromiseId aPromiseId, RefPtr self(this); nsCString keySystem = NS_ConvertUTF16toUTF8(mKeySystem); RefPtr task(NS_NewRunnableFunction( + "ChromiumCDMProxy::Init", [self, nodeId, helper, aPromiseId, thread, keySystem]() -> void { MOZ_ASSERT(self->IsOnOwnerThread()); @@ -125,9 +126,12 @@ ChromiumCDMProxy::OnCDMCreated(uint32_t aPromiseId) this); if (!NS_IsMainThread()) { - mMainThread->Dispatch(NewRunnableMethod( - this, &ChromiumCDMProxy::OnCDMCreated, aPromiseId), - NS_DISPATCH_NORMAL); + mMainThread->Dispatch( + NewRunnableMethod("ChromiumCDMProxy::OnCDMCreated", + this, + &ChromiumCDMProxy::OnCDMCreated, + aPromiseId), + NS_DISPATCH_NORMAL); return; } MOZ_ASSERT(NS_IsMainThread()); @@ -209,18 +213,19 @@ ChromiumCDMProxy::CreateSession(uint32_t aCreateSessionToken, return; } - mGMPThread->Dispatch( - NewRunnableMethod>(cdm, - &gmp::ChromiumCDMParent::CreateSession, - aCreateSessionToken, - sessionType, - initDataType, - aPromiseId, - Move(aInitData))); + mGMPThread->Dispatch(NewRunnableMethod>( + "gmp::ChromiumCDMParent::CreateSession", + cdm, + &gmp::ChromiumCDMParent::CreateSession, + aCreateSessionToken, + sessionType, + initDataType, + aPromiseId, + Move(aInitData))); } void @@ -239,6 +244,7 @@ ChromiumCDMProxy::LoadSession(PromiseId aPromiseId, } mGMPThread->Dispatch(NewRunnableMethod( + "gmp::ChromiumCDMParent::LoadSession", cdm, &gmp::ChromiumCDMParent::LoadSession, aPromiseId, @@ -264,6 +270,7 @@ ChromiumCDMProxy::SetServerCertificate(PromiseId aPromiseId, } mGMPThread->Dispatch(NewRunnableMethod>( + "gmp::ChromiumCDMParent::SetServerCertificate", cdm, &gmp::ChromiumCDMParent::SetServerCertificate, aPromiseId, @@ -290,6 +297,7 @@ ChromiumCDMProxy::UpdateSession(const nsAString& aSessionId, } mGMPThread->Dispatch( NewRunnableMethod>( + "gmp::ChromiumCDMParent::UpdateSession", cdm, &gmp::ChromiumCDMParent::UpdateSession, NS_ConvertUTF16toUTF8(aSessionId), @@ -314,6 +322,7 @@ ChromiumCDMProxy::CloseSession(const nsAString& aSessionId, return; } mGMPThread->Dispatch(NewRunnableMethod( + "gmp::ChromiumCDMParent::CloseSession", cdm, &gmp::ChromiumCDMParent::CloseSession, NS_ConvertUTF16toUTF8(aSessionId), @@ -337,6 +346,7 @@ ChromiumCDMProxy::RemoveSession(const nsAString& aSessionId, return; } mGMPThread->Dispatch(NewRunnableMethod( + "gmp::ChromiumCDMParent::RemoveSession", cdm, &gmp::ChromiumCDMParent::RemoveSession, NS_ConvertUTF16toUTF8(aSessionId), @@ -358,8 +368,8 @@ ChromiumCDMProxy::Shutdown() // We need to keep this proxy alive until the parent has finished its // Shutdown (as it may still try to use the proxy until then). RefPtr self(this); - nsCOMPtr task = - NS_NewRunnableFunction([self, cdm]() { cdm->Shutdown(); }); + nsCOMPtr task = NS_NewRunnableFunction( + "ChromiumCDMProxy::Shutdown", [self, cdm]() { cdm->Shutdown(); }); mGMPThread->Dispatch(task.forget()); } } @@ -372,7 +382,12 @@ ChromiumCDMProxy::RejectPromise(PromiseId aId, if (!NS_IsMainThread()) { nsCOMPtr task; task = NewRunnableMethod( - this, &ChromiumCDMProxy::RejectPromise, aId, aCode, aReason); + "ChromiumCDMProxy::RejectPromise", + this, + &ChromiumCDMProxy::RejectPromise, + aId, + aCode, + aReason); NS_DispatchToMainThread(task); return; } @@ -390,8 +405,10 @@ ChromiumCDMProxy::ResolvePromise(PromiseId aId) { if (!NS_IsMainThread()) { nsCOMPtr task; - task = NewRunnableMethod( - this, &ChromiumCDMProxy::ResolvePromise, aId); + task = NewRunnableMethod("ChromiumCDMProxy::ResolvePromise", + this, + &ChromiumCDMProxy::ResolvePromise, + aId); NS_DispatchToMainThread(task); return; } diff --git a/dom/media/gmp/GMPCDMCallbackProxy.cpp b/dom/media/gmp/GMPCDMCallbackProxy.cpp index 10f4770d6066..12d27e6a65db 100644 --- a/dom/media/gmp/GMPCDMCallbackProxy.cpp +++ b/dom/media/gmp/GMPCDMCallbackProxy.cpp @@ -30,12 +30,9 @@ GMPCDMCallbackProxy::SetDecryptorId(uint32_t aId) RefPtr proxy = mProxy; mMainThread->Dispatch( - NS_NewRunnableFunction([proxy, aId] () - { - proxy->OnSetDecryptorId(aId); - }), - NS_DISPATCH_NORMAL - ); + NS_NewRunnableFunction("GMPCDMCallbackProxy::SetDecryptorId", + [proxy, aId]() { proxy->OnSetDecryptorId(aId); }), + NS_DISPATCH_NORMAL); } void @@ -47,14 +44,10 @@ GMPCDMCallbackProxy::SetSessionId(uint32_t aToken, RefPtr proxy = mProxy; auto sid = NS_ConvertUTF8toUTF16(aSessionId); mMainThread->Dispatch( - NS_NewRunnableFunction([proxy, - aToken, - sid] () - { - proxy->OnSetSessionId(aToken, sid); - }), - NS_DISPATCH_NORMAL - ); + NS_NewRunnableFunction( + "GMPCDMCallbackProxy::SetSessionId", + [proxy, aToken, sid]() { proxy->OnSetSessionId(aToken, sid); }), + NS_DISPATCH_NORMAL); } void @@ -65,12 +58,12 @@ GMPCDMCallbackProxy::ResolveLoadSessionPromise(uint32_t aPromiseId, RefPtr proxy = mProxy; mMainThread->Dispatch( - NS_NewRunnableFunction([proxy, aPromiseId, aSuccess] () - { - proxy->OnResolveLoadSessionPromise(aPromiseId, aSuccess); - }), - NS_DISPATCH_NORMAL - ); + NS_NewRunnableFunction("GMPCDMCallbackProxy::ResolveLoadSessionPromise", + [proxy, aPromiseId, aSuccess]() { + proxy->OnResolveLoadSessionPromise(aPromiseId, + aSuccess); + }), + NS_DISPATCH_NORMAL); } void @@ -91,15 +84,12 @@ GMPCDMCallbackProxy::RejectPromise(uint32_t aPromiseId, RefPtr proxy = mProxy; mMainThread->Dispatch( - NS_NewRunnableFunction([proxy, - aPromiseId, - aException, - aMessage] () - { - proxy->OnRejectPromise(aPromiseId, aException, aMessage); - }), - NS_DISPATCH_NORMAL - ); + NS_NewRunnableFunction("GMPCDMCallbackProxy::RejectPromise", + [proxy, aPromiseId, aException, aMessage]() { + proxy->OnRejectPromise( + aPromiseId, aException, aMessage); + }), + NS_DISPATCH_NORMAL); } void @@ -113,15 +103,11 @@ GMPCDMCallbackProxy::SessionMessage(const nsCString& aSessionId, auto sid = NS_ConvertUTF8toUTF16(aSessionId); nsTArray msg(aMessage); mMainThread->Dispatch( - NS_NewRunnableFunction([proxy, - sid, - aMessageType, - msg] () mutable - { - proxy->OnSessionMessage(sid, aMessageType, msg); - }), - NS_DISPATCH_NORMAL - ); + NS_NewRunnableFunction("GMPCDMCallbackProxy::SessionMessage", + [proxy, sid, aMessageType, msg]() mutable { + proxy->OnSessionMessage(sid, aMessageType, msg); + }), + NS_DISPATCH_NORMAL); } void @@ -133,14 +119,11 @@ GMPCDMCallbackProxy::ExpirationChange(const nsCString& aSessionId, RefPtr proxy = mProxy; auto sid = NS_ConvertUTF8toUTF16(aSessionId); mMainThread->Dispatch( - NS_NewRunnableFunction([proxy, - sid, - aExpiryTime] () - { - proxy->OnExpirationChange(sid, aExpiryTime); - }), - NS_DISPATCH_NORMAL - ); + NS_NewRunnableFunction("GMPCDMCallbackProxy::ExpirationChange", + [proxy, sid, aExpiryTime]() { + proxy->OnExpirationChange(sid, aExpiryTime); + }), + NS_DISPATCH_NORMAL); } void @@ -157,22 +140,17 @@ GMPCDMCallbackProxy::SessionClosed(const nsCString& aSessionId) if (keyStatusesChange) { RefPtr proxy = mProxy; mMainThread->Dispatch( - NS_NewRunnableFunction([proxy, sid] () - { - proxy->OnKeyStatusesChange(sid); - }), - NS_DISPATCH_NORMAL - ); + NS_NewRunnableFunction( + "GMPCDMCallbackProxy::SessionClosed", + [proxy, sid]() { proxy->OnKeyStatusesChange(sid); }), + NS_DISPATCH_NORMAL); } RefPtr proxy = mProxy; mMainThread->Dispatch( - NS_NewRunnableFunction([proxy, sid] () - { - proxy->OnSessionClosed(sid); - }), - NS_DISPATCH_NORMAL - ); + NS_NewRunnableFunction("GMPCDMCallbackProxy::SessionClosed", + [proxy, sid]() { proxy->OnSessionClosed(sid); }), + NS_DISPATCH_NORMAL); } void @@ -187,19 +165,12 @@ GMPCDMCallbackProxy::SessionError(const nsCString& aSessionId, auto sid = NS_ConvertUTF8toUTF16(aSessionId); auto msg = NS_ConvertUTF8toUTF16(aMessage); mMainThread->Dispatch( - NS_NewRunnableFunction([proxy, - sid, - aException, - aSystemCode, - msg] () - { - proxy->OnSessionError(sid, - aException, - aSystemCode, - msg); - }), - NS_DISPATCH_NORMAL - ); + NS_NewRunnableFunction("GMPCDMCallbackProxy::SessionError", + [proxy, sid, aException, aSystemCode, msg]() { + proxy->OnSessionError( + sid, aException, aSystemCode, msg); + }), + NS_DISPATCH_NORMAL); } void @@ -228,12 +199,10 @@ GMPCDMCallbackProxy::BatchedKeyStatusChangedInternal(const nsCString& aSessionId RefPtr proxy = mProxy; auto sid = NS_ConvertUTF8toUTF16(aSessionId); mMainThread->Dispatch( - NS_NewRunnableFunction([proxy, sid] () - { - proxy->OnKeyStatusesChange(sid); - }), - NS_DISPATCH_NORMAL - ); + NS_NewRunnableFunction( + "GMPCDMCallbackProxy::BatchedKeyStatusChangedInternal", + [proxy, sid]() { proxy->OnKeyStatusesChange(sid); }), + NS_DISPATCH_NORMAL); } } @@ -254,12 +223,9 @@ GMPCDMCallbackProxy::Terminated() RefPtr proxy = mProxy; mMainThread->Dispatch( - NS_NewRunnableFunction([proxy] () - { - proxy->Terminated(); - }), - NS_DISPATCH_NORMAL - ); + NS_NewRunnableFunction("GMPCDMCallbackProxy::Terminated", + [proxy]() { proxy->Terminated(); }), + NS_DISPATCH_NORMAL); } } // namespace mozilla diff --git a/dom/media/gmp/GMPCDMProxy.cpp b/dom/media/gmp/GMPCDMProxy.cpp index 63ca56b302b4..78074ddb95bd 100644 --- a/dom/media/gmp/GMPCDMProxy.cpp +++ b/dom/media/gmp/GMPCDMProxy.cpp @@ -92,7 +92,8 @@ GMPCDMProxy::Init(PromiseId aPromiseId, data->mGMPName = aGMPName; data->mCrashHelper = mCrashHelper; nsCOMPtr task( - NewRunnableMethod&&>(this, + NewRunnableMethod&&>("GMPCDMProxy::gmp_Init", + this, &GMPCDMProxy::gmp_Init, Move(data))); mOwnerThread->EventTarget()->Dispatch(task.forget(), NS_DISPATCH_NORMAL); @@ -139,7 +140,8 @@ void GMPCDMProxy::OnSetDecryptorId(uint32_t aId) MOZ_ASSERT(mCreatePromiseId); mDecryptorId = aId; nsCOMPtr task( - NewRunnableMethod(this, + NewRunnableMethod("GMPCDMProxy::OnCDMCreated", + this, &GMPCDMProxy::OnCDMCreated, mCreatePromiseId)); mMainThread->Dispatch(task.forget(), NS_DISPATCH_NORMAL); @@ -294,7 +296,8 @@ GMPCDMProxy::CreateSession(uint32_t aCreateSessionToken, data->mInitData = Move(aInitData); nsCOMPtr task( - NewRunnableMethod&&>(this, + NewRunnableMethod&&>("GMPCDMProxy::gmp_CreateSession", + this, &GMPCDMProxy::gmp_CreateSession, Move(data))); mOwnerThread->EventTarget()->Dispatch(task.forget(), NS_DISPATCH_NORMAL); @@ -337,7 +340,8 @@ GMPCDMProxy::LoadSession(PromiseId aPromiseId, data->mPromiseId = aPromiseId; data->mSessionId = NS_ConvertUTF16toUTF8(aSessionId); nsCOMPtr task( - NewRunnableMethod&&>(this, + NewRunnableMethod&&>("GMPCDMProxy::gmp_LoadSession", + this, &GMPCDMProxy::gmp_LoadSession, Move(data))); mOwnerThread->EventTarget()->Dispatch(task.forget(), NS_DISPATCH_NORMAL); @@ -367,7 +371,8 @@ GMPCDMProxy::SetServerCertificate(PromiseId aPromiseId, data->mPromiseId = aPromiseId; data->mCert = Move(aCert); nsCOMPtr task( - NewRunnableMethod&&>(this, + NewRunnableMethod&&>("GMPCDMProxy::gmp_SetServerCertificate", + this, &GMPCDMProxy::gmp_SetServerCertificate, Move(data))); mOwnerThread->EventTarget()->Dispatch(task.forget(), NS_DISPATCH_NORMAL); @@ -399,7 +404,8 @@ GMPCDMProxy::UpdateSession(const nsAString& aSessionId, data->mSessionId = NS_ConvertUTF16toUTF8(aSessionId); data->mResponse = Move(aResponse); nsCOMPtr task( - NewRunnableMethod&&>(this, + NewRunnableMethod&&>("GMPCDMProxy::gmp_UpdateSession", + this, &GMPCDMProxy::gmp_UpdateSession, Move(data))); mOwnerThread->EventTarget()->Dispatch(task.forget(), NS_DISPATCH_NORMAL); @@ -430,7 +436,8 @@ GMPCDMProxy::CloseSession(const nsAString& aSessionId, data->mPromiseId = aPromiseId; data->mSessionId = NS_ConvertUTF16toUTF8(aSessionId); nsCOMPtr task( - NewRunnableMethod&&>(this, + NewRunnableMethod&&>("GMPCDMProxy::gmp_CloseSession", + this, &GMPCDMProxy::gmp_CloseSession, Move(data))); mOwnerThread->EventTarget()->Dispatch(task.forget(), NS_DISPATCH_NORMAL); @@ -459,7 +466,8 @@ GMPCDMProxy::RemoveSession(const nsAString& aSessionId, data->mPromiseId = aPromiseId; data->mSessionId = NS_ConvertUTF16toUTF8(aSessionId); nsCOMPtr task( - NewRunnableMethod&&>(this, + NewRunnableMethod&&>("GMPCDMProxy::gmp_RemoveSession", + this, &GMPCDMProxy::gmp_RemoveSession, Move(data))); mOwnerThread->EventTarget()->Dispatch(task.forget(), NS_DISPATCH_NORMAL); @@ -483,7 +491,8 @@ GMPCDMProxy::Shutdown() MOZ_ASSERT(NS_IsMainThread()); mKeys.Clear(); // Note: This may end up being the last owning reference to the GMPCDMProxy. - nsCOMPtr task(NewRunnableMethod(this, &GMPCDMProxy::gmp_Shutdown)); + nsCOMPtr task(NewRunnableMethod( + "GMPCDMProxy::gmp_Shutdown", this, &GMPCDMProxy::gmp_Shutdown)); if (mOwnerThread) { mOwnerThread->EventTarget()->Dispatch(task.forget(), NS_DISPATCH_NORMAL); } @@ -535,9 +544,8 @@ GMPCDMProxy::ResolvePromise(PromiseId aId) } } else { nsCOMPtr task; - task = NewRunnableMethod(this, - &GMPCDMProxy::ResolvePromise, - aId); + task = NewRunnableMethod( + "GMPCDMProxy::ResolvePromise", this, &GMPCDMProxy::ResolvePromise, aId); mMainThread->Dispatch(task.forget(), NS_DISPATCH_NORMAL); } } @@ -684,7 +692,8 @@ GMPCDMProxy::Decrypt(MediaRawData* aSample) RefPtr promise(job->Ensure()); nsCOMPtr task( - NewRunnableMethod>(this, &GMPCDMProxy::gmp_Decrypt, job)); + NewRunnableMethod>("GMPCDMProxy::gmp_Decrypt", + this, &GMPCDMProxy::gmp_Decrypt, job)); mOwnerThread->EventTarget()->Dispatch(task.forget(), NS_DISPATCH_NORMAL); return promise; } diff --git a/dom/media/gmp/GMPCDMProxy.h b/dom/media/gmp/GMPCDMProxy.h index a1ec05960395..3a5a2e559739 100644 --- a/dom/media/gmp/GMPCDMProxy.h +++ b/dom/media/gmp/GMPCDMProxy.h @@ -191,7 +191,8 @@ private: PromiseId aId, nsresult aCode, const nsCString& aReason) - : mProxy(aProxy) + : Runnable("GMPCDMProxy::RejectPromiseTask") + , mProxy(aProxy) , mId(aId) , mCode(aCode) , mReason(aReason) diff --git a/dom/media/gmp/GMPContentParent.cpp b/dom/media/gmp/GMPContentParent.cpp index 8ae313eb9956..2c5da871714b 100644 --- a/dom/media/gmp/GMPContentParent.cpp +++ b/dom/media/gmp/GMPContentParent.cpp @@ -50,7 +50,8 @@ class ReleaseGMPContentParent : public Runnable { public: explicit ReleaseGMPContentParent(GMPContentParent* aToRelease) - : mToRelease(aToRelease) + : Runnable("gmp::ReleaseGMPContentParent") + , mToRelease(aToRelease) { } @@ -145,8 +146,8 @@ GMPContentParent::CloseIfUnused() GeckoMediaPluginServiceChild::GetSingleton()); gmp->RemoveGMPContentParent(toClose); } - NS_DispatchToCurrentThread(NewRunnableMethod(toClose, - &GMPContentParent::Close)); + NS_DispatchToCurrentThread(NewRunnableMethod( + "gmp::GMPContentParent::Close", toClose, &GMPContentParent::Close)); } } diff --git a/dom/media/gmp/GMPCrashHelper.cpp b/dom/media/gmp/GMPCrashHelper.cpp index f46c4e833719..74fa5bfde324 100644 --- a/dom/media/gmp/GMPCrashHelper.cpp +++ b/dom/media/gmp/GMPCrashHelper.cpp @@ -19,9 +19,11 @@ GMPCrashHelper::Destroy() delete this; } else { // Don't addref, as then we'd end up releasing after the detele runs! - SystemGroup::Dispatch( - "GMPCrashHelper::Destroy", TaskCategory::Other, - NewNonOwningRunnableMethod(this, &GMPCrashHelper::Destroy)); + SystemGroup::Dispatch("GMPCrashHelper::Destroy", + TaskCategory::Other, + NewNonOwningRunnableMethod("GMPCrashHelper::Destroy", + this, + &GMPCrashHelper::Destroy)); } } diff --git a/dom/media/gmp/GMPDecryptorChild.cpp b/dom/media/gmp/GMPDecryptorChild.cpp index 2cc46de05b48..532457694b6b 100644 --- a/dom/media/gmp/GMPDecryptorChild.cpp +++ b/dom/media/gmp/GMPDecryptorChild.cpp @@ -196,10 +196,12 @@ 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. - mPlugin->GMPMessageLoop()->PostTask(NewRunnableMethod - (this, - &GMPDecryptorChild::Decrypted, - aBuffer, aResult)); + mPlugin->GMPMessageLoop()->PostTask( + NewRunnableMethod("gmp::GMPDecryptorChild::Decrypted", + this, + &GMPDecryptorChild::Decrypted, + aBuffer, + aResult)); return; } diff --git a/dom/media/gmp/GMPParent.cpp b/dom/media/gmp/GMPParent.cpp index 1d7fe33676f9..fdd070ce46ca 100644 --- a/dom/media/gmp/GMPParent.cpp +++ b/dom/media/gmp/GMPParent.cpp @@ -334,6 +334,7 @@ GMPParent::ChildTerminated() LOGD("%s::%s: GMPEventTarget() returned nullptr.", __CLASS__, __FUNCTION__); } else { gmpEventTarget->Dispatch(NewRunnableMethod>( + "gmp::GeckoMediaPluginServiceParent::PluginTerminated", mService, &GeckoMediaPluginServiceParent::PluginTerminated, self), @@ -352,7 +353,8 @@ GMPParent::DeleteProcess() mState = GMPStateClosing; Close(); } - mProcess->Delete(NewRunnableMethod(this, &GMPParent::ChildTerminated)); + mProcess->Delete(NewRunnableMethod( + "gmp::GMPParent::ChildTerminated", 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 9e8b02cb7cec..269f16c68e7a 100644 --- a/dom/media/gmp/GMPPlatform.cpp +++ b/dom/media/gmp/GMPPlatform.cpp @@ -77,7 +77,8 @@ public: // main thread tries to do a sync call back to the calling thread. MOZ_ASSERT(!IsOnChildMainThread()); - mMessageLoop->PostTask(NewRunnableMethod(this, &GMPSyncRunnable::Run)); + mMessageLoop->PostTask(NewRunnableMethod( + "gmp::GMPSyncRunnable::Run", this, &GMPSyncRunnable::Run)); MonitorAutoLock lock(mMonitor); while (!mDone) { lock.Wait(); @@ -140,7 +141,8 @@ RunOnMainThread(GMPTask* aTask) } RefPtr r = new GMPRunnable(aTask); - sMainLoop->PostTask(NewRunnableMethod(r, &GMPRunnable::Run)); + sMainLoop->PostTask( + NewRunnableMethod("gmp::GMPRunnable::Run", r, &GMPRunnable::Run)); return GMPNoErr; } @@ -274,7 +276,8 @@ GMPThreadImpl::Post(GMPTask* aTask) } RefPtr r = new GMPRunnable(aTask); - mThread.message_loop()->PostTask(NewRunnableMethod(r.get(), &GMPRunnable::Run)); + mThread.message_loop()->PostTask( + NewRunnableMethod("gmp::GMPRunnable::Run", r.get(), &GMPRunnable::Run)); } void diff --git a/dom/media/gmp/GMPProcessParent.cpp b/dom/media/gmp/GMPProcessParent.cpp index 8c6cd7a0d323..aad88b3ab145 100644 --- a/dom/media/gmp/GMPProcessParent.cpp +++ b/dom/media/gmp/GMPProcessParent.cpp @@ -85,7 +85,8 @@ void GMPProcessParent::Delete(nsCOMPtr aCallback) { mDeletedCallback = aCallback; - XRE_GetIOMessageLoop()->PostTask(NewNonOwningRunnableMethod(this, &GMPProcessParent::DoDelete)); + XRE_GetIOMessageLoop()->PostTask(NewNonOwningRunnableMethod( + "gmp::GMPProcessParent::DoDelete", this, &GMPProcessParent::DoDelete)); } void diff --git a/dom/media/gmp/GMPServiceChild.cpp b/dom/media/gmp/GMPServiceChild.cpp index 8fec2d90c3a5..02f0c097f06d 100644 --- a/dom/media/gmp/GMPServiceChild.cpp +++ b/dom/media/gmp/GMPServiceChild.cpp @@ -490,8 +490,9 @@ class OpenPGMPServiceChild : public mozilla::Runnable public: OpenPGMPServiceChild(UniquePtr&& aGMPServiceChild, ipc::Endpoint&& aEndpoint) - : mGMPServiceChild(Move(aGMPServiceChild)), - mEndpoint(Move(aEndpoint)) + : Runnable("gmp::OpenPGMPServiceChild") + , mGMPServiceChild(Move(aGMPServiceChild)) + , mEndpoint(Move(aEndpoint)) { } diff --git a/dom/media/gmp/GMPServiceParent.cpp b/dom/media/gmp/GMPServiceParent.cpp index 31fcb158070c..2b66e2622eb1 100644 --- a/dom/media/gmp/GMPServiceParent.cpp +++ b/dom/media/gmp/GMPServiceParent.cpp @@ -141,8 +141,10 @@ GeckoMediaPluginServiceParent::Init() int32_t expected = Preferences::GetInt("media.gmp.storage.version.expected", 0); if (version != expected) { Preferences::SetInt("media.gmp.storage.version.observed", expected); - return GMPDispatch(NewRunnableMethod( - this, &GeckoMediaPluginServiceParent::ClearStorage)); + return GMPDispatch( + NewRunnableMethod("gmp::GeckoMediaPluginServiceParent::ClearStorage", + this, + &GeckoMediaPluginServiceParent::ClearStorage)); } return NS_OK; } @@ -298,7 +300,8 @@ GeckoMediaPluginServiceParent::Observe(nsISupports* aSubject, LOGD(("%s::%s Starting to unload plugins, waiting for sync shutdown..." , __CLASS__, __FUNCTION__)); gmpThread->Dispatch( - NewRunnableMethod(this, + NewRunnableMethod("gmp::GeckoMediaPluginServiceParent::UnloadPlugins", + this, &GeckoMediaPluginServiceParent::UnloadPlugins), NS_DISPATCH_NORMAL); @@ -323,8 +326,10 @@ GeckoMediaPluginServiceParent::Observe(nsISupports* aSubject, } else if (!strcmp("browser:purge-session-history", aTopic)) { // Clear everything! if (!aSomeData || nsDependentString(aSomeData).IsEmpty()) { - return GMPDispatch(NewRunnableMethod( - this, &GeckoMediaPluginServiceParent::ClearStorage)); + return GMPDispatch( + NewRunnableMethod("gmp::GeckoMediaPluginServiceParent::ClearStorage", + this, + &GeckoMediaPluginServiceParent::ClearStorage)); } // Clear nodeIds/records modified after |t|. @@ -334,8 +339,10 @@ GeckoMediaPluginServiceParent::Observe(nsISupports* aSubject, return rv; } return GMPDispatch(NewRunnableMethod( - this, &GeckoMediaPluginServiceParent::ClearRecentHistoryOnGMPThread, - t)); + "gmp::GeckoMediaPluginServiceParent::ClearRecentHistoryOnGMPThread", + this, + &GeckoMediaPluginServiceParent::ClearRecentHistoryOnGMPThread, + t)); } return NS_OK; @@ -727,7 +734,7 @@ GeckoMediaPluginServiceParent::EnsurePluginsOnDiskScanned() // cause an event to be dispatched to which scans for plugins. We // dispatch a sync event to the GMP thread here in order to wait until // after the GMP thread has scanned any paths in MOZ_GMP_PATH. - nsresult rv = GMPDispatch(new mozilla::Runnable(), NS_DISPATCH_SYNC); + nsresult rv = GMPDispatch(new mozilla::Runnable("GMPDummyRunnable"), NS_DISPATCH_SYNC); NS_ENSURE_SUCCESS(rv, rv); MOZ_ASSERT(mScannedPluginOnDisk, "Should have scanned MOZ_GMP_PATH by now"); } @@ -1597,9 +1604,13 @@ GeckoMediaPluginServiceParent::ForgetThisSiteNative(const nsAString& aSite, { MOZ_ASSERT(NS_IsMainThread()); - return GMPDispatch(NewRunnableMethod( - this, &GeckoMediaPluginServiceParent::ForgetThisSiteOnGMPThread, - NS_ConvertUTF16toUTF8(aSite), aPattern)); + return GMPDispatch( + NewRunnableMethod( + "gmp::GeckoMediaPluginServiceParent::ForgetThisSiteOnGMPThread", + this, + &GeckoMediaPluginServiceParent::ForgetThisSiteOnGMPThread, + NS_ConvertUTF16toUTF8(aSite), + aPattern)); } static bool IsNodeIdValid(GMPParent* aParent) { @@ -1827,7 +1838,8 @@ class DeleteGMPServiceParent : public mozilla::Runnable { public: explicit DeleteGMPServiceParent(GMPServiceParent* aToDelete) - : mToDelete(aToDelete) + : Runnable("gmp::DeleteGMPServiceParent") + , mToDelete(aToDelete) { } @@ -1861,11 +1873,12 @@ GMPServiceParent::ActorDestroy(ActorDestroyReason aWhy) // Make sure the IPC channel is closed before destroying mToDelete. MonitorAutoLock lock(monitor); - RefPtr task = - NewNonOwningRunnableMethod(this, - &GMPServiceParent::CloseTransport, - &monitor, - &completed); + RefPtr task = NewNonOwningRunnableMethod( + "gmp::GMPServiceParent::CloseTransport", + this, + &GMPServiceParent::CloseTransport, + &monitor, + &completed); XRE_GetIOMessageLoop()->PostTask(Move(task.forget())); while (!completed) { @@ -1876,12 +1889,12 @@ GMPServiceParent::ActorDestroy(ActorDestroyReason aWhy) // GMPServiceParent until the current calling context is finished with // the object. GMPServiceParent* self = this; - NS_DispatchToCurrentThread(NS_NewRunnableFunction([self]() { - // The GMPServiceParent must be destroyed on the main thread. - NS_DispatchToMainThread(NS_NewRunnableFunction([self]() { - delete self; + NS_DispatchToCurrentThread( + NS_NewRunnableFunction("gmp::GMPServiceParent::ActorDestroy", [self]() { + // The GMPServiceParent must be destroyed on the main thread. + NS_DispatchToMainThread(NS_NewRunnableFunction( + "gmp::GMPServiceParent::ActorDestroy", [self]() { delete self; })); })); - })); } class OpenPGMPServiceParent : public mozilla::Runnable @@ -1890,9 +1903,10 @@ public: OpenPGMPServiceParent(GMPServiceParent* aGMPServiceParent, ipc::Endpoint&& aEndpoint, bool* aResult) - : mGMPServiceParent(aGMPServiceParent), - mEndpoint(Move(aEndpoint)), - mResult(aResult) + : Runnable("gmp::OpenPGMPServiceParent") + , mGMPServiceParent(aGMPServiceParent) + , mEndpoint(Move(aEndpoint)) + , mResult(aResult) { } diff --git a/dom/media/gmp/GMPServiceParent.h b/dom/media/gmp/GMPServiceParent.h index 86a0a8d5cf16..846683cf65e6 100644 --- a/dom/media/gmp/GMPServiceParent.h +++ b/dom/media/gmp/GMPServiceParent.h @@ -145,9 +145,12 @@ private: REMOVE_AND_DELETE_FROM_DISK, }; - PathRunnable(GeckoMediaPluginServiceParent* aService, const nsAString& aPath, - EOperation aOperation, bool aDefer = false) - : mService(aService) + PathRunnable(GeckoMediaPluginServiceParent* aService, + const nsAString& aPath, + EOperation aOperation, + bool aDefer = false) + : Runnable("gmp::GeckoMediaPluginServiceParent::PathRunnable") + , mService(aService) , mPath(aPath) , mOperation(aOperation) , mDefer(aDefer) diff --git a/dom/media/gmp/GMPTimerParent.cpp b/dom/media/gmp/GMPTimerParent.cpp index 3a0c9c52a816..f8cc29315ce1 100644 --- a/dom/media/gmp/GMPTimerParent.cpp +++ b/dom/media/gmp/GMPTimerParent.cpp @@ -54,10 +54,12 @@ GMPTimerParent::RecvSetTimer(const uint32_t& aTimerId, NS_ENSURE_SUCCESS(rv, IPC_OK()); ctx->mParent = this; - rv = ctx->mTimer->InitWithFuncCallback(&GMPTimerParent::GMPTimerExpired, - ctx, - aTimeoutMs, - nsITimer::TYPE_ONE_SHOT); + rv = + ctx->mTimer->InitWithNamedFuncCallback(&GMPTimerParent::GMPTimerExpired, + ctx, + aTimeoutMs, + nsITimer::TYPE_ONE_SHOT, + "gmp::GMPTimerParent::RecvSetTimer"); NS_ENSURE_SUCCESS(rv, IPC_OK()); mTimers.PutEntry(ctx.forget()); diff --git a/dom/media/gmp/GMPVideoDecoderChild.cpp b/dom/media/gmp/GMPVideoDecoderChild.cpp index 6c6cd9dc08f0..001aa3091e54 100644 --- a/dom/media/gmp/GMPVideoDecoderChild.cpp +++ b/dom/media/gmp/GMPVideoDecoderChild.cpp @@ -228,7 +228,9 @@ GMPVideoDecoderChild::Alloc(size_t aSize, if (mPendingDecodeComplete && mNeedShmemIntrCount == 0) { mPendingDecodeComplete = false; mPlugin->GMPMessageLoop()->PostTask( - NewRunnableMethod(this, &GMPVideoDecoderChild::RecvDecodingComplete)); + NewRunnableMethod("gmp::GMPVideoDecoderChild::RecvDecodingComplete", + this, + &GMPVideoDecoderChild::RecvDecodingComplete)); } #else #ifdef GMP_SAFE_SHMEM diff --git a/dom/media/gmp/GMPVideoDecoderParent.cpp b/dom/media/gmp/GMPVideoDecoderParent.cpp index 872c4a8975c6..27c565bfa406 100644 --- a/dom/media/gmp/GMPVideoDecoderParent.cpp +++ b/dom/media/gmp/GMPVideoDecoderParent.cpp @@ -202,12 +202,15 @@ GMPVideoDecoderParent::Reset() mIsAwaitingResetComplete = true; RefPtr self(this); - nsCOMPtr task = NS_NewRunnableFunction([self]() -> void - { - LOGD(("GMPVideoDecoderParent[%p]::ResetCompleteTimeout() timed out waiting for ResetComplete", self.get())); - self->mResetCompleteTimeout = nullptr; - LogToBrowserConsole(NS_LITERAL_STRING("GMPVideoDecoderParent timed out waiting for ResetComplete()")); - }); + nsCOMPtr task = NS_NewRunnableFunction( + "gmp::GMPVideoDecoderParent::Reset", [self]() -> void { + LOGD(("GMPVideoDecoderParent[%p]::ResetCompleteTimeout() timed out " + "waiting for ResetComplete", + self.get())); + self->mResetCompleteTimeout = nullptr; + LogToBrowserConsole(NS_LITERAL_STRING( + "GMPVideoDecoderParent timed out waiting for ResetComplete()")); + }); CancelResetCompleteTimeout(); nsCOMPtr target = mPlugin->GMPEventTarget(); mResetCompleteTimeout = SimpleTimer::Create(task, 5000, target); diff --git a/dom/media/gmp/GMPVideoEncoderChild.cpp b/dom/media/gmp/GMPVideoEncoderChild.cpp index e46769e7f32f..2ad82a6d9ef3 100644 --- a/dom/media/gmp/GMPVideoEncoderChild.cpp +++ b/dom/media/gmp/GMPVideoEncoderChild.cpp @@ -209,7 +209,9 @@ GMPVideoEncoderChild::Alloc(size_t aSize, if (mPendingEncodeComplete && mNeedShmemIntrCount == 0) { mPendingEncodeComplete = false; mPlugin->GMPMessageLoop()->PostTask( - NewRunnableMethod(this, &GMPVideoEncoderChild::RecvEncodingComplete)); + NewRunnableMethod("gmp::GMPVideoEncoderChild::RecvEncodingComplete", + this, + &GMPVideoEncoderChild::RecvEncodingComplete)); } #else #ifdef GMP_SAFE_SHMEM diff --git a/dom/media/gtest/GMPTestMonitor.h b/dom/media/gtest/GMPTestMonitor.h index 6b736e06a5e3..2c5f89e6784e 100644 --- a/dom/media/gtest/GMPTestMonitor.h +++ b/dom/media/gtest/GMPTestMonitor.h @@ -37,7 +37,8 @@ public: mozilla::SystemGroup::Dispatch( "GMPTestMonitor::SetFinished", mozilla::TaskCategory::Other, - mozilla::NewNonOwningRunnableMethod(this, &GMPTestMonitor::MarkFinished)); + mozilla::NewNonOwningRunnableMethod( + "GMPTestMonitor::MarkFinished", this, &GMPTestMonitor::MarkFinished)); } private: diff --git a/dom/media/gtest/TestGMPCrossOrigin.cpp b/dom/media/gtest/TestGMPCrossOrigin.cpp index ca8be7924155..87517531b29e 100644 --- a/dom/media/gtest/TestGMPCrossOrigin.cpp +++ b/dom/media/gtest/TestGMPCrossOrigin.cpp @@ -355,7 +355,8 @@ NS_IMPL_ISUPPORTS(GMPShutdownObserver, nsIRunnable, nsIObserver) class NotifyObserversTask : public Runnable { public: explicit NotifyObserversTask(const char* aTopic) - : mTopic(aTopic) + : mozilla::Runnable("NotifyObserversTask") + , mTopic(aTopic) {} NS_IMETHOD Run() override { MOZ_ASSERT(NS_IsMainThread()); @@ -532,7 +533,8 @@ class GMPStorageTest : public GMPDecryptorProxyCallback void DoTest(void (GMPStorageTest::*aTestMethod)()) { EnsureNSSInitializedChromeOrContent(); nsCOMPtr thread(GetGMPThread()); - ClearGMPStorage(NewRunnableMethod(this, aTestMethod), thread); + ClearGMPStorage( + NewRunnableMethod("GMPStorageTest::DoTest", this, aTestMethod), thread); AwaitFinished(); } @@ -585,8 +587,12 @@ class GMPStorageTest : public GMPDecryptorProxyCallback EXPECT_TRUE(!PBnodeId2.Equals(nodeId2)); nsCOMPtr thread(GetGMPThread()); - ClearGMPStorage(NewRunnableMethod( - this, &GMPStorageTest::TestGetNodeId_Continuation, nodeId1), thread); + ClearGMPStorage( + NewRunnableMethod("GMPStorageTest::TestGetNodeId_Continuation", + this, + &GMPStorageTest::TestGetNodeId_Continuation, + nodeId1), + thread); } void TestGetNodeId_Continuation(nsCString aNodeId1) { @@ -646,8 +652,9 @@ class GMPStorageTest : public GMPDecryptorProxyCallback { public: Updates(GMPStorageTest* aRunner, nsTArray&& aUpdates) - : mRunner(aRunner), - mUpdates(Move(aUpdates)) + : mozilla::Runnable("GMPStorageTest::Updates") + , mRunner(aRunner) + , mUpdates(Move(aUpdates)) { } @@ -707,7 +714,9 @@ 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"), - NewRunnableMethod(this, &GMPStorageTest::SetFinished)); + NewRunnableMethod("GMPStorageTest::SetFinished", + this, + &GMPStorageTest::SetFinished)); CreateDecryptor(NS_LITERAL_STRING("http://example1.com"), NS_LITERAL_STRING("http://example2.com"), @@ -726,8 +735,10 @@ class GMPStorageTest : public GMPDecryptorProxyCallback EXPECT_TRUE(IsGMPStorageIsEmpty()); // Generate storage data for some site. - nsCOMPtr r = NewRunnableMethod( - this, &GMPStorageTest::TestForgetThisSite_AnotherSite); + nsCOMPtr r = + NewRunnableMethod("GMPStorageTest::TestForgetThisSite_AnotherSite", + this, + &GMPStorageTest::TestForgetThisSite_AnotherSite); Expect(NS_LITERAL_CSTRING("test-storage complete"), r.forget()); CreateDecryptor(NS_LITERAL_STRING("http://example1.com"), @@ -740,8 +751,10 @@ class GMPStorageTest : public GMPDecryptorProxyCallback Shutdown(); // Generate storage data for another site. - nsCOMPtr r = NewRunnableMethod( - this, &GMPStorageTest::TestForgetThisSite_CollectSiteInfo); + nsCOMPtr r = + NewRunnableMethod("GMPStorageTest::TestForgetThisSite_CollectSiteInfo", + this, + &GMPStorageTest::TestForgetThisSite_CollectSiteInfo); Expect(NS_LITERAL_CSTRING("test-storage complete"), r.forget()); CreateDecryptor(NS_LITERAL_STRING("http://example3.com"), @@ -786,11 +799,13 @@ class GMPStorageTest : public GMPDecryptorProxyCallback EnumerateGMPStorageDir(NS_LITERAL_CSTRING("id"), NodeIdCollector(siteInfo.get())); // Invoke "Forget this site" on the main thread. - SystemGroup::Dispatch( - "TestForgetThisSite_Forget", - TaskCategory::Other, - NewRunnableMethod&&>( - this, &GMPStorageTest::TestForgetThisSite_Forget, Move(siteInfo))); + SystemGroup::Dispatch("TestForgetThisSite_Forget", + TaskCategory::Other, + NewRunnableMethod&&>( + "GMPStorageTest::TestForgetThisSite_Forget", + this, + &GMPStorageTest::TestForgetThisSite_Forget, + Move(siteInfo))); } void TestForgetThisSite_Forget(UniquePtr&& aSiteInfo) { @@ -803,11 +818,14 @@ class GMPStorageTest : public GMPDecryptorProxyCallback service->GetThread(getter_AddRefs(thread)); nsCOMPtr r = NewRunnableMethod&&>( - this, &GMPStorageTest::TestForgetThisSite_Verify, Move(aSiteInfo)); + "GMPStorageTest::TestForgetThisSite_Verify", + this, + &GMPStorageTest::TestForgetThisSite_Verify, + Move(aSiteInfo)); thread->Dispatch(r, NS_DISPATCH_NORMAL); nsCOMPtr f = NewRunnableMethod( - this, &GMPStorageTest::SetFinished); + "GMPStorageTest::SetFinished", this, &GMPStorageTest::SetFinished); thread->Dispatch(f, NS_DISPATCH_NORMAL); } @@ -872,8 +890,10 @@ class GMPStorageTest : public GMPDecryptorProxyCallback EXPECT_TRUE(IsGMPStorageIsEmpty()); // Generate storage data for some site. - nsCOMPtr r = NewRunnableMethod( - this, &GMPStorageTest::TestClearRecentHistory1_Clear); + nsCOMPtr r = + NewRunnableMethod("GMPStorageTest::TestClearRecentHistory1_Clear", + this, + &GMPStorageTest::TestClearRecentHistory1_Clear); Expect(NS_LITERAL_CSTRING("test-storage complete"), r.forget()); CreateDecryptor(NS_LITERAL_STRING("http://example1.com"), @@ -894,8 +914,10 @@ class GMPStorageTest : public GMPDecryptorProxyCallback EXPECT_TRUE(IsGMPStorageIsEmpty()); // Generate storage data for some site. - nsCOMPtr r = NewRunnableMethod( - this, &GMPStorageTest::TestClearRecentHistory2_Clear); + nsCOMPtr r = + NewRunnableMethod("GMPStorageTest::TestClearRecentHistory2_Clear", + this, + &GMPStorageTest::TestClearRecentHistory2_Clear); Expect(NS_LITERAL_CSTRING("test-storage complete"), r.forget()); CreateDecryptor(NS_LITERAL_STRING("http://example1.com"), @@ -916,8 +938,10 @@ class GMPStorageTest : public GMPDecryptorProxyCallback EXPECT_TRUE(IsGMPStorageIsEmpty()); // Generate storage data for some site. - nsCOMPtr r = NewRunnableMethod( - this, &GMPStorageTest::TestClearRecentHistory3_Clear); + nsCOMPtr r = + NewRunnableMethod("GMPStorageTest::TestClearRecentHistory3_Clear", + this, + &GMPStorageTest::TestClearRecentHistory3_Clear); Expect(NS_LITERAL_CSTRING("test-storage complete"), r.forget()); CreateDecryptor(NS_LITERAL_STRING("http://example1.com"), @@ -947,8 +971,10 @@ class GMPStorageTest : public GMPDecryptorProxyCallback nsresult rv = EnumerateGMPStorageDir(NS_LITERAL_CSTRING("id"), f); EXPECT_TRUE(NS_SUCCEEDED(rv)); - nsCOMPtr r = NewRunnableMethod( - this, &GMPStorageTest::TestClearRecentHistory_CheckEmpty); + nsCOMPtr r = + NewRunnableMethod("GMPStorageTest::TestClearRecentHistory_CheckEmpty", + this, + &GMPStorageTest::TestClearRecentHistory_CheckEmpty); nsCOMPtr t(GetGMPThread()); ClearGMPStorage(r.forget(), t, f.GetResult()); } @@ -958,8 +984,10 @@ class GMPStorageTest : public GMPDecryptorProxyCallback nsresult rv = EnumerateGMPStorageDir(NS_LITERAL_CSTRING("storage"), f); EXPECT_TRUE(NS_SUCCEEDED(rv)); - nsCOMPtr r = NewRunnableMethod( - this, &GMPStorageTest::TestClearRecentHistory_CheckEmpty); + nsCOMPtr r = + NewRunnableMethod("GMPStorageTest::TestClearRecentHistory_CheckEmpty", + this, + &GMPStorageTest::TestClearRecentHistory_CheckEmpty); nsCOMPtr t(GetGMPThread()); ClearGMPStorage(r.forget(), t, f.GetResult()); } @@ -969,8 +997,10 @@ class GMPStorageTest : public GMPDecryptorProxyCallback nsresult rv = EnumerateGMPStorageDir(NS_LITERAL_CSTRING("storage"), f); EXPECT_TRUE(NS_SUCCEEDED(rv)); - nsCOMPtr r = NewRunnableMethod( - this, &GMPStorageTest::TestClearRecentHistory_CheckNonEmpty); + nsCOMPtr r = + NewRunnableMethod("GMPStorageTest::TestClearRecentHistory_CheckNonEmpty", + this, + &GMPStorageTest::TestClearRecentHistory_CheckNonEmpty); nsCOMPtr t(GetGMPThread()); ClearGMPStorage(r.forget(), t, f.GetResult() + 1); } @@ -1026,8 +1056,11 @@ class GMPStorageTest : public GMPDecryptorProxyCallback auto t = time(0); nsCString response("stored crossOriginTestRecordId "); response.AppendInt((int64_t)t); - Expect(response, NewRunnableMethod(this, - &GMPStorageTest::TestCrossOriginStorage_RecordStoredContinuation)); + Expect(response, + NewRunnableMethod( + "GMPStorageTest::TestCrossOriginStorage_RecordStoredContinuation", + this, + &GMPStorageTest::TestCrossOriginStorage_RecordStoredContinuation)); nsCString update("store crossOriginTestRecordId "); update.AppendInt((int64_t)t); @@ -1045,8 +1078,11 @@ class GMPStorageTest : public GMPDecryptorProxyCallback // and try to read the record. Shutdown(); - Expect(NS_LITERAL_CSTRING("retrieve crossOriginTestRecordId succeeded (length 0 bytes)"), - NewRunnableMethod(this, &GMPStorageTest::SetFinished)); + Expect(NS_LITERAL_CSTRING( + "retrieve crossOriginTestRecordId succeeded (length 0 bytes)"), + NewRunnableMethod("GMPStorageTest::SetFinished", + this, + &GMPStorageTest::SetFinished)); CreateDecryptor(NS_LITERAL_STRING("http://example5.com"), NS_LITERAL_STRING("http://example6.com"), @@ -1058,8 +1094,11 @@ 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, NewRunnableMethod(this, - &GMPStorageTest::TestPBStorage_RecordStoredContinuation)); + Expect(response, + NewRunnableMethod( + "GMPStorageTest::TestPBStorage_RecordStoredContinuation", + this, + &GMPStorageTest::TestPBStorage_RecordStoredContinuation)); // Open decryptor on one, origin, write a record, close decryptor, // open another, and test that record can be read, close decryptor, @@ -1075,8 +1114,10 @@ class GMPStorageTest : public GMPDecryptorProxyCallback Shutdown(); Expect(NS_LITERAL_CSTRING("retrieve pbdata succeeded (length 12 bytes)"), - NewRunnableMethod(this, - &GMPStorageTest::TestPBStorage_RecordRetrievedContinuation)); + NewRunnableMethod( + "GMPStorageTest::TestPBStorage_RecordRetrievedContinuation", + this, + &GMPStorageTest::TestPBStorage_RecordRetrievedContinuation)); CreateDecryptor(NS_LITERAL_STRING("http://pb1.com"), NS_LITERAL_STRING("http://pb2.com"), @@ -1089,8 +1130,9 @@ class GMPStorageTest : public GMPDecryptorProxyCallback SimulatePBModeExit(); Expect(NS_LITERAL_CSTRING("retrieve pbdata succeeded (length 0 bytes)"), - NewRunnableMethod(this, - &GMPStorageTest::SetFinished)); + NewRunnableMethod("GMPStorageTest::SetFinished", + this, + &GMPStorageTest::SetFinished)); CreateDecryptor(NS_LITERAL_STRING("http://pb1.com"), NS_LITERAL_STRING("http://pb2.com"), @@ -1103,7 +1145,8 @@ class GMPStorageTest : public GMPDecryptorProxyCallback Shutdown(); Expect(NS_LITERAL_CSTRING("OP tests completed"), - NewRunnableMethod(this, &GMPStorageTest::SetFinished)); + NewRunnableMethod("GMPStorageTest::SetFinished", + this, &GMPStorageTest::SetFinished)); CreateDecryptor(NS_LITERAL_STRING("http://example15.com"), NS_LITERAL_STRING("http://example16.com"), @@ -1141,7 +1184,10 @@ class GMPStorageTest : public GMPDecryptorProxyCallback response.Append(longRecordName); response.AppendLiteral(" "); response.Append(data); - Expect(response, NewRunnableMethod(this, &GMPStorageTest::SetFinished)); + Expect(response, + NewRunnableMethod("GMPStorageTest::SetFinished", + this, + &GMPStorageTest::SetFinished)); nsCString update("store "); update.Append(longRecordName); @@ -1168,9 +1214,11 @@ class GMPStorageTest : public GMPDecryptorProxyCallback return; } EXPECT_FALSE(mNodeId.IsEmpty()); - RefPtr task( - new GMPShutdownObserver(NewRunnableMethod(this, &GMPStorageTest::Shutdown), - Move(aContinuation), mNodeId)); + RefPtr task(new GMPShutdownObserver( + NewRunnableMethod( + "GMPStorageTest::Shutdown", this, &GMPStorageTest::Shutdown), + Move(aContinuation), + mNodeId)); SystemGroup::Dispatch("GMPShutdownObserver", TaskCategory::Other, task.forget()); } @@ -1188,7 +1236,8 @@ class GMPStorageTest : public GMPDecryptorProxyCallback void SetFinished() { mFinished = true; Shutdown(); - nsCOMPtr task = NewRunnableMethod(this, &GMPStorageTest::Dummy); + nsCOMPtr task = + NewRunnableMethod("GMPStorageTest::Dummy", this, &GMPStorageTest::Dummy); SystemGroup::Dispatch("GMPStorageTest::Dummy", TaskCategory::Other, task.forget()); } @@ -1278,9 +1327,8 @@ GMPTestRunner::DoTest(void (GMPTestRunner::*aTestMethod)(GMPTestMonitor&)) nsCOMPtr thread(GetGMPThread()); GMPTestMonitor monitor; - thread->Dispatch(NewRunnableMethod(this, - aTestMethod, - monitor), + thread->Dispatch(NewRunnableMethod( + "GMPTestRunner::DoTest", this, aTestMethod, monitor), NS_DISPATCH_NORMAL); monitor.AwaitFinished(); } diff --git a/dom/media/gtest/TestGMPRemoveAndDelete.cpp b/dom/media/gtest/TestGMPRemoveAndDelete.cpp index 4ac92e34e566..20d715c7eb99 100644 --- a/dom/media/gtest/TestGMPRemoveAndDelete.cpp +++ b/dom/media/gtest/TestGMPRemoveAndDelete.cpp @@ -263,10 +263,16 @@ GMPRemoveTest::CreateVideoDecoder(nsCString aNodeId) GMPVideoHost* host; GMPVideoDecoderProxy* decoder = nullptr; - mGMPThread->Dispatch( - NewNonOwningRunnableMethod( - this, &GMPRemoveTest::gmp_GetVideoDecoder, aNodeId, &decoder, &host), - NS_DISPATCH_NORMAL); + mGMPThread->Dispatch(NewNonOwningRunnableMethod( + "GMPRemoveTest::gmp_GetVideoDecoder", + this, + &GMPRemoveTest::gmp_GetVideoDecoder, + aNodeId, + &decoder, + &host), + NS_DISPATCH_NORMAL); mTestMonitor.AwaitFinished(); @@ -280,9 +286,16 @@ GMPRemoveTest::CreateVideoDecoder(nsCString aNodeId) nsTArray empty; mGMPThread->Dispatch( - NewNonOwningRunnableMethod&, GMPVideoDecoderCallbackProxy*, int32_t>( - decoder, &GMPVideoDecoderProxy::InitDecode, - codec, empty, this, 1 /* core count */), + NewNonOwningRunnableMethod&, + GMPVideoDecoderCallbackProxy*, + int32_t>("GMPVideoDecoderProxy::InitDecode", + decoder, + &GMPVideoDecoderProxy::InitDecode, + codec, + empty, + this, + 1 /* core count */), NS_DISPATCH_SYNC); if (mDecoder) { @@ -331,9 +344,10 @@ GMPRemoveTest::gmp_GetVideoDecoder(nsCString aNodeId, void GMPRemoveTest::CloseVideoDecoder() { - mGMPThread->Dispatch( - NewNonOwningRunnableMethod(mDecoder, &GMPVideoDecoderProxy::Close), - NS_DISPATCH_SYNC); + mGMPThread->Dispatch(NewNonOwningRunnableMethod("GMPVideoDecoderProxy::Close", + mDecoder, + &GMPVideoDecoderProxy::Close), + NS_DISPATCH_SYNC); mDecoder = nullptr; mHost = nullptr; @@ -348,9 +362,10 @@ GMPRemoveTest::DeletePluginDirectory(bool aCanDefer) GMPErr GMPRemoveTest::Decode() { - mGMPThread->Dispatch( - NewNonOwningRunnableMethod(this, &GMPRemoveTest::gmp_Decode), - NS_DISPATCH_NORMAL); + mGMPThread->Dispatch(NewNonOwningRunnableMethod("GMPRemoveTest::gmp_Decode", + this, + &GMPRemoveTest::gmp_Decode), + NS_DISPATCH_NORMAL); mTestMonitor.AwaitFinished(); return mDecodeResult; diff --git a/dom/media/gtest/TestMP4Demuxer.cpp b/dom/media/gtest/TestMP4Demuxer.cpp index 231dba0386cf..0a213f62269c 100644 --- a/dom/media/gtest/TestMP4Demuxer.cpp +++ b/dom/media/gtest/TestMP4Demuxer.cpp @@ -148,7 +148,8 @@ private: void DispatchTask(FunctionType aFun) { - RefPtr r = NS_NewRunnableFunction(aFun); + RefPtr r = + NS_NewRunnableFunction("MP4DemuxerBinding::DispatchTask", aFun); mTaskQueue->Dispatch(r.forget()); } diff --git a/dom/media/hls/HLSDemuxer.cpp b/dom/media/hls/HLSDemuxer.cpp index cfcbf6a225a9..f13a3f6f1cb6 100644 --- a/dom/media/hls/HLSDemuxer.cpp +++ b/dom/media/hls/HLSDemuxer.cpp @@ -88,6 +88,7 @@ public: if (!mDemuxer) { return; } RefPtr self = this; mDemuxer->GetTaskQueue()->Dispatch(NS_NewRunnableFunction( + "HLSDemuxer::HLSDemuxerCallbacksSupport::OnInitialized", [=] () { MutexAutoLock lock(self->mMutex); if (self->mDemuxer) { @@ -638,7 +639,8 @@ HLSTrackDemuxer::BreakCycles() { RefPtr self = this; nsCOMPtr task = - NS_NewRunnableFunction([self]() { + NS_NewRunnableFunction("HLSTrackDemuxer::BreakCycles", + [self]() { self->mParent = nullptr; } ); mParent->GetTaskQueue()->Dispatch(task.forget()); diff --git a/dom/media/imagecapture/CaptureTask.cpp b/dom/media/imagecapture/CaptureTask.cpp index 95aeb8478f24..29832429d792 100644 --- a/dom/media/imagecapture/CaptureTask.cpp +++ b/dom/media/imagecapture/CaptureTask.cpp @@ -176,7 +176,10 @@ CaptureTask::PostTrackEndEvent() { public: explicit TrackEndRunnable(CaptureTask* aTask) - : mTask(aTask) {} + : mozilla::Runnable("TrackEndRunnable") + , mTask(aTask) + { + } NS_IMETHOD Run() override { diff --git a/dom/media/ipc/RemoteVideoDecoder.cpp b/dom/media/ipc/RemoteVideoDecoder.cpp index 28953829bf97..d4e1df158882 100644 --- a/dom/media/ipc/RemoteVideoDecoder.cpp +++ b/dom/media/ipc/RemoteVideoDecoder.cpp @@ -34,10 +34,11 @@ RemoteVideoDecoder::~RemoteVideoDecoder() // it alive until we send the delete message. RefPtr actor = mActor; - RefPtr task = NS_NewRunnableFunction([actor]() { - MOZ_ASSERT(actor); - actor->DestroyIPDL(); - }); + RefPtr task = NS_NewRunnableFunction( + "dom::RemoteVideoDecoder::~RemoteVideoDecoder", [actor]() { + MOZ_ASSERT(actor); + actor->DestroyIPDL(); + }); // Drop out references to the actor so that the last ref // always gets released on the manager thread. @@ -103,10 +104,13 @@ RemoteVideoDecoder::SetSeekThreshold(const media::TimeUnit& aTime) { RefPtr self = this; media::TimeUnit time = aTime; - VideoDecoderManagerChild::GetManagerThread()->Dispatch(NS_NewRunnableFunction([=]() { - MOZ_ASSERT(self->mActor); - self->mActor->SetSeekThreshold(time); - }), NS_DISPATCH_NORMAL); + VideoDecoderManagerChild::GetManagerThread()->Dispatch( + NS_NewRunnableFunction("dom::RemoteVideoDecoder::SetSeekThreshold", + [=]() { + MOZ_ASSERT(self->mActor); + self->mActor->SetSeekThreshold(time); + }), + NS_DISPATCH_NORMAL); } MediaDataDecoder::ConversionRequired @@ -160,11 +164,16 @@ RemoteDecoderModule::CreateVideoDecoder(const CreateDecoderParams& aParams) SynchronousTask task("InitIPDL"); bool success; - VideoDecoderManagerChild::GetManagerThread()->Dispatch(NS_NewRunnableFunction([&]() { - AutoCompleteTask complete(&task); - success = object->mActor->InitIPDL(aParams.VideoConfig(), - aParams.mKnowsCompositor->GetTextureFactoryIdentifier()); - }), NS_DISPATCH_NORMAL); + VideoDecoderManagerChild::GetManagerThread()->Dispatch( + NS_NewRunnableFunction( + "dom::RemoteDecoderModule::CreateVideoDecoder", + [&]() { + AutoCompleteTask complete(&task); + success = object->mActor->InitIPDL( + aParams.VideoConfig(), + aParams.mKnowsCompositor->GetTextureFactoryIdentifier()); + }), + NS_DISPATCH_NORMAL); task.Wait(); if (!success) { diff --git a/dom/media/ipc/VideoDecoderChild.cpp b/dom/media/ipc/VideoDecoderChild.cpp index 600272aa8830..46392b343f3a 100644 --- a/dom/media/ipc/VideoDecoderChild.cpp +++ b/dom/media/ipc/VideoDecoderChild.cpp @@ -124,23 +124,24 @@ VideoDecoderChild::ActorDestroy(ActorDestroyReason aWhy) // Defer reporting an error until we've recreated the manager so that // it'll be safe for MediaFormatReader to recreate decoders RefPtr ref = this; - GetManager()->RunWhenRecreated(NS_NewRunnableFunction([=]() { - if (ref->mInitialized) { - mDecodedData.Clear(); - mDecodePromise.RejectIfExists(NS_ERROR_DOM_MEDIA_NEED_NEW_DECODER, - __func__); - mDrainPromise.RejectIfExists(NS_ERROR_DOM_MEDIA_NEED_NEW_DECODER, - __func__); - mFlushPromise.RejectIfExists(NS_ERROR_DOM_MEDIA_NEED_NEW_DECODER, - __func__); - // Make sure the next request will be rejected accordingly if ever - // called. - mNeedNewDecoder = true; - } else { - ref->mInitPromise.RejectIfExists(NS_ERROR_DOM_MEDIA_NEED_NEW_DECODER, - __func__); - } - })); + GetManager()->RunWhenRecreated( + NS_NewRunnableFunction("dom::VideoDecoderChild::ActorDestroy", [=]() { + if (ref->mInitialized) { + mDecodedData.Clear(); + mDecodePromise.RejectIfExists(NS_ERROR_DOM_MEDIA_NEED_NEW_DECODER, + __func__); + mDrainPromise.RejectIfExists(NS_ERROR_DOM_MEDIA_NEED_NEW_DECODER, + __func__); + mFlushPromise.RejectIfExists(NS_ERROR_DOM_MEDIA_NEED_NEW_DECODER, + __func__); + // Make sure the next request will be rejected accordingly if ever + // called. + mNeedNewDecoder = true; + } else { + ref->mInitPromise.RejectIfExists(NS_ERROR_DOM_MEDIA_NEED_NEW_DECODER, + __func__); + } + })); } mCanSend = false; } diff --git a/dom/media/ipc/VideoDecoderManagerChild.cpp b/dom/media/ipc/VideoDecoderManagerChild.cpp index 7749f56aaa92..3dab09c91a28 100644 --- a/dom/media/ipc/VideoDecoderManagerChild.cpp +++ b/dom/media/ipc/VideoDecoderManagerChild.cpp @@ -61,12 +61,16 @@ VideoDecoderManagerChild::Shutdown() MOZ_ASSERT(NS_IsMainThread()); if (sVideoDecoderChildThread) { - sVideoDecoderChildThread->Dispatch(NS_NewRunnableFunction([]() { - if (sDecoderManager && sDecoderManager->CanSend()) { - sDecoderManager->Close(); - sDecoderManager = nullptr; - } - }), NS_DISPATCH_NORMAL); + sVideoDecoderChildThread->Dispatch( + NS_NewRunnableFunction("dom::VideoDecoderManagerChild::Shutdown", + []() { + if (sDecoderManager && + sDecoderManager->CanSend()) { + sDecoderManager->Close(); + sDecoderManager = nullptr; + } + }), + NS_DISPATCH_NORMAL); sVideoDecoderChildAbstractThread = nullptr; sVideoDecoderChildThread->Shutdown(); @@ -177,12 +181,15 @@ VideoDecoderManagerChild::DeallocShmem(mozilla::ipc::Shmem& aShmem) if (NS_GetCurrentThread() != sVideoDecoderChildThread) { RefPtr self = this; mozilla::ipc::Shmem shmem = aShmem; - sVideoDecoderChildThread->Dispatch(NS_NewRunnableFunction([self, shmem]() { - if (self->CanSend()) { - mozilla::ipc::Shmem shmemCopy = shmem; - self->DeallocShmem(shmemCopy); - } - }), NS_DISPATCH_NORMAL); + sVideoDecoderChildThread->Dispatch( + NS_NewRunnableFunction("dom::VideoDecoderManagerChild::DeallocShmem", + [self, shmem]() { + if (self->CanSend()) { + mozilla::ipc::Shmem shmemCopy = shmem; + self->DeallocShmem(shmemCopy); + } + }), + NS_DISPATCH_NORMAL); return true; } return PVideoDecoderManagerChild::DeallocShmem(aShmem); @@ -219,7 +226,8 @@ VideoDecoderManagerChild::Readback(const SurfaceDescriptorGPUVideo& aSD) RefPtr ref = this; SurfaceDescriptor sd; - if (NS_FAILED(sVideoDecoderChildThread->Dispatch(NS_NewRunnableFunction([&]() { + if (NS_FAILED(sVideoDecoderChildThread->Dispatch(NS_NewRunnableFunction("VideoDecoderManagerChild::Readback", + [&]() { AutoCompleteTask complete(&task); if (ref->CanSend()) { ref->SendReadback(aSD, &sd); @@ -254,11 +262,15 @@ VideoDecoderManagerChild::DeallocateSurfaceDescriptorGPUVideo(const SurfaceDescr { RefPtr ref = this; SurfaceDescriptorGPUVideo sd = Move(aSD); - sVideoDecoderChildThread->Dispatch(NS_NewRunnableFunction([ref, sd]() { - if (ref->CanSend()) { - ref->SendDeallocateSurfaceDescriptorGPUVideo(sd); - } - }), NS_DISPATCH_NORMAL); + sVideoDecoderChildThread->Dispatch( + NS_NewRunnableFunction( + "dom::VideoDecoderManagerChild::DeallocateSurfaceDescriptorGPUVideo", + [ref, sd]() { + if (ref->CanSend()) { + ref->SendDeallocateSurfaceDescriptorGPUVideo(sd); + } + }), + NS_DISPATCH_NORMAL); } void diff --git a/dom/media/ipc/VideoDecoderManagerParent.cpp b/dom/media/ipc/VideoDecoderManagerParent.cpp index f914f8bf8713..d80899aa04b0 100644 --- a/dom/media/ipc/VideoDecoderManagerParent.cpp +++ b/dom/media/ipc/VideoDecoderManagerParent.cpp @@ -50,10 +50,12 @@ public: private: ~VideoDecoderManagerThreadHolder() { - NS_DispatchToMainThread(NS_NewRunnableFunction([]() -> void { - sVideoDecoderManagerThread->Shutdown(); - sVideoDecoderManagerThread = nullptr; - })); + NS_DispatchToMainThread(NS_NewRunnableFunction( + "dom::VideoDecoderManagerThreadHolder::~VideoDecoderManagerThreadHolder", + []() -> void { + sVideoDecoderManagerThread->Shutdown(); + sVideoDecoderManagerThread = nullptr; + })); } }; StaticRefPtr sVideoDecoderManagerThreadHolder; @@ -99,14 +101,16 @@ VideoDecoderManagerParent::StartupThreads() sVideoDecoderManagerThread = managerThread; sVideoDecoderManagerThreadHolder = new VideoDecoderManagerThreadHolder(); #if XP_WIN - sVideoDecoderManagerThread->Dispatch(NS_NewRunnableFunction([]() { + sVideoDecoderManagerThread->Dispatch(NS_NewRunnableFunction("VideoDecoderManagerParent::StartupThreads", + []() { HRESULT hr = CoInitializeEx(0, COINIT_MULTITHREADED); MOZ_ASSERT(hr == S_OK); }), NS_DISPATCH_NORMAL); #endif - sVideoDecoderManagerThread->Dispatch(NS_NewRunnableFunction([]() { - layers::VideoBridgeChild::Startup(); - }), NS_DISPATCH_NORMAL); + sVideoDecoderManagerThread->Dispatch( + NS_NewRunnableFunction("dom::VideoDecoderManagerParent::StartupThreads", + []() { layers::VideoBridgeChild::Startup(); }), + NS_DISPATCH_NORMAL); sManagerTaskQueue = new TaskQueue( managerThread.forget(), "VideoDecoderManagerParent::sManagerTaskQueue"); @@ -132,9 +136,9 @@ void VideoDecoderManagerParent::ShutdownVideoBridge() { if (sVideoDecoderManagerThread) { - RefPtr task = NS_NewRunnableFunction([]() { - VideoBridgeChild::Shutdown(); - }); + RefPtr task = NS_NewRunnableFunction( + "dom::VideoDecoderManagerParent::ShutdownVideoBridge", + []() { VideoBridgeChild::Shutdown(); }); SyncRunnable::DispatchToThread(sVideoDecoderManagerThread, task); } } @@ -159,8 +163,12 @@ VideoDecoderManagerParent::CreateForContent(Endpoint RefPtr parent = new VideoDecoderManagerParent(sVideoDecoderManagerThreadHolder); - RefPtr task = NewRunnableMethod&&>( - parent, &VideoDecoderManagerParent::Open, Move(aEndpoint)); + RefPtr task = + NewRunnableMethod&&>( + "dom::VideoDecoderManagerParent::Open", + parent, + &VideoDecoderManagerParent::Open, + Move(aEndpoint)); sVideoDecoderManagerThread->Dispatch(task.forget(), NS_DISPATCH_NORMAL); return true; } diff --git a/dom/media/mediasink/DecodedStream.cpp b/dom/media/mediasink/DecodedStream.cpp index 3ae885dc1415..39e7bf08e033 100644 --- a/dom/media/mediasink/DecodedStream.cpp +++ b/dom/media/mediasink/DecodedStream.cpp @@ -60,7 +60,9 @@ public: if (event == MediaStreamGraphEvent::EVENT_FINISHED) { aGraph->DispatchToMainThreadAfterStreamStateUpdate( mAbstractMainThread, - NewRunnableMethod(this, &DecodedStreamGraphListener::DoNotifyFinished)); + NewRunnableMethod("DecodedStreamGraphListener::DoNotifyFinished", + this, + &DecodedStreamGraphListener::DoNotifyFinished)); } } @@ -73,10 +75,11 @@ public: void Forget() { RefPtr self = this; - mAbstractMainThread->Dispatch(NS_NewRunnableFunction([self] () { - MOZ_ASSERT(NS_IsMainThread()); - self->mFinishPromise.ResolveIfExists(true, __func__); - })); + mAbstractMainThread->Dispatch( + NS_NewRunnableFunction("DecodedStreamGraphListener::Forget", [self]() { + MOZ_ASSERT(NS_IsMainThread()); + self->mFinishPromise.ResolveIfExists(true, __func__); + })); MutexAutoLock lock(mMutex); mStream = nullptr; } @@ -110,9 +113,11 @@ UpdateStreamSuspended(AbstractThread* aMainThread, MediaStream* aStream, bool aB } else { nsCOMPtr r; if (aBlocking) { - r = NewRunnableMethod(aStream, &MediaStream::Suspend); + r = NewRunnableMethod( + "MediaStream::Suspend", aStream, &MediaStream::Suspend); } else { - r = NewRunnableMethod(aStream, &MediaStream::Resume); + r = + NewRunnableMethod("MediaStream::Resume", aStream, &MediaStream::Resume); } aMainThread->Dispatch(r.forget()); } @@ -406,9 +411,8 @@ DecodedStream::DestroyData(UniquePtr aData) DecodedStreamData* data = aData.release(); data->Forget(); - nsCOMPtr r = NS_NewRunnableFunction([=] () { - delete data; - }); + nsCOMPtr r = NS_NewRunnableFunction("DecodedStream::DestroyData", + [=]() { delete data; }); mAbstractMainThread->Dispatch(r.forget()); } diff --git a/dom/media/mediasource/AsyncEventRunner.h b/dom/media/mediasource/AsyncEventRunner.h index a1b6265f7111..5b506523b998 100644 --- a/dom/media/mediasource/AsyncEventRunner.h +++ b/dom/media/mediasource/AsyncEventRunner.h @@ -16,7 +16,8 @@ class AsyncEventRunner : public Runnable { public: AsyncEventRunner(T* aTarget, const char* aName) - : mTarget(aTarget) + : Runnable("AsyncEventRunner") + , mTarget(aTarget) , mName(aName) {} diff --git a/dom/media/mediasource/AutoTaskQueue.h b/dom/media/mediasource/AutoTaskQueue.h index 225bd6102c3a..5f0a62c2d872 100644 --- a/dom/media/mediasource/AutoTaskQueue.h +++ b/dom/media/mediasource/AutoTaskQueue.h @@ -60,7 +60,8 @@ private: { RefPtr taskqueue = mTaskQueue; nsCOMPtr task = - NS_NewRunnableFunction([taskqueue]() { taskqueue->BeginShutdown(); }); + NS_NewRunnableFunction("AutoTaskQueue::~AutoTaskQueue", + [taskqueue]() { taskqueue->BeginShutdown(); }); SystemGroup::Dispatch("~AutoTaskQueue", TaskCategory::Other, task.forget()); } RefPtr mTaskQueue; diff --git a/dom/media/mediasource/MediaSourceDemuxer.cpp b/dom/media/mediasource/MediaSourceDemuxer.cpp index 7a48c82c765f..e1cdbecc521f 100644 --- a/dom/media/mediasource/MediaSourceDemuxer.cpp +++ b/dom/media/mediasource/MediaSourceDemuxer.cpp @@ -56,8 +56,8 @@ MediaSourceDemuxer::AddSizeOfResources( // NB: The track buffers must only be accessed on the TaskQueue. RefPtr self = this; RefPtr sizes = aSizes; - nsCOMPtr task = - NS_NewRunnableFunction([self, sizes] () { + nsCOMPtr task = NS_NewRunnableFunction( + "MediaSourceDemuxer::AddSizeOfResources", [self, sizes]() { for (TrackBuffersManager* manager : self->mSourceBuffers) { manager->AddSizeOfResources(sizes); } @@ -69,14 +69,15 @@ MediaSourceDemuxer::AddSizeOfResources( void MediaSourceDemuxer::NotifyInitDataArrived() { RefPtr self = this; - nsCOMPtr task = NS_NewRunnableFunction([self]() { - if (self->mInitPromise.IsEmpty()) { - return; - } - if (self->ScanSourceBuffersForContent()) { - self->mInitPromise.ResolveIfExists(NS_OK, __func__); - } - }); + nsCOMPtr task = NS_NewRunnableFunction( + "MediaSourceDemuxer::NotifyInitDataArrived", [self]() { + if (self->mInitPromise.IsEmpty()) { + return; + } + if (self->ScanSourceBuffersForContent()) { + self->mInitPromise.ResolveIfExists(NS_OK, __func__); + } + }); GetTaskQueue()->Dispatch(task.forget()); } @@ -168,10 +169,11 @@ MediaSourceDemuxer::GetCrypto() void MediaSourceDemuxer::AttachSourceBuffer(TrackBuffersManager* aSourceBuffer) { - nsCOMPtr task = - NewRunnableMethod( - this, &MediaSourceDemuxer::DoAttachSourceBuffer, - aSourceBuffer); + nsCOMPtr task = NewRunnableMethod( + "MediaSourceDemuxer::DoAttachSourceBuffer", + this, + &MediaSourceDemuxer::DoAttachSourceBuffer, + aSourceBuffer); GetTaskQueue()->Dispatch(task.forget()); } @@ -186,10 +188,11 @@ MediaSourceDemuxer::DoAttachSourceBuffer(mozilla::TrackBuffersManager* aSourceBu void MediaSourceDemuxer::DetachSourceBuffer(TrackBuffersManager* aSourceBuffer) { - nsCOMPtr task = - NewRunnableMethod( - this, &MediaSourceDemuxer::DoDetachSourceBuffer, - aSourceBuffer); + nsCOMPtr task = NewRunnableMethod( + "MediaSourceDemuxer::DoDetachSourceBuffer", + this, + &MediaSourceDemuxer::DoDetachSourceBuffer, + aSourceBuffer); GetTaskQueue()->Dispatch(task.forget()); } @@ -342,7 +345,7 @@ MediaSourceTrackDemuxer::Reset() MOZ_ASSERT(mParent, "Called after BreackCycle()"); RefPtr self = this; nsCOMPtr task = - NS_NewRunnableFunction([self] () { + NS_NewRunnableFunction("MediaSourceTrackDemuxer::Reset", [self]() { self->mNextSample.reset(); self->mReset = true; self->mManager->Seek(self->mType, TimeUnit::Zero(), TimeUnit::Zero()); @@ -384,10 +387,10 @@ MediaSourceTrackDemuxer::BreakCycles() { RefPtr self = this; nsCOMPtr task = - NS_NewRunnableFunction([self]() { + NS_NewRunnableFunction("MediaSourceTrackDemuxer::BreakCycles", [self]() { self->mParent = nullptr; self->mManager = nullptr; - } ); + }); mParent->GetTaskQueue()->Dispatch(task.forget()); } diff --git a/dom/media/mediasource/TrackBuffersManager.cpp b/dom/media/mediasource/TrackBuffersManager.cpp index ee258a37aab3..b9abcfb1d546 100644 --- a/dom/media/mediasource/TrackBuffersManager.cpp +++ b/dom/media/mediasource/TrackBuffersManager.cpp @@ -65,7 +65,8 @@ public: DispatchKeyNeededEvent(AbstractMediaDecoder* aDecoder, nsTArray& aInitData, const nsString& aInitDataType) - : mDecoder(aDecoder) + : Runnable("DispatchKeyNeededEvent") + , mDecoder(aDecoder) , mInitData(aInitData) , mInitDataType(aInitDataType) { @@ -147,7 +148,10 @@ TrackBuffersManager::QueueTask(SourceBufferTask* aTask) { if (!OnTaskQueue()) { GetTaskQueue()->Dispatch(NewRunnableMethod>( - this, &TrackBuffersManager::QueueTask, aTask)); + "TrackBuffersManager::QueueTask", + this, + &TrackBuffersManager::QueueTask, + aTask)); return; } MOZ_ASSERT(OnTaskQueue()); @@ -212,7 +216,10 @@ TrackBuffersManager::ProcessTasks() default: NS_WARNING("Invalid Task"); } - GetTaskQueue()->Dispatch(NewRunnableMethod(this, &TrackBuffersManager::ProcessTasks)); + GetTaskQueue()->Dispatch( + NewRunnableMethod("TrackBuffersManager::ProcessTasks", + this, + &TrackBuffersManager::ProcessTasks)); } // The MSE spec requires that we abort the current SegmentParserLoop @@ -790,7 +797,10 @@ TrackBuffersManager::RejectAppend(const MediaResult& aRejectValue, const char* a void TrackBuffersManager::ScheduleSegmentParserLoop() { - GetTaskQueue()->Dispatch(NewRunnableMethod(this, &TrackBuffersManager::SegmentParserLoop)); + GetTaskQueue()->Dispatch( + NewRunnableMethod("TrackBuffersManager::SegmentParserLoop", + this, + &TrackBuffersManager::SegmentParserLoop)); } void @@ -874,11 +884,12 @@ TrackBuffersManager::OnDemuxerResetDone(const MediaResult& aResult) if (aResult != NS_OK && mParentDecoder) { RefPtr self = this; - mAbstractMainThread->Dispatch(NS_NewRunnableFunction([self, aResult] () { - if (self->mParentDecoder && self->mParentDecoder->GetOwner()) { - self->mParentDecoder->GetOwner()->DecodeWarning(aResult); - } - })); + mAbstractMainThread->Dispatch(NS_NewRunnableFunction( + "TrackBuffersManager::OnDemuxerResetDone", [self, aResult]() { + if (self->mParentDecoder && self->mParentDecoder->GetOwner()) { + self->mParentDecoder->GetOwner()->DecodeWarning(aResult); + } + })); } // Recreate track demuxers. @@ -999,10 +1010,11 @@ TrackBuffersManager::OnDemuxerInitDone(const MediaResult& aResult) 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 - mAbstractMainThread->Dispatch(NewRunnableMethod - (mParentDecoder.get(), - &MediaSourceDecoder::SetInitialDuration, - duration ? duration : -1)); + mAbstractMainThread->Dispatch( + NewRunnableMethod("MediaSourceDecoder::SetInitialDuration", + mParentDecoder.get(), + &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 @@ -1159,11 +1171,12 @@ TrackBuffersManager::OnDemuxerInitDone(const MediaResult& aResult) if (aResult != NS_OK && mParentDecoder) { RefPtr self = this; - mAbstractMainThread->Dispatch(NS_NewRunnableFunction([self, aResult] () { - if (self->mParentDecoder && self->mParentDecoder->GetOwner()) { - self->mParentDecoder->GetOwner()->DecodeWarning(aResult); - } - })); + mAbstractMainThread->Dispatch(NS_NewRunnableFunction( + "TrackBuffersManager::OnDemuxerInitDone", [self, aResult]() { + if (self->mParentDecoder && self->mParentDecoder->GetOwner()) { + self->mParentDecoder->GetOwner()->DecodeWarning(aResult); + } + })); } } diff --git a/dom/media/ogg/OggDemuxer.cpp b/dom/media/ogg/OggDemuxer.cpp index cc0017d53fa8..26cc97fda18d 100644 --- a/dom/media/ogg/OggDemuxer.cpp +++ b/dom/media/ogg/OggDemuxer.cpp @@ -129,14 +129,20 @@ OggDemuxer::~OggDemuxer() // a chained stream or not. bool isChained = mIsChained; void* ptr = this; - nsCOMPtr task = NS_NewRunnableFunction([ptr, isChained]() -> void { - // We can't use OGG_DEBUG here because it implicitly refers to `this`, - // which we can't capture in this runnable. - MOZ_LOG(gMediaDemuxerLog, mozilla::LogLevel::Debug, - ("OggDemuxer(%p)::%s: Reporting telemetry MEDIA_OGG_LOADED_IS_CHAINED=%d", - ptr, __func__, isChained)); - Telemetry::Accumulate(Telemetry::HistogramID::MEDIA_OGG_LOADED_IS_CHAINED, isChained); - }); + nsCOMPtr task = NS_NewRunnableFunction( + "OggDemuxer::~OggDemuxer", [ptr, isChained]() -> void { + // We can't use OGG_DEBUG here because it implicitly refers to `this`, + // which we can't capture in this runnable. + MOZ_LOG(gMediaDemuxerLog, + mozilla::LogLevel::Debug, + ("OggDemuxer(%p)::%s: Reporting telemetry " + "MEDIA_OGG_LOADED_IS_CHAINED=%d", + ptr, + __func__, + isChained)); + Telemetry::Accumulate( + Telemetry::HistogramID::MEDIA_OGG_LOADED_IS_CHAINED, isChained); + }); SystemGroup::Dispatch("~OggDemuxer::report_telemetry", TaskCategory::Other, task.forget()); diff --git a/dom/media/platforms/PDMFactory.cpp b/dom/media/platforms/PDMFactory.cpp index afc040eabc53..5105957d33c9 100644 --- a/dom/media/platforms/PDMFactory.cpp +++ b/dom/media/platforms/PDMFactory.cpp @@ -191,7 +191,7 @@ PDMFactory::EnsureInit() const // Not on the main thread -> Sync-dispatch creation to main thread. nsCOMPtr mainTarget = GetMainThreadEventTarget(); nsCOMPtr runnable = - NS_NewRunnableFunction([]() { + NS_NewRunnableFunction("PDMFactory::EnsureInit", []() { StaticMutexAutoLock mon(sMonitor); if (!sInstance) { sInstance = new PDMFactoryImpl(); diff --git a/dom/media/platforms/android/RemoteDataDecoder.cpp b/dom/media/platforms/android/RemoteDataDecoder.cpp index 20dac82cfbc5..ed57b99a8226 100644 --- a/dom/media/platforms/android/RemoteDataDecoder.cpp +++ b/dom/media/platforms/android/RemoteDataDecoder.cpp @@ -555,7 +555,8 @@ RemoteDataDecoder::UpdateInputStatus(int64_t aTimestamp, bool aProcessed) { if (!mTaskQueue->IsCurrentThreadIn()) { mTaskQueue->Dispatch( - NewRunnableMethod(this, + NewRunnableMethod("RemoteDataDecoder::UpdateInputStatus", + this, &RemoteDataDecoder::UpdateInputStatus, aTimestamp, aProcessed)); @@ -583,7 +584,8 @@ RemoteDataDecoder::UpdateOutputStatus(MediaData* aSample) { if (!mTaskQueue->IsCurrentThreadIn()) { mTaskQueue->Dispatch( - NewRunnableMethod(this, + NewRunnableMethod("RemoteDataDecoder::UpdateOutputStatus", + this, &RemoteDataDecoder::UpdateOutputStatus, aSample)); return; @@ -617,7 +619,8 @@ RemoteDataDecoder::DrainComplete() { if (!mTaskQueue->IsCurrentThreadIn()) { mTaskQueue->Dispatch( - NewRunnableMethod(this, &RemoteDataDecoder::DrainComplete)); + NewRunnableMethod("RemoteDataDecoder::DrainComplete", + this, &RemoteDataDecoder::DrainComplete)); return; } AssertOnTaskQueue(); @@ -635,7 +638,8 @@ RemoteDataDecoder::Error(const MediaResult& aError) { if (!mTaskQueue->IsCurrentThreadIn()) { mTaskQueue->Dispatch( - NewRunnableMethod(this, &RemoteDataDecoder::Error, aError)); + NewRunnableMethod("RemoteDataDecoder::Error", + this, &RemoteDataDecoder::Error, aError)); return; } AssertOnTaskQueue(); diff --git a/dom/media/platforms/omx/OmxDataDecoder.cpp b/dom/media/platforms/omx/OmxDataDecoder.cpp index 011e23cc861e..885366f99aa5 100644 --- a/dom/media/platforms/omx/OmxDataDecoder.cpp +++ b/dom/media/platforms/omx/OmxDataDecoder.cpp @@ -386,16 +386,17 @@ OmxDataDecoder::EmptyBufferDone(BufferData* aData) mCheckingInputExhausted = true; RefPtr self = this; - nsCOMPtr r = NS_NewRunnableFunction([self, this]() { - mCheckingInputExhausted = false; + nsCOMPtr r = + NS_NewRunnableFunction("OmxDataDecoder::EmptyBufferDone", [self, this]() { + mCheckingInputExhausted = false; - if (mMediaRawDatas.Length()) { - return; - } + if (mMediaRawDatas.Length()) { + return; + } - mDecodePromise.ResolveIfExists(mDecodedData, __func__); - mDecodedData.Clear(); - }); + mDecodePromise.ResolveIfExists(mDecodedData, __func__); + mDecodedData.Clear(); + }); mOmxTaskQueue->Dispatch(r.forget()); } diff --git a/dom/media/platforms/wmf/WMFAudioMFTManager.cpp b/dom/media/platforms/wmf/WMFAudioMFTManager.cpp index e0cad38baa5c..46aa556b7cbf 100644 --- a/dom/media/platforms/wmf/WMFAudioMFTManager.cpp +++ b/dom/media/platforms/wmf/WMFAudioMFTManager.cpp @@ -252,7 +252,8 @@ WMFAudioMFTManager::Output(int64_t aStreamOffset, if (!sample) { LOG("Audio MFTDecoder returned success but null output."); - nsCOMPtr task = NS_NewRunnableFunction([]() -> void { + nsCOMPtr task = NS_NewRunnableFunction("WMFAudioMFTManager::Output", + []() -> void { LOG("Reporting telemetry AUDIO_MFT_OUTPUT_NULL_SAMPLES"); Telemetry::Accumulate(Telemetry::HistogramID::AUDIO_MFT_OUTPUT_NULL_SAMPLES, 1); }); diff --git a/dom/media/platforms/wmf/WMFMediaDataDecoder.cpp b/dom/media/platforms/wmf/WMFMediaDataDecoder.cpp index e06ecee2f0c2..79a6dbf4bfa5 100644 --- a/dom/media/platforms/wmf/WMFMediaDataDecoder.cpp +++ b/dom/media/platforms/wmf/WMFMediaDataDecoder.cpp @@ -62,6 +62,7 @@ SendTelemetry(unsigned long hr) } nsCOMPtr runnable = NS_NewRunnableFunction( + "SendTelemetry", [sample] { Telemetry::Accumulate(Telemetry::MEDIA_WMF_DECODE_ERROR, sample); }); @@ -230,7 +231,8 @@ WMFMediaDataDecoder::SetSeekThreshold(const media::TimeUnit& aTime) RefPtr self = this; nsCOMPtr runnable = - NS_NewRunnableFunction([self, aTime]() { + NS_NewRunnableFunction("WMFMediaDataDecoder::SetSeekThreshold", + [self, aTime]() { media::TimeUnit threshold = aTime; self->mMFTManager->SetSeekThreshold(threshold); }); diff --git a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp index 04b3f11d9014..9de254f16c42 100644 --- a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp +++ b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp @@ -151,7 +151,8 @@ WMFVideoMFTManager::~WMFVideoMFTManager() ? 2 : mGotValidOutputAfterNullOutput ? 3 : 4; - nsCOMPtr task = NS_NewRunnableFunction([=]() -> void { + nsCOMPtr task = NS_NewRunnableFunction("WMFVideoMFTManager::~WMFVideoMFTManager", + [=]() -> void { LOG(nsPrintfCString("Reporting telemetry VIDEO_MFT_OUTPUT_NULL_SAMPLES=%d", telemetry) .get()); @@ -388,7 +389,8 @@ class CreateDXVAManagerEvent : public Runnable public: CreateDXVAManagerEvent(layers::KnowsCompositor* aKnowsCompositor, nsCString& aFailureReason) - : mBackend(LayersBackend::LAYERS_D3D11) + : Runnable("CreateDXVAManagerEvent") + , mBackend(LayersBackend::LAYERS_D3D11) , mKnowsCompositor(aKnowsCompositor) , mFailureReason(aFailureReason) { @@ -691,7 +693,8 @@ public: SupportsConfigEvent(DXVA2Manager* aDXVA2Manager, IMFMediaType* aMediaType, float aFramerate) - : mDXVA2Manager(aDXVA2Manager) + : Runnable("SupportsConfigEvent") + , mDXVA2Manager(aDXVA2Manager) , mMediaType(aMediaType) , mFramerate(aFramerate) , mSupportsConfig(false) diff --git a/dom/media/platforms/wrappers/MediaDataDecoderProxy.cpp b/dom/media/platforms/wrappers/MediaDataDecoderProxy.cpp index 099b7957ca7e..374cacfa2b70 100644 --- a/dom/media/platforms/wrappers/MediaDataDecoderProxy.cpp +++ b/dom/media/platforms/wrappers/MediaDataDecoderProxy.cpp @@ -107,6 +107,7 @@ MediaDataDecoderProxy::SetSeekThreshold(const media::TimeUnit& aTime) RefPtr self = this; media::TimeUnit time = aTime; mProxyThread->Dispatch(NS_NewRunnableFunction( + "MediaDataDecoderProxy::SetSeekThreshold", [self, time] { self->mProxyDecoder->SetSeekThreshold(time); })); } diff --git a/dom/media/systemservices/CamerasChild.cpp b/dom/media/systemservices/CamerasChild.cpp index b955881291ff..f932d87df09c 100644 --- a/dom/media/systemservices/CamerasChild.cpp +++ b/dom/media/systemservices/CamerasChild.cpp @@ -46,7 +46,10 @@ class FakeOnDeviceChangeEventRunnable : public Runnable { public: explicit FakeOnDeviceChangeEventRunnable(uint8_t counter) - : mCounter(counter) {} + : Runnable("camera::FakeOnDeviceChangeEventRunnable") + , mCounter(counter) + { + } NS_IMETHOD Run() override { @@ -74,7 +77,10 @@ class InitializeIPCThread : public Runnable { public: InitializeIPCThread() - : mCamerasChild(nullptr) {} + : Runnable("camera::InitializeIPCThread") + , mCamerasChild(nullptr) + { + } NS_IMETHOD Run() override { // Try to get the PBackground handle @@ -285,8 +291,12 @@ CamerasChild::NumberOfCapabilities(CaptureEngine aCapEngine, LOG(("NumberOfCapabilities for %s", deviceUniqueIdUTF8)); nsCString unique_id(deviceUniqueIdUTF8); nsCOMPtr runnable = - mozilla::NewNonOwningRunnableMethod - (this, &CamerasChild::SendNumberOfCapabilities, aCapEngine, unique_id); + mozilla::NewNonOwningRunnableMethod( + "camera::PCamerasChild::SendNumberOfCapabilities", + this, + &CamerasChild::SendNumberOfCapabilities, + aCapEngine, + unique_id); LockAndDispatch<> dispatcher(this, __func__, runnable, 0, mReplyInteger); LOG(("Capture capability count: %d", dispatcher.ReturnValue())); return dispatcher.ReturnValue(); @@ -297,8 +307,11 @@ CamerasChild::NumberOfCaptureDevices(CaptureEngine aCapEngine) { LOG((__PRETTY_FUNCTION__)); nsCOMPtr runnable = - mozilla::NewNonOwningRunnableMethod - (this, &CamerasChild::SendNumberOfCaptureDevices, aCapEngine); + mozilla::NewNonOwningRunnableMethod( + "camera::PCamerasChild::SendNumberOfCaptureDevices", + this, + &CamerasChild::SendNumberOfCaptureDevices, + aCapEngine); LockAndDispatch<> dispatcher(this, __func__, runnable, 0, mReplyInteger); LOG(("Capture Devices: %d", dispatcher.ReturnValue())); return dispatcher.ReturnValue(); @@ -321,8 +334,11 @@ CamerasChild::EnsureInitialized(CaptureEngine aCapEngine) { LOG((__PRETTY_FUNCTION__)); nsCOMPtr runnable = - mozilla::NewNonOwningRunnableMethod - (this, &CamerasChild::SendEnsureInitialized, aCapEngine); + mozilla::NewNonOwningRunnableMethod( + "camera::PCamerasChild::SendEnsureInitialized", + this, + &CamerasChild::SendEnsureInitialized, + aCapEngine); LockAndDispatch<> dispatcher(this, __func__, runnable, 0, mReplyInteger); LOG(("Capture Devices: %d", dispatcher.ReturnValue())); return dispatcher.ReturnValue(); @@ -337,8 +353,13 @@ CamerasChild::GetCaptureCapability(CaptureEngine aCapEngine, LOG(("GetCaptureCapability: %s %d", unique_idUTF8, capability_number)); nsCString unique_id(unique_idUTF8); nsCOMPtr runnable = - mozilla::NewNonOwningRunnableMethod - (this, &CamerasChild::SendGetCaptureCapability, aCapEngine, unique_id, capability_number); + mozilla::NewNonOwningRunnableMethod( + "camera::PCamerasChild::SendGetCaptureCapability", + this, + &CamerasChild::SendGetCaptureCapability, + aCapEngine, + unique_id, + capability_number); LockAndDispatch<> dispatcher(this, __func__, runnable); if (dispatcher.Success()) { capability = mReplyCapability; @@ -374,8 +395,12 @@ CamerasChild::GetCaptureDevice(CaptureEngine aCapEngine, { LOG((__PRETTY_FUNCTION__)); nsCOMPtr runnable = - mozilla::NewNonOwningRunnableMethod - (this, &CamerasChild::SendGetCaptureDevice, aCapEngine, list_number); + mozilla::NewNonOwningRunnableMethod( + "camera::PCamerasChild::SendGetCaptureDevice", + this, + &CamerasChild::SendGetCaptureDevice, + aCapEngine, + list_number); LockAndDispatch<> dispatcher(this, __func__, runnable); if (dispatcher.Success()) { base::strlcpy(device_nameUTF8, mReplyDeviceName.get(), device_nameUTF8Length); @@ -414,8 +439,15 @@ CamerasChild::AllocateCaptureDevice(CaptureEngine aCapEngine, LOG((__PRETTY_FUNCTION__)); nsCString unique_id(unique_idUTF8); nsCOMPtr runnable = - mozilla::NewNonOwningRunnableMethod - (this, &CamerasChild::SendAllocateCaptureDevice, aCapEngine, unique_id, aPrincipalInfo); + mozilla::NewNonOwningRunnableMethod( + "camera::PCamerasChild::SendAllocateCaptureDevice", + this, + &CamerasChild::SendAllocateCaptureDevice, + aCapEngine, + unique_id, + aPrincipalInfo); LockAndDispatch<> dispatcher(this, __func__, runnable); if (dispatcher.Success()) { LOG(("Capture Device allocated: %d", mReplyInteger)); @@ -443,8 +475,12 @@ CamerasChild::ReleaseCaptureDevice(CaptureEngine aCapEngine, { LOG((__PRETTY_FUNCTION__)); nsCOMPtr runnable = - mozilla::NewNonOwningRunnableMethod - (this, &CamerasChild::SendReleaseCaptureDevice, aCapEngine, capture_id); + mozilla::NewNonOwningRunnableMethod( + "camera::PCamerasChild::SendReleaseCaptureDevice", + this, + &CamerasChild::SendReleaseCaptureDevice, + aCapEngine, + capture_id); LockAndDispatch<> dispatcher(this, __func__, runnable); return dispatcher.ReturnValue(); } @@ -489,9 +525,14 @@ CamerasChild::StartCapture(CaptureEngine aCapEngine, webrtcCaps.rawType, webrtcCaps.codecType, webrtcCaps.interlaced); - nsCOMPtr runnable = - mozilla::NewNonOwningRunnableMethod - (this, &CamerasChild::SendStartCapture, aCapEngine, capture_id, capCap); + nsCOMPtr runnable = mozilla:: + NewNonOwningRunnableMethod( + "camera::PCamerasChild::SendStartCapture", + this, + &CamerasChild::SendStartCapture, + aCapEngine, + capture_id, + capCap); LockAndDispatch<> dispatcher(this, __func__, runnable); return dispatcher.ReturnValue(); } @@ -501,8 +542,12 @@ CamerasChild::StopCapture(CaptureEngine aCapEngine, const int capture_id) { LOG((__PRETTY_FUNCTION__)); nsCOMPtr runnable = - mozilla::NewNonOwningRunnableMethod - (this, &CamerasChild::SendStopCapture, aCapEngine, capture_id); + mozilla::NewNonOwningRunnableMethod( + "camera::PCamerasChild::SendStopCapture", + this, + &CamerasChild::SendStopCapture, + aCapEngine, + capture_id); LockAndDispatch<> dispatcher(this, __func__, runnable); if (dispatcher.Success()) { RemoveCallback(aCapEngine, capture_id); @@ -526,9 +571,9 @@ Shutdown(void) class ShutdownRunnable : public Runnable { public: - explicit - ShutdownRunnable(already_AddRefed&& aReplyEvent) - : mReplyEvent(aReplyEvent) {}; + explicit ShutdownRunnable(already_AddRefed&& aReplyEvent) + : Runnable("camera::ShutdownRunnable") + , mReplyEvent(aReplyEvent){}; NS_IMETHOD Run() override { LOG(("Closing BackgroundChild")); @@ -565,8 +610,8 @@ CamerasChild::ShutdownParent() // Delete the parent actor. // CamerasChild (this) will remain alive and is only deleted by the // IPC layer when SendAllDone returns. - nsCOMPtr deleteRunnable = - mozilla::NewNonOwningRunnableMethod(this, &CamerasChild::SendAllDone); + nsCOMPtr deleteRunnable = mozilla::NewNonOwningRunnableMethod( + "camera::PCamerasChild::SendAllDone", this, &CamerasChild::SendAllDone); CamerasSingleton::Thread()->Dispatch(deleteRunnable, NS_DISPATCH_NORMAL); } else { LOG(("ShutdownParent called without PBackground thread")); @@ -581,9 +626,8 @@ CamerasChild::ShutdownChild() LOG(("PBackground thread exists, dispatching close")); // Dispatch closing the IPC thread back to us when the // BackgroundChild is closed. - RefPtr runnable = - new ShutdownRunnable(NewRunnableMethod(CamerasSingleton::Thread(), - &nsIThread::Shutdown)); + RefPtr runnable = new ShutdownRunnable(NewRunnableMethod( + "nsIThread::Shutdown", CamerasSingleton::Thread(), &nsIThread::Shutdown)); CamerasSingleton::Thread()->Dispatch(runnable.forget(), NS_DISPATCH_NORMAL); } else { LOG(("Shutdown called without PBackground thread")); @@ -593,9 +637,10 @@ CamerasChild::ShutdownChild() CamerasSingleton::Thread() = nullptr; if (CamerasSingleton::FakeDeviceChangeEventThread()) { - RefPtr runnable = - new ShutdownRunnable(NewRunnableMethod(CamerasSingleton::FakeDeviceChangeEventThread(), - &nsIThread::Shutdown)); + RefPtr runnable = new ShutdownRunnable( + NewRunnableMethod("nsIThread::Shutdown", + CamerasSingleton::FakeDeviceChangeEventThread(), + &nsIThread::Shutdown)); CamerasSingleton::FakeDeviceChangeEventThread()->Dispatch(runnable.forget(), NS_DISPATCH_NORMAL); } CamerasSingleton::FakeDeviceChangeEventThread() = nullptr; diff --git a/dom/media/systemservices/CamerasParent.cpp b/dom/media/systemservices/CamerasParent.cpp index 5be8ff338669..54f45e931c33 100644 --- a/dom/media/systemservices/CamerasParent.cpp +++ b/dom/media/systemservices/CamerasParent.cpp @@ -70,11 +70,16 @@ void InputObserver::OnDeviceChange() { class DeliverFrameRunnable : public ::mozilla::Runnable { public: - DeliverFrameRunnable(CamerasParent *aParent, CaptureEngine aEngine, - uint32_t aStreamId, const webrtc::VideoFrame& aFrame, - const VideoFrameProperties& aProperties) - : mParent(aParent), mCapEngine(aEngine), mStreamId(aStreamId), - mProperties(aProperties) + DeliverFrameRunnable(CamerasParent* aParent, + CaptureEngine aEngine, + uint32_t aStreamId, + const webrtc::VideoFrame& aFrame, + const VideoFrameProperties& aProperties) + : Runnable("camera::DeliverFrameRunnable") + , mParent(aParent) + , mCapEngine(aEngine) + , mStreamId(aStreamId) + , mProperties(aProperties) { // No ShmemBuffer (of the right size) was available, so make an // extra buffer here. We have no idea when we are going to run and @@ -87,11 +92,17 @@ public: aProperties.bufferSize(), aFrame); } - DeliverFrameRunnable(CamerasParent* aParent, CaptureEngine aEngine, - uint32_t aStreamId, ShmemBuffer aBuffer, VideoFrameProperties& aProperties) - : mParent(aParent), mCapEngine(aEngine), mStreamId(aStreamId), - mBuffer(Move(aBuffer)), mProperties(aProperties) - {}; + DeliverFrameRunnable(CamerasParent* aParent, + CaptureEngine aEngine, + uint32_t aStreamId, + ShmemBuffer aBuffer, + VideoFrameProperties& aProperties) + : Runnable("camera::DeliverFrameRunnable") + , mParent(aParent) + , mCapEngine(aEngine) + , mStreamId(aStreamId) + , mBuffer(Move(aBuffer)) + , mProperties(aProperties){}; NS_IMETHOD Run() override { if (mParent->IsShuttingDown()) { diff --git a/dom/media/systemservices/MediaSystemResourceManager.cpp b/dom/media/systemservices/MediaSystemResourceManager.cpp index 29db0ef3eaed..e4e2ca2cb95d 100644 --- a/dom/media/systemservices/MediaSystemResourceManager.cpp +++ b/dom/media/systemservices/MediaSystemResourceManager.cpp @@ -65,7 +65,7 @@ MediaSystemResourceManager::Init() bool done = false; RefPtr runnable = - NS_NewRunnableFunction([&]() { + NS_NewRunnableFunction("MediaSystemResourceManager::Init", [&]() { if (!sSingleton) { sSingleton = new MediaSystemResourceManager(); } @@ -199,10 +199,10 @@ MediaSystemResourceManager::Acquire(MediaSystemResourceClient* aClient) } aClient->mResourceState = MediaSystemResourceClient::RESOURCE_STATE_WAITING; ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask( - NewRunnableMethod( - this, - &MediaSystemResourceManager::DoAcquire, - aClient->mId)); + NewRunnableMethod("MediaSystemResourceManager::DoAcquire", + this, + &MediaSystemResourceManager::DoAcquire, + aClient->mId)); } bool @@ -242,10 +242,10 @@ MediaSystemResourceManager::AcquireSyncNoWait(MediaSystemResourceClient* aClient } ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask( - NewRunnableMethod( - this, - &MediaSystemResourceManager::DoAcquire, - aClient->mId)); + NewRunnableMethod("MediaSystemResourceManager::DoAcquire", + this, + &MediaSystemResourceManager::DoAcquire, + aClient->mId)); // should stop the thread until done. while (!done) { @@ -309,10 +309,10 @@ MediaSystemResourceManager::ReleaseResource(MediaSystemResourceClient* aClient) aClient->mResourceState = MediaSystemResourceClient::RESOURCE_STATE_END; ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask( - NewRunnableMethod( - this, - &MediaSystemResourceManager::DoRelease, - aClient->mId)); + NewRunnableMethod("MediaSystemResourceManager::DoRelease", + this, + &MediaSystemResourceManager::DoRelease, + aClient->mId)); } } @@ -338,6 +338,7 @@ MediaSystemResourceManager::HandleAcquireResult(uint32_t aId, bool aSuccess) if (!InImageBridgeChildThread()) { ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask( NewRunnableMethod( + "MediaSystemResourceManager::HandleAcquireResult", this, &MediaSystemResourceManager::HandleAcquireResult, aId, diff --git a/dom/media/systemservices/MediaTaskUtils.h b/dom/media/systemservices/MediaTaskUtils.h index c9b64fd2a4d5..a6c43c57e007 100644 --- a/dom/media/systemservices/MediaTaskUtils.h +++ b/dom/media/systemservices/MediaTaskUtils.h @@ -24,7 +24,12 @@ template class LambdaTask : public Runnable { public: - explicit LambdaTask(OnRunType&& aOnRun) : mOnRun(Move(aOnRun)) {} + explicit LambdaTask(OnRunType&& aOnRun) + : Runnable("media::LambdaTask") + , mOnRun(Move(aOnRun)) + { + } + private: NS_IMETHOD Run() override diff --git a/dom/media/systemservices/MediaUtils.h b/dom/media/systemservices/MediaUtils.h index c208147aaafc..61cbbd7a5089 100644 --- a/dom/media/systemservices/MediaUtils.h +++ b/dom/media/systemservices/MediaUtils.h @@ -186,7 +186,12 @@ template class LambdaRunnable : public Runnable { public: - explicit LambdaRunnable(OnRunType&& aOnRun) : mOnRun(Move(aOnRun)) {} + explicit LambdaRunnable(OnRunType&& aOnRun) + : Runnable("media::LambdaRunnable") + , mOnRun(Move(aOnRun)) + { + } + private: NS_IMETHODIMP Run() override diff --git a/dom/media/webaudio/AnalyserNode.cpp b/dom/media/webaudio/AnalyserNode.cpp index ba9d10b4cc69..0bfd4138198f 100644 --- a/dom/media/webaudio/AnalyserNode.cpp +++ b/dom/media/webaudio/AnalyserNode.cpp @@ -29,9 +29,9 @@ class AnalyserNodeEngine final : public AudioNodeEngine class TransferBuffer final : public Runnable { public: - TransferBuffer(AudioNodeStream* aStream, - const AudioChunk& aChunk) - : mStream(aStream) + TransferBuffer(AudioNodeStream* aStream, const AudioChunk& aChunk) + : Runnable("dom::AnalyserNodeEngine::TransferBuffer") + , mStream(aStream) , mChunk(aChunk) { } diff --git a/dom/media/webaudio/AudioBufferSourceNode.cpp b/dom/media/webaudio/AudioBufferSourceNode.cpp index 5bde3cf099e3..6c61af54ef2a 100644 --- a/dom/media/webaudio/AudioBufferSourceNode.cpp +++ b/dom/media/webaudio/AudioBufferSourceNode.cpp @@ -809,7 +809,10 @@ AudioBufferSourceNode::NotifyMainThreadStreamFinished() { public: explicit EndedEventDispatcher(AudioBufferSourceNode* aNode) - : mNode(aNode) {} + : mozilla::Runnable("EndedEventDispatcher") + , mNode(aNode) + { + } NS_IMETHOD Run() override { // If it's not safe to run scripts right now, schedule this to run later diff --git a/dom/media/webaudio/AudioDestinationNode.cpp b/dom/media/webaudio/AudioDestinationNode.cpp index abe357e3264e..ed55031b238a 100644 --- a/dom/media/webaudio/AudioDestinationNode.cpp +++ b/dom/media/webaudio/AudioDestinationNode.cpp @@ -125,7 +125,8 @@ public: { public: OnCompleteTask(AudioContext* aAudioContext, AudioBuffer* aRenderedBuffer) - : mAudioContext(aAudioContext) + : Runnable("dom::OfflineDestinationNodeEngine::OnCompleteTask") + , mAudioContext(aAudioContext) , mRenderedBuffer(aRenderedBuffer) {} @@ -204,9 +205,9 @@ private: class InputMutedRunnable final : public Runnable { public: - InputMutedRunnable(AudioNodeStream* aStream, - bool aInputMuted) - : mStream(aStream) + InputMutedRunnable(AudioNodeStream* aStream, bool aInputMuted) + : Runnable("dom::InputMutedRunnable") + , mStream(aStream) , mInputMuted(aInputMuted) { } @@ -412,8 +413,10 @@ AudioDestinationNode::NotifyMainThreadStreamFinished() MOZ_ASSERT(mStream->IsFinished()); if (mIsOffline) { - NS_DispatchToCurrentThread(NewRunnableMethod(this, - &AudioDestinationNode::FireOfflineCompletionEvent)); + NS_DispatchToCurrentThread( + NewRunnableMethod("dom::AudioDestinationNode::FireOfflineCompletionEvent", + this, + &AudioDestinationNode::FireOfflineCompletionEvent)); } } diff --git a/dom/media/webaudio/AudioNode.cpp b/dom/media/webaudio/AudioNode.cpp index 068a447ae879..33ad902ee1a3 100644 --- a/dom/media/webaudio/AudioNode.cpp +++ b/dom/media/webaudio/AudioNode.cpp @@ -340,7 +340,10 @@ AudioNode::DisconnectFromOutputIfConnected(uint32_t aOutputNodeIndex, { public: explicit RunnableRelease(already_AddRefed aNode) - : mNode(aNode) {} + : mozilla::Runnable("RunnableRelease") + , mNode(aNode) + { + } NS_IMETHOD Run() override { diff --git a/dom/media/webaudio/ConstantSourceNode.cpp b/dom/media/webaudio/ConstantSourceNode.cpp index b3af764b4ab6..1615233510dc 100644 --- a/dom/media/webaudio/ConstantSourceNode.cpp +++ b/dom/media/webaudio/ConstantSourceNode.cpp @@ -257,7 +257,10 @@ ConstantSourceNode::NotifyMainThreadStreamFinished() { public: explicit EndedEventDispatcher(ConstantSourceNode* aNode) - : mNode(aNode) {} + : mozilla::Runnable("EndedEventDispatcher") + , mNode(aNode) + { + } NS_IMETHOD Run() override { // If it's not safe to run scripts right now, schedule this to run later diff --git a/dom/media/webaudio/DynamicsCompressorNode.cpp b/dom/media/webaudio/DynamicsCompressorNode.cpp index 46e14c79a334..974405ec05f7 100644 --- a/dom/media/webaudio/DynamicsCompressorNode.cpp +++ b/dom/media/webaudio/DynamicsCompressorNode.cpp @@ -148,7 +148,8 @@ private: { public: Command(AudioNodeStream* aStream, float aReduction) - : mStream(aStream) + : mozilla::Runnable("Command") + , mStream(aStream) , mReduction(aReduction) { } diff --git a/dom/media/webaudio/MediaBufferDecoder.cpp b/dom/media/webaudio/MediaBufferDecoder.cpp index c8791dfe470f..4ef2f9328d93 100644 --- a/dom/media/webaudio/MediaBufferDecoder.cpp +++ b/dom/media/webaudio/MediaBufferDecoder.cpp @@ -42,7 +42,8 @@ public: ReportResultTask(WebAudioDecodeJob& aDecodeJob, WebAudioDecodeJob::ResultFn aFunction, WebAudioDecodeJob::ErrorCode aErrorCode) - : mDecodeJob(aDecodeJob) + : Runnable("ReportResultTask") + , mDecodeJob(aDecodeJob) , mFunction(aFunction) , mErrorCode(aErrorCode) { @@ -78,10 +79,12 @@ enum class PhaseEnum : int class MediaDecodeTask final : public Runnable { public: - MediaDecodeTask(const MediaContainerType& aContainerType, uint8_t* aBuffer, + MediaDecodeTask(const MediaContainerType& aContainerType, + uint8_t* aBuffer, uint32_t aLength, WebAudioDecodeJob& aDecodeJob) - : mContainerType(aContainerType) + : Runnable("MediaDecodeTask") + , mContainerType(aContainerType) , mBuffer(aBuffer) , mLength(aLength) , mDecodeJob(aDecodeJob) @@ -103,8 +106,8 @@ private: mDecodeJob.OnFailure(aErrorCode); } else { // Take extra care to cleanup on the main thread - mMainThread->Dispatch(NewRunnableMethod(this, &MediaDecodeTask::Cleanup)); - + mMainThread->Dispatch(NewRunnableMethod( + "MediaDecodeTask::Cleanup", this, &MediaDecodeTask::Cleanup)); nsCOMPtr event = new ReportResultTask(mDecodeJob, &WebAudioDecodeJob::OnFailure, aErrorCode); @@ -266,13 +269,14 @@ MediaDecodeTask::OnMetadataRead(MetadataHolder&& aMetadata) mContainerType.Type().AsString().Data()); } - nsCOMPtr task = NS_NewRunnableFunction([codec]() -> void { - MOZ_ASSERT(!codec.IsEmpty()); - MOZ_LOG(gMediaDecoderLog, - LogLevel::Debug, - ("Telemetry (WebAudio) MEDIA_CODEC_USED= '%s'", codec.get())); - Telemetry::Accumulate(Telemetry::HistogramID::MEDIA_CODEC_USED, codec); - }); + nsCOMPtr task = NS_NewRunnableFunction( + "MediaDecodeTask::OnMetadataRead", [codec]() -> void { + MOZ_ASSERT(!codec.IsEmpty()); + MOZ_LOG(gMediaDecoderLog, + LogLevel::Debug, + ("Telemetry (WebAudio) MEDIA_CODEC_USED= '%s'", codec.get())); + Telemetry::Accumulate(Telemetry::HistogramID::MEDIA_CODEC_USED, codec); + }); SystemGroup::Dispatch("MediaDecodeTask::OnMetadataRead()::report_telemetry", TaskCategory::Other, task.forget()); diff --git a/dom/media/webaudio/OscillatorNode.cpp b/dom/media/webaudio/OscillatorNode.cpp index 7bc61fe62a2e..66485092d756 100644 --- a/dom/media/webaudio/OscillatorNode.cpp +++ b/dom/media/webaudio/OscillatorNode.cpp @@ -580,7 +580,10 @@ OscillatorNode::NotifyMainThreadStreamFinished() { public: explicit EndedEventDispatcher(OscillatorNode* aNode) - : mNode(aNode) {} + : mozilla::Runnable("EndedEventDispatcher") + , mNode(aNode) + { + } NS_IMETHOD Run() override { // If it's not safe to run scripts right now, schedule this to run later diff --git a/dom/media/webaudio/PlayingRefChangeHandler.h b/dom/media/webaudio/PlayingRefChangeHandler.h index 6436d1dbc304..6a832c243a81 100644 --- a/dom/media/webaudio/PlayingRefChangeHandler.h +++ b/dom/media/webaudio/PlayingRefChangeHandler.h @@ -18,7 +18,8 @@ class PlayingRefChangeHandler final : public Runnable public: enum ChangeType { ADDREF, RELEASE }; PlayingRefChangeHandler(AudioNodeStream* aStream, ChangeType aChange) - : mStream(aStream) + : Runnable("dom::PlayingRefChangeHandler") + , mStream(aStream) , mChange(aChange) { } diff --git a/dom/media/webaudio/ScriptProcessorNode.cpp b/dom/media/webaudio/ScriptProcessorNode.cpp index 41a3c99930ae..a3a8370d5e42 100644 --- a/dom/media/webaudio/ScriptProcessorNode.cpp +++ b/dom/media/webaudio/ScriptProcessorNode.cpp @@ -375,7 +375,8 @@ private: Command(AudioNodeStream* aStream, already_AddRefed aInputBuffer, double aPlaybackTime) - : mStream(aStream) + : mozilla::Runnable("Command") + , mStream(aStream) , mInputBuffer(aInputBuffer) , mPlaybackTime(aPlaybackTime) { diff --git a/dom/media/webaudio/WebAudioUtils.cpp b/dom/media/webaudio/WebAudioUtils.cpp index 6289f803b3c2..9bf3465b642b 100644 --- a/dom/media/webaudio/WebAudioUtils.cpp +++ b/dom/media/webaudio/WebAudioUtils.cpp @@ -101,8 +101,9 @@ WebAudioUtils::LogToDeveloperConsole(uint64_t aWindowID, const char* aKey) // It is similar to ContentUtils::ReportToConsole, but also works off main // thread. if (!NS_IsMainThread()) { - nsCOMPtr task = - NS_NewRunnableFunction([aWindowID, aKey]() { LogToDeveloperConsole(aWindowID, aKey); }); + nsCOMPtr task = NS_NewRunnableFunction( + "dom::WebAudioUtils::LogToDeveloperConsole", + [aWindowID, aKey]() { LogToDeveloperConsole(aWindowID, aKey); }); NS_DispatchToMainThread(task.forget(), NS_DISPATCH_NORMAL); return; } diff --git a/dom/media/webaudio/blink/HRTFDatabaseLoader.cpp b/dom/media/webaudio/blink/HRTFDatabaseLoader.cpp index b4aee7b484b4..9ad7e9b65e81 100644 --- a/dom/media/webaudio/blink/HRTFDatabaseLoader.cpp +++ b/dom/media/webaudio/blink/HRTFDatabaseLoader.cpp @@ -111,11 +111,15 @@ size_t HRTFDatabaseLoader::sizeOfIncludingThis(mozilla::MallocSizeOf aMallocSize class HRTFDatabaseLoader::ProxyReleaseEvent final : public Runnable { public: - explicit ProxyReleaseEvent(HRTFDatabaseLoader* loader) : mLoader(loader) {} - NS_IMETHOD Run() override - { - mLoader->MainThreadRelease(); - return NS_OK; + explicit ProxyReleaseEvent(HRTFDatabaseLoader* loader) + : mozilla::Runnable("WebCore::HRTFDatabaseLoader::ProxyReleaseEvent") + , mLoader(loader) + { + } + NS_IMETHOD Run() override + { + mLoader->MainThreadRelease(); + return NS_OK; } private: HRTFDatabaseLoader* mLoader; diff --git a/dom/media/webaudio/blink/ReverbConvolver.cpp b/dom/media/webaudio/blink/ReverbConvolver.cpp index e739400aee35..988209fa6c73 100644 --- a/dom/media/webaudio/blink/ReverbConvolver.cpp +++ b/dom/media/webaudio/blink/ReverbConvolver.cpp @@ -151,8 +151,10 @@ ReverbConvolver::ReverbConvolver(const float* impulseResponseData, NS_WARNING("Cannot start convolver thread."); return; } - m_backgroundThread.message_loop()->PostTask(NewNonOwningRunnableMethod(this, - &ReverbConvolver::backgroundThreadEntry)); + m_backgroundThread.message_loop()->PostTask(NewNonOwningRunnableMethod( + "WebCore::ReverbConvolver::backgroundThreadEntry", + this, + &ReverbConvolver::backgroundThreadEntry)); } } diff --git a/dom/media/webrtc/MediaEngineTabVideoSource.h b/dom/media/webrtc/MediaEngineTabVideoSource.h index afd65f48c825..16a4574259c0 100644 --- a/dom/media/webrtc/MediaEngineTabVideoSource.h +++ b/dom/media/webrtc/MediaEngineTabVideoSource.h @@ -62,28 +62,40 @@ class MediaEngineTabVideoSource : public MediaEngineVideoSource, nsIDOMEventList class StartRunnable : public Runnable { public: - explicit StartRunnable(MediaEngineTabVideoSource *videoSource) : mVideoSource(videoSource) {} + explicit StartRunnable(MediaEngineTabVideoSource *videoSource) + : Runnable("MediaEngineTabVideoSource::StartRunnable") + , mVideoSource(videoSource) + {} NS_IMETHOD Run(); RefPtr mVideoSource; }; class StopRunnable : public Runnable { public: - explicit StopRunnable(MediaEngineTabVideoSource *videoSource) : mVideoSource(videoSource) {} + explicit StopRunnable(MediaEngineTabVideoSource *videoSource) + : Runnable("MediaEngineTabVideoSource::StopRunnable") + , mVideoSource(videoSource) + {} NS_IMETHOD Run(); RefPtr mVideoSource; }; class InitRunnable : public Runnable { public: - explicit InitRunnable(MediaEngineTabVideoSource *videoSource) : mVideoSource(videoSource) {} + explicit InitRunnable(MediaEngineTabVideoSource *videoSource) + : Runnable("MediaEngineTabVideoSource::InitRunnable") + , mVideoSource(videoSource) + {} NS_IMETHOD Run(); RefPtr mVideoSource; }; class DestroyRunnable : public Runnable { public: - explicit DestroyRunnable(MediaEngineTabVideoSource* videoSource) : mVideoSource(videoSource) {} + explicit DestroyRunnable(MediaEngineTabVideoSource* videoSource) + : Runnable("MediaEngineTabVideoSource::DestroyRunnable") + , mVideoSource(videoSource) + {} NS_IMETHOD Run(); RefPtr mVideoSource; }; diff --git a/dom/media/webspeech/recognition/SpeechRecognition.h b/dom/media/webspeech/recognition/SpeechRecognition.h index 08866041a8ac..806d4a8d6f7d 100644 --- a/dom/media/webspeech/recognition/SpeechRecognition.h +++ b/dom/media/webspeech/recognition/SpeechRecognition.h @@ -257,13 +257,15 @@ private: class SpeechEvent : public Runnable { public: - SpeechEvent(SpeechRecognition* aRecognition, SpeechRecognition::EventType aType) - : mAudioSegment(0) - , mRecognitionResultList(nullptr) - , mError(nullptr) - , mRecognition(aRecognition) - , mType(aType) - , mTrackRate(0) + SpeechEvent(SpeechRecognition* aRecognition, + SpeechRecognition::EventType aType) + : Runnable("dom::SpeechEvent") + , mAudioSegment(0) + , mRecognitionResultList(nullptr) + , mError(nullptr) + , mRecognition(aRecognition) + , mType(aType) + , mTrackRate(0) { } diff --git a/dom/media/webspeech/synth/cocoa/OSXSpeechSynthesizerService.mm b/dom/media/webspeech/synth/cocoa/OSXSpeechSynthesizerService.mm index 557c1e945211..78e16be1a2be 100644 --- a/dom/media/webspeech/synth/cocoa/OSXSpeechSynthesizerService.mm +++ b/dom/media/webspeech/synth/cocoa/OSXSpeechSynthesizerService.mm @@ -224,7 +224,8 @@ class RegisterVoicesRunnable final : public Runnable public: RegisterVoicesRunnable(OSXSpeechSynthesizerService* aSpeechService, nsTArray& aList) - : mSpeechService(aSpeechService) + : Runnable("RegisterVoicesRunnable") + , mSpeechService(aSpeechService) , mVoices(aList) { } @@ -269,7 +270,8 @@ class EnumVoicesRunnable final : public Runnable { public: explicit EnumVoicesRunnable(OSXSpeechSynthesizerService* aSpeechService) - : mSpeechService(aSpeechService) + : Runnable("EnumVoicesRunnable") + , mSpeechService(aSpeechService) { } diff --git a/dom/media/webspeech/synth/nsSpeechTask.cpp b/dom/media/webspeech/synth/nsSpeechTask.cpp index 8c02ff95192f..4c6204edea49 100644 --- a/dom/media/webspeech/synth/nsSpeechTask.cpp +++ b/dom/media/webspeech/synth/nsSpeechTask.cpp @@ -66,12 +66,16 @@ public: mStarted = true; aGraph->DispatchToMainThreadAfterStreamStateUpdate( mAbstractMainThread, - NewRunnableMethod(this, &SynthStreamListener::DoNotifyStarted)); + NewRunnableMethod("dom::SynthStreamListener::DoNotifyStarted", + this, + &SynthStreamListener::DoNotifyStarted)); } aGraph->DispatchToMainThreadAfterStreamStateUpdate( mAbstractMainThread, - NewRunnableMethod(this, &SynthStreamListener::DoNotifyFinished)); + NewRunnableMethod("dom::SynthStreamListener::DoNotifyFinished", + this, + &SynthStreamListener::DoNotifyFinished)); } break; case MediaStreamGraphEvent::EVENT_REMOVED: @@ -90,7 +94,9 @@ public: mStarted = true; aGraph->DispatchToMainThreadAfterStreamStateUpdate( mAbstractMainThread, - NewRunnableMethod(this, &SynthStreamListener::DoNotifyStarted)); + NewRunnableMethod("dom::SynthStreamListener::DoNotifyStarted", + this, + &SynthStreamListener::DoNotifyStarted)); } } diff --git a/dom/media/webspeech/synth/pico/nsPicoService.cpp b/dom/media/webspeech/synth/pico/nsPicoService.cpp index c3cf812fcc45..559a0232d7be 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( - NewRunnableMethod(this, &nsPicoService::Init), NS_DISPATCH_NORMAL); + NewRunnableMethod("nsPicoService::Init", this, &nsPicoService::Init), NS_DISPATCH_NORMAL); } // nsISpeechService @@ -579,7 +579,8 @@ nsPicoService::Init() rv = dirIterator->HasMoreElements(&hasMoreElements); } - NS_DispatchToMainThread(NewRunnableMethod(this, &nsPicoService::RegisterVoices)); + NS_DispatchToMainThread(NewRunnableMethod("nsPicoService::RegisterVoices", + this, &nsPicoService::RegisterVoices)); } void diff --git a/dom/media/webspeech/synth/speechd/SpeechDispatcherService.cpp b/dom/media/webspeech/synth/speechd/SpeechDispatcherService.cpp index 77a8f7cd9394..ecfbd25c9caa 100644 --- a/dom/media/webspeech/synth/speechd/SpeechDispatcherService.cpp +++ b/dom/media/webspeech/synth/speechd/SpeechDispatcherService.cpp @@ -273,10 +273,12 @@ speechd_cb(size_t msg_id, size_t client_id, SPDNotificationType state) SpeechDispatcherService* service = SpeechDispatcherService::GetInstance(false); if (service) { - NS_DispatchToMainThread( - NewRunnableMethod( - service, &SpeechDispatcherService::EventNotify, - static_cast(msg_id), state)); + NS_DispatchToMainThread(NewRunnableMethod( + "dom::SpeechDispatcherService::EventNotify", + service, + &SpeechDispatcherService::EventNotify, + static_cast(msg_id), + state)); } } @@ -311,7 +313,10 @@ SpeechDispatcherService::Init() getter_AddRefs(mInitThread)); MOZ_ASSERT(NS_SUCCEEDED(rv)); rv = mInitThread->Dispatch( - NewRunnableMethod(this, &SpeechDispatcherService::Setup), NS_DISPATCH_NORMAL); + NewRunnableMethod("dom::SpeechDispatcherService::Setup", + this, + &SpeechDispatcherService::Setup), + NS_DISPATCH_NORMAL); MOZ_ASSERT(NS_SUCCEEDED(rv)); } @@ -419,7 +424,10 @@ SpeechDispatcherService::Setup() } } - NS_DispatchToMainThread(NewRunnableMethod(this, &SpeechDispatcherService::RegisterVoices)); + NS_DispatchToMainThread( + NewRunnableMethod("dom::SpeechDispatcherService::RegisterVoices", + this, + &SpeechDispatcherService::RegisterVoices)); //mInitialized = true; } @@ -526,10 +534,16 @@ SpeechDispatcherService::Speak(const nsAString& aText, const nsAString& aUri, // In that case, don't send empty string to speechd, // and just emulate a speechd start and end event. NS_DispatchToMainThread(NewRunnableMethod( - callback, &SpeechDispatcherCallback::OnSpeechEvent, SPD_EVENT_BEGIN)); + "dom::SpeechDispatcherCallback::OnSpeechEvent", + callback, + &SpeechDispatcherCallback::OnSpeechEvent, + SPD_EVENT_BEGIN)); NS_DispatchToMainThread(NewRunnableMethod( - callback, &SpeechDispatcherCallback::OnSpeechEvent, SPD_EVENT_END)); + "dom::SpeechDispatcherCallback::OnSpeechEvent", + callback, + &SpeechDispatcherCallback::OnSpeechEvent, + SPD_EVENT_END)); } return NS_OK; diff --git a/dom/media/webspeech/synth/test/nsFakeSynthServices.cpp b/dom/media/webspeech/synth/test/nsFakeSynthServices.cpp index 582ff35510af..ed3e1402e5f4 100644 --- a/dom/media/webspeech/synth/test/nsFakeSynthServices.cpp +++ b/dom/media/webspeech/synth/test/nsFakeSynthServices.cpp @@ -141,8 +141,10 @@ FakeDirectAudioSynth::Speak(const nsAString& aText, const nsAString& aUri, class Runnable final : public mozilla::Runnable { public: - Runnable(nsISpeechTask* aTask, const nsAString& aText) : - mTask(aTask), mText(aText) + Runnable(nsISpeechTask* aTask, const nsAString& aText) + : mozilla::Runnable("Runnable") + , mTask(aTask) + , mText(aText) { } @@ -204,8 +206,9 @@ FakeIndirectAudioSynth::Speak(const nsAString& aText, const nsAString& aUri, class DispatchStart final : public Runnable { public: - explicit DispatchStart(nsISpeechTask* aTask) : - mTask(aTask) + explicit DispatchStart(nsISpeechTask* aTask) + : mozilla::Runnable("DispatchStart") + , mTask(aTask) { } @@ -223,8 +226,10 @@ FakeIndirectAudioSynth::Speak(const nsAString& aText, const nsAString& aUri, class DispatchEnd final : public Runnable { public: - DispatchEnd(nsISpeechTask* aTask, const nsAString& aText) : - mTask(aTask), mText(aText) + DispatchEnd(nsISpeechTask* aTask, const nsAString& aText) + : mozilla::Runnable("DispatchEnd") + , mTask(aTask) + , mText(aText) { } @@ -243,8 +248,10 @@ FakeIndirectAudioSynth::Speak(const nsAString& aText, const nsAString& aUri, class DispatchError final : public Runnable { public: - DispatchError(nsISpeechTask* aTask, const nsAString& aText) : - mTask(aTask), mText(aText) + DispatchError(nsISpeechTask* aTask, const nsAString& aText) + : mozilla::Runnable("DispatchError") + , mTask(aTask) + , mText(aText) { } @@ -356,7 +363,8 @@ nsFakeSynthServices::Observe(nsISupports* aSubject, const char* aTopic, } if (Preferences::GetBool("media.webspeech.synth.test")) { - NS_DispatchToMainThread(NewRunnableMethod(this, &nsFakeSynthServices::Init)); + NS_DispatchToMainThread(NewRunnableMethod( + "dom::nsFakeSynthServices::Init", this, &nsFakeSynthServices::Init)); } return NS_OK; diff --git a/dom/messagechannel/MessagePort.cpp b/dom/messagechannel/MessagePort.cpp index 37d77b5f1b83..0aa457883437 100644 --- a/dom/messagechannel/MessagePort.cpp +++ b/dom/messagechannel/MessagePort.cpp @@ -53,7 +53,8 @@ class PostMessageRunnable final : public CancelableRunnable public: PostMessageRunnable(MessagePort* aPort, SharedMessagePortMessage* aData) - : mPort(aPort) + : CancelableRunnable("dom::PostMessageRunnable") + , mPort(aPort) , mData(aData) { MOZ_ASSERT(aPort); diff --git a/dom/network/UDPSocket.cpp b/dom/network/UDPSocket.cpp index e460428c7120..dbb8f25fe5e9 100644 --- a/dom/network/UDPSocket.cpp +++ b/dom/network/UDPSocket.cpp @@ -551,7 +551,9 @@ UDPSocket::Init(const nsString& aLocalAddress, class OpenSocketRunnable final : public Runnable { public: - explicit OpenSocketRunnable(UDPSocket* aSocket) : mSocket(aSocket) + explicit OpenSocketRunnable(UDPSocket* aSocket) + : mozilla::Runnable("OpenSocketRunnable") + , mSocket(aSocket) { } NS_IMETHOD Run() override diff --git a/dom/notification/DesktopNotification.cpp b/dom/notification/DesktopNotification.cpp index 76f1c5afb030..f3a59e36feb4 100644 --- a/dom/notification/DesktopNotification.cpp +++ b/dom/notification/DesktopNotification.cpp @@ -37,7 +37,8 @@ public: NS_DECL_NSICONTENTPERMISSIONREQUEST explicit DesktopNotificationRequest(DesktopNotification* aNotification) - : mDesktopNotification(aNotification) + : Runnable("dom::DesktopNotificationRequest") + , mDesktopNotification(aNotification) { mRequester = new nsContentPermissionRequester(mDesktopNotification->GetOwner()); } diff --git a/dom/payments/ipc/PaymentRequestParent.cpp b/dom/payments/ipc/PaymentRequestParent.cpp index b2fb89d2b33c..3bf215a284a2 100644 --- a/dom/payments/ipc/PaymentRequestParent.cpp +++ b/dom/payments/ipc/PaymentRequestParent.cpp @@ -149,7 +149,8 @@ PaymentRequestParent::RespondPayment(nsIPaymentActionResponse* aResponse) nsCOMPtr self = do_QueryInterface(this); MOZ_ASSERT(self); nsCOMPtr response = aResponse; - nsCOMPtr r = NS_NewRunnableFunction([self, response] () + nsCOMPtr r = NS_NewRunnableFunction("PaymentRequestParent::RespondPayment", + [self, response] () { self->RespondPayment(response); }); diff --git a/dom/performance/Performance.cpp b/dom/performance/Performance.cpp index 95bfe933af9a..a835b92b8e9d 100644 --- a/dom/performance/Performance.cpp +++ b/dom/performance/Performance.cpp @@ -516,7 +516,8 @@ class NotifyObserversTask final : public CancelableRunnable { public: explicit NotifyObserversTask(Performance* aPerformance) - : mPerformance(aPerformance) + : CancelableRunnable("dom::NotifyObserversTask") + , mPerformance(aPerformance) { MOZ_ASSERT(mPerformance); } diff --git a/dom/plugins/base/nsNPAPIPluginInstance.cpp b/dom/plugins/base/nsNPAPIPluginInstance.cpp index 00223651cb9d..1dc92619b926 100644 --- a/dom/plugins/base/nsNPAPIPluginInstance.cpp +++ b/dom/plugins/base/nsNPAPIPluginInstance.cpp @@ -887,7 +887,8 @@ java::GeckoSurface::LocalRef nsNPAPIPluginInstance::CreateSurface() return nullptr; } - nsCOMPtr frameCallback = NewRunnableMethod(this, &nsNPAPIPluginInstance::OnSurfaceTextureFrameAvailable); + nsCOMPtr frameCallback = NewRunnableMethod("nsNPAPIPluginInstance::OnSurfaceTextureFrameAvailable", + this, &nsNPAPIPluginInstance::OnSurfaceTextureFrameAvailable); java::SurfaceTextureListener::LocalRef listener = java::SurfaceTextureListener::New(); @@ -1447,7 +1448,11 @@ nsNPAPIPluginInstance::ScheduleTimer(uint32_t interval, NPBool repeat, void (*ti return 0; } const short timerType = (repeat ? (short)nsITimer::TYPE_REPEATING_SLACK : (short)nsITimer::TYPE_ONE_SHOT); - xpcomTimer->InitWithFuncCallback(PluginTimerCallback, newTimer, interval, timerType); + xpcomTimer->InitWithNamedFuncCallback(PluginTimerCallback, + newTimer, + interval, + timerType, + "nsNPAPIPluginInstance::ScheduleTimer"); newTimer->timer = xpcomTimer; // save callback function diff --git a/dom/plugins/ipc/ChildAsyncCall.cpp b/dom/plugins/ipc/ChildAsyncCall.cpp index 6adc05d55998..ded84607df71 100644 --- a/dom/plugins/ipc/ChildAsyncCall.cpp +++ b/dom/plugins/ipc/ChildAsyncCall.cpp @@ -12,8 +12,10 @@ namespace mozilla { namespace plugins { ChildAsyncCall::ChildAsyncCall(PluginInstanceChild* instance, - PluginThreadCallback aFunc, void* aUserData) - : mInstance(instance) + PluginThreadCallback aFunc, + void* aUserData) + : CancelableRunnable("plugins::ChildAsyncCall") + , mInstance(instance) , mFunc(aFunc) , mData(aUserData) { diff --git a/dom/plugins/ipc/PluginInstanceChild.cpp b/dom/plugins/ipc/PluginInstanceChild.cpp index 21b2c1dbf8dc..770fdd2f3e5c 100644 --- a/dom/plugins/ipc/PluginInstanceChild.cpp +++ b/dom/plugins/ipc/PluginInstanceChild.cpp @@ -3020,8 +3020,15 @@ PluginInstanceChild::RecvAsyncSetWindow(const gfxSurfaceType& aSurfaceType, // RPC call, and both Flash and Java don't expect to receive setwindow calls // at arbitrary times. mCurrentAsyncSetWindowTask = - NewNonOwningCancelableRunnableMethod - (this, &PluginInstanceChild::DoAsyncSetWindow, aSurfaceType, aWindow, true); + NewNonOwningCancelableRunnableMethod( + "plugins::PluginInstanceChild::DoAsyncSetWindow", + this, + &PluginInstanceChild::DoAsyncSetWindow, + aSurfaceType, + aWindow, + true); RefPtr addrefedTask = mCurrentAsyncSetWindowTask; MessageLoop::current()->PostTask(addrefedTask.forget()); @@ -3947,8 +3954,10 @@ PluginInstanceChild::AsyncShowPluginFrame(void) return; } - mCurrentInvalidateTask = - NewNonOwningCancelableRunnableMethod(this, &PluginInstanceChild::InvalidateRectDelayed); + mCurrentInvalidateTask = NewNonOwningCancelableRunnableMethod( + "plugins::PluginInstanceChild::InvalidateRectDelayed", + this, + &PluginInstanceChild::InvalidateRectDelayed); RefPtr addrefedTask = mCurrentInvalidateTask; MessageLoop::current()->PostTask(addrefedTask.forget()); } diff --git a/dom/plugins/ipc/PluginProcessParent.cpp b/dom/plugins/ipc/PluginProcessParent.cpp index 14d1f50b9dc1..4a24abc802f5 100644 --- a/dom/plugins/ipc/PluginProcessParent.cpp +++ b/dom/plugins/ipc/PluginProcessParent.cpp @@ -124,7 +124,10 @@ PluginProcessParent::Delete() return; } - ioLoop->PostTask(NewNonOwningRunnableMethod(this, &PluginProcessParent::Delete)); + ioLoop->PostTask( + NewNonOwningRunnableMethod("plugins::PluginProcessParent::Delete", + this, + &PluginProcessParent::Delete)); } void diff --git a/dom/plugins/ipc/PluginProcessParent.h b/dom/plugins/ipc/PluginProcessParent.h index 2644c60a32b7..89f1675627b4 100644 --- a/dom/plugins/ipc/PluginProcessParent.h +++ b/dom/plugins/ipc/PluginProcessParent.h @@ -27,9 +27,10 @@ namespace plugins { class LaunchCompleteTask : public Runnable { public: - LaunchCompleteTask() - : mLaunchSucceeded(false) - { + LaunchCompleteTask() + : Runnable("plugins::LaunchCompleteTask") + , mLaunchSucceeded(false) + { } void SetLaunchSucceeded() { mLaunchSucceeded = true; } diff --git a/dom/presentation/PresentationAvailability.cpp b/dom/presentation/PresentationAvailability.cpp index 93f27dfbfc5c..e6c1e094433c 100644 --- a/dom/presentation/PresentationAvailability.cpp +++ b/dom/presentation/PresentationAvailability.cpp @@ -172,10 +172,11 @@ PresentationAvailability::NotifyAvailableChange(const nsTArray& aAvail available |= mAvailabilityOfUrl[i]; } - return NS_DispatchToCurrentThread(NewRunnableMethod - (this, - &PresentationAvailability::UpdateAvailabilityAndDispatchEvent, - available)); + return NS_DispatchToCurrentThread(NewRunnableMethod( + "dom::PresentationAvailability::UpdateAvailabilityAndDispatchEvent", + this, + &PresentationAvailability::UpdateAvailabilityAndDispatchEvent, + available)); } void diff --git a/dom/presentation/PresentationCallbacks.cpp b/dom/presentation/PresentationCallbacks.cpp index fd0ffee31cae..16813f757614 100644 --- a/dom/presentation/PresentationCallbacks.cpp +++ b/dom/presentation/PresentationCallbacks.cpp @@ -137,11 +137,12 @@ PresentationReconnectCallback::NotifySuccess(const nsAString& aUrl) } nsString sessionId = nsString(mSessionId); - return NS_DispatchToMainThread( - NS_NewRunnableFunction([sessionId, service]() -> void { - service->BuildTransport(sessionId, - nsIPresentationService::ROLE_CONTROLLER); - })); + return NS_DispatchToMainThread(NS_NewRunnableFunction( + "dom::PresentationReconnectCallback::NotifySuccess", + [sessionId, service]() -> void { + service->BuildTransport(sessionId, + nsIPresentationService::ROLE_CONTROLLER); + })); } NS_IMETHODIMP diff --git a/dom/presentation/PresentationConnection.cpp b/dom/presentation/PresentationConnection.cpp index f36b506d1e97..b7b6504bffb2 100644 --- a/dom/presentation/PresentationConnection.cpp +++ b/dom/presentation/PresentationConnection.cpp @@ -641,7 +641,9 @@ NS_IMETHODIMP PresentationConnection::Cancel(nsresult aStatus) { nsCOMPtr event = - NewRunnableMethod(this, &PresentationConnection::ProcessConnectionWentAway); + NewRunnableMethod("dom::PresentationConnection::ProcessConnectionWentAway", + this, + &PresentationConnection::ProcessConnectionWentAway); return NS_DispatchToCurrentThread(event); } NS_IMETHODIMP @@ -736,8 +738,9 @@ PresentationConnection::AsyncCloseConnectionWithErrorMsg(const nsAString& aMessa nsString message = nsString(aMessage); RefPtr self = this; - nsCOMPtr r = - NS_NewRunnableFunction([self, message]() -> void { + nsCOMPtr r = NS_NewRunnableFunction( + "dom::PresentationConnection::AsyncCloseConnectionWithErrorMsg", + [self, message]() -> void { // Set |mState| to |PresentationConnectionState::Closed| here to avoid // calling |ProcessStateChanged|. self->mState = PresentationConnectionState::Closed; diff --git a/dom/presentation/PresentationDeviceManager.cpp b/dom/presentation/PresentationDeviceManager.cpp index 7e5a4700c898..a1a76276c7c8 100644 --- a/dom/presentation/PresentationDeviceManager.cpp +++ b/dom/presentation/PresentationDeviceManager.cpp @@ -157,7 +157,9 @@ PresentationDeviceManager::GetAvailableDevices(nsIArray* aPresentationUrls, nsIA // Bug 1194049: some providers may discontinue discovery after timeout. // Call |ForceDiscovery()| here to make sure device lists are updated. NS_DispatchToMainThread( - NewRunnableMethod(this, &PresentationDeviceManager::ForceDiscovery)); + NewRunnableMethod("dom::PresentationDeviceManager::ForceDiscovery", + this, + &PresentationDeviceManager::ForceDiscovery)); nsTArray presentationUrls; if (aPresentationUrls) { diff --git a/dom/presentation/PresentationReceiver.cpp b/dom/presentation/PresentationReceiver.cpp index 738b3758b801..0b9aaa40cc82 100644 --- a/dom/presentation/PresentationReceiver.cpp +++ b/dom/presentation/PresentationReceiver.cpp @@ -135,10 +135,9 @@ PresentationReceiver::GetConnectionList(ErrorResult& aRv) } RefPtr self = this; - nsresult rv = - NS_DispatchToMainThread(NS_NewRunnableFunction([self] () -> void { - self->CreateConnectionList(); - })); + nsresult rv = NS_DispatchToMainThread(NS_NewRunnableFunction( + "dom::PresentationReceiver::GetConnectionList", + [self]() -> void { self->CreateConnectionList(); })); if (NS_FAILED(rv)) { aRv.Throw(rv); return nullptr; diff --git a/dom/presentation/PresentationRequest.cpp b/dom/presentation/PresentationRequest.cpp index b5820221c0f9..2a7d7705b19a 100644 --- a/dom/presentation/PresentationRequest.cpp +++ b/dom/presentation/PresentationRequest.cpp @@ -281,12 +281,12 @@ PresentationRequest::Reconnect(const nsAString& aPresentationId, } nsString presentationId = nsString(aPresentationId); - nsCOMPtr r = - NewRunnableMethod>( - this, - &PresentationRequest::FindOrCreatePresentationConnection, - presentationId, - promise); + nsCOMPtr r = NewRunnableMethod>( + "dom::PresentationRequest::FindOrCreatePresentationConnection", + this, + &PresentationRequest::FindOrCreatePresentationConnection, + presentationId, + promise); if (NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(r)))) { promise->MaybeReject(NS_ERROR_DOM_OPERATION_ERR); diff --git a/dom/presentation/PresentationService.cpp b/dom/presentation/PresentationService.cpp index 34030cfdb813..6a3751ab768a 100644 --- a/dom/presentation/PresentationService.cpp +++ b/dom/presentation/PresentationService.cpp @@ -1119,13 +1119,14 @@ PresentationService::UntrackSessionInfo(const nsAString& aSessionId, uint64_t windowId; nsresult rv = GetWindowIdBySessionIdInternal(aSessionId, aRole, &windowId); if (NS_SUCCEEDED(rv)) { - NS_DispatchToMainThread(NS_NewRunnableFunction([windowId]() -> void { - PRES_DEBUG("Attempt to close window[%" PRIu64 "]\n", windowId); + NS_DispatchToMainThread(NS_NewRunnableFunction( + "dom::PresentationService::UntrackSessionInfo", [windowId]() -> void { + PRES_DEBUG("Attempt to close window[%" PRIu64 "]\n", windowId); - if (auto* window = nsGlobalWindow::GetInnerWindowWithId(windowId)) { - window->Close(); - } - })); + if (auto* window = nsGlobalWindow::GetInnerWindowWithId(windowId)) { + window->Close(); + } + })); } mSessionInfoAtReceiver.Remove(aSessionId); diff --git a/dom/presentation/PresentationSessionInfo.cpp b/dom/presentation/PresentationSessionInfo.cpp index 8208d073ce09..88dac827ac14 100644 --- a/dom/presentation/PresentationSessionInfo.cpp +++ b/dom/presentation/PresentationSessionInfo.cpp @@ -111,7 +111,8 @@ PresentationNetworkHelper::OnGetWifiIPAddress(const nsACString& aIPAddress) MOZ_ASSERT(mFunc); NS_DispatchToMainThread( - NewRunnableMethod(mInfo, + NewRunnableMethod("dom::PresentationNetworkHelper::OnGetWifiIPAddress", + mInfo, mFunc, aIPAddress)); return NS_OK; @@ -684,6 +685,7 @@ PresentationControllingInfo::GetAddress() // into main thread instead of calling it directly. NS_DispatchToMainThread( NewRunnableMethod( + "dom::PresentationControllingInfo::OnGetAddress", this, &PresentationControllingInfo::OnGetAddress, NS_ConvertUTF16toUTF8(ip))); @@ -1109,11 +1111,11 @@ PresentationControllingInfo::OnListedNetworkAddresses(const char** aAddressArray // On Firefox desktop, the IP address is retrieved from a callback function. // To make consistent code sequence, following function call is dispatched // into main thread instead of calling it directly. - NS_DispatchToMainThread( - NewRunnableMethod( - this, - &PresentationControllingInfo::OnGetAddress, - ip)); + NS_DispatchToMainThread(NewRunnableMethod( + "dom::PresentationControllingInfo::OnGetAddress", + this, + &PresentationControllingInfo::OnGetAddress, + ip)); return NS_OK; } @@ -1125,11 +1127,11 @@ PresentationControllingInfo::OnListNetworkAddressesFailed() // In 1-UA case, transport channel can still be established // on loopback interface even if no network address available. - NS_DispatchToMainThread( - NewRunnableMethod( - this, - &PresentationControllingInfo::OnGetAddress, - "127.0.0.1")); + NS_DispatchToMainThread(NewRunnableMethod( + "dom::PresentationControllingInfo::OnGetAddress", + this, + &PresentationControllingInfo::OnGetAddress, + "127.0.0.1")); return NS_OK; } diff --git a/dom/presentation/PresentationTCPSessionTransport.cpp b/dom/presentation/PresentationTCPSessionTransport.cpp index 3af39e6e4232..103d388cddeb 100644 --- a/dom/presentation/PresentationTCPSessionTransport.cpp +++ b/dom/presentation/PresentationTCPSessionTransport.cpp @@ -112,17 +112,19 @@ PresentationTCPSessionTransport::BuildTCPSenderTransport(nsISocketTransport* aTr nsCOMPtr sessionTransport = do_QueryObject(this); nsCOMPtr onSessionTransportRunnable = - NewRunnableMethod - (mListener, - &nsIPresentationSessionTransportBuilderListener::OnSessionTransport, - sessionTransport); + NewRunnableMethod( + "nsIPresentationSessionTransportBuilderListener::OnSessionTransport", + mListener, + &nsIPresentationSessionTransportBuilderListener::OnSessionTransport, + sessionTransport); NS_DispatchToCurrentThread(onSessionTransportRunnable.forget()); - nsCOMPtr setReadyStateRunnable = - NewRunnableMethod(this, - &PresentationTCPSessionTransport::SetReadyState, - ReadyState::OPEN); + nsCOMPtr setReadyStateRunnable = NewRunnableMethod( + "dom::PresentationTCPSessionTransport::SetReadyState", + this, + &PresentationTCPSessionTransport::SetReadyState, + ReadyState::OPEN); return NS_DispatchToCurrentThread(setReadyStateRunnable.forget()); } @@ -192,10 +194,11 @@ PresentationTCPSessionTransport::BuildTCPReceiverTransport(nsIPresentationChanne nsCOMPtr sessionTransport = do_QueryObject(this); nsCOMPtr runnable = - NewRunnableMethod - (mListener, - &nsIPresentationSessionTransportBuilderListener::OnSessionTransport, - sessionTransport); + NewRunnableMethod( + "nsIPresentationSessionTransportBuilderListener::OnSessionTransport", + mListener, + &nsIPresentationSessionTransportBuilderListener::OnSessionTransport, + sessionTransport); return NS_DispatchToCurrentThread(runnable.forget()); } diff --git a/dom/presentation/ipc/PresentationIPCService.cpp b/dom/presentation/ipc/PresentationIPCService.cpp index 5e2273c3c871..8f0460fe2780 100644 --- a/dom/presentation/ipc/PresentationIPCService.cpp +++ b/dom/presentation/ipc/PresentationIPCService.cpp @@ -485,13 +485,15 @@ PresentationIPCService::UntrackSessionInfo(const nsAString& aSessionId, if (NS_SUCCEEDED(GetWindowIdBySessionIdInternal(aSessionId, aRole, &windowId))) { - NS_DispatchToMainThread(NS_NewRunnableFunction([windowId]() -> void { - PRES_DEBUG("Attempt to close window[%" PRIu64 "]\n", windowId); + NS_DispatchToMainThread(NS_NewRunnableFunction( + "dom::PresentationIPCService::UntrackSessionInfo", + [windowId]() -> void { + PRES_DEBUG("Attempt to close window[%" PRIu64 "]\n", windowId); - if (auto* window = nsGlobalWindow::GetInnerWindowWithId(windowId)) { - window->Close(); - } - })); + if (auto* window = nsGlobalWindow::GetInnerWindowWithId(windowId)) { + window->Close(); + } + })); } } diff --git a/dom/presentation/provider/MulticastDNSDeviceProvider.cpp b/dom/presentation/provider/MulticastDNSDeviceProvider.cpp index ddd5939bb4dd..701599a980eb 100644 --- a/dom/presentation/provider/MulticastDNSDeviceProvider.cpp +++ b/dom/presentation/provider/MulticastDNSDeviceProvider.cpp @@ -834,8 +834,10 @@ MulticastDNSDeviceProvider::OnRegistrationFailed(nsIDNSServiceInfo* aServiceInfo mRegisterRequest = nullptr; if (aErrorCode == nsIDNSRegistrationListener::ERROR_SERVICE_NOT_RUNNING) { - return NS_DispatchToMainThread( - NewRunnableMethod(this, &MulticastDNSDeviceProvider::RegisterMDNSService)); + return NS_DispatchToMainThread(NewRunnableMethod( + "dom::presentation::MulticastDNSDeviceProvider::RegisterMDNSService", + this, + &MulticastDNSDeviceProvider::RegisterMDNSService)); } return NS_OK; diff --git a/dom/promise/PromiseDebugging.cpp b/dom/promise/PromiseDebugging.cpp index f3ec33e8bfe8..6ed901256280 100644 --- a/dom/promise/PromiseDebugging.cpp +++ b/dom/promise/PromiseDebugging.cpp @@ -24,6 +24,8 @@ namespace dom { class FlushRejections: public CancelableRunnable { public: + FlushRejections() : CancelableRunnable("dom::FlushRejections") {} + static void Init() { if (!sDispatched.init()) { MOZ_CRASH("Could not initialize FlushRejections::sDispatched"); diff --git a/dom/push/PushManager.cpp b/dom/push/PushManager.cpp index ef7823c0515c..d150a8daff50 100644 --- a/dom/push/PushManager.cpp +++ b/dom/push/PushManager.cpp @@ -272,7 +272,8 @@ public: const nsAString& aScope, PushManager::SubscriptionAction aAction, nsTArray&& aAppServerKey) - : mProxy(aProxy) + : Runnable("dom::GetSubscriptionRunnable") + , mProxy(aProxy) , mScope(aScope) , mAction(aAction) , mAppServerKey(Move(aAppServerKey)) @@ -400,7 +401,8 @@ class PermissionStateRunnable final : public Runnable { public: explicit PermissionStateRunnable(PromiseWorkerProxy* aProxy) - : mProxy(aProxy) + : Runnable("dom::PermissionStateRunnable") + , mProxy(aProxy) {} NS_IMETHOD diff --git a/dom/push/PushSubscription.cpp b/dom/push/PushSubscription.cpp index bfe8b5dd9730..660d1c580cf1 100644 --- a/dom/push/PushSubscription.cpp +++ b/dom/push/PushSubscription.cpp @@ -141,9 +141,9 @@ NS_IMPL_ISUPPORTS(WorkerUnsubscribeResultCallback, nsIUnsubscribeResultCallback) class UnsubscribeRunnable final : public Runnable { public: - UnsubscribeRunnable(PromiseWorkerProxy* aProxy, - const nsAString& aScope) - : mProxy(aProxy) + UnsubscribeRunnable(PromiseWorkerProxy* aProxy, const nsAString& aScope) + : Runnable("dom::UnsubscribeRunnable") + , mProxy(aProxy) , mScope(aScope) { MOZ_ASSERT(aProxy); diff --git a/dom/quota/ActorsParent.cpp b/dom/quota/ActorsParent.cpp index 32acf1f131d7..0beef549ca93 100644 --- a/dom/quota/ActorsParent.cpp +++ b/dom/quota/ActorsParent.cpp @@ -378,7 +378,8 @@ class QuotaObject::StoragePressureRunnable final public: explicit StoragePressureRunnable(uint64_t aUsage) - : mUsage(aUsage) + : Runnable("dom::quota::QuotaObject::StoragePressureRunnable") + , mUsage(aUsage) { } private: @@ -410,7 +411,8 @@ class QuotaManager::CreateRunnable final public: CreateRunnable() - : mResultCode(NS_OK) + : Runnable("dom::quota::QuotaManager::CreateRunnable") + , mResultCode(NS_OK) , mState(State::Initial) { AssertIsOnBackgroundThread(); @@ -455,7 +457,8 @@ class QuotaManager::ShutdownRunnable final public: explicit ShutdownRunnable(bool& aDone) - : mDone(aDone) + : Runnable("dom::quota::QuotaManager::ShutdownRunnable") + , mDone(aDone) { MOZ_ASSERT(NS_IsMainThread()); } @@ -789,8 +792,9 @@ public: protected: explicit OriginOperationBase( - nsIEventTarget* aOwningThread = GetCurrentThreadEventTarget()) + nsIEventTarget* aOwningThread = GetCurrentThreadEventTarget()) : BackgroundThreadObject(aOwningThread) + , Runnable("dom::quota::OriginOperationBase") , mResultCode(NS_OK) , mState(State_Initial) , mActorDestroyed(false) @@ -1560,9 +1564,9 @@ protected: const bool mPersistent; public: - StorageDirectoryHelper(nsIFile* aDirectory, - bool aPersistent) - : mMutex("StorageDirectoryHelper::mMutex") + StorageDirectoryHelper(nsIFile* aDirectory, bool aPersistent) + : Runnable("dom::quota::StorageDirectoryHelper") + , mMutex("StorageDirectoryHelper::mMutex") , mCondVar(mMutex, "StorageDirectoryHelper::mCondVar") , mMainThreadResultCode(NS_OK) , mWaiting(true) @@ -3649,7 +3653,9 @@ QuotaManager::Shutdown() // QuotaManager on the IO thread. This should probably use // NewNonOwningRunnableMethod ... RefPtr runnable = - NewRunnableMethod(this, &QuotaManager::ReleaseIOThreadObjects); + NewRunnableMethod("dom::quota::QuotaManager::ReleaseIOThreadObjects", + this, + &QuotaManager::ReleaseIOThreadObjects); MOZ_ASSERT(runnable); // Give clients a chance to cleanup IO thread only objects. @@ -5885,11 +5891,12 @@ GroupInfoPair::GetGroupInfoForPersistenceType(PersistenceType aPersistenceType) CollectOriginsHelper::CollectOriginsHelper(mozilla::Mutex& aMutex, uint64_t aMinSizeToBeFreed) -: mMinSizeToBeFreed(aMinSizeToBeFreed), - mMutex(aMutex), - mCondVar(aMutex, "CollectOriginsHelper::mCondVar"), - mSizeToBeFreed(0), - mWaiting(true) + : Runnable("dom::quota::CollectOriginsHelper") + , mMinSizeToBeFreed(aMinSizeToBeFreed) + , mMutex(aMutex) + , mCondVar(aMutex, "CollectOriginsHelper::mCondVar") + , mSizeToBeFreed(0) + , mWaiting(true) { MOZ_ASSERT(!NS_IsMainThread(), "Wrong thread!"); mMutex.AssertCurrentThreadOwns(); @@ -6508,7 +6515,9 @@ Quota::RecvStartIdleMaintenance() QuotaManager* quotaManager = QuotaManager::Get(); if (!quotaManager) { nsCOMPtr callback = - NewRunnableMethod(this, &Quota::StartIdleMaintenance); + NewRunnableMethod("dom::quota::Quota::StartIdleMaintenance", + this, + &Quota::StartIdleMaintenance); QuotaManager::GetOrCreate(callback); return IPC_OK(); diff --git a/dom/quota/QuotaManagerService.cpp b/dom/quota/QuotaManagerService.cpp index 01be3f87e203..eb2dbf8c21bd 100644 --- a/dom/quota/QuotaManagerService.cpp +++ b/dom/quota/QuotaManagerService.cpp @@ -86,7 +86,8 @@ class AbortOperationsRunnable final public: explicit AbortOperationsRunnable(ContentParentId aContentParentId) - : mContentParentId(aContentParentId) + : Runnable("dom::quota::AbortOperationsRunnable") + , mContentParentId(aContentParentId) { } private: diff --git a/dom/script/ScriptLoader.cpp b/dom/script/ScriptLoader.cpp index 075be452117e..f00c46bbd0f1 100644 --- a/dom/script/ScriptLoader.cpp +++ b/dom/script/ScriptLoader.cpp @@ -1050,9 +1050,9 @@ private: RefPtr mLoader; RefPtr mRequest; public: - ScriptRequestProcessor(ScriptLoader* aLoader, - ScriptLoadRequest* aRequest) - : mLoader(aLoader) + ScriptRequestProcessor(ScriptLoader* aLoader, ScriptLoadRequest* aRequest) + : Runnable("dom::ScriptRequestProcessor") + , mLoader(aLoader) , mRequest(aRequest) {} NS_IMETHOD Run() override @@ -1207,7 +1207,8 @@ ScriptLoader::ProcessScriptElement(nsIScriptElement* aElement) if (!scriptURI) { // Asynchronously report the failure to create a URI object NS_DispatchToCurrentThread( - NewRunnableMethod(aElement, + NewRunnableMethod("nsIScriptElement::FireErrorEvent", + aElement, &nsIScriptElement::FireErrorEvent)); return false; } @@ -1297,7 +1298,8 @@ ScriptLoader::ProcessScriptElement(nsIScriptElement* aElement) // Asynchronously report the load failure NS_DispatchToCurrentThread( - NewRunnableMethod(aElement, + NewRunnableMethod("nsIScriptElement::FireErrorEvent", + aElement, &nsIScriptElement::FireErrorEvent)); return false; } @@ -1482,7 +1484,8 @@ class NotifyOffThreadScriptLoadCompletedRunnable : public Runnable public: NotifyOffThreadScriptLoadCompletedRunnable(ScriptLoadRequest* aRequest, ScriptLoader* aLoader) - : mRequest(aRequest) + : Runnable("dom::NotifyOffThreadScriptLoadCompletedRunnable") + , mRequest(aRequest) , mLoader(aLoader) , mDocGroup(aLoader->GetDocGroup()) , mToken(nullptr) @@ -2411,8 +2414,10 @@ void ScriptLoader::ProcessPendingRequestsAsync() { if (HasPendingRequests()) { - nsCOMPtr task = NewRunnableMethod(this, - &ScriptLoader::ProcessPendingRequests); + nsCOMPtr task = + NewRunnableMethod("dom::ScriptLoader::ProcessPendingRequests", + this, + &ScriptLoader::ProcessPendingRequests); if (mDocument) { mDocument->Dispatch("ScriptLoader", TaskCategory::Other, task.forget()); } else { diff --git a/dom/security/nsCSPContext.cpp b/dom/security/nsCSPContext.cpp index e844ab9cd395..c1f00a6bfbfa 100644 --- a/dom/security/nsCSPContext.cpp +++ b/dom/security/nsCSPContext.cpp @@ -1075,7 +1075,8 @@ class CSPReportSenderRunnable final : public Runnable const nsAString& aScriptSample, uint32_t aLineNum, nsCSPContext* aCSPContext) - : mBlockedContentSource(aBlockedContentSource) + : mozilla::Runnable("CSPReportSenderRunnable") + , mBlockedContentSource(aBlockedContentSource) , mOriginalURI(aOriginalURI) , mViolatedPolicyIndex(aViolatedPolicyIndex) , mReportOnlyFlag(aReportOnlyFlag) diff --git a/dom/security/nsMixedContentBlocker.cpp b/dom/security/nsMixedContentBlocker.cpp index 92f6edf40bc0..ea8327b3a474 100644 --- a/dom/security/nsMixedContentBlocker.cpp +++ b/dom/security/nsMixedContentBlocker.cpp @@ -119,8 +119,13 @@ enum MixedContentHSTSPrimingState { class nsMixedContentEvent : public Runnable { public: - nsMixedContentEvent(nsISupports *aContext, MixedContentTypes aType, bool aRootHasSecureConnection) - : mContext(aContext), mType(aType), mRootHasSecureConnection(aRootHasSecureConnection) + nsMixedContentEvent(nsISupports* aContext, + MixedContentTypes aType, + bool aRootHasSecureConnection) + : mozilla::Runnable("nsMixedContentEvent") + , mContext(aContext) + , mType(aType) + , mRootHasSecureConnection(aRootHasSecureConnection) {} NS_IMETHOD Run() override diff --git a/dom/smil/nsSMILTimedElement.cpp b/dom/smil/nsSMILTimedElement.cpp index 120536be0747..bfa5d0eb74a5 100644 --- a/dom/smil/nsSMILTimedElement.cpp +++ b/dom/smil/nsSMILTimedElement.cpp @@ -87,9 +87,11 @@ namespace int32_t mDetail; public: - AsyncTimeEventRunner(nsIContent* aTarget, EventMessage aMsg, + AsyncTimeEventRunner(nsIContent* aTarget, + EventMessage aMsg, int32_t aDetail) - : mTarget(aTarget) + : mozilla::Runnable("AsyncTimeEventRunner") + , mTarget(aTarget) , mMsg(aMsg) , mDetail(aDetail) { diff --git a/dom/storage/LocalStorageCache.cpp b/dom/storage/LocalStorageCache.cpp index 2a4a34b79a45..8f785266ccd0 100644 --- a/dom/storage/LocalStorageCache.cpp +++ b/dom/storage/LocalStorageCache.cpp @@ -111,8 +111,9 @@ LocalStorageCache::Release(void) return; } - RefPtr > event = - NewNonOwningRunnableMethod(static_cast(this), + RefPtr> event = + NewNonOwningRunnableMethod("dom::LocalStorageCacheBridge::Release", + static_cast(this), &LocalStorageCacheBridge::Release); nsresult rv = NS_DispatchToMainThread(event); @@ -625,7 +626,8 @@ class LoadUsageRunnable : public Runnable { public: LoadUsageRunnable(int64_t* aUsage, const int64_t aDelta) - : mTarget(aUsage) + : Runnable("dom::LoadUsageRunnable") + , mTarget(aUsage) , mDelta(aDelta) {} diff --git a/dom/storage/StorageDBThread.cpp b/dom/storage/StorageDBThread.cpp index a85ee56a3e75..5de22c50b96f 100644 --- a/dom/storage/StorageDBThread.cpp +++ b/dom/storage/StorageDBThread.cpp @@ -723,8 +723,10 @@ StorageDBThread::NotifyFlushCompletion() { #ifdef DOM_STORAGE_TESTS if (!NS_IsMainThread()) { - RefPtr > event = - NewNonOwningRunnableMethod(this, &StorageDBThread::NotifyFlushCompletion); + RefPtr> event = + NewNonOwningRunnableMethod("dom::StorageDBThread::NotifyFlushCompletion", + this, + &StorageDBThread::NotifyFlushCompletion); NS_DispatchToMainThread(event); return; } diff --git a/dom/storage/StorageIPC.cpp b/dom/storage/StorageIPC.cpp index 603d578918bd..928354114d86 100644 --- a/dom/storage/StorageIPC.cpp +++ b/dom/storage/StorageIPC.cpp @@ -315,7 +315,8 @@ class SendInitialChildDataRunnable : public Runnable { public: explicit SendInitialChildDataRunnable(StorageDBParent* aParent) - : mParent(aParent) + : Runnable("dom::SendInitialChildDataRunnable") + , mParent(aParent) {} private: @@ -645,12 +646,13 @@ public: const nsACString& aOriginNoSuffix, const nsAString& aKey = EmptyString(), const nsAString& aValue = EmptyString()) - : mParent(aParent) - , mType(aType) - , mSuffix(aOriginSuffix) - , mOrigin(aOriginNoSuffix) - , mKey(aKey) - , mValue(aValue) + : Runnable("dom::LoadRunnable") + , mParent(aParent) + , mType(aType) + , mSuffix(aOriginSuffix) + , mOrigin(aOriginNoSuffix) + , mKey(aKey) + , mValue(aValue) { } LoadRunnable(StorageDBParent* aParent, @@ -658,11 +660,12 @@ public: const nsACString& aOriginSuffix, const nsACString& aOriginNoSuffix, nsresult aRv) - : mParent(aParent) - , mType(aType) - , mSuffix(aOriginSuffix) - , mOrigin(aOriginNoSuffix) - , mRv(aRv) + : Runnable("dom::LoadRunnable") + , mParent(aParent) + , mType(aType) + , mSuffix(aOriginSuffix) + , mOrigin(aOriginNoSuffix) + , mRv(aRv) { } private: @@ -750,9 +753,11 @@ namespace { class UsageRunnable : public Runnable { public: - UsageRunnable(StorageDBParent* aParent, const nsACString& aOriginScope, + UsageRunnable(StorageDBParent* aParent, + const nsACString& aOriginScope, const int64_t& aUsage) - : mParent(aParent) + : Runnable("dom::UsageRunnable") + , mParent(aParent) , mOriginScope(aOriginScope) , mUsage(aUsage) {} diff --git a/dom/svg/SVGFEImageElement.cpp b/dom/svg/SVGFEImageElement.cpp index ed6d2cca1539..75854739e41b 100644 --- a/dom/svg/SVGFEImageElement.cpp +++ b/dom/svg/SVGFEImageElement.cpp @@ -172,7 +172,9 @@ SVGFEImageElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, ClearBrokenState(); RemoveStatesSilently(NS_EVENT_STATE_BROKEN); nsContentUtils::AddScriptRunner( - NewRunnableMethod(this, &SVGFEImageElement::MaybeLoadSVGImage)); + NewRunnableMethod("dom::SVGFEImageElement::MaybeLoadSVGImage", + this, + &SVGFEImageElement::MaybeLoadSVGImage)); } return rv; diff --git a/dom/svg/SVGImageElement.cpp b/dom/svg/SVGImageElement.cpp index 6f3ffd7847c8..8dea0ca89a67 100644 --- a/dom/svg/SVGImageElement.cpp +++ b/dom/svg/SVGImageElement.cpp @@ -203,7 +203,9 @@ SVGImageElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, ClearBrokenState(); RemoveStatesSilently(NS_EVENT_STATE_BROKEN); nsContentUtils::AddScriptRunner( - NewRunnableMethod(this, &SVGImageElement::MaybeLoadSVGImage)); + NewRunnableMethod("dom::SVGImageElement::MaybeLoadSVGImage", + this, + &SVGImageElement::MaybeLoadSVGImage)); } return rv; diff --git a/dom/svg/SVGStyleElement.cpp b/dom/svg/SVGStyleElement.cpp index 22fb204dff95..f0332a892318 100644 --- a/dom/svg/SVGStyleElement.cpp +++ b/dom/svg/SVGStyleElement.cpp @@ -78,7 +78,8 @@ SVGStyleElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, NS_ENSURE_SUCCESS(rv, rv); void (SVGStyleElement::*update)() = &SVGStyleElement::UpdateStyleSheetInternal; - nsContentUtils::AddScriptRunner(NewRunnableMethod(this, update)); + nsContentUtils::AddScriptRunner( + NewRunnableMethod("dom::SVGStyleElement::BindToTree", this, update)); return rv; } diff --git a/dom/system/nsDeviceSensors.cpp b/dom/system/nsDeviceSensors.cpp index 739f67a07aa7..bb8b28068f04 100644 --- a/dom/system/nsDeviceSensors.cpp +++ b/dom/system/nsDeviceSensors.cpp @@ -139,10 +139,10 @@ NS_IMETHODIMP nsDeviceSensors::HasWindowListener(uint32_t aType, nsIDOMWindow *a class DeviceSensorTestEvent : public Runnable { public: - DeviceSensorTestEvent(nsDeviceSensors* aTarget, - uint32_t aType) - : mTarget(aTarget) - , mType(aType) + DeviceSensorTestEvent(nsDeviceSensors* aTarget, uint32_t aType) + : mozilla::Runnable("DeviceSensorTestEvent") + , mTarget(aTarget) + , mType(aType) { } diff --git a/dom/u2f/U2F.cpp b/dom/u2f/U2F.cpp index 0d1aaaaba88f..f0a216a69a94 100644 --- a/dom/u2f/U2F.cpp +++ b/dom/u2f/U2F.cpp @@ -163,10 +163,12 @@ U2FStatus::GetResponse() return mResponse; } -U2FTask::U2FTask(const nsAString& aOrigin, const nsAString& aAppId, +U2FTask::U2FTask(const nsAString& aOrigin, + const nsAString& aAppId, const Authenticator& aAuthenticator, nsISerialEventTarget* aEventTarget) - : mOrigin(aOrigin) + : Runnable("dom::U2FTask") + , mOrigin(aOrigin) , mAppId(aAppId) , mAuthenticator(aAuthenticator) , mEventTarget(aEventTarget) @@ -190,7 +192,8 @@ U2FTask::Execute() U2FPrepTask::U2FPrepTask(const Authenticator& aAuthenticator, nsISerialEventTarget* aEventTarget) - : mAuthenticator(aAuthenticator) + : Runnable("dom::U2FPrepTask") + , mAuthenticator(aAuthenticator) , mEventTarget(aEventTarget) {} @@ -444,7 +447,8 @@ U2FSignTask::Run() U2FRunnable::U2FRunnable(const nsAString& aOrigin, const nsAString& aAppId, nsISerialEventTarget* aEventTarget) - : mOrigin(aOrigin) + : Runnable("dom::U2FRunnable") + , mOrigin(aOrigin) , mAppId(aAppId) , mEventTarget(aEventTarget) {} @@ -677,14 +681,14 @@ U2FRegisterRunnable::Run() if (status->IsStopped()) { status->WaitGroupAdd(); mEventTarget->Dispatch(NS_NewRunnableFunction( + "dom::U2FRegisterRunnable::Run", [&status, this] () { RegisterResponse response; response.mErrorCode.Construct( static_cast(status->GetErrorCode())); SendResponse(response); status->WaitGroupDone(); - } - )); + })); // Don't exit until the main thread runnable completes status->WaitGroupWait(); @@ -740,6 +744,7 @@ U2FRegisterRunnable::Run() // Transmit back to the JS engine from the Main Thread status->WaitGroupAdd(); mEventTarget->Dispatch(NS_NewRunnableFunction( + "dom::U2FRegisterRunnable::Run", [&status, this] () { RegisterResponse response; if (status->GetErrorCode() == ErrorCode::OK) { @@ -750,8 +755,7 @@ U2FRegisterRunnable::Run() } SendResponse(response); status->WaitGroupDone(); - } - )); + })); // TODO: Add timeouts, Bug 1301793 status->WaitGroupWait(); @@ -923,6 +927,7 @@ U2FSignRunnable::Run() // Transmit back to the JS engine from the Main Thread status->WaitGroupAdd(); mEventTarget->Dispatch(NS_NewRunnableFunction( + "dom::U2FSignRunnable::Run", [&status, this] () { SignResponse response; if (status->GetErrorCode() == ErrorCode::OK) { @@ -933,8 +938,7 @@ U2FSignRunnable::Run() } SendResponse(response); status->WaitGroupDone(); - } - )); + })); // TODO: Add timeouts, Bug 1301793 status->WaitGroupWait(); diff --git a/dom/url/URLMainThread.cpp b/dom/url/URLMainThread.cpp index 39f5bd3a6963..7d33c2bb30c9 100644 --- a/dom/url/URLMainThread.cpp +++ b/dom/url/URLMainThread.cpp @@ -125,8 +125,8 @@ URLMainThread::CreateObjectURL(const GlobalObject& aGlobal, return; } - nsCOMPtr revocation = NS_NewRunnableFunction( - [url] { + nsCOMPtr revocation = + NS_NewRunnableFunction("dom::URLMainThread::CreateObjectURL", [url] { nsHostObjectProtocolHandler::RemoveDataEntry(url); }); diff --git a/dom/url/URLWorker.cpp b/dom/url/URLWorker.cpp index 0fc8f86d609b..0e66489033e1 100644 --- a/dom/url/URLWorker.cpp +++ b/dom/url/URLWorker.cpp @@ -279,7 +279,8 @@ class TeardownURLRunnable : public Runnable { public: explicit TeardownURLRunnable(URLWorker::URLProxy* aURLProxy) - : mURLProxy(aURLProxy) + : Runnable("dom::TeardownURLRunnable") + , mURLProxy(aURLProxy) { } diff --git a/dom/webauthn/U2FSoftTokenManager.cpp b/dom/webauthn/U2FSoftTokenManager.cpp index 0de3b2fac972..a92c642853fe 100644 --- a/dom/webauthn/U2FSoftTokenManager.cpp +++ b/dom/webauthn/U2FSoftTokenManager.cpp @@ -234,6 +234,7 @@ U2FSoftTokenManager::GetOrCreateWrappingKey(const UniquePK11SlotInfo& aSlot, ("Key stored, nickname set to %s.", mSecretNickname.get())); GetMainThreadEventTarget()->Dispatch(NS_NewRunnableFunction( + "dom::U2FSoftTokenManager::GetOrCreateWrappingKey", [] () { MOZ_ASSERT(NS_IsMainThread()); Preferences::SetUint(PREF_U2F_NSSTOKEN_COUNTER, 0); @@ -797,6 +798,7 @@ U2FSoftTokenManager::Sign(const nsTArray& aApplication, counterItem.data[3] = (mCounter >> 0) & 0xFF; uint32_t counter = mCounter; GetMainThreadEventTarget()->Dispatch(NS_NewRunnableFunction( + "dom::U2FSoftTokenManager::Sign", [counter] () { MOZ_ASSERT(NS_IsMainThread()); Preferences::SetUint(PREF_U2F_NSSTOKEN_COUNTER, counter); diff --git a/dom/webbrowserpersist/WebBrowserPersistDocumentParent.cpp b/dom/webbrowserpersist/WebBrowserPersistDocumentParent.cpp index a54b1f4f2d5f..66073c0aed3b 100644 --- a/dom/webbrowserpersist/WebBrowserPersistDocumentParent.cpp +++ b/dom/webbrowserpersist/WebBrowserPersistDocumentParent.cpp @@ -44,9 +44,11 @@ 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 = NewRunnableMethod - (mOnReady, &nsIWebBrowserPersistDocumentReceiver::OnError, - NS_ERROR_FAILURE); + nsCOMPtr errorLater = NewRunnableMethod( + "nsIWebBrowserPersistDocumentReceiver::OnError", + mOnReady, + &nsIWebBrowserPersistDocumentReceiver::OnError, + NS_ERROR_FAILURE); NS_DispatchToCurrentThread(errorLater); mOnReady = nullptr; } diff --git a/dom/webbrowserpersist/WebBrowserPersistResourcesParent.cpp b/dom/webbrowserpersist/WebBrowserPersistResourcesParent.cpp index 94e0b2c91908..2c5194dce888 100644 --- a/dom/webbrowserpersist/WebBrowserPersistResourcesParent.cpp +++ b/dom/webbrowserpersist/WebBrowserPersistResourcesParent.cpp @@ -31,10 +31,13 @@ WebBrowserPersistResourcesParent::ActorDestroy(ActorDestroyReason aWhy) if (aWhy != Deletion && mVisitor) { // See comment in WebBrowserPersistDocumentParent::ActorDestroy // (or bug 1202887) for why this is deferred. - nsCOMPtr errorLater = NewRunnableMethod - , nsresult> - (mVisitor, &nsIWebBrowserPersistResourceVisitor::EndVisit, - mDocument, NS_ERROR_FAILURE); + nsCOMPtr errorLater = + NewRunnableMethod, nsresult>( + "nsIWebBrowserPersistResourceVisitor::EndVisit", + mVisitor, + &nsIWebBrowserPersistResourceVisitor::EndVisit, + mDocument, + NS_ERROR_FAILURE); NS_DispatchToCurrentThread(errorLater); } mVisitor = nullptr; diff --git a/dom/webbrowserpersist/WebBrowserPersistSerializeParent.cpp b/dom/webbrowserpersist/WebBrowserPersistSerializeParent.cpp index f723145e29e2..c4b179d29286 100644 --- a/dom/webbrowserpersist/WebBrowserPersistSerializeParent.cpp +++ b/dom/webbrowserpersist/WebBrowserPersistSerializeParent.cpp @@ -75,11 +75,18 @@ WebBrowserPersistSerializeParent::ActorDestroy(ActorDestroyReason aWhy) MOZ_ASSERT(aWhy != Deletion); // See comment in WebBrowserPersistDocumentParent::ActorDestroy // (or bug 1202887) for why this is deferred. - nsCOMPtr errorLater = NewRunnableMethod - , nsCOMPtr, - nsCString, nsresult> - (mFinish, &nsIWebBrowserPersistWriteCompletion::OnFinish, - mDocument, mStream, EmptyCString(), NS_ERROR_FAILURE); + nsCOMPtr errorLater = + NewRunnableMethod, + nsCOMPtr, + nsCString, + nsresult>( + "nsIWebBrowserPersistWriteCompletion::OnFinish", + mFinish, + &nsIWebBrowserPersistWriteCompletion::OnFinish, + mDocument, + mStream, + EmptyCString(), + NS_ERROR_FAILURE); NS_DispatchToCurrentThread(errorLater); mFinish = nullptr; } diff --git a/dom/webbrowserpersist/nsWebBrowserPersist.cpp b/dom/webbrowserpersist/nsWebBrowserPersist.cpp index 20d9a21ee4db..fdde2e56e24b 100644 --- a/dom/webbrowserpersist/nsWebBrowserPersist.cpp +++ b/dom/webbrowserpersist/nsWebBrowserPersist.cpp @@ -675,8 +675,10 @@ 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(NewRunnableMethod(this, - &nsWebBrowserPersist::FinishDownload)); + NS_DispatchToCurrentThread( + NewRunnableMethod("nsWebBrowserPersist::FinishDownload", + this, + &nsWebBrowserPersist::FinishDownload)); return; } @@ -787,8 +789,10 @@ nsWebBrowserPersist::OnWrite::OnFinish(nsIWebBrowserPersistDocument* aDoc, return NS_OK; } } - NS_DispatchToCurrentThread(NewRunnableMethod(mParent, - &nsWebBrowserPersist::SerializeNextFile)); + NS_DispatchToCurrentThread( + NewRunnableMethod("nsWebBrowserPersist::SerializeNextFile", + mParent, + &nsWebBrowserPersist::SerializeNextFile)); return NS_OK; } @@ -1790,9 +1794,11 @@ nsWebBrowserPersist::FinishSaveDocumentInternal(nsIURI* aFile, // Bounce this off the event loop to avoid stack overflow. typedef StoreCopyPassByRRef WalkStorage; auto saveMethod = &nsWebBrowserPersist::SaveDocumentDeferred; - nsCOMPtr saveLater = - NewRunnableMethod(this, saveMethod, - mozilla::Move(toWalk)); + nsCOMPtr saveLater = NewRunnableMethod( + "nsWebBrowserPersist::FinishSaveDocumentInternal", + this, + saveMethod, + mozilla::Move(toWalk)); NS_DispatchToCurrentThread(saveLater); } else { // Done walking DOMs; on to the serialization phase. diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp index 2e2d4f3bf5a3..a52e83df1c69 100644 --- a/dom/workers/RuntimeService.cpp +++ b/dom/workers/RuntimeService.cpp @@ -1254,7 +1254,10 @@ public: WorkerThreadPrimaryRunnable(WorkerPrivate* aWorkerPrivate, WorkerThread* aThread, JSRuntime* aParentRuntime) - : mWorkerPrivate(aWorkerPrivate), mThread(aThread), mParentRuntime(aParentRuntime) + : mozilla::Runnable("WorkerThreadPrimaryRunnable") + , mWorkerPrivate(aWorkerPrivate) + , mThread(aThread) + , mParentRuntime(aParentRuntime) { MOZ_ASSERT(aWorkerPrivate); MOZ_ASSERT(aThread); diff --git a/dom/workers/ScriptLoader.cpp b/dom/workers/ScriptLoader.cpp index 5bbb428bbc5b..8a612804ca6b 100644 --- a/dom/workers/ScriptLoader.cpp +++ b/dom/workers/ScriptLoader.cpp @@ -762,7 +762,8 @@ private: mCanceled = true; MOZ_ALWAYS_SUCCEEDS( - NS_DispatchToMainThread(NewRunnableMethod(this, + NS_DispatchToMainThread(NewRunnableMethod("ScriptLoaderRunnable::CancelMainThreadWithBindingAborted", + this, &ScriptLoaderRunnable::CancelMainThreadWithBindingAborted))); } diff --git a/dom/workers/ServiceWorkerClient.cpp b/dom/workers/ServiceWorkerClient.cpp index 07ed5d07394c..68d4a7ec5680 100644 --- a/dom/workers/ServiceWorkerClient.cpp +++ b/dom/workers/ServiceWorkerClient.cpp @@ -137,7 +137,9 @@ public: ServiceWorkerClientPostMessageRunnable(uint64_t aSourceID, const nsACString& aSourceScope, uint64_t aWindowId) - : StructuredCloneHolder(CloningSupported, TransferringSupported, + : mozilla::Runnable("ServiceWorkerClientPostMessageRunnable") + , StructuredCloneHolder(CloningSupported, + TransferringSupported, StructuredCloneScope::SameProcessDifferentThread) , mSourceID(aSourceID) , mSourceScope(aSourceScope) diff --git a/dom/workers/ServiceWorkerClients.cpp b/dom/workers/ServiceWorkerClients.cpp index e32a6e98e7f3..a9b8c6efe5e4 100644 --- a/dom/workers/ServiceWorkerClients.cpp +++ b/dom/workers/ServiceWorkerClients.cpp @@ -111,10 +111,10 @@ class GetRunnable final : public Runnable RefPtr mPromiseProxy; nsString mClientId; public: - GetRunnable(PromiseWorkerProxy* aPromiseProxy, - const nsAString& aClientId) - : mPromiseProxy(aPromiseProxy), - mClientId(aClientId) + GetRunnable(PromiseWorkerProxy* aPromiseProxy, const nsAString& aClientId) + : mozilla::Runnable("GetRunnable") + , mPromiseProxy(aPromiseProxy) + , mClientId(aClientId) { } @@ -201,10 +201,11 @@ public: const nsCString& aScope, uint64_t aServiceWorkerID, bool aIncludeUncontrolled) - : mPromiseProxy(aPromiseProxy), - mScope(aScope), - mServiceWorkerID(aServiceWorkerID), - mIncludeUncontrolled(aIncludeUncontrolled) + : mozilla::Runnable("MatchAllRunnable") + , mPromiseProxy(aPromiseProxy) + , mScope(aScope) + , mServiceWorkerID(aServiceWorkerID) + , mIncludeUncontrolled(aIncludeUncontrolled) { MOZ_ASSERT(mPromiseProxy); } @@ -279,7 +280,8 @@ class ClaimRunnable final : public Runnable public: ClaimRunnable(PromiseWorkerProxy* aPromiseProxy, const nsCString& aScope) - : mPromiseProxy(aPromiseProxy) + : mozilla::Runnable("ClaimRunnable") + , mPromiseProxy(aPromiseProxy) , mScope(aScope) // Safe to call GetWorkerPrivate() since we are being called on the worker // thread via script (so no clean up has occured yet). @@ -508,7 +510,8 @@ public: OpenWindowRunnable(PromiseWorkerProxy* aPromiseProxy, const nsAString& aUrl, const nsAString& aScope) - : mPromiseProxy(aPromiseProxy) + : mozilla::Runnable("OpenWindowRunnable") + , mPromiseProxy(aPromiseProxy) , mUrl(aUrl) , mScope(aScope) { diff --git a/dom/workers/ServiceWorkerEvents.cpp b/dom/workers/ServiceWorkerEvents.cpp index e0f25e6cfab0..6d317a492b5e 100644 --- a/dom/workers/ServiceWorkerEvents.cpp +++ b/dom/workers/ServiceWorkerEvents.cpp @@ -95,10 +95,12 @@ AsyncLog(nsIInterceptedChannel* aInterceptedChannel, BEGIN_WORKERS_NAMESPACE -CancelChannelRunnable::CancelChannelRunnable(nsMainThreadPtrHandle& aChannel, - nsMainThreadPtrHandle& aRegistration, - nsresult aStatus) - : mChannel(aChannel) +CancelChannelRunnable::CancelChannelRunnable( + nsMainThreadPtrHandle& aChannel, + nsMainThreadPtrHandle& aRegistration, + nsresult aStatus) + : Runnable("dom::workers::CancelChannelRunnable") + , mChannel(aChannel) , mRegistration(aRegistration) , mStatus(aStatus) { @@ -177,7 +179,8 @@ public: const ChannelInfo& aWorkerChannelInfo, const nsACString& aScriptSpec, const nsACString& aResponseURLSpec) - : mChannel(aChannel) + : Runnable("dom::workers::FinishResponse") + , mChannel(aChannel) , mInternalResponse(aInternalResponse) , mWorkerChannelInfo(aWorkerChannelInfo) , mScriptSpec(aScriptSpec) @@ -881,7 +884,8 @@ public: } MOZ_ALWAYS_SUCCEEDS(mWorkerPrivate->DispatchToMainThread( - NewRunnableMethod(this, &WaitUntilHandler::ReportOnMainThread))); + NewRunnableMethod("WaitUntilHandler::ReportOnMainThread", + this, &WaitUntilHandler::ReportOnMainThread))); } void diff --git a/dom/workers/ServiceWorkerInfo.cpp b/dom/workers/ServiceWorkerInfo.cpp index 6beba301b811..f0e281e1673a 100644 --- a/dom/workers/ServiceWorkerInfo.cpp +++ b/dom/workers/ServiceWorkerInfo.cpp @@ -144,7 +144,8 @@ class ChangeStateUpdater final : public Runnable public: ChangeStateUpdater(const nsTArray& aInstances, ServiceWorkerState aState) - : mState(aState) + : Runnable("dom::workers::ChangeStateUpdater") + , mState(aState) { for (size_t i = 0; i < aInstances.Length(); ++i) { mInstances.AppendElement(aInstances[i]); diff --git a/dom/workers/ServiceWorkerManager.cpp b/dom/workers/ServiceWorkerManager.cpp index 8c61727affe6..c2c3069da563 100644 --- a/dom/workers/ServiceWorkerManager.cpp +++ b/dom/workers/ServiceWorkerManager.cpp @@ -206,7 +206,8 @@ class TeardownRunnable final : public Runnable { public: explicit TeardownRunnable(ServiceWorkerManagerChild* aActor) - : mActor(aActor) + : Runnable("dom::workers::TeardownRunnable") + , mActor(aActor) { MOZ_ASSERT(mActor); } @@ -386,7 +387,8 @@ class PropagateSoftUpdateRunnable final : public Runnable public: PropagateSoftUpdateRunnable(const OriginAttributes& aOriginAttributes, const nsAString& aScope) - : mOriginAttributes(aOriginAttributes) + : Runnable("dom::workers::PropagateSoftUpdateRunnable") + , mOriginAttributes(aOriginAttributes) , mScope(aScope) {} @@ -416,7 +418,8 @@ public: PropagateUnregisterRunnable(nsIPrincipal* aPrincipal, nsIServiceWorkerUnregisterCallback* aCallback, const nsAString& aScope) - : mPrincipal(aPrincipal) + : Runnable("dom::workers::PropagateUnregisterRunnable") + , mPrincipal(aPrincipal) , mCallback(aCallback) , mScope(aScope) { @@ -448,7 +451,9 @@ class RemoveRunnable final : public Runnable { public: explicit RemoveRunnable(const nsACString& aHost) - {} + : Runnable("dom::workers::RemoveRunnable") + { + } NS_IMETHOD Run() override { @@ -473,7 +478,9 @@ class PropagateRemoveRunnable final : public Runnable { public: explicit PropagateRemoveRunnable(const nsACString& aHost) - {} + : Runnable("dom::workers::PropagateRemoveRunnable") + { + } NS_IMETHOD Run() override { @@ -498,7 +505,9 @@ class PropagateRemoveAllRunnable final : public Runnable { public: PropagateRemoveAllRunnable() - {} + : Runnable("dom::workers::PropagateRemoveAllRunnable") + { + } NS_IMETHOD Run() override { @@ -578,9 +587,11 @@ class SoftUpdateRunnable final : public CancelableRunnable { public: SoftUpdateRunnable(const OriginAttributes& aOriginAttributes, - const nsACString& aScope, bool aInternalMethod, + const nsACString& aScope, + bool aInternalMethod, GenericPromise::Private* aPromise) - : mAttrs(aOriginAttributes) + : CancelableRunnable("dom::workers::SoftUpdateRunnable") + , mAttrs(aOriginAttributes) , mScope(aScope) , mInternalMethod(aInternalMethod) , mPromise(aPromise) @@ -650,7 +661,8 @@ public: ServiceWorkerUpdateFinishCallback* aCallback, Type aType, GenericPromise::Private* aPromise) - : mPrincipal(aPrincipal) + : CancelableRunnable("dom::workers::UpdateRunnable") + , mPrincipal(aPrincipal) , mScope(aScope) , mCallback(aCallback) , mType(aType) @@ -714,7 +726,8 @@ class ResolvePromiseRunnable final : public CancelableRunnable { public: explicit ResolvePromiseRunnable(GenericPromise::Private* aPromise) - : mPromise(aPromise) + : CancelableRunnable("dom::workers::ResolvePromiseRunnable") + , mPromise(aPromise) {} NS_IMETHOD @@ -959,7 +972,9 @@ class GetRegistrationsRunnable final : public Runnable RefPtr mPromise; public: GetRegistrationsRunnable(nsPIDOMWindowInner* aWindow, Promise* aPromise) - : mWindow(aWindow), mPromise(aPromise) + : Runnable("dom::workers::GetRegistrationsRunnable") + , mWindow(aWindow) + , mPromise(aPromise) {} NS_IMETHOD @@ -1085,9 +1100,13 @@ class GetRegistrationRunnable final : public Runnable nsString mDocumentURL; public: - GetRegistrationRunnable(nsPIDOMWindowInner* aWindow, Promise* aPromise, + GetRegistrationRunnable(nsPIDOMWindowInner* aWindow, + Promise* aPromise, const nsAString& aDocumentURL) - : mWindow(aWindow), mPromise(aPromise), mDocumentURL(aDocumentURL) + : Runnable("dom::workers::GetRegistrationRunnable") + , mWindow(aWindow) + , mPromise(aPromise) + , mDocumentURL(aDocumentURL) {} NS_IMETHOD @@ -1191,7 +1210,9 @@ class GetReadyPromiseRunnable final : public Runnable public: GetReadyPromiseRunnable(nsPIDOMWindowInner* aWindow, Promise* aPromise) - : mWindow(aWindow), mPromise(aPromise) + : Runnable("dom::workers::GetReadyPromiseRunnable") + , mWindow(aWindow) + , mPromise(aPromise) {} NS_IMETHOD @@ -2619,12 +2640,14 @@ class ContinueDispatchFetchEventRunnable : public Runnable nsString mDocumentId; bool mIsReload; public: - ContinueDispatchFetchEventRunnable(ServiceWorkerPrivate* aServiceWorkerPrivate, - nsIInterceptedChannel* aChannel, - nsILoadGroup* aLoadGroup, - const nsAString& aDocumentId, - bool aIsReload) - : mServiceWorkerPrivate(aServiceWorkerPrivate) + ContinueDispatchFetchEventRunnable( + ServiceWorkerPrivate* aServiceWorkerPrivate, + nsIInterceptedChannel* aChannel, + nsILoadGroup* aLoadGroup, + const nsAString& aDocumentId, + bool aIsReload) + : Runnable("dom::workers::ContinueDispatchFetchEventRunnable") + , mServiceWorkerPrivate(aServiceWorkerPrivate) , mChannel(aChannel) , mLoadGroup(aLoadGroup) , mDocumentId(aDocumentId) @@ -2765,7 +2788,8 @@ ServiceWorkerManager::DispatchFetchEvent(const OriginAttributes& aOriginAttribut // When this service worker was registered, we also sent down the permissions // for the runnable. They should have arrived by now, but we still need to // wait for them if they have not. - nsCOMPtr permissionsRunnable = NS_NewRunnableFunction([=] () { + nsCOMPtr permissionsRunnable = NS_NewRunnableFunction( + "dom::workers::ServiceWorkerManager::DispatchFetchEvent", [=]() { nsCOMPtr permMgr = services::GetPermissionManager(); MOZ_ALWAYS_SUCCEEDS(permMgr->WhenPermissionsAvailable(serviceWorker->Principal(), continueRunnable)); diff --git a/dom/workers/ServiceWorkerManagerParent.cpp b/dom/workers/ServiceWorkerManagerParent.cpp index 41f106b083d9..a4d21c10b071 100644 --- a/dom/workers/ServiceWorkerManagerParent.cpp +++ b/dom/workers/ServiceWorkerManagerParent.cpp @@ -30,7 +30,8 @@ class RegisterServiceWorkerCallback final : public Runnable public: RegisterServiceWorkerCallback(const ServiceWorkerRegistrationData& aData, uint64_t aParentID) - : mData(aData) + : Runnable("dom::workers::RegisterServiceWorkerCallback") + , mData(aData) , mParentID(aParentID) { AssertIsInMainProcess(); @@ -74,7 +75,8 @@ public: UnregisterServiceWorkerCallback(const PrincipalInfo& aPrincipalInfo, const nsString& aScope, uint64_t aParentID) - : mPrincipalInfo(aPrincipalInfo) + : Runnable("dom::workers::UnregisterServiceWorkerCallback") + , mPrincipalInfo(aPrincipalInfo) , mScope(aScope) , mParentID(aParentID) { @@ -122,7 +124,8 @@ public: CheckPrincipalWithCallbackRunnable(already_AddRefed aParent, const PrincipalInfo& aPrincipalInfo, Runnable* aCallback) - : mContentParent(aParent) + : Runnable("dom::workers::CheckPrincipalWithCallbackRunnable") + , mContentParent(aParent) , mPrincipalInfo(aPrincipalInfo) , mCallback(aCallback) , mBackgroundEventTarget(GetCurrentThreadEventTarget()) diff --git a/dom/workers/ServiceWorkerManagerService.cpp b/dom/workers/ServiceWorkerManagerService.cpp index e3d474648f0f..b622b4f8901d 100644 --- a/dom/workers/ServiceWorkerManagerService.cpp +++ b/dom/workers/ServiceWorkerManagerService.cpp @@ -109,16 +109,17 @@ ServiceWorkerManagerService::PropagateRegistration( // Send permissions fot the newly registered service worker to all of the // content processes. PrincipalInfo pi = aData.principal(); - NS_DispatchToMainThread(NS_NewRunnableFunction([pi] () { - nsTArray cps; - ContentParent::GetAll(cps); - for (auto* cp : cps) { - nsCOMPtr principal = PrincipalInfoToPrincipal(pi); - if (principal) { - cp->TransmitPermissionsForPrincipal(principal); - } + NS_DispatchToMainThread(NS_NewRunnableFunction( + "dom::workers::ServiceWorkerManagerService::PropagateRegistration", [pi]() { + nsTArray cps; + ContentParent::GetAll(cps); + for (auto* cp : cps) { + nsCOMPtr principal = PrincipalInfoToPrincipal(pi); + if (principal) { + cp->TransmitPermissionsForPrincipal(principal); } - })); + } + })); #ifdef DEBUG MOZ_ASSERT(parentFound); diff --git a/dom/workers/ServiceWorkerPrivate.cpp b/dom/workers/ServiceWorkerPrivate.cpp index d52f2a598e33..ca5af769dd39 100644 --- a/dom/workers/ServiceWorkerPrivate.cpp +++ b/dom/workers/ServiceWorkerPrivate.cpp @@ -146,8 +146,11 @@ public: aWorkerPrivate->AssertIsOnWorkerThread(); bool fetchHandlerWasAdded = aWorkerPrivate->FetchHandlerWasAdded(); - nsCOMPtr runnable = NewRunnableMethod(this, - &CheckScriptEvaluationWithCallback::ReportFetchFlag, fetchHandlerWasAdded); + nsCOMPtr runnable = NewRunnableMethod( + "dom::workers::CheckScriptEvaluationWithCallback::ReportFetchFlag", + this, + &CheckScriptEvaluationWithCallback::ReportFetchFlag, + fetchHandlerWasAdded); aWorkerPrivate->DispatchToMainThread(runnable.forget()); ReportScriptEvaluationResult(aWorkerPrivate->WorkerScriptExecutedSuccessfully()); @@ -376,7 +379,10 @@ private: CycleCollectedJSContext* cx = CycleCollectedJSContext::Get(); MOZ_ASSERT(cx); - RefPtr r = NewRunnableMethod(this, &KeepAliveHandler::MaybeDone); + RefPtr r = + NewRunnableMethod("dom::workers::KeepAliveHandler::MaybeDone", + this, + &KeepAliveHandler::MaybeDone); cx->DispatchToMicroTask(r.forget()); } }; @@ -389,9 +395,11 @@ class RegistrationUpdateRunnable : public Runnable const bool mNeedTimeCheck; public: - RegistrationUpdateRunnable(nsMainThreadPtrHandle& aRegistration, - bool aNeedTimeCheck) - : mRegistration(aRegistration) + RegistrationUpdateRunnable( + nsMainThreadPtrHandle& aRegistration, + bool aNeedTimeCheck) + : Runnable("dom::workers::RegistrationUpdateRunnable") + , mRegistration(aRegistration) , mNeedTimeCheck(aNeedTimeCheck) { MOZ_DIAGNOSTIC_ASSERT(mRegistration); @@ -864,9 +872,11 @@ public: mMessageId.IsEmpty()) { return; } - nsCOMPtr runnable = - NewRunnableMethod(this, - &PushErrorReporter::ReportOnMainThread, aReason); + nsCOMPtr runnable = NewRunnableMethod( + "dom::workers::PushErrorReporter::ReportOnMainThread", + this, + &PushErrorReporter::ReportOnMainThread, + aReason); MOZ_ALWAYS_TRUE(NS_SUCCEEDED( workerPrivate->DispatchToMainThread(runnable.forget()))); } @@ -1512,8 +1522,10 @@ private: class ResumeRequest final : public Runnable { nsMainThreadPtrHandle mChannel; public: - explicit ResumeRequest(nsMainThreadPtrHandle& aChannel) - : mChannel(aChannel) + explicit ResumeRequest( + nsMainThreadPtrHandle& aChannel) + : Runnable("dom::workers::FetchEventRunnable::ResumeRequest") + , mChannel(aChannel) { mChannel->SetFinishResponseStart(TimeStamp::Now()); } @@ -1672,7 +1684,9 @@ ServiceWorkerPrivate::SendFetchEvent(nsIInterceptedChannel* aChannel, // if the ServiceWorker script fails to load for some reason, just resume // the original channel. nsCOMPtr failRunnable = - NewRunnableMethod(aChannel, &nsIInterceptedChannel::ResetInterception); + NewRunnableMethod("nsIInterceptedChannel::ResetInterception", + aChannel, + &nsIInterceptedChannel::ResetInterception); aChannel->SetLaunchServiceWorkerStart(TimeStamp::Now()); aChannel->SetDispatchFetchEventStart(TimeStamp::Now()); diff --git a/dom/workers/ServiceWorkerPrivate.h b/dom/workers/ServiceWorkerPrivate.h index fcd32c6c8344..76ddb6e2ec87 100644 --- a/dom/workers/ServiceWorkerPrivate.h +++ b/dom/workers/ServiceWorkerPrivate.h @@ -27,6 +27,8 @@ class KeepAliveToken; class LifeCycleEventCallback : public Runnable { public: + LifeCycleEventCallback() : Runnable("dom::workers::LifeCycleEventCallback") {} + // Called on the worker thread. virtual void SetResult(bool aResult) = 0; diff --git a/dom/workers/ServiceWorkerRegistrar.cpp b/dom/workers/ServiceWorkerRegistrar.cpp index 264b0b3ce583..0006c3832c0a 100644 --- a/dom/workers/ServiceWorkerRegistrar.cpp +++ b/dom/workers/ServiceWorkerRegistrar.cpp @@ -707,7 +707,8 @@ class ServiceWorkerRegistrarSaveDataRunnable final : public Runnable { public: ServiceWorkerRegistrarSaveDataRunnable() - : mEventTarget(GetCurrentThreadEventTarget()) + : Runnable("dom::ServiceWorkerRegistrarSaveDataRunnable") + , mEventTarget(GetCurrentThreadEventTarget()) { AssertIsOnBackgroundThread(); } @@ -721,7 +722,8 @@ public: service->SaveData(); RefPtr runnable = - NewRunnableMethod(service, &ServiceWorkerRegistrar::DataSaved); + NewRunnableMethod("ServiceWorkerRegistrar::DataSaved", + service, &ServiceWorkerRegistrar::DataSaved); nsresult rv = mEventTarget->Dispatch(runnable, NS_DISPATCH_NORMAL); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; @@ -795,7 +797,9 @@ ServiceWorkerRegistrar::MaybeScheduleShutdownCompleted() } RefPtr runnable = - NewRunnableMethod(this, &ServiceWorkerRegistrar::ShutdownCompleted); + NewRunnableMethod("dom::ServiceWorkerRegistrar::ShutdownCompleted", + this, + &ServiceWorkerRegistrar::ShutdownCompleted); nsresult rv = NS_DispatchToMainThread(runnable); if (NS_WARN_IF(NS_FAILED(rv))) { return; @@ -957,7 +961,9 @@ ServiceWorkerRegistrar::ProfileStarted() MOZ_ASSERT(target, "Must have stream transport service"); nsCOMPtr runnable = - NewRunnableMethod(this, &ServiceWorkerRegistrar::LoadData); + NewRunnableMethod("dom::ServiceWorkerRegistrar::LoadData", + 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/ServiceWorkerRegistration.cpp b/dom/workers/ServiceWorkerRegistration.cpp index 53b25ecbf2be..30fdcf7303cf 100644 --- a/dom/workers/ServiceWorkerRegistration.cpp +++ b/dom/workers/ServiceWorkerRegistration.cpp @@ -492,9 +492,9 @@ public: class UpdateRunnable final : public Runnable { public: - UpdateRunnable(PromiseWorkerProxy* aPromiseProxy, - const nsAString& aScope) - : mPromiseProxy(aPromiseProxy) + UpdateRunnable(PromiseWorkerProxy* aPromiseProxy, const nsAString& aScope) + : Runnable("dom::UpdateRunnable") + , mPromiseProxy(aPromiseProxy) , mScope(aScope) {} @@ -663,9 +663,9 @@ class StartUnregisterRunnable final : public Runnable const nsString mScope; public: - StartUnregisterRunnable(PromiseWorkerProxy* aProxy, - const nsAString& aScope) - : mPromiseWorkerProxy(aProxy) + StartUnregisterRunnable(PromiseWorkerProxy* aProxy, const nsAString& aScope) + : Runnable("dom::StartUnregisterRunnable") + , mPromiseWorkerProxy(aProxy) , mScope(aScope) { MOZ_ASSERT(aProxy); @@ -1188,7 +1188,9 @@ ServiceWorkerRegistrationWorkerThread::InitListener() } nsCOMPtr r = - NewRunnableMethod(mListener, &WorkerListener::StartListeningForEvents); + NewRunnableMethod("dom::WorkerListener::StartListeningForEvents", + mListener, + &WorkerListener::StartListeningForEvents); MOZ_ALWAYS_SUCCEEDS(worker->DispatchToMainThread(r.forget())); } @@ -1210,7 +1212,9 @@ ServiceWorkerRegistrationWorkerThread::ReleaseListener() mListener->ClearRegistration(); nsCOMPtr r = - NewRunnableMethod(mListener, &WorkerListener::StopListeningForEvents); + NewRunnableMethod("dom::WorkerListener::StopListeningForEvents", + mListener, + &WorkerListener::StopListeningForEvents); MOZ_ALWAYS_SUCCEEDS(mWorkerPrivate->DispatchToMainThread(r.forget())); mListener = nullptr; diff --git a/dom/workers/ServiceWorkerRegistrationInfo.cpp b/dom/workers/ServiceWorkerRegistrationInfo.cpp index 57a41c3f075b..3a0f50d2ccad 100644 --- a/dom/workers/ServiceWorkerRegistrationInfo.cpp +++ b/dom/workers/ServiceWorkerRegistrationInfo.cpp @@ -228,7 +228,8 @@ void ServiceWorkerRegistrationInfo::TryToActivateAsync() { MOZ_ALWAYS_SUCCEEDS( - NS_DispatchToMainThread(NewRunnableMethod(this, + NS_DispatchToMainThread(NewRunnableMethod("ServiceWorkerRegistrationInfo::TryToActivate", + this, &ServiceWorkerRegistrationInfo::TryToActivate))); } @@ -267,13 +268,17 @@ ServiceWorkerRegistrationInfo::Activate() // "Queue a task to fire a simple event named controllerchange..." nsCOMPtr controllerChangeRunnable = NewRunnableMethod>( - swm, &ServiceWorkerManager::FireControllerChange, this); + "dom::workers::ServiceWorkerManager::FireControllerChange", + swm, + &ServiceWorkerManager::FireControllerChange, + this); NS_DispatchToMainThread(controllerChangeRunnable); - nsCOMPtr failRunnable = - NewRunnableMethod(this, - &ServiceWorkerRegistrationInfo::FinishActivate, - false /* success */); + nsCOMPtr failRunnable = NewRunnableMethod( + "dom::workers::ServiceWorkerRegistrationInfo::FinishActivate", + this, + &ServiceWorkerRegistrationInfo::FinishActivate, + false /* success */); nsMainThreadPtrHandle handle( new nsMainThreadPtrHolder( @@ -375,9 +380,14 @@ ServiceWorkerRegistrationInfo::UpdateRegistrationStateProperties(WhichServiceWor { AssertIsOnMainThread(); - nsCOMPtr runnable = NewRunnableMethod( - this, - &ServiceWorkerRegistrationInfo::AsyncUpdateRegistrationStateProperties, aWorker, aTransition); + nsCOMPtr runnable = + NewRunnableMethod( + "dom::workers::ServiceWorkerRegistrationInfo::" + "AsyncUpdateRegistrationStateProperties", + this, + &ServiceWorkerRegistrationInfo::AsyncUpdateRegistrationStateProperties, + aWorker, + aTransition); MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(runnable.forget())); } diff --git a/dom/workers/ServiceWorkerUpdateJob.cpp b/dom/workers/ServiceWorkerUpdateJob.cpp index 7f56d9d0518c..110cbc1d892a 100644 --- a/dom/workers/ServiceWorkerUpdateJob.cpp +++ b/dom/workers/ServiceWorkerUpdateJob.cpp @@ -509,6 +509,8 @@ ServiceWorkerUpdateJob::Install(ServiceWorkerManager* aSWM) // fire the updatefound event nsCOMPtr upr = NewRunnableMethod>( + "dom::workers::ServiceWorkerManager::" + "FireUpdateFoundOnServiceWorkerRegistrations", aSWM, &ServiceWorkerManager::FireUpdateFoundOnServiceWorkerRegistrations, mRegistration); @@ -516,8 +518,11 @@ ServiceWorkerUpdateJob::Install(ServiceWorkerManager* aSWM) // Call ContinueAfterInstallEvent(false) on main thread if the SW // script fails to load. - nsCOMPtr failRunnable = NewRunnableMethod - (this, &ServiceWorkerUpdateJob::ContinueAfterInstallEvent, false); + nsCOMPtr failRunnable = NewRunnableMethod( + "dom::workers::ServiceWorkerUpdateJob::ContinueAfterInstallEvent", + this, + &ServiceWorkerUpdateJob::ContinueAfterInstallEvent, + false); nsMainThreadPtrHandle handle( new nsMainThreadPtrHolder( diff --git a/dom/workers/ServiceWorkerWindowClient.cpp b/dom/workers/ServiceWorkerWindowClient.cpp index 530c51ca7448..5689ac727a18 100644 --- a/dom/workers/ServiceWorkerWindowClient.cpp +++ b/dom/workers/ServiceWorkerWindowClient.cpp @@ -111,7 +111,8 @@ class ClientFocusRunnable final : public Runnable public: ClientFocusRunnable(uint64_t aWindowId, PromiseWorkerProxy* aPromiseProxy) - : mWindowId(aWindowId) + : mozilla::Runnable("ClientFocusRunnable") + , mWindowId(aWindowId) , mPromiseProxy(aPromiseProxy) { MOZ_ASSERT(mPromiseProxy); @@ -338,10 +339,12 @@ class ClientNavigateRunnable final : public Runnable MOZ_INIT_OUTSIDE_CTOR WorkerPrivate* mWorkerPrivate; public: - ClientNavigateRunnable(uint64_t aWindowId, const nsAString& aUrl, + ClientNavigateRunnable(uint64_t aWindowId, + const nsAString& aUrl, const nsAString& aScope, PromiseWorkerProxy* aPromiseProxy) - : mWindowId(aWindowId) + : mozilla::Runnable("ClientNavigateRunnable") + , mWindowId(aWindowId) , mUrl(aUrl) , mScope(aScope) , mPromiseProxy(aPromiseProxy) diff --git a/dom/workers/WorkerDebuggerManager.cpp b/dom/workers/WorkerDebuggerManager.cpp index dfd7e5acc350..210c3a0b1f3c 100644 --- a/dom/workers/WorkerDebuggerManager.cpp +++ b/dom/workers/WorkerDebuggerManager.cpp @@ -24,8 +24,9 @@ class RegisterDebuggerMainThreadRunnable final : public mozilla::Runnable public: RegisterDebuggerMainThreadRunnable(WorkerPrivate* aWorkerPrivate, bool aNotifyListeners) - : mWorkerPrivate(aWorkerPrivate), - mNotifyListeners(aNotifyListeners) + : mozilla::Runnable("RegisterDebuggerMainThreadRunnable") + , mWorkerPrivate(aWorkerPrivate) + , mNotifyListeners(aNotifyListeners) { } private: @@ -49,7 +50,8 @@ class UnregisterDebuggerMainThreadRunnable final : public mozilla::Runnable public: explicit UnregisterDebuggerMainThreadRunnable(WorkerPrivate* aWorkerPrivate) - : mWorkerPrivate(aWorkerPrivate) + : mozilla::Runnable("UnregisterDebuggerMainThreadRunnable") + , mWorkerPrivate(aWorkerPrivate) { } private: diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp index e50a456c9785..711645a4abfd 100644 --- a/dom/workers/WorkerPrivate.cpp +++ b/dom/workers/WorkerPrivate.cpp @@ -353,6 +353,7 @@ class MainThreadReleaseRunnable final : public Runnable public: MainThreadReleaseRunnable(nsTArray>& aDoomed, nsCOMPtr& aLoadGroupToCancel) + : mozilla::Runnable("MainThreadReleaseRunnable") { mDoomed.SwapElements(aDoomed); mLoadGroupToCancel.swap(aLoadGroupToCancel); @@ -427,7 +428,8 @@ class TopLevelWorkerFinishedRunnable final : public Runnable public: explicit TopLevelWorkerFinishedRunnable(WorkerPrivate* aFinishedWorker) - : mFinishedWorker(aFinishedWorker) + : mozilla::Runnable("TopLevelWorkerFinishedRunnable") + , mFinishedWorker(aFinishedWorker) { aFinishedWorker->AssertIsOnWorkerThread(); } @@ -2578,11 +2580,13 @@ WorkerPrivate::MemoryReporter::FinishCollectRunnable::FinishCollectRunnable( nsISupports* aHandlerData, bool aAnonymize, const nsACString& aPath) - : mHandleReport(aHandleReport), - mHandlerData(aHandlerData), - mAnonymize(aAnonymize), - mSuccess(false), - mCxStats(aPath) + : mozilla::Runnable( + "dom::workers::WorkerPrivate::MemoryReporter::FinishCollectRunnable") + , mHandleReport(aHandleReport) + , mHandlerData(aHandlerData) + , mAnonymize(aAnonymize) + , mSuccess(false) + , mCxStats(aPath) { } NS_IMETHODIMP @@ -4092,8 +4096,9 @@ class PostDebuggerMessageRunnable final : public Runnable public: PostDebuggerMessageRunnable(WorkerDebugger* aDebugger, const nsAString& aMessage) - : mDebugger(aDebugger), - mMessage(aMessage) + : mozilla::Runnable("PostDebuggerMessageRunnable") + , mDebugger(aDebugger) + , mMessage(aMessage) { } @@ -4119,12 +4124,14 @@ class ReportDebuggerErrorRunnable final : public Runnable public: ReportDebuggerErrorRunnable(WorkerDebugger* aDebugger, - const nsAString& aFilename, uint32_t aLineno, + const nsAString& aFilename, + uint32_t aLineno, const nsAString& aMessage) - : mDebugger(aDebugger), - mFilename(aFilename), - mLineno(aLineno), - mMessage(aMessage) + : mozilla::Runnable("ReportDebuggerErrorRunnable") + , mDebugger(aDebugger) + , mFilename(aFilename) + , mLineno(aLineno) + , mMessage(aMessage) { } diff --git a/dom/workers/WorkerRunnable.cpp b/dom/workers/WorkerRunnable.cpp index fd998b24e7e1..e6b6ca775574 100644 --- a/dom/workers/WorkerRunnable.cpp +++ b/dom/workers/WorkerRunnable.cpp @@ -559,10 +559,12 @@ WorkerControlRunnable::DispatchInternal() NS_IMPL_ISUPPORTS_INHERITED0(WorkerControlRunnable, WorkerRunnable) -WorkerMainThreadRunnable::WorkerMainThreadRunnable(WorkerPrivate* aWorkerPrivate, - const nsACString& aTelemetryKey) -: mWorkerPrivate(aWorkerPrivate) -, mTelemetryKey(aTelemetryKey) +WorkerMainThreadRunnable::WorkerMainThreadRunnable( + WorkerPrivate* aWorkerPrivate, + const nsACString& aTelemetryKey) + : mozilla::Runnable("dom::workers::WorkerMainThreadRunnable") + , mWorkerPrivate(aWorkerPrivate) + , mTelemetryKey(aTelemetryKey) { mWorkerPrivate->AssertIsOnWorkerThread(); } @@ -661,8 +663,10 @@ WorkerSameThreadRunnable::PostDispatch(WorkerPrivate* aWorkerPrivate, } } -WorkerProxyToMainThreadRunnable::WorkerProxyToMainThreadRunnable(WorkerPrivate* aWorkerPrivate) - : mWorkerPrivate(aWorkerPrivate) +WorkerProxyToMainThreadRunnable::WorkerProxyToMainThreadRunnable( + WorkerPrivate* aWorkerPrivate) + : mozilla::Runnable("dom::workers::WorkerProxyToMainThreadRunnable") + , mWorkerPrivate(aWorkerPrivate) { MOZ_ASSERT(mWorkerPrivate); mWorkerPrivate->AssertIsOnWorkerThread(); diff --git a/dom/workers/WorkerScope.cpp b/dom/workers/WorkerScope.cpp index fd3e0ed7e1e1..5f978d4774d1 100644 --- a/dom/workers/WorkerScope.cpp +++ b/dom/workers/WorkerScope.cpp @@ -651,7 +651,8 @@ class ReportFetchListenerWarningRunnable final : public Runnable public: explicit ReportFetchListenerWarningRunnable(const nsString& aScope) - : mScope(NS_ConvertUTF16toUTF8(aScope)) + : mozilla::Runnable("ReportFetchListenerWarningRunnable") + , mScope(NS_ConvertUTF16toUTF8(aScope)) { WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate(); MOZ_ASSERT(workerPrivate); @@ -759,7 +760,8 @@ class WorkerScopeSkipWaitingRunnable final : public Runnable public: WorkerScopeSkipWaitingRunnable(PromiseWorkerProxy* aPromiseProxy, const nsCString& aScope) - : mPromiseProxy(aPromiseProxy) + : mozilla::Runnable("WorkerScopeSkipWaitingRunnable") + , mPromiseProxy(aPromiseProxy) , mScope(aScope) { MOZ_ASSERT(aPromiseProxy); diff --git a/dom/xbl/nsBindingManager.cpp b/dom/xbl/nsBindingManager.cpp index 03b492cc4942..9102ebcfebee 100644 --- a/dom/xbl/nsBindingManager.cpp +++ b/dom/xbl/nsBindingManager.cpp @@ -390,8 +390,12 @@ nsBindingManager::DoProcessAttachedQueue() nsresult rv = NS_ERROR_FAILURE; nsCOMPtr timer = do_CreateInstance(NS_TIMER_CONTRACTID); if (timer) { - rv = timer->InitWithFuncCallback(PostPAQEventCallback, this, - 100, nsITimer::TYPE_ONE_SHOT); + rv = timer->InitWithNamedFuncCallback( + PostPAQEventCallback, + this, + 100, + nsITimer::TYPE_ONE_SHOT, + "nsBindingManager::DoProcessAttachedQueue"); } if (NS_SUCCEEDED(rv)) { NS_ADDREF_THIS(); diff --git a/dom/xhr/XMLHttpRequestMainThread.cpp b/dom/xhr/XMLHttpRequestMainThread.cpp index 79ebe8d8c9b0..e2741136098b 100644 --- a/dom/xhr/XMLHttpRequestMainThread.cpp +++ b/dom/xhr/XMLHttpRequestMainThread.cpp @@ -145,7 +145,11 @@ NS_IMPL_ISUPPORTS(nsXHRParseEndListener, nsIDOMEventListener) class nsResumeTimeoutsEvent : public Runnable { public: - explicit nsResumeTimeoutsEvent(nsPIDOMWindowInner* aWindow) : mWindow(aWindow) {} + explicit nsResumeTimeoutsEvent(nsPIDOMWindowInner* aWindow) + : Runnable("dom::nsResumeTimeoutsEvent") + , mWindow(aWindow) + { + } NS_IMETHOD Run() override { @@ -3123,9 +3127,11 @@ XMLHttpRequestMainThread::SendInternal(const BodyExtractorBase* aBody) } else { // Defer the actual sending of async events just in case listeners // are attached after the send() method is called. - return DispatchToMainThread(NewRunnableMethod(this, - &XMLHttpRequestMainThread::CloseRequestWithError, - ProgressEventType::error)); + return DispatchToMainThread(NewRunnableMethod( + "dom::XMLHttpRequestMainThread::CloseRequestWithError", + this, + &XMLHttpRequestMainThread::CloseRequestWithError, + ProgressEventType::error)); } } diff --git a/dom/xhr/XMLHttpRequestWorker.cpp b/dom/xhr/XMLHttpRequestWorker.cpp index f9cd680fce3e..722361a15583 100644 --- a/dom/xhr/XMLHttpRequestWorker.cpp +++ b/dom/xhr/XMLHttpRequestWorker.cpp @@ -357,7 +357,8 @@ class AsyncTeardownRunnable final : public Runnable public: explicit AsyncTeardownRunnable(Proxy* aProxy) - : mProxy(aProxy) + : Runnable("dom::AsyncTeardownRunnable") + , mProxy(aProxy) { MOZ_ASSERT(aProxy); } @@ -438,9 +439,13 @@ class LoadStartDetectionRunnable final : public Runnable, public: LoadStartDetectionRunnable(Proxy* aProxy, XMLHttpRequestWorker* aXHRPrivate) - : mWorkerPrivate(aProxy->mWorkerPrivate), mProxy(aProxy), mXHR(aProxy->mXHR), - mXMLHttpRequestPrivate(aXHRPrivate), mChannelId(mProxy->mInnerChannelId), - mReceivedLoadStart(false) + : Runnable("dom::LoadStartDetectionRunnable") + , mWorkerPrivate(aProxy->mWorkerPrivate) + , mProxy(aProxy) + , mXHR(aProxy->mXHR) + , mXMLHttpRequestPrivate(aXHRPrivate) + , mChannelId(mProxy->mInnerChannelId) + , mReceivedLoadStart(false) { AssertIsOnMainThread(); mEventType.AssignWithConversion(sEventStrings[STRING_loadstart]); diff --git a/dom/xml/XMLStylesheetProcessingInstruction.cpp b/dom/xml/XMLStylesheetProcessingInstruction.cpp index 3d94e179b48a..7c407eb98da4 100644 --- a/dom/xml/XMLStylesheetProcessingInstruction.cpp +++ b/dom/xml/XMLStylesheetProcessingInstruction.cpp @@ -63,7 +63,8 @@ XMLStylesheetProcessingInstruction::BindToTree(nsIDocument* aDocument, void (XMLStylesheetProcessingInstruction::*update)() = &XMLStylesheetProcessingInstruction::UpdateStyleSheetInternal; - nsContentUtils::AddScriptRunner(NewRunnableMethod(this, update)); + nsContentUtils::AddScriptRunner(NewRunnableMethod( + "dom::XMLStylesheetProcessingInstruction::BindToTree", this, update)); return rv; } diff --git a/dom/xml/nsXMLContentSink.cpp b/dom/xml/nsXMLContentSink.cpp index 19b0cc8ee8ec..3bd8a5dff95d 100644 --- a/dom/xml/nsXMLContentSink.cpp +++ b/dom/xml/nsXMLContentSink.cpp @@ -1583,8 +1583,10 @@ nsXMLContentSink::ContinueInterruptedParsingIfEnabled() void nsXMLContentSink::ContinueInterruptedParsingAsync() { - nsCOMPtr ev = NewRunnableMethod(this, - &nsXMLContentSink::ContinueInterruptedParsingIfEnabled); + nsCOMPtr ev = + NewRunnableMethod("nsXMLContentSink::ContinueInterruptedParsingIfEnabled", + this, + &nsXMLContentSink::ContinueInterruptedParsingIfEnabled); NS_DispatchToCurrentThread(ev); } diff --git a/dom/xml/nsXMLPrettyPrinter.cpp b/dom/xml/nsXMLPrettyPrinter.cpp index 1582cd92a2a8..3393335de92d 100644 --- a/dom/xml/nsXMLPrettyPrinter.cpp +++ b/dom/xml/nsXMLPrettyPrinter.cpp @@ -193,8 +193,8 @@ nsXMLPrettyPrinter::MaybeUnhook(nsIContent* aContent) // since AddScriptRunner _could_ in theory run us // synchronously mUnhookPending = true; - nsContentUtils::AddScriptRunner( - NewRunnableMethod(this, &nsXMLPrettyPrinter::Unhook)); + nsContentUtils::AddScriptRunner(NewRunnableMethod( + "nsXMLPrettyPrinter::Unhook", this, &nsXMLPrettyPrinter::Unhook)); } } diff --git a/dom/xslt/xslt/txMozillaXSLTProcessor.cpp b/dom/xslt/xslt/txMozillaXSLTProcessor.cpp index 9424d1110593..c3f4c289a717 100644 --- a/dom/xslt/xslt/txMozillaXSLTProcessor.cpp +++ b/dom/xslt/xslt/txMozillaXSLTProcessor.cpp @@ -546,7 +546,8 @@ public: RefPtr mProcessor; explicit nsTransformBlockerEvent(txMozillaXSLTProcessor* processor) - : mProcessor(processor) + : mozilla::Runnable("nsTransformBlockerEvent") + , mProcessor(processor) {} ~nsTransformBlockerEvent() diff --git a/dom/xul/XULDocument.cpp b/dom/xul/XULDocument.cpp index 1fdc38052edc..5106b595c362 100644 --- a/dom/xul/XULDocument.cpp +++ b/dom/xul/XULDocument.cpp @@ -1039,10 +1039,14 @@ 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(NewRunnableMethod - - (this, &XULDocument::DoPersist, aElement, kNameSpaceID_None, - aAttribute)); + nsContentUtils::AddScriptRunner( + NewRunnableMethod( + "dom::XULDocument::DoPersist", + this, + &XULDocument::DoPersist, + aElement, + kNameSpaceID_None, + aAttribute)); } } @@ -3144,8 +3148,10 @@ XULDocument::MaybeBroadcast() mDelayedBroadcasters.Length())) { if (!nsContentUtils::IsSafeToRunScript()) { if (!mInDestructor) { - nsContentUtils::AddScriptRunner( - NewRunnableMethod(this, &XULDocument::MaybeBroadcast)); + nsContentUtils::AddScriptRunner( + NewRunnableMethod("dom::XULDocument::MaybeBroadcast", + this, + &XULDocument::MaybeBroadcast)); } return; } diff --git a/dom/xul/nsXULElement.cpp b/dom/xul/nsXULElement.cpp index 80b7a33b4f19..ee57baf89f04 100644 --- a/dom/xul/nsXULElement.cpp +++ b/dom/xul/nsXULElement.cpp @@ -793,7 +793,11 @@ IsInFeedSubscribeLine(nsXULElement* aElement) class XULInContentErrorReporter : public Runnable { public: - explicit XULInContentErrorReporter(nsIDocument* aDocument) : mDocument(aDocument) {} + explicit XULInContentErrorReporter(nsIDocument* aDocument) + : mozilla::Runnable("XULInContentErrorReporter") + , mDocument(aDocument) + { + } NS_IMETHOD Run() override { @@ -1873,7 +1877,8 @@ class SetDrawInTitleBarEvent : public Runnable { public: SetDrawInTitleBarEvent(nsIWidget* aWidget, bool aState) - : mWidget(aWidget) + : mozilla::Runnable("SetDrawInTitleBarEvent") + , mWidget(aWidget) , mState(aState) {} @@ -1928,19 +1933,25 @@ nsXULElement::UpdateBrightTitlebarForeground(nsIDocument* aDoc) class MarginSetter : public Runnable { public: - explicit MarginSetter(nsIWidget* aWidget) : - mWidget(aWidget), mMargin(-1, -1, -1, -1) - {} - MarginSetter(nsIWidget *aWidget, const LayoutDeviceIntMargin& aMargin) : - mWidget(aWidget), mMargin(aMargin) - {} + explicit MarginSetter(nsIWidget* aWidget) + : mozilla::Runnable("MarginSetter") + , mWidget(aWidget) + , mMargin(-1, -1, -1, -1) + { + } + MarginSetter(nsIWidget* aWidget, const LayoutDeviceIntMargin& aMargin) + : mozilla::Runnable("MarginSetter") + , mWidget(aWidget) + , mMargin(aMargin) + { + } - NS_IMETHOD Run() override - { - // SetNonClientMargins can dispatch native events, hence doing - // it off a script runner. - mWidget->SetNonClientMargins(mMargin); - return NS_OK; + NS_IMETHOD Run() override + { + // SetNonClientMargins can dispatch native events, hence doing + // it off a script runner. + mWidget->SetNonClientMargins(mMargin); + return NS_OK; } private: @@ -2629,21 +2640,25 @@ class NotifyOffThreadScriptCompletedRunnable : public Runnable void *mToken; public: - NotifyOffThreadScriptCompletedRunnable(nsIOffThreadScriptReceiver* aReceiver, - void *aToken) - : mReceiver(aReceiver), mToken(aToken) - {} + NotifyOffThreadScriptCompletedRunnable(nsIOffThreadScriptReceiver* aReceiver, + void* aToken) + : mozilla::Runnable("NotifyOffThreadScriptCompletedRunnable") + , mReceiver(aReceiver) + , mToken(aToken) + { + } - static void NoteReceiver(nsIOffThreadScriptReceiver* aReceiver) { - if (!sSetupClearOnShutdown) { - ClearOnShutdown(&sReceivers); - sSetupClearOnShutdown = true; - sReceivers = new nsTArray>(); - } + static void NoteReceiver(nsIOffThreadScriptReceiver* aReceiver) + { + if (!sSetupClearOnShutdown) { + ClearOnShutdown(&sReceivers); + sSetupClearOnShutdown = true; + sReceivers = new nsTArray>(); + } - // If we ever crash here, it's because we tried to lazy compile script - // too late in shutdown. - sReceivers->AppendElement(aReceiver); + // If we ever crash here, it's because we tried to lazy compile script + // too late in shutdown. + sReceivers->AppendElement(aReceiver); } NS_DECL_NSIRUNNABLE diff --git a/dom/xul/templates/nsXULTemplateBuilder.cpp b/dom/xul/templates/nsXULTemplateBuilder.cpp index 7d3317f41e41..eb6c8b43797c 100644 --- a/dom/xul/templates/nsXULTemplateBuilder.cpp +++ b/dom/xul/templates/nsXULTemplateBuilder.cpp @@ -1206,14 +1206,18 @@ nsXULTemplateBuilder::AttributeChanged(nsIDocument* aDocument, // case we may need to nuke and rebuild the entire content model // beneath the element. if (aAttribute == nsGkAtoms::ref) - nsContentUtils::AddScriptRunner( - NewRunnableMethod(this, &nsXULTemplateBuilder::RunnableRebuild)); + nsContentUtils::AddScriptRunner( + NewRunnableMethod("nsXULTemplateBuilder::RunnableRebuild", + 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( - NewRunnableMethod(this, &nsXULTemplateBuilder::RunnableLoadAndRebuild)); + nsContentUtils::AddScriptRunner( + NewRunnableMethod("nsXULTemplateBuilder::RunnableLoadAndRebuild", + this, + &nsXULTemplateBuilder::RunnableLoadAndRebuild)); } } } @@ -1233,7 +1237,9 @@ nsXULTemplateBuilder::ContentRemoved(nsIDocument* aDocument, // Pass false to Uninit since content is going away anyway nsContentUtils::AddScriptRunner( - NewRunnableMethod(this, &nsXULTemplateBuilder::UninitFalse)); + NewRunnableMethod("nsXULTemplateBuilder::UninitFalse", + this, + &nsXULTemplateBuilder::UninitFalse)); MOZ_ASSERT(aDocument == mObservedDocument); StopObserving(); @@ -1272,7 +1278,9 @@ nsXULTemplateBuilder::NodeWillBeDestroyed(const nsINode* aNode) mCompDB = nullptr; nsContentUtils::AddScriptRunner( - NewRunnableMethod(this, &nsXULTemplateBuilder::UninitTrue)); + NewRunnableMethod("nsXULTemplateBuilder::UninitTrue", + this, + &nsXULTemplateBuilder::UninitTrue)); } diff --git a/editor/composer/nsEditingSession.cpp b/editor/composer/nsEditingSession.cpp index b95621b61d8a..e00405a4a417 100644 --- a/editor/composer/nsEditingSession.cpp +++ b/editor/composer/nsEditingSession.cpp @@ -974,10 +974,12 @@ nsEditingSession::EndDocumentLoad(nsIWebProgress *aWebProgress, NS_ENSURE_SUCCESS(rv, rv); mEditorStatus = eEditorCreationInProgress; - mLoadBlankDocTimer->InitWithFuncCallback( - nsEditingSession::TimerCallback, - static_cast (mDocShell.get()), - 10, nsITimer::TYPE_ONE_SHOT); + mLoadBlankDocTimer->InitWithNamedFuncCallback( + nsEditingSession::TimerCallback, + static_cast(mDocShell.get()), + 10, + nsITimer::TYPE_ONE_SHOT, + "nsEditingSession::EndDocumentLoad"); } } } diff --git a/editor/composer/nsEditorSpellCheck.cpp b/editor/composer/nsEditorSpellCheck.cpp index afcf48c54ab6..26b81b7b0a94 100644 --- a/editor/composer/nsEditorSpellCheck.cpp +++ b/editor/composer/nsEditorSpellCheck.cpp @@ -301,7 +301,10 @@ class CallbackCaller final : public Runnable { public: explicit CallbackCaller(nsIEditorSpellCheckCallback* aCallback) - : mCallback(aCallback) {} + : mozilla::Runnable("CallbackCaller") + , mCallback(aCallback) + { + } ~CallbackCaller() { diff --git a/editor/libeditor/EditorBase.cpp b/editor/libeditor/EditorBase.cpp index 5cedf8dc1e48..b7500d63645f 100644 --- a/editor/libeditor/EditorBase.cpp +++ b/editor/libeditor/EditorBase.cpp @@ -1840,7 +1840,8 @@ public: EditorInputEventDispatcher(EditorBase* aEditorBase, nsIContent* aTarget, bool aIsComposing) - : mEditorBase(aEditorBase) + : Runnable("EditorInputEventDispatcher") + , mEditorBase(aEditorBase) , mTarget(aTarget) , mIsComposing(aIsComposing) { diff --git a/editor/libeditor/HTMLEditRules.cpp b/editor/libeditor/HTMLEditRules.cpp index 84ba73db4cca..f9617ff08b6c 100644 --- a/editor/libeditor/HTMLEditRules.cpp +++ b/editor/libeditor/HTMLEditRules.cpp @@ -8955,7 +8955,9 @@ NS_IMETHODIMP HTMLEditRules::DocumentModified() { nsContentUtils::AddScriptRunner( - NewRunnableMethod(this, &HTMLEditRules::DocumentModifiedWorker)); + NewRunnableMethod("HTMLEditRules::DocumentModifiedWorker", + this, + &HTMLEditRules::DocumentModifiedWorker)); return NS_OK; } diff --git a/editor/libeditor/HTMLEditor.cpp b/editor/libeditor/HTMLEditor.cpp index f6c436174187..dc47895568f6 100644 --- a/editor/libeditor/HTMLEditor.cpp +++ b/editor/libeditor/HTMLEditor.cpp @@ -3268,8 +3268,10 @@ HTMLEditor::DoContentInserted(nsIDocument* aDocument, nsCOMPtr kungFuDeathGrip(this); if (ShouldReplaceRootElement()) { - nsContentUtils::AddScriptRunner(NewRunnableMethod( - this, &HTMLEditor::ResetRootElementAndEventTarget)); + nsContentUtils::AddScriptRunner( + NewRunnableMethod("HTMLEditor::ResetRootElementAndEventTarget", + this, + &HTMLEditor::ResetRootElementAndEventTarget)); } // We don't need to handle our own modifications else if (!mAction && (aContainer ? aContainer->IsEditable() : aDocument->IsEditable())) { @@ -3316,8 +3318,10 @@ HTMLEditor::ContentRemoved(nsIDocument* aDocument, nsCOMPtr kungFuDeathGrip(this); if (SameCOMIdentity(aChild, mRootElement)) { - nsContentUtils::AddScriptRunner(NewRunnableMethod( - this, &HTMLEditor::ResetRootElementAndEventTarget)); + nsContentUtils::AddScriptRunner( + NewRunnableMethod("HTMLEditor::ResetRootElementAndEventTarget", + this, + &HTMLEditor::ResetRootElementAndEventTarget)); } // We don't need to handle our own modifications else if (!mAction && (aContainer ? aContainer->IsEditable() : aDocument->IsEditable())) { diff --git a/extensions/auth/nsHttpNegotiateAuth.cpp b/extensions/auth/nsHttpNegotiateAuth.cpp index 1f7f241cade1..e1fd1af9ac83 100644 --- a/extensions/auth/nsHttpNegotiateAuth.cpp +++ b/extensions/auth/nsHttpNegotiateAuth.cpp @@ -330,26 +330,26 @@ class GetNextTokenRunnable final : public mozilla::Runnable { ~GetNextTokenRunnable() override = default; public: - GetNextTokenRunnable(nsIHttpAuthenticableChannel *authChannel, - const char *challenge, - bool isProxyAuth, - const char16_t *domain, - const char16_t *username, - const char16_t *password, - nsISupports *sessionState, - nsISupports *continuationState, - GetNextTokenCompleteEvent *aCompleteEvent - ) - : mAuthChannel(authChannel) - , mChallenge(challenge) - , mIsProxyAuth(isProxyAuth) - , mDomain(domain) - , mUsername(username) - , mPassword(password) - , mSessionState(sessionState) - , mContinuationState(continuationState) - , mCompleteEvent(aCompleteEvent) - { + GetNextTokenRunnable(nsIHttpAuthenticableChannel* authChannel, + const char* challenge, + bool isProxyAuth, + const char16_t* domain, + const char16_t* username, + const char16_t* password, + nsISupports* sessionState, + nsISupports* continuationState, + GetNextTokenCompleteEvent* aCompleteEvent) + : mozilla::Runnable("GetNextTokenRunnable") + , mAuthChannel(authChannel) + , mChallenge(challenge) + , mIsProxyAuth(isProxyAuth) + , mDomain(domain) + , mUsername(username) + , mPassword(password) + , mSessionState(sessionState) + , mContinuationState(continuationState) + , mCompleteEvent(aCompleteEvent) + { } NS_IMETHODIMP Run() override diff --git a/extensions/spellcheck/src/mozPersonalDictionary.cpp b/extensions/spellcheck/src/mozPersonalDictionary.cpp index 19a0af4b0ab1..0f3bff145e9a 100644 --- a/extensions/spellcheck/src/mozPersonalDictionary.cpp +++ b/extensions/spellcheck/src/mozPersonalDictionary.cpp @@ -53,7 +53,9 @@ NS_INTERFACE_MAP_END class mozPersonalDictionaryLoader final : public mozilla::Runnable { public: - explicit mozPersonalDictionaryLoader(mozPersonalDictionary *dict) : mDict(dict) + explicit mozPersonalDictionaryLoader(mozPersonalDictionary* dict) + : mozilla::Runnable("mozPersonalDictionaryLoader") + , mDict(dict) { } @@ -76,12 +78,13 @@ private: class mozPersonalDictionarySave final : public mozilla::Runnable { public: - explicit mozPersonalDictionarySave(mozPersonalDictionary *aDict, + explicit mozPersonalDictionarySave(mozPersonalDictionary* aDict, nsCOMPtr aFile, - nsTArray &&aDictWords) - : mDictWords(aDictWords), - mFile(aFile), - mDict(aDict) + nsTArray&& aDictWords) + : mozilla::Runnable("mozPersonalDictionarySave") + , mDictWords(aDictWords) + , mFile(aFile) + , mDict(aDict) { } diff --git a/gfx/ipc/GPUChild.cpp b/gfx/ipc/GPUChild.cpp index 4fdaa2ad220e..f40cf163304b 100644 --- a/gfx/ipc/GPUChild.cpp +++ b/gfx/ipc/GPUChild.cpp @@ -269,7 +269,8 @@ class DeferredDeleteGPUChild : public Runnable { public: explicit DeferredDeleteGPUChild(UniquePtr&& aChild) - : mChild(Move(aChild)) + : Runnable("gfx::DeferredDeleteGPUChild") + , mChild(Move(aChild)) { } diff --git a/gfx/ipc/GPUParent.cpp b/gfx/ipc/GPUParent.cpp index 2bb0057e791f..bb5713b03bf1 100644 --- a/gfx/ipc/GPUParent.cpp +++ b/gfx/ipc/GPUParent.cpp @@ -127,9 +127,10 @@ void GPUParent::NotifyDeviceReset() { if (!NS_IsMainThread()) { - NS_DispatchToMainThread(NS_NewRunnableFunction([] () -> void { - GPUParent::GetSingleton()->NotifyDeviceReset(); - })); + NS_DispatchToMainThread( + NS_NewRunnableFunction("gfx::GPUParent::NotifyDeviceReset", []() -> void { + GPUParent::GetSingleton()->NotifyDeviceReset(); + })); return; } diff --git a/gfx/ipc/VsyncBridgeChild.cpp b/gfx/ipc/VsyncBridgeChild.cpp index a4be827ef9ac..a5bff3725301 100644 --- a/gfx/ipc/VsyncBridgeChild.cpp +++ b/gfx/ipc/VsyncBridgeChild.cpp @@ -29,7 +29,10 @@ VsyncBridgeChild::Create(RefPtr aThread, RefPtr child = new VsyncBridgeChild(aThread, aProcessToken); RefPtr task = NewRunnableMethod&&>( - child, &VsyncBridgeChild::Open, Move(aEndpoint)); + "gfx::VsyncBridgeChild::Open", + child, + &VsyncBridgeChild::Open, + Move(aEndpoint)); aThread->GetThread()->Dispatch(task.forget(), nsIThread::DISPATCH_NORMAL); return child; @@ -58,9 +61,10 @@ public: NotifyVsyncTask(RefPtr aVsyncBridge, TimeStamp aTimeStamp, const uint64_t& aLayersId) - : mVsyncBridge(aVsyncBridge), - mTimeStamp(aTimeStamp), - mLayersId(aLayersId) + : Runnable("gfx::NotifyVsyncTask") + , mVsyncBridge(aVsyncBridge) + , mTimeStamp(aTimeStamp) + , mLayersId(aLayersId) {} NS_IMETHOD Run() override { @@ -106,7 +110,8 @@ void VsyncBridgeChild::Close() { if (!IsOnVsyncIOThread()) { - mLoop->PostTask(NewRunnableMethod(this, &VsyncBridgeChild::Close)); + mLoop->PostTask(NewRunnableMethod( + "gfx::VsyncBridgeChild::Close", this, &VsyncBridgeChild::Close)); return; } diff --git a/gfx/ipc/VsyncBridgeParent.cpp b/gfx/ipc/VsyncBridgeParent.cpp index 5b59f538a99e..995c461b477e 100644 --- a/gfx/ipc/VsyncBridgeParent.cpp +++ b/gfx/ipc/VsyncBridgeParent.cpp @@ -15,7 +15,10 @@ VsyncBridgeParent::Start(Endpoint&& aEndpoint) RefPtr parent = new VsyncBridgeParent(); RefPtr task = NewRunnableMethod&&>( - parent, &VsyncBridgeParent::Open, Move(aEndpoint)); + "gfx::VsyncBridgeParent::Open", + parent, + &VsyncBridgeParent::Open, + Move(aEndpoint)); CompositorThreadHolder::Loop()->PostTask(task.forget()); return parent; @@ -56,7 +59,9 @@ VsyncBridgeParent::Shutdown() { MessageLoop* ccloop = CompositorThreadHolder::Loop(); if (MessageLoop::current() != ccloop) { - ccloop->PostTask(NewRunnableMethod(this, &VsyncBridgeParent::ShutdownImpl)); + ccloop->PostTask(NewRunnableMethod("gfx::VsyncBridgeParent::ShutdownImpl", + this, + &VsyncBridgeParent::ShutdownImpl)); return; } diff --git a/gfx/ipc/VsyncIOThreadHolder.cpp b/gfx/ipc/VsyncIOThreadHolder.cpp index 8730b72131eb..5c9df5efc998 100644 --- a/gfx/ipc/VsyncIOThreadHolder.cpp +++ b/gfx/ipc/VsyncIOThreadHolder.cpp @@ -25,7 +25,8 @@ VsyncIOThreadHolder::~VsyncIOThreadHolder() if (NS_IsMainThread()) { mThread->AsyncShutdown(); } else { - NS_DispatchToMainThread(NewRunnableMethod(mThread, &nsIThread::AsyncShutdown)); + NS_DispatchToMainThread(NewRunnableMethod( + "nsIThread::AsyncShutdown", mThread, &nsIThread::AsyncShutdown)); } } diff --git a/gfx/layers/AsyncCanvasRenderer.cpp b/gfx/layers/AsyncCanvasRenderer.cpp index b1e37e752311..188b11cf713d 100644 --- a/gfx/layers/AsyncCanvasRenderer.cpp +++ b/gfx/layers/AsyncCanvasRenderer.cpp @@ -47,7 +47,8 @@ AsyncCanvasRenderer::NotifyElementAboutAttributesChanged() { public: explicit Runnable(AsyncCanvasRenderer* aRenderer) - : mRenderer(aRenderer) + : mozilla::Runnable("Runnable") + , mRenderer(aRenderer) {} NS_IMETHOD Run() override @@ -82,7 +83,8 @@ AsyncCanvasRenderer::NotifyElementAboutInvalidation() { public: explicit Runnable(AsyncCanvasRenderer* aRenderer) - : mRenderer(aRenderer) + : mozilla::Runnable("Runnable") + , mRenderer(aRenderer) {} NS_IMETHOD Run() override diff --git a/gfx/layers/ImageContainer.h b/gfx/layers/ImageContainer.h index 3e01b01b7cc3..66d645051b60 100644 --- a/gfx/layers/ImageContainer.h +++ b/gfx/layers/ImageContainer.h @@ -58,7 +58,12 @@ public: */ class SurfaceReleaser : public mozilla::Runnable { public: - explicit SurfaceReleaser(RawRef aRef) : mRef(aRef) {} + explicit SurfaceReleaser(RawRef aRef) + : mozilla::Runnable( + "nsAutoRefTraits::SurfaceReleaser") + , mRef(aRef) + { + } NS_IMETHOD Run() override { mRef->Release(); return NS_OK; @@ -96,7 +101,12 @@ public: */ class SurfaceReleaser : public mozilla::Runnable { public: - explicit SurfaceReleaser(RawRef aRef) : mRef(aRef) {} + explicit SurfaceReleaser(RawRef aRef) + : mozilla::Runnable( + "nsAutoRefTraits::SurfaceReleaser") + , mRef(aRef) + { + } NS_IMETHOD Run() override { mRef->Release(); return NS_OK; diff --git a/gfx/layers/LayerScope.cpp b/gfx/layers/LayerScope.cpp index d959b64eea9c..71dcc33fe0b5 100644 --- a/gfx/layers/LayerScope.cpp +++ b/gfx/layers/LayerScope.cpp @@ -344,9 +344,10 @@ private: class CreateServerSocketRunnable : public Runnable { public: - explicit CreateServerSocketRunnable(LayerScopeManager *aLayerScopeManager) - : mLayerScopeManager(aLayerScopeManager) - { + explicit CreateServerSocketRunnable(LayerScopeManager* aLayerScopeManager) + : Runnable("layers::LayerScopeManager::CreateServerSocketRunnable") + , mLayerScopeManager(aLayerScopeManager) + { } NS_IMETHOD Run() override { mLayerScopeManager->mWebSocketManager = diff --git a/gfx/layers/apz/src/APZCTreeManager.cpp b/gfx/layers/apz/src/APZCTreeManager.cpp index e54075e438fc..53ec6edd7612 100644 --- a/gfx/layers/apz/src/APZCTreeManager.cpp +++ b/gfx/layers/apz/src/APZCTreeManager.cpp @@ -176,9 +176,10 @@ APZCTreeManager::APZCTreeManager() mApzcTreeLog("apzctree") { RefPtr self(this); - NS_DispatchToMainThread(NS_NewRunnableFunction([self] { - self->mFlushObserver = new CheckerboardFlushObserver(self); - })); + NS_DispatchToMainThread( + NS_NewRunnableFunction("layers::APZCTreeManager::APZCTreeManager", [self] { + self->mFlushObserver = new CheckerboardFlushObserver(self); + })); AsyncPanZoomController::InitializeGlobalState(); mApzcTreeLog.ConditionOnPrefFunction(gfxPrefs::APZPrintTree); #if defined(MOZ_WIDGET_ANDROID) @@ -854,8 +855,10 @@ APZCTreeManager::FlushApzRepaints(uint64_t aLayersId) const LayerTreeState* state = CompositorBridgeParent::GetIndirectShadowTree(aLayersId); MOZ_ASSERT(state && state->mController); - state->mController->DispatchToRepaintThread(NewRunnableMethod( - state->mController, &GeckoContentController::NotifyFlushComplete)); + state->mController->DispatchToRepaintThread( + NewRunnableMethod("layers::GeckoContentController::NotifyFlushComplete", + state->mController, + &GeckoContentController::NotifyFlushComplete)); } nsEventStatus @@ -1580,7 +1583,8 @@ 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. - APZThreadUtils::RunOnControllerThread(NewRunnableMethod(mInputQueue, &InputQueue::Clear)); + APZThreadUtils::RunOnControllerThread(NewRunnableMethod( + "layers::InputQueue::Clear", mInputQueue, &InputQueue::Clear)); MutexAutoLock lock(mTreeLock); @@ -1601,10 +1605,11 @@ APZCTreeManager::ClearTree() mRootNode = nullptr; RefPtr self(this); - NS_DispatchToMainThread(NS_NewRunnableFunction([self] { - self->mFlushObserver->Unregister(); - self->mFlushObserver = nullptr; - })); + NS_DispatchToMainThread( + NS_NewRunnableFunction("layers::APZCTreeManager::ClearTree", [self] { + self->mFlushObserver->Unregister(); + self->mFlushObserver = nullptr; + })); } RefPtr diff --git a/gfx/layers/apz/src/AndroidAPZ.cpp b/gfx/layers/apz/src/AndroidAPZ.cpp index da8b89a3e052..1b43962f4d65 100644 --- a/gfx/layers/apz/src/AndroidAPZ.cpp +++ b/gfx/layers/apz/src/AndroidAPZ.cpp @@ -245,7 +245,8 @@ AndroidFlingAnimation::DeferHandleFlingOverscroll(ParentLayerPoint& aVelocity) mDeferredTasks.AppendElement( NewRunnableMethod, - RefPtr>(&mApzc, + RefPtr>("layers::AsyncPanZoomController::HandleFlingOverscroll", + &mApzc, &AsyncPanZoomController::HandleFlingOverscroll, aVelocity, mOverscrollHandoffChain, diff --git a/gfx/layers/apz/src/AndroidDynamicToolbarAnimator.cpp b/gfx/layers/apz/src/AndroidDynamicToolbarAnimator.cpp index 08548f5980df..5c88e54e3fa3 100644 --- a/gfx/layers/apz/src/AndroidDynamicToolbarAnimator.cpp +++ b/gfx/layers/apz/src/AndroidDynamicToolbarAnimator.cpp @@ -536,7 +536,8 @@ AndroidDynamicToolbarAnimator::GetToolbarEffect(CompositorOGL* gl) // Send notification that texture is ready after the current composition has completed. if (mCompositorToolbarTexture && mCompositorSendResponseForSnapshotUpdate) { mCompositorSendResponseForSnapshotUpdate = false; - CompositorThreadHolder::Loop()->PostTask(NewRunnableMethod(this, &AndroidDynamicToolbarAnimator::PostToolbarReady)); + CompositorThreadHolder::Loop()->PostTask(NewRunnableMethod("AndroidDynamicToolbarAnimator::PostToolbarReady", + this, &AndroidDynamicToolbarAnimator::PostToolbarReady)); } } @@ -746,7 +747,8 @@ void AndroidDynamicToolbarAnimator::UpdateCompositorToolbarHeight(ScreenIntCoord aHeight) { if (!CompositorThreadHolder::IsInCompositorThread()) { - CompositorThreadHolder::Loop()->PostTask(NewRunnableMethod(this, &AndroidDynamicToolbarAnimator::UpdateCompositorToolbarHeight, aHeight)); + CompositorThreadHolder::Loop()->PostTask(NewRunnableMethod("AndroidDynamicToolbarAnimator::UpdateCompositorToolbarHeight", + this, &AndroidDynamicToolbarAnimator::UpdateCompositorToolbarHeight, aHeight)); return; } @@ -758,7 +760,8 @@ void AndroidDynamicToolbarAnimator::UpdateControllerToolbarHeight(ScreenIntCoord aHeight, ScreenIntCoord aMaxHeight) { if (!APZThreadUtils::IsControllerThread()) { - APZThreadUtils::RunOnControllerThread(NewRunnableMethod(this, &AndroidDynamicToolbarAnimator::UpdateControllerToolbarHeight, aHeight, aMaxHeight)); + APZThreadUtils::RunOnControllerThread(NewRunnableMethod("AndroidDynamicToolbarAnimator::UpdateControllerToolbarHeight", + this, &AndroidDynamicToolbarAnimator::UpdateControllerToolbarHeight, aHeight, aMaxHeight)); return; } @@ -772,7 +775,8 @@ void AndroidDynamicToolbarAnimator::UpdateControllerSurfaceHeight(ScreenIntCoord aHeight) { if (!APZThreadUtils::IsControllerThread()) { - APZThreadUtils::RunOnControllerThread(NewRunnableMethod(this, &AndroidDynamicToolbarAnimator::UpdateControllerSurfaceHeight, aHeight)); + APZThreadUtils::RunOnControllerThread(NewRunnableMethod("AndroidDynamicToolbarAnimator::UpdateControllerSurfaceHeight", + this, &AndroidDynamicToolbarAnimator::UpdateControllerSurfaceHeight, aHeight)); return; } @@ -783,7 +787,8 @@ void AndroidDynamicToolbarAnimator::UpdateControllerCompositionHeight(ScreenIntCoord aHeight) { if (!APZThreadUtils::IsControllerThread()) { - APZThreadUtils::RunOnControllerThread(NewRunnableMethod(this, &AndroidDynamicToolbarAnimator::UpdateControllerCompositionHeight, aHeight)); + APZThreadUtils::RunOnControllerThread(NewRunnableMethod("AndroidDynamicToolbarAnimator::UpdateControllerCompositionHeight", + this, &AndroidDynamicToolbarAnimator::UpdateControllerCompositionHeight, aHeight)); return; } @@ -820,7 +825,8 @@ void AndroidDynamicToolbarAnimator::NotifyControllerPendingAnimation(int32_t aDirection, AnimationStyle aAnimationStyle) { if (!APZThreadUtils::IsControllerThread()) { - APZThreadUtils::RunOnControllerThread(NewRunnableMethod(this, &AndroidDynamicToolbarAnimator::NotifyControllerPendingAnimation, aDirection, aAnimationStyle)); + APZThreadUtils::RunOnControllerThread(NewRunnableMethod("AndroidDynamicToolbarAnimator::NotifyControllerPendingAnimation", + this, &AndroidDynamicToolbarAnimator::NotifyControllerPendingAnimation, aDirection, aAnimationStyle)); return; } @@ -847,6 +853,7 @@ AndroidDynamicToolbarAnimator::StartCompositorAnimation(int32_t aDirection, Anim if (!CompositorThreadHolder::IsInCompositorThread()) { mControllerState = eAnimationStartPending; CompositorThreadHolder::Loop()->PostTask(NewRunnableMethod( + "AndroidDynamicToolbarAnimator::StartCompositorAnimation", this, &AndroidDynamicToolbarAnimator::StartCompositorAnimation, aDirection, aAnimationStyle, aHeight, aWaitForPageResize)); return; } @@ -889,7 +896,8 @@ void AndroidDynamicToolbarAnimator::NotifyControllerAnimationStarted() { if (!APZThreadUtils::IsControllerThread()) { - APZThreadUtils::RunOnControllerThread(NewRunnableMethod(this, &AndroidDynamicToolbarAnimator::NotifyControllerAnimationStarted)); + APZThreadUtils::RunOnControllerThread(NewRunnableMethod("AndroidDynamicToolbarAnimator::NotifyControllerAnimationStarted", + this, &AndroidDynamicToolbarAnimator::NotifyControllerAnimationStarted)); return; } @@ -905,7 +913,8 @@ AndroidDynamicToolbarAnimator::StopCompositorAnimation() { if (!CompositorThreadHolder::IsInCompositorThread()) { mControllerState = eAnimationStopPending; - CompositorThreadHolder::Loop()->PostTask(NewRunnableMethod(this, &AndroidDynamicToolbarAnimator::StopCompositorAnimation)); + CompositorThreadHolder::Loop()->PostTask(NewRunnableMethod("AndroidDynamicToolbarAnimator::StopCompositorAnimation", + this, &AndroidDynamicToolbarAnimator::StopCompositorAnimation)); return; } @@ -931,7 +940,8 @@ void AndroidDynamicToolbarAnimator::NotifyControllerAnimationStopped(ScreenIntCoord aHeight) { if (!APZThreadUtils::IsControllerThread()) { - APZThreadUtils::RunOnControllerThread(NewRunnableMethod(this, &AndroidDynamicToolbarAnimator::NotifyControllerAnimationStopped, aHeight)); + APZThreadUtils::RunOnControllerThread(NewRunnableMethod("AndroidDynamicToolbarAnimator::NotifyControllerAnimationStopped", + this, &AndroidDynamicToolbarAnimator::NotifyControllerAnimationStopped, aHeight)); return; } @@ -946,7 +956,8 @@ void AndroidDynamicToolbarAnimator::RequestComposite() { if (!CompositorThreadHolder::IsInCompositorThread()) { - CompositorThreadHolder::Loop()->PostTask(NewRunnableMethod(this, &AndroidDynamicToolbarAnimator::RequestComposite)); + CompositorThreadHolder::Loop()->PostTask(NewRunnableMethod("AndroidDynamicToolbarAnimator::RequestComposite", + this, &AndroidDynamicToolbarAnimator::RequestComposite)); return; } @@ -993,7 +1004,8 @@ AndroidDynamicToolbarAnimator::UpdateFrameMetrics(ScreenPoint aScrollOffset, CSSRect aCssPageRect) { if (!APZThreadUtils::IsControllerThread()) { - APZThreadUtils::RunOnControllerThread(NewRunnableMethod(this, &AndroidDynamicToolbarAnimator::UpdateFrameMetrics, aScrollOffset, aScale, aCssPageRect)); + APZThreadUtils::RunOnControllerThread(NewRunnableMethod("AndroidDynamicToolbarAnimator::UpdateFrameMetrics", + this, &AndroidDynamicToolbarAnimator::UpdateFrameMetrics, aScrollOffset, aScale, aCssPageRect)); return; } @@ -1011,6 +1023,7 @@ AndroidDynamicToolbarAnimator::UpdateFrameMetrics(ScreenPoint aScrollOffset, RefPtr uiController = UiCompositorControllerParent::GetFromRootLayerTreeId(mRootLayerTreeId); MOZ_ASSERT(uiController); CompositorThreadHolder::Loop()->PostTask(NewRunnableMethod( + "UiCompositorControllerParent::SendRootFrameMetrics", uiController, &UiCompositorControllerParent::SendRootFrameMetrics, aScrollOffset, aScale, aCssPageRect)); } @@ -1086,7 +1099,8 @@ void AndroidDynamicToolbarAnimator::NotifyControllerSnapshotFailed() { if (!APZThreadUtils::IsControllerThread()) { - APZThreadUtils::RunOnControllerThread(NewRunnableMethod(this, &AndroidDynamicToolbarAnimator::NotifyControllerSnapshotFailed)); + APZThreadUtils::RunOnControllerThread(NewRunnableMethod("AndroidDynamicToolbarAnimator::NotifyControllerSnapshotFailed", + this, &AndroidDynamicToolbarAnimator::NotifyControllerSnapshotFailed)); return; } @@ -1133,7 +1147,8 @@ void AndroidDynamicToolbarAnimator::QueueMessage(int32_t aMessage) { if (!CompositorThreadHolder::IsInCompositorThread()) { - CompositorThreadHolder::Loop()->PostTask(NewRunnableMethod(this, &AndroidDynamicToolbarAnimator::QueueMessage, aMessage)); + CompositorThreadHolder::Loop()->PostTask(NewRunnableMethod("AndroidDynamicToolbarAnimator::QueueMessage", + this, &AndroidDynamicToolbarAnimator::QueueMessage, aMessage)); return; } diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index 0c049d5bb2b0..33261aaccd8d 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -636,10 +636,11 @@ public: // HandleSmoothScrollOverscroll() (which acquires the tree lock) would violate // the lock ordering. Instead we schedule HandleSmoothScrollOverscroll() to be // called after mMonitor is released. - mDeferredTasks.AppendElement( - NewRunnableMethod(&mApzc, - &AsyncPanZoomController::HandleSmoothScrollOverscroll, - velocity)); + mDeferredTasks.AppendElement(NewRunnableMethod( + "layers::AsyncPanZoomController::HandleSmoothScrollOverscroll", + &mApzc, + &AsyncPanZoomController::HandleSmoothScrollOverscroll, + velocity)); return false; } @@ -1383,8 +1384,11 @@ nsEventStatus AsyncPanZoomController::OnScale(const PinchGestureInput& aEvent) { if (RefPtr controller = GetGeckoContentController()) { mPinchPaintTimerSet = true; controller->PostDelayedTask( - NewRunnableMethod(this, - &AsyncPanZoomController::DoDelayedRequestContentRepaint), + NewRunnableMethod( + "layers::AsyncPanZoomController::" + "DoDelayedRequestContentRepaint", + this, + &AsyncPanZoomController::DoDelayedRequestContentRepaint), delay); } } @@ -2114,12 +2118,18 @@ nsEventStatus AsyncPanZoomController::GenerateSingleTap(TapType aType, // 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 = - NewRunnableMethod(controller, - &GeckoContentController::HandleTap, - aType, geckoScreenPoint, - aModifiers, GetGuid(), - touch ? touch->GetBlockId() : 0); + NewRunnableMethod("layers::GeckoContentController::HandleTap", + controller, + &GeckoContentController::HandleTap, + aType, + geckoScreenPoint, + aModifiers, + GetGuid(), + touch ? touch->GetBlockId() : 0); controller->PostDelayedTask(runnable.forget(), 0); return nsEventStatus_eConsumeNoDefault; @@ -2966,7 +2976,11 @@ void AsyncPanZoomController::RequestContentRepaint(bool aUserAction) { // use the local variable to resolve the function overload. auto func = static_cast (&AsyncPanZoomController::RequestContentRepaint); - controller->DispatchToRepaintThread(NewRunnableMethod(this, func, aUserAction)); + controller->DispatchToRepaintThread(NewRunnableMethod( + "layers::AsyncPanZoomController::RequestContentRepaint", + this, + func, + aUserAction)); return; } @@ -3750,8 +3764,12 @@ void AsyncPanZoomController::ZoomToRect(CSSRect aRect, const uint32_t aFlags) { auto func = static_cast (&AsyncPanZoomController::RequestContentRepaint); controller->DispatchToRepaintThread( - NewRunnableMethod( - this, func, endZoomToMetrics, velocity)); + NewRunnableMethod( + "layers::AsyncPanZoomController::ZoomToRect", + this, + func, + endZoomToMetrics, + velocity)); } } } diff --git a/gfx/layers/apz/src/GenericFlingAnimation.h b/gfx/layers/apz/src/GenericFlingAnimation.h index 930937c4551a..a3c9b3454f59 100644 --- a/gfx/layers/apz/src/GenericFlingAnimation.h +++ b/gfx/layers/apz/src/GenericFlingAnimation.h @@ -111,10 +111,11 @@ public: // while holding mMonitor, because otherwise, if the overscrolled APZC // is this one, then the SetState(NOTHING) in UpdateAnimation will // stomp on the SetState(SNAP_BACK) it does. - mDeferredTasks.AppendElement( - NewRunnableMethod(mOverscrollHandoffChain.get(), - &OverscrollHandoffChain::SnapBackOverscrolledApzc, - &mApzc)); + mDeferredTasks.AppendElement(NewRunnableMethod( + "layers::OverscrollHandoffChain::SnapBackOverscrolledApzc", + mOverscrollHandoffChain.get(), + &OverscrollHandoffChain::SnapBackOverscrolledApzc, + &mApzc)); return false; } @@ -164,13 +165,15 @@ public: // called after mMonitor is released. FLING_LOG("%p fling went into overscroll, handing off with velocity %s\n", &mApzc, Stringify(velocity).c_str()); mDeferredTasks.AppendElement( - NewRunnableMethod, - RefPtr>(&mApzc, - &AsyncPanZoomController::HandleFlingOverscroll, - velocity, - mOverscrollHandoffChain, - mScrolledApzc)); + NewRunnableMethod, + RefPtr>( + "layers::AsyncPanZoomController::HandleFlingOverscroll", + &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.) diff --git a/gfx/layers/apz/src/GestureEventListener.cpp b/gfx/layers/apz/src/GestureEventListener.cpp index b9efbb26e270..4b162fbee2ce 100644 --- a/gfx/layers/apz/src/GestureEventListener.cpp +++ b/gfx/layers/apz/src/GestureEventListener.cpp @@ -595,8 +595,10 @@ void GestureEventListener::CancelLongTapTimeoutTask() void GestureEventListener::CreateLongTapTimeoutTask() { - RefPtr task = - NewCancelableRunnableMethod(this, &GestureEventListener::HandleInputTimeoutLongTap); + RefPtr task = NewCancelableRunnableMethod( + "layers::GestureEventListener::HandleInputTimeoutLongTap", + this, + &GestureEventListener::HandleInputTimeoutLongTap); mLongTapTimeoutTask = task; mAsyncPanZoomController->PostDelayedTask( @@ -623,10 +625,11 @@ void GestureEventListener::CreateMaxTapTimeoutTask() TouchBlockState* block = mAsyncPanZoomController->GetInputQueue()->GetCurrentTouchBlock(); MOZ_ASSERT(block); - RefPtr task = - NewCancelableRunnableMethod(this, - &GestureEventListener::HandleInputTimeoutMaxTap, - block->IsDuringFastFling()); + RefPtr task = NewCancelableRunnableMethod( + "layers::GestureEventListener::HandleInputTimeoutMaxTap", + 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 8c9b222adefb..aead4f0bd771 100644 --- a/gfx/layers/apz/src/InputQueue.cpp +++ b/gfx/layers/apz/src/InputQueue.cpp @@ -509,10 +509,12 @@ InputQueue::ScheduleMainThreadTimeout(const RefPtr& aTar CancelableBlockState* aBlock) { INPQ_LOG("scheduling main thread timeout for target %p\n", aTarget.get()); aBlock->StartContentResponseTimer(); - aTarget->PostDelayedTask(NewRunnableMethod(this, - &InputQueue::MainThreadTimeout, - aBlock->GetBlockId()), - gfxPrefs::APZContentResponseTimeout()); + aTarget->PostDelayedTask( + NewRunnableMethod("layers::InputQueue::MainThreadTimeout", + this, + &InputQueue::MainThreadTimeout, + aBlock->GetBlockId()), + gfxPrefs::APZContentResponseTimeout()); } CancelableBlockState* diff --git a/gfx/layers/apz/src/Overscroll.h b/gfx/layers/apz/src/Overscroll.h index 586f104cc227..d620db28f271 100644 --- a/gfx/layers/apz/src/Overscroll.h +++ b/gfx/layers/apz/src/Overscroll.h @@ -48,7 +48,10 @@ 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(NewRunnableMethod(&mApzc, &AsyncPanZoomController::ScrollSnap)); + mDeferredTasks.AppendElement( + NewRunnableMethod("layers::AsyncPanZoomController::ScrollSnap", + &mApzc, + &AsyncPanZoomController::ScrollSnap)); return false; } return true; diff --git a/gfx/layers/apz/util/ActiveElementManager.cpp b/gfx/layers/apz/util/ActiveElementManager.cpp index 20d34aa2bb1a..e7c3bc3afa8e 100644 --- a/gfx/layers/apz/util/ActiveElementManager.cpp +++ b/gfx/layers/apz/util/ActiveElementManager.cpp @@ -95,9 +95,11 @@ ActiveElementManager::TriggerElementActivation() MOZ_ASSERT(mSetActiveTask == nullptr); RefPtr task = - NewCancelableRunnableMethod>(this, - &ActiveElementManager::SetActiveTask, - mTarget); + NewCancelableRunnableMethod>( + "layers::ActiveElementManager::SetActiveTask", + 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/CheckerboardReportService.cpp b/gfx/layers/apz/util/CheckerboardReportService.cpp index 7e4a9d93e1d1..a8c89152ef25 100644 --- a/gfx/layers/apz/util/CheckerboardReportService.cpp +++ b/gfx/layers/apz/util/CheckerboardReportService.cpp @@ -42,9 +42,10 @@ void CheckerboardEventStorage::Report(uint32_t aSeverity, const std::string& aLog) { if (!NS_IsMainThread()) { - RefPtr task = NS_NewRunnableFunction([aSeverity, aLog] () -> void { - CheckerboardEventStorage::Report(aSeverity, aLog); - }); + RefPtr task = NS_NewRunnableFunction( + "layers::CheckerboardEventStorage::Report", [aSeverity, aLog]() -> void { + CheckerboardEventStorage::Report(aSeverity, aLog); + }); NS_DispatchToMainThread(task.forget()); return; } diff --git a/gfx/layers/apz/util/ChromeProcessController.cpp b/gfx/layers/apz/util/ChromeProcessController.cpp index 22f597bc020b..dc4a6ddbaaa8 100644 --- a/gfx/layers/apz/util/ChromeProcessController.cpp +++ b/gfx/layers/apz/util/ChromeProcessController.cpp @@ -36,7 +36,10 @@ ChromeProcessController::ChromeProcessController(nsIWidget* aWidget, MOZ_ASSERT(aAPZEventState); MOZ_ASSERT(aAPZCTreeManager); - mUILoop->PostTask(NewRunnableMethod(this, &ChromeProcessController::InitializeRoot)); + mUILoop->PostTask( + NewRunnableMethod("layers::ChromeProcessController::InitializeRoot", + this, + &ChromeProcessController::InitializeRoot)); } ChromeProcessController::~ChromeProcessController() {} @@ -82,7 +85,10 @@ void ChromeProcessController::Destroy() { if (MessageLoop::current() != mUILoop) { - mUILoop->PostTask(NewRunnableMethod(this, &ChromeProcessController::Destroy)); + mUILoop->PostTask( + NewRunnableMethod("layers::ChromeProcessController::Destroy", + this, + &ChromeProcessController::Destroy)); return; } @@ -164,10 +170,19 @@ ChromeProcessController::HandleTap(TapType aType, uint64_t aInputBlockId) { if (MessageLoop::current() != mUILoop) { - mUILoop->PostTask(NewRunnableMethod(this, - &ChromeProcessController::HandleTap, - aType, aPoint, aModifiers, aGuid, aInputBlockId)); + mUILoop->PostTask( + NewRunnableMethod("layers::ChromeProcessController::HandleTap", + this, + &ChromeProcessController::HandleTap, + aType, + aPoint, + aModifiers, + aGuid, + aInputBlockId)); return; } @@ -217,13 +232,17 @@ ChromeProcessController::NotifyPinchGesture(PinchGestureInput::PinchGestureType Modifiers aModifiers) { if (MessageLoop::current() != mUILoop) { - mUILoop->PostTask(NewRunnableMethod - (this, - &ChromeProcessController::NotifyPinchGesture, - aType, aGuid, aSpanChange, aModifiers)); + mUILoop->PostTask(NewRunnableMethod( + "layers::ChromeProcessController::NotifyPinchGesture", + this, + &ChromeProcessController::NotifyPinchGesture, + aType, + aGuid, + aSpanChange, + aModifiers)); return; } @@ -238,11 +257,14 @@ ChromeProcessController::NotifyAPZStateChange(const ScrollableLayerGuid& aGuid, int aArg) { if (MessageLoop::current() != mUILoop) { - mUILoop->PostTask(NewRunnableMethod - (this, &ChromeProcessController::NotifyAPZStateChange, - aGuid, aChange, aArg)); + mUILoop->PostTask( + NewRunnableMethod( + "layers::ChromeProcessController::NotifyAPZStateChange", + this, + &ChromeProcessController::NotifyAPZStateChange, + aGuid, + aChange, + aArg)); return; } @@ -257,10 +279,12 @@ void ChromeProcessController::NotifyMozMouseScrollEvent(const FrameMetrics::ViewID& aScrollId, const nsString& aEvent) { if (MessageLoop::current() != mUILoop) { - mUILoop->PostTask(NewRunnableMethod - (this, &ChromeProcessController::NotifyMozMouseScrollEvent, - aScrollId, aEvent)); + mUILoop->PostTask(NewRunnableMethod( + "layers::ChromeProcessController::NotifyMozMouseScrollEvent", + this, + &ChromeProcessController::NotifyMozMouseScrollEvent, + aScrollId, + aEvent)); return; } @@ -279,9 +303,11 @@ void ChromeProcessController::NotifyAsyncScrollbarDragRejected(const FrameMetrics::ViewID& aScrollId) { if (MessageLoop::current() != mUILoop) { - mUILoop->PostTask(NewRunnableMethod(this, - &ChromeProcessController::NotifyAsyncScrollbarDragRejected, - aScrollId)); + mUILoop->PostTask(NewRunnableMethod( + "layers::ChromeProcessController::NotifyAsyncScrollbarDragRejected", + this, + &ChromeProcessController::NotifyAsyncScrollbarDragRejected, + aScrollId)); return; } diff --git a/gfx/layers/basic/BasicCompositor.cpp b/gfx/layers/basic/BasicCompositor.cpp index 71633c2c00a3..68003d99aa4a 100644 --- a/gfx/layers/basic/BasicCompositor.cpp +++ b/gfx/layers/basic/BasicCompositor.cpp @@ -1027,9 +1027,9 @@ BasicCompositor::TryToEndRemoteDrawing(bool aForceToEnd) const uint32_t retryMs = 2; RefPtr self = this; - RefPtr runnable = NS_NewRunnableFunction([self]() { - self->TryToEndRemoteDrawing(); - }); + RefPtr runnable = + NS_NewRunnableFunction("layers::BasicCompositor::TryToEndRemoteDrawing", + [self]() { self->TryToEndRemoteDrawing(); }); MessageLoop::current()->PostDelayedTask(runnable.forget(), retryMs); return; } diff --git a/gfx/layers/client/CompositableClient.cpp b/gfx/layers/client/CompositableClient.cpp index 785cd8d59067..cedcc176b6ee 100644 --- a/gfx/layers/client/CompositableClient.cpp +++ b/gfx/layers/client/CompositableClient.cpp @@ -194,8 +194,8 @@ CompositableClient::GetTextureClientRecycler() ReentrantMonitorAutoEnter mainThreadAutoMon(barrier); bool done = false; - RefPtr runnable = - NS_NewRunnableFunction([&]() { + RefPtr runnable = NS_NewRunnableFunction( + "layers::CompositableClient::GetTextureClientRecycler", [&]() { if (!mTextureClientRecycler) { mTextureClientRecycler = new layers::TextureClientRecycleAllocator(mForwarder); } diff --git a/gfx/layers/client/TextureClient.cpp b/gfx/layers/client/TextureClient.cpp index 0989c5a4633a..666e3a033d11 100644 --- a/gfx/layers/client/TextureClient.cpp +++ b/gfx/layers/client/TextureClient.cpp @@ -234,9 +234,11 @@ static void DestroyTextureData(TextureData* aTextureData, LayersIPCChannel* aAll if (aMainThreadOnly && !NS_IsMainThread()) { RefPtr allocatorRef = aAllocator; - NS_DispatchToMainThread(NS_NewRunnableFunction([aTextureData, allocatorRef, aDeallocate]() -> void { - DestroyTextureData(aTextureData, allocatorRef, aDeallocate, true); - })); + NS_DispatchToMainThread(NS_NewRunnableFunction( + "layers::DestroyTextureData", + [aTextureData, allocatorRef, aDeallocate]() -> void { + DestroyTextureData(aTextureData, allocatorRef, aDeallocate, true); + })); return; } diff --git a/gfx/layers/client/TextureClient.h b/gfx/layers/client/TextureClient.h index edea3e076204..68f8fb8483e6 100644 --- a/gfx/layers/client/TextureClient.h +++ b/gfx/layers/client/TextureClient.h @@ -776,8 +776,10 @@ public: class TextureClientReleaseTask : public Runnable { public: - explicit TextureClientReleaseTask(TextureClient* aClient) - : mTextureClient(aClient) { + explicit TextureClientReleaseTask(TextureClient* aClient) + : Runnable("layers::TextureClientReleaseTask") + , mTextureClient(aClient) + { } NS_IMETHOD Run() override diff --git a/gfx/layers/client/TextureClientPool.cpp b/gfx/layers/client/TextureClientPool.cpp index f7ccad92d02f..0f7aab8185e7 100644 --- a/gfx/layers/client/TextureClientPool.cpp +++ b/gfx/layers/client/TextureClientPool.cpp @@ -179,15 +179,23 @@ TextureClientPool::ResetTimers() if (mShrinkTimeoutMsec && mTextureClients.size() + mTextureClientsDeferred.size() > mPoolUnusedSize) { TCP_LOG("TexturePool %p scheduling a shrink-to-max-size\n", this); - mShrinkTimer->InitWithFuncCallback(ShrinkCallback, this, mShrinkTimeoutMsec, - nsITimer::TYPE_ONE_SHOT); + mShrinkTimer->InitWithNamedFuncCallback( + ShrinkCallback, + this, + mShrinkTimeoutMsec, + nsITimer::TYPE_ONE_SHOT, + "layers::TextureClientPool::ResetTimers"); } // Clear pool after a period of inactivity to reduce memory consumption if (mClearTimeoutMsec) { TCP_LOG("TexturePool %p scheduling a clear\n", this); - mClearTimer->InitWithFuncCallback(ClearCallback, this, mClearTimeoutMsec, - nsITimer::TYPE_ONE_SHOT); + mClearTimer->InitWithNamedFuncCallback( + ClearCallback, + this, + mClearTimeoutMsec, + nsITimer::TYPE_ONE_SHOT, + "layers::TextureClientPool::ResetTimers"); } } diff --git a/gfx/layers/d3d11/DeviceAttachmentsD3D11.cpp b/gfx/layers/d3d11/DeviceAttachmentsD3D11.cpp index 80f0e937f28d..44199395914f 100644 --- a/gfx/layers/d3d11/DeviceAttachmentsD3D11.cpp +++ b/gfx/layers/d3d11/DeviceAttachmentsD3D11.cpp @@ -247,7 +247,8 @@ DeviceAttachmentsD3D11::InitSyncObject() if (FAILED(hr) || !mSyncHandle) { gfxCriticalError() << "Failed to get SharedHandle for sync texture. Result: " << hexa(hr); - NS_DispatchToMainThread(NS_NewRunnableFunction([] () -> void { + NS_DispatchToMainThread(NS_NewRunnableFunction("DeviceAttachmentsD3D11::InitSyncObject", + [] () -> void { Accumulate(Telemetry::D3D11_SYNC_HANDLE_FAILURE, 1); })); return false; diff --git a/gfx/layers/ipc/APZCTreeManagerParent.cpp b/gfx/layers/ipc/APZCTreeManagerParent.cpp index 940cdf630f1d..4ac60b740092 100644 --- a/gfx/layers/ipc/APZCTreeManagerParent.cpp +++ b/gfx/layers/ipc/APZCTreeManagerParent.cpp @@ -165,11 +165,12 @@ APZCTreeManagerParent::RecvContentReceivedInputBlock( const uint64_t& aInputBlockId, const bool& aPreventDefault) { - APZThreadUtils::RunOnControllerThread( - NewRunnableMethod(mTreeManager, - &IAPZCTreeManager::ContentReceivedInputBlock, - aInputBlockId, - aPreventDefault)); + APZThreadUtils::RunOnControllerThread(NewRunnableMethod( + "layers::IAPZCTreeManager::ContentReceivedInputBlock", + mTreeManager, + &IAPZCTreeManager::ContentReceivedInputBlock, + aInputBlockId, + aPreventDefault)); return IPC_OK(); } @@ -186,10 +187,14 @@ APZCTreeManagerParent::RecvSetTargetAPZC( return IPC_FAIL_NO_REASON(this); } } - APZThreadUtils::RunOnControllerThread(NewRunnableMethod - >> - (mTreeManager, &IAPZCTreeManager::SetTargetAPZC, aInputBlockId, aTargets)); + APZThreadUtils::RunOnControllerThread( + NewRunnableMethod>>( + "layers::IAPZCTreeManager::SetTargetAPZC", + mTreeManager, + &IAPZCTreeManager::SetTargetAPZC, + aInputBlockId, + aTargets)); return IPC_OK(); } @@ -234,12 +239,14 @@ APZCTreeManagerParent::RecvSetAllowedTouchBehavior( const uint64_t& aInputBlockId, nsTArray&& aValues) { - APZThreadUtils::RunOnControllerThread(NewRunnableMethod - >> - (mTreeManager, - &IAPZCTreeManager::SetAllowedTouchBehavior, - aInputBlockId, Move(aValues))); + APZThreadUtils::RunOnControllerThread( + NewRunnableMethod>>( + "layers::IAPZCTreeManager::SetAllowedTouchBehavior", + mTreeManager, + &IAPZCTreeManager::SetAllowedTouchBehavior, + aInputBlockId, + Move(aValues))); return IPC_OK(); } @@ -255,11 +262,13 @@ APZCTreeManagerParent::RecvStartScrollbarDrag( return IPC_FAIL_NO_REASON(this); } - APZThreadUtils::RunOnControllerThread( - NewRunnableMethod( - mTreeManager, - &IAPZCTreeManager::StartScrollbarDrag, - aGuid, aDragMetrics)); + APZThreadUtils::RunOnControllerThread( + NewRunnableMethod( + "layers::IAPZCTreeManager::StartScrollbarDrag", + mTreeManager, + &IAPZCTreeManager::StartScrollbarDrag, + aGuid, + aDragMetrics)); return IPC_OK(); } diff --git a/gfx/layers/ipc/CompositorBridgeChild.cpp b/gfx/layers/ipc/CompositorBridgeChild.cpp index 1f1dd9b72775..59115d80665d 100644 --- a/gfx/layers/ipc/CompositorBridgeChild.cpp +++ b/gfx/layers/ipc/CompositorBridgeChild.cpp @@ -463,6 +463,7 @@ static void ScheduleSendAllPluginsCaptured(CompositorBridgeChild* aThis, MessageLoop* aLoop) { aLoop->PostTask(NewNonOwningRunnableMethod( + "CompositorBridgeChild::SendAllPluginsCaptured", aThis, &CompositorBridgeChild::SendAllPluginsCaptured)); } #endif diff --git a/gfx/layers/ipc/CompositorBridgeParent.cpp b/gfx/layers/ipc/CompositorBridgeParent.cpp index 0ae259c98ff5..56dd91096715 100644 --- a/gfx/layers/ipc/CompositorBridgeParent.cpp +++ b/gfx/layers/ipc/CompositorBridgeParent.cpp @@ -667,21 +667,30 @@ CompositorBridgeParent::ActorDestroy(ActorDestroyReason why) // We must keep the compositor parent alive untill the code handling message // reception is finished on this thread. mSelfRef = this; - MessageLoop::current()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::DeferredDestroy)); + MessageLoop::current()->PostTask( + NewRunnableMethod("layers::CompositorBridgeParent::DeferredDestroy", + this, + &CompositorBridgeParent::DeferredDestroy)); } void CompositorBridgeParent::ScheduleRenderOnCompositorThread() { MOZ_ASSERT(CompositorLoop()); - CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::ScheduleComposition)); + CompositorLoop()->PostTask( + NewRunnableMethod("layers::CompositorBridgeParent::ScheduleComposition", + this, + &CompositorBridgeParent::ScheduleComposition)); } void CompositorBridgeParent::InvalidateOnCompositorThread() { MOZ_ASSERT(CompositorLoop()); - CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::Invalidate)); + CompositorLoop()->PostTask( + NewRunnableMethod("layers::CompositorBridgeParent::Invalidate", + this, + &CompositorBridgeParent::Invalidate)); } void @@ -777,7 +786,10 @@ CompositorBridgeParent::SchedulePauseOnCompositorThread() MonitorAutoLock lock(mPauseCompositionMonitor); MOZ_ASSERT(CompositorLoop()); - CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::PauseComposition)); + CompositorLoop()->PostTask( + NewRunnableMethod("layers::CompositorBridgeParent::PauseComposition", + this, + &CompositorBridgeParent::PauseComposition)); // Wait until the pause has actually been processed by the compositor thread lock.Wait(); @@ -789,7 +801,10 @@ CompositorBridgeParent::ScheduleResumeOnCompositorThread() MonitorAutoLock lock(mResumeCompositionMonitor); MOZ_ASSERT(CompositorLoop()); - CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::ResumeComposition)); + CompositorLoop()->PostTask( + NewRunnableMethod("layers::CompositorBridgeParent::ResumeComposition", + this, + &CompositorBridgeParent::ResumeComposition)); // Wait until the resume has actually been processed by the compositor thread lock.Wait(); @@ -803,10 +818,12 @@ CompositorBridgeParent::ScheduleResumeOnCompositorThread(int width, int height) MonitorAutoLock lock(mResumeCompositionMonitor); MOZ_ASSERT(CompositorLoop()); - CompositorLoop()->PostTask(NewRunnableMethod - (this, - &CompositorBridgeParent::ResumeCompositionAndResize, - width, height)); + CompositorLoop()->PostTask(NewRunnableMethod( + "layers::CompositorBridgeParent::ResumeCompositionAndResize", + this, + &CompositorBridgeParent::ResumeCompositionAndResize, + width, + height)); // Wait until the resume has actually been processed by the compositor thread lock.Wait(); @@ -1182,8 +1199,10 @@ CompositorBridgeParent::ScheduleRotationOnCompositorThread(const TargetConfig& a if (mForceCompositionTask != nullptr) { mForceCompositionTask->Cancel(); } - RefPtr task = - NewCancelableRunnableMethod(this, &CompositorBridgeParent::ForceComposition); + RefPtr task = NewCancelableRunnableMethod( + "layers::CompositorBridgeParent::ForceComposition", + this, + &CompositorBridgeParent::ForceComposition); mForceCompositionTask = task; ScheduleTask(task.forget(), gfxPrefs::OrientationSyncMillis()); } @@ -1333,9 +1352,9 @@ CompositorBridgeParent::FlushApzRepaints(const uint64_t& aLayersId) layersId = mRootLayerTreeID; } RefPtr self = this; - APZThreadUtils::RunOnControllerThread(NS_NewRunnableFunction([=] () { - self->mApzcTreeManager->FlushApzRepaints(layersId); - })); + APZThreadUtils::RunOnControllerThread(NS_NewRunnableFunction( + "layers::CompositorBridgeParent::FlushApzRepaints", + [=]() { self->mApzcTreeManager->FlushApzRepaints(layersId); })); } void @@ -1359,9 +1378,14 @@ CompositorBridgeParent::SetConfirmedTargetAPZC(const uint64_t& aLayersId, void (APZCTreeManager::*setTargetApzcFunc) (uint64_t, const nsTArray&) = &APZCTreeManager::SetTargetAPZC; - RefPtr task = NewRunnableMethod - >> - (mApzcTreeManager.get(), setTargetApzcFunc, aInputBlockId, aTargets); + RefPtr task = + NewRunnableMethod>>( + "layers::CompositorBridgeParent::SetConfirmedTargetAPZC", + mApzcTreeManager.get(), + setTargetApzcFunc, + aInputBlockId, + aTargets); APZThreadUtils::RunOnControllerThread(task.forget()); } @@ -2157,7 +2181,10 @@ void CompositorBridgeParent::ScheduleShowAllPluginWindows() { MOZ_ASSERT(CompositorLoop()); - CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::ShowAllPluginWindows)); + CompositorLoop()->PostTask( + NewRunnableMethod("layers::CompositorBridgeParent::ShowAllPluginWindows", + this, + &CompositorBridgeParent::ShowAllPluginWindows)); } void @@ -2172,7 +2199,10 @@ void CompositorBridgeParent::ScheduleHideAllPluginWindows() { MOZ_ASSERT(CompositorLoop()); - CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::HideAllPluginWindows)); + CompositorLoop()->PostTask( + NewRunnableMethod("layers::CompositorBridgeParent::HideAllPluginWindows", + this, + &CompositorBridgeParent::HideAllPluginWindows)); } void diff --git a/gfx/layers/ipc/CompositorManagerParent.cpp b/gfx/layers/ipc/CompositorManagerParent.cpp index 369839fe581d..f95da86256e5 100644 --- a/gfx/layers/ipc/CompositorManagerParent.cpp +++ b/gfx/layers/ipc/CompositorManagerParent.cpp @@ -57,6 +57,7 @@ CompositorManagerParent::Create(Endpoint&& aEndpoint) RefPtr bridge = new CompositorManagerParent(); RefPtr runnable = NewRunnableMethod&&>( + "CompositorManagerParent::Bind", bridge, &CompositorManagerParent::Bind, Move(aEndpoint)); diff --git a/gfx/layers/ipc/CompositorVsyncScheduler.cpp b/gfx/layers/ipc/CompositorVsyncScheduler.cpp index 40e913c2cc0f..829087efd1ee 100644 --- a/gfx/layers/ipc/CompositorVsyncScheduler.cpp +++ b/gfx/layers/ipc/CompositorVsyncScheduler.cpp @@ -122,9 +122,11 @@ CompositorVsyncScheduler::PostCompositeTask(TimeStamp aCompositeTimestamp) // can be called from the compositor or vsync thread MonitorAutoLock lock(mCurrentCompositeTaskMonitor); if (mCurrentCompositeTask == nullptr && CompositorThreadHolder::Loop()) { - RefPtr task = - NewCancelableRunnableMethod(this, &CompositorVsyncScheduler::Composite, - aCompositeTimestamp); + RefPtr task = NewCancelableRunnableMethod( + "layers::CompositorVsyncScheduler::Composite", + this, + &CompositorVsyncScheduler::Composite, + aCompositeTimestamp); mCurrentCompositeTask = task; ScheduleTask(task.forget(), 0); } @@ -181,8 +183,10 @@ CompositorVsyncScheduler::SetNeedsComposite() { if (!CompositorThreadHolder::IsInCompositorThread()) { MonitorAutoLock lock(mSetNeedsCompositeMonitor); - RefPtr task = - NewCancelableRunnableMethod(this, &CompositorVsyncScheduler::SetNeedsComposite); + RefPtr task = NewCancelableRunnableMethod( + "layers::CompositorVsyncScheduler::SetNeedsComposite", + this, + &CompositorVsyncScheduler::SetNeedsComposite); mSetNeedsCompositeTask = task; ScheduleTask(task.forget(), 0); return; diff --git a/gfx/layers/ipc/CrossProcessCompositorBridgeParent.cpp b/gfx/layers/ipc/CrossProcessCompositorBridgeParent.cpp index 18252c76e228..1887fc2333fc 100644 --- a/gfx/layers/ipc/CrossProcessCompositorBridgeParent.cpp +++ b/gfx/layers/ipc/CrossProcessCompositorBridgeParent.cpp @@ -58,7 +58,10 @@ CrossProcessCompositorBridgeParent::ActorDestroy(ActorDestroyReason aWhy) // We must keep this object alive untill the code handling message // reception is finished on this thread. - MessageLoop::current()->PostTask(NewRunnableMethod(this, &CrossProcessCompositorBridgeParent::DeferredDestroy)); + MessageLoop::current()->PostTask(NewRunnableMethod( + "layers::CrossProcessCompositorBridgeParent::DeferredDestroy", + this, + &CrossProcessCompositorBridgeParent::DeferredDestroy)); } PLayerTransactionParent* diff --git a/gfx/layers/ipc/ImageBridgeChild.cpp b/gfx/layers/ipc/ImageBridgeChild.cpp index ade05fb76773..48c357899159 100644 --- a/gfx/layers/ipc/ImageBridgeChild.cpp +++ b/gfx/layers/ipc/ImageBridgeChild.cpp @@ -578,6 +578,7 @@ ImageBridgeChild::InitForContent(Endpoint&& aEndpoint, uint32 RefPtr child = new ImageBridgeChild(aNamespace); RefPtr runnable = NewRunnableMethod&&>( + "layers::ImageBridgeChild::Bind", child, &ImageBridgeChild::Bind, Move(aEndpoint)); @@ -733,7 +734,10 @@ ImageBridgeChild::InitWithGPUProcess(Endpoint&& aEndpoint, ui MessageLoop* loop = child->GetMessageLoop(); loop->PostTask(NewRunnableMethod&&>( - child, &ImageBridgeChild::Bind, Move(aEndpoint))); + "layers::ImageBridgeChild::Bind", + child, + &ImageBridgeChild::Bind, + Move(aEndpoint))); // Assign this after so other threads can't post messages before we connect to IPDL. { diff --git a/gfx/layers/ipc/ImageBridgeParent.cpp b/gfx/layers/ipc/ImageBridgeParent.cpp index 3dc62d69e967..6553075d37ed 100644 --- a/gfx/layers/ipc/ImageBridgeParent.cpp +++ b/gfx/layers/ipc/ImageBridgeParent.cpp @@ -106,7 +106,10 @@ ImageBridgeParent::CreateForGPUProcess(Endpoint&& aEndpoint) RefPtr parent = new ImageBridgeParent(loop, aEndpoint.OtherPid()); loop->PostTask(NewRunnableMethod&&>( - parent, &ImageBridgeParent::Bind, Move(aEndpoint))); + "layers::ImageBridgeParent::Bind", + parent, + &ImageBridgeParent::Bind, + Move(aEndpoint))); sImageBridgeParentSingleton = parent; return true; @@ -122,7 +125,10 @@ ImageBridgeParent::ActorDestroy(ActorDestroyReason aWhy) MonitorAutoLock lock(*sImageBridgesLock); sImageBridges.erase(OtherPid()); } - MessageLoop::current()->PostTask(NewRunnableMethod(this, &ImageBridgeParent::DeferredDestroy)); + MessageLoop::current()->PostTask( + NewRunnableMethod("layers::ImageBridgeParent::DeferredDestroy", + 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. @@ -210,7 +216,10 @@ ImageBridgeParent::CreateForContent(Endpoint&& aEndpoint) RefPtr bridge = new ImageBridgeParent(loop, aEndpoint.OtherPid()); loop->PostTask(NewRunnableMethod&&>( - bridge, &ImageBridgeParent::Bind, Move(aEndpoint))); + "layers::ImageBridgeParent::Bind", + bridge, + &ImageBridgeParent::Bind, + Move(aEndpoint))); return true; } diff --git a/gfx/layers/ipc/RemoteContentController.cpp b/gfx/layers/ipc/RemoteContentController.cpp index dd7f7547b901..d6d23df98c8e 100644 --- a/gfx/layers/ipc/RemoteContentController.cpp +++ b/gfx/layers/ipc/RemoteContentController.cpp @@ -89,8 +89,19 @@ RemoteContentController::HandleTap(TapType aTapType, } else { // We don't want to get the TabParent or call TabParent::SendHandleTap() from a non-main thread (this might happen // on Android, where this is called from the Java UI thread) - NS_DispatchToMainThread(NewRunnableMethod - (this, &RemoteContentController::HandleTapOnMainThread, aTapType, aPoint, aModifiers, aGuid, aInputBlockId)); + NS_DispatchToMainThread(NewRunnableMethod( + "layers::RemoteContentController::HandleTapOnMainThread", + this, + &RemoteContentController::HandleTapOnMainThread, + aTapType, + aPoint, + aModifiers, + aGuid, + aInputBlockId)); } } @@ -159,11 +170,14 @@ RemoteContentController::NotifyAPZStateChange(const ScrollableLayerGuid& aGuid, { if (MessageLoop::current() != mCompositorThread) { // We have to send messages from the compositor thread - mCompositorThread->PostTask(NewRunnableMethod(this, - &RemoteContentController::NotifyAPZStateChange, - aGuid, aChange, aArg)); + mCompositorThread->PostTask( + NewRunnableMethod( + "layers::RemoteContentController::NotifyAPZStateChange", + this, + &RemoteContentController::NotifyAPZStateChange, + aGuid, + aChange, + aArg)); return; } @@ -176,10 +190,13 @@ void RemoteContentController::UpdateOverscrollVelocity(float aX, float aY, bool aIsRootContent) { if (MessageLoop::current() != mCompositorThread) { - mCompositorThread->PostTask(NewRunnableMethod(this, - &RemoteContentController::UpdateOverscrollVelocity, - aX, aY, aIsRootContent)); + mCompositorThread->PostTask(NewRunnableMethod( + "layers::RemoteContentController::UpdateOverscrollVelocity", + this, + &RemoteContentController::UpdateOverscrollVelocity, + aX, + aY, + aIsRootContent)); return; } if (mCanSend) { @@ -191,10 +208,13 @@ void RemoteContentController::UpdateOverscrollOffset(float aX, float aY, bool aIsRootContent) { if (MessageLoop::current() != mCompositorThread) { - mCompositorThread->PostTask(NewRunnableMethod(this, - &RemoteContentController::UpdateOverscrollOffset, - aX, aY, aIsRootContent)); + mCompositorThread->PostTask(NewRunnableMethod( + "layers::RemoteContentController::UpdateOverscrollOffset", + this, + &RemoteContentController::UpdateOverscrollOffset, + aX, + aY, + aIsRootContent)); return; } if (mCanSend) { @@ -208,10 +228,13 @@ RemoteContentController::NotifyMozMouseScrollEvent(const FrameMetrics::ViewID& a { if (MessageLoop::current() != mCompositorThread) { // We have to send messages from the compositor thread - mCompositorThread->PostTask(NewRunnableMethod(this, - &RemoteContentController::NotifyMozMouseScrollEvent, - aScrollId, aEvent)); + mCompositorThread->PostTask( + NewRunnableMethod( + "layers::RemoteContentController::NotifyMozMouseScrollEvent", + this, + &RemoteContentController::NotifyMozMouseScrollEvent, + aScrollId, + aEvent)); return; } @@ -235,8 +258,11 @@ RemoteContentController::NotifyAsyncScrollbarDragRejected(const FrameMetrics::Vi { if (MessageLoop::current() != mCompositorThread) { // We have to send messages from the compositor thread - mCompositorThread->PostTask(NewRunnableMethod(this, - &RemoteContentController::NotifyAsyncScrollbarDragRejected, aScrollId)); + mCompositorThread->PostTask(NewRunnableMethod( + "layers::RemoteContentController::NotifyAsyncScrollbarDragRejected", + this, + &RemoteContentController::NotifyAsyncScrollbarDragRejected, + aScrollId)); return; } diff --git a/gfx/layers/ipc/ShadowLayers.cpp b/gfx/layers/ipc/ShadowLayers.cpp index 8ebf761cad2a..6c59f4df4ef0 100644 --- a/gfx/layers/ipc/ShadowLayers.cpp +++ b/gfx/layers/ipc/ShadowLayers.cpp @@ -208,7 +208,8 @@ struct ReleaseOnMainThreadTask : public Runnable UniquePtr mObj; explicit ReleaseOnMainThreadTask(UniquePtr& aObj) - : mObj(Move(aObj)) + : Runnable("layers::ReleaseOnMainThreadTask") + , mObj(Move(aObj)) {} NS_IMETHOD Run() override { @@ -233,7 +234,9 @@ ShadowLayerForwarder::~ShadowLayerForwarder() nsIEventTarget::DISPATCH_NORMAL); } else { NS_DispatchToMainThread( - NewRunnableMethod(mShadowManager, &LayerTransactionChild::Destroy)); + NewRunnableMethod("layers::LayerTransactionChild::Destroy", + mShadowManager, + &LayerTransactionChild::Destroy)); } } } diff --git a/gfx/layers/ipc/ThreadSafeRefcountingWithMainThreadDestruction.h b/gfx/layers/ipc/ThreadSafeRefcountingWithMainThreadDestruction.h index e64705478e7e..e86702fccec5 100644 --- a/gfx/layers/ipc/ThreadSafeRefcountingWithMainThreadDestruction.h +++ b/gfx/layers/ipc/ThreadSafeRefcountingWithMainThreadDestruction.h @@ -42,7 +42,11 @@ template struct DeleteOnMainThreadTask : public Runnable { T* mToDelete; - explicit DeleteOnMainThreadTask(T* aToDelete) : mToDelete(aToDelete) {} + explicit DeleteOnMainThreadTask(T* aToDelete) + : Runnable("layers::DeleteOnMainThreadTask") + , mToDelete(aToDelete) + { + } NS_IMETHOD Run() override { MOZ_ASSERT(NS_IsMainThread()); mToDelete->DeleteToBeCalledOnMainThread(); diff --git a/gfx/layers/ipc/UiCompositorControllerChild.cpp b/gfx/layers/ipc/UiCompositorControllerChild.cpp index 60836734a089..47e16bf2f13e 100644 --- a/gfx/layers/ipc/UiCompositorControllerChild.cpp +++ b/gfx/layers/ipc/UiCompositorControllerChild.cpp @@ -48,7 +48,11 @@ UiCompositorControllerChild::CreateForSameProcess(const int64_t& aRootLayerTreeI { RefPtr child = new UiCompositorControllerChild(0); child->mParent = new UiCompositorControllerParent(aRootLayerTreeId); - GetUiThread()->Dispatch(NewRunnableMethod(child, &UiCompositorControllerChild::OpenForSameProcess), nsIThread::DISPATCH_NORMAL); + GetUiThread()->Dispatch( + NewRunnableMethod("layers::UiCompositorControllerChild::OpenForSameProcess", + child, + &UiCompositorControllerChild::OpenForSameProcess), + nsIThread::DISPATCH_NORMAL); return child; } @@ -58,8 +62,12 @@ UiCompositorControllerChild::CreateForGPUProcess(const uint64_t& aProcessToken, { RefPtr child = new UiCompositorControllerChild(aProcessToken); - RefPtr task = NewRunnableMethod&&>( - child, &UiCompositorControllerChild::OpenForGPUProcess, Move(aEndpoint)); + RefPtr task = + NewRunnableMethod&&>( + "layers::UiCompositorControllerChild::OpenForGPUProcess", + child, + &UiCompositorControllerChild::OpenForGPUProcess, + Move(aEndpoint)); GetUiThread()->Dispatch(task.forget(), nsIThread::DISPATCH_NORMAL); return child; @@ -186,7 +194,11 @@ void UiCompositorControllerChild::Destroy() { if (!IsOnUiThread()) { - GetUiThread()->Dispatch(NewRunnableMethod(this, &UiCompositorControllerChild::Destroy), nsIThread::DISPATCH_NORMAL); + GetUiThread()->Dispatch( + NewRunnableMethod("layers::UiCompositorControllerChild::Destroy", + this, + &UiCompositorControllerChild::Destroy), + nsIThread::DISPATCH_NORMAL); return; } diff --git a/gfx/layers/ipc/UiCompositorControllerParent.cpp b/gfx/layers/ipc/UiCompositorControllerParent.cpp index 34da062950ee..a316f79cef28 100644 --- a/gfx/layers/ipc/UiCompositorControllerParent.cpp +++ b/gfx/layers/ipc/UiCompositorControllerParent.cpp @@ -34,8 +34,12 @@ UiCompositorControllerParent::Start(const uint64_t& aRootLayerTreeId, Endpoint

parent = new UiCompositorControllerParent(aRootLayerTreeId); - RefPtr task = NewRunnableMethod&&>( - parent, &UiCompositorControllerParent::Open, Move(aEndpoint)); + RefPtr task = + NewRunnableMethod&&>( + "layers::UiCompositorControllerParent::Open", + parent, + &UiCompositorControllerParent::Open, + Move(aEndpoint)); CompositorThreadHolder::Loop()->PostTask(task.forget()); return parent; @@ -209,7 +213,12 @@ UiCompositorControllerParent::ToolbarAnimatorMessageFromCompositor(int32_t aMess { // This function can be call from ether compositor or controller thread. if (!CompositorThreadHolder::IsInCompositorThread()) { - CompositorThreadHolder::Loop()->PostTask(NewRunnableMethod(this, &UiCompositorControllerParent::ToolbarAnimatorMessageFromCompositor, aMessage)); + CompositorThreadHolder::Loop()->PostTask(NewRunnableMethod( + "layers::UiCompositorControllerParent::" + "ToolbarAnimatorMessageFromCompositor", + this, + &UiCompositorControllerParent::ToolbarAnimatorMessageFromCompositor, + aMessage)); return; } @@ -241,7 +250,10 @@ UiCompositorControllerParent::InitializeForSameProcess() // This function is called by UiCompositorControllerChild in the main thread. // So dispatch to the compositor thread to Initialize. if (!CompositorThreadHolder::IsInCompositorThread()) { - CompositorThreadHolder::Loop()->PostTask(NewRunnableMethod(this, &UiCompositorControllerParent::InitializeForSameProcess)); + CompositorThreadHolder::Loop()->PostTask(NewRunnableMethod( + "layers::UiCompositorControllerParent::InitializeForSameProcess", + this, + &UiCompositorControllerParent::InitializeForSameProcess)); return; } diff --git a/gfx/src/gfxCrashReporterUtils.cpp b/gfx/src/gfxCrashReporterUtils.cpp index 20215963c868..085420a091d9 100644 --- a/gfx/src/gfxCrashReporterUtils.cpp +++ b/gfx/src/gfxCrashReporterUtils.cpp @@ -68,6 +68,7 @@ ObserverToDestroyFeaturesAlreadyReported::Observe(nsISupports* aSubject, class RegisterObserverRunnable : public Runnable { public: + RegisterObserverRunnable() : Runnable("RegisterObserverRunnable") {} NS_IMETHOD Run() override { // LeakLog made me do this. Basically, I just wanted gFeaturesAlreadyReported to be a static nsTArray, // and LeakLog was complaining about leaks like this: @@ -87,7 +88,8 @@ public: class AppendAppNotesRunnable : public CancelableRunnable { public: explicit AppendAppNotesRunnable(const nsACString& aFeatureStr) - : mFeatureString(aFeatureStr) + : CancelableRunnable("AppendAppNotesRunnable") + , mFeatureString(aFeatureStr) { } diff --git a/gfx/thebes/DeviceManagerDx.cpp b/gfx/thebes/DeviceManagerDx.cpp index dc05a4ef76cc..9077d285219f 100644 --- a/gfx/thebes/DeviceManagerDx.cpp +++ b/gfx/thebes/DeviceManagerDx.cpp @@ -976,7 +976,8 @@ DeviceManagerDx::PreloadAttachmentsOnCompositorThread() return; } - RefPtr task = NS_NewRunnableFunction([]() -> void { + RefPtr task = NS_NewRunnableFunction("DeviceManagerDx::PreloadAttachmentsOnCompositorThread", + []() -> void { if (DeviceManagerDx* dm = DeviceManagerDx::Get()) { RefPtr device; RefPtr attachments; diff --git a/gfx/thebes/SoftwareVsyncSource.cpp b/gfx/thebes/SoftwareVsyncSource.cpp index 7e92b89ec462..5776270a85fa 100644 --- a/gfx/thebes/SoftwareVsyncSource.cpp +++ b/gfx/thebes/SoftwareVsyncSource.cpp @@ -46,8 +46,8 @@ SoftwareDisplay::EnableVsync() } mVsyncEnabled = true; - mVsyncThread->message_loop()->PostTask( - NewRunnableMethod(this, &SoftwareDisplay::EnableVsync)); + mVsyncThread->message_loop()->PostTask(NewRunnableMethod( + "SoftwareDisplay::EnableVsync", this, &SoftwareDisplay::EnableVsync)); return; } @@ -65,8 +65,8 @@ SoftwareDisplay::DisableVsync() } mVsyncEnabled = false; - mVsyncThread->message_loop()->PostTask( - NewRunnableMethod(this, &SoftwareDisplay::DisableVsync)); + mVsyncThread->message_loop()->PostTask(NewRunnableMethod( + "SoftwareDisplay::DisableVsync", this, &SoftwareDisplay::DisableVsync)); return; } @@ -129,10 +129,11 @@ SoftwareDisplay::ScheduleNextVsync(mozilla::TimeStamp aVsyncTimestamp) nextVsync = mozilla::TimeStamp::Now(); } - mCurrentVsyncTask = - NewCancelableRunnableMethod(this, - &SoftwareDisplay::NotifyVsync, - nextVsync); + mCurrentVsyncTask = NewCancelableRunnableMethod( + "SoftwareDisplay::NotifyVsync", + this, + &SoftwareDisplay::NotifyVsync, + nextVsync); RefPtr addrefedTask = mCurrentVsyncTask; mVsyncThread->message_loop()->PostDelayedTask( diff --git a/gfx/thebes/gfxFcPlatformFontList.cpp b/gfx/thebes/gfxFcPlatformFontList.cpp index 9d4298dd3249..a01c4928598a 100644 --- a/gfx/thebes/gfxFcPlatformFontList.cpp +++ b/gfx/thebes/gfxFcPlatformFontList.cpp @@ -1181,10 +1181,12 @@ gfxFcPlatformFontList::gfxFcPlatformFontList() mLastConfig = FcConfigGetCurrent(); mCheckFontUpdatesTimer = do_CreateInstance("@mozilla.org/timer;1"); if (mCheckFontUpdatesTimer) { - mCheckFontUpdatesTimer-> - InitWithFuncCallback(CheckFontUpdates, this, - (rescanInterval + 1) * 1000, - nsITimer::TYPE_REPEATING_SLACK); + mCheckFontUpdatesTimer->InitWithNamedFuncCallback( + CheckFontUpdates, + this, + (rescanInterval + 1) * 1000, + nsITimer::TYPE_REPEATING_SLACK, + "gfxFcPlatformFontList::gfxFcPlatformFontList"); } else { NS_WARNING("Failure to create font updates timer"); } diff --git a/gfx/thebes/gfxFont.cpp b/gfx/thebes/gfxFont.cpp index 5aaba73517ee..0863584d8c5d 100644 --- a/gfx/thebes/gfxFont.cpp +++ b/gfx/thebes/gfxFont.cpp @@ -189,10 +189,12 @@ gfxFontCache::gfxFontCache(nsIEventTarget* aEventTarget) if (XRE_IsContentProcess() && NS_IsMainThread()) { mWordCacheExpirationTimer->SetTarget(aEventTarget); } - mWordCacheExpirationTimer-> - InitWithFuncCallback(WordCacheExpirationTimerCallback, this, - SHAPED_WORD_TIMEOUT_SECONDS * 1000, - nsITimer::TYPE_REPEATING_SLACK); + mWordCacheExpirationTimer->InitWithNamedFuncCallback( + WordCacheExpirationTimerCallback, + this, + SHAPED_WORD_TIMEOUT_SECONDS * 1000, + nsITimer::TYPE_REPEATING_SLACK, + "gfxFontCache::gfxFontCache"); } #endif } diff --git a/gfx/thebes/gfxFontInfoLoader.cpp b/gfx/thebes/gfxFontInfoLoader.cpp index a53c96369b3d..47efd180f998 100644 --- a/gfx/thebes/gfxFontInfoLoader.cpp +++ b/gfx/thebes/gfxFontInfoLoader.cpp @@ -44,8 +44,9 @@ class FontInfoLoadCompleteEvent : public Runnable { NS_DECL_ISUPPORTS_INHERITED - explicit FontInfoLoadCompleteEvent(FontInfoData *aFontInfo) : - mFontInfo(aFontInfo) + explicit FontInfoLoadCompleteEvent(FontInfoData* aFontInfo) + : mozilla::Runnable("FontInfoLoadCompleteEvent") + , mFontInfo(aFontInfo) {} NS_IMETHOD Run() override; @@ -58,8 +59,9 @@ class AsyncFontInfoLoader : public Runnable { NS_DECL_ISUPPORTS_INHERITED - explicit AsyncFontInfoLoader(FontInfoData *aFontInfo) : - mFontInfo(aFontInfo) + explicit AsyncFontInfoLoader(FontInfoData* aFontInfo) + : mozilla::Runnable("AsyncFontInfoLoader") + , mFontInfo(aFontInfo) { mCompleteEvent = new FontInfoLoadCompleteEvent(aFontInfo); } @@ -75,7 +77,11 @@ class ShutdownThreadEvent : public Runnable { NS_DECL_ISUPPORTS_INHERITED - explicit ShutdownThreadEvent(nsIThread* aThread) : mThread(aThread) {} + explicit ShutdownThreadEvent(nsIThread* aThread) + : mozilla::Runnable("ShutdownThreadEvent") + , mThread(aThread) + { + } NS_IMETHOD Run() override { mThread->Shutdown(); return NS_OK; @@ -158,8 +164,11 @@ gfxFontInfoLoader::StartLoader(uint32_t aDelay, uint32_t aInterval) // delay? ==> start async thread after a delay if (aDelay) { mState = stateTimerOnDelay; - mTimer->InitWithFuncCallback(DelayedStartCallback, this, aDelay, - nsITimer::TYPE_ONE_SHOT); + mTimer->InitWithNamedFuncCallback(DelayedStartCallback, + this, + aDelay, + nsITimer::TYPE_ONE_SHOT, + "gfxFontInfoLoader::StartLoader"); return; } @@ -209,8 +218,11 @@ gfxFontInfoLoader::FinalizeLoader(FontInfoData *aFontInfo) // not all work completed ==> run load on interval mState = stateTimerOnInterval; - mTimer->InitWithFuncCallback(LoadFontInfoCallback, this, mInterval, - nsITimer::TYPE_REPEATING_SLACK); + mTimer->InitWithNamedFuncCallback(LoadFontInfoCallback, + this, + mInterval, + nsITimer::TYPE_REPEATING_SLACK, + "gfxFontInfoLoader::FinalizeLoader"); } void diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index 9fae40928bff..9b1708170b05 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -309,7 +309,11 @@ class LogForwarderEvent : public Runnable NS_DECL_ISUPPORTS_INHERITED - explicit LogForwarderEvent(const nsCString& aMessage) : mMessage(aMessage) {} + explicit LogForwarderEvent(const nsCString& aMessage) + : mozilla::Runnable("LogForwarderEvent") + , mMessage(aMessage) + { + } NS_IMETHOD Run() override { MOZ_ASSERT(NS_IsMainThread() && (XRE_IsContentProcess() || XRE_IsGPUProcess())); @@ -363,7 +367,11 @@ class CrashTelemetryEvent : public Runnable NS_DECL_ISUPPORTS_INHERITED - explicit CrashTelemetryEvent(uint32_t aReason) : mReason(aReason) {} + explicit CrashTelemetryEvent(uint32_t aReason) + : mozilla::Runnable("CrashTelemetryEvent") + , mReason(aReason) + { + } NS_IMETHOD Run() override { MOZ_ASSERT(NS_IsMainThread()); @@ -2696,11 +2704,12 @@ gfxPlatform::NotifyCompositorCreated(LayersBackend aBackend) mCompositorBackend = aBackend; // Notify that we created a compositor, so telemetry can update. - NS_DispatchToMainThread(NS_NewRunnableFunction([] { - if (nsCOMPtr obsvc = services::GetObserverService()) { - obsvc->NotifyObservers(nullptr, "compositor:created", nullptr); - } - })); + NS_DispatchToMainThread( + NS_NewRunnableFunction("gfxPlatform::NotifyCompositorCreated", [] { + if (nsCOMPtr obsvc = services::GetObserverService()) { + obsvc->NotifyObservers(nullptr, "compositor:created", nullptr); + } + })); } /* static */ void diff --git a/gfx/thebes/gfxPlatformGtk.cpp b/gfx/thebes/gfxPlatformGtk.cpp index efa5ac154989..6aa208d827fa 100644 --- a/gfx/thebes/gfxPlatformGtk.cpp +++ b/gfx/thebes/gfxPlatformGtk.cpp @@ -652,7 +652,10 @@ public: if (!mVsyncThread.Start()) return false; - RefPtr vsyncSetup = NewRunnableMethod(this, &GLXDisplay::SetupGLContext); + RefPtr vsyncSetup = + NewRunnableMethod("GLXVsyncSource::GLXDisplay::SetupGLContext", + this, + &GLXDisplay::SetupGLContext); mVsyncThread.message_loop()->PostTask(vsyncSetup.forget()); // Wait until the setup has completed. lock.Wait(); @@ -724,7 +727,8 @@ public: // If the task has not nulled itself out, it hasn't yet realized // that vsync was disabled earlier, so continue its execution. if (!mVsyncTask) { - mVsyncTask = NewRunnableMethod(this, &GLXDisplay::RunVsync); + mVsyncTask = NewRunnableMethod( + "GLXVsyncSource::GLXDisplay::RunVsync", this, &GLXDisplay::RunVsync); RefPtr addrefedTask = mVsyncTask; mVsyncThread.message_loop()->PostTask(addrefedTask.forget()); } @@ -748,7 +752,8 @@ public: DisableVsync(); // Cleanup thread-specific resources before shutting down. - RefPtr shutdownTask = NewRunnableMethod(this, &GLXDisplay::Cleanup); + RefPtr shutdownTask = NewRunnableMethod( + "GLXVsyncSource::GLXDisplay::Cleanup", this, &GLXDisplay::Cleanup); mVsyncThread.message_loop()->PostTask(shutdownTask.forget()); // Stop, waiting for the cleanup task to finish execution. diff --git a/gfx/thebes/gfxWindowsPlatform.cpp b/gfx/thebes/gfxWindowsPlatform.cpp index 90b2f6240c56..2379dd6ee45c 100755 --- a/gfx/thebes/gfxWindowsPlatform.cpp +++ b/gfx/thebes/gfxWindowsPlatform.cpp @@ -1684,7 +1684,8 @@ public: } mVsyncThread->message_loop()->PostTask( - NewRunnableMethod(this, &D3DVsyncDisplay::VBlankLoop)); + NewRunnableMethod("D3DVsyncDisplay::VBlankLoop", + this, &D3DVsyncDisplay::VBlankLoop)); } virtual void DisableVsync() override @@ -1722,7 +1723,8 @@ public: } mVsyncThread->message_loop()->PostDelayedTask( - NewRunnableMethod(this, &D3DVsyncDisplay::VBlankLoop), + NewRunnableMethod("D3DVsyncDisplay::VBlankLoop", + this, &D3DVsyncDisplay::VBlankLoop), delay.ToMilliseconds()); } diff --git a/gfx/vr/gfxVROculus.cpp b/gfx/vr/gfxVROculus.cpp index a58151504313..91788a901366 100644 --- a/gfx/vr/gfxVROculus.cpp +++ b/gfx/vr/gfxVROculus.cpp @@ -996,9 +996,10 @@ VRControllerOculus::UpdateVibrateHaptic(ovrSession aSession, MOZ_ASSERT(mVibrateThread); RefPtr runnable = - NewRunnableMethod - (this, &VRControllerOculus::UpdateVibrateHaptic, aSession, - aHapticIndex, aIntensity, (duration > kVibrateRate) ? remainingTime : 0, aVibrateIndex, aPromiseID); + NewRunnableMethod( + "VRControllerOculus::UpdateVibrateHaptic", + this, &VRControllerOculus::UpdateVibrateHaptic, aSession, + aHapticIndex, aIntensity, (duration > kVibrateRate) ? remainingTime : 0, aVibrateIndex, aPromiseID); NS_DelayedDispatchToCurrentThread(runnable.forget(), (duration > kVibrateRate) ? kVibrateRate : remainingTime); } else { @@ -1035,8 +1036,9 @@ VRControllerOculus::VibrateHapticComplete(ovrSession aSession, uint32_t aPromise VRManager *vm = VRManager::Get(); MOZ_ASSERT(vm); - CompositorThreadHolder::Loop()->PostTask(NewRunnableMethod - (vm, &VRManager::NotifyVibrateHapticCompleted, aPromiseID)); + CompositorThreadHolder::Loop()->PostTask(NewRunnableMethod( + "VRManager::NotifyVibrateHapticCompleted", + vm, &VRManager::NotifyVibrateHapticCompleted, aPromiseID)); } void @@ -1060,7 +1062,8 @@ VRControllerOculus::VibrateHaptic(ovrSession aSession, RefPtr runnable = NewRunnableMethod - (this, &VRControllerOculus::UpdateVibrateHaptic, aSession, + ("VRControllerOculus::UpdateVibrateHaptic", + this, &VRControllerOculus::UpdateVibrateHaptic, aSession, aHapticIndex, aIntensity, aDuration, mVibrateIndex, aPromiseID); mVibrateThread->Dispatch(runnable.forget(), NS_DISPATCH_NORMAL); } diff --git a/gfx/vr/gfxVROpenVR.cpp b/gfx/vr/gfxVROpenVR.cpp index e43294f2c3d0..cd1ab0ffe7d7 100644 --- a/gfx/vr/gfxVROpenVR.cpp +++ b/gfx/vr/gfxVROpenVR.cpp @@ -454,7 +454,8 @@ VRControllerOpenVR::UpdateVibrateHaptic(::vr::IVRSystem* aVRSystem, RefPtr runnable = NewRunnableMethod<::vr::IVRSystem*, uint32_t, double, double, uint64_t, uint32_t> - (this, &VRControllerOpenVR::UpdateVibrateHaptic, aVRSystem, + ("VRControllerOpenVR::UpdateVibrateHaptic", + this, &VRControllerOpenVR::UpdateVibrateHaptic, aVRSystem, aHapticIndex, aIntensity, duration - kVibrateRate, aVibrateIndex, aPromiseID); NS_DelayedDispatchToCurrentThread(runnable.forget(), kVibrateRate); } else { @@ -470,7 +471,8 @@ VRControllerOpenVR::VibrateHapticComplete(uint32_t aPromiseID) MOZ_ASSERT(vm); CompositorThreadHolder::Loop()->PostTask(NewRunnableMethod - (vm, &VRManager::NotifyVibrateHapticCompleted, aPromiseID)); + ("VRManager::NotifyVibrateHapticCompleted", + vm, &VRManager::NotifyVibrateHapticCompleted, aPromiseID)); } void @@ -494,7 +496,8 @@ VRControllerOpenVR::VibrateHaptic(::vr::IVRSystem* aVRSystem, RefPtr runnable = NewRunnableMethod<::vr::IVRSystem*, uint32_t, double, double, uint64_t, uint32_t> - (this, &VRControllerOpenVR::UpdateVibrateHaptic, aVRSystem, + ("VRControllerOpenVR::UpdateVibrateHaptic", + this, &VRControllerOpenVR::UpdateVibrateHaptic, aVRSystem, aHapticIndex, aIntensity, aDuration, mVibrateIndex, aPromiseID); mVibrateThread->Dispatch(runnable.forget(), NS_DISPATCH_NORMAL); } diff --git a/gfx/vr/ipc/VRManagerChild.cpp b/gfx/vr/ipc/VRManagerChild.cpp index 20869f38f1cf..9807422b1c90 100644 --- a/gfx/vr/ipc/VRManagerChild.cpp +++ b/gfx/vr/ipc/VRManagerChild.cpp @@ -544,7 +544,9 @@ VRManagerChild::RunFrameRequestCallbacks() void VRManagerChild::FireDOMVRDisplayMountedEvent(uint32_t aDisplayID) { - nsContentUtils::AddScriptRunner(NewRunnableMethod(this, + nsContentUtils::AddScriptRunner(NewRunnableMethod( + "gfx::VRManagerChild::FireDOMVRDisplayMountedEventInternal", + this, &VRManagerChild::FireDOMVRDisplayMountedEventInternal, aDisplayID)); } @@ -552,7 +554,9 @@ VRManagerChild::FireDOMVRDisplayMountedEvent(uint32_t aDisplayID) void VRManagerChild::FireDOMVRDisplayUnmountedEvent(uint32_t aDisplayID) { - nsContentUtils::AddScriptRunner(NewRunnableMethod(this, + nsContentUtils::AddScriptRunner(NewRunnableMethod( + "gfx::VRManagerChild::FireDOMVRDisplayUnmountedEventInternal", + this, &VRManagerChild::FireDOMVRDisplayUnmountedEventInternal, aDisplayID)); } @@ -560,7 +564,9 @@ VRManagerChild::FireDOMVRDisplayUnmountedEvent(uint32_t aDisplayID) void VRManagerChild::FireDOMVRDisplayConnectEvent(uint32_t aDisplayID) { - nsContentUtils::AddScriptRunner(NewRunnableMethod(this, + nsContentUtils::AddScriptRunner(NewRunnableMethod( + "gfx::VRManagerChild::FireDOMVRDisplayConnectEventInternal", + this, &VRManagerChild::FireDOMVRDisplayConnectEventInternal, aDisplayID)); } @@ -568,7 +574,9 @@ VRManagerChild::FireDOMVRDisplayConnectEvent(uint32_t aDisplayID) void VRManagerChild::FireDOMVRDisplayDisconnectEvent(uint32_t aDisplayID) { - nsContentUtils::AddScriptRunner(NewRunnableMethod(this, + nsContentUtils::AddScriptRunner(NewRunnableMethod( + "gfx::VRManagerChild::FireDOMVRDisplayDisconnectEventInternal", + this, &VRManagerChild::FireDOMVRDisplayDisconnectEventInternal, aDisplayID)); } @@ -576,7 +584,9 @@ VRManagerChild::FireDOMVRDisplayDisconnectEvent(uint32_t aDisplayID) void VRManagerChild::FireDOMVRDisplayPresentChangeEvent(uint32_t aDisplayID) { - nsContentUtils::AddScriptRunner(NewRunnableMethod(this, + nsContentUtils::AddScriptRunner(NewRunnableMethod( + "gfx::VRManagerChild::FireDOMVRDisplayPresentChangeEventInternal", + this, &VRManagerChild::FireDOMVRDisplayPresentChangeEventInternal, aDisplayID)); } diff --git a/gfx/vr/ipc/VRManagerParent.cpp b/gfx/vr/ipc/VRManagerParent.cpp index 6b0dfefa216c..a10b234a136e 100644 --- a/gfx/vr/ipc/VRManagerParent.cpp +++ b/gfx/vr/ipc/VRManagerParent.cpp @@ -165,7 +165,10 @@ VRManagerParent::CreateForContent(Endpoint&& aEndpoint) RefPtr vmp = new VRManagerParent(aEndpoint.OtherPid(), true); loop->PostTask(NewRunnableMethod&&>( - vmp, &VRManagerParent::Bind, Move(aEndpoint))); + "gfx::VRManagerParent::Bind", + vmp, + &VRManagerParent::Bind, + Move(aEndpoint))); return true; } @@ -206,7 +209,10 @@ VRManagerParent::CreateForGPUProcess(Endpoint&& aEndpoint) RefPtr vmp = new VRManagerParent(aEndpoint.OtherPid(), false); vmp->mCompositorThreadHolder = layers::CompositorThreadHolder::GetSingleton(); loop->PostTask(NewRunnableMethod&&>( - vmp, &VRManagerParent::Bind, Move(aEndpoint))); + "gfx::VRManagerParent::Bind", + vmp, + &VRManagerParent::Bind, + Move(aEndpoint))); return true; } @@ -221,7 +227,10 @@ void VRManagerParent::ActorDestroy(ActorDestroyReason why) { UnregisterFromManager(); - MessageLoop::current()->PostTask(NewRunnableMethod(this, &VRManagerParent::DeferredDestroy)); + MessageLoop::current()->PostTask( + NewRunnableMethod("gfx::VRManagerParent::DeferredDestroy", + this, + &VRManagerParent::DeferredDestroy)); } void diff --git a/gfx/webrender_bindings/RenderThread.cpp b/gfx/webrender_bindings/RenderThread.cpp index 20ab91f90edd..b555c4c93c73 100644 --- a/gfx/webrender_bindings/RenderThread.cpp +++ b/gfx/webrender_bindings/RenderThread.cpp @@ -124,9 +124,11 @@ void RenderThread::NewFrameReady(wr::WindowId aWindowId) { if (!IsInRenderThread()) { - Loop()->PostTask(NewRunnableMethod( - this, &RenderThread::NewFrameReady, aWindowId - )); + Loop()->PostTask( + NewRunnableMethod("wr::RenderThread::NewFrameReady", + this, + &RenderThread::NewFrameReady, + aWindowId)); return; } @@ -139,8 +141,11 @@ RenderThread::NewScrollFrameReady(wr::WindowId aWindowId, bool aCompositeNeeded) { if (!IsInRenderThread()) { Loop()->PostTask(NewRunnableMethod( - this, &RenderThread::NewScrollFrameReady, aWindowId, aCompositeNeeded - )); + "wr::RenderThread::NewScrollFrameReady", + this, + &RenderThread::NewScrollFrameReady, + aWindowId, + aCompositeNeeded)); return; } @@ -151,10 +156,13 @@ void RenderThread::RunEvent(wr::WindowId aWindowId, UniquePtr aEvent) { if (!IsInRenderThread()) { - Loop()->PostTask(NewRunnableMethod&&>( - this, &RenderThread::RunEvent, - aWindowId, Move(aEvent) - )); + Loop()->PostTask( + NewRunnableMethod&&>( + "wr::RenderThread::RunEvent", + this, + &RenderThread::RunEvent, + aWindowId, + Move(aEvent))); return; } @@ -302,6 +310,7 @@ RenderThread::UnregisterExternalImage(uint64_t aExternalImageId) RefPtr texture = mRenderTextures.Get(aExternalImageId); mRenderTextures.Remove(aExternalImageId); Loop()->PostTask(NewRunnableMethod>( + "RenderThread::DeferredRenderTextureHostDestroy", this, &RenderThread::DeferredRenderTextureHostDestroy, Move(texture) )); } else { diff --git a/image/DecodePool.cpp b/image/DecodePool.cpp index 92e38404600e..b6db3a2d0cfe 100644 --- a/image/DecodePool.cpp +++ b/image/DecodePool.cpp @@ -160,7 +160,8 @@ class DecodePoolWorker : public Runnable { public: explicit DecodePoolWorker(DecodePoolImpl* aImpl) - : mImpl(aImpl) + : Runnable("image::DecodePoolWorker") + , mImpl(aImpl) { } NS_IMETHOD Run() override diff --git a/image/Image.cpp b/image/Image.cpp index 5436cbb93464..b2faa61a9c6a 100644 --- a/image/Image.cpp +++ b/image/Image.cpp @@ -157,12 +157,13 @@ ImageResource::SendOnUnlockedDraw(uint32_t aFlags) mProgressTracker->OnUnlockedDraw(); } else { NotNull> image = WrapNotNull(this); - NS_DispatchToMainThread(NS_NewRunnableFunction([=]() -> void { - RefPtr tracker = image->GetProgressTracker(); - if (tracker) { - tracker->OnUnlockedDraw(); - } - })); + NS_DispatchToMainThread(NS_NewRunnableFunction( + "image::ImageResource::SendOnUnlockedDraw", [=]() -> void { + RefPtr tracker = image->GetProgressTracker(); + if (tracker) { + tracker->OnUnlockedDraw(); + } + })); } } diff --git a/image/ProgressTracker.cpp b/image/ProgressTracker.cpp index 1f51cce3e24f..936d37af352d 100644 --- a/image/ProgressTracker.cpp +++ b/image/ProgressTracker.cpp @@ -204,7 +204,8 @@ class AsyncNotifyCurrentStateRunnable : public Runnable public: AsyncNotifyCurrentStateRunnable(ProgressTracker* aProgressTracker, IProgressObserver* aObserver) - : mProgressTracker(aProgressTracker) + : Runnable("image::AsyncNotifyCurrentStateRunnable") + , mProgressTracker(aProgressTracker) , mObserver(aObserver) { MOZ_ASSERT(NS_IsMainThread(), "Should be created on the main thread"); diff --git a/image/RasterImage.cpp b/image/RasterImage.cpp index 8585272ab49c..01e8dfbbe50e 100644 --- a/image/RasterImage.cpp +++ b/image/RasterImage.cpp @@ -1610,7 +1610,8 @@ RasterImage::HandleErrorWorker::DispatchIfNeeded(RasterImage* aImage) } RasterImage::HandleErrorWorker::HandleErrorWorker(RasterImage* aImage) - : mImage(aImage) + : Runnable("image::RasterImage::HandleErrorWorker") + , mImage(aImage) { MOZ_ASSERT(mImage, "Should have image"); } diff --git a/image/test/gtest/TestDecodeToSurface.cpp b/image/test/gtest/TestDecodeToSurface.cpp index f5762d84c172..c2628c8c6665 100644 --- a/image/test/gtest/TestDecodeToSurface.cpp +++ b/image/test/gtest/TestDecodeToSurface.cpp @@ -29,7 +29,8 @@ public: nsIInputStream* aInputStream, ImageOps::ImageBuffer* aImageBuffer, const ImageTestCase& aTestCase) - : mSurface(aSurface) + : mozilla::Runnable("DecodeToSurfaceRunnable") + , mSurface(aSurface) , mInputStream(aInputStream) , mImageBuffer(aImageBuffer) , mTestCase(aTestCase) diff --git a/ipc/chromium/src/base/message_loop.h b/ipc/chromium/src/base/message_loop.h index d16aa0cbebec..91e2a0fb62ca 100644 --- a/ipc/chromium/src/base/message_loop.h +++ b/ipc/chromium/src/base/message_loop.h @@ -140,6 +140,7 @@ public: // arbitrary MessageLoop to Quit. class QuitTask : public mozilla::Runnable { public: + QuitTask() : mozilla::Runnable("QuitTask") {} NS_IMETHOD Run() override { MessageLoop::current()->Quit(); return NS_OK; diff --git a/ipc/chromium/src/base/object_watcher.cc b/ipc/chromium/src/base/object_watcher.cc index ced911fa2079..4308fa42a162 100644 --- a/ipc/chromium/src/base/object_watcher.cc +++ b/ipc/chromium/src/base/object_watcher.cc @@ -21,6 +21,8 @@ public: Delegate* delegate; // Delegate to notify when signaled bool did_signal; // DoneWaiting was called + Watch() : mozilla::Runnable("ObjectWatcher::Watch") {} + NS_IMETHOD Run() override { // The watcher may have already been torn down, in which case we need to // just get out of dodge. diff --git a/ipc/chromium/src/base/task.h b/ipc/chromium/src/base/task.h index 10dc9c488bbc..e66e51fe9054 100644 --- a/ipc/chromium/src/base/task.h +++ b/ipc/chromium/src/base/task.h @@ -159,12 +159,16 @@ class ScopedRunnableMethodFactory : public RevocableStore { template class RunnableMethod : public mozilla::Runnable { public: - RunnableMethod() { } + RunnableMethod() + : mozilla::Runnable("ScopedRunnableMethodFactory::RunnableMethod") + { + } - void Init(T* obj, Method meth, Params&& params) { - obj_ = obj; - meth_ = meth; - params_ = mozilla::Forward(params); + void Init(T* obj, Method meth, Params&& params) + { + obj_ = obj; + meth_ = meth; + params_ = mozilla::Forward(params); } NS_IMETHOD Run() override { @@ -193,7 +197,10 @@ class ScopedRunnableMethodFactory : public RevocableStore { template class DeleteTask : public mozilla::CancelableRunnable { public: - explicit DeleteTask(T* obj) : obj_(obj) { + explicit DeleteTask(T* obj) + : mozilla::CancelableRunnable("DeleteTask") + , obj_(obj) + { } NS_IMETHOD Run() override { delete obj_; @@ -270,9 +277,13 @@ template class RunnableMethod : public mozilla::CancelableRunnable, public RunnableMethodTraits { public: - RunnableMethod(T* obj, Method meth, Params&& params) - : obj_(obj), meth_(meth), params_(mozilla::Forward(params)) { - this->RetainCallee(obj_); + RunnableMethod(T* obj, Method meth, Params&& params) + : mozilla::CancelableRunnable("RunnableMethod") + , obj_(obj) + , meth_(meth) + , params_(mozilla::Forward(params)) + { + this->RetainCallee(obj_); } ~RunnableMethod() { ReleaseCallee(); @@ -324,8 +335,11 @@ NewRunnableMethod(T* object, Method method, Args&&... args) { template class RunnableFunction : public mozilla::CancelableRunnable { public: - RunnableFunction(Function function, Params&& params) - : function_(function), params_(mozilla::Forward(params)) { + RunnableFunction(Function function, Params&& params) + : mozilla::CancelableRunnable("RunnableFunction") + , function_(function) + , params_(mozilla::Forward(params)) + { } ~RunnableFunction() { diff --git a/ipc/chromium/src/base/thread.cc b/ipc/chromium/src/base/thread.cc index d5f0eef35463..f15de139818e 100644 --- a/ipc/chromium/src/base/thread.cc +++ b/ipc/chromium/src/base/thread.cc @@ -22,6 +22,7 @@ namespace base { // This task is used to trigger the message loop to exit. class ThreadQuitTask : public mozilla::Runnable { public: + ThreadQuitTask() : mozilla::Runnable("ThreadQuitTask") {} NS_IMETHOD Run() override { MessageLoop::current()->Quit(); Thread::SetThreadWasQuitProperly(true); diff --git a/ipc/chromium/src/base/timer.h b/ipc/chromium/src/base/timer.h index b65f89392e98..5703707ca8d7 100644 --- a/ipc/chromium/src/base/timer.h +++ b/ipc/chromium/src/base/timer.h @@ -87,8 +87,11 @@ class BaseTimer_Helper { // We have access to the timer_ member so we can orphan this task. class TimerTask : public mozilla::Runnable { public: - explicit TimerTask(TimeDelta delay) : delay_(delay) { - // timer_ is set in InitiateDelayedTask. + explicit TimerTask(TimeDelta delay) + : mozilla::Runnable("base::BaseTimer_Helper::TimerTask") + , delay_(delay) + { + // timer_ is set in InitiateDelayedTask. } virtual ~TimerTask() {} BaseTimer_Helper* timer_; diff --git a/ipc/chromium/src/chrome/common/process_watcher_posix_sigchld.cc b/ipc/chromium/src/chrome/common/process_watcher_posix_sigchld.cc index 5abe143c15db..1b0e62639712 100644 --- a/ipc/chromium/src/chrome/common/process_watcher_posix_sigchld.cc +++ b/ipc/chromium/src/chrome/common/process_watcher_posix_sigchld.cc @@ -79,7 +79,9 @@ class ChildGrimReaper : public ChildReaper, public mozilla::Runnable { public: - explicit ChildGrimReaper(pid_t process) : ChildReaper(process) + explicit ChildGrimReaper(pid_t process) + : ChildReaper(process) + , mozilla::Runnable("ChildGrimReaper") { } diff --git a/ipc/chromium/src/chrome/common/process_watcher_win.cc b/ipc/chromium/src/chrome/common/process_watcher_win.cc index fccb83999e36..37d2632fd85d 100644 --- a/ipc/chromium/src/chrome/common/process_watcher_win.cc +++ b/ipc/chromium/src/chrome/common/process_watcher_win.cc @@ -20,7 +20,7 @@ class ChildReaper : public mozilla::Runnable, public MessageLoop::DestructionObserver { public: explicit ChildReaper(base::ProcessHandle process, bool force) - : process_(process), force_(force) { + : mozilla::Runnable("ChildReaper"), process_(process), force_(force) { watcher_.StartWatching(process_, this); } diff --git a/ipc/glue/BackgroundImpl.cpp b/ipc/glue/BackgroundImpl.cpp index c37f4b2413a9..93f5310c2743 100644 --- a/ipc/glue/BackgroundImpl.cpp +++ b/ipc/glue/BackgroundImpl.cpp @@ -428,7 +428,8 @@ private: threadLocalInfo->mActor.forget(&actor); MOZ_ALWAYS_SUCCEEDS( - NS_DispatchToMainThread(NewNonOwningRunnableMethod(actor, &ChildImpl::Release))); + NS_DispatchToMainThread(NewNonOwningRunnableMethod("ChildImpl::Release", + actor, &ChildImpl::Release))); } } delete threadLocalInfo; @@ -954,7 +955,8 @@ ParentImpl::GetContentParent(PBackgroundParent* aBackgroundActor) // 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. MOZ_ALWAYS_SUCCEEDS( - NS_DispatchToMainThread(NewNonOwningRunnableMethod(actor->mContent, &ContentParent::AddRef))); + NS_DispatchToMainThread(NewNonOwningRunnableMethod("ContentParent::AddRef", + actor->mContent, &ContentParent::AddRef))); } return already_AddRefed(actor->mContent.get()); @@ -1233,7 +1235,8 @@ ParentImpl::Destroy() AssertIsInMainProcess(); MOZ_ALWAYS_SUCCEEDS( - NS_DispatchToMainThread(NewNonOwningRunnableMethod(this, &ParentImpl::MainThreadActorDestroy))); + NS_DispatchToMainThread(NewNonOwningRunnableMethod("ParentImpl::MainThreadActorDestroy", + this, &ParentImpl::MainThreadActorDestroy))); } void @@ -1279,7 +1282,8 @@ ParentImpl::ActorDestroy(ActorDestroyReason aWhy) // long enough to be cleared in this call stack. MOZ_ALWAYS_SUCCEEDS( - NS_DispatchToCurrentThread(NewNonOwningRunnableMethod(this, &ParentImpl::Destroy))); + NS_DispatchToCurrentThread(NewNonOwningRunnableMethod("ParentImpl::Destroy", + this, &ParentImpl::Destroy))); } NS_IMPL_ISUPPORTS(ParentImpl::ShutdownObserver, nsIObserver) diff --git a/ipc/glue/BackgroundParentImpl.cpp b/ipc/glue/BackgroundParentImpl.cpp index 319787b3d885..b9cc273c79ff 100644 --- a/ipc/glue/BackgroundParentImpl.cpp +++ b/ipc/glue/BackgroundParentImpl.cpp @@ -404,7 +404,8 @@ class InitUDPSocketParentCallback final : public Runnable public: InitUDPSocketParentCallback(UDPSocketParent* aActor, const nsACString& aFilter) - : mActor(aActor) + : Runnable("ipc::InitUDPSocketParentCallback") + , mActor(aActor) , mFilter(aFilter) { AssertIsInMainProcess(); @@ -528,7 +529,8 @@ public: CheckPrincipalRunnable(already_AddRefed aParent, const PrincipalInfo& aPrincipalInfo, const nsCString& aOrigin) - : mContentParent(aParent) + : Runnable("ipc::CheckPrincipalRunnable") + , mContentParent(aParent) , mPrincipalInfo(aPrincipalInfo) , mOrigin(aOrigin) { diff --git a/ipc/glue/CrashReporterHost.cpp b/ipc/glue/CrashReporterHost.cpp index ba9af7424887..75c436e2224a 100644 --- a/ipc/glue/CrashReporterHost.cpp +++ b/ipc/glue/CrashReporterHost.cpp @@ -109,9 +109,11 @@ CrashReporterHost::NotifyCrashService(GeckoProcessType aProcessType, const AnnotationTable* aNotes) { if (!NS_IsMainThread()) { - RefPtr runnable = NS_NewRunnableFunction([=] () -> void { - CrashReporterHost::NotifyCrashService(aProcessType, aChildDumpID, aNotes); - }); + RefPtr runnable = NS_NewRunnableFunction( + "ipc::CrashReporterHost::NotifyCrashService", [=]() -> void { + CrashReporterHost::NotifyCrashService( + aProcessType, aChildDumpID, aNotes); + }); RefPtr mainThread = do_GetMainThread(); SyncRunnable::DispatchToThread(mainThread, runnable); return; diff --git a/ipc/glue/GeckoChildProcessHost.cpp b/ipc/glue/GeckoChildProcessHost.cpp index 098b27a5852b..70279c5356c7 100644 --- a/ipc/glue/GeckoChildProcessHost.cpp +++ b/ipc/glue/GeckoChildProcessHost.cpp @@ -359,10 +359,13 @@ GeckoChildProcessHost::SyncLaunch(std::vector aExtraOpts, int aTime MessageLoop* ioLoop = XRE_GetIOMessageLoop(); NS_ASSERTION(MessageLoop::current() != ioLoop, "sync launch from the IO thread NYI"); - ioLoop->PostTask(NewNonOwningRunnableMethod - , base::ProcessArchitecture> - (this, &GeckoChildProcessHost::RunPerformAsyncLaunch, - aExtraOpts, arch)); + ioLoop->PostTask(NewNonOwningRunnableMethod, + base::ProcessArchitecture>( + "ipc::GeckoChildProcessHost::RunPerformAsyncLaunch", + this, + &GeckoChildProcessHost::RunPerformAsyncLaunch, + aExtraOpts, + arch)); return WaitUntilConnected(aTimeoutMs); } @@ -375,10 +378,13 @@ GeckoChildProcessHost::AsyncLaunch(std::vector aExtraOpts, MessageLoop* ioLoop = XRE_GetIOMessageLoop(); - ioLoop->PostTask(NewNonOwningRunnableMethod - , base::ProcessArchitecture> - (this, &GeckoChildProcessHost::RunPerformAsyncLaunch, - aExtraOpts, arch)); + ioLoop->PostTask(NewNonOwningRunnableMethod, + base::ProcessArchitecture>( + "ipc::GeckoChildProcessHost::RunPerformAsyncLaunch", + 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. @@ -434,10 +440,13 @@ GeckoChildProcessHost::LaunchAndWaitForProcessHandle(StringVector aExtraOpts) PrepareLaunch(); MessageLoop* ioLoop = XRE_GetIOMessageLoop(); - ioLoop->PostTask(NewNonOwningRunnableMethod - , base::ProcessArchitecture> - (this, &GeckoChildProcessHost::RunPerformAsyncLaunch, - aExtraOpts, base::GetCurrentProcessArchitecture())); + ioLoop->PostTask(NewNonOwningRunnableMethod, + base::ProcessArchitecture>( + "ipc::GeckoChildProcessHost::RunPerformAsyncLaunch", + this, + &GeckoChildProcessHost::RunPerformAsyncLaunch, + aExtraOpts, + base::GetCurrentProcessArchitecture())); MonitorAutoLock lock(mMonitor); while (mProcessState < PROCESS_CREATED) { diff --git a/ipc/glue/IPCStreamDestination.cpp b/ipc/glue/IPCStreamDestination.cpp index 8c1757f60a08..be61f321c649 100644 --- a/ipc/glue/IPCStreamDestination.cpp +++ b/ipc/glue/IPCStreamDestination.cpp @@ -177,9 +177,12 @@ public: eCloseDestination, }; - HelperRunnable(IPCStreamDestination::DelayedStartInputStream* aDelayedStartInputStream, - Op aOp) - : mDelayedStartInputStream(aDelayedStartInputStream) + HelperRunnable( + IPCStreamDestination::DelayedStartInputStream* aDelayedStartInputStream, + Op aOp) + : Runnable( + "ipc::IPCStreamDestination::DelayedStartInputStream::HelperRunnable") + , mDelayedStartInputStream(aDelayedStartInputStream) , mOp(aOp) { MOZ_ASSERT(aDelayedStartInputStream); diff --git a/ipc/glue/MessageChannel.cpp b/ipc/glue/MessageChannel.cpp index 3f874ef0e481..b20185d35788 100644 --- a/ipc/glue/MessageChannel.cpp +++ b/ipc/glue/MessageChannel.cpp @@ -546,8 +546,10 @@ MessageChannel::MessageChannel(const char* aName, mIsSyncWaitingOnNonMainThread = false; #endif - mOnChannelConnectedTask = - NewNonOwningCancelableRunnableMethod(this, &MessageChannel::DispatchOnChannelConnected); + mOnChannelConnectedTask = NewNonOwningCancelableRunnableMethod( + "ipc::MessageChannel::DispatchOnChannelConnected", + this, + &MessageChannel::DispatchOnChannelConnected); #ifdef OS_WIN mEvent = CreateEventW(nullptr, TRUE, FALSE, nullptr); @@ -799,10 +801,12 @@ MessageChannel::Open(MessageChannel *aTargetChan, MessageLoop *aTargetLoop, Side MonitorAutoLock lock(*mMonitor); mChannelState = ChannelOpening; - aTargetLoop->PostTask(NewNonOwningRunnableMethod - (aTargetChan, - &MessageChannel::OnOpenAsSlave, - this, oppSide)); + aTargetLoop->PostTask(NewNonOwningRunnableMethod( + "ipc::MessageChannel::OnOpenAsSlave", + aTargetChan, + &MessageChannel::OnOpenAsSlave, + this, + oppSide)); while (ChannelOpening == mChannelState) mMonitor->Wait(); @@ -2524,12 +2528,14 @@ MessageChannel::OnNotifyMaybeChannelError() } if (IsOnCxxStack()) { - mChannelErrorTask = - NewNonOwningCancelableRunnableMethod(this, &MessageChannel::OnNotifyMaybeChannelError); - RefPtr task = mChannelErrorTask; - // 10 ms delay is completely arbitrary - mWorkerLoop->PostDelayedTask(task.forget(), 10); - return; + mChannelErrorTask = NewNonOwningCancelableRunnableMethod( + "ipc::MessageChannel::OnNotifyMaybeChannelError", + this, + &MessageChannel::OnNotifyMaybeChannelError); + RefPtr task = mChannelErrorTask; + // 10 ms delay is completely arbitrary + mWorkerLoop->PostDelayedTask(task.forget(), 10); + return; } NotifyMaybeChannelError(); @@ -2544,8 +2550,10 @@ MessageChannel::PostErrorNotifyTask() return; // This must be the last code that runs on this thread! - mChannelErrorTask = - NewNonOwningCancelableRunnableMethod(this, &MessageChannel::OnNotifyMaybeChannelError); + mChannelErrorTask = NewNonOwningCancelableRunnableMethod( + "ipc::MessageChannel::OnNotifyMaybeChannelError", + this, + &MessageChannel::OnNotifyMaybeChannelError); RefPtr task = mChannelErrorTask; mWorkerLoop->PostTask(task.forget()); } diff --git a/ipc/glue/MessageLink.cpp b/ipc/glue/MessageLink.cpp index 9bc1a1165e11..4bc46d11c2a4 100644 --- a/ipc/glue/MessageLink.cpp +++ b/ipc/glue/MessageLink.cpp @@ -102,8 +102,11 @@ ProcessLink::Open(mozilla::ipc::Transport* aTransport, MessageLoop *aIOLoop, Sid // If we were never able to open the transport, immediately post an error message. if (mTransport->Unsound_IsClosed()) { - mIOLoop->PostTask(NewNonOwningRunnableMethod(this, &ProcessLink::OnChannelConnectError)); - return; + mIOLoop->PostTask( + NewNonOwningRunnableMethod("ipc::ProcessLink::OnChannelConnectError", + this, + &ProcessLink::OnChannelConnectError)); + return; } { @@ -113,12 +116,18 @@ 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. - mIOLoop->PostTask(NewNonOwningRunnableMethod(this, &ProcessLink::OnChannelOpened)); + mIOLoop->PostTask( + NewNonOwningRunnableMethod("ipc::ProcessLink::OnChannelOpened", + this, + &ProcessLink::OnChannelOpened)); } else { // Transport::Connect() has already been called. Take // over the channel from the previous listener and process // any queued messages. - mIOLoop->PostTask(NewNonOwningRunnableMethod(this, &ProcessLink::OnTakeConnectedChannel)); + mIOLoop->PostTask(NewNonOwningRunnableMethod( + "ipc::ProcessLink::OnTakeConnectedChannel", + this, + &ProcessLink::OnTakeConnectedChannel)); } // Should not wait here if something goes wrong with the channel. @@ -134,7 +143,11 @@ ProcessLink::EchoMessage(Message *msg) mChan->AssertWorkerThread(); mChan->mMonitor->AssertCurrentThreadOwns(); - mIOLoop->PostTask(NewNonOwningRunnableMethod(this, &ProcessLink::OnEchoMessage, msg)); + mIOLoop->PostTask( + NewNonOwningRunnableMethod("ipc::ProcessLink::OnEchoMessage", + this, + &ProcessLink::OnEchoMessage, + msg)); // OnEchoMessage takes ownership of |msg| } @@ -152,7 +165,8 @@ ProcessLink::SendMessage(Message *msg) mChan->AssertWorkerThread(); mChan->mMonitor->AssertCurrentThreadOwns(); - mIOLoop->PostTask(NewNonOwningRunnableMethod(mTransport, &Transport::Send, msg)); + mIOLoop->PostTask(NewNonOwningRunnableMethod( + "IPC::Channel::Send", mTransport, &Transport::Send, msg)); } void @@ -161,7 +175,8 @@ ProcessLink::SendClose() mChan->AssertWorkerThread(); mChan->mMonitor->AssertCurrentThreadOwns(); - mIOLoop->PostTask(NewNonOwningRunnableMethod(this, &ProcessLink::OnCloseChannel)); + mIOLoop->PostTask(NewNonOwningRunnableMethod( + "ipc::ProcessLink::OnCloseChannel", this, &ProcessLink::OnCloseChannel)); } ThreadLink::ThreadLink(MessageChannel *aChan, MessageChannel *aTargetChan) diff --git a/ipc/glue/MessagePump.cpp b/ipc/glue/MessagePump.cpp index c4d2da790929..42aeb699d4fa 100644 --- a/ipc/glue/MessagePump.cpp +++ b/ipc/glue/MessagePump.cpp @@ -42,7 +42,8 @@ class DoWorkRunnable final : public CancelableRunnable, { public: explicit DoWorkRunnable(MessagePump* aPump) - : mPump(aPump) + : CancelableRunnable("ipc::DoWorkRunnable") + , mPump(aPump) { MOZ_ASSERT(aPump); } diff --git a/ipc/glue/TaskFactory.h b/ipc/glue/TaskFactory.h index 4852e369cae0..80b767ed9b6f 100644 --- a/ipc/glue/TaskFactory.h +++ b/ipc/glue/TaskFactory.h @@ -76,11 +76,12 @@ protected: template class RunnableMethod : public Runnable { public: - RunnableMethod(T* obj, Method meth, const Params& params) - : obj_(obj) - , meth_(meth) - , params_(params) { - + RunnableMethod(T* obj, Method meth, const Params& params) + : Runnable("ipc::TaskFactory::RunnableMethod") + , obj_(obj) + , meth_(meth) + , params_(params) + { } NS_IMETHOD Run() override { diff --git a/ipc/ipdl/test/cxx/TestCancel.cpp b/ipc/ipdl/test/cxx/TestCancel.cpp index 854eb51eec7f..719a41f81d88 100644 --- a/ipc/ipdl/test/cxx/TestCancel.cpp +++ b/ipc/ipdl/test/cxx/TestCancel.cpp @@ -76,9 +76,9 @@ TestCancelParent::RecvTest3_2() mozilla::ipc::IPCResult TestCancelParent::RecvDone() { - MessageLoop::current()->PostTask( - NewNonOwningRunnableMethod(this, &TestCancelParent::Close)); - return IPC_OK(); + MessageLoop::current()->PostTask(NewNonOwningRunnableMethod( + "ipc::IToplevelProtocol::Close", this, &TestCancelParent::Close)); + return IPC_OK(); } mozilla::ipc::IPCResult diff --git a/ipc/ipdl/test/cxx/TestDemon.cpp b/ipc/ipdl/test/cxx/TestDemon.cpp index ef87b3b25b0f..160cd424516a 100644 --- a/ipc/ipdl/test/cxx/TestDemon.cpp +++ b/ipc/ipdl/test/cxx/TestDemon.cpp @@ -176,7 +176,10 @@ TestDemonParent::RunUnlimitedSequence() gFlushStack = false; DoAction(); - MessageLoop::current()->PostTask(NewNonOwningRunnableMethod(this, &TestDemonParent::RunUnlimitedSequence)); + MessageLoop::current()->PostTask(NewNonOwningRunnableMethod( + "_ipdltest::TestDemonParent::RunUnlimitedSequence", + this, + &TestDemonParent::RunUnlimitedSequence)); } void @@ -320,7 +323,10 @@ TestDemonChild::RunUnlimitedSequence() gFlushStack = false; DoAction(); - MessageLoop::current()->PostTask(NewNonOwningRunnableMethod(this, &TestDemonChild::RunUnlimitedSequence)); + MessageLoop::current()->PostTask(NewNonOwningRunnableMethod( + "_ipdltest::TestDemonChild::RunUnlimitedSequence", + this, + &TestDemonChild::RunUnlimitedSequence)); } void diff --git a/ipc/ipdl/test/cxx/TestEndpointBridgeMain.cpp b/ipc/ipdl/test/cxx/TestEndpointBridgeMain.cpp index 412077884493..b01c4b81472a 100644 --- a/ipc/ipdl/test/cxx/TestEndpointBridgeMain.cpp +++ b/ipc/ipdl/test/cxx/TestEndpointBridgeMain.cpp @@ -232,7 +232,9 @@ TestEndpointBridgeMainSubChild::RecvHi() // Need to close the channel without message-processing frames on // the C++ stack MessageLoop::current()->PostTask( - NewNonOwningRunnableMethod(this, &TestEndpointBridgeMainSubChild::Close)); + NewNonOwningRunnableMethod("ipc::IToplevelProtocol::Close", + this, + &TestEndpointBridgeMainSubChild::Close)); return IPC_OK(); } diff --git a/ipc/ipdl/test/cxx/TestEndpointOpens.cpp b/ipc/ipdl/test/cxx/TestEndpointOpens.cpp index b99dccb199ca..51bd176d8a79 100644 --- a/ipc/ipdl/test/cxx/TestEndpointOpens.cpp +++ b/ipc/ipdl/test/cxx/TestEndpointOpens.cpp @@ -232,7 +232,9 @@ TestEndpointOpensOpenedChild::RecvHi() // Need to close the channel without message-processing frames on // the C++ stack MessageLoop::current()->PostTask( - NewNonOwningRunnableMethod(this, &TestEndpointOpensOpenedChild::Close)); + NewNonOwningRunnableMethod("ipc::IToplevelProtocol::Close", + this, + &TestEndpointOpensOpenedChild::Close)); return IPC_OK(); } @@ -253,7 +255,9 @@ ShutdownTestEndpointOpensOpenedChild(TestEndpointOpensOpenedChild* child, // Kick off main-thread shutdown. gMainThread->PostTask( - NewNonOwningRunnableMethod(gOpensChild, &TestEndpointOpensChild::Close)); + NewNonOwningRunnableMethod("ipc::IToplevelProtocol::Close", + gOpensChild, + &TestEndpointOpensChild::Close)); } void diff --git a/ipc/ipdl/test/cxx/TestHangs.cpp b/ipc/ipdl/test/cxx/TestHangs.cpp index 178e5fc184d3..9f639e077774 100644 --- a/ipc/ipdl/test/cxx/TestHangs.cpp +++ b/ipc/ipdl/test/cxx/TestHangs.cpp @@ -76,8 +76,8 @@ TestHangsParent::ShouldContinueFromReplyTimeout() // reply should be here; we'll post a task to shut things down. // This must be after OnMaybeDequeueOne() in the event queue. - MessageLoop::current()->PostTask( - NewNonOwningRunnableMethod(this, &TestHangsParent::CleanUp)); + MessageLoop::current()->PostTask(NewNonOwningRunnableMethod( + "_ipdltest::TestHangsParent::CleanUp", this, &TestHangsParent::CleanUp)); GetIPCChannel()->CloseWithTimeout(); diff --git a/ipc/ipdl/test/cxx/TestInterruptRaces.cpp b/ipc/ipdl/test/cxx/TestInterruptRaces.cpp index 4de6dc75996d..52306b8eafa8 100644 --- a/ipc/ipdl/test/cxx/TestInterruptRaces.cpp +++ b/ipc/ipdl/test/cxx/TestInterruptRaces.cpp @@ -27,9 +27,11 @@ TestInterruptRacesParent::Main() mozilla::ipc::IPCResult TestInterruptRacesParent::RecvStartRace() { - MessageLoop::current()->PostTask( - NewNonOwningRunnableMethod(this, &TestInterruptRacesParent::OnRaceTime)); - return IPC_OK(); + MessageLoop::current()->PostTask(NewNonOwningRunnableMethod( + "_ipdltest::TestInterruptRacesParent::OnRaceTime", + this, + &TestInterruptRacesParent::OnRaceTime)); + return IPC_OK(); } void @@ -44,7 +46,9 @@ TestInterruptRacesParent::OnRaceTime() mHasReply = true; MessageLoop::current()->PostTask( - NewNonOwningRunnableMethod(this, &TestInterruptRacesParent::Test2)); + NewNonOwningRunnableMethod("_ipdltest::TestInterruptRacesParent::Test2", + this, + &TestInterruptRacesParent::Test2)); } mozilla::ipc::IPCResult @@ -71,7 +75,9 @@ TestInterruptRacesParent::Test2() puts(" passed"); MessageLoop::current()->PostTask( - NewNonOwningRunnableMethod(this, &TestInterruptRacesParent::Test3)); + NewNonOwningRunnableMethod("_ipdltest::TestInterruptRacesParent::Test3", + this, + &TestInterruptRacesParent::Test3)); } mozilla::ipc::IPCResult diff --git a/ipc/ipdl/test/cxx/TestInterruptShutdownRace.cpp b/ipc/ipdl/test/cxx/TestInterruptShutdownRace.cpp index 650fb985b9b8..5252f538617c 100644 --- a/ipc/ipdl/test/cxx/TestInterruptShutdownRace.cpp +++ b/ipc/ipdl/test/cxx/TestInterruptShutdownRace.cpp @@ -51,9 +51,10 @@ TestInterruptShutdownRaceParent::RecvStartDeath() { // this will be ordered before the OnMaybeDequeueOne event of // Orphan in the queue - MessageLoop::current()->PostTask( - NewNonOwningRunnableMethod(this, - &TestInterruptShutdownRaceParent::StartShuttingDown)); + MessageLoop::current()->PostTask(NewNonOwningRunnableMethod( + "_ipdltest::TestInterruptShutdownRaceParent::StartShuttingDown", + this, + &TestInterruptShutdownRaceParent::StartShuttingDown)); return IPC_OK(); } diff --git a/ipc/ipdl/test/cxx/TestNestedLoops.cpp b/ipc/ipdl/test/cxx/TestNestedLoops.cpp index 3ea4f00ddfce..09a6ca1eabaf 100644 --- a/ipc/ipdl/test/cxx/TestNestedLoops.cpp +++ b/ipc/ipdl/test/cxx/TestNestedLoops.cpp @@ -45,8 +45,10 @@ TestNestedLoopsParent::RecvNonce() // if we have an OnMaybeDequeueOne waiting for us (we may not, due // to the inherent race condition in this test, then this event // must be ordered after it in the queue - MessageLoop::current()->PostTask( - NewNonOwningRunnableMethod(this, &TestNestedLoopsParent::BreakNestedLoop)); + MessageLoop::current()->PostTask(NewNonOwningRunnableMethod( + "_ipdltest::TestNestedLoopsParent::BreakNestedLoop", + this, + &TestNestedLoopsParent::BreakNestedLoop)); // sigh ... spin for a while to let the reply to R arrive puts(" (sleeping to wait for reply to R ... sorry)"); diff --git a/ipc/ipdl/test/cxx/TestUrgentHangs.cpp b/ipc/ipdl/test/cxx/TestUrgentHangs.cpp index 5b3d6093d4db..91a4f0e9ad1a 100644 --- a/ipc/ipdl/test/cxx/TestUrgentHangs.cpp +++ b/ipc/ipdl/test/cxx/TestUrgentHangs.cpp @@ -49,8 +49,11 @@ TestUrgentHangsParent::Main() // Do a second round of testing once the reply to Test2 comes back. MessageLoop::current()->PostDelayedTask( - NewNonOwningRunnableMethod(this, &TestUrgentHangsParent::SecondStage), - 3000); + NewNonOwningRunnableMethod( + "_ipdltest::TestUrgentHangsParent::SecondStage", + this, + &TestUrgentHangsParent::SecondStage), + 3000); } void @@ -67,8 +70,10 @@ TestUrgentHangsParent::SecondStage() fail("sending Test4_1"); MessageLoop::current()->PostDelayedTask( - NewNonOwningRunnableMethod(this, &TestUrgentHangsParent::ThirdStage), - 3000); + NewNonOwningRunnableMethod("_ipdltest::TestUrgentHangsParent::ThirdStage", + this, + &TestUrgentHangsParent::ThirdStage), + 3000); } void @@ -90,8 +95,9 @@ TestUrgentHangsParent::ThirdStage() // Close the channel after the child finishes its work in RecvTest5. MessageLoop::current()->PostDelayedTask( - NewNonOwningRunnableMethod(this, &TestUrgentHangsParent::Close), - 3000); + NewNonOwningRunnableMethod( + "ipc::IToplevelProtocol::Close", this, &TestUrgentHangsParent::Close), + 3000); } mozilla::ipc::IPCResult diff --git a/ipc/mscom/DispatchForwarder.cpp b/ipc/mscom/DispatchForwarder.cpp index 552229b4de65..5cc5b3d15824 100644 --- a/ipc/mscom/DispatchForwarder.cpp +++ b/ipc/mscom/DispatchForwarder.cpp @@ -109,7 +109,7 @@ DispatchForwarder::GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo) hr = mTarget->GetTypeInfo(iTInfo, lcid, ppTInfo); }; MainThreadInvoker invoker; - if (!invoker.Invoke(NS_NewRunnableFunction(fn))) { + if (!invoker.Invoke(NS_NewRunnableFunction("DispatchForwarder::GetTypeInfo", fn))) { return E_UNEXPECTED; } if (FAILED(hr)) { @@ -128,7 +128,7 @@ DispatchForwarder::GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames, hr = mTarget->GetIDsOfNames(riid, rgszNames, cNames, lcid, rgDispId); }; MainThreadInvoker invoker; - if (!invoker.Invoke(NS_NewRunnableFunction(fn))) { + if (!invoker.Invoke(NS_NewRunnableFunction("DispatchForwarder::GetIDsOfNames", fn))) { return E_UNEXPECTED; } return hr; diff --git a/ipc/mscom/EnsureMTA.cpp b/ipc/mscom/EnsureMTA.cpp index f4bc911e9b21..0c543fd88ab2 100644 --- a/ipc/mscom/EnsureMTA.cpp +++ b/ipc/mscom/EnsureMTA.cpp @@ -17,6 +17,7 @@ namespace { class EnterMTARunnable : public mozilla::Runnable { public: + EnterMTARunnable() : mozilla::Runnable("EnterMTARunnable") {} NS_IMETHOD Run() override { mozilla::DebugOnly hr = ::CoInitializeEx(nullptr, @@ -41,7 +42,7 @@ public: ~BackgroundMTAData() { if (mThread) { - mThread->Dispatch(NS_NewRunnableFunction(&::CoUninitialize), + mThread->Dispatch(NS_NewRunnableFunction("BackgroundMTAData::~BackgroundMTAData", &::CoUninitialize), NS_DISPATCH_NORMAL); mThread->Shutdown(); } diff --git a/ipc/mscom/EnsureMTA.h b/ipc/mscom/EnsureMTA.h index c0e1b06cb1cb..8f03942d4389 100644 --- a/ipc/mscom/EnsureMTA.h +++ b/ipc/mscom/EnsureMTA.h @@ -82,7 +82,7 @@ public: }; nsresult rv = - thread->Dispatch(NS_NewRunnableFunction(eventSetter), NS_DISPATCH_NORMAL); + thread->Dispatch(NS_NewRunnableFunction("EnsureMTA", eventSetter), NS_DISPATCH_NORMAL); MOZ_ASSERT(NS_SUCCEEDED(rv)); if (NS_FAILED(rv)) { return; @@ -117,7 +117,8 @@ private: } DebugOnly rv = thread->Dispatch( - NS_NewRunnableFunction(aClosure), NS_DISPATCH_NORMAL); + NS_NewRunnableFunction("mscom::EnsureMTA::AsyncOperation", + aClosure), NS_DISPATCH_NORMAL); MOZ_ASSERT(NS_SUCCEEDED(rv)); } diff --git a/ipc/mscom/Interceptor.cpp b/ipc/mscom/Interceptor.cpp index 4c18bbe26701..913bafbbfc4d 100644 --- a/ipc/mscom/Interceptor.cpp +++ b/ipc/mscom/Interceptor.cpp @@ -558,7 +558,7 @@ Interceptor::QueryInterfaceTarget(REFIID aIid, void** aOutput) MOZ_ASSERT(NS_IsMainThread()); hr = mTarget->QueryInterface(aIid, aOutput); }; - if (!invoker.Invoke(NS_NewRunnableFunction(runOnMainThread))) { + if (!invoker.Invoke(NS_NewRunnableFunction("Interceptor::QueryInterface", runOnMainThread))) { return E_FAIL; } return hr; diff --git a/ipc/mscom/InterceptorLog.cpp b/ipc/mscom/InterceptorLog.cpp index 7a2944d6108f..b1ec185b8c5c 100644 --- a/ipc/mscom/InterceptorLog.cpp +++ b/ipc/mscom/InterceptorLog.cpp @@ -133,7 +133,7 @@ Logger::Logger(const nsACString& aLeafBaseName) } nsCOMPtr openRunnable( - NewNonOwningRunnableMethod(this, &Logger::OpenFile)); + NewNonOwningRunnableMethod("Logger::OpenFile", this, &Logger::OpenFile)); rv = NS_NewNamedThread("COM Intcpt Log", getter_AddRefs(mThread), openRunnable); if (NS_FAILED(rv)) { @@ -181,7 +181,8 @@ nsresult Logger::Shutdown() { MOZ_ASSERT(NS_IsMainThread()); - nsresult rv = mThread->Dispatch(NewNonOwningRunnableMethod(this, + nsresult rv = mThread->Dispatch(NewNonOwningRunnableMethod("Logger::CloseFile", + this, &Logger::CloseFile), NS_DISPATCH_NORMAL); NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Dispatch failed"); @@ -283,7 +284,8 @@ Logger::LogQI(HRESULT aResult, IUnknown* aTarget, REFIID aIid, IUnknown* aInterf MutexAutoLock lock(mMutex); mEntries.AppendElement(line); - mThread->Dispatch(NewNonOwningRunnableMethod(this, &Logger::Flush), + mThread->Dispatch(NewNonOwningRunnableMethod("Logger::Flush", + this, &Logger::Flush), NS_DISPATCH_NORMAL); } @@ -393,7 +395,8 @@ Logger::LogEvent(ICallFrame* aCallFrame, IUnknown* aTargetInterface) // (3) Enqueue event for logging MutexAutoLock lock(mMutex); mEntries.AppendElement(line); - mThread->Dispatch(NewNonOwningRunnableMethod(this, &Logger::Flush), + mThread->Dispatch(NewNonOwningRunnableMethod("Logger::Flush", + this, &Logger::Flush), NS_DISPATCH_NORMAL); } diff --git a/ipc/mscom/MainThreadHandoff.cpp b/ipc/mscom/MainThreadHandoff.cpp index dad9161bd62d..8eec137d5be1 100644 --- a/ipc/mscom/MainThreadHandoff.cpp +++ b/ipc/mscom/MainThreadHandoff.cpp @@ -122,7 +122,8 @@ class HandoffRunnable : public mozilla::Runnable { public: explicit HandoffRunnable(ICallFrame* aCallFrame, IUnknown* aTargetInterface) - : mCallFrame(aCallFrame) + : Runnable("HandoffRunnable") + , mCallFrame(aCallFrame) , mTargetInterface(aTargetInterface) , mResult(E_UNEXPECTED) { @@ -548,7 +549,7 @@ MainThreadHandoff::OnWalkInterface(REFIID aIid, PVOID* aInterface, }; MainThreadInvoker invoker; - invoker.Invoke(NS_NewRunnableFunction(checkFn)); + invoker.Invoke(NS_NewRunnableFunction("MainThreadHandoff::OnWalkInterface", checkFn)); } if (areTargetsEqual) { diff --git a/ipc/mscom/MainThreadInvoker.h b/ipc/mscom/MainThreadInvoker.h index b81a1eef91b7..e087412cbe26 100644 --- a/ipc/mscom/MainThreadInvoker.h +++ b/ipc/mscom/MainThreadInvoker.h @@ -37,11 +37,12 @@ private: template inline bool -InvokeOnMainThread(Class* aObject, void (Class::*aMethod)(Args...), +InvokeOnMainThread(const char* aName, + Class* aObject, void (Class::*aMethod)(Args...), Args... aArgs) { nsCOMPtr runnable( - NewNonOwningRunnableMethod(aObject, aMethod, + NewNonOwningRunnableMethod(aName, aObject, aMethod, Forward(aArgs)...)); MainThreadInvoker invoker; diff --git a/ipc/mscom/Ptr.h b/ipc/mscom/Ptr.h index 8b83cc7a371a..c4fc2d3b6f85 100644 --- a/ipc/mscom/Ptr.h +++ b/ipc/mscom/Ptr.h @@ -41,7 +41,8 @@ struct MainThreadRelease return; } DebugOnly rv = - NS_DispatchToMainThread(NewNonOwningRunnableMethod(aPtr, + NS_DispatchToMainThread(NewNonOwningRunnableMethod("mscom::MainThreadRelease", + aPtr, &T::Release)); MOZ_ASSERT(NS_SUCCEEDED(rv)); } diff --git a/js/xpconnect/loader/ChromeScriptLoader.cpp b/js/xpconnect/loader/ChromeScriptLoader.cpp index 6bda60fee844..fb771bcf9a20 100644 --- a/js/xpconnect/loader/ChromeScriptLoader.cpp +++ b/js/xpconnect/loader/ChromeScriptLoader.cpp @@ -37,15 +37,17 @@ public: NS_DECL_NSIINCREMENTALSTREAMLOADEROBSERVER NS_DECL_NSIRUNNABLE - AsyncScriptCompiler(JSContext* aCx, nsIGlobalObject* aGlobal, + AsyncScriptCompiler(JSContext* aCx, + nsIGlobalObject* aGlobal, const nsACString& aURL, const CompileScriptOptionsDictionary& aOptions, Promise* aPromise) - : mOptions(aCx) - , mURL(aURL) - , mGlobalObject(aGlobal) - , mPromise(aPromise) - , mCharset(aOptions.mCharset) + : mozilla::Runnable("AsyncScriptCompiler") + , mOptions(aCx) + , mURL(aURL) + , mGlobalObject(aGlobal) + , mPromise(aPromise) + , mCharset(aOptions.mCharset) { mOptions.setVersion(JSVERSION_DEFAULT) .setNoScriptRval(!aOptions.mHasReturnValue) diff --git a/js/xpconnect/loader/ScriptPreloader.cpp b/js/xpconnect/loader/ScriptPreloader.cpp index 3152a2335756..ca33e3a1aa5e 100644 --- a/js/xpconnect/loader/ScriptPreloader.cpp +++ b/js/xpconnect/loader/ScriptPreloader.cpp @@ -571,8 +571,10 @@ ScriptPreloader::WriteCache() MonitorAutoUnlock mau(mSaveMonitor); NS_DispatchToMainThread( - NewRunnableMethod(this, &ScriptPreloader::PrepareCacheWrite), - NS_DISPATCH_SYNC); + NewRunnableMethod("ScriptPreloader::PrepareCacheWrite", + this, + &ScriptPreloader::PrepareCacheWrite), + NS_DISPATCH_SYNC); } if (mSaveComplete) { @@ -802,7 +804,9 @@ ScriptPreloader::OffThreadDecodeCallback(void* token, void* context) if (cache->mToken && !cache->mFinishDecodeRunnablePending) { cache->mFinishDecodeRunnablePending = true; NS_DispatchToMainThread( - NewRunnableMethod(cache, &ScriptPreloader::DoFinishOffThreadDecode)); + NewRunnableMethod("ScriptPreloader::DoFinishOffThreadDecode", + cache, + &ScriptPreloader::DoFinishOffThreadDecode)); } } diff --git a/js/xpconnect/loader/mozJSSubScriptLoader.cpp b/js/xpconnect/loader/mozJSSubScriptLoader.cpp index 47777a15c36c..d813908725ab 100644 --- a/js/xpconnect/loader/mozJSSubScriptLoader.cpp +++ b/js/xpconnect/loader/mozJSSubScriptLoader.cpp @@ -762,9 +762,11 @@ class NotifyPrecompilationCompleteRunnable : public Runnable public: NS_DECL_NSIRUNNABLE - explicit NotifyPrecompilationCompleteRunnable(ScriptPrecompiler* aPrecompiler) - : mPrecompiler(aPrecompiler) - , mToken(nullptr) + explicit NotifyPrecompilationCompleteRunnable( + ScriptPrecompiler* aPrecompiler) + : mozilla::Runnable("NotifyPrecompilationCompleteRunnable") + , mPrecompiler(aPrecompiler) + , mToken(nullptr) {} void SetToken(void* aToken) { diff --git a/js/xpconnect/src/XPCComponents.cpp b/js/xpconnect/src/XPCComponents.cpp index 933a91850628..95cf5f8796d3 100644 --- a/js/xpconnect/src/XPCComponents.cpp +++ b/js/xpconnect/src/XPCComponents.cpp @@ -2635,7 +2635,11 @@ class PreciseGCRunnable : public Runnable { public: PreciseGCRunnable(ScheduledGCCallback* aCallback, bool aShrinking) - : mCallback(aCallback), mShrinking(aShrinking) {} + : mozilla::Runnable("PreciseGCRunnable") + , mCallback(aCallback) + , mShrinking(aShrinking) + { + } NS_IMETHOD Run() override { diff --git a/js/xpconnect/src/XPCJSRuntime.cpp b/js/xpconnect/src/XPCJSRuntime.cpp index 972f72ad04da..f7f2d3d98707 100644 --- a/js/xpconnect/src/XPCJSRuntime.cpp +++ b/js/xpconnect/src/XPCJSRuntime.cpp @@ -746,7 +746,8 @@ XPCJSRuntime::DoCycleCollectionCallback(JSContext* cx) // The GC has detected that a CC at this point would collect a tremendous // amount of garbage that is being revivified unnecessarily. NS_DispatchToCurrentThread( - NS_NewRunnableFunction([](){nsJSContext::CycleCollectNow(nullptr);})); + NS_NewRunnableFunction("XPCJSRuntime::DoCycleCollectionCallback", + []() { nsJSContext::CycleCollectNow(nullptr); })); XPCJSRuntime* self = nsXPConnect::GetRuntimeInstance(); if (!self) @@ -962,9 +963,10 @@ class LargeAllocationFailureRunnable final : public Runnable public: LargeAllocationFailureRunnable() - : mMutex("LargeAllocationFailureRunnable::mMutex"), - mCondVar(mMutex, "LargeAllocationFailureRunnable::mCondVar"), - mWaiting(true) + : mozilla::Runnable("LargeAllocationFailureRunnable") + , mMutex("LargeAllocationFailureRunnable::mMutex") + , mCondVar(mMutex, "LargeAllocationFailureRunnable::mCondVar") + , mWaiting(true) { MOZ_ASSERT(!NS_IsMainThread()); } diff --git a/layout/base/AccessibleCaretEventHub.cpp b/layout/base/AccessibleCaretEventHub.cpp index dded3f6335f4..2c777396c857 100644 --- a/layout/base/AccessibleCaretEventHub.cpp +++ b/layout/base/AccessibleCaretEventHub.cpp @@ -655,8 +655,12 @@ AccessibleCaretEventHub::LaunchLongTapInjector() } int32_t longTapDelay = gfxPrefs::UiClickHoldContextMenusDelay(); - mLongTapInjectorTimer->InitWithFuncCallback(FireLongTap, this, longTapDelay, - nsITimer::TYPE_ONE_SHOT); + mLongTapInjectorTimer->InitWithNamedFuncCallback( + FireLongTap, + this, + longTapDelay, + nsITimer::TYPE_ONE_SHOT, + "AccessibleCaretEventHub::LaunchLongTapInjector"); } void @@ -753,8 +757,12 @@ AccessibleCaretEventHub::LaunchScrollEndInjector() return; } - mScrollEndInjectorTimer->InitWithFuncCallback( - FireScrollEnd, this, kScrollEndTimerDelay, nsITimer::TYPE_ONE_SHOT); + mScrollEndInjectorTimer->InitWithNamedFuncCallback( + FireScrollEnd, + this, + kScrollEndTimerDelay, + nsITimer::TYPE_ONE_SHOT, + "AccessibleCaretEventHub::LaunchScrollEndInjector"); } void diff --git a/layout/base/PresShell.cpp b/layout/base/PresShell.cpp index 3a9e3b56d680..6ba4c4c75f91 100644 --- a/layout/base/PresShell.cpp +++ b/layout/base/PresShell.cpp @@ -542,7 +542,10 @@ class nsBeforeFirstPaintDispatcher : public Runnable { public: explicit nsBeforeFirstPaintDispatcher(nsIDocument* aDocument) - : mDocument(aDocument) {} + : mozilla::Runnable("nsBeforeFirstPaintDispatcher") + , mDocument(aDocument) + { + } // Fires the "before-first-paint" event so that interested parties (right now, the // mobile browser) are aware of it. @@ -2019,8 +2022,8 @@ PresShell::ResizeReflowIgnoreOverride(nscoord aWidth, nscoord aHeight, nscoord a "AsyncResizeEventCallback"); } } else { - RefPtr> event = - NewRunnableMethod(this, &PresShell::FireResizeEvent); + RefPtr> event = NewRunnableMethod( + "PresShell::FireResizeEvent", this, &PresShell::FireResizeEvent); nsresult rv = mDocument->Dispatch("PresShell::FireResizeEvent", TaskCategory::Other, do_AddRef(event)); @@ -6197,7 +6200,9 @@ PresShell::ScheduleApproximateFrameVisibilityUpdateNow() } RefPtr> event = - NewRunnableMethod(this, &PresShell::UpdateApproximateFrameVisibility); + NewRunnableMethod("PresShell::UpdateApproximateFrameVisibility", + this, + &PresShell::UpdateApproximateFrameVisibility); nsresult rv = mDocument->Dispatch("PresShell::UpdateApproximateFrameVisibility", TaskCategory::Other, diff --git a/layout/base/ZoomConstraintsClient.cpp b/layout/base/ZoomConstraintsClient.cpp index b2bdc4cc4870..77ccd80eb22b 100644 --- a/layout/base/ZoomConstraintsClient.cpp +++ b/layout/base/ZoomConstraintsClient.cpp @@ -160,7 +160,9 @@ ZoomConstraintsClient::Observe(nsISupports* aSubject, const char* aTopic, const // returns the updated value. RefPtr> event = - NewRunnableMethod(this, &ZoomConstraintsClient::RefreshZoomConstraints); + NewRunnableMethod("ZoomConstraintsClient::RefreshZoomConstraints", + this, + &ZoomConstraintsClient::RefreshZoomConstraints); mDocument->Dispatch("ZoomConstraintsClient::RefreshZoomConstraints", TaskCategory::Other, event.forget()); diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index acd32c6993cd..9110394bac67 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -7931,19 +7931,23 @@ nsLayoutUtils::PostRestyleEvent(Element* aElement, } } -nsSetAttrRunnable::nsSetAttrRunnable(nsIContent* aContent, nsIAtom* aAttrName, +nsSetAttrRunnable::nsSetAttrRunnable(nsIContent* aContent, + nsIAtom* aAttrName, const nsAString& aValue) - : mContent(aContent), - mAttrName(aAttrName), - mValue(aValue) + : mozilla::Runnable("nsSetAttrRunnable") + , mContent(aContent) + , mAttrName(aAttrName) + , mValue(aValue) { NS_ASSERTION(aContent && aAttrName, "Missing stuff, prepare to crash"); } -nsSetAttrRunnable::nsSetAttrRunnable(nsIContent* aContent, nsIAtom* aAttrName, +nsSetAttrRunnable::nsSetAttrRunnable(nsIContent* aContent, + nsIAtom* aAttrName, int32_t aValue) - : mContent(aContent), - mAttrName(aAttrName) + : mozilla::Runnable("nsSetAttrRunnable") + , mContent(aContent) + , mAttrName(aAttrName) { NS_ASSERTION(aContent && aAttrName, "Missing stuff, prepare to crash"); mValue.AppendInt(aValue); @@ -7957,8 +7961,9 @@ nsSetAttrRunnable::Run() nsUnsetAttrRunnable::nsUnsetAttrRunnable(nsIContent* aContent, nsIAtom* aAttrName) - : mContent(aContent), - mAttrName(aAttrName) + : mozilla::Runnable("nsUnsetAttrRunnable") + , mContent(aContent) + , mAttrName(aAttrName) { NS_ASSERTION(aContent && aAttrName, "Missing stuff, prepare to crash"); } diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index b8215e9e2ffd..4fe3c11fbb23 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -1798,7 +1798,9 @@ nsPresContext::ThemeChanged() sThemeChanged = true; nsCOMPtr ev = - NewRunnableMethod(this, &nsPresContext::ThemeChangedInternal); + NewRunnableMethod("nsPresContext::ThemeChangedInternal", + this, + &nsPresContext::ThemeChangedInternal); nsresult rv = Document()->Dispatch("nsPresContext::ThemeChangedInternal", TaskCategory::Other, ev.forget()); @@ -1861,7 +1863,9 @@ nsPresContext::SysColorChanged() if (!mPendingSysColorChanged) { sLookAndFeelChanged = true; nsCOMPtr ev = - NewRunnableMethod(this, &nsPresContext::SysColorChangedInternal); + NewRunnableMethod("nsPresContext::SysColorChangedInternal", + this, + &nsPresContext::SysColorChangedInternal); nsresult rv = Document()->Dispatch("nsPresContext::SysColorChangedInternal", TaskCategory::Other, ev.forget()); @@ -1896,7 +1900,9 @@ nsPresContext::UIResolutionChanged() { if (!mPendingUIResolutionChanged) { nsCOMPtr ev = - NewRunnableMethod(this, &nsPresContext::UIResolutionChangedInternal); + NewRunnableMethod("nsPresContext::UIResolutionChangedInternal", + this, + &nsPresContext::UIResolutionChangedInternal); nsresult rv = Document()->Dispatch("nsPresContext::UIResolutionChangedInternal", TaskCategory::Other, @@ -2662,11 +2668,13 @@ nsPresContext::NotifyDidPaintSubdocumentCallback(nsIDocument* aDocument, void* a class DelayedFireDOMPaintEvent : public Runnable { public: - DelayedFireDOMPaintEvent(nsPresContext* aPresContext, - nsTArray* aList, - uint64_t aTransactionId, - const mozilla::TimeStamp& aTimeStamp = mozilla::TimeStamp()) - : mPresContext(aPresContext) + DelayedFireDOMPaintEvent( + nsPresContext* aPresContext, + nsTArray* aList, + uint64_t aTransactionId, + const mozilla::TimeStamp& aTimeStamp = mozilla::TimeStamp()) + : mozilla::Runnable("DelayedFireDOMPaintEvent") + , mPresContext(aPresContext) , mTransactionId(aTransactionId) , mTimeStamp(aTimeStamp) { diff --git a/layout/base/nsRefreshDriver.cpp b/layout/base/nsRefreshDriver.cpp index e5f7bad37f2f..df8a42bde400 100644 --- a/layout/base/nsRefreshDriver.cpp +++ b/layout/base/nsRefreshDriver.cpp @@ -397,7 +397,12 @@ protected: mTargetTime = mLastFireTime + mRateDuration; uint32_t delay = static_cast(mRateMilliseconds); - mTimer->InitWithFuncCallback(TimerTick, this, delay, nsITimer::TYPE_ONE_SHOT); + mTimer->InitWithNamedFuncCallback( + TimerTick, + this, + delay, + nsITimer::TYPE_ONE_SHOT, + "SimpleTimerBasedRefreshDriverTimer::StartTimer"); } void StopTimer() override @@ -489,7 +494,12 @@ private: public: ParentProcessVsyncNotifier(RefreshDriverVsyncObserver* aObserver, TimeStamp aVsyncTimestamp) - : mObserver(aObserver), mVsyncTimestamp(aVsyncTimestamp) {} + : Runnable("VsyncRefreshDriverTimer::RefreshDriverVsyncObserver::" + "ParentProcessVsyncNotifier") + , mObserver(aObserver) + , mVsyncTimestamp(aVsyncTimestamp) + { + } NS_DECL_ISUPPORTS_INHERITED @@ -794,7 +804,12 @@ protected: // that we tick at consistent intervals. TimeStamp newTarget = aNowTime + mRateDuration; uint32_t delay = static_cast((newTarget - aNowTime).ToMilliseconds()); - mTimer->InitWithFuncCallback(TimerTick, this, delay, nsITimer::TYPE_ONE_SHOT); + mTimer->InitWithNamedFuncCallback( + TimerTick, + this, + delay, + nsITimer::TYPE_ONE_SHOT, + "StartupRefreshDriverTimer::ScheduleNextTick"); mTargetTime = newTarget; } }; @@ -869,7 +884,11 @@ protected: mTargetTime = mLastFireTime + mRateDuration; uint32_t delay = static_cast(mRateMilliseconds); - mTimer->InitWithFuncCallback(TimerTickOne, this, delay, nsITimer::TYPE_ONE_SHOT); + mTimer->InitWithNamedFuncCallback(TimerTickOne, + this, + delay, + nsITimer::TYPE_ONE_SHOT, + "InactiveRefreshDriverTimer::StartTimer"); } void StopTimer() override @@ -896,7 +915,12 @@ protected: // this doesn't need to be precise; do a simple schedule uint32_t delay = static_cast(mNextTickDuration); - mTimer->InitWithFuncCallback(TimerTickOne, this, delay, nsITimer::TYPE_ONE_SHOT); + mTimer->InitWithNamedFuncCallback( + TimerTickOne, + this, + delay, + nsITimer::TYPE_ONE_SHOT, + "InactiveRefreshDriverTimer::ScheduleNextTick"); LOG("[%p] inactive timer next tick in %f ms [index %d/%d]", this, mNextTickDuration, mNextDriverIndex, GetRefreshDriverCount()); @@ -2104,8 +2128,8 @@ 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. - RefPtr> event = - NewRunnableMethod(this, &nsRefreshDriver::DoRefresh); + RefPtr> event = NewRunnableMethod( + "nsRefreshDriver::DoRefresh", this, &nsRefreshDriver::DoRefresh); nsPresContext* pc = GetPresContext(); if (pc) { pc->Document()->Dispatch("nsRefreshDriver::DoRefresh", diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index 77eea317de40..191f16177cac 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -383,7 +383,8 @@ class nsResizeDropdownAtFinalPosition final { public: explicit nsResizeDropdownAtFinalPosition(nsComboboxControlFrame* aFrame) - : mFrame(aFrame) + : mozilla::Runnable("nsResizeDropdownAtFinalPosition") + , mFrame(aFrame) { } @@ -519,7 +520,11 @@ nsComboboxControlFrame::GetCSSTransformTranslation() class nsAsyncRollup : public Runnable { public: - explicit nsAsyncRollup(nsComboboxControlFrame* aFrame) : mFrame(aFrame) {} + explicit nsAsyncRollup(nsComboboxControlFrame* aFrame) + : mozilla::Runnable("nsAsyncRollup") + , mFrame(aFrame) + { + } NS_IMETHOD Run() override { if (mFrame.IsAlive()) { @@ -534,7 +539,11 @@ public: class nsAsyncResize : public Runnable { public: - explicit nsAsyncResize(nsComboboxControlFrame* aFrame) : mFrame(aFrame) {} + explicit nsAsyncResize(nsComboboxControlFrame* aFrame) + : mozilla::Runnable("nsAsyncResize") + , mFrame(aFrame) + { + } NS_IMETHOD Run() override { if (mFrame.IsAlive()) { diff --git a/layout/forms/nsComboboxControlFrame.h b/layout/forms/nsComboboxControlFrame.h index 81e76e22c6d2..93eb683b7244 100644 --- a/layout/forms/nsComboboxControlFrame.h +++ b/layout/forms/nsComboboxControlFrame.h @@ -253,7 +253,11 @@ protected: class RedisplayTextEvent : public mozilla::Runnable { public: NS_DECL_NSIRUNNABLE - explicit RedisplayTextEvent(nsComboboxControlFrame *c) : mControlFrame(c) {} + explicit RedisplayTextEvent(nsComboboxControlFrame* c) + : mozilla::Runnable("nsComboboxControlFrame::RedisplayTextEvent") + , mControlFrame(c) + { + } void Revoke() { mControlFrame = nullptr; } private: nsComboboxControlFrame *mControlFrame; diff --git a/layout/forms/nsDateTimeControlFrame.cpp b/layout/forms/nsDateTimeControlFrame.cpp index d896ba9308df..58f661b5c734 100644 --- a/layout/forms/nsDateTimeControlFrame.cpp +++ b/layout/forms/nsDateTimeControlFrame.cpp @@ -403,7 +403,9 @@ nsDateTimeControlFrame::AttributeChanged(int32_t aNameSpaceID, do_QueryInterface(mInputAreaContent); if (aAttribute == nsGkAtoms::value) { if (inputAreaContent) { - nsContentUtils::AddScriptRunner(NewRunnableMethod(inputAreaContent, + nsContentUtils::AddScriptRunner(NewRunnableMethod( + "nsIDateTimeInputArea::NotifyInputElementValueChanged", + inputAreaContent, &nsIDateTimeInputArea::NotifyInputElementValueChanged)); } } else { diff --git a/layout/forms/nsDateTimeControlFrame.h b/layout/forms/nsDateTimeControlFrame.h index 2e71f86f4d6f..20f65aca2d69 100644 --- a/layout/forms/nsDateTimeControlFrame.h +++ b/layout/forms/nsDateTimeControlFrame.h @@ -87,7 +87,8 @@ private: { public: explicit SyncDisabledStateEvent(nsDateTimeControlFrame* aFrame) - : mFrame(aFrame) + : mozilla::Runnable("nsDateTimeControlFrame::SyncDisabledStateEvent") + , mFrame(aFrame) {} NS_IMETHOD Run() override diff --git a/layout/forms/nsFileControlFrame.h b/layout/forms/nsFileControlFrame.h index 57f96ac0f447..efc778c375f3 100644 --- a/layout/forms/nsFileControlFrame.h +++ b/layout/forms/nsFileControlFrame.h @@ -95,7 +95,8 @@ protected: { public: explicit SyncDisabledStateEvent(nsFileControlFrame* aFrame) - : mFrame(aFrame) + : mozilla::Runnable("nsFileControlFrame::SyncDisabledStateEvent") + , mFrame(aFrame) {} NS_IMETHOD Run() override { diff --git a/layout/forms/nsNumberControlFrame.cpp b/layout/forms/nsNumberControlFrame.cpp index ab7d3d5a193c..c2c31ef40998 100644 --- a/layout/forms/nsNumberControlFrame.cpp +++ b/layout/forms/nsNumberControlFrame.cpp @@ -303,8 +303,9 @@ class FocusTextField : public Runnable { public: FocusTextField(nsIContent* aNumber, nsIContent* aTextField) - : mNumber(aNumber), - mTextField(aTextField) + : mozilla::Runnable("FocusTextField") + , mNumber(aNumber) + , mTextField(aTextField) {} NS_IMETHOD Run() override diff --git a/layout/forms/nsNumberControlFrame.h b/layout/forms/nsNumberControlFrame.h index 826a0119f052..b7a53489fd53 100644 --- a/layout/forms/nsNumberControlFrame.h +++ b/layout/forms/nsNumberControlFrame.h @@ -174,7 +174,8 @@ private: { public: explicit SyncDisabledStateEvent(nsNumberControlFrame* aFrame) - : mFrame(aFrame) + : mozilla::Runnable("nsNumberControlFrame::SyncDisabledStateEvent") + , mFrame(aFrame) {} NS_IMETHOD Run() override diff --git a/layout/forms/nsTextControlFrame.h b/layout/forms/nsTextControlFrame.h index 3b04fdb622d9..b657ce3f2064 100644 --- a/layout/forms/nsTextControlFrame.h +++ b/layout/forms/nsTextControlFrame.h @@ -233,8 +233,11 @@ protected: class EditorInitializer : public mozilla::Runnable { public: - explicit EditorInitializer(nsTextControlFrame* aFrame) : - mFrame(aFrame) {} + explicit EditorInitializer(nsTextControlFrame* aFrame) + : mozilla::Runnable("nsTextControlFrame::EditorInitializer") + , mFrame(aFrame) + { + } NS_IMETHOD Run() override; @@ -252,8 +255,11 @@ protected: class ScrollOnFocusEvent : public mozilla::Runnable { public: - explicit ScrollOnFocusEvent(nsTextControlFrame* aFrame) : - mFrame(aFrame) {} + explicit ScrollOnFocusEvent(nsTextControlFrame* aFrame) + : mozilla::Runnable("nsTextControlFrame::ScrollOnFocusEvent") + , mFrame(aFrame) + { + } NS_DECL_NSIRUNNABLE diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index cc581b1fe05c..b051f93f735c 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -2548,9 +2548,12 @@ void ScrollFrameHelper::MarkRecentlyScrolled() void ScrollFrameHelper::ResetDisplayPortExpiryTimer() { if (mDisplayPortExpiryTimer) { - mDisplayPortExpiryTimer->InitWithFuncCallback( - RemoveDisplayPortCallback, this, - gfxPrefs::APZDisplayPortExpiryTime(), nsITimer::TYPE_ONE_SHOT); + mDisplayPortExpiryTimer->InitWithNamedFuncCallback( + RemoveDisplayPortCallback, + this, + gfxPrefs::APZDisplayPortExpiryTime(), + nsITimer::TYPE_ONE_SHOT, + "ScrollFrameHelper::ResetDisplayPortExpiryTimer"); } } @@ -2710,8 +2713,12 @@ ScrollFrameHelper::ScheduleSyntheticMouseMove() } } - mScrollActivityTimer->InitWithFuncCallback( - ScrollActivityCallback, this, 100, nsITimer::TYPE_ONE_SHOT); + mScrollActivityTimer->InitWithNamedFuncCallback( + ScrollActivityCallback, + this, + 100, + nsITimer::TYPE_ONE_SHOT, + "ScrollFrameHelper::ScheduleSyntheticMouseMove"); } void diff --git a/layout/generic/nsGfxScrollFrame.h b/layout/generic/nsGfxScrollFrame.h index 4a641b362241..9531cc839f81 100644 --- a/layout/generic/nsGfxScrollFrame.h +++ b/layout/generic/nsGfxScrollFrame.h @@ -137,7 +137,11 @@ public: class AsyncScrollPortEvent : public Runnable { public: NS_DECL_NSIRUNNABLE - explicit AsyncScrollPortEvent(ScrollFrameHelper *helper) : mHelper(helper) {} + explicit AsyncScrollPortEvent(ScrollFrameHelper* helper) + : Runnable("ScrollFrameHelper::AsyncScrollPortEvent") + , mHelper(helper) + { + } void Revoke() { mHelper = nullptr; } private: ScrollFrameHelper *mHelper; @@ -146,7 +150,11 @@ public: class ScrolledAreaEvent : public Runnable { public: NS_DECL_NSIRUNNABLE - explicit ScrolledAreaEvent(ScrollFrameHelper *helper) : mHelper(helper) {} + explicit ScrolledAreaEvent(ScrollFrameHelper* helper) + : Runnable("ScrollFrameHelper::ScrolledAreaEvent") + , mHelper(helper) + { + } void Revoke() { mHelper = nullptr; } private: ScrollFrameHelper *mHelper; diff --git a/layout/generic/nsPluginFrame.h b/layout/generic/nsPluginFrame.h index 14484223b952..44373bd527c4 100644 --- a/layout/generic/nsPluginFrame.h +++ b/layout/generic/nsPluginFrame.h @@ -292,9 +292,12 @@ private: class PluginEventNotifier : public mozilla::Runnable { public: - explicit PluginEventNotifier(const nsString &aEventType) : - mEventType(aEventType) {} - + explicit PluginEventNotifier(const nsString& aEventType) + : mozilla::Runnable("nsPluginFrame::PluginEventNotifier") + , mEventType(aEventType) + { + } + NS_IMETHOD Run() override; private: nsString mEventType; diff --git a/layout/generic/nsSubDocumentFrame.cpp b/layout/generic/nsSubDocumentFrame.cpp index 9bf63a21ea87..6fa63a387f85 100644 --- a/layout/generic/nsSubDocumentFrame.cpp +++ b/layout/generic/nsSubDocumentFrame.cpp @@ -84,7 +84,11 @@ NS_QUERYFRAME_TAIL_INHERITING(nsAtomicContainerFrame) class AsyncFrameInit : public Runnable { public: - explicit AsyncFrameInit(nsIFrame* aFrame) : mFrame(aFrame) {} + explicit AsyncFrameInit(nsIFrame* aFrame) + : mozilla::Runnable("AsyncFrameInit") + , mFrame(aFrame) + { + } NS_IMETHOD Run() override { PROFILER_LABEL("mozilla", "AsyncFrameInit::Run", js::ProfileEntry::Category::OTHER); @@ -908,10 +912,11 @@ public: nsFrameLoader* aFrameLoader, nsIPresShell* aPresShell, bool aHideViewerIfFrameless) - : mFrameElement(aFrameElement), - mFrameLoader(aFrameLoader), - mPresShell(aPresShell), - mHideViewerIfFrameless(aHideViewerIfFrameless) + : mozilla::Runnable("nsHideViewer") + , mFrameElement(aFrameElement) + , mFrameLoader(aFrameLoader) + , mPresShell(aPresShell) + , mHideViewerIfFrameless(aHideViewerIfFrameless) { NS_ASSERTION(mFrameElement, "Must have a frame element"); NS_ASSERTION(mFrameLoader, "Must have a frame loader"); diff --git a/layout/generic/nsVideoFrame.cpp b/layout/generic/nsVideoFrame.cpp index 6ba2cd8705e1..a9d235f199d5 100644 --- a/layout/generic/nsVideoFrame.cpp +++ b/layout/generic/nsVideoFrame.cpp @@ -265,7 +265,10 @@ class DispatchResizeToControls : public Runnable { public: explicit DispatchResizeToControls(nsIContent* aContent) - : mContent(aContent) {} + : mozilla::Runnable("DispatchResizeToControls") + , mContent(aContent) + { + } NS_IMETHOD Run() override { nsContentUtils::DispatchTrustedEvent(mContent->OwnerDoc(), mContent, NS_LITERAL_STRING("resizevideocontrols"), diff --git a/layout/ipc/VsyncParent.cpp b/layout/ipc/VsyncParent.cpp index e0d20101c84c..d15e71d41d56 100644 --- a/layout/ipc/VsyncParent.cpp +++ b/layout/ipc/VsyncParent.cpp @@ -50,7 +50,8 @@ VsyncParent::NotifyVsync(TimeStamp aTimeStamp) // Called on hardware vsync thread. We should post to current ipc thread. MOZ_ASSERT(!IsOnBackgroundThread()); nsCOMPtr vsyncEvent = - NewRunnableMethod(this, + NewRunnableMethod("layout::VsyncParent::DispatchVsyncEvent", + this, &VsyncParent::DispatchVsyncEvent, aTimeStamp); MOZ_ALWAYS_SUCCEEDS(mBackgroundThread->Dispatch(vsyncEvent, NS_DISPATCH_NORMAL)); diff --git a/layout/printing/nsPrintEngine.cpp b/layout/printing/nsPrintEngine.cpp index 82ba2dc215d1..711429e23e84 100644 --- a/layout/printing/nsPrintEngine.cpp +++ b/layout/printing/nsPrintEngine.cpp @@ -3690,8 +3690,10 @@ nsPrintEngine::Observe(nsISupports *aSubject, const char *aTopic, const char16_t //--------------------------------------------------------------- class nsPrintCompletionEvent : public Runnable { public: - explicit nsPrintCompletionEvent(nsIDocumentViewerPrint *docViewerPrint) - : mDocViewerPrint(docViewerPrint) { + explicit nsPrintCompletionEvent(nsIDocumentViewerPrint* docViewerPrint) + : mozilla::Runnable("nsPrintCompletionEvent") + , mDocViewerPrint(docViewerPrint) + { NS_ASSERTION(mDocViewerPrint, "mDocViewerPrint is null."); } diff --git a/layout/style/FontFaceSet.cpp b/layout/style/FontFaceSet.cpp index 44eaded56a60..7de79d532ecc 100644 --- a/layout/style/FontFaceSet.cpp +++ b/layout/style/FontFaceSet.cpp @@ -1498,7 +1498,9 @@ FontFaceSet::DispatchCheckLoadingFinishedAfterDelay() } nsCOMPtr checkTask = - NewRunnableMethod(this, &FontFaceSet::CheckLoadingFinishedAfterDelay); + NewRunnableMethod("dom::FontFaceSet::CheckLoadingFinishedAfterDelay", + this, + &FontFaceSet::CheckLoadingFinishedAfterDelay); mDocument->Dispatch("FontFaceSet::CheckLoadingFinishedAfterDelay", TaskCategory::Other, checkTask.forget()); } diff --git a/layout/style/nsFontFaceLoader.cpp b/layout/style/nsFontFaceLoader.cpp index d8bdee0dd063..ddc1068a2b7b 100644 --- a/layout/style/nsFontFaceLoader.cpp +++ b/layout/style/nsFontFaceLoader.cpp @@ -141,10 +141,12 @@ nsFontFaceLoader::LoadTimerCallback(nsITimer* aTimer, void* aClosure) ufe->mFontDataLoadingState = gfxUserFontEntry::LOADING_ALMOST_DONE; uint32_t delay; loader->mLoadTimer->GetDelay(&delay); - loader->mLoadTimer->InitWithFuncCallback(LoadTimerCallback, - static_cast(loader), - delay >> 1, - nsITimer::TYPE_ONE_SHOT); + loader->mLoadTimer->InitWithNamedFuncCallback( + LoadTimerCallback, + static_cast(loader), + delay >> 1, + nsITimer::TYPE_ONE_SHOT, + "nsFontFaceLoader::LoadTimerCallback"); updateUserFontSet = false; LOG(("userfonts (%p) 75%% done, resetting timer\n", loader)); } diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index 47b8fad406a7..e4d7d4e21b7d 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -1937,7 +1937,8 @@ public: already_AddRefed aRequestProxy, already_AddRefed aImageValue, already_AddRefed aImageTracker) - : mModeFlags(aModeFlags) + : mozilla::Runnable("StyleImageRequestCleanupTask") + , mModeFlags(aModeFlags) , mRequestProxy(aRequestProxy) , mImageValue(aImageValue) , mImageTracker(aImageTracker) @@ -2127,6 +2128,7 @@ CachedBorderImageData::GetCachedSVGViewportSize() struct PurgeCachedImagesTask : mozilla::Runnable { + PurgeCachedImagesTask() : mozilla::Runnable("PurgeCachedImagesTask") {} NS_IMETHOD Run() final { mSubImages.Clear(); diff --git a/layout/svg/SVGTextFrame.h b/layout/svg/SVGTextFrame.h index 6ceb82cf22dd..bd4c450f8e3e 100644 --- a/layout/svg/SVGTextFrame.h +++ b/layout/svg/SVGTextFrame.h @@ -130,7 +130,11 @@ private: class GlyphMetricsUpdater : public Runnable { public: NS_DECL_NSIRUNNABLE - explicit GlyphMetricsUpdater(SVGTextFrame* aFrame) : mFrame(aFrame) { } + explicit GlyphMetricsUpdater(SVGTextFrame* aFrame) + : Runnable("GlyphMetricsUpdater") + , mFrame(aFrame) + { + } static void Run(SVGTextFrame* aFrame); void Revoke() { mFrame = nullptr; } private: diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index 35da37222846..9f56979bdd20 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -5035,8 +5035,11 @@ GetPaintStyleInfo(const nsIFrame* aFrame, class nsDelayedCalcBCBorders : public Runnable { public: - explicit nsDelayedCalcBCBorders(nsIFrame* aFrame) : - mFrame(aFrame) {} + explicit nsDelayedCalcBCBorders(nsIFrame* aFrame) + : mozilla::Runnable("nsDelayedCalcBCBorders") + , mFrame(aFrame) + { + } NS_IMETHOD Run() override { if (mFrame) { diff --git a/layout/xul/nsImageBoxFrame.cpp b/layout/xul/nsImageBoxFrame.cpp index f43a3d1476f6..bbb3e721ee61 100644 --- a/layout/xul/nsImageBoxFrame.cpp +++ b/layout/xul/nsImageBoxFrame.cpp @@ -64,8 +64,12 @@ using namespace mozilla::layers; class nsImageBoxFrameEvent : public Runnable { public: - nsImageBoxFrameEvent(nsIContent *content, EventMessage message) - : mContent(content), mMessage(message) {} + nsImageBoxFrameEvent(nsIContent* content, EventMessage message) + : mozilla::Runnable("nsImageBoxFrameEvent") + , mContent(content) + , mMessage(message) + { + } NS_IMETHOD Run() override; diff --git a/layout/xul/nsListBoxBodyFrame.h b/layout/xul/nsListBoxBodyFrame.h index 6d60b9c3ad3c..f1b4e394c063 100644 --- a/layout/xul/nsListBoxBodyFrame.h +++ b/layout/xul/nsListBoxBodyFrame.h @@ -152,9 +152,11 @@ protected: class nsPositionChangedEvent : public mozilla::Runnable { public: - nsPositionChangedEvent(nsListBoxBodyFrame* aFrame, - bool aUp, int32_t aDelta) : - mFrame(aFrame), mUp(aUp), mDelta(aDelta) + nsPositionChangedEvent(nsListBoxBodyFrame* aFrame, bool aUp, int32_t aDelta) + : mozilla::Runnable("nsListBoxBodyFrame::nsPositionChangedEvent") + , mFrame(aFrame) + , mUp(aUp) + , mDelta(aDelta) {} NS_IMETHOD Run() override diff --git a/layout/xul/nsMenuBarFrame.cpp b/layout/xul/nsMenuBarFrame.cpp index 1687128cb7bd..a169f18a9cc4 100644 --- a/layout/xul/nsMenuBarFrame.cpp +++ b/layout/xul/nsMenuBarFrame.cpp @@ -257,11 +257,14 @@ class nsMenuBarSwitchMenu : public Runnable { public: nsMenuBarSwitchMenu(nsIContent* aMenuBar, - nsIContent *aOldMenu, - nsIContent *aNewMenu, + nsIContent* aOldMenu, + nsIContent* aNewMenu, bool aSelectFirstItem) - : mMenuBar(aMenuBar), mOldMenu(aOldMenu), mNewMenu(aNewMenu), - mSelectFirstItem(aSelectFirstItem) + : mozilla::Runnable("nsMenuBarSwitchMenu") + , mMenuBar(aMenuBar) + , mOldMenu(aOldMenu) + , mNewMenu(aNewMenu) + , mSelectFirstItem(aSelectFirstItem) { } diff --git a/layout/xul/nsMenuFrame.cpp b/layout/xul/nsMenuFrame.cpp index c7232f85a99d..72495127a6b6 100644 --- a/layout/xul/nsMenuFrame.cpp +++ b/layout/xul/nsMenuFrame.cpp @@ -68,10 +68,13 @@ const int32_t kBlinkDelay = 67; // milliseconds class nsMenuActivateEvent : public Runnable { public: - nsMenuActivateEvent(nsIContent *aMenu, + nsMenuActivateEvent(nsIContent* aMenu, nsPresContext* aPresContext, bool aIsActivate) - : mMenu(aMenu), mPresContext(aPresContext), mIsActivate(aIsActivate) + : mozilla::Runnable("nsMenuActivateEvent") + , mMenu(aMenu) + , mPresContext(aPresContext) + , mIsActivate(aIsActivate) { } @@ -114,7 +117,9 @@ class nsMenuAttributeChangedEvent : public Runnable { public: nsMenuAttributeChangedEvent(nsIFrame* aFrame, nsIAtom* aAttr) - : mFrame(aFrame), mAttr(aAttr) + : mozilla::Runnable("nsMenuAttributeChangedEvent") + , mFrame(aFrame) + , mAttr(aAttr) { } diff --git a/layout/xul/nsMenuPopupFrame.h b/layout/xul/nsMenuPopupFrame.h index 25b893e24ba8..298444ddee8b 100644 --- a/layout/xul/nsMenuPopupFrame.h +++ b/layout/xul/nsMenuPopupFrame.h @@ -138,8 +138,10 @@ class nsXULPopupShownEvent : public mozilla::Runnable, public nsIDOMEventListener { public: - nsXULPopupShownEvent(nsIContent *aPopup, nsPresContext* aPresContext) - : mPopup(aPopup), mPresContext(aPresContext) + nsXULPopupShownEvent(nsIContent* aPopup, nsPresContext* aPresContext) + : mozilla::Runnable("nsXULPopupShownEvent") + , mPopup(aPopup) + , mPresContext(aPresContext) { } diff --git a/layout/xul/nsProgressMeterFrame.cpp b/layout/xul/nsProgressMeterFrame.cpp index 801732c63e13..9efd665b1899 100644 --- a/layout/xul/nsProgressMeterFrame.cpp +++ b/layout/xul/nsProgressMeterFrame.cpp @@ -36,12 +36,14 @@ public: nsFrameState mBitToAdd; }; -nsReflowFrameRunnable::nsReflowFrameRunnable(nsIFrame* aFrame, - nsIPresShell::IntrinsicDirty aIntrinsicDirty, - nsFrameState aBitToAdd) - : mWeakFrame(aFrame), - mIntrinsicDirty(aIntrinsicDirty), - mBitToAdd(aBitToAdd) +nsReflowFrameRunnable::nsReflowFrameRunnable( + nsIFrame* aFrame, + nsIPresShell::IntrinsicDirty aIntrinsicDirty, + nsFrameState aBitToAdd) + : mozilla::Runnable("nsReflowFrameRunnable") + , mWeakFrame(aFrame) + , mIntrinsicDirty(aIntrinsicDirty) + , mBitToAdd(aBitToAdd) { } diff --git a/layout/xul/nsSliderFrame.cpp b/layout/xul/nsSliderFrame.cpp index 1892d835afcf..12d8c3670317 100644 --- a/layout/xul/nsSliderFrame.cpp +++ b/layout/xul/nsSliderFrame.cpp @@ -210,8 +210,11 @@ public: nsIAtom* aWhich, int32_t aValue, bool aUserChanged) - : mListener(aListener), mWhich(aWhich), - mValue(aValue), mUserChanged(aUserChanged) + : mozilla::Runnable("nsValueChangedRunnable") + , mListener(aListener) + , mWhich(aWhich) + , mValue(aValue) + , mUserChanged(aUserChanged) {} NS_IMETHOD Run() override @@ -229,10 +232,10 @@ public: class nsDragStateChangedRunnable : public Runnable { public: - nsDragStateChangedRunnable(nsISliderListener* aListener, - bool aDragBeginning) - : mListener(aListener), - mDragBeginning(aDragBeginning) + nsDragStateChangedRunnable(nsISliderListener* aListener, bool aDragBeginning) + : mozilla::Runnable("nsDragStateChangedRunnable") + , mListener(aListener) + , mDragBeginning(aDragBeginning) {} NS_IMETHOD Run() override diff --git a/layout/xul/nsXULPopupManager.h b/layout/xul/nsXULPopupManager.h index 25ffa8095b63..0956a159555e 100644 --- a/layout/xul/nsXULPopupManager.h +++ b/layout/xul/nsXULPopupManager.h @@ -203,12 +203,13 @@ public: class nsXULPopupShowingEvent : public mozilla::Runnable { public: - nsXULPopupShowingEvent(nsIContent *aPopup, + nsXULPopupShowingEvent(nsIContent* aPopup, bool aIsContextMenu, bool aSelectFirstItem) - : mPopup(aPopup), - mIsContextMenu(aIsContextMenu), - mSelectFirstItem(aSelectFirstItem) + : mozilla::Runnable("nsXULPopupShowingEvent") + , mPopup(aPopup) + , mIsContextMenu(aIsContextMenu) + , mSelectFirstItem(aSelectFirstItem) { NS_ASSERTION(aPopup, "null popup supplied to nsXULPopupShowingEvent constructor"); } @@ -225,18 +226,19 @@ private: class nsXULPopupHidingEvent : public mozilla::Runnable { public: - nsXULPopupHidingEvent(nsIContent *aPopup, + nsXULPopupHidingEvent(nsIContent* aPopup, nsIContent* aNextPopup, nsIContent* aLastPopup, nsPopupType aPopupType, bool aDeselectMenu, bool aIsCancel) - : mPopup(aPopup), - mNextPopup(aNextPopup), - mLastPopup(aLastPopup), - mPopupType(aPopupType), - mDeselectMenu(aDeselectMenu), - mIsRollup(aIsCancel) + : mozilla::Runnable("nsXULPopupHidingEvent") + , mPopup(aPopup) + , mNextPopup(aNextPopup) + , mLastPopup(aLastPopup) + , mPopupType(aPopupType) + , mDeselectMenu(aDeselectMenu) + , mIsRollup(aIsCancel) { NS_ASSERTION(aPopup, "null popup supplied to nsXULPopupHidingEvent constructor"); // aNextPopup and aLastPopup may be null @@ -257,10 +259,11 @@ private: class nsXULPopupPositionedEvent : public mozilla::Runnable { public: - explicit nsXULPopupPositionedEvent(nsIContent *aPopup, + explicit nsXULPopupPositionedEvent(nsIContent* aPopup, bool aIsContextMenu, bool aSelectFirstItem) - : mPopup(aPopup) + : mozilla::Runnable("nsXULPopupPositionedEvent") + , mPopup(aPopup) , mIsContextMenu(aIsContextMenu) , mSelectFirstItem(aSelectFirstItem) { @@ -285,7 +288,7 @@ private: class nsXULMenuCommandEvent : public mozilla::Runnable { public: - nsXULMenuCommandEvent(nsIContent *aMenu, + nsXULMenuCommandEvent(nsIContent* aMenu, bool aIsTrusted, bool aShift, bool aControl, @@ -293,15 +296,16 @@ public: bool aMeta, bool aUserInput, bool aFlipChecked) - : mMenu(aMenu), - mIsTrusted(aIsTrusted), - mShift(aShift), - mControl(aControl), - mAlt(aAlt), - mMeta(aMeta), - mUserInput(aUserInput), - mFlipChecked(aFlipChecked), - mCloseMenuMode(CloseMenuMode_Auto) + : mozilla::Runnable("nsXULMenuCommandEvent") + , mMenu(aMenu) + , mIsTrusted(aIsTrusted) + , mShift(aShift) + , mControl(aControl) + , mAlt(aAlt) + , mMeta(aMeta) + , mUserInput(aUserInput) + , mFlipChecked(aFlipChecked) + , mCloseMenuMode(CloseMenuMode_Auto) { NS_ASSERTION(aMenu, "null menu supplied to nsXULMenuCommandEvent constructor"); } diff --git a/layout/xul/tree/nsTreeBodyFrame.cpp b/layout/xul/tree/nsTreeBodyFrame.cpp index dda2cacc9a65..6306478671e1 100644 --- a/layout/xul/tree/nsTreeBodyFrame.cpp +++ b/layout/xul/tree/nsTreeBodyFrame.cpp @@ -4936,7 +4936,11 @@ nsTreeBodyFrame::FireInvalidateEvent(int32_t aStartRowIdx, int32_t aEndRowIdx, class nsOverflowChecker : public Runnable { public: - explicit nsOverflowChecker(nsTreeBodyFrame* aFrame) : mFrame(aFrame) {} + explicit nsOverflowChecker(nsTreeBodyFrame* aFrame) + : mozilla::Runnable("nsOverflowChecker") + , mFrame(aFrame) + { + } NS_IMETHOD Run() override { if (mFrame.IsAlive()) { diff --git a/layout/xul/tree/nsTreeBodyFrame.h b/layout/xul/tree/nsTreeBodyFrame.h index b70767399e9c..e68e0b0654e9 100644 --- a/layout/xul/tree/nsTreeBodyFrame.h +++ b/layout/xul/tree/nsTreeBodyFrame.h @@ -482,7 +482,11 @@ protected: class ScrollEvent : public mozilla::Runnable { public: NS_DECL_NSIRUNNABLE - explicit ScrollEvent(nsTreeBodyFrame *aInner) : mInner(aInner) {} + explicit ScrollEvent(nsTreeBodyFrame* aInner) + : mozilla::Runnable("nsTreeBodyFrame::ScrollEvent") + , mInner(aInner) + { + } void Revoke() { mInner = nullptr; } private: nsTreeBodyFrame* mInner; diff --git a/media/mtransport/nr_socket_prsock.cpp b/media/mtransport/nr_socket_prsock.cpp index c4f3c5844a85..c041df0da177 100644 --- a/media/mtransport/nr_socket_prsock.cpp +++ b/media/mtransport/nr_socket_prsock.cpp @@ -1673,7 +1673,7 @@ class NrTcpSocketIpc::TcpSocketReadyRunner: public Runnable { public: explicit TcpSocketReadyRunner(NrTcpSocketIpc *sck) - : socket_(sck) {} + : Runnable("NrTcpSocketIpc::TcpSocketReadyRunner"), socket_(sck) {} NS_IMETHOD Run() override { socket_->maybe_post_socket_ready(); diff --git a/media/mtransport/runnable_utils.h b/media/mtransport/runnable_utils.h index 3a773e3565c4..b3a04a8af3d1 100644 --- a/media/mtransport/runnable_utils.h +++ b/media/mtransport/runnable_utils.h @@ -53,6 +53,8 @@ RunOnThreadInternal(nsIEventTarget *thread, nsIRunnable *runnable, uint32_t flag template class runnable_args_base : public Runnable { public: + runnable_args_base() : Runnable("media-runnable_args_base") {} + NS_IMETHOD Run() = 0; }; diff --git a/media/mtransport/test/TestSyncRunnable.cpp b/media/mtransport/test/TestSyncRunnable.cpp index 02c7d512018f..a53be04fd103 100644 --- a/media/mtransport/test/TestSyncRunnable.cpp +++ b/media/mtransport/test/TestSyncRunnable.cpp @@ -14,7 +14,7 @@ nsIThread *gThread = nullptr; class TestRunnable : public Runnable { public: - TestRunnable() : ran_(false) {} + TestRunnable() : Runnable("TestRunnable"), ran_(false) {} NS_IMETHOD Run() override { diff --git a/media/mtransport/test/sockettransportservice_unittest.cpp b/media/mtransport/test/sockettransportservice_unittest.cpp index a7edaa193de3..0f0e5924ac65 100644 --- a/media/mtransport/test/sockettransportservice_unittest.cpp +++ b/media/mtransport/test/sockettransportservice_unittest.cpp @@ -78,7 +78,7 @@ class SocketTransportServiceTest : public MtransportTest { class EventReceived : public Runnable { public: explicit EventReceived(SocketTransportServiceTest *test) : - test_(test) {} + Runnable("EventReceived"), test_(test) {} NS_IMETHOD Run() override { test_->ReceiveEvent(); @@ -93,7 +93,7 @@ public: class RegisterEvent : public Runnable { public: explicit RegisterEvent(SocketTransportServiceTest *test) : - test_(test) {} + Runnable("RegisterEvent"), test_(test) {} NS_IMETHOD Run() override { test_->RegisterHandler(); diff --git a/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.h b/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.h index 2d5c5c412769..b8067a278f18 100644 --- a/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.h +++ b/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.h @@ -80,6 +80,7 @@ class GmpInitDoneRunnable : public Runnable { public: explicit GmpInitDoneRunnable(const std::string& aPCHandle) : + Runnable("GmpInitDoneRunnable"), mResult(WEBRTC_VIDEO_CODEC_OK), mPCHandle(aPCHandle) { diff --git a/media/webrtc/signaling/src/media-conduit/WebrtcMediaCodecVP8VideoCodec.cpp b/media/webrtc/signaling/src/media-conduit/WebrtcMediaCodecVP8VideoCodec.cpp index 9b48fa1a7874..4119c21ef7bc 100644 --- a/media/webrtc/signaling/src/media-conduit/WebrtcMediaCodecVP8VideoCodec.cpp +++ b/media/webrtc/signaling/src/media-conduit/WebrtcMediaCodecVP8VideoCodec.cpp @@ -260,7 +260,8 @@ public: protected: MediaCodecOutputDrain() - : mMonitor("MediaCodecOutputDrain monitor") + : Runnable("MediaCodecOutputDrain") + , mMonitor("MediaCodecOutputDrain monitor") , mEnding(false) {} diff --git a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp index f1f98273aa65..a542754849b6 100644 --- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp +++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp @@ -206,6 +206,7 @@ public: nsCOMPtr runnable = NewRunnableMethod, bool>( + "VideoFrameConverter::ProcessVideoFrame", this, &VideoFrameConverter::ProcessVideoFrame, aChunk.mFrame.GetImage(), forceBlack); mTaskQueue->Dispatch(runnable.forget()); diff --git a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.h b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.h index 6d7d36b9e3a5..19cc9e567eae 100644 --- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.h +++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.h @@ -334,6 +334,7 @@ class ConduitDeleteEvent: public Runnable { public: explicit ConduitDeleteEvent(already_AddRefed aConduit) : + Runnable("ConduitDeleteEvent"), mConduit(aConduit) {} /* we exist solely to proxy release of the conduit */ diff --git a/modules/libjar/nsJARChannel.cpp b/modules/libjar/nsJARChannel.cpp index 924a89d55266..db243ce803f8 100644 --- a/modules/libjar/nsJARChannel.cpp +++ b/modules/libjar/nsJARChannel.cpp @@ -1081,7 +1081,8 @@ nsJARChannel::OnDataAvailable(nsIRequest *req, nsISupports *ctx, FireOnProgress(offset + count); } else { NS_DispatchToMainThread(NewRunnableMethod - (this, + ("nsJARChannel::FireOnProgress", + this, &nsJARChannel::FireOnProgress, offset + count)); } diff --git a/modules/libpref/Preferences.cpp b/modules/libpref/Preferences.cpp index 1401f7ee2539..a817f3c7be01 100644 --- a/modules/libpref/Preferences.cpp +++ b/modules/libpref/Preferences.cpp @@ -314,7 +314,7 @@ public: nsCOMPtr target = do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID, &rv); if (NS_SUCCEEDED(rv)) { - target->Dispatch(NS_NewRunnableFunction([] {}), + target->Dispatch(NS_NewRunnableFunction("Preferences_dummy", [] {}), nsIEventTarget::DISPATCH_SYNC); } } @@ -330,7 +330,10 @@ Atomic PreferencesWriter::sPendingWriteData(nullptr); class PWRunnable : public Runnable { public: - explicit PWRunnable(nsIFile* aFile) : mFile(aFile) {} + explicit PWRunnable(nsIFile* aFile) + : Runnable("PWRunnable") + , mFile(aFile) + {} NS_IMETHOD Run() override { @@ -349,7 +352,7 @@ public: nsCOMPtr fileCopy(mFile); SystemGroup::Dispatch("Preferences::WriterRunnable", TaskCategory::Other, - NS_NewRunnableFunction([fileCopy, rvCopy] { + NS_NewRunnableFunction("Preferences::WriterRunnable", [fileCopy, rvCopy] { MOZ_RELEASE_ASSERT(NS_IsMainThread()); if (NS_FAILED(rvCopy)) { Preferences::DirtyCallback(); @@ -558,6 +561,8 @@ PreferenceServiceReporter::CollectReports( namespace { class AddPreferencesMemoryReporterRunnable : public Runnable { +public: + AddPreferencesMemoryReporterRunnable() : Runnable("AddPreferencesMemoryReporterRunnable") {} NS_IMETHOD Run() override { return RegisterStrongMemoryReporter(new PreferenceServiceReporter()); diff --git a/netwerk/base/BackgroundFileSaver.cpp b/netwerk/base/BackgroundFileSaver.cpp index 4d9ff97c4cbb..16d7d552166d 100644 --- a/netwerk/base/BackgroundFileSaver.cpp +++ b/netwerk/base/BackgroundFileSaver.cpp @@ -66,9 +66,10 @@ static LazyLogModule prlog("BackgroundFileSaver"); class NotifyTargetChangeRunnable final : public Runnable { public: - NotifyTargetChangeRunnable(BackgroundFileSaver *aSaver, nsIFile *aTarget) - : mSaver(aSaver) - , mTarget(aTarget) + NotifyTargetChangeRunnable(BackgroundFileSaver* aSaver, nsIFile* aTarget) + : Runnable("net::NotifyTargetChangeRunnable") + , mSaver(aSaver) + , mTarget(aTarget) { } @@ -325,9 +326,11 @@ BackgroundFileSaver::GetWorkerThreadAttention(bool aShouldInterruptCopy) if (!mAsyncCopyContext) { // Copy is not in progress, post an event to handle the change manually. - rv = mWorkerThread->Dispatch(NewRunnableMethod(this, - &BackgroundFileSaver::ProcessAttention), - NS_DISPATCH_NORMAL); + rv = mWorkerThread->Dispatch( + NewRunnableMethod("net::BackgroundFileSaver::ProcessAttention", + 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 @@ -747,7 +750,8 @@ BackgroundFileSaver::CheckCompletion() } // Post an event to notify that the operation completed. - if (NS_FAILED(mControlEventTarget->Dispatch(NewRunnableMethod(this, + if (NS_FAILED(mControlEventTarget->Dispatch(NewRunnableMethod("BackgroundFileSaver::NotifySaveComplete", + this, &BackgroundFileSaver::NotifySaveComplete), NS_DISPATCH_NORMAL))) { NS_WARNING("Unable to post completion event to the control thread."); @@ -1153,7 +1157,8 @@ BackgroundFileSaverStreamListener::AsyncCopyProgressCallback(void *aClosure, self->mReceivedTooMuchData = false; // Post an event to verify if the request should be resumed. - if (NS_FAILED(self->mControlEventTarget->Dispatch(NewRunnableMethod(self, + if (NS_FAILED(self->mControlEventTarget->Dispatch(NewRunnableMethod("BackgroundFileSaverStreamListener::NotifySuspendOrResume", + 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 63273be92ba0..094b6dba8944 100644 --- a/netwerk/base/Dashboard.cpp +++ b/netwerk/base/Dashboard.cpp @@ -200,7 +200,8 @@ ConnectionData::OnTransportStatus(nsITransport *aTransport, nsresult aStatus, GetErrorString(aStatus, mStatus); mEventTarget->Dispatch(NewRunnableMethod> - (mDashboard, &Dashboard::GetConnectionStatus, this), + ("net::Dashboard::GetConnectionStatus", + mDashboard, &Dashboard::GetConnectionStatus, this), NS_DISPATCH_NORMAL); return NS_OK; @@ -221,7 +222,8 @@ ConnectionData::Notify(nsITimer *aTimer) mStatus.AssignLiteral(u"NS_ERROR_NET_TIMEOUT"); mEventTarget->Dispatch(NewRunnableMethod> - (mDashboard, &Dashboard::GetConnectionStatus, this), + ("net::Dashboard::GetConnectionStatus", + mDashboard, &Dashboard::GetConnectionStatus, this), NS_DISPATCH_NORMAL); return NS_OK; @@ -310,7 +312,8 @@ LookupHelper::OnLookupComplete(nsICancelable *aRequest, RefPtr arg = new LookupArgument(aRecord, this); mEventTarget->Dispatch(NewRunnableMethod> - (this, &LookupHelper::ConstructAnswer, arg), + ("net::LookupHelper::ConstructAnswer", + this, &LookupHelper::ConstructAnswer, arg), NS_DISPATCH_NORMAL); return NS_OK; @@ -377,7 +380,8 @@ Dashboard::RequestSockets(NetDashboardCallback *aCallback) "NetDashboardCallback", aCallback, true); socketData->mEventTarget = GetCurrentThreadEventTarget(); gSocketTransportService->Dispatch(NewRunnableMethod> - (this, &Dashboard::GetSocketsDispatch, socketData), + ("net::Dashboard::GetSocketsDispatch", + this, &Dashboard::GetSocketsDispatch, socketData), NS_DISPATCH_NORMAL); return NS_OK; } @@ -392,7 +396,8 @@ Dashboard::GetSocketsDispatch(SocketData *aSocketData) socketData->mTotalRecv = gSocketTransportService->GetReceivedBytes(); } socketData->mEventTarget->Dispatch(NewRunnableMethod> - (this, &Dashboard::GetSockets, socketData), + ("net::Dashboard::GetSockets", + this, &Dashboard::GetSockets, socketData), NS_DISPATCH_NORMAL); return NS_OK; } @@ -447,9 +452,12 @@ Dashboard::RequestHttpConnections(NetDashboardCallback *aCallback) "NetDashboardCallback", aCallback, true); httpData->mEventTarget = GetCurrentThreadEventTarget(); - gSocketTransportService->Dispatch(NewRunnableMethod> - (this, &Dashboard::GetHttpDispatch, httpData), - NS_DISPATCH_NORMAL); + gSocketTransportService->Dispatch( + NewRunnableMethod>("net::Dashboard::GetHttpDispatch", + this, + &Dashboard::GetHttpDispatch, + httpData), + NS_DISPATCH_NORMAL); return NS_OK; } @@ -459,7 +467,8 @@ Dashboard::GetHttpDispatch(HttpData *aHttpData) RefPtr httpData = aHttpData; HttpInfo::GetHttpConnectionData(&httpData->mData); httpData->mEventTarget->Dispatch(NewRunnableMethod> - (this, &Dashboard::GetHttpConnections, httpData), + ("net::Dashboard::GetHttpConnections", + this, &Dashboard::GetHttpConnections, httpData), NS_DISPATCH_NORMAL); return NS_OK; } @@ -625,7 +634,8 @@ Dashboard::RequestWebsocketConnections(NetDashboardCallback *aCallback) wsRequest->mEventTarget = GetCurrentThreadEventTarget(); wsRequest->mEventTarget->Dispatch(NewRunnableMethod> - (this, &Dashboard::GetWebSocketConnections, wsRequest), + ("net::Dashboard::GetWebSocketConnections", + this, &Dashboard::GetWebSocketConnections, wsRequest), NS_DISPATCH_NORMAL); return NS_OK; } @@ -686,9 +696,12 @@ Dashboard::RequestDNSInfo(NetDashboardCallback *aCallback) } } - gSocketTransportService->Dispatch(NewRunnableMethod> - (this, &Dashboard::GetDnsInfoDispatch, dnsData), - NS_DISPATCH_NORMAL); + gSocketTransportService->Dispatch( + NewRunnableMethod>("net::Dashboard::GetDnsInfoDispatch", + this, + &Dashboard::GetDnsInfoDispatch, + dnsData), + NS_DISPATCH_NORMAL); return NS_OK; } @@ -700,7 +713,8 @@ Dashboard::GetDnsInfoDispatch(DnsData *aDnsData) mDnsService->GetDNSCacheEntries(&dnsData->mData); } dnsData->mEventTarget->Dispatch(NewRunnableMethod> - (this, &Dashboard::GetDNSCacheEntries, dnsData), + ("net::Dashboard::GetDNSCacheEntries", + this, &Dashboard::GetDNSCacheEntries, dnsData), NS_DISPATCH_NORMAL); return NS_OK; } @@ -793,7 +807,8 @@ Dashboard::RequestRcwnStats(NetDashboardCallback *aCallback) "NetDashboardCallback", aCallback, true); return rcwnData->mEventTarget->Dispatch( - NewRunnableMethod>(this, &Dashboard::GetRcwnData, rcwnData), + NewRunnableMethod>("net::Dashboard::GetRcwnData", + this, &Dashboard::GetRcwnData, rcwnData), NS_DISPATCH_NORMAL); } @@ -875,7 +890,8 @@ Dashboard::RequestConnection(const nsACString& aHost, uint32_t aPort, if (NS_FAILED(rv)) { mozilla::net::GetErrorString(rv, connectionData->mStatus); connectionData->mEventTarget->Dispatch(NewRunnableMethod> - (this, &Dashboard::GetConnectionStatus, connectionData), + ("net::Dashboard::GetConnectionStatus", + this, &Dashboard::GetConnectionStatus, connectionData), NS_DISPATCH_NORMAL); return rv; } diff --git a/netwerk/base/NetworkActivityMonitor.cpp b/netwerk/base/NetworkActivityMonitor.cpp index 2f7d92628dce..ef2698c54b72 100644 --- a/netwerk/base/NetworkActivityMonitor.cpp +++ b/netwerk/base/NetworkActivityMonitor.cpp @@ -152,7 +152,8 @@ nsNetMon_AcceptRead(PRFileDesc *listenSock, class NotifyNetworkActivity : public mozilla::Runnable { public: explicit NotifyNetworkActivity(NetworkActivityMonitor::Direction aDirection) - : mDirection(aDirection) + : mozilla::Runnable("NotifyNetworkActivity") + , mDirection(aDirection) {} NS_IMETHOD Run() override { diff --git a/netwerk/base/Predictor.cpp b/netwerk/base/Predictor.cpp index 7e969630a8cb..5912cfc60610 100644 --- a/netwerk/base/Predictor.cpp +++ b/netwerk/base/Predictor.cpp @@ -615,9 +615,10 @@ namespace { class PredictorThreadShutdownRunner : public Runnable { public: - PredictorThreadShutdownRunner(nsIThread *ioThread, bool success) - :mIOThread(ioThread) - ,mSuccess(success) + PredictorThreadShutdownRunner(nsIThread* ioThread, bool success) + : Runnable("net::PredictorThreadShutdownRunner") + , mIOThread(ioThread) + , mSuccess(success) { } ~PredictorThreadShutdownRunner() { } @@ -640,9 +641,10 @@ private: class PredictorOldCleanupRunner : public Runnable { public: - PredictorOldCleanupRunner(nsIThread *ioThread, nsIFile *dbFile) - :mIOThread(ioThread) - ,mDBFile(dbFile) + PredictorOldCleanupRunner(nsIThread* ioThread, nsIFile* dbFile) + : Runnable("net::PredictorOldCleanupRunner") + , mIOThread(ioThread) + , mDBFile(dbFile) { } ~PredictorOldCleanupRunner() { } diff --git a/netwerk/base/TLSServerSocket.cpp b/netwerk/base/TLSServerSocket.cpp index 40dcec75418c..77d209b20e9b 100644 --- a/netwerk/base/TLSServerSocket.cpp +++ b/netwerk/base/TLSServerSocket.cpp @@ -286,10 +286,12 @@ public: class OnHandshakeDoneRunnable : public Runnable { public: - OnHandshakeDoneRunnable(const nsMainThreadPtrHandle& aListener, - nsITLSServerSocket* aServer, - nsITLSClientStatus* aStatus) - : mListener(aListener) + OnHandshakeDoneRunnable( + const nsMainThreadPtrHandle& aListener, + nsITLSServerSocket* aServer, + nsITLSClientStatus* aStatus) + : Runnable("net::TLSServerSecurityObserverProxy::OnHandshakeDoneRunnable") + , mListener(aListener) , mServer(aServer) , mStatus(aStatus) { } diff --git a/netwerk/base/Tickler.cpp b/netwerk/base/Tickler.cpp index 555fdbbe5e29..62542d6b0a21 100644 --- a/netwerk/base/Tickler.cpp +++ b/netwerk/base/Tickler.cpp @@ -108,7 +108,8 @@ void Tickler::Tickle() void Tickler::PostCheckTickler() { mLock.AssertCurrentThreadOwns(); - mThread->Dispatch(NewRunnableMethod(this, &Tickler::CheckTickler), + mThread->Dispatch(NewRunnableMethod("net::Tickler::CheckTickler", + this, &Tickler::CheckTickler), NS_DISPATCH_NORMAL); return; } @@ -124,7 +125,8 @@ void Tickler::MaybeStartTickler() mLock.AssertCurrentThreadOwns(); if (!NS_IsMainThread()) { NS_DispatchToMainThread( - NewRunnableMethod(this, &Tickler::MaybeStartTicklerUnlocked)); + NewRunnableMethod("net::Tickler::MaybeStartTicklerUnlocked", + this, &Tickler::MaybeStartTicklerUnlocked)); return; } diff --git a/netwerk/base/nsAsyncStreamCopier.cpp b/netwerk/base/nsAsyncStreamCopier.cpp index 2923ac9e5a89..6fbed58cc118 100644 --- a/netwerk/base/nsAsyncStreamCopier.cpp +++ b/netwerk/base/nsAsyncStreamCopier.cpp @@ -33,9 +33,11 @@ public: * The nsAsyncStreamCopier requesting the information. */ explicit AsyncApplyBufferingPolicyEvent(nsAsyncStreamCopier* aCopier) - : mCopier(aCopier) + : mozilla::Runnable("AsyncApplyBufferingPolicyEvent") + , mCopier(aCopier) , mTarget(GetCurrentThreadEventTarget()) - { } + {} + NS_IMETHOD Run() override { nsresult rv = mCopier->ApplyBufferingPolicy(); @@ -44,7 +46,8 @@ public: return NS_OK; } - rv = mTarget->Dispatch(NewRunnableMethod(mCopier, + rv = mTarget->Dispatch(NewRunnableMethod("nsAsyncStreamCopier::AsyncCopyInternal", + mCopier, &nsAsyncStreamCopier::AsyncCopyInternal), NS_DISPATCH_NORMAL); MOZ_ASSERT(NS_SUCCEEDED(rv)); @@ -54,6 +57,7 @@ public: } return NS_OK; } + private: RefPtr mCopier; nsCOMPtr mTarget; diff --git a/netwerk/base/nsBaseChannel.cpp b/netwerk/base/nsBaseChannel.cpp index 094ef07c458a..9d9b427f1acf 100644 --- a/netwerk/base/nsBaseChannel.cpp +++ b/netwerk/base/nsBaseChannel.cpp @@ -908,9 +908,10 @@ nsBaseChannel::OnDataAvailable(nsIRequest *request, nsISupports *ctxt, OnTransportStatusAsyncEvent(nsBaseChannel* aChannel, int64_t aProgress, int64_t aContentLength) - : mChannel(aChannel), - mProgress(aProgress), - mContentLength(aContentLength) + : mozilla::Runnable("OnTransportStatusAsyncEvent") + , mChannel(aChannel) + , mProgress(aProgress) + , mContentLength(aContentLength) { } NS_IMETHOD Run() override diff --git a/netwerk/base/nsBaseChannel.h b/netwerk/base/nsBaseChannel.h index 5427acef132f..6ae87b37b180 100644 --- a/netwerk/base/nsBaseChannel.h +++ b/netwerk/base/nsBaseChannel.h @@ -261,7 +261,9 @@ private: { public: RedirectRunnable(nsBaseChannel* chan, nsIChannel* newChannel) - : mChannel(chan), mNewChannel(newChannel) + : mozilla::Runnable("nsBaseChannel::RedirectRunnable") + , mChannel(chan) + , mNewChannel(newChannel) { NS_PRECONDITION(newChannel, "Must have channel to redirect to"); } diff --git a/netwerk/base/nsIOService.cpp b/netwerk/base/nsIOService.cpp index 48f92048f387..024877641faa 100644 --- a/netwerk/base/nsIOService.cpp +++ b/netwerk/base/nsIOService.cpp @@ -1398,14 +1398,13 @@ nsIOService::GetPrefBranch(nsIPrefBranch **result) class nsWakeupNotifier : public Runnable { public: - explicit nsWakeupNotifier(nsIIOServiceInternal *ioService) - :mIOService(ioService) - { } + explicit nsWakeupNotifier(nsIIOServiceInternal* ioService) + : Runnable("net::nsWakeupNotifier") + , mIOService(ioService) + { + } - NS_IMETHOD Run() override - { - return mIOService->NotifyWakeup(); - } + NS_IMETHOD Run() override { return mIOService->NotifyWakeup(); } private: virtual ~nsWakeupNotifier() { } diff --git a/netwerk/base/nsInputStreamPump.cpp b/netwerk/base/nsInputStreamPump.cpp index c57fc1322326..97b282582418 100644 --- a/netwerk/base/nsInputStreamPump.cpp +++ b/netwerk/base/nsInputStreamPump.cpp @@ -697,7 +697,9 @@ nsInputStreamPump::OnStateStop() MOZ_ASSERT(NS_IsMainThread(), "OnStateStop should only be called on the main thread."); nsresult rv = NS_DispatchToMainThread( - NewRunnableMethod(this, &nsInputStreamPump::CallOnStateStop)); + NewRunnableMethod("nsInputStreamPump::CallOnStateStop", + 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 da8dfefdc6a3..5a43f26e5615 100644 --- a/netwerk/base/nsPACMan.cpp +++ b/netwerk/base/nsPACMan.cpp @@ -85,9 +85,9 @@ GetExtraJSContextHeapSize() class ExecuteCallback final : public Runnable { public: - ExecuteCallback(nsPACManCallback *aCallback, - nsresult status) - : mCallback(aCallback) + ExecuteCallback(nsPACManCallback* aCallback, nsresult status) + : Runnable("net::ExecuteCallback") + , mCallback(aCallback) , mStatus(status) { } @@ -125,8 +125,9 @@ private: class ShutdownThread final : public Runnable { public: - explicit ShutdownThread(nsIThread *thread) - : mThread(thread) + explicit ShutdownThread(nsIThread* thread) + : Runnable("net::ShutdownThread") + , mThread(thread) { } @@ -146,8 +147,9 @@ private: class WaitForThreadShutdown final : public Runnable { public: - explicit WaitForThreadShutdown(nsPACMan *aPACMan) - : mPACMan(aPACMan) + explicit WaitForThreadShutdown(nsPACMan* aPACMan) + : Runnable("net::WaitForThreadShutdown") + , mPACMan(aPACMan) { } @@ -174,8 +176,9 @@ private: class PACLoadComplete final : public Runnable { public: - explicit PACLoadComplete(nsPACMan *aPACMan) - : mPACMan(aPACMan) + explicit PACLoadComplete(nsPACMan* aPACMan) + : Runnable("net::PACLoadComplete") + , mPACMan(aPACMan) { } @@ -201,8 +204,9 @@ class ExecutePACThreadAction final : public Runnable { public: // by default we just process the queue - explicit ExecutePACThreadAction(nsPACMan *aPACMan) - : mPACMan(aPACMan) + explicit ExecutePACThreadAction(nsPACMan* aPACMan) + : Runnable("net::ExecutePACThreadAction") + , mPACMan(aPACMan) , mCancel(false) , mCancelStatus(NS_OK) , mSetupPAC(false) @@ -266,10 +270,12 @@ private: //----------------------------------------------------------------------------- -PendingPACQuery::PendingPACQuery(nsPACMan *pacMan, nsIURI *uri, - nsPACManCallback *callback, +PendingPACQuery::PendingPACQuery(nsPACMan* pacMan, + nsIURI* uri, + nsPACManCallback* callback, bool mainThreadResponse) - : mPACMan(pacMan) + : Runnable("net::PendingPACQuery") + , mPACMan(pacMan) , mCallback(callback) , mOnMainThreadOnly(mainThreadResponse) { @@ -433,7 +439,8 @@ nsPACMan::LoadPACFromURI(const nsCString &spec) if (!mLoadPending) { nsresult rv; - if (NS_FAILED(rv = NS_DispatchToCurrentThread(NewRunnableMethod(this, &nsPACMan::StartLoading)))) + if (NS_FAILED(rv = NS_DispatchToCurrentThread(NewRunnableMethod("nsPACMan::StartLoading", + this, &nsPACMan::StartLoading)))) return rv; mLoadPending = true; } diff --git a/netwerk/base/nsPreloadedStream.cpp b/netwerk/base/nsPreloadedStream.cpp index d203f550526e..dd88e50cb3ec 100644 --- a/netwerk/base/nsPreloadedStream.cpp +++ b/netwerk/base/nsPreloadedStream.cpp @@ -110,17 +110,19 @@ nsPreloadedStream::CloseWithStatus(nsresult aStatus) class RunOnThread : public Runnable { public: - RunOnThread(nsIAsyncInputStream *aStream, - nsIInputStreamCallback *aCallback) - : mStream(aStream), - mCallback(aCallback) {} + RunOnThread(nsIAsyncInputStream* aStream, nsIInputStreamCallback* aCallback) + : Runnable("net::RunOnThread") + , mStream(aStream) + , mCallback(aCallback) + { + } - virtual ~RunOnThread() {} + virtual ~RunOnThread() {} - NS_IMETHOD Run() override - { - mCallback->OnInputStreamReady(mStream); - return NS_OK; + NS_IMETHOD Run() override + { + mCallback->OnInputStreamReady(mStream); + return NS_OK; } private: diff --git a/netwerk/base/nsRequestObserverProxy.cpp b/netwerk/base/nsRequestObserverProxy.cpp index 9e95b356ba65..939cb87c9e34 100644 --- a/netwerk/base/nsRequestObserverProxy.cpp +++ b/netwerk/base/nsRequestObserverProxy.cpp @@ -24,8 +24,9 @@ static LazyLogModule gRequestObserverProxyLog("nsRequestObserverProxy"); // nsARequestObserverEvent internal class... //----------------------------------------------------------------------------- -nsARequestObserverEvent::nsARequestObserverEvent(nsIRequest *request) - : mRequest(request) +nsARequestObserverEvent::nsARequestObserverEvent(nsIRequest* request) + : Runnable("net::nsARequestObserverEvent") + , mRequest(request) { NS_PRECONDITION(mRequest, "null pointer"); } diff --git a/netwerk/base/nsServerSocket.cpp b/netwerk/base/nsServerSocket.cpp index 3c9e12621c77..c64c19f2f16f 100644 --- a/netwerk/base/nsServerSocket.cpp +++ b/netwerk/base/nsServerSocket.cpp @@ -27,7 +27,7 @@ typedef void (nsServerSocket:: *nsServerSocketFunc)(void); static nsresult PostEvent(nsServerSocket *s, nsServerSocketFunc func) { - nsCOMPtr ev = NewRunnableMethod(s, func); + nsCOMPtr ev = NewRunnableMethod("net::PostEvent", s, func); if (!gSocketTransportService) return NS_ERROR_FAILURE; @@ -122,8 +122,8 @@ nsServerSocket::TryAttach() // if (!gSocketTransportService->CanAttachSocket()) { - nsCOMPtr event = - NewRunnableMethod(this, &nsServerSocket::OnMsgAttach); + nsCOMPtr event = NewRunnableMethod( + "net::nsServerSocket::OnMsgAttach", this, &nsServerSocket::OnMsgAttach); if (!event) return NS_ERROR_OUT_OF_MEMORY; @@ -434,10 +434,12 @@ public: class OnSocketAcceptedRunnable : public Runnable { public: - OnSocketAcceptedRunnable(const nsMainThreadPtrHandle& aListener, - nsIServerSocket* aServ, - nsISocketTransport* aTransport) - : mListener(aListener) + OnSocketAcceptedRunnable( + const nsMainThreadPtrHandle& aListener, + nsIServerSocket* aServ, + nsISocketTransport* aTransport) + : Runnable("net::ServerSocketListenerProxy::OnSocketAcceptedRunnable") + , mListener(aListener) , mServ(aServ) , mTransport(aTransport) { } @@ -453,10 +455,12 @@ public: class OnStopListeningRunnable : public Runnable { public: - OnStopListeningRunnable(const nsMainThreadPtrHandle& aListener, - nsIServerSocket* aServ, - nsresult aStatus) - : mListener(aListener) + OnStopListeningRunnable( + const nsMainThreadPtrHandle& aListener, + nsIServerSocket* aServ, + nsresult aStatus) + : Runnable("net::ServerSocketListenerProxy::OnStopListeningRunnable") + , mListener(aListener) , mServ(aServ) , mStatus(aStatus) { } diff --git a/netwerk/base/nsSocketTransport2.cpp b/netwerk/base/nsSocketTransport2.cpp index 88af2bceefd4..01deb4a74d3e 100644 --- a/netwerk/base/nsSocketTransport2.cpp +++ b/netwerk/base/nsSocketTransport2.cpp @@ -73,18 +73,22 @@ namespace net { class nsSocketEvent : public Runnable { public: - nsSocketEvent(nsSocketTransport *transport, uint32_t type, - nsresult status = NS_OK, nsISupports *param = nullptr) - : mTransport(transport) - , mType(type) - , mStatus(status) - , mParam(param) - {} + nsSocketEvent(nsSocketTransport* transport, + uint32_t type, + nsresult status = NS_OK, + nsISupports* param = nullptr) + : Runnable("net::nsSocketEvent") + , mTransport(transport) + , mType(type) + , mStatus(status) + , mParam(param) + { + } - NS_IMETHOD Run() override - { - mTransport->OnSocketEvent(mType, mStatus, mParam); - return NS_OK; + NS_IMETHOD Run() override + { + mTransport->OnSocketEvent(mType, mStatus, mParam); + return NS_OK; } private: @@ -1969,7 +1973,11 @@ nsSocketTransport::FastOpenInProgress() class ThunkPRClose : public Runnable { public: - explicit ThunkPRClose(PRFileDesc *fd) : mFD(fd) {} + explicit ThunkPRClose(PRFileDesc* fd) + : Runnable("net::ThunkPRClose") + , mFD(fd) + { + } NS_IMETHOD Run() override { diff --git a/netwerk/base/nsSocketTransportService2.cpp b/netwerk/base/nsSocketTransportService2.cpp index e458262097b3..4ecccd6c2523 100644 --- a/netwerk/base/nsSocketTransportService2.cpp +++ b/netwerk/base/nsSocketTransportService2.cpp @@ -948,12 +948,16 @@ nsSocketTransportService::Run() mRawThread->HasPendingEvents(&pendingEvents); if (pendingEvents) { if (!mServingPendingQueue) { - nsresult rv = Dispatch(NewRunnableMethod(this, - &nsSocketTransportService::MarkTheLastElementOfPendingQueue), - nsIEventTarget::DISPATCH_NORMAL); - if (NS_FAILED(rv)) { - NS_WARNING("Could not dispatch a new event on the " - "socket thread."); + nsresult rv = Dispatch( + NewRunnableMethod("net::nsSocketTransportService::" + "MarkTheLastElementOfPendingQueue", + this, + &nsSocketTransportService:: + MarkTheLastElementOfPendingQueue), + nsIEventTarget::DISPATCH_NORMAL); + if (NS_FAILED(rv)) { + NS_WARNING("Could not dispatch a new event on the " + "socket thread."); } else { mServingPendingQueue = true; } @@ -1316,11 +1320,13 @@ nsSocketTransportService::OnKeepaliveEnabledPrefChange() { // Dispatch to socket thread if we're not executing there. if (!OnSocketThread()) { - gSocketTransportService->Dispatch( - NewRunnableMethod( - this, &nsSocketTransportService::OnKeepaliveEnabledPrefChange), - NS_DISPATCH_NORMAL); - return; + gSocketTransportService->Dispatch( + NewRunnableMethod( + "net::nsSocketTransportService::OnKeepaliveEnabledPrefChange", + this, + &nsSocketTransportService::OnKeepaliveEnabledPrefChange), + NS_DISPATCH_NORMAL); + return; } SOCKET_LOG(("nsSocketTransportService::OnKeepaliveEnabledPrefChange %s", @@ -1371,11 +1377,12 @@ nsSocketTransportService::Observe(nsISupports *subject, } if (!strcmp(topic, "last-pb-context-exited")) { - nsCOMPtr ev = - NewRunnableMethod(this, - &nsSocketTransportService::ClosePrivateConnections); - nsresult rv = Dispatch(ev, nsIEventTarget::DISPATCH_NORMAL); - NS_ENSURE_SUCCESS(rv, rv); + nsCOMPtr ev = NewRunnableMethod( + "net::nsSocketTransportService::ClosePrivateConnections", + this, + &nsSocketTransportService::ClosePrivateConnections); + nsresult rv = Dispatch(ev, nsIEventTarget::DISPATCH_NORMAL); + NS_ENSURE_SUCCESS(rv, rv); } if (!strcmp(topic, NS_TIMER_CALLBACK_TOPIC)) { @@ -1622,7 +1629,8 @@ nsSocketTransportService::StartPollWatchdog() // Start off the timer from a runnable off of the main thread in order to // avoid a deadlock, see bug 1370448. RefPtr self(this); - NS_DispatchToMainThread(NS_NewRunnableFunction([self] { + NS_DispatchToMainThread(NS_NewRunnableFunction("nsSocketTransportService::StartPollWatchdog", + [self] { MutexAutoLock lock(self->mLock); // Poll can hang sometimes. If we are in shutdown, we are going to start a diff --git a/netwerk/base/nsStreamTransportService.cpp b/netwerk/base/nsStreamTransportService.cpp index 41e2784777d8..f19ae454a07e 100644 --- a/netwerk/base/nsStreamTransportService.cpp +++ b/netwerk/base/nsStreamTransportService.cpp @@ -575,17 +575,18 @@ nsStreamTransportService::Observe(nsISupports *subject, const char *topic, class AvailableEvent final : public Runnable { - public: - AvailableEvent(nsIInputStream *stream, - nsIInputAvailableCallback *callback) - : mStream(stream) - , mCallback(callback) - , mDoingCallback(false) - , mSize(0) - , mResultForCallback(NS_OK) - { - mCallbackTarget = GetCurrentThreadEventTarget(); - } +public: + AvailableEvent(nsIInputStream* stream, + nsIInputAvailableCallback* callback) + : Runnable("net::AvailableEvent") + , mStream(stream) + , mCallback(callback) + , mDoingCallback(false) + , mSize(0) + , mResultForCallback(NS_OK) + { + mCallbackTarget = GetCurrentThreadEventTarget(); + } NS_IMETHOD Run() override { diff --git a/netwerk/base/nsUDPSocket.cpp b/netwerk/base/nsUDPSocket.cpp index 4de0dbce7564..cde4a2446520 100644 --- a/netwerk/base/nsUDPSocket.cpp +++ b/netwerk/base/nsUDPSocket.cpp @@ -48,7 +48,8 @@ PostEvent(nsUDPSocket *s, nsUDPSocketFunc func) if (!gSocketTransportService) return NS_ERROR_FAILURE; - return gSocketTransportService->Dispatch(NewRunnableMethod(s, func), NS_DISPATCH_NORMAL); + return gSocketTransportService->Dispatch( + NewRunnableMethod("net::PostEvent", s, func), NS_DISPATCH_NORMAL); } static nsresult @@ -91,7 +92,8 @@ class SetSocketOptionRunnable : public Runnable { public: SetSocketOptionRunnable(nsUDPSocket* aSocket, const PRSocketOptionData& aOpt) - : mSocket(aSocket) + : Runnable("net::SetSocketOptionRunnable") + , mSocket(aSocket) , mOpt(aOpt) {} @@ -354,8 +356,8 @@ nsUDPSocket::TryAttach() // if (!gSocketTransportService->CanAttachSocket()) { - nsCOMPtr event = - NewRunnableMethod(this, &nsUDPSocket::OnMsgAttach); + nsCOMPtr event = NewRunnableMethod( + "net::nsUDPSocket::OnMsgAttach", this, &nsUDPSocket::OnMsgAttach); nsresult rv = gSocketTransportService->NotifyWhenCanAttachSocket(event); if (NS_FAILED(rv)) @@ -858,10 +860,12 @@ public: class OnPacketReceivedRunnable : public Runnable { public: - OnPacketReceivedRunnable(const nsMainThreadPtrHandle& aListener, - nsIUDPSocket* aSocket, - nsIUDPMessage* aMessage) - : mListener(aListener) + OnPacketReceivedRunnable( + const nsMainThreadPtrHandle& aListener, + nsIUDPSocket* aSocket, + nsIUDPMessage* aMessage) + : Runnable("net::SocketListenerProxy::OnPacketReceivedRunnable") + , mListener(aListener) , mSocket(aSocket) , mMessage(aMessage) { } @@ -877,10 +881,12 @@ public: class OnStopListeningRunnable : public Runnable { public: - OnStopListeningRunnable(const nsMainThreadPtrHandle& aListener, - nsIUDPSocket* aSocket, - nsresult aStatus) - : mListener(aListener) + OnStopListeningRunnable( + const nsMainThreadPtrHandle& aListener, + nsIUDPSocket* aSocket, + nsresult aStatus) + : Runnable("net::SocketListenerProxy::OnStopListeningRunnable") + , mListener(aListener) , mSocket(aSocket) , mStatus(aStatus) { } @@ -966,7 +972,8 @@ public: OnPacketReceivedRunnable(const nsCOMPtr& aListener, nsIUDPSocket* aSocket, nsIUDPMessage* aMessage) - : mListener(aListener) + : Runnable("net::SocketListenerProxyBackground::OnPacketReceivedRunnable") + , mListener(aListener) , mSocket(aSocket) , mMessage(aMessage) { } @@ -985,7 +992,8 @@ public: OnStopListeningRunnable(const nsCOMPtr& aListener, nsIUDPSocket* aSocket, nsresult aStatus) - : mListener(aListener) + : Runnable("net::SocketListenerProxyBackground::OnStopListeningRunnable") + , mListener(aListener) , mSocket(aSocket) , mStatus(aStatus) { } @@ -1141,10 +1149,11 @@ PendingSendStream::OnLookupComplete(nsICancelable *request, class SendRequestRunnable: public Runnable { public: - SendRequestRunnable(nsUDPSocket *aSocket, - const NetAddr &aAddr, + SendRequestRunnable(nsUDPSocket* aSocket, + const NetAddr& aAddr, FallibleTArray&& aData) - : mSocket(aSocket) + : Runnable("net::SendRequestRunnable") + , mSocket(aSocket) , mAddr(aAddr) , mData(Move(aData)) { } diff --git a/netwerk/cache/nsCacheEntryDescriptor.cpp b/netwerk/cache/nsCacheEntryDescriptor.cpp index d78d1c214940..76d02e42dd9d 100644 --- a/netwerk/cache/nsCacheEntryDescriptor.cpp +++ b/netwerk/cache/nsCacheEntryDescriptor.cpp @@ -28,6 +28,7 @@ class nsAsyncDoomEvent : public mozilla::Runnable { public: nsAsyncDoomEvent(nsCacheEntryDescriptor *descriptor, nsICacheListener *listener) + : mozilla::Runnable("nsAsyncDoomEvent") { mDescriptor = descriptor; mListener = listener; diff --git a/netwerk/cache/nsCacheService.cpp b/netwerk/cache/nsCacheService.cpp index 4e251d4de56d..61155b0811ab 100644 --- a/netwerk/cache/nsCacheService.cpp +++ b/netwerk/cache/nsCacheService.cpp @@ -226,32 +226,35 @@ NS_IMPL_ISUPPORTS(nsSetDiskSmartSizeCallback, nsITimerCallback) class nsSetSmartSizeEvent: public Runnable { public: - explicit nsSetSmartSizeEvent(int32_t smartSize) - : mSmartSize(smartSize) {} + explicit nsSetSmartSizeEvent(int32_t smartSize) + : mozilla::Runnable("nsSetSmartSizeEvent") + , mSmartSize(smartSize) + { + } - NS_IMETHOD Run() - { - NS_ASSERTION(NS_IsMainThread(), - "Setting smart size data off the main thread"); + NS_IMETHOD Run() + { + NS_ASSERTION(NS_IsMainThread(), + "Setting smart size data off the main thread"); - // Main thread may have already called nsCacheService::Shutdown - if (!nsCacheService::IsInitialized()) - return NS_ERROR_NOT_AVAILABLE; + // Main thread may have already called nsCacheService::Shutdown + if (!nsCacheService::IsInitialized()) + return NS_ERROR_NOT_AVAILABLE; - // Ensure smart sizing wasn't switched off while event was pending. - // It is safe to access the observer without the lock since we are - // on the main thread and the value changes only on the main thread. - if (!nsCacheService::gService->mObserver->SmartSizeEnabled()) - return NS_OK; + // Ensure smart sizing wasn't switched off while event was pending. + // It is safe to access the observer without the lock since we are + // on the main thread and the value changes only on the main thread. + if (!nsCacheService::gService->mObserver->SmartSizeEnabled()) + return NS_OK; - nsCacheService::SetDiskCacheCapacity(mSmartSize); + nsCacheService::SetDiskCacheCapacity(mSmartSize); - nsCOMPtr ps = do_GetService(NS_PREFSERVICE_CONTRACTID); - if (!ps || - NS_FAILED(ps->SetIntPref(DISK_CACHE_SMART_SIZE_PREF, mSmartSize))) - NS_WARNING("Failed to set smart size pref"); + nsCOMPtr ps = do_GetService(NS_PREFSERVICE_CONTRACTID); + if (!ps || + NS_FAILED(ps->SetIntPref(DISK_CACHE_SMART_SIZE_PREF, mSmartSize))) + NS_WARNING("Failed to set smart size pref"); - return NS_OK; + return NS_OK; } private: @@ -263,23 +266,25 @@ private: class nsGetSmartSizeEvent: public Runnable { public: - nsGetSmartSizeEvent(const nsAString& cachePath, uint32_t currentSize, - bool shouldUseOldMaxSmartSize) - : mCachePath(cachePath) - , mCurrentSize(currentSize) - , mShouldUseOldMaxSmartSize(shouldUseOldMaxSmartSize) - {} - - // Calculates user's disk space available on a background thread and - // dispatches this value back to the main thread. - NS_IMETHOD Run() override - { - uint32_t size; - size = nsCacheProfilePrefObserver::GetSmartCacheSize(mCachePath, - mCurrentSize, - mShouldUseOldMaxSmartSize); - NS_DispatchToMainThread(new nsSetSmartSizeEvent(size)); - return NS_OK; + nsGetSmartSizeEvent(const nsAString& cachePath, + uint32_t currentSize, + bool shouldUseOldMaxSmartSize) + : mozilla::Runnable("nsGetSmartSizeEvent") + , mCachePath(cachePath) + , mCurrentSize(currentSize) + , mShouldUseOldMaxSmartSize(shouldUseOldMaxSmartSize) + { + } + + // Calculates user's disk space available on a background thread and + // dispatches this value back to the main thread. + NS_IMETHOD Run() override + { + uint32_t size; + size = nsCacheProfilePrefObserver::GetSmartCacheSize( + mCachePath, mCurrentSize, mShouldUseOldMaxSmartSize); + NS_DispatchToMainThread(new nsSetSmartSizeEvent(size)); + return NS_OK; } private: @@ -290,8 +295,9 @@ private: class nsBlockOnCacheThreadEvent : public Runnable { public: - nsBlockOnCacheThreadEvent() - { + nsBlockOnCacheThreadEvent() + : mozilla::Runnable("nsBlockOnCacheThreadEvent") + { } NS_IMETHOD Run() override { @@ -976,9 +982,10 @@ nsCacheProfilePrefObserver::CacheCompressionLevel() class nsProcessRequestEvent : public Runnable { public: - explicit nsProcessRequestEvent(nsCacheRequest *aRequest) - { - mRequest = aRequest; + explicit nsProcessRequestEvent(nsCacheRequest* aRequest) + : mozilla::Runnable("nsProcessRequestEvent") + { + mRequest = aRequest; } NS_IMETHOD Run() override @@ -1017,6 +1024,7 @@ public: nsDoomEvent(nsCacheSession *session, const nsACString &key, nsICacheListener *listener) + : mozilla::Runnable("nsDoomEvent") { mKey = *session->ClientID(); mKey.Append(':'); @@ -1333,11 +1341,13 @@ namespace { class EvictionNotifierRunnable : public Runnable { public: - explicit EvictionNotifierRunnable(nsISupports* aSubject) - : mSubject(aSubject) - { } + explicit EvictionNotifierRunnable(nsISupports* aSubject) + : mozilla::Runnable("EvictionNotifierRunnable") + , mSubject(aSubject) + { + } - NS_DECL_NSIRUNNABLE + NS_DECL_NSIRUNNABLE private: nsCOMPtr mSubject; @@ -1531,10 +1541,12 @@ 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 = NewRunnableMethod(this, - &nsCacheService::FireClearNetworkCacheStoredAnywhereNotification); - NS_DispatchToMainThread(event); + if (!NS_IsMainThread()) { + nsCOMPtr event = NewRunnableMethod( + "nsCacheService::FireClearNetworkCacheStoredAnywhereNotification", + this, + &nsCacheService::FireClearNetworkCacheStoredAnywhereNotification); + NS_DispatchToMainThread(event); } else { // else you're already on main thread - notify observers FireClearNetworkCacheStoredAnywhereNotification(); @@ -1645,37 +1657,42 @@ nsCacheService::CreateDiskDevice() class nsDisableOldMaxSmartSizePrefEvent: public Runnable { public: - nsDisableOldMaxSmartSizePrefEvent() {} + nsDisableOldMaxSmartSizePrefEvent() + : mozilla::Runnable("nsDisableOldMaxSmartSizePrefEvent") + { + } - NS_IMETHOD Run() override - { - // Main thread may have already called nsCacheService::Shutdown - if (!nsCacheService::IsInitialized()) - return NS_ERROR_NOT_AVAILABLE; + NS_IMETHOD Run() override + { + // Main thread may have already called nsCacheService::Shutdown + if (!nsCacheService::IsInitialized()) + return NS_ERROR_NOT_AVAILABLE; - nsCOMPtr branch = do_GetService(NS_PREFSERVICE_CONTRACTID); - if (!branch) { - return NS_ERROR_NOT_AVAILABLE; - } + nsCOMPtr branch = do_GetService(NS_PREFSERVICE_CONTRACTID); + if (!branch) { + return NS_ERROR_NOT_AVAILABLE; + } - nsresult rv = branch->SetBoolPref(DISK_CACHE_USE_OLD_MAX_SMART_SIZE_PREF, false); - if (NS_FAILED(rv)) { - NS_WARNING("Failed to disable old max smart size"); - return rv; - } + nsresult rv = + branch->SetBoolPref(DISK_CACHE_USE_OLD_MAX_SMART_SIZE_PREF, false); + if (NS_FAILED(rv)) { + NS_WARNING("Failed to disable old max smart size"); + return rv; + } - // It is safe to call SetDiskSmartSize_Locked() without holding the lock - // when we are on main thread and nsCacheService is initialized. - nsCacheService::gService->SetDiskSmartSize_Locked(); + // It is safe to call SetDiskSmartSize_Locked() without holding the lock + // when we are on main thread and nsCacheService is initialized. + nsCacheService::gService->SetDiskSmartSize_Locked(); - if (nsCacheService::gService->mObserver->PermittedToSmartSize(branch, false)) { - rv = branch->SetIntPref(DISK_CACHE_CAPACITY_PREF, MAX_CACHE_SIZE); - if (NS_FAILED(rv)) { - NS_WARNING("Failed to set cache capacity pref"); - } - } + if (nsCacheService::gService->mObserver->PermittedToSmartSize(branch, + false)) { + rv = branch->SetIntPref(DISK_CACHE_CAPACITY_PREF, MAX_CACHE_SIZE); + if (NS_FAILED(rv)) { + NS_WARNING("Failed to set cache capacity pref"); + } + } - return NS_OK; + return NS_OK; } }; @@ -1856,23 +1873,25 @@ nsCacheService::CreateRequest(nsCacheSession * session, class nsCacheListenerEvent : public Runnable { public: - nsCacheListenerEvent(nsICacheListener *listener, - nsICacheEntryDescriptor *descriptor, - nsCacheAccessMode accessGranted, - nsresult status) - : mListener(listener) // transfers reference - , mDescriptor(descriptor) // transfers reference (may be null) - , mAccessGranted(accessGranted) - , mStatus(status) - {} + nsCacheListenerEvent(nsICacheListener* listener, + nsICacheEntryDescriptor* descriptor, + nsCacheAccessMode accessGranted, + nsresult status) + : mozilla::Runnable("nsCacheListenerEvent") + , mListener(listener) // transfers reference + , mDescriptor(descriptor) // transfers reference (may be null) + , mAccessGranted(accessGranted) + , mStatus(status) + { + } - NS_IMETHOD Run() override - { - mListener->OnCacheEntryAvailable(mDescriptor, mAccessGranted, mStatus); + NS_IMETHOD Run() override + { + mListener->OnCacheEntryAvailable(mDescriptor, mAccessGranted, mStatus); - NS_RELEASE(mListener); - NS_IF_RELEASE(mDescriptor); - return NS_OK; + NS_RELEASE(mListener); + NS_IF_RELEASE(mDescriptor); + return NS_OK; } private: diff --git a/netwerk/cache/nsCacheService.h b/netwerk/cache/nsCacheService.h index 049a8ddb6b75..c02c7b4d483a 100644 --- a/netwerk/cache/nsCacheService.h +++ b/netwerk/cache/nsCacheService.h @@ -40,17 +40,18 @@ class mozIStorageService; class nsNotifyDoomListener : public mozilla::Runnable { public: - nsNotifyDoomListener(nsICacheListener *listener, - nsresult status) - : mListener(listener) // transfers reference - , mStatus(status) - {} + nsNotifyDoomListener(nsICacheListener* listener, nsresult status) + : mozilla::Runnable("nsNotifyDoomListener") + , mListener(listener) // transfers reference + , mStatus(status) + { + } - NS_IMETHOD Run() override - { - mListener->OnCacheEntryDoomed(mStatus); - NS_RELEASE(mListener); - return NS_OK; + NS_IMETHOD Run() override + { + mListener->OnCacheEntryDoomed(mStatus); + NS_RELEASE(mListener); + return NS_OK; } private: diff --git a/netwerk/cache/nsCacheUtils.cpp b/netwerk/cache/nsCacheUtils.cpp index 7cb5622747c4..801eaf9900b6 100644 --- a/netwerk/cache/nsCacheUtils.cpp +++ b/netwerk/cache/nsCacheUtils.cpp @@ -12,8 +12,9 @@ using namespace mozilla; class nsDestroyThreadEvent : public Runnable { public: - explicit nsDestroyThreadEvent(nsIThread *thread) - : mThread(thread) + explicit nsDestroyThreadEvent(nsIThread* thread) + : mozilla::Runnable("nsDestroyThreadEvent") + , mThread(thread) {} NS_IMETHOD Run() override { @@ -24,8 +25,9 @@ private: nsCOMPtr mThread; }; -nsShutdownThread::nsShutdownThread(nsIThread *aThread) - : mMonitor("nsShutdownThread.mMonitor") +nsShutdownThread::nsShutdownThread(nsIThread* aThread) + : mozilla::Runnable("nsShutdownThread") + , mMonitor("nsShutdownThread.mMonitor") , mShuttingDown(false) , mThread(aThread) { diff --git a/netwerk/cache/nsDeleteDir.cpp b/netwerk/cache/nsDeleteDir.cpp index 1f3f3934e970..0f9f3a6fa5b6 100644 --- a/netwerk/cache/nsDeleteDir.cpp +++ b/netwerk/cache/nsDeleteDir.cpp @@ -21,7 +21,10 @@ using namespace mozilla; class nsBlockOnBackgroundThreadEvent : public Runnable { public: - nsBlockOnBackgroundThreadEvent() {} + nsBlockOnBackgroundThreadEvent() + : mozilla::Runnable("nsBlockOnBackgroundThreadEvent") + { + } NS_IMETHOD Run() override { MutexAutoLock lock(nsDeleteDir::gInstance->mLock); @@ -390,8 +393,11 @@ nsDeleteDir::PostTimer(void *arg, uint32_t delay) if (NS_FAILED(rv)) return rv; - rv = timer->InitWithFuncCallback(TimerCallback, arg, delay, - nsITimer::TYPE_ONE_SHOT); + rv = timer->InitWithNamedFuncCallback(TimerCallback, + arg, + delay, + nsITimer::TYPE_ONE_SHOT, + "nsDeleteDir::PostTimer"); if (NS_FAILED(rv)) return rv; diff --git a/netwerk/cache/nsDiskCacheDevice.cpp b/netwerk/cache/nsDiskCacheDevice.cpp index d0f18c91c867..9cf285a95d78 100644 --- a/netwerk/cache/nsDiskCacheDevice.cpp +++ b/netwerk/cache/nsDiskCacheDevice.cpp @@ -52,14 +52,15 @@ using namespace mozilla; class nsDiskCacheDeviceDeactivateEntryEvent : public Runnable { public: - nsDiskCacheDeviceDeactivateEntryEvent(nsDiskCacheDevice *device, - nsCacheEntry * entry, - nsDiskCacheBinding * binding) - : mCanceled(false), - mEntry(entry), - mDevice(device), - mBinding(binding) - { + nsDiskCacheDeviceDeactivateEntryEvent(nsDiskCacheDevice* device, + nsCacheEntry* entry, + nsDiskCacheBinding* binding) + : mozilla::Runnable("nsDiskCacheDeviceDeactivateEntryEvent") + , mCanceled(false) + , mEntry(entry) + , mDevice(device) + , mBinding(binding) + { } NS_IMETHOD Run() override @@ -82,14 +83,17 @@ private: class nsEvictDiskCacheEntriesEvent : public Runnable { public: - explicit nsEvictDiskCacheEntriesEvent(nsDiskCacheDevice *device) - : mDevice(device) {} + explicit nsEvictDiskCacheEntriesEvent(nsDiskCacheDevice* device) + : mozilla::Runnable("nsEvictDiskCacheEntriesEvent") + , mDevice(device) + { + } - NS_IMETHOD Run() override - { - nsCacheServiceAutoLock lock; - mDevice->EvictDiskCacheEntries(mDevice->mCacheCapacity); - return NS_OK; + NS_IMETHOD Run() override + { + nsCacheServiceAutoLock lock; + mDevice->EvictDiskCacheEntries(mDevice->mCacheCapacity); + return NS_OK; } private: diff --git a/netwerk/cache/nsDiskCacheDeviceSQL.cpp b/netwerk/cache/nsDiskCacheDeviceSQL.cpp index a616682674dd..c72460086d65 100644 --- a/netwerk/cache/nsDiskCacheDeviceSQL.cpp +++ b/netwerk/cache/nsDiskCacheDeviceSQL.cpp @@ -299,10 +299,11 @@ nsOfflineCacheEvictionFunction::Apply() class nsOfflineCacheDiscardCache : public Runnable { public: - nsOfflineCacheDiscardCache(nsOfflineCacheDevice *device, - nsCString &group, - nsCString &clientID) - : mDevice(device) + nsOfflineCacheDiscardCache(nsOfflineCacheDevice* device, + nsCString& group, + nsCString& clientID) + : mozilla::Runnable("nsOfflineCacheDiscardCache") + , mDevice(device) , mGroup(group) , mClientID(clientID) { @@ -920,7 +921,8 @@ nsApplicationCache::GetUsage(uint32_t *usage) class nsCloseDBEvent : public Runnable { public: - explicit nsCloseDBEvent(mozIStorageConnection *aDB) + explicit nsCloseDBEvent(mozIStorageConnection* aDB) + : mozilla::Runnable("nsCloseDBEvent") { mDB = aDB; } diff --git a/netwerk/cache/nsDiskCacheMap.cpp b/netwerk/cache/nsDiskCacheMap.cpp index d7ce13a35a74..7d38055637e5 100644 --- a/netwerk/cache/nsDiskCacheMap.cpp +++ b/netwerk/cache/nsDiskCacheMap.cpp @@ -1350,10 +1350,12 @@ nsresult nsDiskCacheMap::ResetCacheTimer(int32_t timeout) { mCleanCacheTimer->Cancel(); - nsresult rv = - mCleanCacheTimer->InitWithFuncCallback(RevalidateTimerCallback, - nullptr, timeout, - nsITimer::TYPE_ONE_SHOT); + nsresult rv = mCleanCacheTimer->InitWithNamedFuncCallback( + RevalidateTimerCallback, + nullptr, + timeout, + nsITimer::TYPE_ONE_SHOT, + "nsDiskCacheMap::ResetCacheTimer"); NS_ENSURE_SUCCESS(rv, rv); mLastInvalidateTime = PR_IntervalNow(); diff --git a/netwerk/cache2/CacheEntry.cpp b/netwerk/cache2/CacheEntry.cpp index fcfce09de099..2bc7b468b7d4 100644 --- a/netwerk/cache2/CacheEntry.cpp +++ b/netwerk/cache2/CacheEntry.cpp @@ -663,7 +663,8 @@ bool CacheEntry::InvokeCallbacks(bool aReadOnly) if (NS_SUCCEEDED(rv) && !onCheckThread) { // Redispatch to the target thread - rv = mCallbacks[i].mTarget->Dispatch(NewRunnableMethod(this, + rv = mCallbacks[i].mTarget->Dispatch(NewRunnableMethod("net::CacheEntry::InvokeCallbacksLock", + this, &CacheEntry::InvokeCallbacksLock), nsIEventTarget::DISPATCH_NORMAL); if (NS_SUCCEEDED(rv)) { @@ -1859,7 +1860,11 @@ 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... - NS_DispatchToMainThread(NewRunnableMethod(this, &CacheEntry::StoreFrecency, mFrecency)); + NS_DispatchToMainThread( + NewRunnableMethod("net::CacheEntry::StoreFrecency", + this, + &CacheEntry::StoreFrecency, + mFrecency)); } if (aOperations & Ops::REGISTER) { @@ -1894,7 +1899,8 @@ void CacheEntry::StoreFrecency(double aFrecency) // CacheOutputCloseListener CacheOutputCloseListener::CacheOutputCloseListener(CacheEntry* aEntry) -: mEntry(aEntry) + : Runnable("net::CacheOutputCloseListener") + , mEntry(aEntry) { } diff --git a/netwerk/cache2/CacheEntry.h b/netwerk/cache2/CacheEntry.h index d37cecdbb20f..044d544bdd9b 100644 --- a/netwerk/cache2/CacheEntry.h +++ b/netwerk/cache2/CacheEntry.h @@ -208,7 +208,11 @@ private: { public: DoomCallbackRunnable(CacheEntry* aEntry, nsresult aRv) - : mEntry(aEntry), mRv(aRv) {} + : Runnable("net::CacheEntry::DoomCallbackRunnable") + , mEntry(aEntry) + , mRv(aRv) + { + } private: NS_IMETHOD Run() override diff --git a/netwerk/cache2/CacheFile.cpp b/netwerk/cache2/CacheFile.cpp index 42c6d3b3c68d..89f9a3a73b01 100644 --- a/netwerk/cache2/CacheFile.cpp +++ b/netwerk/cache2/CacheFile.cpp @@ -30,10 +30,11 @@ namespace net { class NotifyCacheFileListenerEvent : public Runnable { public: - NotifyCacheFileListenerEvent(CacheFileListener *aCallback, + NotifyCacheFileListenerEvent(CacheFileListener* aCallback, nsresult aResult, bool aIsNew) - : mCallback(aCallback) + : Runnable("net::NotifyCacheFileListenerEvent") + , mCallback(aCallback) , mRV(aResult) , mIsNew(aIsNew) { @@ -65,11 +66,12 @@ protected: class NotifyChunkListenerEvent : public Runnable { public: - NotifyChunkListenerEvent(CacheFileChunkListener *aCallback, + NotifyChunkListenerEvent(CacheFileChunkListener* aCallback, nsresult aResult, uint32_t aChunkIdx, - CacheFileChunk *aChunk) - : mCallback(aCallback) + CacheFileChunk* aChunk) + : Runnable("net::NotifyChunkListenerEvent") + , mCallback(aCallback) , mRV(aResult) , mChunkIdx(aChunkIdx) , mChunk(aChunk) diff --git a/netwerk/cache2/CacheFileChunk.cpp b/netwerk/cache2/CacheFileChunk.cpp index 2803fccf5e51..1cc18d4e9b34 100644 --- a/netwerk/cache2/CacheFileChunk.cpp +++ b/netwerk/cache2/CacheFileChunk.cpp @@ -246,9 +246,10 @@ CacheFileChunkWriteHandle::UpdateDataSize(uint32_t aOffset, uint32_t aLen) class NotifyUpdateListenerEvent : public Runnable { public: - NotifyUpdateListenerEvent(CacheFileChunkListener *aCallback, - CacheFileChunk *aChunk) - : mCallback(aCallback) + NotifyUpdateListenerEvent(CacheFileChunkListener* aCallback, + CacheFileChunk* aChunk) + : Runnable("net::NotifyUpdateListenerEvent") + , mCallback(aCallback) , mChunk(aChunk) { LOG(("NotifyUpdateListenerEvent::NotifyUpdateListenerEvent() [this=%p]", @@ -283,7 +284,8 @@ CacheFileChunk::DispatchRelease() return false; } - NS_DispatchToMainThread(NewNonOwningRunnableMethod(this, &CacheFileChunk::Release)); + NS_DispatchToMainThread(NewNonOwningRunnableMethod( + "net::CacheFileChunk::Release", this, &CacheFileChunk::Release)); return true; } diff --git a/netwerk/cache2/CacheFileContextEvictor.cpp b/netwerk/cache2/CacheFileContextEvictor.cpp index 51c87011a230..4328d0bcd6bf 100644 --- a/netwerk/cache2/CacheFileContextEvictor.cpp +++ b/netwerk/cache2/CacheFileContextEvictor.cpp @@ -523,7 +523,9 @@ CacheFileContextEvictor::StartEvicting() } nsCOMPtr ev; - ev = NewRunnableMethod(this, &CacheFileContextEvictor::EvictEntries); + ev = NewRunnableMethod("net::CacheFileContextEvictor::EvictEntries", + this, + &CacheFileContextEvictor::EvictEntries); RefPtr ioThread = CacheFileIOManager::IOThread(); diff --git a/netwerk/cache2/CacheFileIOManager.cpp b/netwerk/cache2/CacheFileIOManager.cpp index 189dd86d7362..f56f5f1067de 100644 --- a/netwerk/cache2/CacheFileIOManager.cpp +++ b/netwerk/cache2/CacheFileIOManager.cpp @@ -69,10 +69,10 @@ CacheFileHandle::DispatchRelease() return false; } - nsresult rv = - ioTarget->Dispatch(NewNonOwningRunnableMethod(this, - &CacheFileHandle::Release), - nsIEventTarget::DISPATCH_NORMAL); + nsresult rv = ioTarget->Dispatch( + NewNonOwningRunnableMethod( + "net::CacheFileHandle::Release", this, &CacheFileHandle::Release), + nsIEventTarget::DISPATCH_NORMAL); if (NS_FAILED(rv)) { return false; } @@ -545,7 +545,8 @@ CacheFileHandles::SizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const class ShutdownEvent : public Runnable { public: ShutdownEvent() - : mMonitor("ShutdownEvent.mMonitor") + : Runnable("net::ShutdownEvent") + , mMonitor("ShutdownEvent.mMonitor") , mNotified(false) { } @@ -596,9 +597,11 @@ protected: class OpenFileEvent : public Runnable { public: - OpenFileEvent(const nsACString &aKey, uint32_t aFlags, - CacheFileIOListener *aCallback) - : mFlags(aFlags) + OpenFileEvent(const nsACString& aKey, + uint32_t aFlags, + CacheFileIOListener* aCallback) + : Runnable("net::OpenFileEvent") + , mFlags(aFlags) , mCallback(aCallback) , mKey(aKey) { @@ -654,9 +657,13 @@ protected: class ReadEvent : public Runnable { public: - ReadEvent(CacheFileHandle *aHandle, int64_t aOffset, char *aBuf, - int32_t aCount, CacheFileIOListener *aCallback) - : mHandle(aHandle) + ReadEvent(CacheFileHandle* aHandle, + int64_t aOffset, + char* aBuf, + int32_t aCount, + CacheFileIOListener* aCallback) + : Runnable("net::ReadEvent") + , mHandle(aHandle) , mOffset(aOffset) , mBuf(aBuf) , mCount(aCount) @@ -695,10 +702,15 @@ protected: class WriteEvent : public Runnable { public: - WriteEvent(CacheFileHandle *aHandle, int64_t aOffset, const char *aBuf, - int32_t aCount, bool aValidate, bool aTruncate, - CacheFileIOListener *aCallback) - : mHandle(aHandle) + WriteEvent(CacheFileHandle* aHandle, + int64_t aOffset, + const char* aBuf, + int32_t aCount, + bool aValidate, + bool aTruncate, + CacheFileIOListener* aCallback) + : Runnable("net::WriteEvent") + , mHandle(aHandle) , mOffset(aOffset) , mBuf(aBuf) , mCount(aCount) @@ -759,9 +771,9 @@ protected: class DoomFileEvent : public Runnable { public: - DoomFileEvent(CacheFileHandle *aHandle, - CacheFileIOListener *aCallback) - : mCallback(aCallback) + DoomFileEvent(CacheFileHandle* aHandle, CacheFileIOListener* aCallback) + : Runnable("net::DoomFileEvent") + , mCallback(aCallback) , mHandle(aHandle) { } @@ -797,9 +809,9 @@ protected: class DoomFileByKeyEvent : public Runnable { public: - DoomFileByKeyEvent(const nsACString &aKey, - CacheFileIOListener *aCallback) - : mCallback(aCallback) + DoomFileByKeyEvent(const nsACString& aKey, CacheFileIOListener* aCallback) + : Runnable("net::DoomFileByKeyEvent") + , mCallback(aCallback) { SHA1Sum sum; sum.update(aKey.BeginReading(), aKey.Length()); @@ -840,8 +852,9 @@ protected: class ReleaseNSPRHandleEvent : public Runnable { public: - explicit ReleaseNSPRHandleEvent(CacheFileHandle *aHandle) - : mHandle(aHandle) + explicit ReleaseNSPRHandleEvent(CacheFileHandle* aHandle) + : Runnable("net::ReleaseNSPRHandleEvent") + , mHandle(aHandle) { } @@ -866,9 +879,12 @@ protected: class TruncateSeekSetEOFEvent : public Runnable { public: - TruncateSeekSetEOFEvent(CacheFileHandle *aHandle, int64_t aTruncatePos, - int64_t aEOFPos, CacheFileIOListener *aCallback) - : mHandle(aHandle) + TruncateSeekSetEOFEvent(CacheFileHandle* aHandle, + int64_t aTruncatePos, + int64_t aEOFPos, + CacheFileIOListener* aCallback) + : Runnable("net::TruncateSeekSetEOFEvent") + , mHandle(aHandle) , mTruncatePos(aTruncatePos) , mEOFPos(aEOFPos) , mCallback(aCallback) @@ -908,9 +924,11 @@ protected: class RenameFileEvent : public Runnable { public: - RenameFileEvent(CacheFileHandle *aHandle, const nsACString &aNewName, - CacheFileIOListener *aCallback) - : mHandle(aHandle) + RenameFileEvent(CacheFileHandle* aHandle, + const nsACString& aNewName, + CacheFileIOListener* aCallback) + : Runnable("net::RenameFileEvent") + , mHandle(aHandle) , mNewName(aNewName) , mCallback(aCallback) { @@ -948,10 +966,12 @@ protected: class InitIndexEntryEvent : public Runnable { public: - InitIndexEntryEvent(CacheFileHandle *aHandle, - OriginAttrsHash aOriginAttrsHash, bool aAnonymous, + InitIndexEntryEvent(CacheFileHandle* aHandle, + OriginAttrsHash aOriginAttrsHash, + bool aAnonymous, bool aPinning) - : mHandle(aHandle) + : Runnable("net::InitIndexEntryEvent") + , mHandle(aHandle) , mOriginAttrsHash(aOriginAttrsHash) , mAnonymous(aAnonymous) , mPinning(aPinning) @@ -993,13 +1013,14 @@ protected: class UpdateIndexEntryEvent : public Runnable { public: - UpdateIndexEntryEvent(CacheFileHandle *aHandle, - const uint32_t *aFrecency, - const uint32_t *aExpirationTime, - const bool *aHasAltData, - const uint16_t *aOnStartTime, - const uint16_t *aOnStopTime) - : mHandle(aHandle) + UpdateIndexEntryEvent(CacheFileHandle* aHandle, + const uint32_t* aFrecency, + const uint32_t* aExpirationTime, + const bool* aHasAltData, + const uint16_t* aOnStartTime, + const uint16_t* aOnStopTime) + : Runnable("net::UpdateIndexEntryEvent") + , mHandle(aHandle) , mHasFrecency(false) , mHasExpirationTime(false) , mHasHasAltData(false) @@ -1078,10 +1099,11 @@ public: RefPtr mFile; RefPtr mIOMan; - MetadataWriteScheduleEvent(CacheFileIOManager * aManager, - CacheFile * aFile, + MetadataWriteScheduleEvent(CacheFileIOManager* aManager, + CacheFile* aFile, EMode aMode) - : mMode(aMode) + : Runnable("net::MetadataWriteScheduleEvent") + , mMode(aMode) , mFile(aFile) , mIOMan(aManager) { } @@ -2721,8 +2743,9 @@ CacheFileIOManager::EvictIfOverLimit() } nsCOMPtr ev; - ev = NewRunnableMethod(ioMan, - &CacheFileIOManager::EvictIfOverLimitInternal); + ev = NewRunnableMethod("net::CacheFileIOManager::EvictIfOverLimitInternal", + ioMan, + &CacheFileIOManager::EvictIfOverLimitInternal); rv = ioMan->mIOThread->Dispatch(ev, CacheIOThread::EVICT); NS_ENSURE_SUCCESS(rv, rv); @@ -2785,8 +2808,9 @@ CacheFileIOManager::EvictIfOverLimitInternal() cacheUsage, cacheLimit)); nsCOMPtr ev; - ev = NewRunnableMethod(this, - &CacheFileIOManager::OverLimitEvictionInternal); + ev = NewRunnableMethod("net::CacheFileIOManager::OverLimitEvictionInternal", + this, + &CacheFileIOManager::OverLimitEvictionInternal); rv = mIOThread->Dispatch(ev, CacheIOThread::EVICT); NS_ENSURE_SUCCESS(rv, rv); @@ -2945,7 +2969,9 @@ CacheFileIOManager::EvictAll() } nsCOMPtr ev; - ev = NewRunnableMethod(ioMan, &CacheFileIOManager::EvictAllInternal); + ev = NewRunnableMethod("net::CacheFileIOManager::EvictAllInternal", + ioMan, + &CacheFileIOManager::EvictAllInternal); rv = ioMan->mIOThread->DispatchAfterPendingOpens(ev); if (NS_WARN_IF(NS_FAILED(rv))) { @@ -2960,6 +2986,7 @@ namespace { class EvictionNotifierRunnable : public Runnable { public: + EvictionNotifierRunnable() : Runnable("EvictionNotifierRunnable") {} NS_DECL_NSIRUNNABLE }; @@ -3063,8 +3090,12 @@ CacheFileIOManager::EvictByContext(nsILoadContextInfo *aLoadContextInfo, bool aP } nsCOMPtr ev; - ev = NewRunnableMethod, bool> - (ioMan, &CacheFileIOManager::EvictByContextInternal, aLoadContextInfo, aPinned); + ev = NewRunnableMethod, bool>( + "net::CacheFileIOManager::EvictByContextInternal", + ioMan, + &CacheFileIOManager::EvictByContextInternal, + aLoadContextInfo, + aPinned); rv = ioMan->mIOThread->DispatchAfterPendingOpens(ev); if (NS_WARN_IF(NS_FAILED(rv))) { @@ -3182,8 +3213,10 @@ CacheFileIOManager::CacheIndexStateChanged() // We have to re-distatch even if we are on IO thread to prevent reentering // the lock in CacheIndex nsCOMPtr ev; - ev = NewRunnableMethod( - gInstance.get(), &CacheFileIOManager::CacheIndexStateChangedInternal); + ev = + NewRunnableMethod("net::CacheFileIOManager::CacheIndexStateChangedInternal", + gInstance.get(), + &CacheFileIOManager::CacheIndexStateChangedInternal); nsCOMPtr ioTarget = IOTarget(); MOZ_ASSERT(ioTarget); @@ -3347,9 +3380,12 @@ CacheFileIOManager::StartRemovingTrash() rv = timer->SetTarget(ioTarget); NS_ENSURE_SUCCESS(rv, rv); - rv = timer->InitWithFuncCallback(CacheFileIOManager::OnTrashTimer, nullptr, - kRemoveTrashStartDelay - elapsed, - nsITimer::TYPE_ONE_SHOT); + rv = timer->InitWithNamedFuncCallback( + CacheFileIOManager::OnTrashTimer, + nullptr, + kRemoveTrashStartDelay - elapsed, + nsITimer::TYPE_ONE_SHOT, + "net::CacheFileIOManager::StartRemovingTrash"); NS_ENSURE_SUCCESS(rv, rv); mTrashTimer.swap(timer); @@ -3357,8 +3393,9 @@ CacheFileIOManager::StartRemovingTrash() } nsCOMPtr ev; - ev = NewRunnableMethod(this, - &CacheFileIOManager::RemoveTrashInternal); + ev = NewRunnableMethod("net::CacheFileIOManager::RemoveTrashInternal", + this, + &CacheFileIOManager::RemoveTrashInternal); rv = mIOThread->Dispatch(ev, CacheIOThread::EVICT); NS_ENSURE_SUCCESS(rv, rv); @@ -4219,9 +4256,10 @@ class SizeOfHandlesRunnable : public Runnable { public: SizeOfHandlesRunnable(mozilla::MallocSizeOf mallocSizeOf, - CacheFileHandles const &handles, - nsTArray const &specialHandles) - : mMonitor("SizeOfHandlesRunnable.mMonitor") + CacheFileHandles const& handles, + nsTArray const& specialHandles) + : Runnable("net::SizeOfHandlesRunnable") + , mMonitor("SizeOfHandlesRunnable.mMonitor") , mMallocSizeOf(mallocSizeOf) , mHandles(handles) , mSpecialHandles(specialHandles) diff --git a/netwerk/cache2/CacheIndex.cpp b/netwerk/cache2/CacheIndex.cpp index 836c0be9cf36..7cbc5d6b4cd8 100644 --- a/netwerk/cache2/CacheIndex.cpp +++ b/netwerk/cache2/CacheIndex.cpp @@ -367,7 +367,9 @@ CacheIndex::PreShutdown() } nsCOMPtr event; - event = NewRunnableMethod(index, &CacheIndex::PreShutdownInternal); + event = NewRunnableMethod("net::CacheIndex::PreShutdownInternal", + index, + &CacheIndex::PreShutdownInternal); nsCOMPtr ioTarget = CacheFileIOManager::IOTarget(); MOZ_ASSERT(ioTarget); @@ -1436,15 +1438,18 @@ CacheIndex::AsyncGetDiskConsumption(nsICacheStorageConsumptionObserver* aObserve // Move forward with index re/building if it is pending RefPtr ioThread = CacheFileIOManager::IOThread(); if (ioThread) { - ioThread->Dispatch(NS_NewRunnableFunction([]() -> void { - StaticMutexAutoLock lock(sLock); + ioThread->Dispatch( + NS_NewRunnableFunction("net::CacheIndex::AsyncGetDiskConsumption", + []() -> void { + StaticMutexAutoLock lock(sLock); - RefPtr index = gInstance; - if (index && index->mUpdateTimer) { - index->mUpdateTimer->Cancel(); - index->DelayedUpdateLocked(); - } - }), CacheIOThread::INDEX); + RefPtr index = gInstance; + if (index && index->mUpdateTimer) { + index->mUpdateTimer->Cancel(); + index->DelayedUpdateLocked(); + } + }), + CacheIOThread::INDEX); } return NS_OK; @@ -2656,8 +2661,11 @@ CacheIndex::ScheduleUpdateTimer(uint32_t aDelay) rv = timer->SetTarget(ioTarget); NS_ENSURE_SUCCESS(rv, rv); - rv = timer->InitWithFuncCallback(CacheIndex::DelayedUpdate, nullptr, - aDelay, nsITimer::TYPE_ONE_SHOT); + rv = timer->InitWithNamedFuncCallback(CacheIndex::DelayedUpdate, + nullptr, + aDelay, + nsITimer::TYPE_ONE_SHOT, + "net::CacheIndex::ScheduleUpdateTimer"); NS_ENSURE_SUCCESS(rv, rv); mUpdateTimer.swap(timer); diff --git a/netwerk/cache2/CacheIndex.h b/netwerk/cache2/CacheIndex.h index bfd43efd1190..cfbf46cb681f 100644 --- a/netwerk/cache2/CacheIndex.h +++ b/netwerk/cache2/CacheIndex.h @@ -1205,8 +1205,11 @@ private: } private: - explicit DiskConsumptionObserver(nsWeakPtr const &aWeakObserver) - : mObserver(aWeakObserver) { } + explicit DiskConsumptionObserver(nsWeakPtr const& aWeakObserver) + : Runnable("net::CacheIndex::DiskConsumptionObserver") + , mObserver(aWeakObserver) + { + } virtual ~DiskConsumptionObserver() { if (mObserver && !NS_IsMainThread()) { NS_ReleaseOnMainThread( diff --git a/netwerk/cache2/CacheObserver.cpp b/netwerk/cache2/CacheObserver.cpp index af03316dbf11..37c834a1e75d 100644 --- a/netwerk/cache2/CacheObserver.cpp +++ b/netwerk/cache2/CacheObserver.cpp @@ -325,7 +325,9 @@ CacheObserver::SetDiskCacheCapacity(uint32_t aCapacity) sSelf->StoreDiskCacheCapacity(); } else { nsCOMPtr event = - NewRunnableMethod(sSelf, &CacheObserver::StoreDiskCacheCapacity); + NewRunnableMethod("net::CacheObserver::StoreDiskCacheCapacity", + sSelf, + &CacheObserver::StoreDiskCacheCapacity); NS_DispatchToMainThread(event); } } @@ -351,7 +353,9 @@ CacheObserver::SetCacheFSReported() sSelf->StoreCacheFSReported(); } else { nsCOMPtr event = - NewRunnableMethod(sSelf, &CacheObserver::StoreCacheFSReported); + NewRunnableMethod("net::CacheObserver::StoreCacheFSReported", + sSelf, + &CacheObserver::StoreCacheFSReported); NS_DispatchToMainThread(event); } } @@ -377,7 +381,9 @@ CacheObserver::SetHashStatsReported() sSelf->StoreHashStatsReported(); } else { nsCOMPtr event = - NewRunnableMethod(sSelf, &CacheObserver::StoreHashStatsReported); + NewRunnableMethod("net::CacheObserver::StoreHashStatsReported", + sSelf, + &CacheObserver::StoreHashStatsReported); NS_DispatchToMainThread(event); } } diff --git a/netwerk/cache2/CacheStorageService.cpp b/netwerk/cache2/CacheStorageService.cpp index bbc68f04562a..0d66ae5c3ddc 100644 --- a/netwerk/cache2/CacheStorageService.cpp +++ b/netwerk/cache2/CacheStorageService.cpp @@ -147,7 +147,9 @@ void CacheStorageService::Shutdown() mShutdown = true; nsCOMPtr event = - NewRunnableMethod(this, &CacheStorageService::ShutdownBackground); + NewRunnableMethod("net::CacheStorageService::ShutdownBackground", + this, + &CacheStorageService::ShutdownBackground); Dispatch(event); #ifdef NS_FREE_PERMANENT_DATA @@ -195,9 +197,9 @@ class WalkCacheRunnable : public Runnable , public CacheStorageService::EntryInfoCallback { protected: - WalkCacheRunnable(nsICacheStorageVisitor* aVisitor, - bool aVisitEntries) - : mService(CacheStorageService::Self()) + WalkCacheRunnable(nsICacheStorageVisitor* aVisitor, bool aVisitEntries) + : Runnable("net::WalkCacheRunnable") + , mService(CacheStorageService::Self()) , mCallback(aVisitor) , mSize(0) , mNotifyStorage(true) @@ -390,7 +392,8 @@ private: { public: explicit OnCacheEntryInfoRunnable(WalkDiskCacheRunnable* aWalker) - : mWalker(aWalker) + : Runnable("net::WalkDiskCacheRunnable::OnCacheEntryInfoRunnable") + , mWalker(aWalker) { } @@ -572,7 +575,9 @@ public: private: CleaupCacheDirectoriesRunnable(uint32_t aVersion, uint32_t aActive) - : mVersion(aVersion), mActive(aActive) + : Runnable("net::CleaupCacheDirectoriesRunnable") + , mVersion(aVersion) + , mActive(aActive) { nsCacheService::GetDiskCacheDirectory(getter_AddRefs(mCache1Dir)); CacheFileIOManager::GetCacheDirectory(getter_AddRefs(mCache2Dir)); @@ -1265,7 +1270,9 @@ 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 = - NewRunnableMethod(this, &CacheStorageService::SchedulePurgeOverMemoryLimit); + NewRunnableMethod("net::CacheStorageService::SchedulePurgeOverMemoryLimit", + this, + &CacheStorageService::SchedulePurgeOverMemoryLimit); cacheIOTarget->Dispatch(event, nsIEventTarget::DISPATCH_NORMAL); } @@ -1321,7 +1328,9 @@ CacheStorageService::Notify(nsITimer* aTimer) mPurgeTimer = nullptr; nsCOMPtr event = - NewRunnableMethod(this, &CacheStorageService::PurgeOverMemoryLimit); + NewRunnableMethod("net::CacheStorageService::PurgeOverMemoryLimit", + this, + &CacheStorageService::PurgeOverMemoryLimit); Dispatch(event); } @@ -1812,7 +1821,11 @@ CacheStorageService::DoomStorageEntry(CacheStorage const* aStorage, class Callback : public Runnable { public: - explicit Callback(nsICacheEntryDoomCallback* aCallback) : mCallback(aCallback) { } + explicit Callback(nsICacheEntryDoomCallback* aCallback) + : mozilla::Runnable("Callback") + , mCallback(aCallback) + { + } NS_IMETHOD Run() override { mCallback->OnCacheEntryDoomed(NS_ERROR_NOT_AVAILABLE); @@ -1936,7 +1949,11 @@ CacheStorageService::DoomStorageEntries(nsCSubstring const& aContextKey, class Callback : public Runnable { public: - explicit Callback(nsICacheEntryDoomCallback* aCallback) : mCallback(aCallback) { } + explicit Callback(nsICacheEntryDoomCallback* aCallback) + : mozilla::Runnable("Callback") + , mCallback(aCallback) + { + } NS_IMETHOD Run() override { mCallback->OnCacheEntryDoomed(NS_OK); diff --git a/netwerk/cache2/CacheStorageService.h b/netwerk/cache2/CacheStorageService.h index 5f3d60cc24eb..67fbfc4d9f65 100644 --- a/netwerk/cache2/CacheStorageService.h +++ b/netwerk/cache2/CacheStorageService.h @@ -365,7 +365,11 @@ private: { public: PurgeFromMemoryRunnable(CacheStorageService* aService, uint32_t aWhat) - : mService(aService), mWhat(aWhat) { } + : Runnable("net::CacheStorageService::PurgeFromMemoryRunnable") + , mService(aService) + , mWhat(aWhat) + { + } private: virtual ~PurgeFromMemoryRunnable() { } @@ -386,7 +390,12 @@ private: class IOThreadSuspender : public Runnable { public: - IOThreadSuspender() : mMon("IOThreadSuspender"), mSignaled(false) { } + IOThreadSuspender() + : Runnable("net::CacheStorageService::IOThreadSuspender") + , mMon("IOThreadSuspender") + , mSignaled(false) + { + } void Notify(); private: virtual ~IOThreadSuspender() { } diff --git a/netwerk/cache2/OldWrappers.cpp b/netwerk/cache2/OldWrappers.cpp index e33c23cc45ad..ecc1d22e99ff 100644 --- a/netwerk/cache2/OldWrappers.cpp +++ b/netwerk/cache2/OldWrappers.cpp @@ -40,7 +40,9 @@ namespace { class DoomCallbackSynchronizer : public Runnable { public: - explicit DoomCallbackSynchronizer(nsICacheEntryDoomCallback* cb) : mCB(cb) + explicit DoomCallbackSynchronizer(nsICacheEntryDoomCallback* cb) + : Runnable("net::DoomCallbackSynchronizer") + , mCB(cb) { } nsresult Dispatch(); @@ -302,7 +304,8 @@ NS_IMPL_ISUPPORTS_INHERITED(_OldGetDiskConsumption, _OldGetDiskConsumption::_OldGetDiskConsumption( nsICacheStorageConsumptionObserver* aCallback) - : mCallback(aCallback) + : Runnable("net::_OldGetDiskConsumption") + , mCallback(aCallback) , mSize(0) { } @@ -660,7 +663,8 @@ _OldCacheLoad::_OldCacheLoad(nsCSubstring const& aScheme, nsILoadContextInfo* aLoadInfo, bool aWriteToDisk, uint32_t aFlags) - : mScheme(aScheme) + : Runnable("net::_OldCacheLoad") + , mScheme(aScheme) , mCacheKey(aCacheKey) , mCallback(aCallback) , mLoadInfo(GetLoadContextInfo(aLoadInfo)) diff --git a/netwerk/dns/DNSRequestChild.cpp b/netwerk/dns/DNSRequestChild.cpp index e26078cdca59..37d428c8502f 100644 --- a/netwerk/dns/DNSRequestChild.cpp +++ b/netwerk/dns/DNSRequestChild.cpp @@ -165,7 +165,8 @@ class CancelDNSRequestEvent : public Runnable { public: CancelDNSRequestEvent(DNSRequestChild* aDnsReq, nsresult aReason) - : mDnsRequest(aDnsReq) + : Runnable("net::CancelDNSRequestEvent") + , mDnsRequest(aDnsReq) , mReasonForCancel(aReason) {} @@ -215,7 +216,9 @@ DNSRequestChild::StartRequest() SystemGroup::Dispatch( "StartDNSRequestChild", TaskCategory::Other, - NewRunnableMethod(this, &DNSRequestChild::StartRequest)); + NewRunnableMethod("net::DNSRequestChild::StartRequest", + this, + &DNSRequestChild::StartRequest)); return; } @@ -279,7 +282,9 @@ DNSRequestChild::RecvLookupCompleted(const DNSRequestResponse& reply) CallOnLookupComplete(); } else { nsCOMPtr event = - NewRunnableMethod(this, &DNSRequestChild::CallOnLookupComplete); + NewRunnableMethod("net::DNSRequestChild::CallOnLookupComplete", + 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 f1779ec9cc89..fd50ea5f943e 100644 --- a/netwerk/dns/mdns/libmdns/MDNSResponderOperator.cpp +++ b/netwerk/dns/mdns/libmdns/MDNSResponderOperator.cpp @@ -75,7 +75,8 @@ public: PR_Close(mFD); mFD = nullptr; - mThread->Dispatch(NewRunnableMethod(this, &ServiceWatcher::Deallocate), + mThread->Dispatch(NewRunnableMethod("MDNSResponderOperator::ServiceWatcher::Deallocate", + this, &ServiceWatcher::Deallocate), NS_DISPATCH_NORMAL); } @@ -125,7 +126,8 @@ public: } mFD = PR_ImportFile(osfd); - return PostEvent(&ServiceWatcher::OnMsgAttach); + return PostEvent("MDNSResponderOperator::ServiceWatcher::OnMsgAttach", + &ServiceWatcher::OnMsgAttach); } void Close() @@ -137,7 +139,8 @@ public: return; } - PostEvent(&ServiceWatcher::OnMsgClose); + PostEvent("MDNSResponderOperator::ServiceWatcher::OnMsgClose", + &ServiceWatcher::OnMsgClose); } private: @@ -152,9 +155,10 @@ private: mOperatorHolder = nullptr; } - nsresult PostEvent(void(ServiceWatcher::*func)(void)) + nsresult PostEvent(const char* aName, + void(ServiceWatcher::*func)(void)) { - return gSocketTransportService->Dispatch(NewRunnableMethod(this, func), + return gSocketTransportService->Dispatch(NewRunnableMethod(aName, this, func), NS_DISPATCH_NORMAL); } @@ -219,7 +223,8 @@ private: // if (!gSocketTransportService->CanAttachSocket()) { nsCOMPtr event = - NewRunnableMethod(this, &ServiceWatcher::OnMsgAttach); + NewRunnableMethod("MDNSResponderOperator::ServiceWatcher::OnMsgAttach", + this, &ServiceWatcher::OnMsgAttach); nsresult rv = gSocketTransportService->NotifyWhenCanAttachSocket(event); if (NS_FAILED(rv)) { diff --git a/netwerk/dns/mdns/libmdns/MDNSResponderReply.cpp b/netwerk/dns/mdns/libmdns/MDNSResponderReply.cpp index 5b008b05454c..e887eba83cae 100644 --- a/netwerk/dns/mdns/libmdns/MDNSResponderReply.cpp +++ b/netwerk/dns/mdns/libmdns/MDNSResponderReply.cpp @@ -18,7 +18,8 @@ BrowseReplyRunnable::BrowseReplyRunnable(DNSServiceRef aSdRef, const nsACString& aRegType, const nsACString& aReplyDomain, BrowseOperator* aContext) - : mSdRef(aSdRef) + : Runnable("net::BrowseReplyRunnable") + , mSdRef(aSdRef) , mFlags(aFlags) , mInterfaceIndex(aInterfaceIndex) , mErrorCode(aErrorCode) @@ -83,7 +84,8 @@ RegisterReplyRunnable::RegisterReplyRunnable(DNSServiceRef aSdRef, const nsACString& aRegType, const nsACString& domain, RegisterOperator* aContext) - : mSdRef(aSdRef) + : Runnable("net::RegisterReplyRunnable") + , mSdRef(aSdRef) , mFlags(aFlags) , mErrorCode(aErrorCode) , mName(aName) @@ -148,7 +150,8 @@ ResolveReplyRunnable::ResolveReplyRunnable(DNSServiceRef aSdRef, uint16_t aTxtLen, const unsigned char* aTxtRecord, ResolveOperator* aContext) - : mSdRef(aSdRef) + : Runnable("net::ResolveReplyRunnable") + , mSdRef(aSdRef) , mFlags(aFlags) , mInterfaceIndex(aInterfaceIndex) , mErrorCode(aErrorCode) @@ -229,7 +232,8 @@ GetAddrInfoReplyRunnable::GetAddrInfoReplyRunnable(DNSServiceRef aSdRef, const mozilla::net::NetAddr& aAddress, uint32_t aTTL, GetAddrInfoOperator* aContext) - : mSdRef(aSdRef) + : Runnable("net::GetAddrInfoReplyRunnable") + , mSdRef(aSdRef) , mFlags(aFlags) , mInterfaceIndex(aInterfaceIndex) , mErrorCode(aErrorCode) diff --git a/netwerk/dns/nsDNSService2.cpp b/netwerk/dns/nsDNSService2.cpp index 34a3c75b6018..dd1b060a3f3a 100644 --- a/netwerk/dns/nsDNSService2.cpp +++ b/netwerk/dns/nsDNSService2.cpp @@ -453,9 +453,10 @@ nsDNSSyncRequest::SizeOfIncludingThis(MallocSizeOf mallocSizeOf) const class NotifyDNSResolution: public Runnable { public: - explicit NotifyDNSResolution(const nsACString &aHostname) - : mHostname(aHostname) - { + explicit NotifyDNSResolution(const nsACString& aHostname) + : mozilla::Runnable("NotifyDNSResolution") + , mHostname(aHostname) + { } NS_IMETHOD Run() override diff --git a/netwerk/ipc/ChannelEventQueue.cpp b/netwerk/ipc/ChannelEventQueue.cpp index 471f88cb7a17..f099d44499cf 100644 --- a/netwerk/ipc/ChannelEventQueue.cpp +++ b/netwerk/ipc/ChannelEventQueue.cpp @@ -149,7 +149,8 @@ ChannelEventQueue::ResumeInternal() { public: explicit CompleteResumeRunnable(ChannelEventQueue* aQueue, nsISupports* aOwner) - : mQueue(aQueue) + : CancelableRunnable("CompleteResumeRunnable") + , mQueue(aQueue) , mOwner(aOwner) { } diff --git a/netwerk/protocol/about/nsAboutCache.cpp b/netwerk/protocol/about/nsAboutCache.cpp index d85738c47796..8a2857fd6000 100644 --- a/netwerk/protocol/about/nsAboutCache.cpp +++ b/netwerk/protocol/about/nsAboutCache.cpp @@ -224,7 +224,10 @@ nsAboutCache::Channel::VisitNextStorage() // from visitor callback. The cache v1 service doesn't like it. // TODO - mayhemer, bug 913828, remove this dispatch and call // directly. - return NS_DispatchToMainThread(mozilla::NewRunnableMethod(this, &nsAboutCache::Channel::FireVisitStorage)); + return NS_DispatchToMainThread( + mozilla::NewRunnableMethod("nsAboutCache::Channel::FireVisitStorage", + this, + &nsAboutCache::Channel::FireVisitStorage)); } void diff --git a/netwerk/protocol/file/nsFileChannel.cpp b/netwerk/protocol/file/nsFileChannel.cpp index 695aecde8e1d..13fd3dc51147 100644 --- a/netwerk/protocol/file/nsFileChannel.cpp +++ b/netwerk/protocol/file/nsFileChannel.cpp @@ -35,12 +35,14 @@ using namespace mozilla::net; class nsFileCopyEvent : public Runnable { public: - nsFileCopyEvent(nsIOutputStream *dest, nsIInputStream *source, int64_t len) - : mDest(dest) + nsFileCopyEvent(nsIOutputStream* dest, nsIInputStream* source, int64_t len) + : mozilla::Runnable("nsFileCopyEvent") + , mDest(dest) , mSource(source) , mLen(len) , mStatus(NS_OK) - , mInterruptStatus(NS_OK) { + , mInterruptStatus(NS_OK) + { } // Read the current status of the file copy operation. @@ -233,7 +235,9 @@ nsFileUploadContentStream::AsyncWait(nsIInputStreamCallback *callback, if (IsNonBlocking()) { nsCOMPtr callback = - NewRunnableMethod(this, &nsFileUploadContentStream::OnCopyComplete); + NewRunnableMethod("nsFileUploadContentStream::OnCopyComplete", + this, + &nsFileUploadContentStream::OnCopyComplete); mCopyEvent->Dispatch(callback, mSink, target); } diff --git a/netwerk/protocol/ftp/FTPChannelParent.cpp b/netwerk/protocol/ftp/FTPChannelParent.cpp index cf3577bb1501..1e89f16cd289 100644 --- a/netwerk/protocol/ftp/FTPChannelParent.cpp +++ b/netwerk/protocol/ftp/FTPChannelParent.cpp @@ -755,7 +755,9 @@ FTPChannelParent::DivertTo(nsIStreamListener *aListener) // Call OnStartRequest and SendDivertMessages asynchronously to avoid // reentering client context. NS_DispatchToCurrentThread( - NewRunnableMethod(this, &FTPChannelParent::StartDiversion)); + NewRunnableMethod("net::FTPChannelParent::StartDiversion", + this, + &FTPChannelParent::StartDiversion)); return; } @@ -800,10 +802,11 @@ FTPChannelParent::StartDiversion() class FTPFailDiversionEvent : public Runnable { public: - FTPFailDiversionEvent(FTPChannelParent *aChannelParent, + FTPFailDiversionEvent(FTPChannelParent* aChannelParent, nsresult aErrorCode, bool aSkipResume) - : mChannelParent(aChannelParent) + : Runnable("net::FTPFailDiversionEvent") + , mChannelParent(aChannelParent) , mErrorCode(aErrorCode) , mSkipResume(aSkipResume) { diff --git a/netwerk/protocol/ftp/nsFTPChannel.cpp b/netwerk/protocol/ftp/nsFTPChannel.cpp index b6c43f79af31..06bb3b567bd1 100644 --- a/netwerk/protocol/ftp/nsFTPChannel.cpp +++ b/netwerk/protocol/ftp/nsFTPChannel.cpp @@ -148,15 +148,17 @@ public: class OnFTPControlLogRunnable : public Runnable { public: - OnFTPControlLogRunnable(nsIFTPEventSink* aTarget, - bool aServer, - const char* aMessage) - : mTarget(aTarget) - , mServer(aServer) - , mMessage(aMessage) - { } + OnFTPControlLogRunnable(nsIFTPEventSink* aTarget, + bool aServer, + const char* aMessage) + : mozilla::Runnable("FTPEventSinkProxy::OnFTPControlLogRunnable") + , mTarget(aTarget) + , mServer(aServer) + , mMessage(aMessage) + { + } - NS_DECL_NSIRUNNABLE + NS_DECL_NSIRUNNABLE private: nsCOMPtr mTarget; diff --git a/netwerk/protocol/ftp/nsFtpConnectionThread.cpp b/netwerk/protocol/ftp/nsFtpConnectionThread.cpp index ae3354881f62..79cde813624b 100644 --- a/netwerk/protocol/ftp/nsFtpConnectionThread.cpp +++ b/netwerk/protocol/ftp/nsFtpConnectionThread.cpp @@ -1779,10 +1779,11 @@ nsFtpState::KillControlConnection() class nsFtpAsyncAlert : public Runnable { public: - nsFtpAsyncAlert(nsIPrompt *aPrompter, nsString aResponseMsg) - : mPrompter(aPrompter) - , mResponseMsg(aResponseMsg) - { + nsFtpAsyncAlert(nsIPrompt* aPrompter, nsString aResponseMsg) + : mozilla::Runnable("nsFtpAsyncAlert") + , mPrompter(aPrompter) + , mResponseMsg(aResponseMsg) + { } protected: virtual ~nsFtpAsyncAlert() diff --git a/netwerk/protocol/ftp/nsFtpProtocolHandler.cpp b/netwerk/protocol/ftp/nsFtpProtocolHandler.cpp index 2724e397bd1d..1e3831be22d2 100644 --- a/netwerk/protocol/ftp/nsFtpProtocolHandler.cpp +++ b/netwerk/protocol/ftp/nsFtpProtocolHandler.cpp @@ -331,10 +331,12 @@ nsFtpProtocolHandler::InsertConnection(nsIURI *aKey, nsFtpControlConnection *aCo if (!ts) return NS_ERROR_OUT_OF_MEMORY; - rv = timer->InitWithFuncCallback(nsFtpProtocolHandler::Timeout, - ts, - mIdleTimeout*1000, - nsITimer::TYPE_REPEATING_SLACK); + rv = timer->InitWithNamedFuncCallback( + nsFtpProtocolHandler::Timeout, + ts, + mIdleTimeout * 1000, + nsITimer::TYPE_REPEATING_SLACK, + "nsFtpProtocolHandler::InsertConnection"); if (NS_FAILED(rv)) { delete ts; return rv; diff --git a/netwerk/protocol/gio/nsGIOProtocolHandler.cpp b/netwerk/protocol/gio/nsGIOProtocolHandler.cpp index d94fda4ca643..a1fce01b6bc5 100644 --- a/netwerk/protocol/gio/nsGIOProtocolHandler.cpp +++ b/netwerk/protocol/gio/nsGIOProtocolHandler.cpp @@ -543,8 +543,10 @@ nsGIOInputStream::DoRead(char *aBuf, uint32_t aCount, uint32_t *aCountRead) class nsGIOSetContentTypeEvent : public mozilla::Runnable { public: - nsGIOSetContentTypeEvent(nsIChannel *channel, const char *contentType) - : mChannel(channel), mContentType(contentType) + nsGIOSetContentTypeEvent(nsIChannel* channel, const char* contentType) + : mozilla::Runnable("nsGIOSetContentTypeEvent") + , mChannel(channel) + , mContentType(contentType) { // stash channel reference in mChannel. no AddRef here! see note // in SetContentTypeOfchannel. diff --git a/netwerk/protocol/http/AlternateServices.cpp b/netwerk/protocol/http/AlternateServices.cpp index 46accd423741..5c01969c3c34 100644 --- a/netwerk/protocol/http/AlternateServices.cpp +++ b/netwerk/protocol/http/AlternateServices.cpp @@ -270,7 +270,8 @@ AltSvcMapping::Sync() if (!NS_IsMainThread()) { nsCOMPtr r; - r = NewRunnableMethod(this, + r = NewRunnableMethod("net::AltSvcMapping::SyncString", + this, &AltSvcMapping::SyncString, value); NS_DispatchToMainThread(r, NS_DISPATCH_NORMAL); @@ -984,18 +985,21 @@ AltSvcCache::GetAltServiceMapping(const nsACString &scheme, const nsACString &ho class ProxyClearHostMapping : public Runnable { public: - explicit ProxyClearHostMapping(const nsACString &host, int32_t port, - const OriginAttributes &originAttributes) - : mHost(host) + explicit ProxyClearHostMapping(const nsACString& host, + int32_t port, + const OriginAttributes& originAttributes) + : Runnable("net::ProxyClearHostMapping") + , mHost(host) , mPort(port) , mOriginAttributes(originAttributes) - {} + { + } - NS_IMETHOD Run() override - { - MOZ_ASSERT(NS_IsMainThread()); - gHttpHandler->ConnMgr()->ClearHostMapping(mHost, mPort, mOriginAttributes); - return NS_OK; + NS_IMETHOD Run() override + { + MOZ_ASSERT(NS_IsMainThread()); + gHttpHandler->ConnMgr()->ClearHostMapping(mHost, mPort, mOriginAttributes); + return NS_OK; } private: nsCString mHost; diff --git a/netwerk/protocol/http/Http2Push.cpp b/netwerk/protocol/http/Http2Push.cpp index 2b1356ba8bb8..34adc008ff6c 100644 --- a/netwerk/protocol/http/Http2Push.cpp +++ b/netwerk/protocol/http/Http2Push.cpp @@ -25,13 +25,14 @@ namespace net { class CallChannelOnPush final : public Runnable { public: - CallChannelOnPush(nsIHttpChannelInternal *associatedChannel, - const nsACString &pushedURI, - Http2PushedStream *pushStream) - : mAssociatedChannel(associatedChannel) - , mPushedURI(pushedURI) - , mPushedStream(pushStream) - { + CallChannelOnPush(nsIHttpChannelInternal* associatedChannel, + const nsACString& pushedURI, + Http2PushedStream* pushStream) + : Runnable("net::CallChannelOnPush") + , mAssociatedChannel(associatedChannel) + , mPushedURI(pushedURI) + , mPushedStream(pushStream) + { } NS_IMETHOD Run() override diff --git a/netwerk/protocol/http/Http2Session.cpp b/netwerk/protocol/http/Http2Session.cpp index 9ae4c31e3c23..2ee3a577a27b 100644 --- a/netwerk/protocol/http/Http2Session.cpp +++ b/netwerk/protocol/http/Http2Session.cpp @@ -2107,11 +2107,12 @@ Http2Session::RecvContinuation(Http2Session *self) class UpdateAltSvcEvent : public Runnable { public: -UpdateAltSvcEvent(const nsCString &header, - const nsCString &aOrigin, - nsHttpConnectionInfo *aCI, - nsIInterfaceRequestor *callbacks) - : mHeader(header) + UpdateAltSvcEvent(const nsCString& header, + const nsCString& aOrigin, + nsHttpConnectionInfo* aCI, + nsIInterfaceRequestor* callbacks) + : Runnable("net::UpdateAltSvcEvent") + , mHeader(header) , mOrigin(aOrigin) , mCI(aCI) , mCallbacks(callbacks) diff --git a/netwerk/protocol/http/HttpBackgroundChannelChild.cpp b/netwerk/protocol/http/HttpBackgroundChannelChild.cpp index 5adc316df39a..82b172870f85 100644 --- a/netwerk/protocol/http/HttpBackgroundChannelChild.cpp +++ b/netwerk/protocol/http/HttpBackgroundChannelChild.cpp @@ -205,12 +205,19 @@ HttpBackgroundChannelChild::RecvOnTransportAndData( LOG((" > pending until OnStartRequest [offset=%" PRIu64 " count=%" PRIu32 "]\n", aOffset, aCount)); - mQueuedRunnables.AppendElement( - NewRunnableMethod( - this, &HttpBackgroundChannelChild::RecvOnTransportAndData, - aChannelStatus, aTransportStatus, aOffset, - aCount, aData)); + mQueuedRunnables.AppendElement(NewRunnableMethod( + "net::HttpBackgroundChannelChild::RecvOnTransportAndData", + this, + &HttpBackgroundChannelChild::RecvOnTransportAndData, + aChannelStatus, + aTransportStatus, + aOffset, + aCount, + aData)); return IPC_OK(); } @@ -242,8 +249,11 @@ HttpBackgroundChannelChild::RecvOnStopRequest( mQueuedRunnables.AppendElement( NewRunnableMethod( - this, &HttpBackgroundChannelChild::RecvOnStopRequest, - aChannelStatus, aTiming)); + "net::HttpBackgroundChannelChild::RecvOnStopRequest", + this, + &HttpBackgroundChannelChild::RecvOnStopRequest, + aChannelStatus, + aTiming)); return IPC_OK(); } @@ -271,8 +281,11 @@ HttpBackgroundChannelChild::RecvOnProgress(const int64_t& aProgress, mQueuedRunnables.AppendElement( NewRunnableMethod( - this, &HttpBackgroundChannelChild::RecvOnProgress, - aProgress, aProgressMax)); + "net::HttpBackgroundChannelChild::RecvOnProgress", + this, + &HttpBackgroundChannelChild::RecvOnProgress, + aProgress, + aProgressMax)); return IPC_OK(); } @@ -297,9 +310,11 @@ HttpBackgroundChannelChild::RecvOnStatus(const nsresult& aStatus) LOG((" > pending until OnStartRequest [status=%" PRIx32 "]\n", static_cast(aStatus))); - mQueuedRunnables.AppendElement( - NewRunnableMethod( - this, &HttpBackgroundChannelChild::RecvOnStatus, aStatus)); + mQueuedRunnables.AppendElement(NewRunnableMethod( + "net::HttpBackgroundChannelChild::RecvOnStatus", + this, + &HttpBackgroundChannelChild::RecvOnStatus, + aStatus)); return IPC_OK(); } @@ -322,8 +337,10 @@ HttpBackgroundChannelChild::RecvFlushedForDiversion() if (IsWaitingOnStartRequest()) { LOG((" > pending until OnStartRequest\n")); - mQueuedRunnables.AppendElement( - NewRunnableMethod(this, &HttpBackgroundChannelChild::RecvFlushedForDiversion)); + mQueuedRunnables.AppendElement(NewRunnableMethod( + "net::HttpBackgroundChannelChild::RecvFlushedForDiversion", + this, + &HttpBackgroundChannelChild::RecvFlushedForDiversion)); return IPC_OK(); } @@ -347,7 +364,9 @@ HttpBackgroundChannelChild::RecvDivertMessages() LOG((" > pending until OnStartRequest\n")); mQueuedRunnables.AppendElement( - NewRunnableMethod(this, &HttpBackgroundChannelChild::RecvDivertMessages)); + NewRunnableMethod("net::HttpBackgroundChannelChild::RecvDivertMessages", + this, + &HttpBackgroundChannelChild::RecvDivertMessages)); return IPC_OK(); } @@ -420,8 +439,8 @@ HttpBackgroundChannelChild::ActorDestroy(ActorDestroyReason aWhy) if (!mQueuedRunnables.IsEmpty()) { LOG((" > pending until queued messages are flushed\n")); RefPtr self = this; - mQueuedRunnables.AppendElement( - NS_NewRunnableFunction([self]() { + mQueuedRunnables.AppendElement(NS_NewRunnableFunction( + "net::HttpBackgroundChannelChild::ActorDestroy", [self]() { MOZ_ASSERT(NS_IsMainThread()); RefPtr channelChild = self->mChannelChild.forget(); diff --git a/netwerk/protocol/http/HttpBackgroundChannelParent.cpp b/netwerk/protocol/http/HttpBackgroundChannelParent.cpp index 83167245e0c4..3dc3395f71e3 100644 --- a/netwerk/protocol/http/HttpBackgroundChannelParent.cpp +++ b/netwerk/protocol/http/HttpBackgroundChannelParent.cpp @@ -37,7 +37,8 @@ class ContinueAsyncOpenRunnable final : public Runnable public: ContinueAsyncOpenRunnable(HttpBackgroundChannelParent* aActor, const uint64_t& aChannelId) - : mActor(aActor) + : Runnable("net::ContinueAsyncOpenRunnable") + , mActor(aActor) , mChannelId(aChannelId) { AssertIsInMainProcess(); @@ -122,16 +123,21 @@ HttpBackgroundChannelParent::OnChannelClosed() nsresult rv; RefPtr self = this; - rv = mBackgroundThread->Dispatch(NS_NewRunnableFunction([self]() { - LOG(("HttpBackgroundChannelParent::DeleteRunnable [this=%p]\n", self.get())); - AssertIsOnBackgroundThread(); + rv = mBackgroundThread->Dispatch( + NS_NewRunnableFunction( + "net::HttpBackgroundChannelParent::OnChannelClosed", + [self]() { + LOG(("HttpBackgroundChannelParent::DeleteRunnable [this=%p]\n", + self.get())); + AssertIsOnBackgroundThread(); - if (!self->mIPCOpened.compareExchange(true, false)) { - return; - } + if (!self->mIPCOpened.compareExchange(true, false)) { + return; + } - Unused << self->Send__delete__(self); - }), NS_DISPATCH_NORMAL); + Unused << self->Send__delete__(self); + }), + NS_DISPATCH_NORMAL); Unused << NS_WARN_IF(NS_FAILED(rv)); } @@ -148,7 +154,9 @@ HttpBackgroundChannelParent::OnStartRequestSent() if (!IsOnBackgroundThread()) { nsresult rv = mBackgroundThread->Dispatch( - NewRunnableMethod(this, &HttpBackgroundChannelParent::OnStartRequestSent), + NewRunnableMethod("net::HttpBackgroundChannelParent::OnStartRequestSent", + this, + &HttpBackgroundChannelParent::OnStartRequestSent), NS_DISPATCH_NORMAL); MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv)); @@ -176,10 +184,19 @@ HttpBackgroundChannelParent::OnTransportAndData( if (!IsOnBackgroundThread()) { nsresult rv = mBackgroundThread->Dispatch( - NewRunnableMethod - (this, &HttpBackgroundChannelParent::OnTransportAndData, - aChannelStatus, aTransportStatus, aOffset, aCount, aData), + NewRunnableMethod( + "net::HttpBackgroundChannelParent::OnTransportAndData", + this, + &HttpBackgroundChannelParent::OnTransportAndData, + aChannelStatus, + aTransportStatus, + aOffset, + aCount, + aData), NS_DISPATCH_NORMAL); MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv)); @@ -205,9 +222,12 @@ HttpBackgroundChannelParent::OnStopRequest(const nsresult& aChannelStatus, if (!IsOnBackgroundThread()) { nsresult rv = mBackgroundThread->Dispatch( - NewRunnableMethod - (this, &HttpBackgroundChannelParent::OnStopRequest, - aChannelStatus, aTiming), + NewRunnableMethod( + "net::HttpBackgroundChannelParent::OnStopRequest", + this, + &HttpBackgroundChannelParent::OnStopRequest, + aChannelStatus, + aTiming), NS_DISPATCH_NORMAL); MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv)); @@ -232,9 +252,12 @@ HttpBackgroundChannelParent::OnProgress(const int64_t& aProgress, if (!IsOnBackgroundThread()) { nsresult rv = mBackgroundThread->Dispatch( - NewRunnableMethod - (this, &HttpBackgroundChannelParent::OnProgress, - aProgress, aProgressMax), + NewRunnableMethod( + "net::HttpBackgroundChannelParent::OnProgress", + this, + &HttpBackgroundChannelParent::OnProgress, + aProgress, + aProgressMax), NS_DISPATCH_NORMAL); MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv)); @@ -258,8 +281,11 @@ HttpBackgroundChannelParent::OnStatus(const nsresult& aStatus) if (!IsOnBackgroundThread()) { nsresult rv = mBackgroundThread->Dispatch( - NewRunnableMethod - (this, &HttpBackgroundChannelParent::OnStatus, aStatus), + NewRunnableMethod( + "net::HttpBackgroundChannelParent::OnStatus", + this, + &HttpBackgroundChannelParent::OnStatus, + aStatus), NS_DISPATCH_NORMAL); MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv)); @@ -282,7 +308,9 @@ HttpBackgroundChannelParent::OnDiversion() if (!IsOnBackgroundThread()) { nsresult rv = mBackgroundThread->Dispatch( - NewRunnableMethod(this, &HttpBackgroundChannelParent::OnDiversion), + NewRunnableMethod("net::HttpBackgroundChannelParent::OnDiversion", + this, + &HttpBackgroundChannelParent::OnDiversion), NS_DISPATCH_NORMAL); MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv)); @@ -315,7 +343,10 @@ HttpBackgroundChannelParent::OnNotifyTrackingProtectionDisabled() if (!IsOnBackgroundThread()) { nsresult rv = mBackgroundThread->Dispatch( - NewRunnableMethod(this, &HttpBackgroundChannelParent::OnNotifyTrackingProtectionDisabled), + NewRunnableMethod( + "net::HttpBackgroundChannelParent::OnNotifyTrackingProtectionDisabled", + this, + &HttpBackgroundChannelParent::OnNotifyTrackingProtectionDisabled), NS_DISPATCH_NORMAL); MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv)); @@ -338,7 +369,10 @@ HttpBackgroundChannelParent::OnNotifyTrackingResource() if (!IsOnBackgroundThread()) { nsresult rv = mBackgroundThread->Dispatch( - NewRunnableMethod(this, &HttpBackgroundChannelParent::OnNotifyTrackingResource), + NewRunnableMethod( + "net::HttpBackgroundChannelParent::OnNotifyTrackingResource", + this, + &HttpBackgroundChannelParent::OnNotifyTrackingResource), NS_DISPATCH_NORMAL); MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv)); @@ -364,9 +398,13 @@ HttpBackgroundChannelParent::OnSetClassifierMatchedInfo( if (!IsOnBackgroundThread()) { nsresult rv = mBackgroundThread->Dispatch( - NewRunnableMethod - (this, &HttpBackgroundChannelParent::OnSetClassifierMatchedInfo, - aList, aProvider, aPrefix), + NewRunnableMethod( + "net::HttpBackgroundChannelParent::OnSetClassifierMatchedInfo", + this, + &HttpBackgroundChannelParent::OnSetClassifierMatchedInfo, + aList, + aProvider, + aPrefix), NS_DISPATCH_NORMAL); MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv)); @@ -392,8 +430,8 @@ HttpBackgroundChannelParent::ActorDestroy(ActorDestroyReason aWhy) mIPCOpened = false; RefPtr self = this; - DebugOnly rv = - NS_DispatchToMainThread(NS_NewRunnableFunction([self]() { + DebugOnly rv = NS_DispatchToMainThread(NS_NewRunnableFunction( + "net::HttpBackgroundChannelParent::ActorDestroy", [self]() { MOZ_ASSERT(NS_IsMainThread()); RefPtr channelParent = diff --git a/netwerk/protocol/http/HttpBaseChannel.cpp b/netwerk/protocol/http/HttpBaseChannel.cpp index 746732acae24..cf4978453981 100644 --- a/netwerk/protocol/http/HttpBaseChannel.cpp +++ b/netwerk/protocol/http/HttpBaseChannel.cpp @@ -916,7 +916,10 @@ HttpBaseChannel::OnCopyComplete(nsresult aStatus) MOZ_ASSERT(XRE_IsParentProcess()); nsCOMPtr runnable = NewRunnableMethod( - this, &HttpBaseChannel::EnsureUploadStreamIsCloneableComplete, aStatus); + "net::HttpBaseChannel::EnsureUploadStreamIsCloneableComplete", + this, + &HttpBaseChannel::EnsureUploadStreamIsCloneableComplete, + aStatus); NS_DispatchToMainThread(runnable.forget()); } diff --git a/netwerk/protocol/http/HttpBaseChannel.h b/netwerk/protocol/http/HttpBaseChannel.h index 1241a606e625..3bb119cc7b93 100644 --- a/netwerk/protocol/http/HttpBaseChannel.h +++ b/netwerk/protocol/http/HttpBaseChannel.h @@ -724,7 +724,8 @@ nsresult HttpAsyncAborter::AsyncCall(void (T::*funcPtr)(), { nsresult rv; - RefPtr> event = NewRunnableMethod(mThis, funcPtr); + RefPtr> event = + NewRunnableMethod("net::HttpAsyncAborter::AsyncCall", mThis, funcPtr); rv = NS_DispatchToCurrentThread(event); if (NS_SUCCEEDED(rv) && retval) { *retval = event; diff --git a/netwerk/protocol/http/HttpChannelChild.cpp b/netwerk/protocol/http/HttpChannelChild.cpp index 701984dc3f30..eabe4bf755b7 100644 --- a/netwerk/protocol/http/HttpChannelChild.cpp +++ b/netwerk/protocol/http/HttpChannelChild.cpp @@ -789,12 +789,13 @@ HttpChannelChild::OnTransportAndData(const nsresult& channelStatus, nsCOMPtr neckoTarget = GetNeckoTarget(); MOZ_ASSERT(neckoTarget); - DebugOnly rv = - neckoTarget->Dispatch( - NS_NewRunnableFunction([self, transportStatus, progress, progressMax]() { - self->DoOnStatus(self, transportStatus); - self->DoOnProgress(self, progress, progressMax); - }), NS_DISPATCH_NORMAL); + DebugOnly rv = neckoTarget->Dispatch( + NS_NewRunnableFunction("net::HttpChannelChild::OnTransportAndData", + [self, transportStatus, progress, progressMax]() { + self->DoOnStatus(self, transportStatus); + self->DoOnProgress(self, progress, progressMax); + }), + NS_DISPATCH_NORMAL); MOZ_ASSERT(NS_SUCCEEDED(rv)); } @@ -987,7 +988,9 @@ HttpChannelChild::OnStopRequest(const nsresult& channelStatus, MOZ_ASSERT(neckoTarget); DebugOnly rv = neckoTarget->Dispatch( - NewRunnableMethod(mEventQ, &ChannelEventQueue::Resume), NS_DISPATCH_NORMAL); + NewRunnableMethod( + "net::ChannelEventQueue::Resume", mEventQ, &ChannelEventQueue::Resume), + NS_DISPATCH_NORMAL); MOZ_ASSERT(NS_SUCCEEDED(rv)); return; } @@ -1301,7 +1304,9 @@ HttpChannelChild::CleanupBackgroundChannel() SystemGroup::Dispatch( "HttpChannelChild::CleanupBackgroundChannel", TaskCategory::Other, - NewRunnableMethod(bgChild, &HttpBackgroundChannelChild::OnChannelClosed)); + NewRunnableMethod("net::HttpBackgroundChannelChild::OnChannelClosed", + bgChild, + &HttpBackgroundChannelChild::OnChannelClosed)); } else { bgChild->OnChannelClosed(); } @@ -1334,11 +1339,13 @@ HttpChannelChild::RecvDeleteSelf() return IPC_OK(); } -HttpChannelChild::OverrideRunnable::OverrideRunnable(HttpChannelChild* aChannel, - HttpChannelChild* aNewChannel, - InterceptStreamListener* aListener, - nsIInputStream* aInput, - nsAutoPtr& aHead) +HttpChannelChild::OverrideRunnable::OverrideRunnable( + HttpChannelChild* aChannel, + HttpChannelChild* aNewChannel, + InterceptStreamListener* aListener, + nsIInputStream* aInput, + nsAutoPtr& aHead) + : Runnable("net::HttpChannelChild::OverrideRunnable") { mChannel = aChannel; mNewChannel = aNewChannel; @@ -1391,9 +1398,11 @@ HttpChannelChild::RecvFinishInterceptedRedirect() nsCOMPtr neckoTarget = GetNeckoTarget(); MOZ_ASSERT(neckoTarget); - Unused << neckoTarget->Dispatch( - NewRunnableMethod(this, &HttpChannelChild::FinishInterceptedRedirect), - NS_DISPATCH_NORMAL); + Unused << neckoTarget->Dispatch( + NewRunnableMethod("net::HttpChannelChild::FinishInterceptedRedirect", + this, + &HttpChannelChild::FinishInterceptedRedirect), + NS_DISPATCH_NORMAL); return IPC_OK(); } @@ -3223,10 +3232,11 @@ HttpChannelChild::TrySendDeletingChannel() nsCOMPtr neckoTarget = GetNeckoTarget(); MOZ_ASSERT(neckoTarget); - DebugOnly rv = - neckoTarget->Dispatch( - NewNonOwningRunnableMethod(this, &HttpChannelChild::TrySendDeletingChannel), - NS_DISPATCH_NORMAL); + DebugOnly rv = neckoTarget->Dispatch( + NewNonOwningRunnableMethod("net::HttpChannelChild::TrySendDeletingChannel", + this, + &HttpChannelChild::TrySendDeletingChannel), + NS_DISPATCH_NORMAL); MOZ_ASSERT(NS_SUCCEEDED(rv)); } @@ -3234,7 +3244,10 @@ void HttpChannelChild::OnCopyComplete(nsresult aStatus) { nsCOMPtr runnable = NewRunnableMethod( - this, &HttpChannelChild::EnsureUploadStreamIsCloneableComplete, aStatus); + "net::HttpBaseChannel::EnsureUploadStreamIsCloneableComplete", + this, + &HttpChannelChild::EnsureUploadStreamIsCloneableComplete, + aStatus); nsCOMPtr neckoTarget = GetNeckoTarget(); MOZ_ASSERT(neckoTarget); @@ -3248,7 +3261,7 @@ HttpChannelChild::AsyncCall(void (HttpChannelChild::*funcPtr)(), nsresult rv; RefPtr> event = - NewRunnableMethod(this, funcPtr); + NewRunnableMethod("net::HttpChannelChild::AsyncCall", this, funcPtr); nsCOMPtr neckoTarget = GetNeckoTarget(); MOZ_ASSERT(neckoTarget); diff --git a/netwerk/protocol/http/HttpChannelParent.cpp b/netwerk/protocol/http/HttpChannelParent.cpp index c12e71ed047e..84858280455d 100644 --- a/netwerk/protocol/http/HttpChannelParent.cpp +++ b/netwerk/protocol/http/HttpChannelParent.cpp @@ -392,8 +392,9 @@ class InvokeAsyncOpen : public Runnable public: InvokeAsyncOpen(const nsMainThreadPtrHandle& aChannel, nsresult aStatus) - : mChannel(aChannel) - , mStatus(aStatus) + : Runnable("net::InvokeAsyncOpen") + , mChannel(aChannel) + , mStatus(aStatus) { } @@ -1964,7 +1965,9 @@ HttpChannelParent::DivertTo(nsIStreamListener *aListener) // Call OnStartRequest and SendDivertMessages asynchronously to avoid // reentering client context. NS_DispatchToCurrentThread( - NewRunnableMethod(this, &HttpChannelParent::StartDiversion)); + NewRunnableMethod("net::HttpChannelParent::StartDiversion", + this, + &HttpChannelParent::StartDiversion)); return; } @@ -2028,7 +2031,8 @@ class HTTPFailDiversionEvent : public Runnable public: HTTPFailDiversionEvent(HttpChannelParent *aChannelParent, nsresult aErrorCode) - : mChannelParent(aChannelParent) + : Runnable("net::HTTPFailDiversionEvent") + , mChannelParent(aChannelParent) , mErrorCode(aErrorCode) { MOZ_RELEASE_ASSERT(aChannelParent); diff --git a/netwerk/protocol/http/HttpChannelParentListener.cpp b/netwerk/protocol/http/HttpChannelParentListener.cpp index e5170e38cb8c..a10dd94f7bfd 100644 --- a/netwerk/protocol/http/HttpChannelParentListener.cpp +++ b/netwerk/protocol/http/HttpChannelParentListener.cpp @@ -305,7 +305,8 @@ class FinishSynthesizedResponse : public Runnable nsCOMPtr mChannel; public: explicit FinishSynthesizedResponse(nsIInterceptedChannel* aChannel) - : mChannel(aChannel) + : Runnable("net::FinishSynthesizedResponse") + , mChannel(aChannel) { } diff --git a/netwerk/protocol/http/nsHttpActivityDistributor.cpp b/netwerk/protocol/http/nsHttpActivityDistributor.cpp index 42388f3a27a2..f0db7eb48604 100644 --- a/netwerk/protocol/http/nsHttpActivityDistributor.cpp +++ b/netwerk/protocol/http/nsHttpActivityDistributor.cpp @@ -20,21 +20,22 @@ typedef nsTArray ObserverArray; class nsHttpActivityEvent : public Runnable { public: - nsHttpActivityEvent(nsISupports *aHttpChannel, - uint32_t aActivityType, - uint32_t aActivitySubtype, - PRTime aTimestamp, - uint64_t aExtraSizeData, - const nsACString & aExtraStringData, - ObserverArray *aObservers) - : mHttpChannel(aHttpChannel) - , mActivityType(aActivityType) - , mActivitySubtype(aActivitySubtype) - , mTimestamp(aTimestamp) - , mExtraSizeData(aExtraSizeData) - , mExtraStringData(aExtraStringData) - , mObservers(*aObservers) - { + nsHttpActivityEvent(nsISupports* aHttpChannel, + uint32_t aActivityType, + uint32_t aActivitySubtype, + PRTime aTimestamp, + uint64_t aExtraSizeData, + const nsACString& aExtraStringData, + ObserverArray* aObservers) + : Runnable("net::nsHttpActivityEvent") + , mHttpChannel(aHttpChannel) + , mActivityType(aActivityType) + , mActivitySubtype(aActivitySubtype) + , mTimestamp(aTimestamp) + , mExtraSizeData(aExtraSizeData) + , mExtraStringData(aExtraStringData) + , mObservers(*aObservers) + { } NS_IMETHOD Run() override diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp index bc8eee4bdcdb..1f6bb6948edf 100644 --- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -7453,16 +7453,17 @@ nsHttpChannel::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult st class OnTransportStatusAsyncEvent : public Runnable { public: - OnTransportStatusAsyncEvent(nsITransportEventSink* aEventSink, - nsresult aTransportStatus, - int64_t aProgress, - int64_t aProgressMax) - : mEventSink(aEventSink) + OnTransportStatusAsyncEvent(nsITransportEventSink* aEventSink, + nsresult aTransportStatus, + int64_t aProgress, + int64_t aProgressMax) + : Runnable("net::OnTransportStatusAsyncEvent") + , mEventSink(aEventSink) , mTransportStatus(aTransportStatus) , mProgress(aProgress) , mProgressMax(aProgressMax) - { - MOZ_ASSERT(!NS_IsMainThread(), "Shouldn't be created on main thread"); + { + MOZ_ASSERT(!NS_IsMainThread(), "Shouldn't be created on main thread"); } NS_IMETHOD Run() override diff --git a/netwerk/protocol/http/nsHttpConnection.cpp b/netwerk/protocol/http/nsHttpConnection.cpp index e77fcd612167..10d34f64edb3 100644 --- a/netwerk/protocol/http/nsHttpConnection.cpp +++ b/netwerk/protocol/http/nsHttpConnection.cpp @@ -1390,40 +1390,43 @@ nsHttpConnection::PushBack(const char *data, uint32_t length) class HttpConnectionForceIO : public Runnable { public: - HttpConnectionForceIO(nsHttpConnection *aConn, bool doRecv, + HttpConnectionForceIO(nsHttpConnection* aConn, + bool doRecv, bool isFastOpenForce) - : mConn(aConn) - , mDoRecv(doRecv) - , mIsFastOpenForce(isFastOpenForce) - {} + : Runnable("net::HttpConnectionForceIO") + , mConn(aConn) + , mDoRecv(doRecv) + , mIsFastOpenForce(isFastOpenForce) + { + } - NS_IMETHOD Run() override - { - MOZ_ASSERT(OnSocketThread(), "not on socket thread"); + NS_IMETHOD Run() override + { + MOZ_ASSERT(OnSocketThread(), "not on socket thread"); - if (mDoRecv) { - if (!mConn->mSocketIn) - return NS_OK; - return mConn->OnInputStreamReady(mConn->mSocketIn); - } + if (mDoRecv) { + if (!mConn->mSocketIn) + return NS_OK; + return mConn->OnInputStreamReady(mConn->mSocketIn); + } - // This runnable will be called when the ForceIO timer expires - // (mIsFastOpenForce==false) or during the TCP Fast Open to force - // writes (mIsFastOpenForce==true). - if (mIsFastOpenForce && !mConn->mWaitingFor0RTTResponse) { - // If we have exit the TCP Fast Open in the meantime we can skip - // this. - return NS_OK; - } - if (!mIsFastOpenForce) { - MOZ_ASSERT(mConn->mForceSendPending); - mConn->mForceSendPending = false; - } + // This runnable will be called when the ForceIO timer expires + // (mIsFastOpenForce==false) or during the TCP Fast Open to force + // writes (mIsFastOpenForce==true). + if (mIsFastOpenForce && !mConn->mWaitingFor0RTTResponse) { + // If we have exit the TCP Fast Open in the meantime we can skip + // this. + return NS_OK; + } + if (!mIsFastOpenForce) { + MOZ_ASSERT(mConn->mForceSendPending); + mConn->mForceSendPending = false; + } - if (!mConn->mSocketOut) { - return NS_OK; - } - return mConn->OnOutputStreamReady(mConn->mSocketOut); + if (!mConn->mSocketOut) { + return NS_OK; + } + return mConn->OnOutputStreamReady(mConn->mSocketOut); } private: RefPtr mConn; @@ -1515,8 +1518,12 @@ nsHttpConnection::MaybeForceSendIO() MOZ_ASSERT(!mForceSendTimer); mForceSendPending = true; mForceSendTimer = do_CreateInstance("@mozilla.org/timer;1"); - return mForceSendTimer->InitWithFuncCallback( - nsHttpConnection::ForceSendIO, this, kForceDelay, nsITimer::TYPE_ONE_SHOT); + return mForceSendTimer->InitWithNamedFuncCallback( + nsHttpConnection::ForceSendIO, + this, + kForceDelay, + nsITimer::TYPE_ONE_SHOT, + "net::nsHttpConnection::MaybeForceSendIO"); } // trigger an asynchronous read @@ -2070,11 +2077,12 @@ nsHttpConnection::StartShortLivedTCPKeepalives() // Add time for final keepalive probes, and 2 seconds for a buffer. time += ((probeCount) * retryIntervalS) - (time % idleTimeS) + 2; } - mTCPKeepaliveTransitionTimer->InitWithFuncCallback( - nsHttpConnection::UpdateTCPKeepalive, - this, - (uint32_t)time*1000, - nsITimer::TYPE_ONE_SHOT); + mTCPKeepaliveTransitionTimer->InitWithNamedFuncCallback( + nsHttpConnection::UpdateTCPKeepalive, + this, + (uint32_t)time * 1000, + nsITimer::TYPE_ONE_SHOT, + "net::nsHttpConnection::StartShortLivedTCPKeepalives"); } else { NS_WARNING("nsHttpConnection::StartShortLivedTCPKeepalives failed to " "create timer."); diff --git a/netwerk/protocol/http/nsHttpConnectionMgr.cpp b/netwerk/protocol/http/nsHttpConnectionMgr.cpp index 2baf816d0cf3..8076cf8f2914 100644 --- a/netwerk/protocol/http/nsHttpConnectionMgr.cpp +++ b/netwerk/protocol/http/nsHttpConnectionMgr.cpp @@ -250,17 +250,22 @@ nsHttpConnectionMgr::Shutdown() class ConnEvent : public Runnable { public: - ConnEvent(nsHttpConnectionMgr *mgr, - nsConnEventHandler handler, int32_t iparam, ARefBase *vparam) - : mMgr(mgr) - , mHandler(handler) - , mIParam(iparam) - , mVParam(vparam) {} + ConnEvent(nsHttpConnectionMgr* mgr, + nsConnEventHandler handler, + int32_t iparam, + ARefBase* vparam) + : Runnable("net::ConnEvent") + , mMgr(mgr) + , mHandler(handler) + , mIParam(iparam) + , mVParam(vparam) + { + } - NS_IMETHOD Run() override - { - (mMgr->*mHandler)(mIParam, mVParam); - return NS_OK; + NS_IMETHOD Run() override + { + (mMgr->*mHandler)(mIParam, mVParam); + return NS_OK; } private: diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp index 05ebfa1f5e12..093fc1da637a 100644 --- a/netwerk/protocol/http/nsHttpHandler.cpp +++ b/netwerk/protocol/http/nsHttpHandler.cpp @@ -2309,10 +2309,11 @@ nsHttpHandler::Observe(nsISupports *subject, } else if (!strcmp(topic, "browser:purge-session-history")) { if (mConnMgr) { if (gSocketTransportService) { - nsCOMPtr event = - NewRunnableMethod(mConnMgr, - &nsHttpConnectionMgr::ClearConnectionHistory); - gSocketTransportService->Dispatch(event, NS_DISPATCH_NORMAL); + nsCOMPtr event = NewRunnableMethod( + "net::nsHttpConnectionMgr::ClearConnectionHistory", + mConnMgr, + &nsHttpConnectionMgr::ClearConnectionHistory); + gSocketTransportService->Dispatch(event, NS_DISPATCH_NORMAL); } mConnMgr->ClearAltServiceMappings(); } diff --git a/netwerk/protocol/http/nsHttpTransaction.cpp b/netwerk/protocol/http/nsHttpTransaction.cpp index c214d553d581..8d169e534143 100644 --- a/netwerk/protocol/http/nsHttpTransaction.cpp +++ b/netwerk/protocol/http/nsHttpTransaction.cpp @@ -2068,14 +2068,16 @@ nsHttpTransaction::GetResponseEnd() class DeleteHttpTransaction : public Runnable { public: - explicit DeleteHttpTransaction(nsHttpTransaction *trans) - : mTrans(trans) - {} + explicit DeleteHttpTransaction(nsHttpTransaction* trans) + : Runnable("net::DeleteHttpTransaction") + , mTrans(trans) + { + } - NS_IMETHOD Run() override - { - delete mTrans; - return NS_OK; + NS_IMETHOD Run() override + { + delete mTrans; + return NS_OK; } private: nsHttpTransaction *mTrans; diff --git a/netwerk/protocol/http/nsHttpTransaction.h b/netwerk/protocol/http/nsHttpTransaction.h index 395ae4fd5640..d795eef61374 100644 --- a/netwerk/protocol/http/nsHttpTransaction.h +++ b/netwerk/protocol/http/nsHttpTransaction.h @@ -233,7 +233,11 @@ private: public: UpdateSecurityCallbacks(nsHttpTransaction* aTrans, nsIInterfaceRequestor* aCallbacks) - : mTrans(aTrans), mCallbacks(aCallbacks) {} + : Runnable("net::nsHttpTransaction::UpdateSecurityCallbacks") + , mTrans(aTrans) + , mCallbacks(aCallbacks) + { + } NS_IMETHOD Run() override { diff --git a/netwerk/protocol/websocket/WebSocketChannel.cpp b/netwerk/protocol/websocket/WebSocketChannel.cpp index 5f6043225a53..24798d66bff3 100644 --- a/netwerk/protocol/websocket/WebSocketChannel.cpp +++ b/netwerk/protocol/websocket/WebSocketChannel.cpp @@ -709,11 +709,13 @@ NS_IMPL_ISUPPORTS(CallOnServerClose, nsIRunnable) class CallAcknowledge final : public CancelableRunnable { public: - CallAcknowledge(WebSocketChannel* aChannel, - uint32_t aSize) - : mChannel(aChannel), - mListenerMT(mChannel->mListenerMT), - mSize(aSize) {} + CallAcknowledge(WebSocketChannel* aChannel, uint32_t aSize) + : CancelableRunnable("net::CallAcknowledge") + , mChannel(aChannel) + , mListenerMT(mChannel->mListenerMT) + , mSize(aSize) + { + } NS_IMETHOD Run() override { @@ -1263,7 +1265,9 @@ WebSocketChannel::Observe(nsISupports *subject, // Next we check mDataStarted, which we need to do on mTargetThread. if (!IsOnTargetThread()) { mTargetThread->Dispatch( - NewRunnableMethod(this, &WebSocketChannel::OnNetworkChanged), + NewRunnableMethod("net::WebSocketChannel::OnNetworkChanged", + this, + &WebSocketChannel::OnNetworkChanged), NS_DISPATCH_NORMAL); } else { nsresult rv = OnNetworkChanged(); @@ -1291,7 +1295,9 @@ WebSocketChannel::OnNetworkChanged() } return mSocketThread->Dispatch( - NewRunnableMethod(this, &WebSocketChannel::OnNetworkChanged), + NewRunnableMethod("net::WebSocketChannel::OnNetworkChanged", + this, + &WebSocketChannel::OnNetworkChanged), NS_DISPATCH_NORMAL); } @@ -1378,8 +1384,10 @@ WebSocketChannel::BeginOpen(bool aCalledFromAdmissionManager) // When called from nsWSAdmissionManager post an event to avoid potential // re-entering of nsWSAdmissionManager and its lock. NS_DispatchToMainThread( - NewRunnableMethod(this, &WebSocketChannel::BeginOpenInternal), - NS_DISPATCH_NORMAL); + NewRunnableMethod("net::WebSocketChannel::BeginOpenInternal", + this, + &WebSocketChannel::BeginOpenInternal), + NS_DISPATCH_NORMAL); } else { BeginOpenInternal(); } @@ -2296,7 +2304,8 @@ class RemoveObserverRunnable : public Runnable public: explicit RemoveObserverRunnable(WebSocketChannel* aChannel) - : mChannel(aChannel) + : Runnable("net::RemoveObserverRunnable") + , mChannel(aChannel) {} NS_IMETHOD Run() override @@ -2940,7 +2949,9 @@ WebSocketChannel::StartWebsocketData() if (!IsOnTargetThread()) { return mTargetThread->Dispatch( - NewRunnableMethod(this, &WebSocketChannel::StartWebsocketData), + NewRunnableMethod("net::WebSocketChannel::StartWebsocketData", + this, + &WebSocketChannel::StartWebsocketData), NS_DISPATCH_NORMAL); } @@ -2953,7 +2964,8 @@ WebSocketChannel::StartWebsocketData() LOG(("WebSocketChannel::StartWebsocketData mSocketIn->AsyncWait() failed " "with error 0x%08" PRIx32, static_cast(rv))); return mSocketThread->Dispatch( - NewRunnableMethod(this, + NewRunnableMethod("net::WebSocketChannel::AbortSession", + this, &WebSocketChannel::AbortSession, rv), NS_DISPATCH_NORMAL); @@ -2961,7 +2973,9 @@ WebSocketChannel::StartWebsocketData() if (mPingInterval) { rv = mSocketThread->Dispatch( - NewRunnableMethod(this, &WebSocketChannel::StartPinging), + NewRunnableMethod("net::WebSocketChannel::StartPinging", + 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 127325e3b2c9..b037af9218dd 100644 --- a/netwerk/protocol/websocket/WebSocketChannelChild.cpp +++ b/netwerk/protocol/websocket/WebSocketChannelChild.cpp @@ -111,7 +111,8 @@ WebSocketChannelChild::MaybeReleaseIPCObject() if (!NS_IsMainThread()) { nsCOMPtr target = GetNeckoTarget(); MOZ_ALWAYS_SUCCEEDS( - target->Dispatch(NewRunnableMethod(this, + target->Dispatch(NewRunnableMethod("WebSocketChannelChild::MaybeReleaseIPCObject", + this, &WebSocketChannelChild::MaybeReleaseIPCObject), NS_DISPATCH_NORMAL)); return; @@ -135,8 +136,9 @@ WebSocketChannelChild::IsEncrypted() const class WrappedChannelEvent : public Runnable { public: - explicit WrappedChannelEvent(ChannelEvent *aChannelEvent) - : mChannelEvent(aChannelEvent) + explicit WrappedChannelEvent(ChannelEvent* aChannelEvent) + : Runnable("net::WrappedChannelEvent") + , mChannelEvent(aChannelEvent) { MOZ_RELEASE_ASSERT(aChannelEvent); } @@ -598,10 +600,11 @@ WebSocketChannelChild::AsyncOpen(nsIURI *aURI, class CloseEvent : public Runnable { public: - CloseEvent(WebSocketChannelChild *aChild, + CloseEvent(WebSocketChannelChild* aChild, uint16_t aCode, const nsACString& aReason) - : mChild(aChild) + : Runnable("net::CloseEvent") + , mChild(aChild) , mCode(aCode) , mReason(aReason) { @@ -648,10 +651,11 @@ WebSocketChannelChild::Close(uint16_t code, const nsACString & reason) class MsgEvent : public Runnable { public: - MsgEvent(WebSocketChannelChild *aChild, - const nsACString &aMsg, + MsgEvent(WebSocketChannelChild* aChild, + const nsACString& aMsg, bool aBinaryMsg) - : mChild(aChild) + : Runnable("net::MsgEvent") + , mChild(aChild) , mMsg(aMsg) , mBinaryMsg(aBinaryMsg) { @@ -727,10 +731,11 @@ WebSocketChannelChild::SendBinaryMsg(const nsACString &aMsg) class BinaryStreamEvent : public Runnable { public: - BinaryStreamEvent(WebSocketChannelChild *aChild, + BinaryStreamEvent(WebSocketChannelChild* aChild, nsIInputStream* aStream, uint32_t aLength) - : mChild(aChild) + : Runnable("net::BinaryStreamEvent") + , mChild(aChild) , mStream(aStream) , mLength(aLength) { diff --git a/netwerk/protocol/websocket/WebSocketEventService.cpp b/netwerk/protocol/websocket/WebSocketEventService.cpp index ffa6e52d0182..963dba28cb79 100644 --- a/netwerk/protocol/websocket/WebSocketEventService.cpp +++ b/netwerk/protocol/websocket/WebSocketEventService.cpp @@ -35,9 +35,9 @@ IsChildProcess() class WebSocketBaseRunnable : public Runnable { public: - WebSocketBaseRunnable(uint32_t aWebSocketSerialID, - uint64_t aInnerWindowID) - : mWebSocketSerialID(aWebSocketSerialID) + WebSocketBaseRunnable(uint32_t aWebSocketSerialID, uint64_t aInnerWindowID) + : Runnable("net::WebSocketBaseRunnable") + , mWebSocketSerialID(aWebSocketSerialID) , mInnerWindowID(aInnerWindowID) {} diff --git a/netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp b/netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp index 7ec3d376f77a..c6551af16341 100644 --- a/netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp +++ b/netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp @@ -601,8 +601,10 @@ nsWyciwygChannel::OnCacheEntryAvailable(nsICacheEntry *aCacheEntry, LOG(("channel was canceled [this=%p status=%" PRIx32 "]\n", this, static_cast(mStatus))); // Since OnCacheEntryAvailable can be called directly from AsyncOpen // we must dispatch. - NS_DispatchToCurrentThread(mozilla::NewRunnableMethod( - this, &nsWyciwygChannel::NotifyListener)); + NS_DispatchToCurrentThread( + mozilla::NewRunnableMethod("nsWyciwygChannel::NotifyListener", + this, + &nsWyciwygChannel::NotifyListener)); } return NS_OK; diff --git a/netwerk/sctp/datachannel/DataChannel.cpp b/netwerk/sctp/datachannel/DataChannel.cpp index efd20a14bcc8..7d542cc4f530 100644 --- a/netwerk/sctp/datachannel/DataChannel.cpp +++ b/netwerk/sctp/datachannel/DataChannel.cpp @@ -2301,11 +2301,13 @@ DataChannelConnection::SendBinary(DataChannel *channel, const char *data, class ReadBlobRunnable : public Runnable { public: - ReadBlobRunnable(DataChannelConnection* aConnection, uint16_t aStream, - nsIInputStream* aBlob) : - mConnection(aConnection), - mStream(aStream), - mBlob(aBlob) + ReadBlobRunnable(DataChannelConnection* aConnection, + uint16_t aStream, + nsIInputStream* aBlob) + : Runnable("ReadBlobRunnable") + , mConnection(aConnection) + , mStream(aStream) + , mBlob(aBlob) {} NS_IMETHOD Run() override { @@ -2348,10 +2350,14 @@ DataChannelConnection::SendBlob(uint16_t stream, nsIInputStream *aBlob) class DataChannelBlobSendRunnable : public Runnable { public: - DataChannelBlobSendRunnable(already_AddRefed& aConnection, - uint16_t aStream) - : mConnection(aConnection) - , mStream(aStream) {} + DataChannelBlobSendRunnable( + already_AddRefed& aConnection, + uint16_t aStream) + : Runnable("DataChannelBlobSendRunnable") + , mConnection(aConnection) + , mStream(aStream) + { + } ~DataChannelBlobSendRunnable() override { diff --git a/netwerk/sctp/datachannel/DataChannel.h b/netwerk/sctp/datachannel/DataChannel.h index fec16b4060b3..e3616f2b30f0 100644 --- a/netwerk/sctp/datachannel/DataChannel.h +++ b/netwerk/sctp/datachannel/DataChannel.h @@ -467,37 +467,49 @@ public: NO_LONGER_BUFFERED, }; /* types */ - DataChannelOnMessageAvailable(int32_t aType, - DataChannelConnection *aConnection, - DataChannel *aChannel, - nsCString &aData, // XXX this causes inefficiency - int32_t aLen) - : mType(aType), - mChannel(aChannel), - mConnection(aConnection), - mData(aData), - mLen(aLen) {} + DataChannelOnMessageAvailable( + int32_t aType, + DataChannelConnection* aConnection, + DataChannel* aChannel, + nsCString& aData, // XXX this causes inefficiency + int32_t aLen) + : Runnable("DataChannelOnMessageAvailable") + , mType(aType) + , mChannel(aChannel) + , mConnection(aConnection) + , mData(aData) + , mLen(aLen) + { + } - DataChannelOnMessageAvailable(int32_t aType, - DataChannel *aChannel) - : mType(aType), - mChannel(aChannel) {} + DataChannelOnMessageAvailable(int32_t aType, DataChannel* aChannel) + : Runnable("DataChannelOnMessageAvailable") + , mType(aType) + , mChannel(aChannel) + { + } // XXX is it safe to leave mData/mLen uninitialized? This should only be // used for notifications that don't use them, but I'd like more // bulletproof compile-time checking. - DataChannelOnMessageAvailable(int32_t aType, - DataChannelConnection *aConnection, - DataChannel *aChannel) - : mType(aType), - mChannel(aChannel), - mConnection(aConnection) {} + DataChannelOnMessageAvailable(int32_t aType, + DataChannelConnection* aConnection, + DataChannel* aChannel) + : Runnable("DataChannelOnMessageAvailable") + , mType(aType) + , mChannel(aChannel) + , mConnection(aConnection) + { + } // for ON_CONNECTION/ON_DISCONNECTED - DataChannelOnMessageAvailable(int32_t aType, - DataChannelConnection *aConnection) - : mType(aType), - mConnection(aConnection) {} + DataChannelOnMessageAvailable(int32_t aType, + DataChannelConnection* aConnection) + : Runnable("DataChannelOnMessageAvailable") + , mType(aType) + , mConnection(aConnection) + { + } NS_IMETHOD Run() override { diff --git a/netwerk/socket/nsNamedPipeIOLayer.cpp b/netwerk/socket/nsNamedPipeIOLayer.cpp index 400f61fa5ac7..5373d202da6d 100644 --- a/netwerk/socket/nsNamedPipeIOLayer.cpp +++ b/netwerk/socket/nsNamedPipeIOLayer.cpp @@ -211,7 +211,7 @@ NamedPipeInfo::OnDataAvailable(uint32_t aBytesTransferred, mErrorCode = ERROR_SUCCESS; // dispatch an empty event to trigger STS thread - gSocketTransportService->Dispatch(NS_NewRunnableFunction([]{}), + gSocketTransportService->Dispatch(NS_NewRunnableFunction("NamedPipeInfo::OnDataAvailable", []{}), NS_DISPATCH_NORMAL); return NS_OK; @@ -229,7 +229,7 @@ NamedPipeInfo::OnError(uint32_t aError, mErrorCode = aError; // dispatch an empty event to trigger STS thread - gSocketTransportService->Dispatch(NS_NewRunnableFunction([]{}), + gSocketTransportService->Dispatch(NS_NewRunnableFunction("NamedPipeInfo::OnError", []{}), NS_DISPATCH_NORMAL); return NS_OK; diff --git a/netwerk/socket/nsNamedPipeService.cpp b/netwerk/socket/nsNamedPipeService.cpp index 8e72cc8ef02d..d27386300890 100644 --- a/netwerk/socket/nsNamedPipeService.cpp +++ b/netwerk/socket/nsNamedPipeService.cpp @@ -42,7 +42,8 @@ NamedPipeService::Init() // nsIObserverService must be accessed in main thread. // register shutdown event to stop NamedPipeSrv thread. nsCOMPtr self(this); - nsCOMPtr r = NS_NewRunnableFunction([self = Move(self)] () -> void { + nsCOMPtr r = NS_NewRunnableFunction("NamedPipeService::Init", + [self = Move(self)] () -> void { MOZ_ASSERT(NS_IsMainThread()); nsCOMPtr svc = mozilla::services::GetObserverService(); diff --git a/netwerk/system/linux/nsNotifyAddrListener_Linux.h b/netwerk/system/linux/nsNotifyAddrListener_Linux.h index a2b8f2277942..d8150d17ff61 100644 --- a/netwerk/system/linux/nsNotifyAddrListener_Linux.h +++ b/netwerk/system/linux/nsNotifyAddrListener_Linux.h @@ -44,8 +44,11 @@ private: class ChangeEvent : public mozilla::Runnable { public: NS_DECL_NSIRUNNABLE - ChangeEvent(nsINetworkLinkService *aService, const char *aEventID) - : mService(aService), mEventID(aEventID) { + ChangeEvent(nsINetworkLinkService* aService, const char* aEventID) + : mozilla::Runnable("nsNotifyAddrListener::ChangeEvent") + , mService(aService) + , mEventID(aEventID) + { } private: nsCOMPtr mService; diff --git a/netwerk/system/win32/nsNotifyAddrListener.h b/netwerk/system/win32/nsNotifyAddrListener.h index 47a9ed64514a..d2173aea9caa 100644 --- a/netwerk/system/win32/nsNotifyAddrListener.h +++ b/netwerk/system/win32/nsNotifyAddrListener.h @@ -38,8 +38,10 @@ protected: public: NS_DECL_NSIRUNNABLE ChangeEvent(nsINetworkLinkService *aService, const char *aEventID) - : mService(aService), mEventID(aEventID) { - } + : Runnable("nsNotifyAddrListener::ChangeEvent") + , mService(aService) + , mEventID(aEventID) + {} private: nsCOMPtr mService; const char *mEventID; diff --git a/parser/html/nsHtml5StreamParser.cpp b/parser/html/nsHtml5StreamParser.cpp index 5c5fe3965b3b..18215b0b363b 100644 --- a/parser/html/nsHtml5StreamParser.cpp +++ b/parser/html/nsHtml5StreamParser.cpp @@ -1135,12 +1135,12 @@ nsHtml5StreamParser::DoDataAvailable(const uint8_t* aBuffer, uint32_t aLength) { mozilla::MutexAutoLock flushTimerLock(mFlushTimerMutex); - mFlushTimer->InitWithFuncCallback(nsHtml5StreamParser::TimerCallback, - static_cast (this), - mFlushTimerEverFired ? - sTimerInitialDelay : - sTimerSubsequentDelay, - nsITimer::TYPE_ONE_SHOT); + mFlushTimer->InitWithNamedFuncCallback( + nsHtml5StreamParser::TimerCallback, + static_cast(this), + mFlushTimerEverFired ? sTimerInitialDelay : sTimerSubsequentDelay, + nsITimer::TYPE_ONE_SHOT, + "nsHtml5StreamParser::DoDataAvailable"); } mFlushTimerArmed = true; } diff --git a/parser/html/nsHtml5TreeOpExecutor.cpp b/parser/html/nsHtml5TreeOpExecutor.cpp index 860196b31168..df4320a49940 100644 --- a/parser/html/nsHtml5TreeOpExecutor.cpp +++ b/parser/html/nsHtml5TreeOpExecutor.cpp @@ -52,7 +52,8 @@ class nsHtml5ExecutorReflusher : public Runnable RefPtr mExecutor; public: explicit nsHtml5ExecutorReflusher(nsHtml5TreeOpExecutor* aExecutor) - : mExecutor(aExecutor) + : mozilla::Runnable("nsHtml5ExecutorReflusher") + , mExecutor(aExecutor) {} NS_IMETHOD Run() override { @@ -241,7 +242,8 @@ nsHtml5TreeOpExecutor::MarkAsBroken(nsresult aReason) // a safer point. if (mParser) { // can mParser ever be null here? MOZ_ALWAYS_SUCCEEDS( - NS_DispatchToMainThread(NewRunnableMethod(GetParser(), &nsHtml5Parser::Terminate))); + NS_DispatchToMainThread(NewRunnableMethod("nsHtml5Parser::Terminate", + GetParser(), &nsHtml5Parser::Terminate))); } return aReason; } diff --git a/parser/htmlparser/nsParser.cpp b/parser/htmlparser/nsParser.cpp index 7dbbc840487f..0dc9beb3c009 100644 --- a/parser/htmlparser/nsParser.cpp +++ b/parser/htmlparser/nsParser.cpp @@ -110,7 +110,8 @@ public: RefPtr mParser; explicit nsParserContinueEvent(nsParser* aParser) - : mParser(aParser) + : mozilla::Runnable("nsParserContinueEvent") + , mParser(aParser) {} NS_IMETHOD Run() override diff --git a/security/manager/ssl/CryptoTask.h b/security/manager/ssl/CryptoTask.h index ae107fe30748..1d50156b9b3e 100644 --- a/security/manager/ssl/CryptoTask.h +++ b/security/manager/ssl/CryptoTask.h @@ -62,8 +62,9 @@ public: protected: CryptoTask() - : mRv(NS_ERROR_NOT_INITIALIZED), - mReleasedNSSResources(false) + : Runnable("CryptoTask") + , mRv(NS_ERROR_NOT_INITIALIZED) + , mReleasedNSSResources(false) { } diff --git a/security/manager/ssl/DataStorage.cpp b/security/manager/ssl/DataStorage.cpp index 99d26ca32a69..808b2392b518 100644 --- a/security/manager/ssl/DataStorage.cpp +++ b/security/manager/ssl/DataStorage.cpp @@ -329,7 +329,8 @@ class DataStorage::Reader : public Runnable { public: explicit Reader(DataStorage* aDataStorage) - : mDataStorage(aDataStorage) + : Runnable("DataStorage::Reader") + , mDataStorage(aDataStorage) { } ~Reader(); @@ -355,7 +356,8 @@ DataStorage::Reader::~Reader() // This is for tests. nsCOMPtr job = - NewRunnableMethod(mDataStorage, + NewRunnableMethod("DataStorage::NotifyObservers", + mDataStorage, &DataStorage::NotifyObservers, "data-storage-ready"); nsresult rv = NS_DispatchToMainThread(job, NS_DISPATCH_NORMAL); @@ -797,7 +799,8 @@ class DataStorage::Writer : public Runnable { public: Writer(nsCString& aData, DataStorage* aDataStorage) - : mData(aData) + : Runnable("DataStorage::Writer") + , mData(aData) , mDataStorage(aDataStorage) { } @@ -850,7 +853,8 @@ DataStorage::Writer::Run() // Observed by tests. nsCOMPtr job = - NewRunnableMethod(mDataStorage, + NewRunnableMethod("DataStorage::NotifyObservers", + mDataStorage, &DataStorage::NotifyObservers, "data-storage-written"); rv = NS_DispatchToMainThread(job, NS_DISPATCH_NORMAL); @@ -941,7 +945,7 @@ DataStorage::AsyncSetTimer(const MutexAutoLock& /*aProofOfLock*/) mPendingWrite = true; nsCOMPtr job = - NewRunnableMethod(this, &DataStorage::SetTimer); + NewRunnableMethod("DataStorage::SetTimer", this, &DataStorage::SetTimer); nsresult rv = mWorkerThread->Dispatch(job, NS_DISPATCH_NORMAL); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; @@ -965,8 +969,11 @@ DataStorage::SetTimer() } } - rv = mTimer->InitWithFuncCallback(TimerCallback, this, - mTimerDelay, nsITimer::TYPE_ONE_SHOT); + rv = mTimer->InitWithNamedFuncCallback(TimerCallback, + this, + mTimerDelay, + nsITimer::TYPE_ONE_SHOT, + "DataStorage::SetTimer"); Unused << NS_WARN_IF(NS_FAILED(rv)); } @@ -990,8 +997,8 @@ DataStorage::DispatchShutdownTimer(const MutexAutoLock& /*aProofOfLock*/) { MOZ_ASSERT(XRE_IsParentProcess()); - nsCOMPtr job = - NewRunnableMethod(this, &DataStorage::ShutdownTimer); + nsCOMPtr job = NewRunnableMethod( + "DataStorage::ShutdownTimer", 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 d377bcffe0d2..9edbc6bc464b 100644 --- a/security/manager/ssl/PSMContentListener.cpp +++ b/security/manager/ssl/PSMContentListener.cpp @@ -153,7 +153,9 @@ 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 = - NewRunnableMethod(this, &PSMContentStreamListener::ImportCertificate); + NewRunnableMethod("psm::PSMContentStreamListener::ImportCertificate", + this, + &PSMContentStreamListener::ImportCertificate); MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(r)); return NS_OK; diff --git a/security/manager/ssl/PSMRunnable.cpp b/security/manager/ssl/PSMRunnable.cpp index 9f151a83fde7..e83cf960a473 100644 --- a/security/manager/ssl/PSMRunnable.cpp +++ b/security/manager/ssl/PSMRunnable.cpp @@ -7,7 +7,8 @@ namespace mozilla { namespace psm { SyncRunnableBase::SyncRunnableBase() - : monitor("SyncRunnableBase::monitor") + : Runnable("psm::SyncRunnableBase") + , monitor("SyncRunnableBase::monitor") { } diff --git a/security/manager/ssl/PSMRunnable.h b/security/manager/ssl/PSMRunnable.h index 87dada184f18..d8a2fffe039c 100644 --- a/security/manager/ssl/PSMRunnable.h +++ b/security/manager/ssl/PSMRunnable.h @@ -32,7 +32,8 @@ class NotifyObserverRunnable : public Runnable public: NotifyObserverRunnable(nsIObserver * observer, const char * topicStringLiteral) - : mObserver(new nsMainThreadPtrHolder( + : Runnable("psm::NotifyObserverRunnable"), + mObserver(new nsMainThreadPtrHolder( "psm::NotifyObserverRunnable::mObserver", observer)), mTopic(topicStringLiteral) { } diff --git a/security/manager/ssl/SSLServerCertVerification.cpp b/security/manager/ssl/SSLServerCertVerification.cpp index 2304753d141f..9593fac227ef 100644 --- a/security/manager/ssl/SSLServerCertVerification.cpp +++ b/security/manager/ssl/SSLServerCertVerification.cpp @@ -736,7 +736,8 @@ class CertErrorRunnableRunnable : public Runnable { public: explicit CertErrorRunnableRunnable(CertErrorRunnable* certErrorRunnable) - : mCertErrorRunnable(certErrorRunnable) + : Runnable("psm::CertErrorRunnableRunnable") + , mCertErrorRunnable(certErrorRunnable) { } private: @@ -796,12 +797,18 @@ private: }; SSLServerCertVerificationJob::SSLServerCertVerificationJob( - const RefPtr& certVerifier, const void* fdForLogging, - nsNSSSocketInfo* infoObject, const UniqueCERTCertificate& cert, - UniqueCERTCertList peerCertChain, const SECItem* stapledOCSPResponse, - const SECItem* sctsFromTLSExtension, - uint32_t providerFlags, Time time, PRTime prtime) - : mCertVerifier(certVerifier) + const RefPtr& certVerifier, + const void* fdForLogging, + nsNSSSocketInfo* infoObject, + const UniqueCERTCertificate& cert, + UniqueCERTCertList peerCertChain, + const SECItem* stapledOCSPResponse, + const SECItem* sctsFromTLSExtension, + uint32_t providerFlags, + Time time, + PRTime prtime) + : Runnable("psm::SSLServerCertVerificationJob") + , mCertVerifier(certVerifier) , mFdForLogging(fdForLogging) , mInfoObject(infoObject) , mCert(CERT_DupCertificate(cert.get())) @@ -1817,10 +1824,13 @@ AuthCertificateHook(void* arg, PRFileDesc* fd, PRBool checkSig, PRBool isServer) } SSLServerCertVerificationResult::SSLServerCertVerificationResult( - nsNSSSocketInfo* infoObject, PRErrorCode errorCode, - Telemetry::HistogramID telemetryID, uint32_t telemetryValue, - SSLErrorMessageType errorMessageType) - : mInfoObject(infoObject) + nsNSSSocketInfo* infoObject, + PRErrorCode errorCode, + Telemetry::HistogramID telemetryID, + uint32_t telemetryValue, + SSLErrorMessageType errorMessageType) + : Runnable("psm::SSLServerCertVerificationResult") + , mInfoObject(infoObject) , mErrorCode(errorCode) , mErrorMessageType(errorMessageType) , mTelemetryID(telemetryID) diff --git a/security/manager/ssl/nsNSSCallbacks.cpp b/security/manager/ssl/nsNSSCallbacks.cpp index 18f1b2ef0a78..1ec6334b452b 100644 --- a/security/manager/ssl/nsNSSCallbacks.cpp +++ b/security/manager/ssl/nsNSSCallbacks.cpp @@ -68,7 +68,8 @@ public: }; nsHTTPDownloadEvent::nsHTTPDownloadEvent() -:mResponsibleForDoneSignal(true) + : mozilla::Runnable("nsHTTPDownloadEvent") + , mResponsibleForDoneSignal(true) { } @@ -196,6 +197,7 @@ nsHTTPDownloadEvent::Run() struct nsCancelHTTPDownloadEvent : Runnable { RefPtr mListener; + nsCancelHTTPDownloadEvent() : Runnable("nsCancelHTTPDownloadEvent") {} NS_IMETHOD Run() override { mListener->FreeLoadGroup(true); mListener = nullptr; diff --git a/security/manager/ssl/nsNSSComponent.cpp b/security/manager/ssl/nsNSSComponent.cpp index dc5ab78aa27d..8f0619498036 100644 --- a/security/manager/ssl/nsNSSComponent.cpp +++ b/security/manager/ssl/nsNSSComponent.cpp @@ -99,11 +99,12 @@ bool EnsureNSSInitializedChromeOrContent() } // Forward to the main thread synchronously. - mozilla::SyncRunnable::DispatchToThread(mainThread, - new SyncRunnable(NS_NewRunnableFunction([]() { - initialized = EnsureNSSInitializedChromeOrContent(); - })) - ); + mozilla::SyncRunnable::DispatchToThread( + mainThread, + new SyncRunnable( + NS_NewRunnableFunction("EnsureNSSInitializedChromeOrContent", []() { + initialized = EnsureNSSInitializedChromeOrContent(); + }))); return initialized; } diff --git a/security/manager/ssl/nsNSSIOLayer.cpp b/security/manager/ssl/nsNSSIOLayer.cpp index 0c44dc91e3d6..89b82679abb3 100644 --- a/security/manager/ssl/nsNSSIOLayer.cpp +++ b/security/manager/ssl/nsNSSIOLayer.cpp @@ -1730,7 +1730,8 @@ class FallbackPrefRemover final : public Runnable { public: explicit FallbackPrefRemover(const nsACString& aHost) - : mHost(aHost) + : mozilla::Runnable("FallbackPrefRemover") + , mHost(aHost) {} NS_IMETHOD Run() override; private: diff --git a/security/manager/ssl/nsNSSModule.cpp b/security/manager/ssl/nsNSSModule.cpp index de47b4ec829f..321498508095 100644 --- a/security/manager/ssl/nsNSSModule.cpp +++ b/security/manager/ssl/nsNSSModule.cpp @@ -106,11 +106,11 @@ Constructor(nsISupports* aOuter, REFNSIID aIID, void** aResult) } // Forward to the main thread synchronously. - mozilla::SyncRunnable::DispatchToThread(mainThread, - new SyncRunnable(NS_NewRunnableFunction([&]() { + mozilla::SyncRunnable::DispatchToThread( + mainThread, + new SyncRunnable(NS_NewRunnableFunction("psm::Constructor", [&]() { rv = Instantiate(aIID, aResult); - })) - ); + }))); return rv; } diff --git a/security/sandbox/linux/reporter/SandboxReporter.cpp b/security/sandbox/linux/reporter/SandboxReporter.cpp index 8da246b07f18..a9275f00465a 100644 --- a/security/sandbox/linux/reporter/SandboxReporter.cpp +++ b/security/sandbox/linux/reporter/SandboxReporter.cpp @@ -100,9 +100,8 @@ SandboxReporter::Singleton() // by that point (so it won't race by calling Singleton()), all // non-main XPCOM threads will also be shut down, and currently // the only other user is the main-thread-only Troubleshoot.jsm. - NS_DispatchToMainThread(NS_NewRunnableFunction([] { - ClearOnShutdown(&sSingleton); - })); + NS_DispatchToMainThread(NS_NewRunnableFunction( + "SandboxReporter::Singleton", [] { ClearOnShutdown(&sSingleton); })); } return sSingleton.get(); } diff --git a/services/crypto/component/IdentityCryptoService.cpp b/services/crypto/component/IdentityCryptoService.cpp index a4871dfe5079..4b36ad09563e 100644 --- a/services/crypto/component/IdentityCryptoService.cpp +++ b/services/crypto/component/IdentityCryptoService.cpp @@ -325,9 +325,10 @@ KeyPair::Sign(const nsACString & textToSign, } KeyGenRunnable::KeyGenRunnable(KeyType keyType, - nsIIdentityKeyGenCallback * callback, + nsIIdentityKeyGenCallback* callback, nsIEventTarget* operationThread) - : mKeyType(keyType) + : mozilla::Runnable("KeyGenRunnable") + , mKeyType(keyType) , mCallback(new nsMainThreadPtrHolder( "KeyGenRunnable::mCallback", callback)) , mRv(NS_ERROR_NOT_INITIALIZED) @@ -483,10 +484,11 @@ KeyGenRunnable::Run() return NS_OK; } -SignRunnable::SignRunnable(const nsACString & aText, - SECKEYPrivateKey * privateKey, - nsIIdentitySignCallback * aCallback) - : mTextToSign(aText) +SignRunnable::SignRunnable(const nsACString& aText, + SECKEYPrivateKey* privateKey, + nsIIdentitySignCallback* aCallback) + : mozilla::Runnable("SignRunnable") + , mTextToSign(aText) , mPrivateKey(SECKEY_CopyPrivateKey(privateKey)) , mCallback(new nsMainThreadPtrHolder( "SignRunnable::mCallback", aCallback)) diff --git a/storage/StorageBaseStatementInternal.cpp b/storage/StorageBaseStatementInternal.cpp index 69bf3aeb3968..8993a23d551e 100644 --- a/storage/StorageBaseStatementInternal.cpp +++ b/storage/StorageBaseStatementInternal.cpp @@ -35,10 +35,11 @@ public: * on. We release the statement on that thread since releasing the * statement might end up releasing the connection too. */ - AsyncStatementFinalizer(StorageBaseStatementInternal *aStatement, - Connection *aConnection) - : mStatement(aStatement) - , mConnection(aConnection) + AsyncStatementFinalizer(StorageBaseStatementInternal* aStatement, + Connection* aConnection) + : Runnable("storage::AsyncStatementFinalizer") + , mStatement(aStatement) + , mConnection(aConnection) { } @@ -81,10 +82,11 @@ public: * responsibility for the instance and all other references to it * should be forgotten. */ - LastDitchSqliteStatementFinalizer(RefPtr &aConnection, - sqlite3_stmt *aStatement) - : mConnection(aConnection) - , mAsyncStatement(aStatement) + LastDitchSqliteStatementFinalizer(RefPtr& aConnection, + sqlite3_stmt* aStatement) + : Runnable("storage::LastDitchSqliteStatementFinalizer") + , mConnection(aConnection) + , mAsyncStatement(aStatement) { NS_PRECONDITION(aConnection, "You must provide a Connection"); } diff --git a/storage/mozStorageConnection.cpp b/storage/mozStorageConnection.cpp index 903b96adebfe..49571570f118 100644 --- a/storage/mozStorageConnection.cpp +++ b/storage/mozStorageConnection.cpp @@ -378,7 +378,8 @@ public: AsyncCloseConnection(Connection *aConnection, sqlite3 *aNativeConnection, nsIRunnable *aCallbackEvent) - : mConnection(aConnection) + : Runnable("storage::AsyncCloseConnection") + , mConnection(aConnection) , mNativeConnection(aNativeConnection) , mCallbackEvent(aCallbackEvent) { @@ -390,7 +391,8 @@ public: MOZ_ASSERT(NS_GetCurrentThread() != mConnection->threadOpenedOn); nsCOMPtr event = - NewRunnableMethod(mConnection, &Connection::shutdownAsyncThread); + NewRunnableMethod("storage::Connection::shutdownAsyncThread", + mConnection, &Connection::shutdownAsyncThread); MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(event)); // Internal close. @@ -831,7 +833,8 @@ Connection::initializeOnAsyncThread(nsIFile* aStorageFile) { MutexAutoLock lockedScope(sharedAsyncExecutionMutex); mAsyncExecutionThreadShuttingDown = true; nsCOMPtr event = - NewRunnableMethod(this, &Connection::shutdownAsyncThread); + NewRunnableMethod("Connection::shutdownAsyncThread", + this, &Connection::shutdownAsyncThread); Unused << NS_DispatchToMainThread(event); } return rv; diff --git a/storage/mozStoragePrivateHelpers.cpp b/storage/mozStoragePrivateHelpers.cpp index 91924204f107..3c3688583729 100644 --- a/storage/mozStoragePrivateHelpers.cpp +++ b/storage/mozStoragePrivateHelpers.cpp @@ -251,8 +251,9 @@ namespace { class CallbackEvent : public Runnable { public: - explicit CallbackEvent(mozIStorageCompletionCallback *aCallback) - : mCallback(aCallback) + explicit CallbackEvent(mozIStorageCompletionCallback* aCallback) + : Runnable("storage::CallbackEvent") + , mCallback(aCallback) { } diff --git a/storage/mozStorageService.cpp b/storage/mozStorageService.cpp index 7b3d8e738f9c..8ca2ae4806f8 100644 --- a/storage/mozStorageService.cpp +++ b/storage/mozStorageService.cpp @@ -387,6 +387,7 @@ Service::minimizeMemory() // dispatch will fail and that's okay. nsCOMPtr event = NewRunnableMethod( + "Connection::ExecuteSimpleSQL", conn, &Connection::ExecuteSimpleSQL, shrinkPragma); Unused << conn->threadOpenedOn->Dispatch(event, NS_DISPATCH_NORMAL); } @@ -677,7 +678,8 @@ public: nsIFile* aStorageFile, int32_t aGrowthIncrement, mozIStorageCompletionCallback* aCallback) - : mConnection(aConnection) + : Runnable("storage::AsyncInitDatabase") + , mConnection(aConnection) , mStorageFile(aStorageFile) , mGrowthIncrement(aGrowthIncrement) , mCallback(aCallback) diff --git a/storage/test/gtest/storage_test_harness.h b/storage/test/gtest/storage_test_harness.h index b1003f043471..09a01c7f9da5 100644 --- a/storage/test/gtest/storage_test_harness.h +++ b/storage/test/gtest/storage_test_harness.h @@ -299,9 +299,10 @@ void watch_for_mutex_use_on_this_thread() class ThreadWedger : public mozilla::Runnable { public: - explicit ThreadWedger(nsIEventTarget *aTarget) - : mReentrantMonitor("thread wedger") - , unwedged(false) + explicit ThreadWedger(nsIEventTarget* aTarget) + : mozilla::Runnable("ThreadWedger") + , mReentrantMonitor("thread wedger") + , unwedged(false) { aTarget->Dispatch(this, aTarget->NS_DISPATCH_NORMAL); } diff --git a/storage/test/gtest/test_service_init_background_thread.cpp b/storage/test/gtest/test_service_init_background_thread.cpp index e811e249702b..5a2c1b5ae92a 100644 --- a/storage/test/gtest/test_service_init_background_thread.cpp +++ b/storage/test/gtest/test_service_init_background_thread.cpp @@ -19,6 +19,7 @@ class ServiceInitializer : public mozilla::Runnable { public: + ServiceInitializer() : mozilla::Runnable("ServiceInitializer") {} NS_IMETHOD Run() override { // Use an explicit do_GetService instead of getService so that the check in diff --git a/storage/test/gtest/test_spinningSynchronousClose.cpp b/storage/test/gtest/test_spinningSynchronousClose.cpp index 1e8d599b33e7..5d7c27544da6 100644 --- a/storage/test/gtest/test_spinningSynchronousClose.cpp +++ b/storage/test/gtest/test_spinningSynchronousClose.cpp @@ -21,7 +21,8 @@ class CompletionRunnable final : public Runnable { public: explicit CompletionRunnable() - : mDone(false) + : Runnable("CompletionRunnable") + , mDone(false) { } diff --git a/storage/test/gtest/test_unlock_notify.cpp b/storage/test/gtest/test_unlock_notify.cpp index d108f3b16a09..b5a4529cd614 100644 --- a/storage/test/gtest/test_unlock_notify.cpp +++ b/storage/test/gtest/test_unlock_notify.cpp @@ -29,9 +29,10 @@ class DatabaseLocker : public mozilla::Runnable { public: explicit DatabaseLocker(const char* aSQL) - : monitor("DatabaseLocker::monitor") - , mSQL(aSQL) - , mState(STARTING) + : mozilla::Runnable("DatabaseLocker") + , monitor("DatabaseLocker::monitor") + , mSQL(aSQL) + , mState(STARTING) { } diff --git a/toolkit/components/filewatcher/NativeFileWatcherWin.cpp b/toolkit/components/filewatcher/NativeFileWatcherWin.cpp index 96be46eaef5c..faf166eff662 100644 --- a/toolkit/components/filewatcher/NativeFileWatcherWin.cpp +++ b/toolkit/components/filewatcher/NativeFileWatcherWin.cpp @@ -37,7 +37,8 @@ public: */ WatchedErrorEvent(const nsMainThreadPtrHandle& aOnError, const nsresult& anError, const DWORD& osError) - : mOnError(aOnError) + : Runnable("WatchedErrorEvent") + , mOnError(aOnError) , mError(anError) { MOZ_ASSERT(!NS_IsMainThread()); @@ -75,7 +76,8 @@ public: */ WatchedSuccessEvent(const nsMainThreadPtrHandle& aOnSuccess, const nsAString& aResourcePath) - : mOnSuccess(aOnSuccess) + : Runnable("WatchedSuccessEvent") + , mOnSuccess(aOnSuccess) , mResourcePath(aResourcePath) { MOZ_ASSERT(!NS_IsMainThread()); @@ -112,7 +114,8 @@ public: */ WatchedChangeEvent(const nsMainThreadPtrHandle& aOnChange, const nsAString& aChangedResource) - : mOnChange(aOnChange) + : Runnable("WatchedChangeEvent") + , mOnChange(aOnChange) , mChangedResource(aChangedResource) { MOZ_ASSERT(!NS_IsMainThread()); @@ -228,7 +231,8 @@ class NativeWatcherIOShutdownTask : public Runnable { public: NativeWatcherIOShutdownTask() - : mWorkerThread(do_GetCurrentThread()) + : Runnable("NativeWatcherIOShutdownTask") + , mWorkerThread(do_GetCurrentThread()) { MOZ_ASSERT(!NS_IsMainThread()); } @@ -259,7 +263,8 @@ class NativeFileWatcherIOTask : public Runnable { public: explicit NativeFileWatcherIOTask(HANDLE aIOCompletionPort) - : mIOCompletionPort(aIOCompletionPort) + : Runnable("NativeFileWatcherIOTask") + , mIOCompletionPort(aIOCompletionPort) , mShuttingDown(false) { } @@ -1324,6 +1329,7 @@ NativeFileWatcherService::AddPath(const nsAString& aPathToWatch, nsresult rv = mIOThread->Dispatch( NewRunnableMethod( + "NativeFileWatcherIOTask::AddPathRunnableMethod", static_cast(mWorkerIORunnable.get()), &NativeFileWatcherIOTask::AddPathRunnableMethod, wrappedCallbacks.get()), @@ -1397,6 +1403,7 @@ NativeFileWatcherService::RemovePath(const nsAString& aPathToRemove, nsresult rv = mIOThread->Dispatch( NewRunnableMethod( + "NativeFileWatcherIOTask::RemovePathRunnableMethod", static_cast(mWorkerIORunnable.get()), &NativeFileWatcherIOTask::RemovePathRunnableMethod, wrappedCallbacks.get()), @@ -1446,6 +1453,7 @@ NativeFileWatcherService::Uninit() nsresult rv = ioThread->Dispatch( NewRunnableMethod( + "NativeFileWatcherIOTask::DeactivateRunnableMethod", static_cast(mWorkerIORunnable.get()), &NativeFileWatcherIOTask::DeactivateRunnableMethod), nsIEventTarget::DISPATCH_NORMAL); diff --git a/toolkit/components/osfile/NativeOSFileInternals.cpp b/toolkit/components/osfile/NativeOSFileInternals.cpp index c671cfeae309..63003e3acf1a 100644 --- a/toolkit/components/osfile/NativeOSFileInternals.cpp +++ b/toolkit/components/osfile/NativeOSFileInternals.cpp @@ -411,13 +411,14 @@ public: already_AddRefed& aDiscardedResult, const nsACString& aOperation, int32_t aOSError) - : mOnSuccess(aOnSuccess) + : Runnable("ErrorEvent") + , mOnSuccess(aOnSuccess) , mOnError(aOnError) , mDiscardedResult(aDiscardedResult) , mOSError(aOSError) , mOperation(aOperation) - { - MOZ_ASSERT(!NS_IsMainThread()); + { + MOZ_ASSERT(!NS_IsMainThread()); } NS_IMETHOD Run() override { @@ -460,14 +461,16 @@ public: * we do not manipulate xpconnect refcounters off the main thread * (which is illegal). */ - SuccessEvent(nsMainThreadPtrHandle& aOnSuccess, - nsMainThreadPtrHandle& aOnError, - already_AddRefed& aResult) - : mOnSuccess(aOnSuccess) + SuccessEvent( + nsMainThreadPtrHandle& aOnSuccess, + nsMainThreadPtrHandle& aOnError, + already_AddRefed& aResult) + : Runnable("SuccessEvent") + , mOnSuccess(aOnSuccess) , mOnError(aOnError) , mResult(aResult) - { - MOZ_ASSERT(!NS_IsMainThread()); + { + MOZ_ASSERT(!NS_IsMainThread()); } NS_IMETHOD Run() override { @@ -500,9 +503,11 @@ public: */ class AbstractDoEvent: public Runnable { public: - AbstractDoEvent(nsMainThreadPtrHandle& aOnSuccess, - nsMainThreadPtrHandle& aOnError) - : mOnSuccess(aOnSuccess) + AbstractDoEvent( + nsMainThreadPtrHandle& aOnSuccess, + nsMainThreadPtrHandle& aOnError) + : Runnable("AbstractDoEvent") + , mOnSuccess(aOnSuccess) , mOnError(aOnError) #if defined(DEBUG) , mResolved(false) diff --git a/toolkit/components/places/FaviconHelpers.cpp b/toolkit/components/places/FaviconHelpers.cpp index b34267fd88eb..2960e2f0fac8 100644 --- a/toolkit/components/places/FaviconHelpers.cpp +++ b/toolkit/components/places/FaviconHelpers.cpp @@ -504,7 +504,8 @@ AsyncFetchAndSetIconForPage::AsyncFetchAndSetIconForPage( , bool aFaviconLoadPrivate , nsIFaviconDataCallback* aCallback , nsIPrincipal* aLoadingPrincipal -) : mCallback(new nsMainThreadPtrHolder( +) : Runnable("places::AsyncFetchAndSetIconForPage") + , mCallback(new nsMainThreadPtrHolder( "AsyncFetchAndSetIconForPage::mCallback", aCallback)) , mIcon(aIcon) , mPage(aPage) @@ -543,7 +544,9 @@ 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 = - NewRunnableMethod(this, &AsyncFetchAndSetIconForPage::FetchFromNetwork); + NewRunnableMethod("places::AsyncFetchAndSetIconForPage::FetchFromNetwork", + this, + &AsyncFetchAndSetIconForPage::FetchFromNetwork); return NS_DispatchToMainThread(event); } @@ -786,10 +789,11 @@ AsyncFetchAndSetIconForPage::OnStopRequest(nsIRequest* aRequest, //// AsyncAssociateIconToPage AsyncAssociateIconToPage::AsyncAssociateIconToPage( - const IconData& aIcon -, const PageData& aPage -, const nsMainThreadPtrHandle& aCallback -) : mCallback(aCallback) + const IconData& aIcon, + const PageData& aPage, + const nsMainThreadPtrHandle& aCallback) + : Runnable("places::AsyncAssociateIconToPage") + , mCallback(aCallback) , mIcon(aIcon) , mPage(aPage) { @@ -938,7 +942,8 @@ AsyncGetFaviconURLForPage::AsyncGetFaviconURLForPage( , const nsACString& aPageHost , uint16_t aPreferredWidth , nsIFaviconDataCallback* aCallback -) : mPreferredWidth(aPreferredWidth == 0 ? UINT16_MAX : aPreferredWidth) +) : Runnable("places::AsyncGetFaviconURLForPage") + , mPreferredWidth(aPreferredWidth == 0 ? UINT16_MAX : aPreferredWidth) , mCallback(new nsMainThreadPtrHolder( "AsyncGetFaviconURLForPage::mCallback", aCallback)) { @@ -978,7 +983,8 @@ AsyncGetFaviconDataForPage::AsyncGetFaviconDataForPage( , const nsACString& aPageHost , uint16_t aPreferredWidth , nsIFaviconDataCallback* aCallback -) : mPreferredWidth(aPreferredWidth == 0 ? UINT16_MAX : aPreferredWidth) +) : Runnable("places::AsyncGetFaviconDataForPage") + , mPreferredWidth(aPreferredWidth == 0 ? UINT16_MAX : aPreferredWidth) , mCallback(new nsMainThreadPtrHolder( "AsyncGetFaviconDataForPage::mCallback", aCallback)) { @@ -1018,8 +1024,9 @@ AsyncGetFaviconDataForPage::Run() //////////////////////////////////////////////////////////////////////////////// //// AsyncReplaceFaviconData -AsyncReplaceFaviconData::AsyncReplaceFaviconData(const IconData &aIcon) - : mIcon(aIcon) +AsyncReplaceFaviconData::AsyncReplaceFaviconData(const IconData& aIcon) + : Runnable("places::AsyncReplaceFaviconData") + , mIcon(aIcon) { MOZ_ASSERT(NS_IsMainThread()); } @@ -1044,8 +1051,10 @@ AsyncReplaceFaviconData::Run() NS_ENSURE_SUCCESS(rv, rv); // We can invalidate the cache version since we now persist the icon. - nsCOMPtr event = - NewRunnableMethod(this, &AsyncReplaceFaviconData::RemoveIconDataCacheEntry); + nsCOMPtr event = NewRunnableMethod( + "places::AsyncReplaceFaviconData::RemoveIconDataCacheEntry", + this, + &AsyncReplaceFaviconData::RemoveIconDataCacheEntry); rv = NS_DispatchToMainThread(event); NS_ENSURE_SUCCESS(rv, rv); @@ -1073,13 +1082,13 @@ AsyncReplaceFaviconData::RemoveIconDataCacheEntry() //// NotifyIconObservers NotifyIconObservers::NotifyIconObservers( - const IconData& aIcon -, const PageData& aPage -, const nsMainThreadPtrHandle& aCallback -) -: mCallback(aCallback) -, mIcon(aIcon) -, mPage(aPage) + const IconData& aIcon, + const PageData& aPage, + const nsMainThreadPtrHandle& aCallback) + : Runnable("places::NotifyIconObservers") + , mCallback(aCallback) + , mIcon(aIcon) + , mPage(aPage) { } @@ -1150,9 +1159,10 @@ NotifyIconObservers::SendGlobalNotifications(nsIURI* aIconURI) //////////////////////////////////////////////////////////////////////////////// //// FetchAndConvertUnsupportedPayloads -FetchAndConvertUnsupportedPayloads::FetchAndConvertUnsupportedPayloads ( - mozIStorageConnection* aDBConn -) : mDB(aDBConn) +FetchAndConvertUnsupportedPayloads::FetchAndConvertUnsupportedPayloads( + mozIStorageConnection* aDBConn) + : Runnable("places::FetchAndConvertUnsupportedPayloads") + , mDB(aDBConn) { } @@ -1381,11 +1391,11 @@ FetchAndConvertUnsupportedPayloads::StorePayload(int64_t aId, //////////////////////////////////////////////////////////////////////////////// //// AsyncCopyFavicons -AsyncCopyFavicons::AsyncCopyFavicons( - PageData& aFromPage -, PageData& aToPage -, nsIFaviconDataCallback* aCallback -) : mFromPage(aFromPage) +AsyncCopyFavicons::AsyncCopyFavicons(PageData& aFromPage, + PageData& aToPage, + nsIFaviconDataCallback* aCallback) + : Runnable("places::AsyncCopyFavicons") + , mFromPage(aFromPage) , mToPage(aToPage) , mCallback(new nsMainThreadPtrHolder( "AsyncCopyFavicons::mCallback", aCallback)) diff --git a/toolkit/components/places/Helpers.cpp b/toolkit/components/places/Helpers.cpp index 33aa89e88f06..39580041382a 100644 --- a/toolkit/components/places/Helpers.cpp +++ b/toolkit/components/places/Helpers.cpp @@ -321,7 +321,8 @@ GetHiddenState(bool aIsRedirect, //// PlacesEvent PlacesEvent::PlacesEvent(const char* aTopic) -: mTopic(aTopic) + : Runnable("places::PlacesEvent") + , mTopic(aTopic) { } diff --git a/toolkit/components/places/Helpers.h b/toolkit/components/places/Helpers.h index 854105f94004..514d679d9e82 100644 --- a/toolkit/components/places/Helpers.h +++ b/toolkit/components/places/Helpers.h @@ -193,11 +193,11 @@ public: */ FinalizeStatementCacheProxy( mozilla::storage::StatementCache& aStatementCache, - nsISupports* aOwner - ) - : mStatementCache(aStatementCache) - , mOwner(aOwner) - , mCallingThread(do_GetCurrentThread()) + nsISupports* aOwner) + : Runnable("places::FinalizeStatementCacheProxy") + , mStatementCache(aStatementCache) + , mOwner(aOwner) + , mCallingThread(do_GetCurrentThread()) { } diff --git a/toolkit/components/places/History.cpp b/toolkit/components/places/History.cpp index 3410e75e89e0..04f1b1d4cc5d 100644 --- a/toolkit/components/places/History.cpp +++ b/toolkit/components/places/History.cpp @@ -503,7 +503,10 @@ 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. - NS_DispatchToMainThread(NewRunnableMethod(cb, &VisitedQuery::NotifyVisitedStatus)); + NS_DispatchToMainThread( + NewRunnableMethod("places::VisitedQuery::NotifyVisitedStatus", + cb, + &VisitedQuery::NotifyVisitedStatus)); return NS_OK; } @@ -623,8 +626,9 @@ class NotifyVisitObservers : public Runnable { public: explicit NotifyVisitObservers(VisitData& aPlace) - : mPlace(aPlace) - , mHistory(History::GetService()) + : Runnable("places::NotifyVisitObservers") + , mPlace(aPlace) + , mHistory(History::GetService()) { } @@ -700,9 +704,10 @@ public: NotifyTitleObservers(const nsCString& aSpec, const nsString& aTitle, const nsCString& aGUID) - : mSpec(aSpec) - , mTitle(aTitle) - , mGUID(aGUID) + : Runnable("places::NotifyTitleObservers") + , mSpec(aSpec) + , mTitle(aTitle) + , mGUID(aGUID) { } @@ -735,14 +740,16 @@ private: class NotifyPlaceInfoCallback : public Runnable { public: - NotifyPlaceInfoCallback(const nsMainThreadPtrHandle& aCallback, - const VisitData& aPlace, - bool aIsSingleVisit, - nsresult aResult) - : mCallback(aCallback) - , mPlace(aPlace) - , mResult(aResult) - , mIsSingleVisit(aIsSingleVisit) + NotifyPlaceInfoCallback( + const nsMainThreadPtrHandle& aCallback, + const VisitData& aPlace, + bool aIsSingleVisit, + nsresult aResult) + : Runnable("places::NotifyPlaceInfoCallback") + , mCallback(aCallback) + , mPlace(aPlace) + , mResult(aResult) + , mIsSingleVisit(aIsSingleVisit) { MOZ_ASSERT(aCallback, "Must pass a non-null callback!"); } @@ -805,10 +812,12 @@ private: class NotifyCompletion : public Runnable { public: - explicit NotifyCompletion(const nsMainThreadPtrHandle& aCallback, - uint32_t aUpdatedCount = 0) - : mCallback(aCallback) - , mUpdatedCount(aUpdatedCount) + explicit NotifyCompletion( + const nsMainThreadPtrHandle& aCallback, + uint32_t aUpdatedCount = 0) + : Runnable("places::NotifyCompletion") + , mCallback(aCallback) + , mUpdatedCount(aUpdatedCount) { MOZ_ASSERT(aCallback, "Must pass a non-null callback!"); } @@ -874,7 +883,10 @@ CanAddURI(nsIURI* aURI, class NotifyManyFrecenciesChanged final : public Runnable { public: - NotifyManyFrecenciesChanged() {} + NotifyManyFrecenciesChanged() + : Runnable("places::NotifyManyFrecenciesChanged") + { + } NS_IMETHOD Run() override { @@ -1063,20 +1075,22 @@ public: return NS_OK; } private: - InsertVisitedURIs(mozIStorageConnection* aConnection, - nsTArray& aPlaces, - const nsMainThreadPtrHandle& aCallback, - bool aGroupNotifications, - bool aIgnoreErrors, - bool aIgnoreResults, - uint32_t aInitialUpdatedCount) - : mDBConn(aConnection) - , mCallback(aCallback) - , mGroupNotifications(aGroupNotifications) - , mIgnoreErrors(aIgnoreErrors) - , mIgnoreResults(aIgnoreResults) - , mSuccessfulUpdatedCount(aInitialUpdatedCount) - , mHistory(History::GetService()) + InsertVisitedURIs( + mozIStorageConnection* aConnection, + nsTArray& aPlaces, + const nsMainThreadPtrHandle& aCallback, + bool aGroupNotifications, + bool aIgnoreErrors, + bool aIgnoreResults, + uint32_t aInitialUpdatedCount) + : Runnable("places::InsertVisitedURIs") + , mDBConn(aConnection) + , mCallback(aCallback) + , mGroupNotifications(aGroupNotifications) + , mIgnoreErrors(aIgnoreErrors) + , mIgnoreResults(aIgnoreResults) + , mSuccessfulUpdatedCount(aInitialUpdatedCount) + , mHistory(History::GetService()) { MOZ_ASSERT(NS_IsMainThread(), "This should be called on the main thread"); @@ -1400,9 +1414,9 @@ public: } private: - SetPageTitle(const nsCString& aSpec, - const nsAString& aTitle) - : mHistory(History::GetService()) + SetPageTitle(const nsCString& aSpec, const nsAString& aTitle) + : Runnable("places::SetPageTitle") + , mHistory(History::GetService()) { mPlace.spec = aSpec; mPlace.title = aTitle; @@ -1531,9 +1545,9 @@ NS_IMPL_ISUPPORTS( class NotifyRemoveVisits : public Runnable { public: - explicit NotifyRemoveVisits(nsTHashtable& aPlaces) - : mPlaces(VISITS_REMOVAL_INITIAL_HASH_LENGTH) + : Runnable("places::NotifyRemoveVisits") + , mPlaces(VISITS_REMOVAL_INITIAL_HASH_LENGTH) , mHistory(History::GetService()) { MOZ_ASSERT(!NS_IsMainThread(), @@ -1680,11 +1694,11 @@ public: } private: - RemoveVisits(mozIStorageConnection* aConnection, - RemoveVisitsFilter& aFilter) - : mDBConn(aConnection) - , mHasTransitionType(false) - , mHistory(History::GetService()) + RemoveVisits(mozIStorageConnection* aConnection, RemoveVisitsFilter& aFilter) + : Runnable("places::RemoveVisits") + , mDBConn(aConnection) + , mHasTransitionType(false) + , mHistory(History::GetService()) { MOZ_ASSERT(NS_IsMainThread(), "This should be called on the main thread"); diff --git a/toolkit/components/places/nsNavHistory.cpp b/toolkit/components/places/nsNavHistory.cpp index edf37a7ea3c4..3693c1512ab9 100644 --- a/toolkit/components/places/nsNavHistory.cpp +++ b/toolkit/components/places/nsNavHistory.cpp @@ -564,7 +564,8 @@ public: const nsACString& aGUID, bool aHidden, PRTime aLastVisitDate) - : mSpec(aSpec) + : mozilla::Runnable("FrecencyNotification") + , mSpec(aSpec) , mNewFrecency(aNewFrecency) , mGUID(aGUID) , mHidden(aHidden) @@ -675,9 +676,11 @@ nsNavHistory::GetNow() if (!mExpireNowTimer) mExpireNowTimer = do_CreateInstance("@mozilla.org/timer;1"); if (mExpireNowTimer) - mExpireNowTimer->InitWithFuncCallback(expireNowTimerCallback, this, - RENEW_CACHED_NOW_TIMEOUT, - nsITimer::TYPE_ONE_SHOT); + mExpireNowTimer->InitWithNamedFuncCallback(expireNowTimerCallback, + this, + RENEW_CACHED_NOW_TIMEOUT, + nsITimer::TYPE_ONE_SHOT, + "nsNavHistory::GetNow"); } return mCachedNow; } diff --git a/toolkit/components/places/tests/gtest/places_test_harness_tail.h b/toolkit/components/places/tests/gtest/places_test_harness_tail.h index fc363cb6a734..a6e3e0c54963 100644 --- a/toolkit/components/places/tests/gtest/places_test_harness_tail.h +++ b/toolkit/components/places/tests/gtest/places_test_harness_tail.h @@ -21,6 +21,7 @@ int gTestsIndex = 0; class RunNextTest : public mozilla::Runnable { public: + RunNextTest() : mozilla::Runnable("RunNextTest") {} NS_IMETHOD Run() override { NS_ASSERTION(NS_IsMainThread(), "Not running on the main thread?"); diff --git a/toolkit/components/satchel/nsFormFillController.cpp b/toolkit/components/satchel/nsFormFillController.cpp index b613e86a5c20..f277cce17ff2 100644 --- a/toolkit/components/satchel/nsFormFillController.cpp +++ b/toolkit/components/satchel/nsFormFillController.cpp @@ -149,8 +149,11 @@ 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 = - mozilla::NewRunnableMethod> - (this, &nsFormFillController::MaybeStartControllingInput, focusedInput); + mozilla::NewRunnableMethod>( + "nsFormFillController::MaybeStartControllingInput", + this, + &nsFormFillController::MaybeStartControllingInput, + focusedInput); NS_DispatchToCurrentThread(event); } diff --git a/toolkit/components/startup/nsAppStartup.cpp b/toolkit/components/startup/nsAppStartup.cpp index e824e91dedaf..75b418754773 100644 --- a/toolkit/components/startup/nsAppStartup.cpp +++ b/toolkit/components/startup/nsAppStartup.cpp @@ -103,7 +103,11 @@ private: RefPtr mService; public: - explicit nsAppExitEvent(nsAppStartup *service) : mService(service) {} + explicit nsAppExitEvent(nsAppStartup* service) + : mozilla::Runnable("nsAppExitEvent") + , mService(service) + { + } NS_IMETHOD Run() override { // Tell the appshell to exit diff --git a/toolkit/components/telemetry/Telemetry.cpp b/toolkit/components/telemetry/Telemetry.cpp index 0694633f0263..4f340facc3c1 100644 --- a/toolkit/components/telemetry/Telemetry.cpp +++ b/toolkit/components/telemetry/Telemetry.cpp @@ -553,10 +553,11 @@ public: nsFetchTelemetryData(const char* aShutdownTimeFilename, nsIFile* aFailedProfileLockFile, nsIFile* aProfileDir) - : mShutdownTimeFilename(aShutdownTimeFilename), - mFailedProfileLockFile(aFailedProfileLockFile), - mTelemetry(TelemetryImpl::sTelemetry), - mProfileDir(aProfileDir) + : mozilla::Runnable("nsFetchTelemetryData") + , mShutdownTimeFilename(aShutdownTimeFilename) + , mFailedProfileLockFile(aFailedProfileLockFile) + , mTelemetry(TelemetryImpl::sTelemetry) + , mProfileDir(aProfileDir) { } @@ -581,7 +582,9 @@ public: ReadLastShutdownDuration(mShutdownTimeFilename); mTelemetry->ReadLateWritesStacks(mProfileDir); nsCOMPtr e = - NewRunnableMethod(this, &nsFetchTelemetryData::MainThread); + NewRunnableMethod("nsFetchTelemetryData::MainThread", + this, + &nsFetchTelemetryData::MainThread); NS_ENSURE_STATE(e); NS_DispatchToMainThread(e); return NS_OK; @@ -1056,8 +1059,10 @@ class GetLoadedModulesResultRunnable final : public Runnable nsCOMPtr mWorkerThread; public: - GetLoadedModulesResultRunnable(const nsMainThreadPtrHandle& aPromise, const SharedLibraryInfo& rawModules) - : mPromise(aPromise) + GetLoadedModulesResultRunnable(const nsMainThreadPtrHandle& aPromise, + const SharedLibraryInfo& rawModules) + : mozilla::Runnable("GetLoadedModulesResultRunnable") + , mPromise(aPromise) , mRawModules(rawModules) , mWorkerThread(do_GetCurrentThread()) { @@ -1175,8 +1180,10 @@ class GetLoadedModulesRunnable final : public Runnable nsMainThreadPtrHandle mPromise; public: - explicit GetLoadedModulesRunnable(const nsMainThreadPtrHandle& aPromise) - : mPromise(aPromise) + explicit GetLoadedModulesRunnable( + const nsMainThreadPtrHandle& aPromise) + : mozilla::Runnable("GetLoadedModulesRunnable") + , mPromise(aPromise) { } NS_IMETHOD diff --git a/toolkit/components/telemetry/TelemetryCommon.cpp b/toolkit/components/telemetry/TelemetryCommon.cpp index 5d813c601aaa..77fdf77a6d51 100644 --- a/toolkit/components/telemetry/TelemetryCommon.cpp +++ b/toolkit/components/telemetry/TelemetryCommon.cpp @@ -102,8 +102,9 @@ LogToBrowserConsole(uint32_t aLogLevel, const nsAString& aMsg) { if (!NS_IsMainThread()) { nsString msg(aMsg); - nsCOMPtr task = - NS_NewRunnableFunction([aLogLevel, msg]() { LogToBrowserConsole(aLogLevel, msg); }); + nsCOMPtr task = NS_NewRunnableFunction( + "Telemetry::Common::LogToBrowserConsole", + [aLogLevel, msg]() { LogToBrowserConsole(aLogLevel, msg); }); NS_DispatchToMainThread(task.forget(), NS_DISPATCH_NORMAL); return; } diff --git a/toolkit/components/telemetry/tests/gtest/TestScalars.cpp b/toolkit/components/telemetry/tests/gtest/TestScalars.cpp index 1ce7fb758a6e..1efed54069c9 100644 --- a/toolkit/components/telemetry/tests/gtest/TestScalars.cpp +++ b/toolkit/components/telemetry/tests/gtest/TestScalars.cpp @@ -301,9 +301,11 @@ TEST_F(TelemetryTestFixture, NonMainThreadAdd) { Unused << mTelemetry->ClearScalars(); // Define the function that will be called on the testing thread. - nsCOMPtr runnable = NS_NewRunnableFunction([]() -> void { - Telemetry::ScalarAdd(Telemetry::ScalarID::TELEMETRY_TEST_UNSIGNED_INT_KIND, 37); - }); + nsCOMPtr runnable = NS_NewRunnableFunction( + "TelemetryTestFixture_NonMainThreadAdd_Test::TestBody", []() -> void { + Telemetry::ScalarAdd( + Telemetry::ScalarID::TELEMETRY_TEST_UNSIGNED_INT_KIND, 37); + }); // Spawn the testing thread and run the function. nsCOMPtr testingThread; diff --git a/toolkit/components/url-classifier/Classifier.cpp b/toolkit/components/url-classifier/Classifier.cpp index 1ee35dd593d3..aaa53dd84886 100644 --- a/toolkit/components/url-classifier/Classifier.cpp +++ b/toolkit/components/url-classifier/Classifier.cpp @@ -302,7 +302,8 @@ Classifier::Reset() return; } - nsCOMPtr r = NS_NewRunnableFunction(resetFunc); + nsCOMPtr r = + NS_NewRunnableFunction("safebrowsing::Classifier::Reset", resetFunc); SyncRunnable::DispatchToThread(mUpdateThread, r); } @@ -738,25 +739,30 @@ Classifier::AsyncApplyUpdates(nsTArray* aUpdates, nsCOMPtr callerThread = NS_GetCurrentThread(); MOZ_ASSERT(callerThread != mUpdateThread); - nsCOMPtr bgRunnable = NS_NewRunnableFunction([=] { - MOZ_ASSERT(NS_GetCurrentThread() == mUpdateThread, "MUST be on update thread"); + nsCOMPtr bgRunnable = + NS_NewRunnableFunction("safebrowsing::Classifier::AsyncApplyUpdates", [=] { + MOZ_ASSERT(NS_GetCurrentThread() == mUpdateThread, + "MUST be on update thread"); - LOG(("Step 1. ApplyUpdatesBackground on update thread.")); - nsCString failedTableName; - nsresult bgRv = ApplyUpdatesBackground(aUpdates, failedTableName); + LOG(("Step 1. ApplyUpdatesBackground on update thread.")); + nsCString failedTableName; + nsresult bgRv = ApplyUpdatesBackground(aUpdates, failedTableName); - nsCOMPtr fgRunnable = NS_NewRunnableFunction([=] { - MOZ_ASSERT(NS_GetCurrentThread() == callerThread, "MUST be on caller thread"); + nsCOMPtr fgRunnable = NS_NewRunnableFunction( + "safebrowsing::Classifier::AsyncApplyUpdates", [=] { + MOZ_ASSERT(NS_GetCurrentThread() == callerThread, + "MUST be on caller thread"); - LOG(("Step 2. ApplyUpdatesForeground on caller thread")); - nsresult rv = ApplyUpdatesForeground(bgRv, failedTableName);; + LOG(("Step 2. ApplyUpdatesForeground on caller thread")); + nsresult rv = ApplyUpdatesForeground(bgRv, failedTableName); + ; - LOG(("Step 3. Updates applied! Fire callback.")); + LOG(("Step 3. Updates applied! Fire callback.")); - aCallback(rv); + aCallback(rv); + }); + callerThread->Dispatch(fgRunnable, NS_DISPATCH_NORMAL); }); - callerThread->Dispatch(fgRunnable, NS_DISPATCH_NORMAL); - }); return mUpdateThread->Dispatch(bgRunnable, NS_DISPATCH_NORMAL); } diff --git a/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp b/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp index aad5fcbcb469..398929dc7b51 100644 --- a/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp +++ b/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp @@ -1830,39 +1830,41 @@ nsUrlClassifierDBService::AsyncClassifyLocalWithTables(nsIURI *aURI, new nsMainThreadPtrHolder( "nsIURIClassifierCallback", aCallback)); - nsCOMPtr r = - NS_NewRunnableFunction([worker, key, tables, callback, startTime] () -> void { + nsCOMPtr r = NS_NewRunnableFunction( + "nsUrlClassifierDBService::AsyncClassifyLocalWithTables", + [worker, key, tables, callback, startTime]() -> void { - nsCString matchedLists; - nsAutoPtr results(new LookupResultArray()); - if (results) { - nsresult rv = worker->DoLocalLookup(key, tables, results); - if (NS_SUCCEEDED(rv)) { - for (uint32_t i = 0; i < results->Length(); i++) { - if (i > 0) { - matchedLists.AppendLiteral(","); + nsCString matchedLists; + nsAutoPtr results(new LookupResultArray()); + if (results) { + nsresult rv = worker->DoLocalLookup(key, tables, results); + if (NS_SUCCEEDED(rv)) { + for (uint32_t i = 0; i < results->Length(); i++) { + if (i > 0) { + matchedLists.AppendLiteral(","); + } + matchedLists.Append(results->ElementAt(i).mTableName); } - matchedLists.Append(results->ElementAt(i).mTableName); } } - } - nsCOMPtr cbRunnable = - NS_NewRunnableFunction([callback, matchedLists, startTime] () -> void { - // Measure the time diff between calling and callback. - AccumulateDelta_impl::compute( - Telemetry::URLCLASSIFIER_ASYNC_CLASSIFYLOCAL_TIME, startTime); + nsCOMPtr cbRunnable = NS_NewRunnableFunction( + "nsUrlClassifierDBService::AsyncClassifyLocalWithTables", + [callback, matchedLists, startTime]() -> void { + // Measure the time diff between calling and callback. + AccumulateDelta_impl::compute( + Telemetry::URLCLASSIFIER_ASYNC_CLASSIFYLOCAL_TIME, startTime); - // |callback| is captured as const value so ... - auto cb = const_cast(callback.get()); - cb->OnClassifyComplete(NS_OK, // Not used. - matchedLists, - EmptyCString(), // provider. (Not used) - EmptyCString()); // prefix. (Not used) - }); + // |callback| is captured as const value so ... + auto cb = const_cast(callback.get()); + cb->OnClassifyComplete(NS_OK, // Not used. + matchedLists, + EmptyCString(), // provider. (Not used) + EmptyCString()); // prefix. (Not used) + }); - NS_DispatchToMainThread(cbRunnable); - }); + NS_DispatchToMainThread(cbRunnable); + }); return gDbBackgroundThread->Dispatch(r, NS_DISPATCH_NORMAL); } @@ -2266,8 +2268,10 @@ nsUrlClassifierDBService::Shutdown() // between main thread and the worker thread. (Both threads // would access Classifier::mUpdateThread.) using Worker = nsUrlClassifierDBServiceWorker; - RefPtr r = - NewRunnableMethod(mWorker, &Worker::FlushAndDisableAsyncUpdate); + RefPtr r = NewRunnableMethod( + "nsUrlClassifierDBServiceWorker::FlushAndDisableAsyncUpdate", + mWorker, + &Worker::FlushAndDisableAsyncUpdate); SyncRunnable::DispatchToThread(gDbBackgroundThread, r); // At this point the update thread has been shut down and diff --git a/toolkit/components/url-classifier/nsUrlClassifierProxies.cpp b/toolkit/components/url-classifier/nsUrlClassifierProxies.cpp index b48ae6bd666d..e5ff0dbc1604 100644 --- a/toolkit/components/url-classifier/nsUrlClassifierProxies.cpp +++ b/toolkit/components/url-classifier/nsUrlClassifierProxies.cpp @@ -113,7 +113,8 @@ NS_IMETHODIMP UrlClassifierDBServiceWorkerProxy::FinishStream() { nsCOMPtr r = - NewRunnableMethod(mTarget, + NewRunnableMethod("nsUrlClassifierDBServiceWorker::FinishStream", + mTarget, &nsUrlClassifierDBServiceWorker::FinishStream); return DispatchToWorkerThread(r); } @@ -147,7 +148,8 @@ NS_IMETHODIMP UrlClassifierDBServiceWorkerProxy::FinishUpdate() { nsCOMPtr r = - NewRunnableMethod(mTarget, + NewRunnableMethod("nsUrlClassifierDBServiceWorker::FinishUpdate", + mTarget, &nsUrlClassifierDBServiceWorker::FinishUpdate); return DispatchToWorkerThread(r); } @@ -156,7 +158,8 @@ NS_IMETHODIMP UrlClassifierDBServiceWorkerProxy::CancelUpdate() { nsCOMPtr r = - NewRunnableMethod(mTarget, + NewRunnableMethod("nsUrlClassifierDBServiceWorker::CancelUpdate", + mTarget, &nsUrlClassifierDBServiceWorker::CancelUpdate); return DispatchToWorkerThread(r); } @@ -165,7 +168,8 @@ NS_IMETHODIMP UrlClassifierDBServiceWorkerProxy::ResetDatabase() { nsCOMPtr r = - NewRunnableMethod(mTarget, + NewRunnableMethod("nsUrlClassifierDBServiceWorker::ResetDatabase", + mTarget, &nsUrlClassifierDBServiceWorker::ResetDatabase); return DispatchToWorkerThread(r); } @@ -174,7 +178,8 @@ NS_IMETHODIMP UrlClassifierDBServiceWorkerProxy::ReloadDatabase() { nsCOMPtr r = - NewRunnableMethod(mTarget, + NewRunnableMethod("nsUrlClassifierDBServiceWorker::ReloadDatabase", + mTarget, &nsUrlClassifierDBServiceWorker::ReloadDatabase); return DispatchToWorkerThread(r); } @@ -183,7 +188,8 @@ NS_IMETHODIMP UrlClassifierDBServiceWorkerProxy::ClearCache() { nsCOMPtr r = - NewRunnableMethod(mTarget, + NewRunnableMethod("nsUrlClassifierDBServiceWorker::ClearCache", + mTarget, &nsUrlClassifierDBServiceWorker::ClearCache); return DispatchToWorkerThread(r); } @@ -192,7 +198,8 @@ nsresult UrlClassifierDBServiceWorkerProxy::OpenDb() { nsCOMPtr r = - NewRunnableMethod(mTarget, + NewRunnableMethod("nsUrlClassifierDBServiceWorker::OpenDb", + mTarget, &nsUrlClassifierDBServiceWorker::OpenDb); return DispatchToWorkerThread(r); } @@ -201,7 +208,8 @@ nsresult UrlClassifierDBServiceWorkerProxy::CloseDb() { nsCOMPtr r = - NewRunnableMethod(mTarget, + NewRunnableMethod("nsUrlClassifierDBServiceWorker::CloseDb", + mTarget, &nsUrlClassifierDBServiceWorker::CloseDb); return DispatchToWorkerThread(r); } diff --git a/toolkit/components/url-classifier/nsUrlClassifierProxies.h b/toolkit/components/url-classifier/nsUrlClassifierProxies.h index cad88316657c..f337ed0fe2d2 100644 --- a/toolkit/components/url-classifier/nsUrlClassifierProxies.h +++ b/toolkit/components/url-classifier/nsUrlClassifierProxies.h @@ -35,7 +35,8 @@ public: nsIPrincipal* aPrincipal, const nsACString& aTables, nsIUrlClassifierCallback* aCB) - : mTarget(aTarget) + : mozilla::Runnable("UrlClassifierDBServiceWorkerProxy::LookupRunnable") + , mTarget(aTarget) , mPrincipal(aPrincipal) , mLookupTables(aTables) , mCB(aCB) @@ -55,7 +56,9 @@ public: public: GetTablesRunnable(nsUrlClassifierDBServiceWorker* aTarget, nsIUrlClassifierCallback* aCB) - : mTarget(aTarget) + : mozilla::Runnable( + "UrlClassifierDBServiceWorkerProxy::GetTablesRunnable") + , mTarget(aTarget) , mCB(aCB) { } @@ -72,7 +75,9 @@ public: BeginUpdateRunnable(nsUrlClassifierDBServiceWorker* aTarget, nsIUrlClassifierUpdateObserver* aUpdater, const nsACString& aTables) - : mTarget(aTarget) + : mozilla::Runnable( + "UrlClassifierDBServiceWorkerProxy::BeginUpdateRunnable") + , mTarget(aTarget) , mUpdater(aUpdater) , mTables(aTables) { } @@ -90,7 +95,9 @@ public: public: BeginStreamRunnable(nsUrlClassifierDBServiceWorker* aTarget, const nsACString& aTable) - : mTarget(aTarget) + : mozilla::Runnable( + "UrlClassifierDBServiceWorkerProxy::BeginStreamRunnable") + , mTarget(aTarget) , mTable(aTable) { } @@ -106,7 +113,9 @@ public: public: UpdateStreamRunnable(nsUrlClassifierDBServiceWorker* aTarget, const nsACString& aUpdateChunk) - : mTarget(aTarget) + : mozilla::Runnable( + "UrlClassifierDBServiceWorkerProxy::UpdateStreamRunnable") + , mTarget(aTarget) , mUpdateChunk(aUpdateChunk) { } @@ -121,8 +130,10 @@ public: { public: CacheCompletionsRunnable(nsUrlClassifierDBServiceWorker* aTarget, - mozilla::safebrowsing::CacheResultArray *aEntries) - : mTarget(aTarget) + mozilla::safebrowsing::CacheResultArray* aEntries) + : mozilla::Runnable( + "UrlClassifierDBServiceWorkerProxy::CacheCompletionsRunnable") + , mTarget(aTarget) , mEntries(aEntries) { } @@ -140,7 +151,9 @@ public: const nsACString& spec, const nsACString& tables, mozilla::safebrowsing::LookupResultArray* results) - : mTarget(aTarget) + : mozilla::Runnable( + "UrlClassifierDBServiceWorkerProxy::DoLocalLookupRunnable") + , mTarget(aTarget) , mSpec(spec) , mTables(tables) , mResults(results) @@ -159,7 +172,9 @@ public: { public: explicit ClearLastResultsRunnable(nsUrlClassifierDBServiceWorker* aTarget) - : mTarget(aTarget) + : mozilla::Runnable( + "UrlClassifierDBServiceWorkerProxy::ClearLastResultsRunnable") + , mTarget(aTarget) { } NS_DECL_NSIRUNNABLE @@ -173,9 +188,11 @@ public: explicit GetCacheInfoRunnable(nsUrlClassifierDBServiceWorker* aTarget, const nsACString& aTable, nsIUrlClassifierCacheInfo** aCache) - : mTarget(aTarget), - mTable(aTable), - mCache(aCache) + : mozilla::Runnable( + "UrlClassifierDBServiceWorkerProxy::GetCacheInfoRunnable") + , mTarget(aTarget) + , mTable(aTable) + , mCache(aCache) { } NS_DECL_NSIRUNNABLE @@ -220,9 +237,12 @@ public: class LookupCompleteRunnable : public mozilla::Runnable { public: - LookupCompleteRunnable(const nsMainThreadPtrHandle& aTarget, - mozilla::safebrowsing::LookupResultArray *aResults) - : mTarget(aTarget) + LookupCompleteRunnable( + const nsMainThreadPtrHandle& aTarget, + mozilla::safebrowsing::LookupResultArray* aResults) + : mozilla::Runnable( + "UrlClassifierLookupCallbackProxy::LookupCompleteRunnable") + , mTarget(aTarget) , mResults(aResults) { } @@ -253,9 +273,11 @@ public: class HandleEventRunnable : public mozilla::Runnable { public: - HandleEventRunnable(const nsMainThreadPtrHandle& aTarget, - const nsACString& aValue) - : mTarget(aTarget) + HandleEventRunnable( + const nsMainThreadPtrHandle& aTarget, + const nsACString& aValue) + : mozilla::Runnable("UrlClassifierCallbackProxy::HandleEventRunnable") + , mTarget(aTarget) , mValue(aValue) { } @@ -287,10 +309,13 @@ public: class UpdateUrlRequestedRunnable : public mozilla::Runnable { public: - UpdateUrlRequestedRunnable(const nsMainThreadPtrHandle& aTarget, - const nsACString& aURL, - const nsACString& aTable) - : mTarget(aTarget) + UpdateUrlRequestedRunnable( + const nsMainThreadPtrHandle& aTarget, + const nsACString& aURL, + const nsACString& aTable) + : mozilla::Runnable( + "UrlClassifierUpdateObserverProxy::UpdateUrlRequestedRunnable") + , mTarget(aTarget) , mURL(aURL) , mTable(aTable) { } @@ -305,9 +330,13 @@ public: class StreamFinishedRunnable : public mozilla::Runnable { public: - StreamFinishedRunnable(const nsMainThreadPtrHandle& aTarget, - nsresult aStatus, uint32_t aDelay) - : mTarget(aTarget) + StreamFinishedRunnable( + const nsMainThreadPtrHandle& aTarget, + nsresult aStatus, + uint32_t aDelay) + : mozilla::Runnable( + "UrlClassifierUpdateObserverProxy::StreamFinishedRunnable") + , mTarget(aTarget) , mStatus(aStatus) , mDelay(aDelay) { } @@ -323,9 +352,12 @@ public: class UpdateErrorRunnable : public mozilla::Runnable { public: - UpdateErrorRunnable(const nsMainThreadPtrHandle& aTarget, - nsresult aError) - : mTarget(aTarget) + UpdateErrorRunnable( + const nsMainThreadPtrHandle& aTarget, + nsresult aError) + : mozilla::Runnable( + "UrlClassifierUpdateObserverProxy::UpdateErrorRunnable") + , mTarget(aTarget) , mError(aError) { } @@ -339,9 +371,12 @@ public: class UpdateSuccessRunnable : public mozilla::Runnable { public: - UpdateSuccessRunnable(const nsMainThreadPtrHandle& aTarget, - uint32_t aRequestedTimeout) - : mTarget(aTarget) + UpdateSuccessRunnable( + const nsMainThreadPtrHandle& aTarget, + uint32_t aRequestedTimeout) + : mozilla::Runnable( + "UrlClassifierUpdateObserverProxy::UpdateSuccessRunnable") + , mTarget(aTarget) , mRequestedTimeout(aRequestedTimeout) { } diff --git a/toolkit/components/url-classifier/tests/gtest/Common.cpp b/toolkit/components/url-classifier/tests/gtest/Common.cpp index e8f89e854cd5..2d11cf87ccca 100644 --- a/toolkit/components/url-classifier/tests/gtest/Common.cpp +++ b/toolkit/components/url-classifier/tests/gtest/Common.cpp @@ -15,7 +15,8 @@ using namespace mozilla::safebrowsing; template void RunTestInNewThread(Function&& aFunction) { - nsCOMPtr r = NS_NewRunnableFunction(mozilla::Forward(aFunction)); + nsCOMPtr r = NS_NewRunnableFunction( + "RunTestInNewThread", mozilla::Forward(aFunction)); nsCOMPtr testingThread; nsresult rv = NS_NewNamedThread("Testing Thread", getter_AddRefs(testingThread), r); @@ -35,14 +36,15 @@ nsresult SyncApplyUpdates(Classifier* aClassifier, auto onUpdateComplete = [&done, &ret](nsresult rv) { // We are on the "ApplyUpdate" thread. Post an event to main thread // so that we can avoid busy waiting on the main thread. - nsCOMPtr r = NS_NewRunnableFunction([&done, &ret, rv] { - ret = rv; - done = true; - }); + nsCOMPtr r = + NS_NewRunnableFunction("SyncApplyUpdates", [&done, &ret, rv] { + ret = rv; + done = true; + }); NS_DispatchToMainThread(r); }; - nsCOMPtr r = NS_NewRunnableFunction([&]() { + nsCOMPtr r = NS_NewRunnableFunction("SyncApplyUpdates", [&]() { nsresult rv = aClassifier->AsyncApplyUpdates(aUpdates, onUpdateComplete); if (NS_FAILED(rv)) { onUpdateComplete(rv); diff --git a/toolkit/crashreporter/InjectCrashReporter.cpp b/toolkit/crashreporter/InjectCrashReporter.cpp index e82c8ee4d86b..22c200f1b028 100644 --- a/toolkit/crashreporter/InjectCrashReporter.cpp +++ b/toolkit/crashreporter/InjectCrashReporter.cpp @@ -17,7 +17,8 @@ using CrashReporter::GetChildNotificationPipe; namespace mozilla { InjectCrashRunnable::InjectCrashRunnable(DWORD pid) - : mPID(pid) + : Runnable("InjectCrashRunnable") + , mPID(pid) { nsCOMPtr dll; nsresult rv = NS_GetSpecialDirectory(NS_GRE_DIR, getter_AddRefs(dll)); diff --git a/toolkit/crashreporter/nsExceptionHandler.cpp b/toolkit/crashreporter/nsExceptionHandler.cpp index f9eed55cd4c4..97f636a45c51 100644 --- a/toolkit/crashreporter/nsExceptionHandler.cpp +++ b/toolkit/crashreporter/nsExceptionHandler.cpp @@ -321,7 +321,7 @@ static nsIThread* sInjectorThread; class ReportInjectedCrash : public Runnable { public: - explicit ReportInjectedCrash(uint32_t pid) : mPID(pid) { } + explicit ReportInjectedCrash(uint32_t pid) : Runnable("ReportInjectedCrash"), mPID(pid) { } NS_IMETHOD Run(); @@ -3444,6 +3444,7 @@ OOPInit() class ProxyToMainThread : public Runnable { public: + ProxyToMainThread() : Runnable("nsExceptionHandler::ProxyToMainThread") {} NS_IMETHOD Run() override { OOPInit(); return NS_OK; diff --git a/toolkit/crashreporter/test/gtest/TestCrashThreadAnnotation.cpp b/toolkit/crashreporter/test/gtest/TestCrashThreadAnnotation.cpp index a4325e6dd42f..7cb84905ee86 100644 --- a/toolkit/crashreporter/test/gtest/TestCrashThreadAnnotation.cpp +++ b/toolkit/crashreporter/test/gtest/TestCrashThreadAnnotation.cpp @@ -79,13 +79,14 @@ TEST(TestCrashThreadAnnotation, TestGetFlatThreadAnnotation_AfterShutdown) already_AddRefed CreateTestThread(const char* aName, Monitor& aMonitor, bool& aDone) { - nsCOMPtr setNameRunnable = NS_NewRunnableFunction([aName, &aMonitor, &aDone] () -> void { - NS_SetCurrentThreadName(aName); + nsCOMPtr setNameRunnable = NS_NewRunnableFunction( + "CrashReporter::CreateTestThread", [aName, &aMonitor, &aDone]() -> void { + NS_SetCurrentThreadName(aName); - MonitorAutoLock lock(aMonitor); - aDone = true; - aMonitor.NotifyAll(); - }); + MonitorAutoLock lock(aMonitor); + aDone = true; + aMonitor.NotifyAll(); + }); nsCOMPtr thread; mozilla::Unused << NS_NewThread(getter_AddRefs(thread), setNameRunnable); @@ -126,15 +127,18 @@ TEST(TestCrashThreadAnnotation, TestGetFlatThreadAnnotation_SetNameTwice) Monitor monitor("TestCrashThreadAnnotation"); bool threadNameSet = false; - nsCOMPtr setNameRunnable = NS_NewRunnableFunction([&] () -> void { - NS_SetCurrentThreadName("Thread1"); - // Set the name again. We should get the latest name. - NS_SetCurrentThreadName("Thread1Again"); + nsCOMPtr setNameRunnable = NS_NewRunnableFunction( + "CrashReporter::TestCrashThreadAnnotation_TestGetFlatThreadAnnotation_" + "SetNameTwice_Test::TestBody", + [&]() -> void { + NS_SetCurrentThreadName("Thread1"); + // Set the name again. We should get the latest name. + NS_SetCurrentThreadName("Thread1Again"); - MonitorAutoLock lock(monitor); - threadNameSet = true; - monitor.NotifyAll(); - }); + MonitorAutoLock lock(monitor); + threadNameSet = true; + monitor.NotifyAll(); + }); nsCOMPtr thread; nsresult rv = NS_NewThread(getter_AddRefs(thread), setNameRunnable); ASSERT_TRUE(NS_SUCCEEDED(rv)); diff --git a/toolkit/xre/ProfileReset.h b/toolkit/xre/ProfileReset.h index a164fe07513b..503ef6035086 100644 --- a/toolkit/xre/ProfileReset.h +++ b/toolkit/xre/ProfileReset.h @@ -20,7 +20,8 @@ class ProfileResetCleanupResultTask : public mozilla::Runnable { public: ProfileResetCleanupResultTask() - : mWorkerThread(do_GetCurrentThread()) + : mozilla::Runnable("ProfileResetCleanupResultTask") + , mWorkerThread(do_GetCurrentThread()) { MOZ_ASSERT(!NS_IsMainThread()); } @@ -38,9 +39,12 @@ private: class ProfileResetCleanupAsyncTask : public mozilla::Runnable { public: - ProfileResetCleanupAsyncTask(nsIFile* aProfileDir, nsIFile* aProfileLocalDir, - nsIFile* aTargetDir, const nsAString &aLeafName) - : mProfileDir(aProfileDir) + ProfileResetCleanupAsyncTask(nsIFile* aProfileDir, + nsIFile* aProfileLocalDir, + nsIFile* aTargetDir, + const nsAString& aLeafName) + : mozilla::Runnable("ProfileResetCleanupAsyncTask") + , mProfileDir(aProfileDir) , mProfileLocalDir(aProfileLocalDir) , mTargetDir(aTargetDir) , mLeafName(aLeafName) diff --git a/toolkit/xre/nsEmbedFunctions.cpp b/toolkit/xre/nsEmbedFunctions.cpp index 1fbcc961a728..8d40f84db1ed 100644 --- a/toolkit/xre/nsEmbedFunctions.cpp +++ b/toolkit/xre/nsEmbedFunctions.cpp @@ -751,10 +751,10 @@ class MainFunctionRunnable : public Runnable public: NS_DECL_NSIRUNNABLE - MainFunctionRunnable(MainFunction aFunction, - void* aData) - : mFunction(aFunction), - mData(aData) + MainFunctionRunnable(MainFunction aFunction, void* aData) + : mozilla::Runnable("MainFunctionRunnable") + , mFunction(aFunction) + , mData(aData) { NS_ASSERTION(aFunction, "Don't give me a null pointer!"); } diff --git a/toolkit/xre/nsNativeAppSupportUnix.cpp b/toolkit/xre/nsNativeAppSupportUnix.cpp index a04a79953cb0..0fb613bef33b 100644 --- a/toolkit/xre/nsNativeAppSupportUnix.cpp +++ b/toolkit/xre/nsNativeAppSupportUnix.cpp @@ -254,7 +254,10 @@ nsNativeAppSupportUnix::InteractCB(SmcConn smc_conn, SmPointer client_data) // means we won't process any more. libsm hates us if we do the InteractDone // with a pending ShutdownCancelled, and we would certainly like to handle Die // whilst a dialog is displayed - NS_DispatchToCurrentThread(NewRunnableMethod(self, &nsNativeAppSupportUnix::DoInteract)); + NS_DispatchToCurrentThread( + NewRunnableMethod("nsNativeAppSupportUnix::DoInteract", + self, + &nsNativeAppSupportUnix::DoInteract)); } void diff --git a/toolkit/xre/nsUpdateDriver.cpp b/toolkit/xre/nsUpdateDriver.cpp index 79ff15d7e277..e79a49061ef6 100644 --- a/toolkit/xre/nsUpdateDriver.cpp +++ b/toolkit/xre/nsUpdateDriver.cpp @@ -83,7 +83,8 @@ UpdateDriverSetupMacCommandLine(int& argc, char**& argv, bool restart) Monitor monitor("nsUpdateDriver SetupMacCommandLine"); nsresult rv = NS_DispatchToMainThread( - NS_NewRunnableFunction([&argc, &argv, restart, &monitor]() -> void + NS_NewRunnableFunction("UpdateDriverSetupMacCommandLine", + [&argc, &argv, restart, &monitor]() -> void { CommandLineServiceMac::SetupMacCommandLine(argc, argv, restart); MonitorAutoLock(monitor).Notify(); @@ -917,7 +918,10 @@ nsUpdateProcessor::ProcessUpdate(nsIUpdate* aUpdate) mInfo.mAppVersion = appVersion; MOZ_ASSERT(NS_IsMainThread(), "not main thread"); - nsCOMPtr r = NewRunnableMethod(this, &nsUpdateProcessor::StartStagedUpdate); + nsCOMPtr r = + NewRunnableMethod("nsUpdateProcessor::StartStagedUpdate", + this, + &nsUpdateProcessor::StartStagedUpdate); return NS_NewNamedThread("Update Watcher", getter_AddRefs(mProcessWatcher), r); } @@ -941,13 +945,19 @@ nsUpdateProcessor::StartStagedUpdate() if (mUpdaterPID) { // Track the state of the updater process while it is staging an update. - rv = NS_DispatchToCurrentThread(NewRunnableMethod(this, &nsUpdateProcessor::WaitForProcess)); + rv = NS_DispatchToCurrentThread( + NewRunnableMethod("nsUpdateProcessor::WaitForProcess", + 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(NewRunnableMethod(this, &nsUpdateProcessor::ShutdownWatcherThread)); + rv = NS_DispatchToMainThread( + NewRunnableMethod("nsUpdateProcessor::ShutdownWatcherThread", + this, + &nsUpdateProcessor::ShutdownWatcherThread)); NS_ENSURE_SUCCESS_VOID(rv); } } @@ -965,9 +975,13 @@ nsUpdateProcessor::WaitForProcess() { MOZ_ASSERT(!NS_IsMainThread(), "main thread"); if (ProcessHasTerminated(mUpdaterPID)) { - NS_DispatchToMainThread(NewRunnableMethod(this, &nsUpdateProcessor::UpdateDone)); + NS_DispatchToMainThread(NewRunnableMethod( + "nsUpdateProcessor::UpdateDone", this, &nsUpdateProcessor::UpdateDone)); } else { - NS_DispatchToCurrentThread(NewRunnableMethod(this, &nsUpdateProcessor::WaitForProcess)); + NS_DispatchToCurrentThread( + NewRunnableMethod("nsUpdateProcessor::WaitForProcess", + this, + &nsUpdateProcessor::WaitForProcess)); } } diff --git a/tools/profiler/core/platform.cpp b/tools/profiler/core/platform.cpp index 97b2fe426e0e..77d04fe46a0d 100644 --- a/tools/profiler/core/platform.cpp +++ b/tools/profiler/core/platform.cpp @@ -337,9 +337,10 @@ private: IOInterposer::Register(IOInterposeObserver::OpAll, mInterposeObserver); } else { RefPtr observer = mInterposeObserver; - NS_DispatchToMainThread(NS_NewRunnableFunction([=]() { - IOInterposer::Register(IOInterposeObserver::OpAll, observer); - })); + NS_DispatchToMainThread( + NS_NewRunnableFunction("ActivePS::ActivePS", [=]() { + IOInterposer::Register(IOInterposeObserver::OpAll, observer); + })); } } } @@ -353,9 +354,10 @@ private: IOInterposer::Unregister(IOInterposeObserver::OpAll, mInterposeObserver); } else { RefPtr observer = mInterposeObserver; - NS_DispatchToMainThread(NS_NewRunnableFunction([=]() { - IOInterposer::Unregister(IOInterposeObserver::OpAll, observer); - })); + NS_DispatchToMainThread( + NS_NewRunnableFunction("ActivePS::~ActivePS", [=]() { + IOInterposer::Unregister(IOInterposeObserver::OpAll, observer); + })); } } } @@ -2052,9 +2054,8 @@ NotifyObservers(const char* aTopic, nsISupports* aSubject = nullptr) // these notifications are only observed in the parent process, where the // profiler_* functions are currently only called on the main thread. nsCOMPtr subject = aSubject; - NS_DispatchToMainThread(NS_NewRunnableFunction([=] { - NotifyObservers(aTopic, subject); - })); + NS_DispatchToMainThread(NS_NewRunnableFunction( + "NotifyObservers", [=] { NotifyObservers(aTopic, subject); })); return; } diff --git a/tools/profiler/gecko/ChildProfilerController.cpp b/tools/profiler/gecko/ChildProfilerController.cpp index 9ecdf2281992..230a9cdf95b3 100644 --- a/tools/profiler/gecko/ChildProfilerController.cpp +++ b/tools/profiler/gecko/ChildProfilerController.cpp @@ -32,8 +32,11 @@ ChildProfilerController::Init(Endpoint&& aEndpoint) if (NS_SUCCEEDED(NS_NewNamedThread("ProfilerChild", getter_AddRefs(mThread)))) { // Now that mThread has been set, run SetupProfilerChild on the thread. mThread->Dispatch(NewRunnableMethod&&>( - this, &ChildProfilerController::SetupProfilerChild, Move(aEndpoint)), - NS_DISPATCH_NORMAL); + "ChildProfilerController::SetupProfilerChild", + this, + &ChildProfilerController::SetupProfilerChild, + Move(aEndpoint)), + NS_DISPATCH_NORMAL); } } @@ -56,8 +59,11 @@ ChildProfilerController::ShutdownAndMaybeGrabShutdownProfileFirst(nsCString* aOu { if (mThread) { mThread->Dispatch(NewRunnableMethod( - this, &ChildProfilerController::ShutdownProfilerChild, aOutShutdownProfile), - NS_DISPATCH_NORMAL); + "ChildProfilerController::ShutdownProfilerChild", + this, + &ChildProfilerController::ShutdownProfilerChild, + aOutShutdownProfile), + NS_DISPATCH_NORMAL); // Shut down the thread. This call will spin until all runnables (including // the ShutdownProfilerChild runnable) have been processed. mThread->Shutdown(); diff --git a/tools/profiler/gecko/ThreadResponsiveness.cpp b/tools/profiler/gecko/ThreadResponsiveness.cpp index 4f411f0754a8..8cc7d20ef359 100644 --- a/tools/profiler/gecko/ThreadResponsiveness.cpp +++ b/tools/profiler/gecko/ThreadResponsiveness.cpp @@ -18,7 +18,8 @@ class CheckResponsivenessTask : public mozilla::Runnable, public nsITimerCallback { public: CheckResponsivenessTask() - : mLastTracerTime(TimeStamp::Now()) + : mozilla::Runnable("CheckResponsivenessTask") + , mLastTracerTime(TimeStamp::Now()) , mMutex("CheckResponsivenessTask") , mTimer(nullptr) , mHasEverBeenSuccessfullyDispatched(false) diff --git a/tools/profiler/tests/gtest/GeckoProfiler.cpp b/tools/profiler/tests/gtest/GeckoProfiler.cpp index e4befc4622b8..dc883b99d5c9 100644 --- a/tools/profiler/tests/gtest/GeckoProfiler.cpp +++ b/tools/profiler/tests/gtest/GeckoProfiler.cpp @@ -184,10 +184,16 @@ TEST(GeckoProfiler, DifferentThreads) uint32_t features = ProfilerFeature::JS | ProfilerFeature::Threads; const char* filters[] = { "GeckoMain", "Compositor" }; - thread->Dispatch(NS_NewRunnableFunction([&]() { - profiler_start(PROFILER_DEFAULT_ENTRIES, PROFILER_DEFAULT_INTERVAL, - features, filters, MOZ_ARRAY_LENGTH(filters)); - }), NS_DISPATCH_SYNC); + thread->Dispatch( + NS_NewRunnableFunction("GeckoProfiler_DifferentThreads_Test::TestBody", + [&]() { + profiler_start(PROFILER_DEFAULT_ENTRIES, + PROFILER_DEFAULT_INTERVAL, + features, + filters, + MOZ_ARRAY_LENGTH(filters)); + }), + NS_DISPATCH_SYNC); ASSERT_TRUE(profiler_is_active()); ASSERT_TRUE(!profiler_feature_active(ProfilerFeature::GPU)); @@ -197,9 +203,10 @@ TEST(GeckoProfiler, DifferentThreads) ActiveParamsCheck(PROFILER_DEFAULT_ENTRIES, PROFILER_DEFAULT_INTERVAL, features, filters, MOZ_ARRAY_LENGTH(filters)); - thread->Dispatch(NS_NewRunnableFunction([&]() { - profiler_stop(); - }), NS_DISPATCH_SYNC); + thread->Dispatch( + NS_NewRunnableFunction("GeckoProfiler_DifferentThreads_Test::TestBody", + [&]() { profiler_stop(); }), + NS_DISPATCH_SYNC); InactiveFeaturesAndParamsCheck(); } @@ -213,21 +220,29 @@ TEST(GeckoProfiler, DifferentThreads) profiler_start(PROFILER_DEFAULT_ENTRIES, PROFILER_DEFAULT_INTERVAL, features, filters, MOZ_ARRAY_LENGTH(filters)); - thread->Dispatch(NS_NewRunnableFunction([&]() { - ASSERT_TRUE(profiler_is_active()); - ASSERT_TRUE(!profiler_feature_active(ProfilerFeature::GPU)); - ASSERT_TRUE(!profiler_feature_active(ProfilerFeature::Privacy)); - ASSERT_TRUE(!profiler_feature_active(ProfilerFeature::Restyle)); + thread->Dispatch( + NS_NewRunnableFunction( + "GeckoProfiler_DifferentThreads_Test::TestBody", + [&]() { + ASSERT_TRUE(profiler_is_active()); + ASSERT_TRUE(!profiler_feature_active(ProfilerFeature::GPU)); + ASSERT_TRUE(!profiler_feature_active(ProfilerFeature::Privacy)); + ASSERT_TRUE(!profiler_feature_active(ProfilerFeature::Restyle)); - ActiveParamsCheck(PROFILER_DEFAULT_ENTRIES, PROFILER_DEFAULT_INTERVAL, - features, filters, MOZ_ARRAY_LENGTH(filters)); - }), NS_DISPATCH_SYNC); + ActiveParamsCheck(PROFILER_DEFAULT_ENTRIES, + PROFILER_DEFAULT_INTERVAL, + features, + filters, + MOZ_ARRAY_LENGTH(filters)); + }), + NS_DISPATCH_SYNC); profiler_stop(); - thread->Dispatch(NS_NewRunnableFunction([&]() { - InactiveFeaturesAndParamsCheck(); - }), NS_DISPATCH_SYNC); + thread->Dispatch( + NS_NewRunnableFunction("GeckoProfiler_DifferentThreads_Test::TestBody", + [&]() { InactiveFeaturesAndParamsCheck(); }), + NS_DISPATCH_SYNC); } thread->Shutdown(); @@ -542,11 +557,15 @@ TEST(GeckoProfiler, StreamJSONForThisProcessThreaded) features, filters, MOZ_ARRAY_LENGTH(filters)); // Call profiler_stream_json_for_this_process on a background thread. - thread->Dispatch(NS_NewRunnableFunction([&]() { - w.Start(SpliceableJSONWriter::SingleLineStyle); - ASSERT_TRUE(profiler_stream_json_for_this_process(w)); - w.End(); - }), NS_DISPATCH_SYNC); + thread->Dispatch( + NS_NewRunnableFunction( + "GeckoProfiler_StreamJSONForThisProcessThreaded_Test::TestBody", + [&]() { + w.Start(SpliceableJSONWriter::SingleLineStyle); + ASSERT_TRUE(profiler_stream_json_for_this_process(w)); + w.End(); + }), + NS_DISPATCH_SYNC); UniquePtr profile = w.WriteFunc()->CopyData(); @@ -554,10 +573,14 @@ TEST(GeckoProfiler, StreamJSONForThisProcessThreaded) // Stop the profiler and call profiler_stream_json_for_this_process on a // background thread. - thread->Dispatch(NS_NewRunnableFunction([&]() { - profiler_stop(); - ASSERT_TRUE(!profiler_stream_json_for_this_process(w)); - }), NS_DISPATCH_SYNC); + thread->Dispatch( + NS_NewRunnableFunction( + "GeckoProfiler_StreamJSONForThisProcessThreaded_Test::TestBody", + [&]() { + profiler_stop(); + ASSERT_TRUE(!profiler_stream_json_for_this_process(w)); + }), + NS_DISPATCH_SYNC); thread->Shutdown(); // Call profiler_stream_json_for_this_process on the main thread. diff --git a/uriloader/prefetch/nsOfflineCacheUpdate.cpp b/uriloader/prefetch/nsOfflineCacheUpdate.cpp index 6081797bedab..ab3a57ea97e0 100644 --- a/uriloader/prefetch/nsOfflineCacheUpdate.cpp +++ b/uriloader/prefetch/nsOfflineCacheUpdate.cpp @@ -1751,8 +1751,10 @@ nsOfflineCacheUpdate::Begin() mItemsInProgress = 0; if (mState == STATE_CANCELLED) { - nsresult rv = NS_DispatchToMainThread(NewRunnableMethod(this, - &nsOfflineCacheUpdate::AsyncFinishWithError)); + nsresult rv = NS_DispatchToMainThread( + NewRunnableMethod("nsOfflineCacheUpdate::AsyncFinishWithError", + this, + &nsOfflineCacheUpdate::AsyncFinishWithError)); NS_ENSURE_SUCCESS(rv, rv); return NS_OK; diff --git a/view/nsView.cpp b/view/nsView.cpp index c1de2ecca4e1..d4e0bfb22e4f 100644 --- a/view/nsView.cpp +++ b/view/nsView.cpp @@ -134,7 +134,11 @@ class DestroyWidgetRunnable : public Runnable { public: NS_DECL_NSIRUNNABLE - explicit DestroyWidgetRunnable(nsIWidget* aWidget) : mWidget(aWidget) {} + explicit DestroyWidgetRunnable(nsIWidget* aWidget) + : mozilla::Runnable("DestroyWidgetRunnable") + , mWidget(aWidget) + { + } private: nsCOMPtr mWidget; diff --git a/widget/VsyncDispatcher.cpp b/widget/VsyncDispatcher.cpp index f6aeee54d4a0..cac138b7b08e 100644 --- a/widget/VsyncDispatcher.cpp +++ b/widget/VsyncDispatcher.cpp @@ -73,9 +73,11 @@ CompositorVsyncDispatcher::SetCompositorVsyncObserver(VsyncObserver* aVsyncObser } bool observeVsync = aVsyncObserver != nullptr; - nsCOMPtr vsyncControl = NewRunnableMethod(this, - &CompositorVsyncDispatcher::ObserveVsync, - observeVsync); + nsCOMPtr vsyncControl = + NewRunnableMethod("CompositorVsyncDispatcher::ObserveVsync", + this, + &CompositorVsyncDispatcher::ObserveVsync, + observeVsync); NS_DispatchToMainThread(vsyncControl); } @@ -164,8 +166,10 @@ void RefreshTimerVsyncDispatcher::UpdateVsyncStatus() { if (!NS_IsMainThread()) { - NS_DispatchToMainThread(NewRunnableMethod(this, - &RefreshTimerVsyncDispatcher::UpdateVsyncStatus)); + NS_DispatchToMainThread( + NewRunnableMethod("RefreshTimerVsyncDispatcher::UpdateVsyncStatus", + this, + &RefreshTimerVsyncDispatcher::UpdateVsyncStatus)); return; } diff --git a/widget/android/AndroidBridge.cpp b/widget/android/AndroidBridge.cpp index adeac2357c47..f97b2052c727 100644 --- a/widget/android/AndroidBridge.cpp +++ b/widget/android/AndroidBridge.cpp @@ -564,7 +564,7 @@ AndroidBridge::GetStaticStringField(const char *className, const char *fieldName namespace mozilla { class TracerRunnable : public Runnable{ public: - TracerRunnable() { + TracerRunnable() : Runnable("TracerRunnable") { mTracerLock = new Mutex("TracerRunnable"); mTracerCondVar = new CondVar(*mTracerLock, "TracerRunnable"); mMainThread = do_GetMainThread(); diff --git a/widget/android/AndroidJNIWrapper.cpp b/widget/android/AndroidJNIWrapper.cpp index e549c6fc7ca5..14af0e02fedc 100644 --- a/widget/android/AndroidJNIWrapper.cpp +++ b/widget/android/AndroidJNIWrapper.cpp @@ -20,6 +20,7 @@ extern "C" { class GetGlobalClassRefRunnable : public mozilla::Runnable { public: GetGlobalClassRefRunnable(const char *className, jclass *foundClass) : + mozilla::Runnable("GetGlobalClassRefRunnable"), mClassName(className), mResult(foundClass) {} NS_IMETHOD Run() override { *mResult = __jsjni_GetGlobalClassRef(mClassName); diff --git a/widget/android/AndroidUiThread.cpp b/widget/android/AndroidUiThread.cpp index 98b876b2bb29..ac97d289c370 100644 --- a/widget/android/AndroidUiThread.cpp +++ b/widget/android/AndroidUiThread.cpp @@ -105,7 +105,7 @@ NS_IMPL_ISUPPORTS(ThreadObserver, nsIThreadObserver) NS_IMETHODIMP ThreadObserver::OnDispatchedEvent(nsIThreadInternal *thread) { - AndroidBridge::Bridge()->PostTaskToUiThread(NS_NewRunnableFunction(&PumpEvents), 0); + AndroidBridge::Bridge()->PostTaskToUiThread(NS_NewRunnableFunction("PumpEvents", &PumpEvents), 0); return NS_OK; } @@ -123,7 +123,7 @@ ThreadObserver::AfterProcessNextEvent(nsIThreadInternal *thread, bool eventWasPr class CreateOnUiThread : public Runnable { public: - CreateOnUiThread() + CreateOnUiThread() : Runnable("CreateOnUiThread") {} NS_IMETHOD Run() override { @@ -141,7 +141,7 @@ public: class DestroyOnUiThread : public Runnable { public: - DestroyOnUiThread() : mDestroyed(false) + DestroyOnUiThread() : Runnable("DestroyOnUiThread"), mDestroyed(false) {} NS_IMETHOD Run() override { diff --git a/widget/android/EventDispatcher.cpp b/widget/android/EventDispatcher.cpp index 736889ba926f..d188563f5e26 100644 --- a/widget/android/EventDispatcher.cpp +++ b/widget/android/EventDispatcher.cpp @@ -650,7 +650,7 @@ public: // Invoke callbacks synchronously if we're already on Gecko thread. return aCall(); } - NS_DispatchToMainThread(NS_NewRunnableFunction(Move(aCall))); + NS_DispatchToMainThread(NS_NewRunnableFunction("OnNativeCall", Move(aCall))); } static void Finalize(const CallbackDelegate::LocalRef& aInstance) diff --git a/widget/android/fennec/ThumbnailHelper.h b/widget/android/fennec/ThumbnailHelper.h index 192e15c5271f..8908a55e85fd 100644 --- a/widget/android/fennec/ThumbnailHelper.h +++ b/widget/android/fennec/ThumbnailHelper.h @@ -206,7 +206,7 @@ public: void Run() override { MessageLoop::current()->PostIdleTask( - NS_NewRunnableFunction(Move(Base::lambda))); + NS_NewRunnableFunction("OnNativeCall", Move(Base::lambda))); } }; diff --git a/widget/android/jni/Natives.h b/widget/android/jni/Natives.h index 13c93a61c29b..427de483e21d 100644 --- a/widget/android/jni/Natives.h +++ b/widget/android/jni/Natives.h @@ -529,7 +529,7 @@ struct Dispatcher // For a static method, do not forward the "this arg" (i.e. the class // local ref) if the implementation does not request it. This saves us // a pair of calls to add/delete global ref. - NS_DispatchToMainThread(NS_NewRunnableFunction(ProxyNativeCall< + NS_DispatchToMainThread(NS_NewRunnableFunction("ProxyNativeCall", ProxyNativeCall< Impl, typename Traits::Owner, IsStatic, HasThisArg, Args...>(HasThisArg || !IsStatic ? thisArg : nullptr, Forward(args)...))); diff --git a/widget/android/nsAppShell.cpp b/widget/android/nsAppShell.cpp index d83d07a16f1a..d896de80404b 100644 --- a/widget/android/nsAppShell.cpp +++ b/widget/android/nsAppShell.cpp @@ -149,6 +149,7 @@ public: { struct NoOpRunnable : Runnable { + NoOpRunnable() : Runnable("NoOpRunnable") {} NS_IMETHOD Run() override { return NS_OK; } }; diff --git a/widget/android/nsScreenManagerAndroid.cpp b/widget/android/nsScreenManagerAndroid.cpp index 3256a19876fd..1feafb2e9bab 100644 --- a/widget/android/nsScreenManagerAndroid.cpp +++ b/widget/android/nsScreenManagerAndroid.cpp @@ -120,6 +120,7 @@ public: int32_t screenId = -1; // return value nsCOMPtr mainThread = do_GetMainThread(); SyncRunnable::DispatchToThread(mainThread, NS_NewRunnableFunction( + "nsScreenManagerAndroid::ScreenManagerHelperSupport::AddDisplay", [&aDisplayType, &aWidth, &aHeight, &aDensity, &screenId] { MOZ_ASSERT(NS_IsMainThread()); nsCOMPtr screenMgr = @@ -141,6 +142,7 @@ public: static void RemoveDisplay(int32_t aScreenId) { nsCOMPtr mainThread = do_GetMainThread(); SyncRunnable::DispatchToThread(mainThread, NS_NewRunnableFunction( + "nsScreenManagerAndroid::ScreenManagerHelperSupport::RemoveDisplay", [&aScreenId] { MOZ_ASSERT(NS_IsMainThread()); nsCOMPtr screenMgr = diff --git a/widget/android/nsWindow.cpp b/widget/android/nsWindow.cpp index 555982aca033..cefaf234f838 100644 --- a/widget/android/nsWindow.cpp +++ b/widget/android/nsWindow.cpp @@ -1008,7 +1008,8 @@ public: if (!AndroidBridge::IsJavaUiThread()) { RefPtr uiThread = GetAndroidUiThread(); if (uiThread) { - uiThread->Dispatch(NewRunnableMethod(child, + uiThread->Dispatch(NewRunnableMethod("layers::UiCompositorControllerChild::InvalidateAndRender", + child, &UiCompositorControllerChild::InvalidateAndRender), nsIThread::DISPATCH_NORMAL); } @@ -1038,6 +1039,7 @@ public: RefPtr uiThread = GetAndroidUiThread(); if (uiThread) { uiThread->Dispatch(NewRunnableMethod( + "layers::UiCompositorControllerChild::SetPinned", child, &UiCompositorControllerChild::SetPinned, aPinned, aReason), nsIThread::DISPATCH_NORMAL); } @@ -1060,6 +1062,7 @@ public: RefPtr uiThread = GetAndroidUiThread(); if (uiThread) { uiThread->Dispatch(NewRunnableMethod( + "layers::UiCompositorControllerChild::ToolbarAnimatorMessageFromUI", child, &UiCompositorControllerChild::ToolbarAnimatorMessageFromUI, aMessage), nsIThread::DISPATCH_NORMAL); } diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index c258b673e7bc..1e07d123eef5 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -3224,7 +3224,7 @@ class WidgetsReleaserRunnable final : public mozilla::Runnable { public: explicit WidgetsReleaserRunnable(nsTArray>&& aWidgetArray) - : mWidgetArray(aWidgetArray) + : mozilla::Runnable("WidgetsReleaserRunnable"), mWidgetArray(aWidgetArray) { } diff --git a/widget/gtk/nsDeviceContextSpecG.cpp b/widget/gtk/nsDeviceContextSpecG.cpp index 294c7dd52d98..3dadc17d0add 100644 --- a/widget/gtk/nsDeviceContextSpecG.cpp +++ b/widget/gtk/nsDeviceContextSpecG.cpp @@ -258,7 +258,10 @@ 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. - NS_DispatchToCurrentThread(NewRunnableMethod(spec, &nsDeviceContextSpecGTK::StartPrintJob)); + NS_DispatchToCurrentThread( + NewRunnableMethod("nsDeviceContextSpecGTK::StartPrintJob", + spec, + &nsDeviceContextSpecGTK::StartPrintJob)); return TRUE; } } @@ -316,7 +319,10 @@ NS_IMETHODIMP nsDeviceContextSpecGTK::EndDocument() } else { // We don't have a printer. We have to enumerate the printers and find // one with a matching name. - NS_DispatchToCurrentThread(NewRunnableMethod(this, &nsDeviceContextSpecGTK::EnumeratePrinters)); + NS_DispatchToCurrentThread( + NewRunnableMethod("nsDeviceContextSpecGTK::EnumeratePrinters", + 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 f91c9acf7ee2..5e3d0b6f0d6e 100644 --- a/widget/gtk/nsWindow.cpp +++ b/widget/gtk/nsWindow.cpp @@ -2443,7 +2443,8 @@ nsWindow::OnSizeAllocate(GtkAllocation *aAllocation) // GtkWindow callers of gtk_widget_size_allocate expect the signal // handlers to return sometime in the near future. mNeedsDispatchResized = true; - NS_DispatchToCurrentThread(NewRunnableMethod(this, &nsWindow::MaybeDispatchResized)); + NS_DispatchToCurrentThread(NewRunnableMethod( + "nsWindow::MaybeDispatchResized", this, &nsWindow::MaybeDispatchResized)); } void @@ -4731,7 +4732,9 @@ nsWindow::GrabPointer(guint32 aTime) // popups don't rollup while potentially adjusting the grab for // this popup. nsCOMPtr event = - NewRunnableMethod(this, &nsWindow::CheckForRollupDuringGrab); + NewRunnableMethod("nsWindow::CheckForRollupDuringGrab", + this, + &nsWindow::CheckForRollupDuringGrab); NS_DispatchToCurrentThread(event.forget()); } } diff --git a/widget/nsBaseFilePicker.cpp b/widget/nsBaseFilePicker.cpp index 1ddfdba055a6..40d4ca69ea19 100644 --- a/widget/nsBaseFilePicker.cpp +++ b/widget/nsBaseFilePicker.cpp @@ -67,10 +67,11 @@ LocalFileToDirectoryOrBlob(nsPIDOMWindowInner* aWindow, class AsyncShowFilePicker : public mozilla::Runnable { public: - AsyncShowFilePicker(nsIFilePicker *aFilePicker, - nsIFilePickerShownCallback *aCallback) : - mFilePicker(aFilePicker), - mCallback(aCallback) + AsyncShowFilePicker(nsIFilePicker* aFilePicker, + nsIFilePickerShownCallback* aCallback) + : mozilla::Runnable("AsyncShowFilePicker") + , mFilePicker(aFilePicker) + , mCallback(aCallback) { } diff --git a/widget/nsBaseWidget.cpp b/widget/nsBaseWidget.cpp index 7965eecbfa97..dc6e98c49873 100644 --- a/widget/nsBaseWidget.cpp +++ b/widget/nsBaseWidget.cpp @@ -926,11 +926,12 @@ void nsBaseWidget::ConfigureAPZCTreeManager() bool aPreventDefault) { MOZ_ASSERT(NS_IsMainThread()); - APZThreadUtils::RunOnControllerThread(NewRunnableMethod - (treeManager, - &IAPZCTreeManager::ContentReceivedInputBlock, - aInputBlockId, - aPreventDefault)); + APZThreadUtils::RunOnControllerThread(NewRunnableMethod( + "layers::IAPZCTreeManager::ContentReceivedInputBlock", + treeManager, + &IAPZCTreeManager::ContentReceivedInputBlock, + aInputBlockId, + aPreventDefault)); }); mAPZEventState = new APZEventState(this, mozilla::Move(callback)); @@ -938,11 +939,14 @@ void nsBaseWidget::ConfigureAPZCTreeManager() const nsTArray& aFlags) { MOZ_ASSERT(NS_IsMainThread()); - APZThreadUtils::RunOnControllerThread(NewRunnableMethod - >>(treeManager, - &IAPZCTreeManager::SetAllowedTouchBehavior, - aInputBlockId, aFlags)); + APZThreadUtils::RunOnControllerThread( + NewRunnableMethod>>( + "layers::IAPZCTreeManager::SetAllowedTouchBehavior", + treeManager, + &IAPZCTreeManager::SetAllowedTouchBehavior, + aInputBlockId, + aFlags)); }; mRootContentController = CreateRootContentController(); @@ -969,10 +973,14 @@ void nsBaseWidget::SetConfirmedTargetAPZC(uint64_t aInputBlockId, const nsTArray& aTargets) const { - APZThreadUtils::RunOnControllerThread(NewRunnableMethod - >>(mAPZC, - &IAPZCTreeManager::SetTargetAPZC, - aInputBlockId, aTargets)); + APZThreadUtils::RunOnControllerThread( + NewRunnableMethod>>( + "layers::IAPZCTreeManager::SetTargetAPZC", + mAPZC, + &IAPZCTreeManager::SetTargetAPZC, + aInputBlockId, + aTargets)); } void @@ -1077,7 +1085,8 @@ public: nsEventStatus aAPZResult, uint64_t aInputBlockId, ScrollableLayerGuid aGuid) - : mWheelInput(aWheelInput) + : mozilla::Runnable("DispatchWheelEventOnMainThread") + , mWheelInput(aWheelInput) , mWidget(aWidget) , mAPZResult(aAPZResult) , mInputBlockId(aInputBlockId) @@ -1106,7 +1115,8 @@ public: DispatchWheelInputOnControllerThread(const WidgetWheelEvent& aWheelEvent, IAPZCTreeManager* aAPZC, nsBaseWidget* aWidget) - : mMainMessageLoop(MessageLoop::current()) + : mozilla::Runnable("DispatchWheelInputOnControllerThread") + , mMainMessageLoop(MessageLoop::current()) , mWheelInput(aWheelEvent) , mAPZC(aAPZC) , mWidget(aWidget) @@ -1877,10 +1887,13 @@ nsBaseWidget::StartAsyncScrollbarDrag(const AsyncDragMetrics& aDragMetrics) uint64_t layersId = mCompositorSession->RootLayerTreeId(); ScrollableLayerGuid guid(layersId, aDragMetrics.mPresShellId, aDragMetrics.mViewId); - APZThreadUtils::RunOnControllerThread(NewRunnableMethod - (mAPZC, - &IAPZCTreeManager::StartScrollbarDrag, - guid, aDragMetrics)); + APZThreadUtils::RunOnControllerThread( + NewRunnableMethod( + "layers::IAPZCTreeManager::StartScrollbarDrag", + mAPZC, + &IAPZCTreeManager::StartScrollbarDrag, + guid, + aDragMetrics)); } already_AddRefed @@ -1939,9 +1952,12 @@ nsIWidget::SynthesizeNativeTouchTap(LayoutDeviceIntPoint aPoint, bool aLongTap, if (timeout > TOUCH_INJECT_PUMP_TIMER_MSEC) { timeout = TOUCH_INJECT_PUMP_TIMER_MSEC; } - mLongTapTimer->InitWithFuncCallback(OnLongTapTimerCallback, this, - timeout, - nsITimer::TYPE_REPEATING_SLACK); + mLongTapTimer->InitWithNamedFuncCallback( + OnLongTapTimerCallback, + this, + timeout, + nsITimer::TYPE_REPEATING_SLACK, + "nsIWidget::SynthesizeNativeTouchTap"); } // If we already have a long tap pending, cancel it. We only allow one long diff --git a/widget/nsIdleService.cpp b/widget/nsIdleService.cpp index 80392322a029..d2d9daf18447 100644 --- a/widget/nsIdleService.cpp +++ b/widget/nsIdleService.cpp @@ -143,10 +143,11 @@ nsIdleServiceDaily::Observe(nsISupports *, ("nsIdleServiceDaily: Restarting daily timer")); // Start timer for the next check in one day. - (void)mTimer->InitWithFuncCallback(DailyCallback, - this, - SECONDS_PER_DAY * PR_MSEC_PER_SEC, - nsITimer::TYPE_ONE_SHOT); + (void)mTimer->InitWithNamedFuncCallback(DailyCallback, + this, + SECONDS_PER_DAY * PR_MSEC_PER_SEC, + nsITimer::TYPE_ONE_SHOT, + "nsIdleServiceDaily::Observe"); return NS_OK; } @@ -218,10 +219,11 @@ nsIdleServiceDaily::Init() mExpectedTriggerTime = PR_Now() + (milliSecLeftUntilDaily * PR_USEC_PER_MSEC); - (void)mTimer->InitWithFuncCallback(DailyCallback, - this, - milliSecLeftUntilDaily, - nsITimer::TYPE_ONE_SHOT); + (void)mTimer->InitWithNamedFuncCallback(DailyCallback, + this, + milliSecLeftUntilDaily, + nsITimer::TYPE_ONE_SHOT, + "nsIdleServiceDaily::Init"); } // Register for when we should terminate/pause @@ -292,10 +294,12 @@ nsIdleServiceDaily::DailyCallback(nsITimer* aTimer, void* aClosure) delayTime / PR_USEC_PER_MSEC); #endif - (void)self->mTimer->InitWithFuncCallback(DailyCallback, - self, - delayTime / PR_USEC_PER_MSEC, - nsITimer::TYPE_ONE_SHOT); + (void)self->mTimer->InitWithNamedFuncCallback( + DailyCallback, + self, + delayTime / PR_USEC_PER_MSEC, + nsITimer::TYPE_ONE_SHOT, + "nsIdleServiceDaily::DailyCallback"); return; } @@ -828,11 +832,11 @@ nsIdleService::SetTimerExpiryIfBefore(TimeStamp aNextTimeout) #endif // Start the timer - mTimer->InitWithFuncCallback(StaticIdleTimerCallback, - this, - deltaTime.ToMilliseconds(), - nsITimer::TYPE_ONE_SHOT); - + mTimer->InitWithNamedFuncCallback(StaticIdleTimerCallback, + this, + deltaTime.ToMilliseconds(), + nsITimer::TYPE_ONE_SHOT, + "nsIdleService::SetTimerExpiryIfBefore"); } } diff --git a/widget/windows/AudioSession.cpp b/widget/windows/AudioSession.cpp index 5a5db2f02fc5..f077dd48a113 100644 --- a/widget/windows/AudioSession.cpp +++ b/widget/windows/AudioSession.cpp @@ -409,7 +409,8 @@ AudioSession::OnSessionDisconnected(AudioSessionDisconnectReason aReason) // Run our code asynchronously. Per MSDN we can't do anything interesting // in this callback. nsCOMPtr runnable = - NewRunnableMethod(this, &AudioSession::OnSessionDisconnectedInternal); + NewRunnableMethod("widget::AudioSession::OnSessionDisconnectedInternal", + this, &AudioSession::OnSessionDisconnectedInternal); NS_DispatchToMainThread(runnable); return S_OK; } diff --git a/widget/windows/LSPAnnotator.cpp b/widget/windows/LSPAnnotator.cpp index 9132ceb2b02f..5a36bc26d10c 100644 --- a/widget/windows/LSPAnnotator.cpp +++ b/widget/windows/LSPAnnotator.cpp @@ -29,6 +29,7 @@ class LSPAnnotationGatherer : public Runnable ~LSPAnnotationGatherer() {} public: + LSPAnnotationGatherer() : Runnable("crashreporter::LSPAnnotationGatherer") {} NS_DECL_NSIRUNNABLE void Annotate(); @@ -137,7 +138,8 @@ LSPAnnotationGatherer::Run() } mString = str; - NS_DispatchToMainThread(NewRunnableMethod(this, &LSPAnnotationGatherer::Annotate)); + NS_DispatchToMainThread(NewRunnableMethod("crashreporter::LSPAnnotationGatherer::Annotate", + this, &LSPAnnotationGatherer::Annotate)); return NS_OK; } diff --git a/widget/windows/WidgetTraceEvent.cpp b/widget/windows/WidgetTraceEvent.cpp index 4e4be3af3ca7..915a72fd7747 100644 --- a/widget/windows/WidgetTraceEvent.cpp +++ b/widget/windows/WidgetTraceEvent.cpp @@ -34,7 +34,7 @@ HANDLE sEventHandle = nullptr; // thread. class HWNDGetter : public mozilla::Runnable { public: - HWNDGetter() : hidden_window_hwnd(nullptr) {} + HWNDGetter() : Runnable("HWNDGetter"), hidden_window_hwnd(nullptr) {} HWND hidden_window_hwnd; diff --git a/widget/windows/nsColorPicker.cpp b/widget/windows/nsColorPicker.cpp index 777169f9783d..c4a9d6823ece 100644 --- a/widget/windows/nsColorPicker.cpp +++ b/widget/windows/nsColorPicker.cpp @@ -96,7 +96,8 @@ static AsyncColorChooser* gColorChooser; AsyncColorChooser::AsyncColorChooser(COLORREF aInitialColor, nsIWidget* aParentWidget, nsIColorPickerShownCallback* aCallback) - : mInitialColor(aInitialColor) + : mozilla::Runnable("AsyncColorChooser") + , mInitialColor(aInitialColor) , mColor(aInitialColor) , mParentWidget(aParentWidget) , mCallback(aCallback) diff --git a/widget/windows/nsSound.cpp b/widget/windows/nsSound.cpp index 7c8b73d65627..7086ef831936 100644 --- a/widget/windows/nsSound.cpp +++ b/widget/windows/nsSound.cpp @@ -34,13 +34,13 @@ static mozilla::LazyLogModule gWin32SoundLog("nsSound"); class nsSoundPlayer: public mozilla::Runnable { public: nsSoundPlayer(nsSound *aSound, const wchar_t* aSoundName) : - mSoundName(aSoundName), mSound(aSound) + Runnable("nsSoundPlayer"), mSoundName(aSoundName), mSound(aSound) { Init(); } nsSoundPlayer(nsSound *aSound, const nsAString& aSoundName) : - mSoundName(aSoundName), mSound(aSound) + Runnable("nsSoundPlayer"), mSoundName(aSoundName), mSound(aSound) { Init(); } @@ -62,6 +62,7 @@ protected: class SoundReleaser: public mozilla::Runnable { public: explicit SoundReleaser(nsSound* aSound) : + Runnable("SoundReleaser"), mSound(aSound) { } diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index 8e25356c8323..b9c3d82a516d 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -5329,7 +5329,8 @@ nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam, if (wParam == TRUE && !gfxEnv::DisableForcePresent() && gfxWindowsPlatform::GetPlatform()->DwmCompositionEnabled()) { - NS_DispatchToMainThread(NewRunnableMethod(this, &nsWindow::ForcePresent)); + NS_DispatchToMainThread(NewRunnableMethod("nsWindow::ForcePresent", + this, &nsWindow::ForcePresent)); } // let the dwm handle nc painting on glass diff --git a/widget/windows/nsWindowGfx.cpp b/widget/windows/nsWindowGfx.cpp index ccc07480f978..e4b6989fa028 100644 --- a/widget/windows/nsWindowGfx.cpp +++ b/widget/windows/nsWindowGfx.cpp @@ -394,7 +394,7 @@ bool nsWindow::OnPaint(HDC aDC, uint32_t aNestingLevel) this, LayoutDeviceIntRegion::FromUnknownRegion(region)); if (!gfxEnv::DisableForcePresent() && gfxWindowsPlatform::GetPlatform()->DwmCompositionEnabled()) { nsCOMPtr event = - NewRunnableMethod(this, &nsWindow::ForcePresent); + NewRunnableMethod("nsWindow::ForcePresent", this, &nsWindow::ForcePresent); NS_DispatchToMainThread(event); } } diff --git a/xpcom/base/CycleCollectedJSContext.cpp b/xpcom/base/CycleCollectedJSContext.cpp index 8347159eeefe..0da8c5703f1f 100644 --- a/xpcom/base/CycleCollectedJSContext.cpp +++ b/xpcom/base/CycleCollectedJSContext.cpp @@ -186,9 +186,12 @@ CycleCollectedJSContext::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const class PromiseJobRunnable final : public Runnable { public: - PromiseJobRunnable(JS::HandleObject aCallback, JS::HandleObject aAllocationSite, + PromiseJobRunnable(JS::HandleObject aCallback, + JS::HandleObject aAllocationSite, nsIGlobalObject* aIncumbentGlobal) - : mCallback(new PromiseJobCallback(aCallback, aAllocationSite, aIncumbentGlobal)) + : Runnable("PromiseJobRunnable") + , mCallback( + new PromiseJobCallback(aCallback, aAllocationSite, aIncumbentGlobal)) { } diff --git a/xpcom/base/nsConsoleService.cpp b/xpcom/base/nsConsoleService.cpp index 2283f2c9facc..125aafcad6c5 100644 --- a/xpcom/base/nsConsoleService.cpp +++ b/xpcom/base/nsConsoleService.cpp @@ -127,7 +127,9 @@ nsConsoleService::~nsConsoleService() class AddConsolePrefWatchers : public Runnable { public: - explicit AddConsolePrefWatchers(nsConsoleService* aConsole) : mConsole(aConsole) + explicit AddConsolePrefWatchers(nsConsoleService* aConsole) + : mozilla::Runnable("AddConsolePrefWatchers") + , mConsole(aConsole) { } @@ -168,7 +170,8 @@ class LogMessageRunnable : public Runnable { public: LogMessageRunnable(nsIConsoleMessage* aMessage, nsConsoleService* aService) - : mMessage(aMessage) + : mozilla::Runnable("LogMessageRunnable") + , mMessage(aMessage) , mService(aService) { } diff --git a/xpcom/base/nsCycleCollector.cpp b/xpcom/base/nsCycleCollector.cpp index 128d99a2c8e5..5fc3778651d5 100644 --- a/xpcom/base/nsCycleCollector.cpp +++ b/xpcom/base/nsCycleCollector.cpp @@ -1488,7 +1488,9 @@ struct CCGraphDescriber : public LinkedListElement class LogStringMessageAsync : public CancelableRunnable { public: - explicit LogStringMessageAsync(const nsAString& aMsg) : mMsg(aMsg) + explicit LogStringMessageAsync(const nsAString& aMsg) + : mozilla::CancelableRunnable("LogStringMessageAsync") + , mMsg(aMsg) {} NS_IMETHOD Run() override diff --git a/xpcom/base/nsDumpUtils.cpp b/xpcom/base/nsDumpUtils.cpp index c68862d08a47..8e822457ccea 100644 --- a/xpcom/base/nsDumpUtils.cpp +++ b/xpcom/base/nsDumpUtils.cpp @@ -74,7 +74,8 @@ FdWatcher::Init() nsCOMPtr os = services::GetObserverService(); os->AddObserver(this, "xpcom-shutdown", /* ownsWeak = */ false); - XRE_GetIOMessageLoop()->PostTask(NewRunnableMethod(this, &FdWatcher::StartWatching)); + XRE_GetIOMessageLoop()->PostTask(NewRunnableMethod( + "FdWatcher::StartWatching", 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 12a99da18dc9..86c74dbdcd6b 100644 --- a/xpcom/base/nsDumpUtils.h +++ b/xpcom/base/nsDumpUtils.h @@ -89,7 +89,8 @@ public: MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(!strcmp(aTopic, "xpcom-shutdown")); - XRE_GetIOMessageLoop()->PostTask(mozilla::NewRunnableMethod(this, &FdWatcher::StopWatching)); + XRE_GetIOMessageLoop()->PostTask(mozilla::NewRunnableMethod( + "FdWatcher::StopWatching", this, &FdWatcher::StopWatching)); return NS_OK; } diff --git a/xpcom/base/nsMemoryInfoDumper.cpp b/xpcom/base/nsMemoryInfoDumper.cpp index 06453b126ffd..867b9eb2ed03 100644 --- a/xpcom/base/nsMemoryInfoDumper.cpp +++ b/xpcom/base/nsMemoryInfoDumper.cpp @@ -61,8 +61,10 @@ class DumpMemoryInfoToTempDirRunnable : public Runnable { public: DumpMemoryInfoToTempDirRunnable(const nsAString& aIdentifier, - bool aAnonymize, bool aMinimizeMemoryUsage) - : mIdentifier(aIdentifier) + bool aAnonymize, + bool aMinimizeMemoryUsage) + : mozilla::Runnable("DumpMemoryInfoToTempDirRunnable") + , mIdentifier(aIdentifier) , mAnonymize(aAnonymize) , mMinimizeMemoryUsage(aMinimizeMemoryUsage) { @@ -93,7 +95,8 @@ public: GCAndCCLogDumpRunnable(const nsAString& aIdentifier, bool aDumpAllTraces, bool aDumpChildProcesses) - : mIdentifier(aIdentifier) + : mozilla::Runnable("GCAndCCLogDumpRunnable") + , mIdentifier(aIdentifier) , mDumpAllTraces(aDumpAllTraces) , mDumpChildProcesses(aDumpChildProcesses) { diff --git a/xpcom/base/nsMemoryReporterManager.cpp b/xpcom/base/nsMemoryReporterManager.cpp index 323a753f75c6..f34ba97b5628 100644 --- a/xpcom/base/nsMemoryReporterManager.cpp +++ b/xpcom/base/nsMemoryReporterManager.cpp @@ -1679,7 +1679,9 @@ nsMemoryReporterManager::GetReportsExtended( if (aMinimize) { nsCOMPtr callback = - NewRunnableMethod(this, &nsMemoryReporterManager::StartGettingReports); + NewRunnableMethod("nsMemoryReporterManager::StartGettingReports", + this, + &nsMemoryReporterManager::StartGettingReports); rv = MinimizeMemoryUsage(callback); } else { rv = StartGettingReports(); @@ -1737,9 +1739,12 @@ nsMemoryReporterManager::StartGettingReports() FinishReporting(); return NS_ERROR_FAILURE; } - rv = timer->InitWithFuncCallback(TimeoutCallback, - this, kTimeoutLengthMS, - nsITimer::TYPE_ONE_SHOT); + rv = timer->InitWithNamedFuncCallback( + TimeoutCallback, + this, + kTimeoutLengthMS, + nsITimer::TYPE_ONE_SHOT, + "nsMemoryReporterManager::StartGettingReports"); if (NS_WARN_IF(NS_FAILED(rv))) { FinishReporting(); return rv; @@ -1768,7 +1773,8 @@ nsMemoryReporterManager::DispatchReporter( nsCOMPtr handleReportData = aHandleReportData; nsCOMPtr event = NS_NewRunnableFunction( - [self, reporter, aIsAsync, handleReport, handleReportData, aAnonymize] () { + "nsMemoryReporterManager::DispatchReporter", + [self, reporter, aIsAsync, handleReport, handleReportData, aAnonymize]() { reporter->CollectReports(handleReport, handleReportData, aAnonymize); if (!aIsAsync) { self->EndReport(); @@ -2510,7 +2516,8 @@ class MinimizeMemoryUsageRunnable : public Runnable { public: explicit MinimizeMemoryUsageRunnable(nsIRunnable* aCallback) - : mCallback(aCallback) + : mozilla::Runnable("MinimizeMemoryUsageRunnable") + , mCallback(aCallback) , mRemainingIters(sNumIters) { } diff --git a/xpcom/base/nsMessageLoop.cpp b/xpcom/base/nsMessageLoop.cpp index fabf6b9f5220..52da4412a7f0 100644 --- a/xpcom/base/nsMessageLoop.cpp +++ b/xpcom/base/nsMessageLoop.cpp @@ -72,7 +72,8 @@ private: MessageLoopIdleTask::MessageLoopIdleTask(nsIRunnable* aTask, uint32_t aEnsureRunsAfterMS) - : mTask(aTask) + : mozilla::Runnable("MessageLoopIdleTask") + , mTask(aTask) { // Init() really shouldn't fail, but if it does, we schedule our runnable // immediately, because it's more important to guarantee that we run the task diff --git a/xpcom/base/nsStatusReporterManager.cpp b/xpcom/base/nsStatusReporterManager.cpp index f20d0d59e490..ccd0a21e92d9 100644 --- a/xpcom/base/nsStatusReporterManager.cpp +++ b/xpcom/base/nsStatusReporterManager.cpp @@ -32,6 +32,7 @@ class DumpStatusInfoToTempDirRunnable : public mozilla::Runnable { public: DumpStatusInfoToTempDirRunnable() + : mozilla::Runnable("DumpStatusInfoToTempDirRunnable") { } diff --git a/xpcom/ds/nsHashPropertyBag.cpp b/xpcom/ds/nsHashPropertyBag.cpp index 4dbcc6a2a687..0585e850a6c4 100644 --- a/xpcom/ds/nsHashPropertyBag.cpp +++ b/xpcom/ds/nsHashPropertyBag.cpp @@ -276,7 +276,8 @@ class ProxyHashtableDestructor final : public mozilla::Runnable public: using HashtableType = nsInterfaceHashtable; explicit ProxyHashtableDestructor(HashtableType&& aTable) - : mPropertyHash(mozilla::Move(aTable)) + : mozilla::Runnable("ProxyHashtableDestructor") + , mPropertyHash(mozilla::Move(aTable)) {} NS_IMETHODIMP diff --git a/xpcom/ds/nsObserverService.cpp b/xpcom/ds/nsObserverService.cpp index f375766c0e9d..56765a274f36 100644 --- a/xpcom/ds/nsObserverService.cpp +++ b/xpcom/ds/nsObserverService.cpp @@ -182,7 +182,10 @@ 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. - NS_DispatchToCurrentThread(NewRunnableMethod(os, &nsObserverService::RegisterReporter)); + NS_DispatchToCurrentThread( + NewRunnableMethod("nsObserverService::RegisterReporter", + os, + &nsObserverService::RegisterReporter)); return os->QueryInterface(aIID, aInstancePtr); } diff --git a/xpcom/io/nsInputStreamTee.cpp b/xpcom/io/nsInputStreamTee.cpp index f6f9b7e80fe0..968282b5e612 100644 --- a/xpcom/io/nsInputStreamTee.cpp +++ b/xpcom/io/nsInputStreamTee.cpp @@ -61,8 +61,11 @@ class nsInputStreamTeeWriteEvent : public Runnable { public: // aTee's lock is held across construction of this object - nsInputStreamTeeWriteEvent(const char* aBuf, uint32_t aCount, - nsIOutputStream* aSink, nsInputStreamTee* aTee) + nsInputStreamTeeWriteEvent(const char* aBuf, + uint32_t aCount, + nsIOutputStream* aSink, + nsInputStreamTee* aTee) + : mozilla::Runnable("nsInputStreamTeeWriteEvent") { // copy the buffer - will be free'd by dtor mBuf = (char*)malloc(aCount); diff --git a/xpcom/io/nsLocalFileWin.cpp b/xpcom/io/nsLocalFileWin.cpp index 16fd575cb067..b5b7dbe184c5 100644 --- a/xpcom/io/nsLocalFileWin.cpp +++ b/xpcom/io/nsLocalFileWin.cpp @@ -114,6 +114,7 @@ class AsyncLocalFileWinDone : public Runnable { public: AsyncLocalFileWinDone() : + Runnable("AsyncLocalFileWinDone"), mWorkerThread(do_GetCurrentThread()) { // Objects of this type must only be created on worker threads @@ -143,7 +144,8 @@ class AsyncRevealOperation : public Runnable { public: explicit AsyncRevealOperation(const nsAString& aResolvedPath) - : mResolvedPath(aResolvedPath) + : Runnable("AsyncRevealOperation"), + mResolvedPath(aResolvedPath) { } diff --git a/xpcom/tests/gtest/TestMozPromise.cpp b/xpcom/tests/gtest/TestMozPromise.cpp index 0d82fc9fdad6..6038fd6dc9b6 100644 --- a/xpcom/tests/gtest/TestMozPromise.cpp +++ b/xpcom/tests/gtest/TestMozPromise.cpp @@ -43,10 +43,11 @@ public: TestPromise::Private* aPromise, const TestPromise::ResolveOrRejectValue& aValue, int aIterations) - : mTaskQueue(aTaskQueue) - , mPromise(aPromise) - , mValue(aValue) - , mIterations(aIterations) + : mozilla::Runnable("DelayedResolveOrReject") + , mTaskQueue(aTaskQueue) + , mPromise(aPromise) + , mValue(aValue) + , mIterations(aIterations) {} NS_IMETHOD Run() override @@ -85,7 +86,7 @@ template void RunOnTaskQueue(TaskQueue* aQueue, FunctionType aFun) { - nsCOMPtr r = NS_NewRunnableFunction(aFun); + nsCOMPtr r = NS_NewRunnableFunction("RunOnTaskQueue", aFun); aQueue->Dispatch(r.forget()); } diff --git a/xpcom/tests/gtest/TestRWLock.cpp b/xpcom/tests/gtest/TestRWLock.cpp index 65de524f279a..4dcd83b7ab61 100644 --- a/xpcom/tests/gtest/TestRWLock.cpp +++ b/xpcom/tests/gtest/TestRWLock.cpp @@ -22,7 +22,8 @@ static const size_t sWriteLockIteration = 10; class RWLockRunnable : public mozilla::Runnable { public: RWLockRunnable(RWLock* aRWLock, mozilla::Atomic* aSharedData) - : mRWLock(aRWLock) + : mozilla::Runnable("RWLockRunnable") + , mRWLock(aRWLock) , mSharedData(aSharedData) {} diff --git a/xpcom/tests/gtest/TestRacingServiceManager.cpp b/xpcom/tests/gtest/TestRacingServiceManager.cpp index 1309083ed853..ae5d9348dbcd 100644 --- a/xpcom/tests/gtest/TestRacingServiceManager.cpp +++ b/xpcom/tests/gtest/TestRacingServiceManager.cpp @@ -183,7 +183,11 @@ class TestRunnable : public Runnable public: NS_DECL_NSIRUNNABLE - TestRunnable() : mFirstRunnableDone(false) { } + TestRunnable() + : mozilla::Runnable("TestRacingServiceManager::TestRunnable") + , mFirstRunnableDone(false) + { + } bool mFirstRunnableDone; }; diff --git a/xpcom/tests/gtest/TestStateWatching.cpp b/xpcom/tests/gtest/TestStateWatching.cpp index 16d06a5fff5a..e083dc5e5772 100644 --- a/xpcom/tests/gtest/TestStateWatching.cpp +++ b/xpcom/tests/gtest/TestStateWatching.cpp @@ -32,11 +32,12 @@ TEST(WatchManager, Shutdown) WatchManager manager(p, queue); Watchable notifier(false, "notifier"); - queue->Dispatch(NS_NewRunnableFunction([&] () { - manager.Watch(notifier, &Foo::Notify); - notifier = true; // Trigger the call to Foo::Notify(). - manager.Shutdown(); // Shutdown() should cancel the call. - })); + queue->Dispatch(NS_NewRunnableFunction( + "TestStateWatching::WatchManager_Shutdown_Test::TestBody", [&]() { + manager.Watch(notifier, &Foo::Notify); + notifier = true; // Trigger the call to Foo::Notify(). + manager.Shutdown(); // Shutdown() should cancel the call. + })); queue->BeginShutdown(); queue->AwaitShutdownAndIdle(); diff --git a/xpcom/tests/gtest/TestTaskQueue.cpp b/xpcom/tests/gtest/TestTaskQueue.cpp index 1e764fcc1ea2..0f320f529db0 100644 --- a/xpcom/tests/gtest/TestTaskQueue.cpp +++ b/xpcom/tests/gtest/TestTaskQueue.cpp @@ -29,26 +29,39 @@ TEST(TaskQueue, EventOrder) // We expect task1 happens before task3. for (int i = 0; i < 10000; ++i) { - tq1->Dispatch(NS_NewRunnableFunction([&] () { - tq2->Dispatch(NS_NewRunnableFunction([] () { // task0 - })); - tq3->Dispatch(NS_NewRunnableFunction([&] () { // task1 - EXPECT_EQ(1, ++counter); - errored = counter != 1; - MonitorAutoLock mon(monitor); - ++sync; - mon.Notify(); - })); - tq2->Dispatch(NS_NewRunnableFunction([&] () { // task2 - tq3->Dispatch(NS_NewRunnableFunction([&] () { // task3 - EXPECT_EQ(0, --counter); - errored = counter != 0; - MonitorAutoLock mon(monitor); - ++sync; - mon.Notify(); - })); - })); - }), AbstractThread::AssertDispatchSuccess, AbstractThread::TailDispatch); + tq1->Dispatch( + NS_NewRunnableFunction( + "TestTaskQueue::TaskQueue_EventOrder_Test::TestBody", + [&]() { + tq2->Dispatch(NS_NewRunnableFunction( + "TestTaskQueue::TaskQueue_EventOrder_Test::TestBody", + []() { // task0 + })); + tq3->Dispatch(NS_NewRunnableFunction( + "TestTaskQueue::TaskQueue_EventOrder_Test::TestBody", + [&]() { // task1 + EXPECT_EQ(1, ++counter); + errored = counter != 1; + MonitorAutoLock mon(monitor); + ++sync; + mon.Notify(); + })); + tq2->Dispatch(NS_NewRunnableFunction( + "TestTaskQueue::TaskQueue_EventOrder_Test::TestBody", + [&]() { // task2 + tq3->Dispatch(NS_NewRunnableFunction( + "TestTaskQueue::TaskQueue_EventOrder_Test::TestBody", + [&]() { // task3 + EXPECT_EQ(0, --counter); + errored = counter != 0; + MonitorAutoLock mon(monitor); + ++sync; + mon.Notify(); + })); + })); + }), + AbstractThread::AssertDispatchSuccess, + AbstractThread::TailDispatch); // Ensure task1 and task3 are done before next loop. MonitorAutoLock mon(monitor); diff --git a/xpcom/tests/gtest/TestThreadPool.cpp b/xpcom/tests/gtest/TestThreadPool.cpp index 56abf7608d53..76e56236ea33 100644 --- a/xpcom/tests/gtest/TestThreadPool.cpp +++ b/xpcom/tests/gtest/TestThreadPool.cpp @@ -69,14 +69,18 @@ TEST(ThreadPool, Parallelism) EXPECT_TRUE(pool); // Dispatch and sleep to ensure we have an idle thread - nsCOMPtr r0 = new Runnable(); + nsCOMPtr r0 = new Runnable("TestRunnable"); pool->Dispatch(r0, NS_DISPATCH_SYNC); PR_Sleep(PR_SecondsToInterval(2)); class Runnable1 : public Runnable { public: Runnable1(Monitor& aMonitor, bool& aDone) - : mMonitor(aMonitor), mDone(aDone) {} + : mozilla::Runnable("Runnable1") + , mMonitor(aMonitor) + , mDone(aDone) + { + } NS_IMETHOD Run() override { MonitorAutoLock mon(mMonitor); @@ -96,7 +100,11 @@ TEST(ThreadPool, Parallelism) class Runnable2 : public Runnable { public: Runnable2(Monitor& aMonitor, bool& aDone) - : mMonitor(aMonitor), mDone(aDone) {} + : mozilla::Runnable("Runnable2") + , mMonitor(aMonitor) + , mDone(aDone) + { + } NS_IMETHOD Run() override { MonitorAutoLock mon(mMonitor); diff --git a/xpcom/tests/gtest/TestThreadPoolListener.cpp b/xpcom/tests/gtest/TestThreadPoolListener.cpp index f95106fa855f..01ecff49a73c 100644 --- a/xpcom/tests/gtest/TestThreadPoolListener.cpp +++ b/xpcom/tests/gtest/TestThreadPoolListener.cpp @@ -159,7 +159,7 @@ TEST(ThreadPoolListener, Test) ReentrantMonitorAutoEnter mon(*gReentrantMonitor); for (uint32_t i = 0; i < NUMBER_OF_THREADS; i++) { - nsCOMPtr runnable = new Runnable(); + nsCOMPtr runnable = new Runnable("TestRunnable"); ASSERT_TRUE(runnable); rv = pool->Dispatch(runnable, NS_DISPATCH_NORMAL); diff --git a/xpcom/tests/gtest/TestThreadUtils.cpp b/xpcom/tests/gtest/TestThreadUtils.cpp index d779e013284e..30baea27d509 100644 --- a/xpcom/tests/gtest/TestThreadUtils.cpp +++ b/xpcom/tests/gtest/TestThreadUtils.cpp @@ -45,6 +45,8 @@ private: NS_IMPL_ISUPPORTS0(nsFoo) class TestSuicide : public mozilla::Runnable { +public: + TestSuicide() : mozilla::Runnable("TestSuicide") {} NS_IMETHOD Run() override { // Runs first time on thread "Suicide", then dies on MainThread if (!NS_IsMainThread()) { @@ -185,8 +187,9 @@ static void TestNewRunnableFunction(bool aNamed) nsCOMPtr trackedRunnable; { TestCopyWithNoMove tracker(©Counter); - trackedRunnable = aNamed ? NS_NewRunnableFunction("unused", tracker) : - NS_NewRunnableFunction(tracker); + trackedRunnable = + aNamed ? NS_NewRunnableFunction("unused", tracker) + : NS_NewRunnableFunction("TestNewRunnableFunction", tracker); // Original 'tracker' is destroyed here. } // Verify that the runnable contains a non-destroyed function object. @@ -202,9 +205,11 @@ static void TestNewRunnableFunction(bool aNamed) { // Passing as rvalue, but using copy. // (TestCopyWithDeletedMove wouldn't allow this.) - trackedRunnable = aNamed ? - NS_NewRunnableFunction("unused", TestCopyWithNoMove(©Counter)) : - NS_NewRunnableFunction(TestCopyWithNoMove(©Counter)); + trackedRunnable = + aNamed + ? NS_NewRunnableFunction("unused", TestCopyWithNoMove(©Counter)) + : NS_NewRunnableFunction("TestNewRunnableFunction", + TestCopyWithNoMove(©Counter)); } trackedRunnable->Run(); } @@ -217,8 +222,9 @@ static void TestNewRunnableFunction(bool aNamed) nsCOMPtr trackedRunnable; { TestCopyWithDeletedMove tracker(©Counter); - trackedRunnable = aNamed ? NS_NewRunnableFunction("unused", tracker) : - NS_NewRunnableFunction(tracker); + trackedRunnable = + aNamed ? NS_NewRunnableFunction("unused", tracker) + : NS_NewRunnableFunction("TestNewRunnableFunction", tracker); } trackedRunnable->Run(); } @@ -233,8 +239,10 @@ static void TestNewRunnableFunction(bool aNamed) nsCOMPtr trackedRunnable; { TestMove tracker(&moveCounter); - trackedRunnable = aNamed ? NS_NewRunnableFunction("unused", Move(tracker)) : - NS_NewRunnableFunction(Move(tracker)); + trackedRunnable = + aNamed + ? NS_NewRunnableFunction("unused", Move(tracker)) + : NS_NewRunnableFunction("TestNewRunnableFunction", Move(tracker)); } trackedRunnable->Run(); } @@ -246,9 +254,10 @@ static void TestNewRunnableFunction(bool aNamed) { nsCOMPtr trackedRunnable; { - trackedRunnable = aNamed ? - NS_NewRunnableFunction("unused", TestMove(&moveCounter)) : - NS_NewRunnableFunction(TestMove(&moveCounter)); + trackedRunnable = + aNamed ? NS_NewRunnableFunction("unused", TestMove(&moveCounter)) + : NS_NewRunnableFunction("TestNewRunnableFunction", + TestMove(&moveCounter)); } trackedRunnable->Run(); } @@ -264,8 +273,10 @@ static void TestNewRunnableFunction(bool aNamed) nsCOMPtr trackedRunnable; { TestCopyMove tracker(©Counter, &moveCounter); - trackedRunnable = aNamed ? NS_NewRunnableFunction("unused", Move(tracker)) : - NS_NewRunnableFunction(Move(tracker)); + trackedRunnable = + aNamed + ? NS_NewRunnableFunction("unused", Move(tracker)) + : NS_NewRunnableFunction("TestNewRunnableFunction", Move(tracker)); } trackedRunnable->Run(); } @@ -280,9 +291,12 @@ static void TestNewRunnableFunction(bool aNamed) { nsCOMPtr trackedRunnable; { - trackedRunnable = aNamed ? - NS_NewRunnableFunction("unused", TestCopyMove(©Counter, &moveCounter)) : - NS_NewRunnableFunction(TestCopyMove(©Counter, &moveCounter)); + trackedRunnable = + aNamed + ? NS_NewRunnableFunction("unused", + TestCopyMove(©Counter, &moveCounter)) + : NS_NewRunnableFunction("TestNewRunnableFunction", + TestCopyMove(©Counter, &moveCounter)); } trackedRunnable->Run(); } @@ -300,9 +314,11 @@ static void TestNewRunnableFunction(bool aNamed) { TestCopyWithNoMove tracker(©Counter); // Expect 2 copies (here -> local lambda -> runnable lambda). - trackedRunnable = aNamed ? - NS_NewRunnableFunction("unused", [tracker]() mutable { tracker(); }) : - NS_NewRunnableFunction([tracker]() mutable { tracker(); }); + trackedRunnable = + aNamed ? NS_NewRunnableFunction("unused", + [tracker]() mutable { tracker(); }) + : NS_NewRunnableFunction("TestNewRunnableFunction", + [tracker]() mutable { tracker(); }); } trackedRunnable->Run(); } @@ -316,9 +332,11 @@ static void TestNewRunnableFunction(bool aNamed) { TestCopyWithDeletedMove tracker(©Counter); // Expect 2 copies (here -> local lambda -> runnable lambda). - trackedRunnable = aNamed ? - NS_NewRunnableFunction("unused", [tracker]() mutable { tracker(); }) : - NS_NewRunnableFunction([tracker]() mutable { tracker(); }); + trackedRunnable = + aNamed ? NS_NewRunnableFunction("unused", + [tracker]() mutable { tracker(); }) + : NS_NewRunnableFunction("TestNewRunnableFunction", + [tracker]() mutable { tracker(); }); } trackedRunnable->Run(); } @@ -337,9 +355,11 @@ static void TestNewRunnableFunction(bool aNamed) nsCOMPtr trackedRunnable; { TestCopyMove tracker(©Counter, &moveCounter); - trackedRunnable = aNamed ? - NS_NewRunnableFunction("unused", [tracker]() mutable { tracker(); }) : - NS_NewRunnableFunction([tracker]() mutable { tracker(); }); + trackedRunnable = + aNamed ? NS_NewRunnableFunction("unused", + [tracker]() mutable { tracker(); }) + : NS_NewRunnableFunction("TestNewRunnableFunction", + [tracker]() mutable { tracker(); }); // Expect 1 copy (here -> local lambda) and 1 move (local -> runnable lambda). } trackedRunnable->Run(); @@ -364,7 +384,8 @@ TEST(ThreadUtils, NewNamedRunnableFunction) // Test naming. { const char* expectedName = "NamedRunnable"; - RefPtr NamedRunnable = NS_NewRunnableFunction(expectedName, []{}); + RefPtr NamedRunnable = + NS_NewRunnableFunction(expectedName, [] {}); ExpectRunnableName(NamedRunnable, expectedName); } } @@ -385,27 +406,34 @@ static void TestNewRunnableMethod(bool aNamed) // Read only string. Dereferencing in runnable method to check this works. char* message = (char*)"Test message"; - NS_DispatchToMainThread(aNamed ? - NewRunnableMethod("unused", bar, &nsBar::DoBar1) : - NewRunnableMethod(bar, &nsBar::DoBar1)); - NS_DispatchToMainThread(aNamed ? - NewRunnableMethod("unused", constBar, &nsBar::DoBar1Const) : - NewRunnableMethod(constBar, &nsBar::DoBar1Const)); - NS_DispatchToMainThread(aNamed ? - NewRunnableMethod("unused", bar, &nsBar::DoBar2) : - NewRunnableMethod(bar, &nsBar::DoBar2)); - NS_DispatchToMainThread(aNamed ? - NewRunnableMethod>("unused", bar, &nsBar::DoBar3, foo) : - NewRunnableMethod>(bar, &nsBar::DoBar3, foo)); - NS_DispatchToMainThread(aNamed ? - NewRunnableMethod>("unused", bar, &nsBar::DoBar4, foo) : - NewRunnableMethod>(bar, &nsBar::DoBar4, foo)); - NS_DispatchToMainThread(aNamed ? - NewRunnableMethod("unused", bar, &nsBar::DoBar5, rawFoo) : - NewRunnableMethod(bar, &nsBar::DoBar5, rawFoo)); - NS_DispatchToMainThread(aNamed ? - NewRunnableMethod("unused", bar, &nsBar::DoBar6, message) : - NewRunnableMethod(bar, &nsBar::DoBar6, message)); + NS_DispatchToMainThread( + aNamed ? NewRunnableMethod("unused", bar, &nsBar::DoBar1) + : NewRunnableMethod("nsBar::DoBar1", bar, &nsBar::DoBar1)); + NS_DispatchToMainThread( + aNamed ? NewRunnableMethod("unused", constBar, &nsBar::DoBar1Const) + : NewRunnableMethod( + "nsBar::DoBar1Const", constBar, &nsBar::DoBar1Const)); + NS_DispatchToMainThread( + aNamed ? NewRunnableMethod("unused", bar, &nsBar::DoBar2) + : NewRunnableMethod("nsBar::DoBar2", bar, &nsBar::DoBar2)); + NS_DispatchToMainThread( + aNamed + ? NewRunnableMethod>("unused", bar, &nsBar::DoBar3, foo) + : NewRunnableMethod>( + "nsBar::DoBar3", bar, &nsBar::DoBar3, foo)); + NS_DispatchToMainThread( + aNamed + ? NewRunnableMethod>("unused", bar, &nsBar::DoBar4, foo) + : NewRunnableMethod>( + "nsBar::DoBar4", bar, &nsBar::DoBar4, foo)); + NS_DispatchToMainThread( + aNamed ? NewRunnableMethod("unused", bar, &nsBar::DoBar5, rawFoo) + : NewRunnableMethod( + "nsBar::DoBar5", bar, &nsBar::DoBar5, rawFoo)); + NS_DispatchToMainThread( + aNamed ? NewRunnableMethod("unused", bar, &nsBar::DoBar6, message) + : NewRunnableMethod( + "nsBar::DoBar6", bar, &nsBar::DoBar6, message)); #ifdef HAVE_STDCALL NS_DispatchToMainThread(aNamed ? NewRunnableMethod("unused", bar, &nsBar::DoBar1std) : @@ -555,7 +583,7 @@ public: ASSERT_TRUE(mSetIdleDeadlineCalled); mRunnableExecuted[2] = true; mSetIdleDeadlineCalled = false; - NS_DispatchToCurrentThread(NewRunnableMethod(this, &IdleObject::Method3)); + NS_DispatchToCurrentThread(NewRunnableMethod("IdleObject::Method3", this, &IdleObject::Method3)); } void Method3() @@ -563,11 +591,13 @@ public: CheckExecutedMethods("Method3", 3); mTimer = do_CreateInstance(NS_TIMER_CONTRACTID); - mTimer->InitWithFuncCallback(Method4, this, 10, nsITimer::TYPE_ONE_SHOT); + mTimer->InitWithNamedFuncCallback( + Method4, this, 10, nsITimer::TYPE_ONE_SHOT, "IdleObject::Method3"); NS_IdleDispatchToCurrentThread( - NewIdleRunnableMethodWithTimer(this, &IdleObject::Method5), 50); + NewIdleRunnableMethodWithTimer("IdleObject::Method5", this, &IdleObject::Method5), 50); NS_IdleDispatchToCurrentThread( - NewRunnableMethod(this, &IdleObject::Method6), 100); + NewRunnableMethod("IdleObject::Method6", this, &IdleObject::Method6), + 100); PR_Sleep(PR_MillisecondsToInterval(200)); mRunnableExecuted[3] = true; @@ -621,18 +651,21 @@ TEST(ThreadUtils, IdleRunnableMethod) RefPtr idleInheritedSetDeadline = new IdleObjectInheritedSetDeadline(); - NS_DispatchToCurrentThread(NewRunnableMethod(idle, &IdleObject::Method0)); + NS_DispatchToCurrentThread( + NewRunnableMethod("IdleObject::Method0", idle, &IdleObject::Method0)); NS_IdleDispatchToCurrentThread( - NewIdleRunnableMethod(idle, &IdleObject::Method1)); + NewIdleRunnableMethod("IdleObject::Method1", idle, &IdleObject::Method1)); NS_IdleDispatchToCurrentThread( - NewIdleRunnableMethodWithTimer(idle, &IdleObject::Method2), 60000); + NewIdleRunnableMethodWithTimer("IdleObject::Method2", idle, &IdleObject::Method2), 60000); NS_IdleDispatchToCurrentThread( - NewIdleRunnableMethod(idle, &IdleObject::Method7)); + NewIdleRunnableMethod("IdleObject::Method7", idle, &IdleObject::Method7)); NS_IdleDispatchToCurrentThread(NewIdleRunnableMethod( - idle, &IdleObject::CheckExecutedMethods, "final", 8)); + "IdleObject::CheckExecutedMethods", idle, &IdleObject::CheckExecutedMethods, "final", 8)); NS_IdleDispatchToCurrentThread(NewIdleRunnableMethod( + "IdleObjectWithoutSetDeadline::Method", idleNoSetDeadline, &IdleObjectWithoutSetDeadline::Method)); NS_IdleDispatchToCurrentThread(NewIdleRunnableMethod( + "IdleObjectInheritedSetDeadline::Method", idleInheritedSetDeadline, &IdleObjectInheritedSetDeadline::Method)); NS_ProcessPendingEvents(nullptr); @@ -1076,24 +1109,34 @@ TEST(ThreadUtils, main) // Test legacy functions. nsCOMPtr r1 = - NewRunnableMethod(rpt, &ThreadUtilsObject::Test0); + NewRunnableMethod("TestThreadUtils::ThreadUtilsObject::Test0", + rpt, + &ThreadUtilsObject::Test0); r1->Run(); EXPECT_EQ(count += 1, rpt->mCount); - r1 = NewRunnableMethod(rpt, &ThreadUtilsObject::Test1i, 11); + r1 = NewRunnableMethod("TestThreadUtils::ThreadUtilsObject::Test1i", + rpt, + &ThreadUtilsObject::Test1i, + 11); r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); EXPECT_EQ(11, rpt->mA0); // Test calling a method from a non-ref-counted base. - r1 = NewRunnableMethod(rpt, &ThreadUtilsObject::MethodFromNonRefCountedBase); + r1 = NewRunnableMethod("TestThreadUtils::ThreadUtilsObjectNonRefCountedBase::" + "MethodFromNonRefCountedBase", + rpt, + &ThreadUtilsObject::MethodFromNonRefCountedBase); r1->Run(); EXPECT_EQ(count, rpt->mCount); // Test variadic function with simple POD arguments. - r1 = NewRunnableMethod(rpt, &ThreadUtilsObject::Test0); + r1 = NewRunnableMethod("TestThreadUtils::ThreadUtilsObject::Test0", + rpt, + &ThreadUtilsObject::Test0); r1->Run(); EXPECT_EQ(count += 1, rpt->mCount); @@ -1106,20 +1149,31 @@ TEST(ThreadUtils, main) StoreCopyPassByValue>::value, "detail::ParameterStorage>::Type should be StoreCopyPassByValue"); - r1 = NewRunnableMethod(rpt, &ThreadUtilsObject::Test1i, 12); + r1 = NewRunnableMethod("TestThreadUtils::ThreadUtilsObject::Test1i", + rpt, + &ThreadUtilsObject::Test1i, + 12); r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); EXPECT_EQ(12, rpt->mA0); - r1 = NewRunnableMethod( - rpt, &ThreadUtilsObject::Test2i, 21, 22); + r1 = NewRunnableMethod("TestThreadUtils::ThreadUtilsObject::Test2i", + rpt, + &ThreadUtilsObject::Test2i, + 21, + 22); r1->Run(); EXPECT_EQ(count += 3, rpt->mCount); EXPECT_EQ(21, rpt->mA0); EXPECT_EQ(22, rpt->mA1); r1 = NewRunnableMethod( - rpt, &ThreadUtilsObject::Test3i, 31, 32, 33); + "TestThreadUtils::ThreadUtilsObject::Test3i", + rpt, + &ThreadUtilsObject::Test3i, + 31, + 32, + 33); r1->Run(); EXPECT_EQ(count += 4, rpt->mCount); EXPECT_EQ(31, rpt->mA0); @@ -1127,7 +1181,13 @@ TEST(ThreadUtils, main) EXPECT_EQ(33, rpt->mA2); r1 = NewRunnableMethod( - rpt, &ThreadUtilsObject::Test4i, 41, 42, 43, 44); + "TestThreadUtils::ThreadUtilsObject::Test4i", + rpt, + &ThreadUtilsObject::Test4i, + 41, + 42, + 43, + 44); r1->Run(); EXPECT_EQ(count += 5, rpt->mCount); EXPECT_EQ(41, rpt->mA0); @@ -1139,7 +1199,10 @@ TEST(ThreadUtils, main) // Passing a short to make sure forwarding works with an inexact type match. short int si = 11; - r1 = NewRunnableMethod(rpt, &ThreadUtilsObject::Test1i, si); + r1 = NewRunnableMethod("TestThreadUtils::ThreadUtilsObject::Test1i", + rpt, + &ThreadUtilsObject::Test1i, + si); r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); EXPECT_EQ(si, rpt->mA0); @@ -1165,7 +1228,10 @@ TEST(ThreadUtils, main) "detail::ParameterStorage::Type::passed_type should be int*"); { int i = 12; - r1 = NewRunnableMethod(rpt, &ThreadUtilsObject::Test1pi, &i); + r1 = NewRunnableMethod("TestThreadUtils::ThreadUtilsObject::Test1pi", + rpt, + &ThreadUtilsObject::Test1pi, + &i); r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); EXPECT_EQ(i, rpt->mA0); @@ -1192,7 +1258,11 @@ TEST(ThreadUtils, main) "detail::ParameterStorage::Type::passed_type should be const int*"); { int i = 1201; - r1 = NewRunnableMethod(rpt, &ThreadUtilsObject::Test1pci, &i); + r1 = NewRunnableMethod( + "TestThreadUtils::ThreadUtilsObject::Test1pci", + rpt, + &ThreadUtilsObject::Test1pci, + &i); r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); EXPECT_EQ(i, rpt->mA0); @@ -1208,7 +1278,10 @@ TEST(ThreadUtils, main) { int i = 1202; r1 = NewRunnableMethod>( - rpt, &ThreadUtilsObject::Test1pi, i); + "TestThreadUtils::ThreadUtilsObject::Test1pi", + rpt, + &ThreadUtilsObject::Test1pi, + i); r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); EXPECT_EQ(i, rpt->mA0); @@ -1224,7 +1297,10 @@ TEST(ThreadUtils, main) { int i = 1203; r1 = NewRunnableMethod>( - rpt, &ThreadUtilsObject::Test1pci, i); + "TestThreadUtils::ThreadUtilsObject::Test1pci", + rpt, + &ThreadUtilsObject::Test1pci, + i); r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); EXPECT_EQ(i, rpt->mA0); @@ -1283,7 +1359,10 @@ TEST(ThreadUtils, main) "ParameterStorage::Type::passed_type should be int&"); { int i = 13; - r1 = NewRunnableMethod(rpt, &ThreadUtilsObject::Test1ri, i); + r1 = NewRunnableMethod("TestThreadUtils::ThreadUtilsObject::Test1ri", + rpt, + &ThreadUtilsObject::Test1ri, + i); r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); EXPECT_EQ(i, rpt->mA0); @@ -1304,8 +1383,11 @@ TEST(ThreadUtils, main) "ParameterStorage::Type::passed_type should be int&&"); { int i = 14; - r1 = NewRunnableMethod( - rpt, &ThreadUtilsObject::Test1rri, mozilla::Move(i)); + r1 = + NewRunnableMethod("TestThreadUtils::ThreadUtilsObject::Test1rri", + rpt, + &ThreadUtilsObject::Test1rri, + mozilla::Move(i)); } r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); @@ -1327,7 +1409,10 @@ TEST(ThreadUtils, main) { mozilla::UniquePtr upi; r1 = NewRunnableMethod&&>( - rpt, &ThreadUtilsObject::Test1upi, mozilla::Move(upi)); + "TestThreadUtils::ThreadUtilsObject::Test1upi", + rpt, + &ThreadUtilsObject::Test1upi, + mozilla::Move(upi)); } r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); @@ -1349,9 +1434,11 @@ TEST(ThreadUtils, main) "ParameterStorage>>::Type::passed_type should be UniquePtr&&"); { mozilla::UniquePtr upi; - r1 = NewRunnableMethod - >>( - rpt, &ThreadUtilsObject::Test1upi, mozilla::Move(upi)); + r1 = NewRunnableMethod>>( + "TestThreadUtils::ThreadUtilsObject::Test1upi", + rpt, + &ThreadUtilsObject::Test1upi, + mozilla::Move(upi)); } r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); @@ -1361,7 +1448,10 @@ TEST(ThreadUtils, main) { mozilla::UniquePtr upi = mozilla::MakeUnique(1); r1 = NewRunnableMethod&&>( - rpt, &ThreadUtilsObject::Test1upi, mozilla::Move(upi)); + "TestThreadUtils::ThreadUtilsObject::Test1upi", + rpt, + &ThreadUtilsObject::Test1upi, + mozilla::Move(upi)); } r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); @@ -1369,9 +1459,11 @@ TEST(ThreadUtils, main) { mozilla::UniquePtr upi = mozilla::MakeUnique(1); - r1 = NewRunnableMethod - >> - (rpt, &ThreadUtilsObject::Test1upi, mozilla::Move(upi)); + r1 = NewRunnableMethod>>( + "TestThreadUtils::ThreadUtilsObject::Test1upi", + rpt, + &ThreadUtilsObject::Test1upi, + mozilla::Move(upi)); } r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); @@ -1379,7 +1471,10 @@ TEST(ThreadUtils, main) // Unique pointer as prvalue. r1 = NewRunnableMethod&&>( - rpt, &ThreadUtilsObject::Test1upi, mozilla::MakeUnique(2)); + "TestThreadUtils::ThreadUtilsObject::Test1upi", + rpt, + &ThreadUtilsObject::Test1upi, + mozilla::MakeUnique(2)); r1->Run(); EXPECT_EQ(count += 2, rpt->mCount); EXPECT_EQ(2, rpt->mA0); @@ -1388,7 +1483,10 @@ TEST(ThreadUtils, main) { mozilla::UniquePtr upi; r1 = NewRunnableMethod&>( - rpt, &ThreadUtilsObject::Test1rupi, upi); + "TestThreadUtils::ThreadUtilsObject::Test1rupi", + rpt, + &ThreadUtilsObject::Test1rupi, + upi); // Passed as lref, so Run() must be called while local upi is still alive! r1->Run(); } @@ -1408,7 +1506,10 @@ TEST(ThreadUtils, main) EXPECT_EQ(1, gAlive); if (gDebug) { printf("%d - r2 = NewRunnableMethod>(&TestByValue, s)\n", __LINE__); } r2 = NewRunnableMethod>( - rpt, &ThreadUtilsObject::TestByValue, s); + "TestThreadUtils::ThreadUtilsObject::TestByValue", + rpt, + &ThreadUtilsObject::TestByValue, + s); EXPECT_EQ(2, gAlive); EXPECT_LE(1, gCopyConstructions); // At least 1 copy-construction. Spy::ClearActions(); @@ -1434,9 +1535,11 @@ TEST(ThreadUtils, main) if (gDebug) { printf("%d - Test: Store copy from prvalue, pass by value\n", __LINE__); } { if (gDebug) { printf("%d - r3 = NewRunnableMethod>(&TestByValue, Spy(11))\n", __LINE__); } - nsCOMPtr r3 = - NewRunnableMethod>( - rpt, &ThreadUtilsObject::TestByValue, Spy(11)); + nsCOMPtr r3 = NewRunnableMethod>( + "TestThreadUtils::ThreadUtilsObject::TestByValue", + rpt, + &ThreadUtilsObject::TestByValue, + Spy(11)); EXPECT_EQ(1, gAlive); EXPECT_EQ(1, gConstructions); EXPECT_LE(1, gMoveConstructions); @@ -1463,7 +1566,10 @@ TEST(ThreadUtils, main) EXPECT_EQ(1, gAlive); Spy::ClearActions(); r4 = NewRunnableMethod>( - rpt, &ThreadUtilsObject::TestByValue, mozilla::Move(s)); + "TestThreadUtils::ThreadUtilsObject::TestByValue", + rpt, + &ThreadUtilsObject::TestByValue, + mozilla::Move(s)); EXPECT_LE(1, gMoveConstructions); EXPECT_EQ(1, gAlive); EXPECT_EQ(1, gZombies); @@ -1495,7 +1601,10 @@ TEST(ThreadUtils, main) EXPECT_EQ(1, gAlive); if (gDebug) { printf("%d - r5 = NewRunnableMethod>(&TestByConstLRef, s)\n", __LINE__); } r5 = NewRunnableMethod>( - rpt, &ThreadUtilsObject::TestByConstLRef, s); + "TestThreadUtils::ThreadUtilsObject::TestByConstLRef", + rpt, + &ThreadUtilsObject::TestByConstLRef, + s); EXPECT_EQ(2, gAlive); EXPECT_LE(1, gCopyConstructions); // At least 1 copy-construction. Spy::ClearActions(); @@ -1521,9 +1630,11 @@ TEST(ThreadUtils, main) if (gDebug) { printf("%d - Test: Store copy from prvalue, pass by const lvalue ref\n", __LINE__); } { if (gDebug) { printf("%d - r6 = NewRunnableMethod>(&TestByConstLRef, Spy(21))\n", __LINE__); } - nsCOMPtr r6 = - NewRunnableMethod>( - rpt, &ThreadUtilsObject::TestByConstLRef, Spy(21)); + nsCOMPtr r6 = NewRunnableMethod>( + "TestThreadUtils::ThreadUtilsObject::TestByConstLRef", + rpt, + &ThreadUtilsObject::TestByConstLRef, + Spy(21)); EXPECT_EQ(1, gAlive); EXPECT_EQ(1, gConstructions); EXPECT_LE(1, gMoveConstructions); @@ -1552,7 +1663,10 @@ TEST(ThreadUtils, main) EXPECT_EQ(1, gAlive); if (gDebug) { printf("%d - r7 = NewRunnableMethod>(&TestByRRef, s)\n", __LINE__); } r7 = NewRunnableMethod>( - rpt, &ThreadUtilsObject::TestByRRef, s); + "TestThreadUtils::ThreadUtilsObject::TestByRRef", + rpt, + &ThreadUtilsObject::TestByRRef, + s); EXPECT_EQ(2, gAlive); EXPECT_LE(1, gCopyConstructions); // At least 1 copy-construction. Spy::ClearActions(); @@ -1579,9 +1693,11 @@ TEST(ThreadUtils, main) if (gDebug) { printf("%d - Test: Store copy from prvalue, pass by rvalue ref\n", __LINE__); } { if (gDebug) { printf("%d - r8 = NewRunnableMethod>(&TestByRRef, Spy(31))\n", __LINE__); } - nsCOMPtr r8 = - NewRunnableMethod>( - rpt, &ThreadUtilsObject::TestByRRef, Spy(31)); + nsCOMPtr r8 = NewRunnableMethod>( + "TestThreadUtils::ThreadUtilsObject::TestByRRef", + rpt, + &ThreadUtilsObject::TestByRRef, + Spy(31)); EXPECT_EQ(1, gAlive); EXPECT_EQ(1, gConstructions); EXPECT_LE(1, gMoveConstructions); @@ -1610,8 +1726,10 @@ TEST(ThreadUtils, main) Spy::ClearActions(); if (gDebug) { printf("%d - r9 = NewRunnableMethod(&TestByLRef, s)\n", __LINE__); } nsCOMPtr r9 = - NewRunnableMethod( - rpt, &ThreadUtilsObject::TestByLRef, s); + NewRunnableMethod("TestThreadUtils::ThreadUtilsObject::TestByLRef", + rpt, + &ThreadUtilsObject::TestByLRef, + s); EXPECT_EQ(0, gAllConstructions); EXPECT_EQ(0, gDestructions); EXPECT_EQ(1, gAlive); @@ -1643,7 +1761,10 @@ TEST(ThreadUtils, main) EXPECT_EQ(1, gAlive); if (gDebug) { printf("%d - r10 = NewRunnableMethod>(&TestByRRef, s.get())\n", __LINE__); } r10 = NewRunnableMethod>( - rpt, &ThreadUtilsObject::TestByPointer, s.get()); + "TestThreadUtils::ThreadUtilsObject::TestByPointer", + rpt, + &ThreadUtilsObject::TestByPointer, + s.get()); EXPECT_LE(0, gAllConstructions); EXPECT_EQ(1, gAlive); Spy::ClearActions(); @@ -1675,9 +1796,11 @@ TEST(ThreadUtils, main) EXPECT_EQ(1, gAlive); Spy::ClearActions(); if (gDebug) { printf("%d - r11 = NewRunnableMethod(&TestByPointer, s)\n", __LINE__); } - nsCOMPtr r11 = - NewRunnableMethod( - rpt, &ThreadUtilsObject::TestByPointer, &s); + nsCOMPtr r11 = NewRunnableMethod( + "TestThreadUtils::ThreadUtilsObject::TestByPointer", + rpt, + &ThreadUtilsObject::TestByPointer, + &s); EXPECT_EQ(0, gAllConstructions); EXPECT_EQ(0, gDestructions); EXPECT_EQ(1, gAlive); @@ -1705,9 +1828,11 @@ TEST(ThreadUtils, main) EXPECT_EQ(1, gAlive); Spy::ClearActions(); if (gDebug) { printf("%d - r12 = NewRunnableMethod(&TestByPointer, s)\n", __LINE__); } - nsCOMPtr r12 = - NewRunnableMethod( - rpt, &ThreadUtilsObject::TestByPointerToConst, &s); + nsCOMPtr r12 = NewRunnableMethod( + "TestThreadUtils::ThreadUtilsObject::TestByPointerToConst", + rpt, + &ThreadUtilsObject::TestByPointerToConst, + &s); EXPECT_EQ(0, gAllConstructions); EXPECT_EQ(0, gDestructions); EXPECT_EQ(1, gAlive); diff --git a/xpcom/tests/gtest/TestTimers.cpp b/xpcom/tests/gtest/TestTimers.cpp index ce8bba028c3b..2ca87f89a2d3 100644 --- a/xpcom/tests/gtest/TestTimers.cpp +++ b/xpcom/tests/gtest/TestTimers.cpp @@ -242,15 +242,17 @@ public: timer->SetTarget(aTarget); } - timer->InitWithFuncCallback(&UnusedCallbackFunc, - nullptr, - kTimerOffset + kTimerInterval * i, - aType); + timer->InitWithNamedFuncCallback(&UnusedCallbackFunc, + nullptr, + kTimerOffset + kTimerInterval * i, + aType, + "FindExpirationTimeState::InitTimers"); } else { - timer->InitWithFuncCallback(&UnusedCallbackFunc, - nullptr, - kTimerOffset + kTimerInterval * i, - nsITimer::TYPE_ONE_SHOT); + timer->InitWithNamedFuncCallback(&UnusedCallbackFunc, + nullptr, + kTimerOffset + kTimerInterval * i, + nsITimer::TYPE_ONE_SHOT, + "FindExpirationTimeState::InitTimers"); } mTimers.push_front(timer.get()); } @@ -426,8 +428,9 @@ class FuzzTestThreadState final : public nsITimerCallback { class StartRunnable final : public mozilla::Runnable { public: - explicit StartRunnable(FuzzTestThreadState* threadState) : - mThreadState(threadState) + explicit StartRunnable(FuzzTestThreadState* threadState) + : mozilla::Runnable("FuzzTestThreadState::StartRunnable") + , mThreadState(threadState) {} NS_IMETHOD Run() override diff --git a/xpcom/threads/AbstractThread.cpp b/xpcom/threads/AbstractThread.cpp index fc0dd2ec9e89..d8f9c944a42b 100644 --- a/xpcom/threads/AbstractThread.cpp +++ b/xpcom/threads/AbstractThread.cpp @@ -104,7 +104,10 @@ public: if (!mTailDispatcher.isSome()) { mTailDispatcher.emplace(/* aIsTailDispatcher = */ true); - nsCOMPtr event = NewRunnableMethod(this, &EventTargetWrapper::FireTailDispatcher); + nsCOMPtr event = + NewRunnableMethod("EventTargetWrapper::FireTailDispatcher", + this, + &EventTargetWrapper::FireTailDispatcher); nsContentUtils::RunInStableState(event.forget()); } @@ -154,7 +157,8 @@ private: explicit Runner(EventTargetWrapper* aThread, already_AddRefed aRunnable, bool aDrainDirectTasks) - : mThread(aThread) + : CancelableRunnable("EventTargetWrapper::Runner") + , mThread(aThread) , mRunnable(aRunnable) , mDrainDirectTasks(aDrainDirectTasks) { @@ -344,7 +348,8 @@ AbstractThread::CreateXPCOMThreadWrapper(nsIThread* aThread, bool aRequireTailDi // target thread. This ensures that sCurrentThreadTLS is as expected by // AbstractThread::GetCurrent() on the target thread. nsCOMPtr r = - NS_NewRunnableFunction([wrapper]() { sCurrentThreadTLS.set(wrapper); }); + NS_NewRunnableFunction("AbstractThread::CreateXPCOMThreadWrapper", + [wrapper]() { sCurrentThreadTLS.set(wrapper); }); aThread->Dispatch(r.forget(), NS_DISPATCH_NORMAL); return wrapper.forget(); } diff --git a/xpcom/threads/BackgroundHangMonitor.cpp b/xpcom/threads/BackgroundHangMonitor.cpp index cd40198c6fa4..3e6d0694f887 100644 --- a/xpcom/threads/BackgroundHangMonitor.cpp +++ b/xpcom/threads/BackgroundHangMonitor.cpp @@ -446,7 +446,8 @@ public: BackgroundHangThread* aThread, Telemetry::HangHistogram&& aHistogram, Telemetry::NativeHangStack&& aNativeStack) - : mManager(aManager) + : CancelableRunnable("ProcessHangRunnable") + , mManager(aManager) , mNativeStack(mozilla::Move(aNativeStack)) , mThread(aThread) , mHistogram(mozilla::Move(aHistogram)) diff --git a/xpcom/threads/LazyIdleThread.cpp b/xpcom/threads/LazyIdleThread.cpp index 001c4e5893e9..b5b761ed84e4 100644 --- a/xpcom/threads/LazyIdleThread.cpp +++ b/xpcom/threads/LazyIdleThread.cpp @@ -104,7 +104,7 @@ LazyIdleThread::EnableIdleTimeout() } if (mThread) { - nsCOMPtr runnable(new Runnable()); + nsCOMPtr runnable(new Runnable("LazyIdleThreadDummyRunnable")); if (NS_FAILED(Dispatch(runnable.forget(), NS_DISPATCH_NORMAL))) { NS_WARNING("Failed to dispatch!"); } @@ -158,8 +158,8 @@ LazyIdleThread::EnsureThread() return NS_ERROR_UNEXPECTED; } - nsCOMPtr runnable = - NewRunnableMethod(this, &LazyIdleThread::InitThread); + nsCOMPtr runnable = NewRunnableMethod( + "LazyIdleThread::InitThread", this, &LazyIdleThread::InitThread); if (NS_WARN_IF(!runnable)) { return NS_ERROR_UNEXPECTED; } @@ -279,8 +279,8 @@ LazyIdleThread::ShutdownThread() } #endif - nsCOMPtr runnable = - NewRunnableMethod(this, &LazyIdleThread::CleanupThread); + nsCOMPtr runnable = NewRunnableMethod( + "LazyIdleThread::CleanupThread", this, &LazyIdleThread::CleanupThread); if (NS_WARN_IF(!runnable)) { return NS_ERROR_UNEXPECTED; } @@ -356,8 +356,8 @@ LazyIdleThread::Release() // Stabilize refcount. mRefCnt = 1; - nsCOMPtr runnable = - NewNonOwningRunnableMethod(this, &LazyIdleThread::SelfDestruct); + nsCOMPtr runnable = NewNonOwningRunnableMethod( + "LazyIdleThread::SelfDestruct", this, &LazyIdleThread::SelfDestruct); NS_WARNING_ASSERTION(runnable, "Couldn't make runnable!"); if (NS_FAILED(NS_DispatchToCurrentThread(runnable))) { @@ -591,8 +591,8 @@ LazyIdleThread::AfterProcessNextEvent(nsIThreadInternal* /* aThread */, } if (shouldNotifyIdle) { - nsCOMPtr runnable = - NewRunnableMethod(this, &LazyIdleThread::ScheduleTimer); + nsCOMPtr runnable = NewRunnableMethod( + "LazyIdleThread::ScheduleTimer", this, &LazyIdleThread::ScheduleTimer); if (NS_WARN_IF(!runnable)) { return NS_ERROR_UNEXPECTED; } diff --git a/xpcom/threads/MozPromise.h b/xpcom/threads/MozPromise.h index 9933a32a36ca..2c8011f1d43c 100644 --- a/xpcom/threads/MozPromise.h +++ b/xpcom/threads/MozPromise.h @@ -380,7 +380,9 @@ protected: { public: ResolveOrRejectRunnable(ThenValueBase* aThenValue, MozPromise* aPromise) - : mThenValue(aThenValue) + : CancelableRunnable( + "MozPromise::ThenValueBase::ResolveOrRejectRunnable") + , mThenValue(aThenValue) , mPromise(aPromise) { MOZ_DIAGNOSTIC_ASSERT(!mPromise->IsPending()); @@ -1378,9 +1380,14 @@ template* aMethodCall) - : mProxyPromise(aProxyPromise), mMethodCall(aMethodCall) {} + ProxyRunnable( + typename PromiseType::Private* aProxyPromise, + MethodCall* aMethodCall) + : CancelableRunnable("detail::ProxyRunnable") + , mProxyPromise(aProxyPromise) + , mMethodCall(aMethodCall) + { + } NS_IMETHOD Run() override { @@ -1489,11 +1496,14 @@ class ProxyFunctionRunnable : public CancelableRunnable { typedef typename Decay::Type FunctionStorage; public: - template + template ProxyFunctionRunnable(typename PromiseType::Private* aProxyPromise, F&& aFunction) - : mProxyPromise(aProxyPromise) - , mFunction(new FunctionStorage(Forward(aFunction))) {} + : CancelableRunnable("detail::ProxyFunctionRunnable") + , mProxyPromise(aProxyPromise) + , mFunction(new FunctionStorage(Forward(aFunction))) + { + } NS_IMETHOD Run() override { diff --git a/xpcom/threads/SchedulerGroup.cpp b/xpcom/threads/SchedulerGroup.cpp index 81e14d05bf7c..8bd0f60ccb57 100644 --- a/xpcom/threads/SchedulerGroup.cpp +++ b/xpcom/threads/SchedulerGroup.cpp @@ -331,8 +331,9 @@ SchedulerGroup::SetValidatingAccess(ValidationType aType) SchedulerGroup::Runnable::Runnable(already_AddRefed&& aRunnable, SchedulerGroup* aGroup) - : mRunnable(Move(aRunnable)), - mGroup(aGroup) + : mozilla::Runnable("SchedulerGroup::Runnable") + , mRunnable(Move(aRunnable)) + , mGroup(aGroup) { } diff --git a/xpcom/threads/SharedThreadPool.cpp b/xpcom/threads/SharedThreadPool.cpp index d52878c741aa..314b0cc2a0c5 100644 --- a/xpcom/threads/SharedThreadPool.cpp +++ b/xpcom/threads/SharedThreadPool.cpp @@ -143,7 +143,8 @@ NS_IMETHODIMP_(MozExternalRefCountType) SharedThreadPool::Release(void) // Dispatch an event to the main thread to call Shutdown() on // the nsIThreadPool. The Runnable here will add a refcount to the pool, // and when the Runnable releases the nsIThreadPool it will be deleted. - NS_DispatchToMainThread(NewRunnableMethod(mPool, &nsIThreadPool::Shutdown)); + NS_DispatchToMainThread(NewRunnableMethod( + "nsIThreadPool::Shutdown", 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 669e928a666f..ef883f9061db 100644 --- a/xpcom/threads/StateMirroring.h +++ b/xpcom/threads/StateMirroring.h @@ -152,9 +152,11 @@ private: { MIRROR_LOG("%s [%p] Disconnecting all mirrors", mName, this); for (size_t i = 0; i < mMirrors.Length(); ++i) { - mMirrors[i]->OwnerThread()->Dispatch(NewRunnableMethod(mMirrors[i], - &AbstractMirror::NotifyDisconnected), - AbstractThread::DontAssertDispatchSuccess); + mMirrors[i]->OwnerThread()->Dispatch( + NewRunnableMethod("AbstractMirror::NotifyDisconnected", + mMirrors[i], + &AbstractMirror::NotifyDisconnected), + AbstractThread::DontAssertDispatchSuccess); } mMirrors.Clear(); } @@ -191,7 +193,8 @@ 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) { - AbstractThread::DispatchDirectTask(NewRunnableMethod(this, &Impl::DoNotify)); + AbstractThread::DispatchDirectTask(NewRunnableMethod( + "Canonical::Impl::DoNotify", this, &Impl::DoNotify)); } } @@ -222,7 +225,11 @@ private: already_AddRefed MakeNotifier(AbstractMirror* aMirror) { - return NewRunnableMethod(aMirror, &AbstractMirror::UpdateValue, mValue);; + return NewRunnableMethod("AbstractMirror::UpdateValue", + aMirror, + &AbstractMirror::UpdateValue, + mValue); + ; } T mValue; @@ -325,8 +332,12 @@ private: MOZ_ASSERT(!IsConnected()); MOZ_ASSERT(OwnerThread()->RequiresTailDispatch(aCanonical->OwnerThread()), "Can't get coherency without tail dispatch"); - nsCOMPtr r = NewRunnableMethod>> - (aCanonical, &AbstractCanonical::AddMirror, this); + nsCOMPtr r = + NewRunnableMethod>>( + "AbstractCanonical::AddMirror", + aCanonical, + &AbstractCanonical::AddMirror, + this); aCanonical->OwnerThread()->Dispatch(r.forget(), AbstractThread::DontAssertDispatchSuccess); mCanonical = aCanonical; } @@ -340,8 +351,12 @@ private: } MIRROR_LOG("%s [%p] Disconnecting from %p", mName, this, mCanonical.get()); - nsCOMPtr r = NewRunnableMethod>> - (mCanonical, &AbstractCanonical::RemoveMirror, this); + nsCOMPtr r = + NewRunnableMethod>>( + "AbstractCanonical::RemoveMirror", + 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 99d521603e3a..351f59915b58 100644 --- a/xpcom/threads/StateWatching.h +++ b/xpcom/threads/StateWatching.h @@ -256,7 +256,10 @@ private: mStrongRef = mOwner; // Hold the owner alive while notifying. // Queue up our notification jobs to run in a stable state. - mOwnerThread->TailDispatcher().AddDirectTask(NewRunnableMethod(this, &PerCallbackWatcher::DoNotify)); + mOwnerThread->TailDispatcher().AddDirectTask( + NewRunnableMethod("WatchManager::PerCallbackWatcher::DoNotify", + this, + &PerCallbackWatcher::DoNotify)); } bool CallbackMethodIs(CallbackMethod aMethod) const diff --git a/xpcom/threads/SyncRunnable.h b/xpcom/threads/SyncRunnable.h index d96bac7ba907..ff617e5a7069 100644 --- a/xpcom/threads/SyncRunnable.h +++ b/xpcom/threads/SyncRunnable.h @@ -34,14 +34,16 @@ class SyncRunnable : public Runnable { public: explicit SyncRunnable(nsIRunnable* aRunnable) - : mRunnable(aRunnable) + : Runnable("SyncRunnable") + , mRunnable(aRunnable) , mMonitor("SyncRunnable") , mDone(false) { } explicit SyncRunnable(already_AddRefed aRunnable) - : mRunnable(Move(aRunnable)) + : Runnable("SyncRunnable") + , mRunnable(Move(aRunnable)) , mMonitor("SyncRunnable") , mDone(false) { diff --git a/xpcom/threads/TaskDispatcher.h b/xpcom/threads/TaskDispatcher.h index 52e810ffb531..a23f017d2ca2 100644 --- a/xpcom/threads/TaskDispatcher.h +++ b/xpcom/threads/TaskDispatcher.h @@ -185,7 +185,11 @@ private: class TaskGroupRunnable : public Runnable { public: - explicit TaskGroupRunnable(UniquePtr&& aTasks) : mTasks(Move(aTasks)) {} + explicit TaskGroupRunnable(UniquePtr&& aTasks) + : Runnable("AutoTaskDispatcher::TaskGroupRunnable") + , mTasks(Move(aTasks)) + { + } NS_IMETHOD Run() override { diff --git a/xpcom/threads/TaskQueue.h b/xpcom/threads/TaskQueue.h index b5f71ec756c1..b97586c8eccb 100644 --- a/xpcom/threads/TaskQueue.h +++ b/xpcom/threads/TaskQueue.h @@ -203,7 +203,8 @@ protected: class Runner : public Runnable { public: explicit Runner(TaskQueue* aQueue) - : mQueue(aQueue) + : Runnable("TaskQueue::Runner") + , mQueue(aQueue) { } NS_IMETHOD Run() override; diff --git a/xpcom/threads/ThrottledEventQueue.cpp b/xpcom/threads/ThrottledEventQueue.cpp index 501157a1fb51..37afc70fae7a 100644 --- a/xpcom/threads/ThrottledEventQueue.cpp +++ b/xpcom/threads/ThrottledEventQueue.cpp @@ -65,7 +65,8 @@ class ThrottledEventQueue::Inner final : public nsIObserver public: explicit Executor(Inner* aInner) - : mInner(aInner) + : Runnable("ThrottledEventQueue::Inner::Executor") + , mInner(aInner) { } NS_IMETHODIMP diff --git a/xpcom/threads/TimerThread.cpp b/xpcom/threads/TimerThread.cpp index 3a889549534b..b91b27b2073a 100644 --- a/xpcom/threads/TimerThread.cpp +++ b/xpcom/threads/TimerThread.cpp @@ -58,7 +58,8 @@ class TimerObserverRunnable : public Runnable { public: explicit TimerObserverRunnable(nsIObserver* aObserver) - : mObserver(aObserver) + : mozilla::Runnable("TimerObserverRunnable") + , mObserver(aObserver) { } @@ -147,7 +148,8 @@ public: NS_IMETHOD GetName(nsACString& aName) override; nsTimerEvent() - : mTimer() + : mozilla::CancelableRunnable("nsTimerEvent") + , mTimer() , mGeneration(0) { // Note: We override operator new for this class, and the override is diff --git a/xpcom/threads/nsMemoryPressure.cpp b/xpcom/threads/nsMemoryPressure.cpp index fea9b0437888..30d27c2989e0 100644 --- a/xpcom/threads/nsMemoryPressure.cpp +++ b/xpcom/threads/nsMemoryPressure.cpp @@ -49,6 +49,6 @@ nsresult NS_DispatchMemoryPressure(MemoryPressureState aState) { NS_DispatchEventualMemoryPressure(aState); - nsCOMPtr event = new Runnable; + nsCOMPtr event = new Runnable("NS_DispatchEventualMemoryPressure"); return NS_DispatchToMainThread(event); } diff --git a/xpcom/threads/nsProcessCommon.cpp b/xpcom/threads/nsProcessCommon.cpp index 7c4a4856d57c..844139a5635a 100644 --- a/xpcom/threads/nsProcessCommon.cpp +++ b/xpcom/threads/nsProcessCommon.cpp @@ -307,7 +307,8 @@ nsProcess::Monitor(void* aArg) if (NS_IsMainThread()) { process->ProcessComplete(); } else { - NS_DispatchToMainThread(NewRunnableMethod(process, &nsProcess::ProcessComplete)); + NS_DispatchToMainThread(NewRunnableMethod( + "nsProcess::ProcessComplete", process, &nsProcess::ProcessComplete)); } if (!process->mBlocking) { diff --git a/xpcom/threads/nsThread.cpp b/xpcom/threads/nsThread.cpp index 84a7dc19a86f..5c78a0fadb5a 100644 --- a/xpcom/threads/nsThread.cpp +++ b/xpcom/threads/nsThread.cpp @@ -240,10 +240,11 @@ public: DelayedRunnable(already_AddRefed aTargetThread, already_AddRefed aRunnable, uint32_t aDelay) - : mTargetThread(aTargetThread), - mWrappedRunnable(aRunnable), - mDelayedFrom(TimeStamp::NowLoRes()), - mDelay(aDelay) + : mozilla::Runnable("DelayedRunnable") + , mTargetThread(aTargetThread) + , mWrappedRunnable(aRunnable) + , mDelayedFrom(TimeStamp::NowLoRes()) + , mDelay(aDelay) { } NS_DECL_ISUPPORTS_INHERITED diff --git a/xpcom/threads/nsThreadUtils.cpp b/xpcom/threads/nsThreadUtils.cpp index d85d5afd7e55..77c3f7fe93a9 100644 --- a/xpcom/threads/nsThreadUtils.cpp +++ b/xpcom/threads/nsThreadUtils.cpp @@ -342,8 +342,11 @@ public: mTimer = do_CreateInstance(NS_TIMER_CONTRACTID); if (mTimer) { mTimer->SetTarget(aTarget); - mTimer->InitWithFuncCallback(TimedOut, this, aDelay, - nsITimer::TYPE_ONE_SHOT); + mTimer->InitWithNamedFuncCallback(TimedOut, + this, + aDelay, + nsITimer::TYPE_ONE_SHOT, + "IdleRunnableWrapper::SetTimer"); } } private: diff --git a/xpcom/threads/nsThreadUtils.h b/xpcom/threads/nsThreadUtils.h index a8e8c898377f..d0db6e2c7074 100644 --- a/xpcom/threads/nsThreadUtils.h +++ b/xpcom/threads/nsThreadUtils.h @@ -472,7 +472,10 @@ class IdleRunnable : public CancelableRunnable, public: NS_DECL_ISUPPORTS_INHERITED - IdleRunnable() {} + IdleRunnable() + : CancelableRunnable("IdleRunnable") + { + } explicit IdleRunnable(const char* aName) : CancelableRunnable(aName) {} protected: @@ -494,7 +497,8 @@ class RunnableFunction : public Runnable public: template explicit RunnableFunction(F&& aFunction) - : mFunction(Forward(aFunction)) + : Runnable("RunnableFunction") + , mFunction(Forward(aFunction)) { } NS_IMETHOD Run() override { @@ -613,7 +617,7 @@ ToSupports(mozilla::Runnable *p) template already_AddRefed -NS_NewRunnableFunction(Function&& aFunction) +NS_NewRunnableFunctionXXX(Function&& aFunction) { // We store a non-reference in RunnableFunction, but still forward aFunction // to move if possible. @@ -626,7 +630,7 @@ already_AddRefed NS_NewRunnableFunction(const char* aName, Function&& aFunction) { return mozilla::detail::SetRunnableName( - NS_NewRunnableFunction(mozilla::Forward(aFunction)), aName); + NS_NewRunnableFunctionXXX(mozilla::Forward(aFunction)), aName); } namespace mozilla { @@ -693,7 +697,15 @@ class nsRunnableMethod mozilla::IdleRunnable>::Type>::Type, protected mozilla::detail::TimerBehaviour { + using BaseType = typename mozilla::Conditional::Type>::Type; public: + nsRunnableMethod() : BaseType("nsRunnableMethod") {} + virtual void Revoke() = 0; // These ReturnTypeEnforcer classes set up a blacklist for return types that @@ -1210,8 +1222,11 @@ public: if (nsCOMPtr timer = GetTimer()) { timer->Cancel(); timer->SetTarget(aTarget); - timer->InitWithFuncCallback(TimedOut, this, aDelay, - nsITimer::TYPE_ONE_SHOT); + timer->InitWithNamedFuncCallback(TimedOut, + this, + aDelay, + nsITimer::TYPE_ONE_SHOT, + "detail::RunnableMethodImpl::SetTimer"); } } }; @@ -1370,7 +1385,7 @@ using NonOwningIdleRunnableMethodWithTimerImpl = RunnableMethodImpl< template already_AddRefed> -NewRunnableMethod(PtrType&& aPtr, Method aMethod) +NewRunnableMethodXXX(PtrType&& aPtr, Method aMethod) { return do_AddRef( new detail::OwningRunnableMethodImpl @@ -1382,12 +1397,12 @@ already_AddRefed> NewRunnableMethod(const char* aName, PtrType&& aPtr, Method aMethod) { return detail::SetRunnableName( - NewRunnableMethod(Forward(aPtr), aMethod), aName); + NewRunnableMethodXXX(Forward(aPtr), aMethod), aName); } template already_AddRefed> -NewCancelableRunnableMethod(PtrType&& aPtr, Method aMethod) +NewCancelableRunnableMethodXXX(PtrType&& aPtr, Method aMethod) { return do_AddRef( new detail::CancelableRunnableMethodImpl @@ -1399,12 +1414,12 @@ already_AddRefed> NewCancelableRunnableMethod(const char* aName, PtrType&& aPtr, Method aMethod) { return detail::SetRunnableName( - NewCancelableRunnableMethod(Forward(aPtr), aMethod), aName); + NewCancelableRunnableMethodXXX(Forward(aPtr), aMethod), aName); } template already_AddRefed> -NewIdleRunnableMethod(PtrType&& aPtr, Method aMethod) +NewIdleRunnableMethodXXX(PtrType&& aPtr, Method aMethod) { return do_AddRef(new detail::IdleRunnableMethodImpl( Forward(aPtr), aMethod)); @@ -1415,12 +1430,12 @@ already_AddRefed> NewIdleRunnableMethod(const char* aName, PtrType&& aPtr, Method aMethod) { return detail::SetRunnableName( - NewIdleRunnableMethod(Forward(aPtr), aMethod), aName); + NewIdleRunnableMethodXXX(Forward(aPtr), aMethod), aName); } template already_AddRefed> -NewIdleRunnableMethodWithTimer(PtrType&& aPtr, Method aMethod) +NewIdleRunnableMethodWithTimerXXX(PtrType&& aPtr, Method aMethod) { return do_AddRef(new detail::IdleRunnableMethodWithTimerImpl( Forward(aPtr), aMethod)); @@ -1433,13 +1448,13 @@ NewIdleRunnableMethodWithTimer(const char* aName, Method aMethod) { return detail::SetRunnableName( - NewIdleRunnableMethodWithTimer(Forward(aPtr), aMethod), + NewIdleRunnableMethodWithTimerXXX(Forward(aPtr), aMethod), aName); } template already_AddRefed> -NewNonOwningRunnableMethod(PtrType&& aPtr, Method aMethod) +NewNonOwningRunnableMethodXXX(PtrType&& aPtr, Method aMethod) { return do_AddRef( new detail::NonOwningRunnableMethodImpl @@ -1451,12 +1466,12 @@ already_AddRefed> NewNonOwningRunnableMethod(const char* aName, PtrType&& aPtr, Method aMethod) { return detail::SetRunnableName( - NewNonOwningRunnableMethod(Forward(aPtr), aMethod), aName); + NewNonOwningRunnableMethodXXX(Forward(aPtr), aMethod), aName); } template already_AddRefed> -NewNonOwningCancelableRunnableMethod(PtrType&& aPtr, Method aMethod) +NewNonOwningCancelableRunnableMethodXXX(PtrType&& aPtr, Method aMethod) { return do_AddRef( new detail::NonOwningCancelableRunnableMethodImpl @@ -1469,12 +1484,12 @@ NewNonOwningCancelableRunnableMethod(const char* aName, PtrType&& aPtr, Method aMethod) { return detail::SetRunnableName( - NewNonOwningCancelableRunnableMethod(Forward(aPtr), aMethod), aName); + NewNonOwningCancelableRunnableMethodXXX(Forward(aPtr), aMethod), aName); } template already_AddRefed> -NewNonOwningIdleRunnableMethod(PtrType&& aPtr, Method aMethod) +NewNonOwningIdleRunnableMethodXXX(PtrType&& aPtr, Method aMethod) { return do_AddRef( new detail::NonOwningIdleRunnableMethodImpl( @@ -1488,12 +1503,12 @@ NewNonOwningIdleRunnableMethod(const char* aName, Method aMethod) { return detail::SetRunnableName( - NewNonOwningIdleRunnableMethod(Forward(aPtr), aMethod), aName); + NewNonOwningIdleRunnableMethodXXX(Forward(aPtr), aMethod), aName); } template already_AddRefed> -NewNonOwningIdleRunnableMethodWithTimer(PtrType&& aPtr, +NewNonOwningIdleRunnableMethodWithTimerXXX(PtrType&& aPtr, Method aMethod) { return do_AddRef( @@ -1507,7 +1522,7 @@ NewNonOwningIdleRunnableMethodWithTimer(const char* aName, PtrType&& aPtr, Method aMethod) { - return detail::SetRunnableName(NewNonOwningIdleRunnableMethodWithTimer( + return detail::SetRunnableName(NewNonOwningIdleRunnableMethodWithTimerXXX( Forward(aPtr), aMethod), aName); } @@ -1518,7 +1533,7 @@ NewNonOwningIdleRunnableMethodWithTimer(const char* aName, // 'Types' are the stored type for each argument, see ParameterStorage for details. template already_AddRefed> -NewRunnableMethod(PtrType&& aPtr, Method aMethod, Args&&... aArgs) +NewRunnableMethodXXX(PtrType&& aPtr, Method aMethod, Args&&... aArgs) { static_assert(sizeof...(Storages) == sizeof...(Args), " size should be equal to number of arguments"); @@ -1534,13 +1549,13 @@ NewRunnableMethod(const char* aName, PtrType&& aPtr, Method aMethod, Args&&... a static_assert(sizeof...(Storages) == sizeof...(Args), " size should be equal to number of arguments"); return detail::SetRunnableName( - NewRunnableMethod + NewRunnableMethodXXX (Forward(aPtr), aMethod, mozilla::Forward(aArgs)...), aName); } template already_AddRefed> -NewNonOwningRunnableMethod(PtrType&& aPtr, Method aMethod, Args&&... aArgs) +NewNonOwningRunnableMethodXXX(PtrType&& aPtr, Method aMethod, Args&&... aArgs) { static_assert(sizeof...(Storages) == sizeof...(Args), " size should be equal to number of arguments"); @@ -1557,13 +1572,13 @@ NewNonOwningRunnableMethod(const char* aName, PtrType&& aPtr, Method aMethod, static_assert(sizeof...(Storages) == sizeof...(Args), " size should be equal to number of arguments"); return detail::SetRunnableName( - NewNonOwningRunnableMethod + NewNonOwningRunnableMethodXXX (Forward(aPtr), aMethod, mozilla::Forward(aArgs)...), aName); } template already_AddRefed> -NewCancelableRunnableMethod(PtrType&& aPtr, Method aMethod, Args&&... aArgs) +NewCancelableRunnableMethodXXX(PtrType&& aPtr, Method aMethod, Args&&... aArgs) { static_assert(sizeof...(Storages) == sizeof...(Args), " size should be equal to number of arguments"); @@ -1580,13 +1595,13 @@ NewCancelableRunnableMethod(const char* aName, PtrType&& aPtr, Method aMethod, static_assert(sizeof...(Storages) == sizeof...(Args), " size should be equal to number of arguments"); return detail::SetRunnableName( - NewCancelableRunnableMethod + NewCancelableRunnableMethodXXX (Forward(aPtr), aMethod, mozilla::Forward(aArgs)...), aName); } template already_AddRefed> -NewNonOwningCancelableRunnableMethod(PtrType&& aPtr, Method aMethod, +NewNonOwningCancelableRunnableMethodXXX(PtrType&& aPtr, Method aMethod, Args&&... aArgs) { static_assert(sizeof...(Storages) == sizeof...(Args), @@ -1604,7 +1619,7 @@ NewNonOwningCancelableRunnableMethod(const char* aName, PtrType&& aPtr, static_assert(sizeof...(Storages) == sizeof...(Args), " size should be equal to number of arguments"); return detail::SetRunnableName( - NewNonOwningCancelableRunnableMethod + NewNonOwningCancelableRunnableMethodXXX (Forward(aPtr), aMethod, mozilla::Forward(aArgs)...), aName); } @@ -1613,7 +1628,7 @@ template already_AddRefed> -NewIdleRunnableMethod(PtrType&& aPtr, Method aMethod, Args&&... aArgs) +NewIdleRunnableMethodXXX(PtrType&& aPtr, Method aMethod, Args&&... aArgs) { static_assert(sizeof...(Storages) == sizeof...(Args), " size should be equal to number of arguments"); @@ -1635,7 +1650,7 @@ NewIdleRunnableMethod(const char* aName, static_assert(sizeof...(Storages) == sizeof...(Args), " size should be equal to number of arguments"); return detail::SetRunnableName( - NewIdleRunnableMethod( + NewIdleRunnableMethodXXX( Forward(aPtr), aMethod, mozilla::Forward(aArgs)...), aName); } @@ -1645,7 +1660,7 @@ template already_AddRefed> -NewNonOwningIdleRunnableMethod(PtrType&& aPtr, Method aMethod, Args&&... aArgs) +NewNonOwningIdleRunnableMethodXXX(PtrType&& aPtr, Method aMethod, Args&&... aArgs) { static_assert(sizeof...(Storages) == sizeof...(Args), " size should be equal to number of arguments"); @@ -1667,7 +1682,7 @@ NewNonOwningIdleRunnableMethod(const char* aName, static_assert(sizeof...(Storages) == sizeof...(Args), " size should be equal to number of arguments"); return detail::SetRunnableName( - NewNonOwningIdleRunnableMethod( + NewNonOwningIdleRunnableMethodXXX( Forward(aPtr), aMethod, mozilla::Forward(aArgs)...), aName); } diff --git a/xpfe/appshell/nsAppShellService.cpp b/xpfe/appshell/nsAppShellService.cpp index 63aa3699e816..f93528a05b3c 100644 --- a/xpfe/appshell/nsAppShellService.cpp +++ b/xpfe/appshell/nsAppShellService.cpp @@ -404,9 +404,10 @@ WebBrowserChrome2Stub::Blur() class BrowserDestroyer final : public Runnable { public: - BrowserDestroyer(nsIWebBrowser *aBrowser, nsISupports *aContainer) : - mBrowser(aBrowser), - mContainer(aContainer) + BrowserDestroyer(nsIWebBrowser* aBrowser, nsISupports* aContainer) + : mozilla::Runnable("BrowserDestroyer") + , mBrowser(aBrowser) + , mContainer(aContainer) { } diff --git a/xpfe/appshell/nsContentTreeOwner.cpp b/xpfe/appshell/nsContentTreeOwner.cpp index d9067cea541a..1a73de11a5df 100644 --- a/xpfe/appshell/nsContentTreeOwner.cpp +++ b/xpfe/appshell/nsContentTreeOwner.cpp @@ -942,7 +942,8 @@ class nsContentTitleSettingEvent : public Runnable { public: nsContentTitleSettingEvent(dom::Element* dse, const nsAString& wtm) - : mElement(dse), + : Runnable("nsContentTitleSettingEvent"), + mElement(dse), mTitleDefault(wtm) {} NS_IMETHOD Run() override diff --git a/xpfe/components/directory/nsDirectoryViewer.cpp b/xpfe/components/directory/nsDirectoryViewer.cpp index 6acda8805c09..f1dff24fe569 100644 --- a/xpfe/components/directory/nsDirectoryViewer.cpp +++ b/xpfe/components/directory/nsDirectoryViewer.cpp @@ -863,11 +863,15 @@ nsHTTPIndex::GetTargets(nsIRDFResource *aSource, nsIRDFResource *aProperty, bool NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create a timer"); if (NS_SUCCEEDED(rv)) { - mTimer->InitWithFuncCallback(nsHTTPIndex::FireTimer, this, 1, - nsITimer::TYPE_ONE_SHOT); - // Note: don't addref "this" as we'll cancel the - // timer in the httpIndex destructor - } + mTimer->InitWithNamedFuncCallback( + nsHTTPIndex::FireTimer, + this, + 1, + nsITimer::TYPE_ONE_SHOT, + "nsHTTPIndex::GetTargets"); + // Note: don't addref "this" as we'll cancel the + // timer in the httpIndex destructor + } } } } @@ -898,11 +902,14 @@ nsHTTPIndex::AddElement(nsIRDFResource *parent, nsIRDFResource *prop, nsIRDFNode NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create a timer"); if (NS_FAILED(rv)) return(rv); - mTimer->InitWithFuncCallback(nsHTTPIndex::FireTimer, this, 1, - nsITimer::TYPE_ONE_SHOT); - // Note: don't addref "this" as we'll cancel the - // timer in the httpIndex destructor - } + mTimer->InitWithNamedFuncCallback(nsHTTPIndex::FireTimer, + this, + 1, + nsITimer::TYPE_ONE_SHOT, + "nsHTTPIndex::AddElement"); + // Note: don't addref "this" as we'll cancel the + // timer in the httpIndex destructor + } return(NS_OK); } @@ -1031,8 +1038,11 @@ nsHTTPIndex::FireTimer(nsITimer* aTimer, void* aClosure) httpIndex->mTimer = do_CreateInstance("@mozilla.org/timer;1"); if (httpIndex->mTimer) { - httpIndex->mTimer->InitWithFuncCallback(nsHTTPIndex::FireTimer, aClosure, 10, - nsITimer::TYPE_ONE_SHOT); + httpIndex->mTimer->InitWithNamedFuncCallback(nsHTTPIndex::FireTimer, + aClosure, + 10, + nsITimer::TYPE_ONE_SHOT, + "nsHTTPIndex::FireTimer"); // Note: don't addref "this" as we'll cancel the // timer in the httpIndex destructor }