From 86a3aa0b540b4c8a3d4c627cb7b1da9ff5c04d3b Mon Sep 17 00:00:00 2001 From: roytam1 Date: Tue, 6 Dec 2022 13:48:22 +0800 Subject: [PATCH] import changes from `dev' branch of rmottola/Arctic-Fox: - missing part of Bug 1165772: P1. (7311039be4) - missing gstreamer stuff (54a80d69b2) - Bug 1214208: Do not use MP3Decoder on B2G. r=alfredo (0a19e7946e) - Bug 1194014 - Remove redundant includes. r=jya (ccc3753113) - Bug 1039639 - Add support for Flac on Firefox OS. r=cajbir (7d76197e07) - Bug 875573 - Add video/x-m4v mime type. r=kentuckyfriedtakahe (6ec8af93e6) - cleanup (6fb3d5dd26) - Bug 1180621 - [FxOS] Enable VP9 codec for the Android version after KK. r=sotaro (58f7c2b657) - Bug 1187247: [MSE] P2. Enable WebM in MediaSource. r=jya (2df0ee1f7a) - Bug 1187247: [MSE] P1. Continue parsing MediaSegment if buffer starts with SimpleBlock/Block. r=kinetik (574475ed6f) - Bug 1217170: P1. Rename functions to explicitly reflect what they are doing. r=kentuckyfriedtakahe (70c81a8179) - Bug 1070216 - Split DOMMediaStream::InitStreamCommon into three. r=roc (1bda71cc88) - Bug 1215582 - Rename Blacklist to Block list in GStreamerFormatReader. r=gerald (4f08077f5e) - Bug 1170958 - Destroy track-locked MediaInputPorts when the track ends. r=roc (ff3922a2d6) - Bug 1070216 - constify DOMMediaStream::Get[Audio/Video]Tracks(). r=roc (ba09f6f191) - Bug 1070216 - Guard against adding a track owned by one MSG to a stream owned by another. r=padenot (a80deb8b30) - Bug 1070216 - Implement MediaStream constructors. r=smaug,jib,padenot (3403ef2599) - Bug 1070216 - Guard against a null MediaInputPort in DOMMediaStream::FindPlaybackDOMTrack(). r=roc (453a9ffbc1) - Bug 1212783 - Expose TrackPort in DOMMediaStream.h r=roc (fb61c79ae7) - Bug 1219711 - Ensure MediaStreamTrack.enabled propagates across peer connections. r=jesup (d9d1e54dae) - Bug 1129051 - Fix double free in Camera Control Listener. Fix webrtc memory leak. r=aosmond (3e9b3bccfd) - Bug 1152260 - Generate focused event for drivers that do not notify us when using continuous auto focus. r=mikeh (6c7bd42fdc) - Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz (51b2c66dc7) - Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz (c54c735e37) - Bug 1187364 - Part 2. Ensure that recording is resumed with a key frame. r=mchiang (c1c6048982) - Bug 1187364 - Part 3. Fix missing end comment in WebIDL. r=me,bz (7faf106cc1) - Bug 1212783 - Add a MediaStreamTrack to DOMCameraControl. r=aosmond (91e11efd3a) - Bug 1124338 - Fix possible camera cached parameters invalidation from underlying driver modification. r=aosmond (dea67dc155) - Bug 1196330 - Do not restart preview if configuration is unchanged. r=dhylands (097644f5d9) - Bug 1215372 - Filter empty camera face detected events at gonk layer. r=dhylands (733efe50eb) - Bug 1179726 - Prefer lower resolutions than 4kuhd as the default video recording profile. r=dhylands (27c71273dc) - Bug 1222122 - Add picture size to verified parameters when reconfiguring the camera. r=dhylands (8c1fac6a4a) - Bug 1141267 - register CameraThread with profiler, r=aosmond (299592a024) - Bug 1008483 - removes the RW lock in CameraControlImpl and replaces it with a standard mutex. r=aosmond (45936cb90d) - Bug 1008483 - Part 2. Readd missing nsPrintfCString.h include which has broken some local builds. r=me (9dd84b0f19) - Bug 1191731 - Update poster API to allow application control over when poster is saved. r=bz, r=dhylands (73f9e7e0f4) - Bug 1155648 - Fix documentation for DOMMediaStream::OnTracksAvailable. r=jesup (702828c304) - Bug 1217170: [MSE] P2. Enable WebM/MSE on systems with no MP4/H264 support. r=kentuckyfriedtakahe (0b814b0708) - Bug 1213177: Enable WebM on machines where H264 HW decoding is disabled. r=kentuckyfriedtakahe (e64da2ea24) - add back some sps telemetry (52c2c64f5b) - missing bit of Bug 1195073: [MSE/webm] P1 (9c45e82c3d) - Bug 1150305 - sourcebuffer.buffered returns the same object if not changed. r=roc, r=bz, r=jya (6005d56c0c) - Bug 1215447 - move flag setting from SeekStarted() to Seek(). r=roc. (a646b744c1) - Bug 1119936 - Audio from FM Radio or Music app ceases to play when switching between front/back camera. r=roc (1a60aa7d69) - Bug 1186806 - Part 1: Replace nsBaseHashtable::EnumerateRead() with iterators in HTMLFormControlsCollection. r=khuey (ccb8cb180a) - Bug 1186806 - Part 2: Use NS_IMPL_CYCLE_COLLECTION_TRAVERSE instead of manual traversal in HTMLFormElement. r=khuey (57e6eabf1b) - Bug 1186806 - Part 3: Replace nsBaseHashtable::EnumerateRead() with iterators in HTMLMediaElement. r=khuey (243ef6e83b) - Bug 1186806 - Part 4: Replace nsBaseHashtable::EnumerateRead() with iterators in HTMLPropertiesCollection. r=khuey (499bdef85f) - Bug 1163958 - Reduce the allocation in MediaStreamGraph - patch 3 CLOSED TREE (a557661df1) - Bug 1219330 - Prevent the creation of TextureClient after shutdown. r=mattwoodrow (a6c047d54f) - Bug 1205559: Make TextureChild/TextureClient thread-safe. r=nical (307c089631) - missing bit of 1219330 (0e351ea419) - nsRefPtr -> RefPtr (07ba248e69) - Bug 1215023. Part 1 - make MediaDecoder::mOwner a const member. We will check mShuttingDown before calling functions of mOwner. r=kinetik. (da7f201815) - Bug 1215023. Part 2 - remove null check of mOwner. We check mShuttingDown to know whether it is valid to call functions of mOwner. r=kinetik. (8d28a04bbe) - Bug 1220558. Part 2 - remove unused members. r=jya. (d3a9ed8c68) - Bug 1223599 - Remove the throttling argument from AbstractMediaDecoder::NotifyDataArrived(). r=jya. (320323ff1d) - Bug 1194606 - Make MediaDecoderStateMachine capable of requesting different kind (decoded/raw) of media data. r=jya (1e2b6a5c44) - Bug 1197075: P3. Decode frames ahead of MDSM requesting them. r=edwin This makes the media.*-decode-ahead pref performs more according to its name. We decode audio and video in advance so a MediaDataPromise can be resolved almost instantly. Default is 2. (b3f56447c4) - Bug 1189964 - Fix bustage. r=bustage CLOSED TREE (afaa49b4b5) - Bug 1212149 - e10s support for opening notification settings. r=wchen (f0e7778fb6) - Bug 1215644 - Use child process volume service cache for available and storage status requests. r=dhylands (dfd49f2ef3) - bug 1215552 - nsHttpConnectionMgr::PostEvent shouldnt manually ref count r=hurley (5e2f1886e6) - Bug 1219392 - Capitalize mozilla::unused to avoid conflicts. r=froydnj (0c8bb7f15a) - bug 1217834 - buzzfeed packet loss r=dragana (e9a60b605f) - Bug 1168033 - Add a comment to nsHttpConnectionMgr.cpp explaining the assignment of attemptedOptimisticPipeline. r=mcmanus (2451996350) - bug 1189645 - remove spdy telem r=hurley (cda90abbdb) - Bug 1148268 - fixed misspelling attribute mActorDestoryed. r=dhyland. (3615d68765) - Bug 1216031 - Make MediaDecoder::mVideoFrameContainer const. r=kinetik. (a3feb9d6bc) - missing bits of Bug 1165515 - Part 13-2 (009e32281f) - Bug 1131473 - crash in -[NativeMenuItemTarget menuItemHit:]. r=spohl (ea2da6441c) - Bug 1216416 - Fix -Wimplicit-fallthrough warnings in widget/cocoa. r=spohl (faaa390b20) - Bug 1181977 - Firefox app menu contains only "Quit" in certain edgecases. r=spohl (0b9d912961) --- accessible/ipc/ProxyAccessible.cpp | 256 +++++----- caps/DomainPolicy.cpp | 2 +- chrome/nsChromeRegistryChrome.cpp | 2 +- docshell/base/nsDocShell.cpp | 2 +- dom/asmjscache/AsmJSCache.cpp | 10 +- dom/base/ImageEncoder.cpp | 2 +- dom/base/nsContentPermissionHelper.cpp | 12 +- dom/base/nsFocusManager.cpp | 2 +- dom/base/nsFrameLoader.cpp | 12 +- dom/base/nsGkAtomList.h | 1 + dom/base/nsGlobalWindow.cpp | 6 +- dom/base/nsScriptLoader.cpp | 6 +- dom/bindings/Bindings.conf | 4 - .../BluetoothDaemonA2dpInterface.cpp | 4 +- .../BluetoothDaemonAvrcpInterface.cpp | 20 +- .../BluetoothDaemonCoreInterface.cpp | 40 +- .../BluetoothDaemonGattInterface.cpp | 70 +-- .../BluetoothDaemonHandsfreeInterface.cpp | 30 +- .../bluedroid/BluetoothDaemonInterface.cpp | 4 +- .../BluetoothDaemonSetupInterface.cpp | 6 +- .../BluetoothDaemonSocketInterface.cpp | 4 +- .../bluedroid/BluetoothServiceBluedroid.cpp | 2 +- dom/bluetooth/bluez/BluetoothDBusService.cpp | 26 +- dom/bluetooth/common/BluetoothService.cpp | 2 +- dom/bluetooth/ipc/BluetoothParent.cpp | 6 +- .../BroadcastChannelParent.cpp | 4 +- dom/cache/AutoUtils.cpp | 10 +- dom/cache/CacheChild.cpp | 2 +- dom/cache/CacheOpParent.cpp | 8 +- dom/cache/CachePushStreamChild.cpp | 4 +- dom/cache/CachePushStreamParent.cpp | 2 +- dom/cache/CacheStorage.cpp | 2 +- dom/cache/CacheStorageChild.cpp | 4 +- dom/cache/CacheStorageParent.cpp | 2 +- dom/cache/CacheStreamControlChild.cpp | 6 +- dom/cache/CacheStreamControlParent.cpp | 6 +- dom/cache/FileUtils.cpp | 2 +- dom/cache/Manager.cpp | 4 +- dom/cache/ReadStream.cpp | 2 +- dom/cache/TypeUtils.cpp | 2 +- dom/camera/CameraControlImpl.cpp | 125 +++-- dom/camera/CameraControlImpl.h | 17 +- dom/camera/CameraControlListener.h | 13 +- dom/camera/DOMCameraControl.cpp | 186 ++++++- dom/camera/DOMCameraControl.h | 15 + dom/camera/DOMCameraControlListener.cpp | 34 +- dom/camera/DOMCameraControlListener.h | 3 +- dom/camera/GonkCameraControl.cpp | 466 +++++++++++++++--- dom/camera/GonkCameraControl.h | 20 +- dom/camera/GonkRecorder.cpp | 186 ++++++- dom/camera/GonkRecorder.h | 7 +- dom/camera/GonkRecorderProfiles.cpp | 8 +- dom/camera/GonkRecorderProfiles.def | 40 +- dom/camera/ICameraControl.h | 10 + dom/camera/moz.build | 1 + dom/camera/test/camera_common.js | 10 + .../test/test_camera_configuration.html | 57 ++- .../test/test_camera_fake_parameters.html | 27 + ..._camera_hardware_auto_focus_moving_cb.html | 28 +- dom/camera/test/test_camera_record.html | 48 +- dom/canvas/CanvasRenderingContext2D.cpp | 4 +- dom/datastore/DataStoreService.cpp | 2 +- .../DeviceStorageRequestChild.cpp | 16 - .../DeviceStorageRequestParent.cpp | 110 +---- .../DeviceStorageRequestParent.h | 24 +- dom/devicestorage/PDeviceStorageRequest.ipdl | 12 - dom/devicestorage/nsDeviceStorage.cpp | 20 +- dom/events/EventDispatcher.cpp | 2 +- dom/events/IMEStateManager.cpp | 4 +- dom/events/TextComposition.cpp | 6 +- dom/fetch/FetchDriver.cpp | 4 +- dom/fetch/Request.cpp | 4 +- dom/filehandle/ActorsParent.cpp | 6 +- dom/filesystem/FileSystemTaskBase.cpp | 2 +- dom/fmradio/ipc/FMRadioParent.cpp | 16 +- dom/fmradio/ipc/FMRadioRequestParent.cpp | 2 +- dom/gamepad/GamepadFunctions.cpp | 2 +- dom/geolocation/nsGeolocation.cpp | 4 +- dom/geolocation/nsGeolocationSettings.cpp | 2 +- dom/html/HTMLFormControlsCollection.cpp | 13 +- dom/html/HTMLFormElement.cpp | 13 +- dom/html/HTMLMediaElement.cpp | 72 +-- dom/html/HTMLPropertiesCollection.cpp | 23 +- dom/html/TimeRanges.cpp | 29 +- dom/html/TimeRanges.h | 13 +- dom/indexedDB/ActorsParent.cpp | 52 +- dom/ipc/Blob.cpp | 4 +- dom/ipc/ColorPickerParent.cpp | 8 +- dom/ipc/ContentChild.cpp | 34 +- dom/ipc/ContentParent.cpp | 122 ++--- dom/ipc/ContentParent.h | 4 + dom/ipc/ContentProcess.cpp | 2 +- dom/ipc/FilePickerParent.cpp | 10 +- dom/ipc/NuwaChild.cpp | 2 +- dom/ipc/NuwaParent.cpp | 4 +- dom/ipc/PContent.ipdl | 2 + dom/ipc/PreallocatedProcessManager.cpp | 2 +- dom/ipc/ProcessHangMonitor.cpp | 10 +- dom/ipc/ProcessPriorityManager.cpp | 6 +- dom/ipc/ScreenManagerParent.cpp | 4 +- dom/ipc/TabChild.cpp | 10 +- dom/ipc/TabParent.cpp | 56 +-- dom/ipc/nsIContentParent.cpp | 6 +- dom/locales/en-US/chrome/dom/dom.properties | 2 + dom/media/AbstractMediaDecoder.h | 2 +- dom/media/DOMMediaStream.cpp | 305 ++++++++---- dom/media/DOMMediaStream.h | 131 ++++- dom/media/DecoderTraits.cpp | 75 ++- dom/media/DecoderTraits.h | 7 +- dom/media/MediaDecoder.cpp | 122 ++--- dom/media/MediaDecoder.h | 9 +- dom/media/MediaDecoderReader.cpp | 43 -- dom/media/MediaDecoderReader.h | 34 +- dom/media/MediaDecoderStateMachine.h | 6 +- dom/media/MediaFormatReader.cpp | 90 +++- dom/media/MediaFormatReader.h | 29 +- dom/media/MediaManager.cpp | 2 +- dom/media/MediaManager.h | 2 +- dom/media/MediaResource.cpp | 2 +- dom/media/MediaResourceCallback.h | 2 +- dom/media/MediaStreamGraph.cpp | 2 +- dom/media/StreamBuffer.cpp | 4 + dom/media/android/AndroidMediaPluginHost.cpp | 1 - dom/media/fmp4/MP4Demuxer.cpp | 60 +++ dom/media/gmp/GMPAudioDecoderChild.cpp | 12 +- dom/media/gmp/GMPAudioDecoderParent.cpp | 2 +- dom/media/gmp/GMPContentParent.cpp | 4 +- dom/media/gmp/GMPDecryptorChild.cpp | 2 +- dom/media/gmp/GMPDecryptorParent.cpp | 16 +- dom/media/gmp/GMPParent.cpp | 4 +- dom/media/gmp/GMPStorageParent.cpp | 22 +- dom/media/gmp/GMPTimerParent.cpp | 2 +- dom/media/gmp/GMPVideoDecoderChild.cpp | 2 +- dom/media/gmp/GMPVideoDecoderParent.cpp | 2 +- dom/media/gmp/GMPVideoEncoderChild.cpp | 4 +- dom/media/gmp/GMPVideoEncoderParent.cpp | 2 +- dom/media/gstreamer/GStreamerFormatHelper.cpp | 26 +- dom/media/gstreamer/GStreamerFormatHelper.h | 4 +- dom/media/gstreamer/GStreamerReader.cpp | 10 +- dom/media/gstreamer/GStreamerReader.h | 6 +- dom/media/gtest/TestMediaFormatReader.cpp | 4 +- dom/media/mediasource/MediaSource.cpp | 29 +- dom/media/mediasource/SourceBuffer.cpp | 33 +- dom/media/mediasource/SourceBuffer.h | 6 +- dom/media/systemservices/CamerasChild.cpp | 2 +- dom/media/systemservices/CamerasParent.cpp | 30 +- dom/media/systemservices/MediaParent.cpp | 2 +- .../MediaSystemResourceManagerParent.cpp | 2 +- .../MediaSystemResourceService.cpp | 8 +- dom/media/test/manifest.js | 1 + dom/media/test/mochitest.ini | 1 + dom/media/test/small-shot.flac | Bin 0 -> 16430 bytes dom/media/test/test_can_play_type_mpeg.html | 2 + dom/media/webaudio/AnalyserNode.cpp | 2 +- dom/media/webaudio/BufferDecoder.h | 2 +- .../webrtc/MediaEngineGonkVideoSource.cpp | 4 +- dom/media/webrtc/MediaEngineGonkVideoSource.h | 2 +- .../webspeech/synth/nsSynthVoiceRegistry.cpp | 8 +- dom/messagechannel/MessagePort.cpp | 2 +- dom/messagechannel/MessagePortParent.cpp | 6 +- dom/messagechannel/MessagePortService.cpp | 4 +- dom/mobilemessage/ipc/SmsIPCService.cpp | 2 +- dom/mobilemessage/ipc/SmsParent.cpp | 22 +- dom/network/TCPServerSocketParent.cpp | 4 +- dom/network/TCPSocket.cpp | 2 +- dom/network/TCPSocketChild.cpp | 2 +- dom/network/TCPSocketParent.cpp | 8 +- dom/network/UDPSocket.h | 2 - dom/network/UDPSocketChild.cpp | 10 +- dom/network/UDPSocketParent.cpp | 16 +- dom/nfc/gonk/NfcMessageHandler.cpp | 2 +- dom/nfc/gonk/NfcService.cpp | 6 +- dom/notification/Notification.cpp | 31 +- dom/notification/Notification.h | 1 + dom/plugins/base/nsNPAPIPluginInstance.cpp | 2 +- dom/plugins/base/nsPluginTags.cpp | 2 +- dom/plugins/ipc/BrowserStreamParent.cpp | 8 +- dom/plugins/ipc/PluginInstanceParent.cpp | 12 +- dom/plugins/ipc/PluginInstanceParent.h | 2 +- dom/plugins/ipc/PluginModuleChild.cpp | 2 +- dom/plugins/ipc/PluginModuleParent.cpp | 18 +- .../ipc/PluginScriptableObjectParent.cpp | 4 +- dom/plugins/ipc/PluginWidgetChild.cpp | 2 +- .../provider/MulticastDNSDeviceProvider.cpp | 24 +- dom/speakermanager/SpeakerManagerService.cpp | 2 +- dom/storage/DOMStorageCache.cpp | 4 +- dom/storage/DOMStorageIPC.cpp | 20 +- dom/svg/nsSVGElement.cpp | 2 +- dom/webidl/CameraControl.webidl | 36 +- dom/webidl/MediaStream.webidl | 8 +- dom/webidl/SourceBuffer.webidl | 2 +- dom/workers/ServiceWorkerManager.cpp | 6 +- dom/workers/ServiceWorkerManagerChild.cpp | 2 +- dom/workers/ServiceWorkerManagerParent.cpp | 2 +- dom/workers/ServiceWorkerManagerService.cpp | 10 +- dom/workers/ServiceWorkerPeriodicUpdater.cpp | 2 +- dom/workers/ServiceWorkerScriptCache.cpp | 2 +- dom/xbl/nsBindingManager.cpp | 2 +- .../ipc/PrintProgressDialogChild.cpp | 12 +- .../ipc/PrintProgressDialogParent.cpp | 4 +- .../ipc/PrintSettingsDialogChild.cpp | 2 +- .../printingui/ipc/PrintingParent.cpp | 4 +- .../printingui/ipc/nsPrintingProxy.cpp | 8 +- extensions/cookie/nsPermissionManager.cpp | 4 +- gfx/gl/SharedSurface.cpp | 4 +- gfx/layers/apz/src/AsyncPanZoomController.cpp | 2 +- gfx/layers/client/CompositableClient.h | 2 +- gfx/layers/client/TextureClient.cpp | 61 ++- gfx/layers/composite/TextureHost.cpp | 2 +- gfx/layers/ipc/CompositorChild.cpp | 6 +- gfx/layers/ipc/CompositorLRU.cpp | 6 +- gfx/layers/ipc/CompositorParent.cpp | 16 +- gfx/layers/ipc/ISurfaceAllocator.cpp | 39 ++ gfx/layers/ipc/ImageBridgeParent.cpp | 2 +- gfx/layers/ipc/ImageContainerParent.cpp | 2 +- gfx/layers/ipc/LayerTransactionParent.cpp | 4 +- gfx/layers/ipc/SharedBufferManagerParent.cpp | 2 +- gfx/layers/ipc/SharedPlanarYCbCrImage.cpp | 5 +- gfx/vr/gfxVR.cpp | 2 +- hal/sandbox/SandboxHal.cpp | 20 +- ipc/glue/BackgroundImpl.cpp | 4 +- ipc/glue/CrossProcessMutex_posix.cpp | 2 +- ipc/glue/ProcessUtils_linux.cpp | 2 +- ipc/glue/Shmem.cpp | 4 +- ipc/hal/DaemonRunnables.h | 22 +- ipc/ipdl/test/cxx/TestBadActor.cpp | 2 +- ipc/ipdl/test/cxx/TestDataStructures.cpp | 2 +- js/ipc/WrapperOwner.cpp | 2 +- js/src/jsmath.cpp | 2 +- js/src/vm/Stopwatch.cpp | 2 +- js/xpconnect/loader/mozJSSubScriptLoader.cpp | 2 +- js/xpconnect/src/XPCWrappedNative.cpp | 2 +- layout/base/FrameLayerBuilder.cpp | 2 +- layout/base/nsRefreshDriver.cpp | 6 +- layout/base/nsStyleSheetService.cpp | 4 +- layout/forms/nsComboboxControlFrame.cpp | 2 +- layout/generic/nsColumnSetFrame.cpp | 2 +- layout/generic/nsGfxScrollFrame.cpp | 2 +- layout/generic/nsImageFrame.cpp | 2 +- layout/ipc/VsyncParent.cpp | 2 +- layout/mathml/nsMathMLChar.cpp | 2 +- media/libstagefright/binding/SinfParser.cpp | 4 +- .../WebrtcGlobalInformation.cpp | 8 +- mfbt/AlreadyAddRefed.h | 2 +- mfbt/tests/TestSplayTree.cpp | 2 +- mfbt/tests/TestTuple.cpp | 6 +- mfbt/unused.cpp | 2 +- mfbt/unused.h | 6 +- modules/libpref/init/all.js | 4 +- netwerk/base/ARefBase.h | 30 ++ netwerk/base/EventTokenBucket.cpp | 2 - netwerk/base/EventTokenBucket.h | 9 +- netwerk/cache2/CacheIndex.cpp | 2 +- netwerk/dns/DNSRequestChild.cpp | 2 +- netwerk/dns/DNSRequestParent.cpp | 6 +- netwerk/ipc/RemoteOpenFileChild.cpp | 10 +- netwerk/ipc/RemoteOpenFileParent.cpp | 2 +- netwerk/mime/nsMimeTypes.h | 1 + netwerk/protocol/data/DataChannelChild.cpp | 2 +- netwerk/protocol/ftp/FTPChannelParent.cpp | 2 +- .../protocol/http/ConnectionDiagnostics.cpp | 2 +- netwerk/protocol/http/HttpChannelChild.cpp | 2 +- netwerk/protocol/http/HttpChannelParent.cpp | 12 +- .../http/HttpChannelParentListener.cpp | 2 +- netwerk/protocol/http/SpdySession31.cpp | 24 - netwerk/protocol/http/nsHttpConnection.h | 2 + netwerk/protocol/http/nsHttpConnectionInfo.h | 5 +- netwerk/protocol/http/nsHttpConnectionMgr.cpp | 450 ++++++++--------- netwerk/protocol/http/nsHttpConnectionMgr.h | 128 ++--- netwerk/protocol/http/nsHttpTransaction.h | 2 + .../res/SubstitutingProtocolHandler.cpp | 2 +- netwerk/protocol/res/nsResProtocolHandler.cpp | 2 +- .../rtsp/controller/RtspControllerParent.cpp | 2 +- .../WebSocketEventListenerParent.cpp | 14 +- netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp | 2 +- netwerk/sctp/datachannel/DataChannel.cpp | 2 +- netwerk/test/TestOpen.cpp | 2 +- netwerk/test/TestProtocols.cpp | 4 +- parser/html/nsHtml5Atom.cpp | 2 +- security/manager/ssl/DataStorage.cpp | 16 +- security/manager/ssl/PSMContentListener.cpp | 12 +- .../manager/ssl/SSLServerCertVerification.cpp | 2 +- security/manager/ssl/SharedSSLState.cpp | 2 +- .../manager/ssl/nsKeygenHandlerContent.cpp | 6 +- security/manager/ssl/nsSmartCardMonitor.cpp | 2 +- security/sandbox/linux/Sandbox.cpp | 4 +- security/sandbox/linux/SandboxUtil.cpp | 2 +- security/sandbox/linux/glue/SandboxCrash.cpp | 6 +- .../nsParentalControlsServiceDefault.cpp | 2 +- .../perfmonitoring/nsPerformanceStats.cpp | 14 +- toolkit/components/places/History.cpp | 4 +- toolkit/components/telemetry/Histograms.json | 12 +- .../components/terminator/nsTerminator.cpp | 4 +- toolkit/content/devicestorage.properties | 2 +- toolkit/system/gnome/nsPackageKitService.cpp | 2 +- toolkit/xre/glxtest.cpp | 8 +- toolkit/xre/nsAppRunner.cpp | 4 +- tools/memory-profiler/UncensoredAllocator.cpp | 2 +- tools/profiler/tasktracer/GeckoTaskTracer.cpp | 2 +- .../exthandler/ExternalHelperAppParent.cpp | 6 +- .../exthandler/nsExternalHelperAppService.cpp | 1 + .../prefetch/OfflineCacheUpdateParent.cpp | 6 +- .../prefetch/nsOfflineCacheUpdateService.cpp | 2 +- widget/PuppetWidget.cpp | 6 +- widget/ScreenProxy.cpp | 2 +- widget/cocoa/TextInputHandler.mm | 2 +- widget/cocoa/nsAppShell.mm | 2 - widget/cocoa/nsChildView.mm | 2 + widget/cocoa/nsClipboard.mm | 2 +- widget/cocoa/nsMenuBarX.mm | 27 +- widget/cocoa/nsMenuGroupOwnerX.h | 7 + widget/cocoa/nsMenuGroupOwnerX.mm | 15 + widget/cocoa/nsMenuX.mm | 4 +- widget/cocoa/nsNativeThemeCocoa.mm | 2 +- widget/gonk/ProcessOrientation.cpp | 6 +- widget/gtk/nsAppShell.cpp | 6 +- widget/gtk/nsSound.cpp | 2 +- widget/nsBaseDragService.cpp | 2 +- widget/nsDragServiceProxy.cpp | 4 +- widget/nsScreenManagerProxy.cpp | 10 +- widget/windows/nsWindowGfx.cpp | 2 +- xpcom/base/SystemMemoryReporter.cpp | 10 +- xpcom/base/nsDumpUtils.cpp | 2 +- xpcom/base/nsMemoryInfoDumper.cpp | 4 +- xpcom/ds/nsAtomTable.cpp | 2 +- xpcom/tests/TestTArray.cpp | 2 +- xpcom/tests/gtest/TestCloneInputStream.cpp | 2 +- xpcom/threads/AbstractThread.cpp | 2 +- xpcom/threads/TaskQueue.h | 2 +- 329 files changed, 3290 insertions(+), 2125 deletions(-) create mode 100644 dom/media/test/small-shot.flac create mode 100644 netwerk/base/ARefBase.h diff --git a/accessible/ipc/ProxyAccessible.cpp b/accessible/ipc/ProxyAccessible.cpp index 5654a87cf7..33299aa410 100644 --- a/accessible/ipc/ProxyAccessible.cpp +++ b/accessible/ipc/ProxyAccessible.cpp @@ -80,7 +80,7 @@ uint64_t ProxyAccessible::State() const { uint64_t state = 0; - unused << mDoc->SendState(mID, &state); + Unused << mDoc->SendState(mID, &state); return state; } @@ -88,45 +88,45 @@ uint64_t ProxyAccessible::NativeState() const { uint64_t state = 0; - unused << mDoc->SendNativeState(mID, &state); + Unused << mDoc->SendNativeState(mID, &state); return state; } void ProxyAccessible::Name(nsString& aName) const { - unused << mDoc->SendName(mID, &aName); + Unused << mDoc->SendName(mID, &aName); } void ProxyAccessible::Value(nsString& aValue) const { - unused << mDoc->SendValue(mID, &aValue); + Unused << mDoc->SendValue(mID, &aValue); } void ProxyAccessible::Help(nsString& aHelp) const { - unused << mDoc->SendHelp(mID, &aHelp); + Unused << mDoc->SendHelp(mID, &aHelp); } void ProxyAccessible::Description(nsString& aDesc) const { - unused << mDoc->SendDescription(mID, &aDesc); + Unused << mDoc->SendDescription(mID, &aDesc); } void ProxyAccessible::Attributes(nsTArray *aAttrs) const { - unused << mDoc->SendAttributes(mID, aAttrs); + Unused << mDoc->SendAttributes(mID, aAttrs); } nsTArray ProxyAccessible::RelationByType(RelationType aType) const { nsTArray targetIDs; - unused << mDoc->SendRelationByType(mID, static_cast(aType), + Unused << mDoc->SendRelationByType(mID, static_cast(aType), &targetIDs); size_t targetCount = targetIDs.Length(); @@ -144,7 +144,7 @@ ProxyAccessible::Relations(nsTArray* aTypes, const { nsTArray ipcRelations; - unused << mDoc->SendRelations(mID, &ipcRelations); + Unused << mDoc->SendRelations(mID, &ipcRelations); size_t relationCount = ipcRelations.Length(); aTypes->SetCapacity(relationCount); @@ -172,7 +172,7 @@ bool ProxyAccessible::IsSearchbox() const { bool retVal = false; - unused << mDoc->SendIsSearchbox(mID, &retVal); + Unused << mDoc->SendIsSearchbox(mID, &retVal); return retVal; } @@ -180,7 +180,7 @@ nsIAtom* ProxyAccessible::LandmarkRole() const { nsString landmark; - unused << mDoc->SendLandmarkRole(mID, &landmark); + Unused << mDoc->SendLandmarkRole(mID, &landmark); return NS_GetStaticAtom(landmark); } @@ -188,7 +188,7 @@ nsIAtom* ProxyAccessible::ARIARoleAtom() const { nsString role; - unused << mDoc->SendARIARoleAtom(mID, &role); + Unused << mDoc->SendARIARoleAtom(mID, &role); return NS_GetStaticAtom(role); } @@ -196,7 +196,7 @@ int32_t ProxyAccessible::GetLevelInternal() { int32_t level = 0; - unused << mDoc->SendGetLevelInternal(mID, &level); + Unused << mDoc->SendGetLevelInternal(mID, &level); return level; } @@ -204,7 +204,7 @@ int32_t ProxyAccessible::CaretLineNumber() { int32_t line = -1; - unused << mDoc->SendCaretOffset(mID, &line); + Unused << mDoc->SendCaretOffset(mID, &line); return line; } @@ -212,21 +212,21 @@ int32_t ProxyAccessible::CaretOffset() { int32_t offset = 0; - unused << mDoc->SendCaretOffset(mID, &offset); + Unused << mDoc->SendCaretOffset(mID, &offset); return offset; } void ProxyAccessible::SetCaretOffset(int32_t aOffset) { - unused << mDoc->SendSetCaretOffset(mID, aOffset); + Unused << mDoc->SendSetCaretOffset(mID, aOffset); } int32_t ProxyAccessible::CharacterCount() { int32_t count = 0; - unused << mDoc->SendCharacterCount(mID, &count); + Unused << mDoc->SendCharacterCount(mID, &count); return count; } @@ -234,7 +234,7 @@ int32_t ProxyAccessible::SelectionCount() { int32_t count = 0; - unused << mDoc->SendSelectionCount(mID, &count); + Unused << mDoc->SendSelectionCount(mID, &count); return count; } @@ -243,7 +243,7 @@ ProxyAccessible::TextSubstring(int32_t aStartOffset, int32_t aEndOfset, nsString& aText) const { bool valid; - unused << mDoc->SendTextSubstring(mID, aStartOffset, aEndOfset, &aText, &valid); + Unused << mDoc->SendTextSubstring(mID, aStartOffset, aEndOfset, &aText, &valid); return valid; } @@ -253,7 +253,7 @@ ProxyAccessible::GetTextAfterOffset(int32_t aOffset, nsString& aText, int32_t* aStartOffset, int32_t* aEndOffset) { - unused << mDoc->SendGetTextAfterOffset(mID, aOffset, aBoundaryType, + Unused << mDoc->SendGetTextAfterOffset(mID, aOffset, aBoundaryType, &aText, aStartOffset, aEndOffset); } @@ -263,7 +263,7 @@ ProxyAccessible::GetTextAtOffset(int32_t aOffset, nsString& aText, int32_t* aStartOffset, int32_t* aEndOffset) { - unused << mDoc->SendGetTextAtOffset(mID, aOffset, aBoundaryType, + Unused << mDoc->SendGetTextAtOffset(mID, aOffset, aBoundaryType, &aText, aStartOffset, aEndOffset); } @@ -273,7 +273,7 @@ ProxyAccessible::GetTextBeforeOffset(int32_t aOffset, nsString& aText, int32_t* aStartOffset, int32_t* aEndOffset) { - unused << mDoc->SendGetTextBeforeOffset(mID, aOffset, aBoundaryType, + Unused << mDoc->SendGetTextBeforeOffset(mID, aOffset, aBoundaryType, &aText, aStartOffset, aEndOffset); } @@ -281,7 +281,7 @@ char16_t ProxyAccessible::CharAt(int32_t aOffset) { uint16_t retval = 0; - unused << mDoc->SendCharAt(mID, aOffset, &retval); + Unused << mDoc->SendCharAt(mID, aOffset, &retval); return static_cast(retval); } @@ -292,14 +292,14 @@ ProxyAccessible::TextAttributes(bool aIncludeDefAttrs, int32_t* aStartOffset, int32_t* aEndOffset) { - unused << mDoc->SendTextAttributes(mID, aIncludeDefAttrs, aOffset, + Unused << mDoc->SendTextAttributes(mID, aIncludeDefAttrs, aOffset, aAttributes, aStartOffset, aEndOffset); } void ProxyAccessible::DefaultTextAttributes(nsTArray* aAttrs) { - unused << mDoc->SendDefaultTextAttributes(mID, aAttrs); + Unused << mDoc->SendDefaultTextAttributes(mID, aAttrs); } nsIntRect @@ -307,7 +307,7 @@ ProxyAccessible::TextBounds(int32_t aStartOffset, int32_t aEndOffset, uint32_t aCoordType) { nsIntRect rect; - unused << + Unused << mDoc->SendTextBounds(mID, aStartOffset, aEndOffset, aCoordType, &rect); return rect; } @@ -316,7 +316,7 @@ nsIntRect ProxyAccessible::CharBounds(int32_t aOffset, uint32_t aCoordType) { nsIntRect rect; - unused << + Unused << mDoc->SendCharBounds(mID, aOffset, aCoordType, &rect); return rect; } @@ -325,7 +325,7 @@ int32_t ProxyAccessible::OffsetAtPoint(int32_t aX, int32_t aY, uint32_t aCoordType) { int32_t retVal = -1; - unused << mDoc->SendOffsetAtPoint(mID, aX, aY, aCoordType, &retVal); + Unused << mDoc->SendOffsetAtPoint(mID, aX, aY, aCoordType, &retVal); return retVal; } @@ -336,7 +336,7 @@ ProxyAccessible::SelectionBoundsAt(int32_t aSelectionNum, int32_t* aEndOffset) { bool retVal = false; - unused << mDoc->SendSelectionBoundsAt(mID, aSelectionNum, &retVal, &aData, + Unused << mDoc->SendSelectionBoundsAt(mID, aSelectionNum, &retVal, &aData, aStartOffset, aEndOffset); return retVal; } @@ -347,7 +347,7 @@ ProxyAccessible::SetSelectionBoundsAt(int32_t aSelectionNum, int32_t aEndOffset) { bool retVal = false; - unused << mDoc->SendSetSelectionBoundsAt(mID, aSelectionNum, aStartOffset, + Unused << mDoc->SendSetSelectionBoundsAt(mID, aSelectionNum, aStartOffset, aEndOffset, &retVal); return retVal; } @@ -357,7 +357,7 @@ ProxyAccessible::AddToSelection(int32_t aStartOffset, int32_t aEndOffset) { bool retVal = false; - unused << mDoc->SendAddToSelection(mID, aStartOffset, aEndOffset, &retVal); + Unused << mDoc->SendAddToSelection(mID, aStartOffset, aEndOffset, &retVal); return retVal; } @@ -365,7 +365,7 @@ bool ProxyAccessible::RemoveFromSelection(int32_t aSelectionNum) { bool retVal = false; - unused << mDoc->SendRemoveFromSelection(mID, aSelectionNum, &retVal); + Unused << mDoc->SendRemoveFromSelection(mID, aSelectionNum, &retVal); return retVal; } @@ -373,7 +373,7 @@ void ProxyAccessible::ScrollSubstringTo(int32_t aStartOffset, int32_t aEndOffset, uint32_t aScrollType) { - unused << mDoc->SendScrollSubstringTo(mID, aStartOffset, aEndOffset, aScrollType); + Unused << mDoc->SendScrollSubstringTo(mID, aStartOffset, aEndOffset, aScrollType); } void @@ -382,27 +382,27 @@ ProxyAccessible::ScrollSubstringToPoint(int32_t aStartOffset, uint32_t aCoordinateType, int32_t aX, int32_t aY) { - unused << mDoc->SendScrollSubstringToPoint(mID, aStartOffset, aEndOffset, + Unused << mDoc->SendScrollSubstringToPoint(mID, aStartOffset, aEndOffset, aCoordinateType, aX, aY); } void ProxyAccessible::Text(nsString* aText) { - unused << mDoc->SendText(mID, aText); + Unused << mDoc->SendText(mID, aText); } void ProxyAccessible::ReplaceText(const nsString& aText) { - unused << mDoc->SendReplaceText(mID, aText); + Unused << mDoc->SendReplaceText(mID, aText); } bool ProxyAccessible::InsertText(const nsString& aText, int32_t aPosition) { bool valid; - unused << mDoc->SendInsertText(mID, aText, aPosition, &valid); + Unused << mDoc->SendInsertText(mID, aText, aPosition, &valid); return valid; } @@ -410,7 +410,7 @@ bool ProxyAccessible::CopyText(int32_t aStartPos, int32_t aEndPos) { bool valid; - unused << mDoc->SendCopyText(mID, aStartPos, aEndPos, &valid); + Unused << mDoc->SendCopyText(mID, aStartPos, aEndPos, &valid); return valid; } @@ -418,7 +418,7 @@ bool ProxyAccessible::CutText(int32_t aStartPos, int32_t aEndPos) { bool valid; - unused << mDoc->SendCutText(mID, aStartPos, aEndPos, &valid); + Unused << mDoc->SendCutText(mID, aStartPos, aEndPos, &valid); return valid; } @@ -426,7 +426,7 @@ bool ProxyAccessible::DeleteText(int32_t aStartPos, int32_t aEndPos) { bool valid; - unused << mDoc->SendDeleteText(mID, aStartPos, aEndPos, &valid); + Unused << mDoc->SendDeleteText(mID, aStartPos, aEndPos, &valid); return valid; } @@ -434,7 +434,7 @@ bool ProxyAccessible::PasteText(int32_t aPosition) { bool valid; - unused << mDoc->SendPasteText(mID, aPosition, &valid); + Unused << mDoc->SendPasteText(mID, aPosition, &valid); return valid; } @@ -442,7 +442,7 @@ nsIntPoint ProxyAccessible::ImagePosition(uint32_t aCoordType) { nsIntPoint retVal; - unused << mDoc->SendImagePosition(mID, aCoordType, &retVal); + Unused << mDoc->SendImagePosition(mID, aCoordType, &retVal); return retVal; } @@ -450,7 +450,7 @@ nsIntSize ProxyAccessible::ImageSize() { nsIntSize retVal; - unused << mDoc->SendImageSize(mID, &retVal); + Unused << mDoc->SendImageSize(mID, &retVal); return retVal; } @@ -458,7 +458,7 @@ uint32_t ProxyAccessible::StartOffset(bool* aOk) { uint32_t retVal = 0; - unused << mDoc->SendStartOffset(mID, &retVal, aOk); + Unused << mDoc->SendStartOffset(mID, &retVal, aOk); return retVal; } @@ -466,7 +466,7 @@ uint32_t ProxyAccessible::EndOffset(bool* aOk) { uint32_t retVal = 0; - unused << mDoc->SendEndOffset(mID, &retVal, aOk); + Unused << mDoc->SendEndOffset(mID, &retVal, aOk); return retVal; } @@ -474,7 +474,7 @@ bool ProxyAccessible::IsLinkValid() { bool retVal = false; - unused << mDoc->SendIsLinkValid(mID, &retVal); + Unused << mDoc->SendIsLinkValid(mID, &retVal); return retVal; } @@ -482,14 +482,14 @@ uint32_t ProxyAccessible::AnchorCount(bool* aOk) { uint32_t retVal = 0; - unused << mDoc->SendAnchorCount(mID, &retVal, aOk); + Unused << mDoc->SendAnchorCount(mID, &retVal, aOk); return retVal; } void ProxyAccessible::AnchorURIAt(uint32_t aIndex, nsCString& aURI, bool* aOk) { - unused << mDoc->SendAnchorURIAt(mID, aIndex, &aURI, aOk); + Unused << mDoc->SendAnchorURIAt(mID, aIndex, &aURI, aOk); } ProxyAccessible* @@ -497,7 +497,7 @@ ProxyAccessible::AnchorAt(uint32_t aIndex) { uint64_t id = 0; bool ok = false; - unused << mDoc->SendAnchorAt(mID, aIndex, &id, &ok); + Unused << mDoc->SendAnchorAt(mID, aIndex, &id, &ok); return ok ? mDoc->GetAccessible(id) : nullptr; } @@ -505,7 +505,7 @@ uint32_t ProxyAccessible::LinkCount() { uint32_t retVal = 0; - unused << mDoc->SendLinkCount(mID, &retVal); + Unused << mDoc->SendLinkCount(mID, &retVal); return retVal; } @@ -514,7 +514,7 @@ ProxyAccessible::LinkAt(const uint32_t& aIndex) { uint64_t linkID = 0; bool ok = false; - unused << mDoc->SendLinkAt(mID, aIndex, &linkID, &ok); + Unused << mDoc->SendLinkAt(mID, aIndex, &linkID, &ok); return ok ? mDoc->GetAccessible(linkID) : nullptr; } @@ -523,7 +523,7 @@ ProxyAccessible::LinkIndexOf(ProxyAccessible* aLink) { int32_t retVal = -1; if (aLink) { - unused << mDoc->SendLinkIndexOf(mID, aLink->ID(), &retVal); + Unused << mDoc->SendLinkIndexOf(mID, aLink->ID(), &retVal); } return retVal; @@ -533,7 +533,7 @@ int32_t ProxyAccessible::LinkIndexAtOffset(uint32_t aOffset) { int32_t retVal = -1; - unused << mDoc->SendLinkIndexAtOffset(mID, aOffset, &retVal); + Unused << mDoc->SendLinkIndexAtOffset(mID, aOffset, &retVal); return retVal; } @@ -542,7 +542,7 @@ ProxyAccessible::TableOfACell() { uint64_t tableID = 0; bool ok = false; - unused << mDoc->SendTableOfACell(mID, &tableID, &ok); + Unused << mDoc->SendTableOfACell(mID, &tableID, &ok); return ok ? mDoc->GetAccessible(tableID) : nullptr; } @@ -550,7 +550,7 @@ uint32_t ProxyAccessible::ColIdx() { uint32_t index = 0; - unused << mDoc->SendColIdx(mID, &index); + Unused << mDoc->SendColIdx(mID, &index); return index; } @@ -558,7 +558,7 @@ uint32_t ProxyAccessible::RowIdx() { uint32_t index = 0; - unused << mDoc->SendRowIdx(mID, &index); + Unused << mDoc->SendRowIdx(mID, &index); return index; } @@ -566,7 +566,7 @@ uint32_t ProxyAccessible::ColExtent() { uint32_t extent = 0; - unused << mDoc->SendColExtent(mID, &extent); + Unused << mDoc->SendColExtent(mID, &extent); return extent; } @@ -574,7 +574,7 @@ uint32_t ProxyAccessible::RowExtent() { uint32_t extent = 0; - unused << mDoc->SendRowExtent(mID, &extent); + Unused << mDoc->SendRowExtent(mID, &extent); return extent; } @@ -582,7 +582,7 @@ void ProxyAccessible::ColHeaderCells(nsTArray* aCells) { nsTArray targetIDs; - unused << mDoc->SendColHeaderCells(mID, &targetIDs); + Unused << mDoc->SendColHeaderCells(mID, &targetIDs); size_t targetCount = targetIDs.Length(); for (size_t i = 0; i < targetCount; i++) { @@ -594,7 +594,7 @@ void ProxyAccessible::RowHeaderCells(nsTArray* aCells) { nsTArray targetIDs; - unused << mDoc->SendRowHeaderCells(mID, &targetIDs); + Unused << mDoc->SendRowHeaderCells(mID, &targetIDs); size_t targetCount = targetIDs.Length(); for (size_t i = 0; i < targetCount; i++) { @@ -606,7 +606,7 @@ bool ProxyAccessible::IsCellSelected() { bool selected = false; - unused << mDoc->SendIsCellSelected(mID, &selected); + Unused << mDoc->SendIsCellSelected(mID, &selected); return selected; } @@ -615,21 +615,21 @@ ProxyAccessible::TableCaption() { uint64_t captionID = 0; bool ok = false; - unused << mDoc->SendTableCaption(mID, &captionID, &ok); + Unused << mDoc->SendTableCaption(mID, &captionID, &ok); return ok ? mDoc->GetAccessible(captionID) : nullptr; } void ProxyAccessible::TableSummary(nsString& aSummary) { - unused << mDoc->SendTableSummary(mID, &aSummary); + Unused << mDoc->SendTableSummary(mID, &aSummary); } uint32_t ProxyAccessible::TableColumnCount() { uint32_t count = 0; - unused << mDoc->SendTableColumnCount(mID, &count); + Unused << mDoc->SendTableColumnCount(mID, &count); return count; } @@ -637,7 +637,7 @@ uint32_t ProxyAccessible::TableRowCount() { uint32_t count = 0; - unused << mDoc->SendTableRowCount(mID, &count); + Unused << mDoc->SendTableRowCount(mID, &count); return count; } @@ -646,7 +646,7 @@ ProxyAccessible::TableCellAt(uint32_t aRow, uint32_t aCol) { uint64_t cellID = 0; bool ok = false; - unused << mDoc->SendTableCellAt(mID, aRow, aCol, &cellID, &ok); + Unused << mDoc->SendTableCellAt(mID, aRow, aCol, &cellID, &ok); return ok ? mDoc->GetAccessible(cellID) : nullptr; } @@ -654,7 +654,7 @@ int32_t ProxyAccessible::TableCellIndexAt(uint32_t aRow, uint32_t aCol) { int32_t index = 0; - unused << mDoc->SendTableCellIndexAt(mID, aRow, aCol, &index); + Unused << mDoc->SendTableCellIndexAt(mID, aRow, aCol, &index); return index; } @@ -662,7 +662,7 @@ int32_t ProxyAccessible::TableColumnIndexAt(uint32_t aCellIndex) { int32_t index = 0; - unused << mDoc->SendTableColumnIndexAt(mID, aCellIndex, &index); + Unused << mDoc->SendTableColumnIndexAt(mID, aCellIndex, &index); return index; } @@ -670,7 +670,7 @@ int32_t ProxyAccessible::TableRowIndexAt(uint32_t aCellIndex) { int32_t index = 0; - unused << mDoc->SendTableRowIndexAt(mID, aCellIndex, &index); + Unused << mDoc->SendTableRowIndexAt(mID, aCellIndex, &index); return index; } @@ -678,14 +678,14 @@ void ProxyAccessible::TableRowAndColumnIndicesAt(uint32_t aCellIndex, int32_t* aRow, int32_t* aCol) { - unused << mDoc->SendTableRowAndColumnIndicesAt(mID, aCellIndex, aRow, aCol); + Unused << mDoc->SendTableRowAndColumnIndicesAt(mID, aCellIndex, aRow, aCol); } uint32_t ProxyAccessible::TableColumnExtentAt(uint32_t aRow, uint32_t aCol) { uint32_t extent = 0; - unused << mDoc->SendTableColumnExtentAt(mID, aRow, aCol, &extent); + Unused << mDoc->SendTableColumnExtentAt(mID, aRow, aCol, &extent); return extent; } @@ -693,27 +693,27 @@ uint32_t ProxyAccessible::TableRowExtentAt(uint32_t aRow, uint32_t aCol) { uint32_t extent = 0; - unused << mDoc->SendTableRowExtentAt(mID, aRow, aCol, &extent); + Unused << mDoc->SendTableRowExtentAt(mID, aRow, aCol, &extent); return extent; } void ProxyAccessible::TableColumnDescription(uint32_t aCol, nsString& aDescription) { - unused << mDoc->SendTableColumnDescription(mID, aCol, &aDescription); + Unused << mDoc->SendTableColumnDescription(mID, aCol, &aDescription); } void ProxyAccessible::TableRowDescription(uint32_t aRow, nsString& aDescription) { - unused << mDoc->SendTableRowDescription(mID, aRow, &aDescription); + Unused << mDoc->SendTableRowDescription(mID, aRow, &aDescription); } bool ProxyAccessible::TableColumnSelected(uint32_t aCol) { bool selected = false; - unused << mDoc->SendTableColumnSelected(mID, aCol, &selected); + Unused << mDoc->SendTableColumnSelected(mID, aCol, &selected); return selected; } @@ -721,7 +721,7 @@ bool ProxyAccessible::TableRowSelected(uint32_t aRow) { bool selected = false; - unused << mDoc->SendTableRowSelected(mID, aRow, &selected); + Unused << mDoc->SendTableRowSelected(mID, aRow, &selected); return selected; } @@ -729,7 +729,7 @@ bool ProxyAccessible::TableCellSelected(uint32_t aRow, uint32_t aCol) { bool selected = false; - unused << mDoc->SendTableCellSelected(mID, aRow, aCol, &selected); + Unused << mDoc->SendTableCellSelected(mID, aRow, aCol, &selected); return selected; } @@ -737,7 +737,7 @@ uint32_t ProxyAccessible::TableSelectedCellCount() { uint32_t count = 0; - unused << mDoc->SendTableSelectedCellCount(mID, &count); + Unused << mDoc->SendTableSelectedCellCount(mID, &count); return count; } @@ -745,7 +745,7 @@ uint32_t ProxyAccessible::TableSelectedColumnCount() { uint32_t count = 0; - unused << mDoc->SendTableSelectedColumnCount(mID, &count); + Unused << mDoc->SendTableSelectedColumnCount(mID, &count); return count; } @@ -753,7 +753,7 @@ uint32_t ProxyAccessible::TableSelectedRowCount() { uint32_t count = 0; - unused << mDoc->SendTableSelectedRowCount(mID, &count); + Unused << mDoc->SendTableSelectedRowCount(mID, &count); return count; } @@ -761,7 +761,7 @@ void ProxyAccessible::TableSelectedCells(nsTArray* aCellIDs) { nsAutoTArray cellIDs; - unused << mDoc->SendTableSelectedCells(mID, &cellIDs); + Unused << mDoc->SendTableSelectedCells(mID, &cellIDs); aCellIDs->SetCapacity(cellIDs.Length()); for (uint32_t i = 0; i < cellIDs.Length(); ++i) { aCellIDs->AppendElement(mDoc->GetAccessible(cellIDs[i])); @@ -771,50 +771,50 @@ ProxyAccessible::TableSelectedCells(nsTArray* aCellIDs) void ProxyAccessible::TableSelectedCellIndices(nsTArray* aCellIndices) { - unused << mDoc->SendTableSelectedCellIndices(mID, aCellIndices); + Unused << mDoc->SendTableSelectedCellIndices(mID, aCellIndices); } void ProxyAccessible::TableSelectedColumnIndices(nsTArray* aColumnIndices) { - unused << mDoc->SendTableSelectedColumnIndices(mID, aColumnIndices); + Unused << mDoc->SendTableSelectedColumnIndices(mID, aColumnIndices); } void ProxyAccessible::TableSelectedRowIndices(nsTArray* aRowIndices) { - unused << mDoc->SendTableSelectedRowIndices(mID, aRowIndices); + Unused << mDoc->SendTableSelectedRowIndices(mID, aRowIndices); } void ProxyAccessible::TableSelectColumn(uint32_t aCol) { - unused << mDoc->SendTableSelectColumn(mID, aCol); + Unused << mDoc->SendTableSelectColumn(mID, aCol); } void ProxyAccessible::TableSelectRow(uint32_t aRow) { - unused << mDoc->SendTableSelectRow(mID, aRow); + Unused << mDoc->SendTableSelectRow(mID, aRow); } void ProxyAccessible::TableUnselectColumn(uint32_t aCol) { - unused << mDoc->SendTableUnselectColumn(mID, aCol); + Unused << mDoc->SendTableUnselectColumn(mID, aCol); } void ProxyAccessible::TableUnselectRow(uint32_t aRow) { - unused << mDoc->SendTableUnselectRow(mID, aRow); + Unused << mDoc->SendTableUnselectRow(mID, aRow); } bool ProxyAccessible::TableIsProbablyForLayout() { bool forLayout = false; - unused << mDoc->SendTableIsProbablyForLayout(mID, &forLayout); + Unused << mDoc->SendTableIsProbablyForLayout(mID, &forLayout); return forLayout; } @@ -823,7 +823,7 @@ ProxyAccessible::AtkTableColumnHeader(int32_t aCol) { uint64_t headerID = 0; bool ok = false; - unused << mDoc->SendAtkTableColumnHeader(mID, aCol, &headerID, &ok); + Unused << mDoc->SendAtkTableColumnHeader(mID, aCol, &headerID, &ok); return ok ? mDoc->GetAccessible(headerID) : nullptr; } @@ -832,7 +832,7 @@ ProxyAccessible::AtkTableRowHeader(int32_t aRow) { uint64_t headerID = 0; bool ok = false; - unused << mDoc->SendAtkTableRowHeader(mID, aRow, &headerID, &ok); + Unused << mDoc->SendAtkTableRowHeader(mID, aRow, &headerID, &ok); return ok ? mDoc->GetAccessible(headerID) : nullptr; } @@ -840,7 +840,7 @@ void ProxyAccessible::SelectedItems(nsTArray* aSelectedItems) { nsAutoTArray itemIDs; - unused << mDoc->SendSelectedItems(mID, &itemIDs); + Unused << mDoc->SendSelectedItems(mID, &itemIDs); aSelectedItems->SetCapacity(itemIDs.Length()); for (size_t i = 0; i < itemIDs.Length(); ++i) { aSelectedItems->AppendElement(mDoc->GetAccessible(itemIDs[i])); @@ -851,7 +851,7 @@ uint32_t ProxyAccessible::SelectedItemCount() { uint32_t count = 0; - unused << mDoc->SendSelectedItemCount(mID, &count); + Unused << mDoc->SendSelectedItemCount(mID, &count); return count; } @@ -860,7 +860,7 @@ ProxyAccessible::GetSelectedItem(uint32_t aIndex) { uint64_t selectedItemID = 0; bool ok = false; - unused << mDoc->SendGetSelectedItem(mID, aIndex, &selectedItemID, &ok); + Unused << mDoc->SendGetSelectedItem(mID, aIndex, &selectedItemID, &ok); return ok ? mDoc->GetAccessible(selectedItemID) : nullptr; } @@ -868,7 +868,7 @@ bool ProxyAccessible::IsItemSelected(uint32_t aIndex) { bool selected = false; - unused << mDoc->SendIsItemSelected(mID, aIndex, &selected); + Unused << mDoc->SendIsItemSelected(mID, aIndex, &selected); return selected; } @@ -876,7 +876,7 @@ bool ProxyAccessible::AddItemToSelection(uint32_t aIndex) { bool success = false; - unused << mDoc->SendAddItemToSelection(mID, aIndex, &success); + Unused << mDoc->SendAddItemToSelection(mID, aIndex, &success); return success; } @@ -884,7 +884,7 @@ bool ProxyAccessible::RemoveItemFromSelection(uint32_t aIndex) { bool success = false; - unused << mDoc->SendRemoveItemFromSelection(mID, aIndex, &success); + Unused << mDoc->SendRemoveItemFromSelection(mID, aIndex, &success); return success; } @@ -892,7 +892,7 @@ bool ProxyAccessible::SelectAll() { bool success = false; - unused << mDoc->SendSelectAll(mID, &success); + Unused << mDoc->SendSelectAll(mID, &success); return success; } @@ -900,27 +900,27 @@ bool ProxyAccessible::UnselectAll() { bool success = false; - unused << mDoc->SendUnselectAll(mID, &success); + Unused << mDoc->SendUnselectAll(mID, &success); return success; } void ProxyAccessible::TakeSelection() { - unused << mDoc->SendTakeSelection(mID); + Unused << mDoc->SendTakeSelection(mID); } void ProxyAccessible::SetSelected(bool aSelect) { - unused << mDoc->SendSetSelected(mID, aSelect); + Unused << mDoc->SendSetSelected(mID, aSelect); } bool ProxyAccessible::DoAction(uint8_t aIndex) { bool success = false; - unused << mDoc->SendDoAction(mID, aIndex, &success); + Unused << mDoc->SendDoAction(mID, aIndex, &success); return success; } @@ -928,20 +928,20 @@ uint8_t ProxyAccessible::ActionCount() { uint8_t count = 0; - unused << mDoc->SendActionCount(mID, &count); + Unused << mDoc->SendActionCount(mID, &count); return count; } void ProxyAccessible::ActionDescriptionAt(uint8_t aIndex, nsString& aDescription) { - unused << mDoc->SendActionDescriptionAt(mID, aIndex, &aDescription); + Unused << mDoc->SendActionDescriptionAt(mID, aIndex, &aDescription); } void ProxyAccessible::ActionNameAt(uint8_t aIndex, nsString& aName) { - unused << mDoc->SendActionNameAt(mID, aIndex, &aName); + Unused << mDoc->SendActionNameAt(mID, aIndex, &aName); } KeyBinding @@ -949,7 +949,7 @@ ProxyAccessible::AccessKey() { uint32_t key = 0; uint32_t modifierMask = 0; - unused << mDoc->SendAccessKey(mID, &key, &modifierMask); + Unused << mDoc->SendAccessKey(mID, &key, &modifierMask); return KeyBinding(key, modifierMask); } @@ -958,21 +958,21 @@ ProxyAccessible::KeyboardShortcut() { uint32_t key = 0; uint32_t modifierMask = 0; - unused << mDoc->SendKeyboardShortcut(mID, &key, &modifierMask); + Unused << mDoc->SendKeyboardShortcut(mID, &key, &modifierMask); return KeyBinding(key, modifierMask); } void ProxyAccessible::AtkKeyBinding(nsString& aBinding) { - unused << mDoc->SendAtkKeyBinding(mID, &aBinding); + Unused << mDoc->SendAtkKeyBinding(mID, &aBinding); } double ProxyAccessible::CurValue() { double val = UnspecifiedNaN(); - unused << mDoc->SendCurValue(mID, &val); + Unused << mDoc->SendCurValue(mID, &val); return val; } @@ -980,7 +980,7 @@ bool ProxyAccessible::SetCurValue(double aValue) { bool success = false; - unused << mDoc->SendSetCurValue(mID, aValue, &success); + Unused << mDoc->SendSetCurValue(mID, aValue, &success); return success; } @@ -988,7 +988,7 @@ double ProxyAccessible::MinValue() { double val = UnspecifiedNaN(); - unused << mDoc->SendMinValue(mID, &val); + Unused << mDoc->SendMinValue(mID, &val); return val; } @@ -996,7 +996,7 @@ double ProxyAccessible::MaxValue() { double val = UnspecifiedNaN(); - unused << mDoc->SendMaxValue(mID, &val); + Unused << mDoc->SendMaxValue(mID, &val); return val; } @@ -1004,21 +1004,21 @@ double ProxyAccessible::Step() { double step = UnspecifiedNaN(); - unused << mDoc->SendStep(mID, &step); + Unused << mDoc->SendStep(mID, &step); return step; } void ProxyAccessible::TakeFocus() { - unused << mDoc->SendTakeFocus(mID); + Unused << mDoc->SendTakeFocus(mID); } uint32_t ProxyAccessible::EmbeddedChildCount() const { uint32_t count; - unused << mDoc->SendEmbeddedChildCount(mID, &count); + Unused << mDoc->SendEmbeddedChildCount(mID, &count); return count; } @@ -1027,7 +1027,7 @@ ProxyAccessible::IndexOfEmbeddedChild(const ProxyAccessible* aChild) { uint64_t childID = aChild->mID; uint32_t childIdx; - unused << mDoc->SendIndexOfEmbeddedChild(mID, childID, &childIdx); + Unused << mDoc->SendIndexOfEmbeddedChild(mID, childID, &childIdx); return childIdx; } @@ -1043,7 +1043,7 @@ ProxyAccessible::EmbeddedChildAt(size_t aChildIdx) } uint64_t childID; - unused << mDoc->SendEmbeddedChildAt(mID, aChildIdx, &childID); + Unused << mDoc->SendEmbeddedChildAt(mID, aChildIdx, &childID); return mDoc->GetAccessible(childID); } @@ -1052,7 +1052,7 @@ ProxyAccessible::FocusedChild() { uint64_t childID = 0; bool ok = false; - unused << mDoc->SendFocusedChild(mID, &childID, &ok); + Unused << mDoc->SendFocusedChild(mID, &childID, &ok); return ok ? mDoc->GetAccessible(childID) : nullptr; } @@ -1062,7 +1062,7 @@ ProxyAccessible::ChildAtPoint(int32_t aX, int32_t aY, { uint64_t childID = 0; bool ok = false; - unused << mDoc->SendAccessibleAtPoint(mID, aX, aY, false, + Unused << mDoc->SendAccessibleAtPoint(mID, aX, aY, false, static_cast(aWhichChild), &childID, &ok); return ok ? mDoc->GetAccessible(childID) : nullptr; @@ -1072,7 +1072,7 @@ nsIntRect ProxyAccessible::Bounds() { nsIntRect rect; - unused << mDoc->SendExtents(mID, false, + Unused << mDoc->SendExtents(mID, false, &(rect.x), &(rect.y), &(rect.width), &(rect.height)); return rect; @@ -1081,38 +1081,38 @@ ProxyAccessible::Bounds() void ProxyAccessible::Language(nsString& aLocale) { - unused << mDoc->SendLanguage(mID, &aLocale); + Unused << mDoc->SendLanguage(mID, &aLocale); } void ProxyAccessible::DocType(nsString& aType) { - unused << mDoc->SendDocType(mID, &aType); + Unused << mDoc->SendDocType(mID, &aType); } void ProxyAccessible::Title(nsString& aTitle) { - unused << mDoc->SendTitle(mID, &aTitle); + Unused << mDoc->SendTitle(mID, &aTitle); } void ProxyAccessible::URL(nsString& aURL) { - unused << mDoc->SendURL(mID, &aURL); + Unused << mDoc->SendURL(mID, &aURL); } void ProxyAccessible::MimeType(nsString aMime) { - unused << mDoc->SendMimeType(mID, &aMime); + Unused << mDoc->SendMimeType(mID, &aMime); } void ProxyAccessible::URLDocTypeMimeType(nsString& aURL, nsString& aDocType, nsString& aMimeType) { - unused << mDoc->SendURLDocTypeMimeType(mID, &aURL, &aDocType, &aMimeType); + Unused << mDoc->SendURLDocTypeMimeType(mID, &aURL, &aDocType, &aMimeType); } ProxyAccessible* @@ -1121,7 +1121,7 @@ ProxyAccessible::AccessibleAtPoint(int32_t aX, int32_t aY, { uint64_t childID = 0; bool ok = false; - unused << + Unused << mDoc->SendAccessibleAtPoint(mID, aX, aY, aNeedsScreenCoords, static_cast(Accessible::eDirectChild), &childID, &ok); @@ -1132,7 +1132,7 @@ void ProxyAccessible::Extents(bool aNeedsScreenCoords, int32_t* aX, int32_t* aY, int32_t* aWidth, int32_t* aHeight) { - unused << mDoc->SendExtents(mID, aNeedsScreenCoords, aX, aY, aWidth, aHeight); + Unused << mDoc->SendExtents(mID, aNeedsScreenCoords, aX, aY, aWidth, aHeight); } Accessible* diff --git a/caps/DomainPolicy.cpp b/caps/DomainPolicy.cpp index 8ced3a91b9..240db8d3de 100644 --- a/caps/DomainPolicy.cpp +++ b/caps/DomainPolicy.cpp @@ -35,7 +35,7 @@ BroadcastDomainSetChange(DomainSetType aSetType, DomainSetChangeType aChangeType SerializeURI(aDomain, uri); for (uint32_t i = 0; i < parents.Length(); i++) { - unused << parents[i]->SendDomainSetChanged(aSetType, aChangeType, uri); + Unused << parents[i]->SendDomainSetChanged(aSetType, aChangeType, uri); } return NS_OK; } diff --git a/chrome/nsChromeRegistryChrome.cpp b/chrome/nsChromeRegistryChrome.cpp index 151fd4ce0e..1c768613d4 100644 --- a/chrome/nsChromeRegistryChrome.cpp +++ b/chrome/nsChromeRegistryChrome.cpp @@ -766,7 +766,7 @@ SendManifestEntry(const ChromeRegistryItem &aItem) return; for (uint32_t i = 0; i < parents.Length(); i++) { - unused << parents[i]->SendRegisterChromeItem(aItem); + Unused << parents[i]->SendRegisterChromeItem(aItem); } } diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 7f008e130e..ac520e79c1 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -5075,7 +5075,7 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI, // asserts). Satisfy that assertion now since GetDoc will force // creation of one if it hasn't already been created. if (mScriptGlobal) { - unused << mScriptGlobal->GetDoc(); + Unused << mScriptGlobal->GetDoc(); } // Display a message box diff --git a/dom/asmjscache/AsmJSCache.cpp b/dom/asmjscache/AsmJSCache.cpp index 2a79965e4b..4e064ffc9e 100644 --- a/dom/asmjscache/AsmJSCache.cpp +++ b/dom/asmjscache/AsmJSCache.cpp @@ -56,7 +56,7 @@ using mozilla::ipc::BackgroundChild; using mozilla::ipc::IsOnBackgroundThread; using mozilla::ipc::PBackgroundChild; using mozilla::ipc::PrincipalInfo; -using mozilla::unused; +using mozilla::Unused; using mozilla::HashString; namespace mozilla { @@ -478,7 +478,7 @@ private: FinishOnOwningThread(); if (!mActorDestroyed) { - unused << Send__delete__(this, mResult); + Unused << Send__delete__(this, mResult); } } @@ -993,7 +993,7 @@ ParentRunnable::Run() // Metadata is now open. if (!SendOnOpenMetadataForRead(mMetadata)) { - unused << Send__delete__(this, JS::AsmJSCache_InternalError); + Unused << Send__delete__(this, JS::AsmJSCache_InternalError); } return NS_OK; @@ -1035,7 +1035,7 @@ ParentRunnable::Run() FileDescriptor::PlatformHandleType handle = FileDescriptor::PlatformHandleType(PR_FileDesc2NativeHandle(mFileDesc)); if (!SendOnOpenCacheFile(mFileSize, FileDescriptor(handle))) { - unused << Send__delete__(this, JS::AsmJSCache_InternalError); + Unused << Send__delete__(this, JS::AsmJSCache_InternalError); } return NS_OK; @@ -1451,7 +1451,7 @@ ChildRunnable::Run() Release(); if (!mActorDestroyed) { - unused << Send__delete__(this, JS::AsmJSCache_Success); + Unused << Send__delete__(this, JS::AsmJSCache_Success); } mState = eFinished; diff --git a/dom/base/ImageEncoder.cpp b/dom/base/ImageEncoder.cpp index e5a751c5cf..60e39913f8 100644 --- a/dom/base/ImageEncoder.cpp +++ b/dom/base/ImageEncoder.cpp @@ -210,7 +210,7 @@ public: rv = NS_DispatchToMainThread(mEncodingCompleteEvent); if (NS_FAILED(rv)) { // Better to leak than to crash. - unused << mEncodingCompleteEvent.forget(); + Unused << mEncodingCompleteEvent.forget(); return rv; } diff --git a/dom/base/nsContentPermissionHelper.cpp b/dom/base/nsContentPermissionHelper.cpp index 760b541246..1b1c50d027 100644 --- a/dom/base/nsContentPermissionHelper.cpp +++ b/dom/base/nsContentPermissionHelper.cpp @@ -33,7 +33,7 @@ #include "nsIDOMEvent.h" #include "nsWeakPtr.h" -using mozilla::unused; // +using mozilla::Unused; // using namespace mozilla::dom; using namespace mozilla; @@ -473,7 +473,7 @@ nsContentPermissionRequestProxy::nsContentPermissionRequesterProxy mGetCallback = aCallback; mWaitGettingResult = true; - unused << mParent->SendGetVisibility(); + Unused << mParent->SendGetVisibility(); return NS_OK; } @@ -608,7 +608,7 @@ nsContentPermissionRequestProxy::Cancel() nsTArray emptyChoices; - unused << ContentPermissionRequestParent::Send__delete__(mParent, false, emptyChoices); + Unused << ContentPermissionRequestParent::Send__delete__(mParent, false, emptyChoices); mParent = nullptr; return NS_OK; } @@ -672,7 +672,7 @@ nsContentPermissionRequestProxy::Allow(JS::HandleValue aChoices) return NS_ERROR_FAILURE; } - unused << ContentPermissionRequestParent::Send__delete__(mParent, true, choices); + Unused << ContentPermissionRequestParent::Send__delete__(mParent, true, choices); mParent = nullptr; return NS_OK; } @@ -776,7 +776,7 @@ RemotePermissionRequest::RecvGetVisibility() bool isActive = false; docshell->GetIsActive(&isActive); - unused << SendNotifyVisibility(isActive); + Unused << SendNotifyVisibility(isActive); return true; } @@ -787,6 +787,6 @@ RemotePermissionRequest::NotifyVisibility(bool isVisible) return NS_OK; } - unused << SendNotifyVisibility(isVisible); + Unused << SendNotifyVisibility(isVisible); return NS_OK; } diff --git a/dom/base/nsFocusManager.cpp b/dom/base/nsFocusManager.cpp index 70aa44d2cc..95131b79b5 100644 --- a/dom/base/nsFocusManager.cpp +++ b/dom/base/nsFocusManager.cpp @@ -1120,7 +1120,7 @@ void ActivateOrDeactivateChild(TabParent* aParent, void* aArg) { bool active = static_cast(aArg); - unused << aParent->SendParentActivated(active); + Unused << aParent->SendParentActivated(active); } void diff --git a/dom/base/nsFrameLoader.cpp b/dom/base/nsFrameLoader.cpp index 21dbaebea1..cb2029950b 100644 --- a/dom/base/nsFrameLoader.cpp +++ b/dom/base/nsFrameLoader.cpp @@ -988,8 +988,8 @@ nsFrameLoader::SwapWithOtherRemoteLoader(nsFrameLoader* aOther, mInSwap = aOther->mInSwap = false; - unused << mRemoteBrowser->SendSwappedWithOtherRemoteLoader(); - unused << aOther->mRemoteBrowser->SendSwappedWithOtherRemoteLoader(); + Unused << mRemoteBrowser->SendSwappedWithOtherRemoteLoader(); + Unused << aOther->mRemoteBrowser->SendSwappedWithOtherRemoteLoader(); return NS_OK; } @@ -2298,7 +2298,7 @@ nsFrameLoader::TryRemoteBrowser() nsGkAtoms::mozpasspointerevents, nsGkAtoms::_true, eCaseMatters)) { - unused << mRemoteBrowser->SendSetUpdateHitRegion(true); + Unused << mRemoteBrowser->SendSetUpdateHitRegion(true); } ReallyLoadFrameScripts(); @@ -2343,14 +2343,14 @@ nsFrameLoader::DeactivateRemoteFrame() { void nsFrameLoader::ActivateUpdateHitRegion() { if (mRemoteBrowser) { - unused << mRemoteBrowser->SendSetUpdateHitRegion(true); + Unused << mRemoteBrowser->SendSetUpdateHitRegion(true); } } void nsFrameLoader::DeactivateUpdateHitRegion() { if (mRemoteBrowser) { - unused << mRemoteBrowser->SendSetUpdateHitRegion(false); + Unused << mRemoteBrowser->SendSetUpdateHitRegion(false); } } @@ -2861,7 +2861,7 @@ nsFrameLoader::RequestNotifyAfterRemotePaint() { // If remote browsing (e10s), handle this with the TabParent. if (mRemoteBrowser) { - unused << mRemoteBrowser->SendRequestNotifyAfterRemotePaint(); + Unused << mRemoteBrowser->SendRequestNotifyAfterRemotePaint(); } return NS_OK; diff --git a/dom/base/nsGkAtomList.h b/dom/base/nsGkAtomList.h index 01622074ee..9e603f26f8 100644 --- a/dom/base/nsGkAtomList.h +++ b/dom/base/nsGkAtomList.h @@ -857,6 +857,7 @@ GK_ATOM(onpopuphidden, "onpopuphidden") GK_ATOM(onpopuphiding, "onpopuphiding") GK_ATOM(onpopupshowing, "onpopupshowing") GK_ATOM(onpopupshown, "onpopupshown") +GK_ATOM(onposter, "onposter") GK_ATOM(onpreviewstatechange, "onpreviewstatechange") GK_ATOM(onpullphonebookreq, "onpullphonebookreq") GK_ATOM(onpullvcardentryreq, "onpullvcardentryreq") diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 24ca9c1aa2..4ed8d872b7 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -12199,7 +12199,7 @@ nsGlobalWindow::SetTimeoutOrInterval(nsIScriptTimeoutHandler *aHandler, } // The timeout is now also held in the timer's closure. - unused << copy.forget(); + Unused << copy.forget(); } else { // If we are frozen, however, then we instead simply set // timeout->mTimeRemaining to be the "time remaining" in the timeout (i.e., @@ -12595,7 +12595,7 @@ nsGlobalWindow::RunTimeout(nsTimeout *aTimeout) // through a timeout that fired while a modal (to this window) // dialog was open or through other non-obvious paths. MOZ_ASSERT(dummy_timeout->HasRefCntOne(), "dummy_timeout may leak"); - unused << timeoutExtraRef.forget().take(); + Unused << timeoutExtraRef.forget().take(); mTimeoutInsertionPoint = last_insertion_point; @@ -13098,7 +13098,7 @@ nsGlobalWindow::SuspendTimeouts(uint32_t aIncrease, // Suspend all of the AudioContexts for this window for (uint32_t i = 0; i < mAudioContexts.Length(); ++i) { ErrorResult dummy; - unused << mAudioContexts[i]->Suspend(dummy); + RefPtr d = mAudioContexts[i]->Suspend(dummy); } } diff --git a/dom/base/nsScriptLoader.cpp b/dom/base/nsScriptLoader.cpp index 734a83e582..2bebdf76b4 100644 --- a/dom/base/nsScriptLoader.cpp +++ b/dom/base/nsScriptLoader.cpp @@ -844,8 +844,8 @@ NotifyOffThreadScriptLoadCompletedRunnable::~NotifyOffThreadScriptLoadCompletedR } else { MOZ_ASSERT(false, "We really shouldn't leak!"); // Better to leak than crash. - unused << mRequest.forget(); - unused << mLoader.forget(); + Unused << mRequest.forget(); + Unused << mLoader.forget(); } } } @@ -915,7 +915,7 @@ nsScriptLoader::AttemptAsyncScriptCompile(nsScriptLoadRequest* aRequest) mDocument->BlockOnload(); aRequest->mProgress = nsScriptLoadRequest::Progress_Compiling; - unused << runnable.forget(); + Unused << runnable.forget(); return NS_OK; } diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index dd7cefae92..d59a4a2043 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -1339,10 +1339,6 @@ DOMInterfaces = { 'implicitJSContext': ['readHeapSnapshot', 'saveHeapSnapshot'] }, -'TimeRanges': { - 'wrapperCache': False -}, - 'TouchList': { 'headerFile': 'mozilla/dom/TouchEvent.h', }, diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonA2dpInterface.cpp b/dom/bluetooth/bluedroid/BluetoothDaemonA2dpInterface.cpp index 454de29383..631b93b683 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonA2dpInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothDaemonA2dpInterface.cpp @@ -68,7 +68,7 @@ BluetoothDaemonA2dpModule::ConnectCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -90,7 +90,7 @@ BluetoothDaemonA2dpModule::DisconnectCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonAvrcpInterface.cpp b/dom/bluetooth/bluedroid/BluetoothDaemonAvrcpInterface.cpp index 63e479a3c4..8a764ce85d 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonAvrcpInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothDaemonAvrcpInterface.cpp @@ -70,7 +70,7 @@ BluetoothDaemonAvrcpModule::GetPlayStatusRspCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -96,7 +96,7 @@ BluetoothDaemonAvrcpModule::ListPlayerAppAttrRspCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -120,7 +120,7 @@ BluetoothDaemonAvrcpModule::ListPlayerAppValueRspCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -145,7 +145,7 @@ BluetoothDaemonAvrcpModule::GetPlayerAppValueRspCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -169,7 +169,7 @@ BluetoothDaemonAvrcpModule::GetPlayerAppAttrTextRspCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -193,7 +193,7 @@ BluetoothDaemonAvrcpModule::GetPlayerAppValueTextRspCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -217,7 +217,7 @@ BluetoothDaemonAvrcpModule::GetElementAttrRspCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -239,7 +239,7 @@ BluetoothDaemonAvrcpModule::SetPlayerAppValueRspCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -267,7 +267,7 @@ BluetoothDaemonAvrcpModule::RegisterNotificationRspCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -289,7 +289,7 @@ BluetoothDaemonAvrcpModule::SetVolumeCmd(uint8_t aVolume, if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.cpp b/dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.cpp index 430f051362..d8bf6d3672 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.cpp @@ -65,7 +65,7 @@ BluetoothDaemonCoreModule::EnableCmd(BluetoothResultHandler* aRes) if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return rv; } @@ -82,7 +82,7 @@ BluetoothDaemonCoreModule::DisableCmd(BluetoothResultHandler* aRes) if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return rv; } @@ -100,7 +100,7 @@ BluetoothDaemonCoreModule::GetAdapterPropertiesCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return rv; } @@ -123,7 +123,7 @@ BluetoothDaemonCoreModule::GetAdapterPropertyCmd(const nsAString& aName, if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return rv; } @@ -145,7 +145,7 @@ BluetoothDaemonCoreModule::SetAdapterPropertyCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return rv; } @@ -168,7 +168,7 @@ BluetoothDaemonCoreModule::GetRemoteDevicePropertiesCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return rv; } @@ -194,7 +194,7 @@ BluetoothDaemonCoreModule::GetRemoteDevicePropertyCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return rv; } @@ -220,7 +220,7 @@ BluetoothDaemonCoreModule::SetRemoteDevicePropertyCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return rv; } @@ -245,7 +245,7 @@ BluetoothDaemonCoreModule::GetRemoteServiceRecordCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return rv; } @@ -267,7 +267,7 @@ BluetoothDaemonCoreModule::GetRemoteServicesCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return rv; } @@ -284,7 +284,7 @@ BluetoothDaemonCoreModule::StartDiscoveryCmd(BluetoothResultHandler* aRes) if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return rv; } @@ -301,7 +301,7 @@ BluetoothDaemonCoreModule::CancelDiscoveryCmd(BluetoothResultHandler* aRes) if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return rv; } @@ -330,7 +330,7 @@ BluetoothDaemonCoreModule::CreateBondCmd(const nsAString& aBdAddr, if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return rv; } @@ -353,7 +353,7 @@ BluetoothDaemonCoreModule::RemoveBondCmd(const nsAString& aBdAddr, if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return rv; } @@ -376,7 +376,7 @@ BluetoothDaemonCoreModule::CancelBondCmd(const nsAString& aBdAddr, if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return rv; } @@ -402,7 +402,7 @@ BluetoothDaemonCoreModule::PinReplyCmd(const nsAString& aBdAddr, bool aAccept, if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return rv; } @@ -428,7 +428,7 @@ BluetoothDaemonCoreModule::SspReplyCmd(const nsAString& aBdAddr, if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return rv; } @@ -450,7 +450,7 @@ BluetoothDaemonCoreModule::DutModeConfigureCmd(bool aEnable, if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return rv; } @@ -474,7 +474,7 @@ BluetoothDaemonCoreModule::DutModeSendCmd(uint16_t aOpcode, if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return rv; } @@ -498,7 +498,7 @@ BluetoothDaemonCoreModule::LeTestModeCmd(uint16_t aOpcode, if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return rv; } diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonGattInterface.cpp b/dom/bluetooth/bluedroid/BluetoothDaemonGattInterface.cpp index dcc72d2f4b..d46e8f5be3 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonGattInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothDaemonGattInterface.cpp @@ -69,7 +69,7 @@ BluetoothDaemonGattModule::ClientRegisterCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -91,7 +91,7 @@ BluetoothDaemonGattModule::ClientUnregisterCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -115,7 +115,7 @@ BluetoothDaemonGattModule::ClientScanCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -145,7 +145,7 @@ BluetoothDaemonGattModule::ClientConnectCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -173,7 +173,7 @@ BluetoothDaemonGattModule::ClientDisconnectCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -198,7 +198,7 @@ BluetoothDaemonGattModule::ClientListenCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -223,7 +223,7 @@ BluetoothDaemonGattModule::ClientRefreshCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -251,7 +251,7 @@ BluetoothDaemonGattModule::ClientSearchServiceCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -280,7 +280,7 @@ BluetoothDaemonGattModule::ClientGetIncludedServiceCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -310,7 +310,7 @@ BluetoothDaemonGattModule::ClientGetCharacteristicCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -342,7 +342,7 @@ BluetoothDaemonGattModule::ClientGetDescriptorCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -370,7 +370,7 @@ BluetoothDaemonGattModule::ClientReadCharacteristicCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -397,7 +397,7 @@ BluetoothDaemonGattModule::ClientWriteCharacteristicCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -426,7 +426,7 @@ BluetoothDaemonGattModule::ClientReadDescriptorCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -454,7 +454,7 @@ BluetoothDaemonGattModule::ClientWriteDescriptorCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -478,7 +478,7 @@ BluetoothDaemonGattModule::ClientExecuteWriteCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -507,7 +507,7 @@ BluetoothDaemonGattModule::ClientRegisterNotificationCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -536,7 +536,7 @@ BluetoothDaemonGattModule::ClientDeregisterNotificationCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -562,7 +562,7 @@ BluetoothDaemonGattModule::ClientReadRemoteRssiCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -585,7 +585,7 @@ BluetoothDaemonGattModule::ClientGetDeviceTypeCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -621,7 +621,7 @@ BluetoothDaemonGattModule::ClientSetAdvDataCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -655,7 +655,7 @@ BluetoothDaemonGattModule::ClientTestCommandCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -677,7 +677,7 @@ BluetoothDaemonGattModule::ServerRegisterCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -699,7 +699,7 @@ BluetoothDaemonGattModule::ServerUnregisterCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -729,7 +729,7 @@ BluetoothDaemonGattModule::ServerConnectPeripheralCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -756,7 +756,7 @@ BluetoothDaemonGattModule::ServerDisconnectPeripheralCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -782,7 +782,7 @@ BluetoothDaemonGattModule::ServerAddServiceCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -809,7 +809,7 @@ BluetoothDaemonGattModule::ServerAddIncludedServiceCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -840,7 +840,7 @@ BluetoothDaemonGattModule::ServerAddCharacteristicCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -869,7 +869,7 @@ BluetoothDaemonGattModule::ServerAddDescriptorCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -896,7 +896,7 @@ BluetoothDaemonGattModule::ServerStartServiceCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -921,7 +921,7 @@ BluetoothDaemonGattModule::ServerStopServiceCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -946,7 +946,7 @@ BluetoothDaemonGattModule::ServerDeleteServiceCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -974,7 +974,7 @@ BluetoothDaemonGattModule::ServerSendIndicationCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -1007,7 +1007,7 @@ BluetoothDaemonGattModule::ServerSendResponseCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonHandsfreeInterface.cpp b/dom/bluetooth/bluedroid/BluetoothDaemonHandsfreeInterface.cpp index f7df8873e8..561c0f6e06 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonHandsfreeInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothDaemonHandsfreeInterface.cpp @@ -72,7 +72,7 @@ BluetoothDaemonHandsfreeModule::ConnectCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -95,7 +95,7 @@ BluetoothDaemonHandsfreeModule::DisconnectCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -118,7 +118,7 @@ BluetoothDaemonHandsfreeModule::ConnectAudioCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -141,7 +141,7 @@ BluetoothDaemonHandsfreeModule::DisconnectAudioCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -167,7 +167,7 @@ BluetoothDaemonHandsfreeModule::StartVoiceRecognitionCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -193,7 +193,7 @@ BluetoothDaemonHandsfreeModule::StopVoiceRecognitionCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -224,7 +224,7 @@ BluetoothDaemonHandsfreeModule::VolumeControlCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -253,7 +253,7 @@ BluetoothDaemonHandsfreeModule::DeviceStatusNotificationCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -283,7 +283,7 @@ BluetoothDaemonHandsfreeModule::CopsResponseCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -334,7 +334,7 @@ BluetoothDaemonHandsfreeModule::CindResponseCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -364,7 +364,7 @@ BluetoothDaemonHandsfreeModule::FormattedAtResponseCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -396,7 +396,7 @@ BluetoothDaemonHandsfreeModule::AtResponseCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -441,7 +441,7 @@ BluetoothDaemonHandsfreeModule::ClccResponseCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -474,7 +474,7 @@ BluetoothDaemonHandsfreeModule::PhoneStateChangeCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } @@ -500,7 +500,7 @@ BluetoothDaemonHandsfreeModule::ConfigureWbsCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return NS_OK; } diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp b/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp index ba960b7c1e..f405064dca 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp @@ -477,7 +477,7 @@ BluetoothDaemonInterface::Init( // If we could not cleanup properly before and an old // instance of the daemon is still running, we kill it // here. - unused << NS_WARN_IF(property_set("ctl.stop", "bluetoothd")); + Unused << NS_WARN_IF(property_set("ctl.stop", "bluetoothd")); mResultHandlerQ.AppendElement(aRes); @@ -1023,7 +1023,7 @@ BluetoothDaemonInterface::OnConnectError(int aIndex) mCmdChannel->Close(); case CMD_CHANNEL: // Stop daemon and close listen socket - unused << NS_WARN_IF(property_set("ctl.stop", "bluetoothd")); + Unused << NS_WARN_IF(property_set("ctl.stop", "bluetoothd")); mListenSocket->Close(); case LISTEN_SOCKET: if (!mResultHandlerQ.IsEmpty()) { diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonSetupInterface.cpp b/dom/bluetooth/bluedroid/BluetoothDaemonSetupInterface.cpp index e15de97703..534cb45f26 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonSetupInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothDaemonSetupInterface.cpp @@ -75,7 +75,7 @@ BluetoothDaemonSetupModule::RegisterModuleCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return rv; } @@ -97,7 +97,7 @@ BluetoothDaemonSetupModule::UnregisterModuleCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return rv; } @@ -121,7 +121,7 @@ BluetoothDaemonSetupModule::ConfigurationCmd( if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return rv; } diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonSocketInterface.cpp b/dom/bluetooth/bluedroid/BluetoothDaemonSocketInterface.cpp index 5adab62011..cea68ce08a 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonSocketInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothDaemonSocketInterface.cpp @@ -49,7 +49,7 @@ BluetoothDaemonSocketModule::ListenCmd(BluetoothSocketType aType, if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return rv; } @@ -80,7 +80,7 @@ BluetoothDaemonSocketModule::ConnectCmd(const nsAString& aBdAddr, if (NS_FAILED(rv)) { return rv; } - unused << pdu.forget(); + Unused << pdu.forget(); return rv; } diff --git a/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp b/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp index 7eef0a1a55..9854decf8b 100644 --- a/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp +++ b/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp @@ -2033,7 +2033,7 @@ BluetoothServiceBluedroid::RemoteDevicePropertiesNotification( break; } } - unused << NS_WARN_IF(i == mGetRemoteServiceRecordArray.Length()); + Unused << NS_WARN_IF(i == mGetRemoteServiceRecordArray.Length()); } else if (p.mType == PROPERTY_UNKNOWN) { /* Bug 1065999: working around unknown properties */ } else { diff --git a/dom/bluetooth/bluez/BluetoothDBusService.cpp b/dom/bluetooth/bluez/BluetoothDBusService.cpp index 893b566b9c..9f23c2daab 100644 --- a/dom/bluetooth/bluez/BluetoothDBusService.cpp +++ b/dom/bluetooth/bluez/BluetoothDBusService.cpp @@ -1234,7 +1234,7 @@ AppendDeviceName(BluetoothSignal& aSignal) NS_ENSURE_TRUE_VOID(success); - unused << handler.forget(); // picked up by callback handler + Unused << handler.forget(); // picked up by callback handler } class SetPairingConfirmationTask : public Task @@ -1660,7 +1660,7 @@ private: NS_ENSURE_TRUE(success, false); - unused << handler.forget(); // picked up by callback handler + Unused << handler.forget(); // picked up by callback handler return true; } @@ -1699,7 +1699,7 @@ public: NS_ENSURE_TRUE_VOID(success); - unused << handler.forget(); /* picked up by callback handler */ + Unused << handler.forget(); /* picked up by callback handler */ } }; @@ -2390,7 +2390,7 @@ protected: return false; } - unused << handler.forget(); // picked up by callback handler + Unused << handler.forget(); // picked up by callback handler return true; } @@ -2450,7 +2450,7 @@ public: DBUS_TYPE_INVALID); NS_ENSURE_TRUE_VOID(success); - unused << handler.forget(); // picked up by callback handler + Unused << handler.forget(); // picked up by callback handler } private: @@ -2523,7 +2523,7 @@ public: DBUS_TYPE_INVALID); NS_ENSURE_TRUE_VOID(success); - unused << mRunnable.forget(); // picked up by callback handler + Unused << mRunnable.forget(); // picked up by callback handler } private: @@ -2791,7 +2791,7 @@ protected: NS_ENSURE_TRUE(success, false); - unused << handler.forget(); // picked up by callback handler + Unused << handler.forget(); // picked up by callback handler return true; } @@ -2954,7 +2954,7 @@ public: 1000, msg); NS_ENSURE_TRUE_VOID(success); - unused << mRunnable.forget(); // picked up by callback handler + Unused << mRunnable.forget(); // picked up by callback handler } private: @@ -3099,7 +3099,7 @@ public: DBUS_TYPE_INVALID); NS_ENSURE_TRUE_VOID(success); - unused << mRunnable.forget(); // picked up by callback handler + Unused << mRunnable.forget(); // picked up by callback handler /** * FIXME: Bug 820274 @@ -3168,7 +3168,7 @@ public: DBUS_TYPE_INVALID); NS_ENSURE_TRUE_VOID(success); - unused << mRunnable.forget(); // picked up by callback handler + Unused << mRunnable.forget(); // picked up by callback handler } protected: @@ -3622,7 +3622,7 @@ public: DBUS_TYPE_INVALID); NS_ENSURE_TRUE_VOID(success); - unused << handler.forget(); // picked up by callback handler + Unused << handler.forget(); // picked up by callback handler } private: @@ -3927,7 +3927,7 @@ public: DBUS_TYPE_INVALID); NS_ENSURE_TRUE_VOID(success); - unused << mRunnable.forget(); // picked up by callback handler + Unused << mRunnable.forget(); // picked up by callback handler } private: @@ -4057,7 +4057,7 @@ public: DBUS_TYPE_INVALID); NS_ENSURE_TRUE_VOID(success); - unused << mRunnable.forget(); // picked up by callback handler + Unused << mRunnable.forget(); // picked up by callback handler } private: diff --git a/dom/bluetooth/common/BluetoothService.cpp b/dom/bluetooth/common/BluetoothService.cpp index e9abeb6a47..ec2e67368e 100644 --- a/dom/bluetooth/common/BluetoothService.cpp +++ b/dom/bluetooth/common/BluetoothService.cpp @@ -453,7 +453,7 @@ BluetoothService::SetEnabled(bool aEnabled) GetAllBluetoothActors(childActors); for (uint32_t index = 0; index < childActors.Length(); index++) { - unused << childActors[index]->SendEnabled(aEnabled); + Unused << childActors[index]->SendEnabled(aEnabled); } /** diff --git a/dom/bluetooth/ipc/BluetoothParent.cpp b/dom/bluetooth/ipc/BluetoothParent.cpp index 5d51d2470e..10f2b3fc39 100644 --- a/dom/bluetooth/ipc/BluetoothParent.cpp +++ b/dom/bluetooth/ipc/BluetoothParent.cpp @@ -17,7 +17,7 @@ #include "BluetoothReplyRunnable.h" #include "BluetoothService.h" -using mozilla::unused; +using mozilla::Unused; USING_BLUETOOTH_NAMESPACE /******************************************************************************* @@ -99,7 +99,7 @@ BluetoothParent::BeginShutdown() { // Only do something here if we haven't yet begun the shutdown sequence. if (mShutdownState == Running) { - unused << SendBeginShutdown(); + Unused << SendBeginShutdown(); mShutdownState = SentBeginShutdown; } } @@ -342,7 +342,7 @@ BluetoothParent::DeallocPBluetoothRequestParent(PBluetoothRequestParent* aActor) void BluetoothParent::Notify(const BluetoothSignal& aSignal) { - unused << SendNotify(aSignal); + Unused << SendNotify(aSignal); } /******************************************************************************* diff --git a/dom/broadcastchannel/BroadcastChannelParent.cpp b/dom/broadcastchannel/BroadcastChannelParent.cpp index e0bcbd83ac..4d3191ce1a 100644 --- a/dom/broadcastchannel/BroadcastChannelParent.cpp +++ b/dom/broadcastchannel/BroadcastChannelParent.cpp @@ -60,7 +60,7 @@ BroadcastChannelParent::RecvClose() mService->UnregisterActor(this); mService = nullptr; - unused << Send__delete__(this); + Unused << Send__delete__(this); return true; } @@ -105,7 +105,7 @@ BroadcastChannelParent::CheckAndDeliver(const ClonedMessageData& aData, newData.blobsParent()[i] = blobParent; } - unused << SendNotify(newData); + Unused << SendNotify(newData); } } diff --git a/dom/cache/AutoUtils.cpp b/dom/cache/AutoUtils.cpp index 98f491eb92..0b7c76b487 100644 --- a/dom/cache/AutoUtils.cpp +++ b/dom/cache/AutoUtils.cpp @@ -24,7 +24,7 @@ namespace { -using mozilla::unused; +using mozilla::Unused; using mozilla::dom::cache::CachePushStreamChild; using mozilla::dom::cache::CacheReadStream; using mozilla::dom::cache::CacheReadStreamOrVoid; @@ -54,7 +54,7 @@ CleanupChildFds(CacheReadStream& aReadStream, CleanupAction aAction) MOZ_ASSERT(fdSetActor); if (aAction == Delete) { - unused << fdSetActor->Send__delete__(fdSetActor); + Unused << fdSetActor->Send__delete__(fdSetActor); } // FileDescriptorSet doesn't clear its fds in its ActorDestroy, so we @@ -114,7 +114,7 @@ CleanupParentFds(CacheReadStream& aReadStream, CleanupAction aAction) MOZ_ASSERT(fdSetActor); if (aAction == Delete) { - unused << fdSetActor->Send__delete__(fdSetActor); + Unused << fdSetActor->Send__delete__(fdSetActor); } // FileDescriptorSet doesn't clear its fds in its ActorDestroy, so we @@ -482,7 +482,7 @@ AutoParentOpResult::~AutoParentOpResult() if (action == Forget || result.actorParent() == nullptr) { break; } - unused << PCacheParent::Send__delete__(result.actorParent()); + Unused << PCacheParent::Send__delete__(result.actorParent()); } default: // other types do not need clean up @@ -490,7 +490,7 @@ AutoParentOpResult::~AutoParentOpResult() } if (action == Delete && mStreamControl) { - unused << PCacheStreamControlParent::Send__delete__(mStreamControl); + Unused << PCacheStreamControlParent::Send__delete__(mStreamControl); } } diff --git a/dom/cache/CacheChild.cpp b/dom/cache/CacheChild.cpp index cf30648bc8..d0478501b7 100644 --- a/dom/cache/CacheChild.cpp +++ b/dom/cache/CacheChild.cpp @@ -124,7 +124,7 @@ CacheChild::StartDestroy() MOZ_ASSERT(!mListener); // Start actor destruction from parent process - unused << SendTeardown(); + Unused << SendTeardown(); } void diff --git a/dom/cache/CacheOpParent.cpp b/dom/cache/CacheOpParent.cpp index f0d3ca06d2..1077d4e8ab 100644 --- a/dom/cache/CacheOpParent.cpp +++ b/dom/cache/CacheOpParent.cpp @@ -56,7 +56,7 @@ CacheOpParent::Execute(ManagerId* aManagerId) RefPtr manager; nsresult rv = Manager::GetOrCreate(aManagerId, getter_AddRefs(manager)); if (NS_WARN_IF(NS_FAILED(rv))) { - unused << Send__delete__(this, ErrorResult(rv), void_t()); + Unused << Send__delete__(this, ErrorResult(rv), void_t()); return; } @@ -144,7 +144,7 @@ CacheOpParent::OnPrincipalVerified(nsresult aRv, ManagerId* aManagerId) mVerifier = nullptr; if (NS_WARN_IF(NS_FAILED(aRv))) { - unused << Send__delete__(this, ErrorResult(aRv), void_t()); + Unused << Send__delete__(this, ErrorResult(aRv), void_t()); return; } @@ -165,7 +165,7 @@ CacheOpParent::OnOpComplete(ErrorResult&& aRv, const CacheOpResult& aResult, // Never send an op-specific result if we have an error. Instead, send // void_t() to ensure that we don't leak actors on the child side. if (NS_WARN_IF(aRv.Failed())) { - unused << Send__delete__(this, aRv, void_t()); + Unused << Send__delete__(this, aRv, void_t()); aRv.SuppressException(); // We serialiazed it, as best we could. return; } @@ -190,7 +190,7 @@ CacheOpParent::OnOpComplete(ErrorResult&& aRv, const CacheOpResult& aResult, result.Add(aSavedRequestList[i], aStreamList); } - unused << Send__delete__(this, aRv, result.SendAsOpResult()); + Unused << Send__delete__(this, aRv, result.SendAsOpResult()); } already_AddRefed diff --git a/dom/cache/CachePushStreamChild.cpp b/dom/cache/CachePushStreamChild.cpp index 57eca994ef..47ac0c9592 100644 --- a/dom/cache/CachePushStreamChild.cpp +++ b/dom/cache/CachePushStreamChild.cpp @@ -189,7 +189,7 @@ CachePushStreamChild::DoRead() // If we read any data from the stream, send it across. if (!buffer.IsEmpty()) { - unused << SendBuffer(buffer); + Unused << SendBuffer(buffer); } if (rv == NS_BASE_STREAM_WOULD_BLOCK) { @@ -252,7 +252,7 @@ CachePushStreamChild::OnEnd(nsresult aRv) } // This will trigger an ActorDestroy() from the parent side - unused << SendClose(aRv); + Unused << SendClose(aRv); } } // namespace cache diff --git a/dom/cache/CachePushStreamParent.cpp b/dom/cache/CachePushStreamParent.cpp index 9c145c2d5a..3690f8f7b4 100644 --- a/dom/cache/CachePushStreamParent.cpp +++ b/dom/cache/CachePushStreamParent.cpp @@ -79,7 +79,7 @@ bool CachePushStreamParent::RecvClose(const nsresult& aRv) { mWriter->CloseWithStatus(aRv); - unused << Send__delete__(this); + Unused << Send__delete__(this); return true; } diff --git a/dom/cache/CacheStorage.cpp b/dom/cache/CacheStorage.cpp index fa33bc0196..2e4fda9801 100644 --- a/dom/cache/CacheStorage.cpp +++ b/dom/cache/CacheStorage.cpp @@ -32,7 +32,7 @@ namespace mozilla { namespace dom { namespace cache { -using mozilla::unused; +using mozilla::Unused; using mozilla::ErrorResult; using mozilla::dom::workers::WorkerPrivate; using mozilla::ipc::BackgroundChild; diff --git a/dom/cache/CacheStorageChild.cpp b/dom/cache/CacheStorageChild.cpp index 9d05c112a8..0d03f561ac 100644 --- a/dom/cache/CacheStorageChild.cpp +++ b/dom/cache/CacheStorageChild.cpp @@ -53,7 +53,7 @@ CacheStorageChild::ExecuteOp(nsIGlobalObject* aGlobal, Promise* aPromise, nsISupports* aParent, const CacheOpArgs& aArgs) { mNumChildActors += 1; - unused << SendPCacheOpConstructor( + Unused << SendPCacheOpConstructor( new CacheOpChild(GetFeature(), aGlobal, aParent, aPromise), aArgs); } @@ -99,7 +99,7 @@ CacheStorageChild::StartDestroy() MOZ_ASSERT(!mListener); // Start actor destruction from parent process - unused << SendTeardown(); + Unused << SendTeardown(); } void diff --git a/dom/cache/CacheStorageParent.cpp b/dom/cache/CacheStorageParent.cpp index b4b83d1e36..1e4217e60d 100644 --- a/dom/cache/CacheStorageParent.cpp +++ b/dom/cache/CacheStorageParent.cpp @@ -101,7 +101,7 @@ CacheStorageParent::RecvPCacheOpConstructor(PCacheOpParent* aActor, } if (NS_WARN_IF(NS_FAILED(mVerifiedStatus))) { - unused << CacheOpParent::Send__delete__(actor, ErrorResult(mVerifiedStatus), + Unused << CacheOpParent::Send__delete__(actor, ErrorResult(mVerifiedStatus), void_t()); return true; } diff --git a/dom/cache/CacheStreamControlChild.cpp b/dom/cache/CacheStreamControlChild.cpp index 78b12221dd..3e23c5f209 100644 --- a/dom/cache/CacheStreamControlChild.cpp +++ b/dom/cache/CacheStreamControlChild.cpp @@ -101,7 +101,7 @@ CacheStreamControlChild::SerializeFds(CacheReadStream* aReadStreamOut, if (!aFds.IsEmpty()) { fdSet = Manager()->SendPFileDescriptorSetConstructor(aFds[0]); for (uint32_t i = 1; i < aFds.Length(); ++i) { - unused << fdSet->SendAddFileDescriptor(aFds[i]); + Unused << fdSet->SendAddFileDescriptor(aFds[i]); } } @@ -128,14 +128,14 @@ CacheStreamControlChild::DeserializeFds(const CacheReadStream& aReadStream, fdSetActor->ForgetFileDescriptors(aFdsOut); MOZ_ASSERT(!aFdsOut.IsEmpty()); - unused << fdSetActor->Send__delete__(fdSetActor); + Unused << fdSetActor->Send__delete__(fdSetActor); } void CacheStreamControlChild::NoteClosedAfterForget(const nsID& aId) { NS_ASSERT_OWNINGTHREAD(CacheStreamControlChild); - unused << SendNoteClosed(aId); + Unused << SendNoteClosed(aId); // A stream has closed. If we delayed StartDestry() due to this stream // being read, then we should check to see if any of the remaining streams diff --git a/dom/cache/CacheStreamControlParent.cpp b/dom/cache/CacheStreamControlParent.cpp index 2aac608de5..07a0341d06 100644 --- a/dom/cache/CacheStreamControlParent.cpp +++ b/dom/cache/CacheStreamControlParent.cpp @@ -61,7 +61,7 @@ CacheStreamControlParent::SerializeFds(CacheReadStream* aReadStreamOut, if (!aFds.IsEmpty()) { fdSet = Manager()->SendPFileDescriptorSetConstructor(aFds[0]); for (uint32_t i = 1; i < aFds.Length(); ++i) { - unused << fdSet->SendAddFileDescriptor(aFds[i]); + Unused << fdSet->SendAddFileDescriptor(aFds[i]); } } @@ -141,7 +141,7 @@ CacheStreamControlParent::Close(const nsID& aId) { NS_ASSERT_OWNINGTHREAD(CacheStreamControlParent); NotifyClose(aId); - unused << SendClose(aId); + Unused << SendClose(aId); } void @@ -149,7 +149,7 @@ CacheStreamControlParent::CloseAll() { NS_ASSERT_OWNINGTHREAD(CacheStreamControlParent); NotifyCloseAll(); - unused << SendCloseAll(); + Unused << SendCloseAll(); } void diff --git a/dom/cache/FileUtils.cpp b/dom/cache/FileUtils.cpp index c17cc38d11..a7a4ef1bff 100644 --- a/dom/cache/FileUtils.cpp +++ b/dom/cache/FileUtils.cpp @@ -187,7 +187,7 @@ BodyCancelWrite(nsIFile* aBaseDir, nsISupports* aCopyContext) MOZ_ASSERT(aCopyContext); nsresult rv = NS_CancelAsyncCopy(aCopyContext, NS_ERROR_ABORT); - unused << NS_WARN_IF(NS_FAILED(rv)); + Unused << NS_WARN_IF(NS_FAILED(rv)); // The partially written file must be cleaned up after the async copy // makes its callback. diff --git a/dom/cache/Manager.cpp b/dom/cache/Manager.cpp index ec0a71a66c..42ca203393 100644 --- a/dom/cache/Manager.cpp +++ b/dom/cache/Manager.cpp @@ -141,7 +141,7 @@ public: } rv = BodyDeleteFiles(dbDir, mDeletedBodyIdList); - unused << NS_WARN_IF(NS_FAILED(rv)); + Unused << NS_WARN_IF(NS_FAILED(rv)); aResolver->Resolve(rv); } @@ -900,7 +900,7 @@ private: } rv = trans.Commit(); - unused << NS_WARN_IF(NS_FAILED(rv)); + Unused << NS_WARN_IF(NS_FAILED(rv)); DoResolve(rv); } diff --git a/dom/cache/ReadStream.cpp b/dom/cache/ReadStream.cpp index 82bcc93afc..edf93af3ad 100644 --- a/dom/cache/ReadStream.cpp +++ b/dom/cache/ReadStream.cpp @@ -20,7 +20,7 @@ namespace mozilla { namespace dom { namespace cache { -using mozilla::unused; +using mozilla::Unused; using mozilla::ipc::FileDescriptor; // ---------------------------------------------------------------------------- diff --git a/dom/cache/TypeUtils.cpp b/dom/cache/TypeUtils.cpp index 14add73018..119a758b0a 100644 --- a/dom/cache/TypeUtils.cpp +++ b/dom/cache/TypeUtils.cpp @@ -78,7 +78,7 @@ SerializeNormalStream(nsIInputStream* aStream, CacheReadStream& aReadStreamOut) fdSet = manager->SendPFileDescriptorSetConstructor(fds[0]); for (uint32_t i = 1; i < fds.Length(); ++i) { - unused << fdSet->SendAddFileDescriptor(fds[i]); + Unused << fdSet->SendAddFileDescriptor(fds[i]); } } diff --git a/dom/camera/CameraControlImpl.cpp b/dom/camera/CameraControlImpl.cpp index 875eb89393..20c1ef9ff6 100644 --- a/dom/camera/CameraControlImpl.cpp +++ b/dom/camera/CameraControlImpl.cpp @@ -18,7 +18,7 @@ using namespace mozilla; /* static */ StaticRefPtr CameraControlImpl::sCameraThread; CameraControlImpl::CameraControlImpl() - : mListenerLock(PR_NewRWLock(PR_RWLOCK_RANK_NONE, "CameraControlImpl.Listeners.Lock")) + : mListenerLock("mozilla::camera::CameraControlImpl.Listeners") , mPreviewState(CameraControlListener::kPreviewStopped) , mHardwareState(CameraControlListener::kHardwareUninitialized) , mHardwareStateChangeReason(NS_OK) @@ -26,6 +26,18 @@ CameraControlImpl::CameraControlImpl() DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this); mCurrentConfiguration.mMode = ICameraControl::kUnspecifiedMode; + class Delegate : public nsRunnable + { + public: + NS_IMETHOD + Run() + { + char stackBaseGuess; + profiler_register_thread("CameraThread", &stackBaseGuess); + return NS_OK; + } + }; + // reuse the same camera thread to conserve resources nsCOMPtr ct = do_QueryInterface(sCameraThread); if (ct) { @@ -35,34 +47,14 @@ CameraControlImpl::CameraControlImpl() if (NS_FAILED(rv)) { MOZ_CRASH("Failed to create new Camera Thread"); } + mCameraThread->Dispatch(new Delegate(), NS_DISPATCH_NORMAL); sCameraThread = mCameraThread; } - - // Care must be taken with the mListenerLock read-write lock to prevent - // deadlocks. Currently this is handled by ensuring that any attempts to - // acquire the lock for writing (as in Add/RemoveListener()) happen in a - // runnable dispatched to the Camera Thread--even if the method is being - // called from that thread. This ensures that if a registered listener - // (which is invoked with a read-lock) tries to call Add/RemoveListener(), - // the lock-for-writing attempt won't happen until the listener has - // completed. - // - // Multiple parallel listeners being invoked are not a problem because - // the read-write lock allows multiple simultaneous read-locks. - if (!mListenerLock) { - MOZ_CRASH("Out of memory getting new PRRWLock"); - } } CameraControlImpl::~CameraControlImpl() { DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this); - - MOZ_ASSERT(mListenerLock, "mListenerLock missing in ~CameraControlImpl()"); - if (mListenerLock) { - PR_DestroyRWLock(mListenerLock); - mListenerLock = nullptr; - } } void @@ -72,7 +64,7 @@ CameraControlImpl::OnHardwareStateChange(CameraControlListener::HardwareState aN // This callback can run on threads other than the Main Thread and // the Camera Thread. On Gonk, it may be called from the camera's // local binder thread, should the mediaserver process die. - RwLockAutoEnterRead lock(mListenerLock); + MutexAutoLock lock(mListenerLock); if (aNewState == mHardwareState) { DOM_CAMERA_LOGI("OnHardwareStateChange: state did not change from %d\n", mHardwareState); @@ -101,7 +93,7 @@ void CameraControlImpl::OnConfigurationChange() { MOZ_ASSERT(NS_GetCurrentThread() == mCameraThread); - RwLockAutoEnterRead lock(mListenerLock); + MutexAutoLock lock(mListenerLock); DOM_CAMERA_LOGI("OnConfigurationChange : %zu listeners\n", mListeners.Length()); @@ -117,7 +109,7 @@ CameraControlImpl::OnAutoFocusComplete(bool aAutoFocusSucceeded) // This callback can run on threads other than the Main Thread and // the Camera Thread. On Gonk, it is called from the camera // library's auto focus thread. - RwLockAutoEnterRead lock(mListenerLock); + MutexAutoLock lock(mListenerLock); for (uint32_t i = 0; i < mListeners.Length(); ++i) { CameraControlListener* l = mListeners[i]; @@ -128,7 +120,7 @@ CameraControlImpl::OnAutoFocusComplete(bool aAutoFocusSucceeded) void CameraControlImpl::OnAutoFocusMoving(bool aIsMoving) { - RwLockAutoEnterRead lock(mListenerLock); + MutexAutoLock lock(mListenerLock); for (uint32_t i = 0; i < mListeners.Length(); ++i) { CameraControlListener* l = mListeners[i]; @@ -142,7 +134,7 @@ CameraControlImpl::OnFacesDetected(const nsTArray& aFaces) // This callback can run on threads other than the Main Thread and // the Camera Thread. On Gonk, it is called from the camera // library's face detection thread. - RwLockAutoEnterRead lock(mListenerLock); + MutexAutoLock lock(mListenerLock); for (uint32_t i = 0; i < mListeners.Length(); ++i) { CameraControlListener* l = mListeners[i]; @@ -151,12 +143,12 @@ CameraControlImpl::OnFacesDetected(const nsTArray& aFaces) } void -CameraControlImpl::OnTakePictureComplete(uint8_t* aData, uint32_t aLength, const nsAString& aMimeType) +CameraControlImpl::OnTakePictureComplete(const uint8_t* aData, uint32_t aLength, const nsAString& aMimeType) { // This callback can run on threads other than the Main Thread and // the Camera Thread. On Gonk, it is called from the camera // library's snapshot thread. - RwLockAutoEnterRead lock(mListenerLock); + MutexAutoLock lock(mListenerLock); for (uint32_t i = 0; i < mListeners.Length(); ++i) { CameraControlListener* l = mListeners[i]; @@ -164,13 +156,26 @@ CameraControlImpl::OnTakePictureComplete(uint8_t* aData, uint32_t aLength, const } } +void +CameraControlImpl::OnPoster(dom::BlobImpl* aBlobImpl) +{ + // This callback can run on threads other than the Main Thread and + // the Camera Thread. + MutexAutoLock lock(mListenerLock); + + for (uint32_t i = 0; i < mListeners.Length(); ++i) { + CameraControlListener* l = mListeners[i]; + l->OnPoster(aBlobImpl); + } +} + void CameraControlImpl::OnShutter() { // This callback can run on threads other than the Main Thread and // the Camera Thread. On Gonk, it is called from the camera driver's // preview thread. - RwLockAutoEnterRead lock(mListenerLock); + MutexAutoLock lock(mListenerLock); for (uint32_t i = 0; i < mListeners.Length(); ++i) { CameraControlListener* l = mListeners[i]; @@ -185,7 +190,7 @@ CameraControlImpl::OnRecorderStateChange(CameraControlListener::RecorderState aS // This callback can run on threads other than the Main Thread and // the Camera Thread. On Gonk, it is called from the media encoder // thread. - RwLockAutoEnterRead lock(mListenerLock); + MutexAutoLock lock(mListenerLock); for (uint32_t i = 0; i < mListeners.Length(); ++i) { CameraControlListener* l = mListeners[i]; @@ -199,7 +204,7 @@ CameraControlImpl::OnPreviewStateChange(CameraControlListener::PreviewState aNew // This callback runs on the Main Thread and the Camera Thread, and // may run on the local binder thread, should the mediaserver // process die. - RwLockAutoEnterRead lock(mListenerLock); + MutexAutoLock lock(mListenerLock); if (aNewState == mPreviewState) { DOM_CAMERA_LOGI("OnPreviewStateChange: state did not change from %d\n", mPreviewState); @@ -226,7 +231,7 @@ void CameraControlImpl::OnRateLimitPreview(bool aLimit) { // This function runs on neither the Main Thread nor the Camera Thread. - RwLockAutoEnterRead lock(mListenerLock); + MutexAutoLock lock(mListenerLock); DOM_CAMERA_LOGI("OnRateLimitPreview: %d\n", aLimit); @@ -241,7 +246,7 @@ CameraControlImpl::OnNewPreviewFrame(layers::Image* aImage, uint32_t aWidth, uin { // This function runs on neither the Main Thread nor the Camera Thread. // On Gonk, it is called from the camera driver's preview thread. - RwLockAutoEnterRead lock(mListenerLock); + MutexAutoLock lock(mListenerLock); DOM_CAMERA_LOGI("OnNewPreviewFrame: we have %zu preview frame listener(s)\n", mListeners.Length()); @@ -261,7 +266,7 @@ CameraControlImpl::OnUserError(CameraControlListener::UserContext aContext, { // This callback can run on threads other than the Main Thread and // the Camera Thread. - RwLockAutoEnterRead lock(mListenerLock); + MutexAutoLock lock(mListenerLock); const char* context[] = { "StartCamera", @@ -272,6 +277,8 @@ CameraControlImpl::OnUserError(CameraControlListener::UserContext aContext, "TakePicture", "StartRecording", "StopRecording", + "PauseRecording", + "ResumeRecording", "SetConfiguration", "StartPreview", "StopPreview", @@ -300,7 +307,7 @@ CameraControlImpl::OnSystemError(CameraControlListener::SystemContext aContext, { // This callback can run on threads other than the Main Thread and // the Camera Thread. - RwLockAutoEnterRead lock(mListenerLock); + MutexAutoLock lock(mListenerLock); const char* context[] = { "Camera Service" @@ -576,6 +583,48 @@ CameraControlImpl::StopRecording() return Dispatch(new Message(this, CameraControlListener::kInStopRecording)); } +nsresult +CameraControlImpl::PauseRecording() +{ + class Message : public ControlMessage + { + public: + Message(CameraControlImpl* aCameraControl, + CameraControlListener::UserContext aContext) + : ControlMessage(aCameraControl, aContext) + { } + + nsresult + RunImpl() override + { + return mCameraControl->PauseRecordingImpl(); + } + }; + + return Dispatch(new Message(this, CameraControlListener::kInPauseRecording)); +} + +nsresult +CameraControlImpl::ResumeRecording() +{ + class Message : public ControlMessage + { + public: + Message(CameraControlImpl* aCameraControl, + CameraControlListener::UserContext aContext) + : ControlMessage(aCameraControl, aContext) + { } + + nsresult + RunImpl() override + { + return mCameraControl->ResumeRecordingImpl(); + } + }; + + return Dispatch(new Message(this, CameraControlListener::kInResumeRecording)); +} + nsresult CameraControlImpl::StartPreview() { @@ -676,7 +725,7 @@ protected: void CameraControlImpl::AddListenerImpl(already_AddRefed aListener) { - RwLockAutoEnterWrite lock(mListenerLock); + MutexAutoLock lock(mListenerLock); CameraControlListener* l = *mListeners.AppendElement() = aListener; DOM_CAMERA_LOGI("Added camera control listener %p\n", l); @@ -714,7 +763,7 @@ CameraControlImpl::AddListener(CameraControlListener* aListener) void CameraControlImpl::RemoveListenerImpl(CameraControlListener* aListener) { - RwLockAutoEnterWrite lock(mListenerLock); + MutexAutoLock lock(mListenerLock); RefPtr l(aListener); mListeners.RemoveElement(l); diff --git a/dom/camera/CameraControlImpl.h b/dom/camera/CameraControlImpl.h index fc3b647aa0..d3a6e47bc0 100644 --- a/dom/camera/CameraControlImpl.h +++ b/dom/camera/CameraControlImpl.h @@ -9,9 +9,9 @@ #include "nsWeakPtr.h" #include "mozilla/Attributes.h" #include "mozilla/ReentrantMonitor.h" +#include "mozilla/Mutex.h" #include "nsIFile.h" #include "nsProxyRelease.h" -#include "AutoRwLock.h" #include "ICameraControl.h" #include "CameraCommon.h" #include "DeviceStorage.h" @@ -20,9 +20,13 @@ namespace mozilla { +namespace dom { + class BlobImpl; +} // namespace dom + namespace layers { class Image; -} +} // namespace layers class CameraControlImpl : public ICameraControl { @@ -44,6 +48,8 @@ public: virtual nsresult StartRecording(DeviceStorageFileDescriptor* aFileDescriptor, const StartRecordingOptions* aOptions) override; virtual nsresult StopRecording() override; + virtual nsresult PauseRecording() override; + virtual nsresult ResumeRecording() override; virtual nsresult ResumeContinuousFocus() override; // Event handlers called directly from outside this class. @@ -56,7 +62,8 @@ protected: // Event handlers. void OnAutoFocusComplete(bool aAutoFocusSucceeded); void OnFacesDetected(const nsTArray& aFaces); - void OnTakePictureComplete(uint8_t* aData, uint32_t aLength, const nsAString& aMimeType); + void OnTakePictureComplete(const uint8_t* aData, uint32_t aLength, const nsAString& aMimeType); + void OnPoster(dom::BlobImpl* aBlobImpl); void OnRateLimitPreview(bool aLimit); bool OnNewPreviewFrame(layers::Image* aImage, uint32_t aWidth, uint32_t aHeight); @@ -84,7 +91,7 @@ protected: void AddListenerImpl(already_AddRefed aListener); void RemoveListenerImpl(CameraControlListener* aListener); nsTArray > mListeners; - PRRWLock* mListenerLock; + mutable Mutex mListenerLock; class ControlMessage; class ListenerMessage; @@ -116,6 +123,8 @@ protected: virtual nsresult StartRecordingImpl(DeviceStorageFileDescriptor* aFileDescriptor, const StartRecordingOptions* aOptions) = 0; virtual nsresult StopRecordingImpl() = 0; + virtual nsresult PauseRecordingImpl() = 0; + virtual nsresult ResumeRecordingImpl() = 0; virtual nsresult ResumeContinuousFocusImpl() = 0; virtual nsresult PushParametersImpl() = 0; virtual nsresult PullParametersImpl() = 0; diff --git a/dom/camera/CameraControlListener.h b/dom/camera/CameraControlListener.h index 532fdaf5ab..232791e937 100644 --- a/dom/camera/CameraControlListener.h +++ b/dom/camera/CameraControlListener.h @@ -10,6 +10,10 @@ namespace mozilla { +namespace dom { + class BlobImpl; +} + namespace layers { class Image; } @@ -60,6 +64,10 @@ public: { kRecorderStopped, kRecorderStarted, + kRecorderPaused, + kRecorderResumed, + kPosterCreated, + kPosterFailed, #ifdef MOZ_B2G_CAMERA kFileSizeLimitReached, kVideoLengthLimitReached, @@ -89,8 +97,9 @@ public: virtual void OnAutoFocusComplete(bool aAutoFocusSucceeded) { } virtual void OnAutoFocusMoving(bool aIsMoving) { } - virtual void OnTakePictureComplete(uint8_t* aData, uint32_t aLength, const nsAString& aMimeType) { } + virtual void OnTakePictureComplete(const uint8_t* aData, uint32_t aLength, const nsAString& aMimeType) { } virtual void OnFacesDetected(const nsTArray& aFaces) { } + virtual void OnPoster(dom::BlobImpl* aBlobImpl) { } enum UserContext { @@ -102,6 +111,8 @@ public: kInTakePicture, kInStartRecording, kInStopRecording, + kInPauseRecording, + kInResumeRecording, kInSetConfiguration, kInStartPreview, kInStopPreview, diff --git a/dom/camera/DOMCameraControl.cpp b/dom/camera/DOMCameraControl.cpp index 299024d7e2..c69533dd4e 100644 --- a/dom/camera/DOMCameraControl.cpp +++ b/dom/camera/DOMCameraControl.cpp @@ -37,6 +37,7 @@ #include "mozilla/dom/CameraFacesDetectedEventBinding.h" #include "mozilla/dom/CameraStateChangeEvent.h" #include "mozilla/dom/CameraClosedEvent.h" +#include "mozilla/dom/VideoStreamTrack.h" #include "mozilla/dom/BlobEvent.h" #include "DOMCameraDetectedFace.h" #include "mozilla/dom/BindingUtils.h" @@ -46,6 +47,45 @@ using namespace mozilla; using namespace mozilla::dom; using namespace mozilla::ipc; +class mozilla::TrackCreatedListener : public MediaStreamListener +{ +public: + explicit TrackCreatedListener(nsDOMCameraControl* aCameraControl) + : mCameraControl(aCameraControl) {} + + void Forget() { mCameraControl = nullptr; } + + void DoNotifyTrackCreated(TrackID aTrackID) + { + MOZ_ASSERT(NS_IsMainThread()); + + if (!mCameraControl) { + return; + } + + mCameraControl->TrackCreated(aTrackID); + } + + void NotifyQueuedTrackChanges(MediaStreamGraph* aGraph, TrackID aID, + StreamTime aTrackOffset, uint32_t aTrackEvents, + const MediaSegment& aQueuedMedia, + MediaStream* aInputStream, + TrackID aInputTrackID) override + { + if (aTrackEvents & TRACK_EVENT_CREATED) { + nsCOMPtr runnable = + NS_NewRunnableMethodWithArgs( + this, &TrackCreatedListener::DoNotifyTrackCreated, aID); + aGraph->DispatchToMainThreadAfterStreamStateUpdate(runnable.forget()); + } + } + +protected: + ~TrackCreatedListener() {} + + nsDOMCameraControl* mCameraControl; +}; + #ifdef MOZ_WIDGET_GONK StaticRefPtr nsDOMCameraControl::sCachedCameraControl; /* static */ nsresult nsDOMCameraControl::sCachedCameraControlStartResult = NS_OK; @@ -82,6 +122,19 @@ nsDOMCameraControl::HasSupport(JSContext* aCx, JSObject* aGlobal) return Navigator::HasCameraSupport(aCx, aGlobal); } +static nsresult +RegisterStorageRequestEvents(DOMRequest* aRequest, nsIDOMEventListener* aListener) +{ + EventListenerManager* elm = aRequest->GetOrCreateListenerManager(); + if (NS_WARN_IF(!elm)) { + return NS_ERROR_UNEXPECTED; + } + + elm->AddEventListener(NS_LITERAL_STRING("success"), aListener, false, false); + elm->AddEventListener(NS_LITERAL_STRING("error"), aListener, false, false); + return NS_OK; +} + class mozilla::StartRecordingHelper : public nsIDOMEventListener { public: @@ -90,6 +143,7 @@ public: explicit StartRecordingHelper(nsDOMCameraControl* aDOMCameraControl) : mDOMCameraControl(aDOMCameraControl) + , mState(false) { MOZ_COUNT_CTOR(StartRecordingHelper); } @@ -98,10 +152,12 @@ protected: virtual ~StartRecordingHelper() { MOZ_COUNT_DTOR(StartRecordingHelper); + mDOMCameraControl->OnCreatedFileDescriptor(mState); } protected: RefPtr mDOMCameraControl; + bool mState; }; NS_IMETHODIMP @@ -109,8 +165,7 @@ StartRecordingHelper::HandleEvent(nsIDOMEvent* aEvent) { nsString eventType; aEvent->GetType(eventType); - - mDOMCameraControl->OnCreatedFileDescriptor(eventType.EqualsLiteral("success")); + mState = eventType.EqualsLiteral("success"); return NS_OK; } @@ -202,6 +257,7 @@ nsDOMCameraControl::nsDOMCameraControl(uint32_t aCameraId, , mWindow(aWindow) , mPreviewState(CameraControlListener::kPreviewStopped) , mRecording(false) + , mRecordingStoppedDeferred(false) , mSetInitialConfig(false) { DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this); @@ -263,6 +319,11 @@ nsDOMCameraControl::nsDOMCameraControl(uint32_t aCameraId, #endif mCurrentConfiguration = initialConfig.forget(); + // Register a TrackCreatedListener directly on CameraPreviewMediaStream + // so we can know the TrackID of the video track. + mTrackCreatedListener = new TrackCreatedListener(this); + mInput->AddListener(mTrackCreatedListener); + // Register the playback listener directly on the camera input stream. // We want as low latency as possible for the camera, thus avoiding // MediaStreamGraph altogether. Don't do the regular InitStreamCommon() @@ -318,6 +379,10 @@ nsDOMCameraControl::~nsDOMCameraControl() mInput->Destroy(); mInput = nullptr; } + if (mTrackCreatedListener) { + mTrackCreatedListener->Forget(); + mTrackCreatedListener = nullptr; + } } JSObject* @@ -459,6 +524,19 @@ nsDOMCameraControl::GetCameraStream() const return mInput; } +void +nsDOMCameraControl::TrackCreated(TrackID aTrackID) { + // This track is not connected through a port. + MediaInputPort* inputPort = nullptr; + dom::VideoStreamTrack* track = + new dom::VideoStreamTrack(this, aTrackID); + RefPtr port = + new TrackPort(inputPort, track, + TrackPort::InputPortOwnership::OWNED); + mTracks.AppendElement(port.forget()); + NotifyTrackAdded(track); +} + #define THROW_IF_NO_CAMERACONTROL(...) \ do { \ if (!mCameraControl) { \ @@ -759,7 +837,11 @@ nsDOMCameraControl::StartRecording(const CameraStartRecordingOptions& aOptions, return nullptr; } - if (mStartRecordingPromise || mRecording) { + // If we are trying to start recording, already recording or are still + // waiting for a poster to be created/fail, we need to wait + if (mStartRecordingPromise || mRecording || + mRecordingStoppedDeferred || + mOptions.mCreatePoster) { promise->MaybeReject(NS_ERROR_IN_PROGRESS); return promise.forget(); } @@ -778,20 +860,16 @@ nsDOMCameraControl::StartRecording(const CameraStartRecordingOptions& aOptions, return nullptr; } - mStartRecordingPromise = promise; - mOptions = aOptions; - - EventListenerManager* elm = request->GetOrCreateListenerManager(); - if (!elm) { + nsCOMPtr listener = new StartRecordingHelper(this); + aRv = RegisterStorageRequestEvents(request, listener); + if (aRv.Failed()) { NotifyRecordingStatusChange(NS_LITERAL_STRING("shutdown")); - aRv.Throw(NS_ERROR_UNEXPECTED); return nullptr; } + mStartRecordingPromise = promise; + mOptions = aOptions; mRecording = true; - nsCOMPtr listener = new StartRecordingHelper(this); - elm->AddEventListener(NS_LITERAL_STRING("success"), listener, false, false); - elm->AddEventListener(NS_LITERAL_STRING("error"), listener, false, false); return promise.forget(); } @@ -806,6 +884,7 @@ nsDOMCameraControl::OnCreatedFileDescriptor(bool aSucceeded) // Race condition where StopRecording comes in before we issue // the start recording request to Gonk rv = NS_ERROR_ABORT; + mOptions.mCreatePoster = false; } else if (aSucceeded && mDSFileDescriptor->mFileDescriptor.IsValid()) { ICameraControl::StartRecordingOptions o; @@ -813,6 +892,7 @@ nsDOMCameraControl::OnCreatedFileDescriptor(bool aSucceeded) o.maxFileSizeBytes = mOptions.mMaxFileSizeBytes; o.maxVideoLengthMs = mOptions.mMaxVideoLengthMs; o.autoEnableLowLightTorch = mOptions.mAutoEnableLowLightTorch; + o.createPoster = mOptions.mCreatePoster; rv = mCameraControl->StartRecording(mDSFileDescriptor.get(), &o); if (NS_SUCCEEDED(rv)) { return; @@ -842,6 +922,24 @@ nsDOMCameraControl::StopRecording(ErrorResult& aRv) aRv = mCameraControl->StopRecording(); } +void +nsDOMCameraControl::PauseRecording(ErrorResult& aRv) +{ + DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this); + THROW_IF_NO_CAMERACONTROL(); + + aRv = mCameraControl->PauseRecording(); +} + +void +nsDOMCameraControl::ResumeRecording(ErrorResult& aRv) +{ + DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this); + THROW_IF_NO_CAMERACONTROL(); + + aRv = mCameraControl->ResumeRecording(); +} + void nsDOMCameraControl::ResumePreview(ErrorResult& aRv) { @@ -1274,6 +1372,30 @@ nsDOMCameraControl::OnPreviewStateChange(CameraControlListener::PreviewState aSt DispatchPreviewStateEvent(aState); } +void +nsDOMCameraControl::OnPoster(BlobImpl* aPoster) +{ + DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this); + MOZ_ASSERT(NS_IsMainThread()); + MOZ_ASSERT(mOptions.mCreatePoster); + + RefPtr blob = Blob::Create(GetParentObject(), aPoster); + if (NS_WARN_IF(!blob)) { + OnRecorderStateChange(CameraControlListener::kPosterFailed, 0, 0); + return; + } + + BlobEventInit eventInit; + eventInit.mData = blob; + + RefPtr event = BlobEvent::Constructor(this, + NS_LITERAL_STRING("poster"), + eventInit); + + DispatchTrustedEvent(event); + OnRecorderStateChange(CameraControlListener::kPosterCreated, 0, 0); +} + void nsDOMCameraControl::OnRecorderStateChange(CameraControlListener::RecorderState aState, int32_t aArg, int32_t aTrackNum) @@ -1298,10 +1420,33 @@ nsDOMCameraControl::OnRecorderStateChange(CameraControlListener::RecorderState a break; case CameraControlListener::kRecorderStopped: + if (mOptions.mCreatePoster) { + mRecordingStoppedDeferred = true; + return; + } + NotifyRecordingStatusChange(NS_LITERAL_STRING("shutdown")); state = NS_LITERAL_STRING("Stopped"); break; + case CameraControlListener::kPosterCreated: + state = NS_LITERAL_STRING("PosterCreated"); + mOptions.mCreatePoster = false; + break; + + case CameraControlListener::kPosterFailed: + state = NS_LITERAL_STRING("PosterFailed"); + mOptions.mCreatePoster = false; + break; + + case CameraControlListener::kRecorderPaused: + state = NS_LITERAL_STRING("Paused"); + break; + + case CameraControlListener::kRecorderResumed: + state = NS_LITERAL_STRING("Resumed"); + break; + #ifdef MOZ_B2G_CAMERA case CameraControlListener::kFileSizeLimitReached: state = NS_LITERAL_STRING("FileSizeLimitReached"); @@ -1334,6 +1479,11 @@ nsDOMCameraControl::OnRecorderStateChange(CameraControlListener::RecorderState a } DispatchStateEvent(NS_LITERAL_STRING("recorderstatechange"), state); + + if (mRecordingStoppedDeferred && !mOptions.mCreatePoster) { + mRecordingStoppedDeferred = false; + OnRecorderStateChange(CameraControlListener::kRecorderStopped, 0, 0); + } } void @@ -1553,6 +1703,18 @@ nsDOMCameraControl::OnUserError(CameraControlListener::UserContext aContext, nsr NS_WARNING("Failed to stop recording"); return; + case CameraControlListener::kInPauseRecording: + // This method doesn't have any callbacks, so all we can do is log the + // failure. This only happens after the hardware has been released. + NS_WARNING("Failed to pause recording"); + return; + + case CameraControlListener::kInResumeRecording: + // This method doesn't have any callbacks, so all we can do is log the + // failure. This only happens after the hardware has been released. + NS_WARNING("Failed to resume recording"); + return; + case CameraControlListener::kInStartPreview: // This method doesn't have any callbacks, so all we can do is log the // failure. This only happens after the hardware has been released. diff --git a/dom/camera/DOMCameraControl.h b/dom/camera/DOMCameraControl.h index 413986cd5d..ecf9c72195 100644 --- a/dom/camera/DOMCameraControl.h +++ b/dom/camera/DOMCameraControl.h @@ -39,6 +39,8 @@ namespace dom { } // namespace dom class ErrorResult; class StartRecordingHelper; +class RecorderPosterHelper; +class TrackCreatedListener; #define NS_DOM_CAMERA_CONTROL_CID \ { 0x3700c096, 0xf920, 0x438d, \ @@ -72,6 +74,10 @@ public: MediaStream* GetCameraStream() const override; + // Called by TrackCreatedListener when the underlying track has been created. + // XXX Bug 1124630. This can be removed with CameraPreviewMediaStream. + void TrackCreated(TrackID aTrackID); + // Attributes. void GetEffect(nsString& aEffect, ErrorResult& aRv); void SetEffect(const nsAString& aEffect, ErrorResult& aRv); @@ -121,6 +127,8 @@ public: const nsAString& filename, ErrorResult& aRv); void StopRecording(ErrorResult& aRv); + void PauseRecording(ErrorResult& aRv); + void ResumeRecording(ErrorResult& aRv); void ResumePreview(ErrorResult& aRv); already_AddRefed ReleaseHardware(ErrorResult& aRv); void ResumeContinuousFocus(ErrorResult& aRv); @@ -142,6 +150,7 @@ public: IMPL_EVENT_HANDLER(focus) IMPL_EVENT_HANDLER(picture) IMPL_EVENT_HANDLER(configurationchange) + IMPL_EVENT_HANDLER(poster) protected: virtual ~nsDOMCameraControl(); @@ -165,6 +174,7 @@ protected: friend class DOMCameraControlListener; friend class mozilla::StartRecordingHelper; + friend class mozilla::RecorderPosterHelper; void OnCreatedFileDescriptor(bool aSucceeded); @@ -172,6 +182,7 @@ protected: void OnAutoFocusMoving(bool aIsMoving); void OnTakePictureComplete(nsIDOMBlob* aPicture); void OnFacesDetected(const nsTArray& aFaces); + void OnPoster(dom::BlobImpl* aPoster); void OnGetCameraComplete(); void OnHardwareStateChange(DOMCameraControlListener::HardwareState aState, nsresult aReason); @@ -220,6 +231,9 @@ protected: // our viewfinder stream RefPtr mInput; + // A listener on mInput for adding tracks to the DOM side. + RefPtr mTrackCreatedListener; + // set once when this object is created nsCOMPtr mWindow; @@ -227,6 +241,7 @@ protected: RefPtr mDSFileDescriptor; DOMCameraControlListener::PreviewState mPreviewState; bool mRecording; + bool mRecordingStoppedDeferred; bool mSetInitialConfig; #ifdef MOZ_WIDGET_GONK diff --git a/dom/camera/DOMCameraControlListener.cpp b/dom/camera/DOMCameraControlListener.cpp index ddad4296ea..83a3d9ea6d 100644 --- a/dom/camera/DOMCameraControlListener.cpp +++ b/dom/camera/DOMCameraControlListener.cpp @@ -341,18 +341,20 @@ DOMCameraControlListener::OnAutoFocusComplete(bool aAutoFocusSucceeded) } void -DOMCameraControlListener::OnTakePictureComplete(uint8_t* aData, uint32_t aLength, const nsAString& aMimeType) +DOMCameraControlListener::OnTakePictureComplete(const uint8_t* aData, uint32_t aLength, const nsAString& aMimeType) { class Callback : public DOMCallback { public: Callback(nsMainThreadPtrHandle aDOMCameraControl, - uint8_t* aData, uint32_t aLength, const nsAString& aMimeType) + const uint8_t* aData, uint32_t aLength, const nsAString& aMimeType) : DOMCallback(aDOMCameraControl) - , mData(aData) , mLength(aLength) , mMimeType(aMimeType) - { } + { + mData = (uint8_t*) malloc(aLength); + memcpy(mData, aData, aLength); + } void RunCallback(nsDOMCameraControl* aDOMCameraControl) override @@ -408,3 +410,27 @@ DOMCameraControlListener::OnUserError(UserContext aContext, nsresult aError) NS_DispatchToMainThread(new Callback(mDOMCameraControl, aContext, aError)); } + +void +DOMCameraControlListener::OnPoster(BlobImpl* aBlobImpl) +{ + class Callback : public DOMCallback + { + public: + Callback(nsMainThreadPtrHandle aDOMCameraControl, BlobImpl* aBlobImpl) + : DOMCallback(aDOMCameraControl) + , mBlobImpl(aBlobImpl) + { } + + void + RunCallback(nsDOMCameraControl* aDOMCameraControl) override + { + aDOMCameraControl->OnPoster(mBlobImpl); + } + + protected: + RefPtr mBlobImpl; + }; + + NS_DispatchToMainThread(new Callback(mDOMCameraControl, aBlobImpl)); +} diff --git a/dom/camera/DOMCameraControlListener.h b/dom/camera/DOMCameraControlListener.h index a5c30c6d00..0684b416fc 100644 --- a/dom/camera/DOMCameraControlListener.h +++ b/dom/camera/DOMCameraControlListener.h @@ -21,7 +21,7 @@ public: virtual void OnAutoFocusComplete(bool aAutoFocusSucceeded) override; virtual void OnAutoFocusMoving(bool aIsMoving) override; virtual void OnFacesDetected(const nsTArray& aFaces) override; - virtual void OnTakePictureComplete(uint8_t* aData, uint32_t aLength, const nsAString& aMimeType) override; + virtual void OnTakePictureComplete(const uint8_t* aData, uint32_t aLength, const nsAString& aMimeType) override; virtual void OnHardwareStateChange(HardwareState aState, nsresult aReason) override; virtual void OnPreviewStateChange(PreviewState aState) override; @@ -31,6 +31,7 @@ public: virtual void OnRateLimitPreview(bool aLimit) override; virtual bool OnNewPreviewFrame(layers::Image* aImage, uint32_t aWidth, uint32_t aHeight) override; virtual void OnUserError(UserContext aContext, nsresult aError) override; + virtual void OnPoster(dom::BlobImpl* aBlobImpl) override; protected: virtual ~DOMCameraControlListener(); diff --git a/dom/camera/GonkCameraControl.cpp b/dom/camera/GonkCameraControl.cpp index c32e473eae..84030ebe70 100644 --- a/dom/camera/GonkCameraControl.cpp +++ b/dom/camera/GonkCameraControl.cpp @@ -27,17 +27,22 @@ #include #include #include "GrallocImages.h" +#include "imgIEncoder.h" +#include "libyuv.h" +#include "nsNetUtil.h" // for NS_ReadInputStreamToBuffer #endif +#include "nsNetCID.h" // for NS_STREAMTRANSPORTSERVICE_CONTRACTID +#include "nsAutoPtr.h" // for nsAutoArrayPtr #include "nsCOMPtr.h" #include "nsMemory.h" #include "nsThread.h" +#include "nsITimer.h" #include "mozilla/FileUtils.h" #include "mozilla/Services.h" #include "mozilla/unused.h" #include "mozilla/ipc/FileDescriptorUtils.h" #include "nsAlgorithm.h" #include "nsPrintfCString.h" -#include "AutoRwLock.h" #include "GonkCameraHwMgr.h" #include "GonkRecorderProfiles.h" #include "CameraCommon.h" @@ -45,6 +50,7 @@ #include "DeviceStorageFileDescriptor.h" using namespace mozilla; +using namespace mozilla::dom; using namespace mozilla::layers; using namespace mozilla::gfx; using namespace mozilla::ipc; @@ -59,6 +65,9 @@ using namespace android; } \ } while(0) +static const unsigned long kAutoFocusCompleteTimeoutMs = 1000; +static const int32_t kAutoFocusCompleteTimeoutLimit = 3; + // Construct nsGonkCameraControl on the main thread. nsGonkCameraControl::nsGonkCameraControl(uint32_t aCameraId) : mCameraId(aCameraId) @@ -75,11 +84,20 @@ nsGonkCameraControl::nsGonkCameraControl(uint32_t aCameraId) #endif , mRecorderMonitor("GonkCameraControl::mRecorder.Monitor") , mVideoFile(nullptr) + , mCapturePoster(false) + , mAutoFocusPending(false) + , mAutoFocusCompleteExpired(0) + , mPrevFacesDetected(0) , mReentrantMonitor("GonkCameraControl::OnTakePicture.Monitor") { // Constructor runs on the main thread... DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this); mImageContainer = LayerManager::CreateImageContainer(); + + mAutoFocusCompleteTimer = do_CreateInstance(NS_TIMER_CONTRACTID); + if (NS_WARN_IF(!mAutoFocusCompleteTimer)) { + mAutoFocusCompleteExpired = kAutoFocusCompleteTimeoutLimit; + } } nsresult @@ -122,13 +140,19 @@ nsGonkCameraControl::StartInternal(const Configuration* aInitialConfig) case NS_ERROR_ALREADY_INITIALIZED: case NS_OK: break; - + default: return rv; } if (aInitialConfig) { - rv = SetConfigurationInternal(*aInitialConfig); + Configuration config; + rv = ValidateConfiguration(*aInitialConfig, config); + if (NS_WARN_IF(NS_FAILED(rv))) { + return rv; + } + + rv = SetConfigurationInternal(config); if (NS_WARN_IF(NS_FAILED(rv))) { // The initial configuration failed, close up the hardware StopInternal(); @@ -166,9 +190,11 @@ nsGonkCameraControl::Initialize() DOM_CAMERA_LOGI("Initializing camera %d (this=%p, mCameraHw=%p)\n", mCameraId, this, mCameraHw.get()); mCurrentConfiguration.mRecorderProfile.Truncate(); + mRequestedPreviewSize.width = UINT32_MAX; + mRequestedPreviewSize.height = UINT32_MAX; // Initialize our camera configuration database. - PullParametersImpl(); + mCameraHw->PullParameters(mParams); // Set preferred preview frame format. mParams.Set(CAMERA_PARAM_PREVIEWFORMAT, NS_LITERAL_STRING("yuv420sp")); @@ -261,7 +287,7 @@ nsGonkCameraControl::Initialize() DOM_CAMERA_LOGI(" - metering mode: '%s'\n", NS_ConvertUTF16toUTF8(mode).get()); } - + return NS_OK; } @@ -304,9 +330,19 @@ nsGonkCameraControl::ValidateConfiguration(const Configuration& aConfig, Configu return NS_ERROR_INVALID_ARG; } + if (mCurrentConfiguration.mMode == aConfig.mMode && + mCurrentConfiguration.mRecorderProfile.Equals(profile->GetName()) && + mRequestedPreviewSize.Equals(aConfig.mPreviewSize) && + mCurrentConfiguration.mPictureSize.Equals(aValidatedConfig.mPictureSize)) + { + DOM_CAMERA_LOGI("Camera configuration is unchanged\n"); + return NS_ERROR_ALREADY_INITIALIZED; + } + aValidatedConfig.mMode = aConfig.mMode; aValidatedConfig.mPreviewSize = aConfig.mPreviewSize; aValidatedConfig.mRecorderProfile = profile->GetName(); + mRequestedPreviewSize = aConfig.mPreviewSize; return NS_OK; } @@ -315,53 +351,46 @@ nsGonkCameraControl::SetConfigurationInternal(const Configuration& aConfig) { DOM_CAMERA_LOGT("%s:%d\n", __func__, __LINE__); - // Ensure sanity of all provided parameters and determine defaults if - // none are provided when given a new configuration - Configuration config; - nsresult rv = ValidateConfiguration(aConfig, config); + ICameraControlParameterSetAutoEnter set(this); + + nsresult rv; + switch (aConfig.mMode) { + case kPictureMode: + rv = SetPictureConfiguration(aConfig); + break; + + case kVideoMode: + rv = SetVideoConfiguration(aConfig); + break; + + default: + MOZ_ASSERT_UNREACHABLE("Unanticipated camera mode in SetConfigurationInternal()"); + rv = NS_ERROR_FAILURE; + break; + } + + DOM_CAMERA_LOGT("%s:%d\n", __func__, __LINE__); if (NS_WARN_IF(NS_FAILED(rv))) { + mRequestedPreviewSize.width = UINT32_MAX; + mRequestedPreviewSize.height = UINT32_MAX; return rv; } - { - ICameraControlParameterSetAutoEnter set(this); + rv = Set(CAMERA_PARAM_RECORDINGHINT, aConfig.mMode == kVideoMode); + if (NS_FAILED(rv)) { + DOM_CAMERA_LOGE("Failed to set recording hint (0x%x)\n", rv); + } - switch (config.mMode) { - case kPictureMode: - rv = SetPictureConfiguration(config); - break; + mCurrentConfiguration.mMode = aConfig.mMode; + mCurrentConfiguration.mRecorderProfile = aConfig.mRecorderProfile; - case kVideoMode: - rv = SetVideoConfiguration(config); - break; - - default: - MOZ_ASSERT_UNREACHABLE("Unanticipated camera mode in SetConfigurationInternal()"); - rv = NS_ERROR_FAILURE; - break; - } - - DOM_CAMERA_LOGT("%s:%d\n", __func__, __LINE__); - if (NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } - - rv = Set(CAMERA_PARAM_RECORDINGHINT, config.mMode == kVideoMode); - if (NS_FAILED(rv)) { - DOM_CAMERA_LOGE("Failed to set recording hint (0x%x)\n", rv); - } - - mCurrentConfiguration.mMode = config.mMode; - mCurrentConfiguration.mRecorderProfile = config.mRecorderProfile; - - if (config.mMode == kPictureMode) { - mCurrentConfiguration.mPictureSize = config.mPictureSize; - } else /* if config.mMode == kVideoMode */ { - // The following is best-effort; we don't currently support taking - // pictures while in video mode, but we should at least return - // sane values to OnConfigurationChange() handlers... - SetPictureSizeImpl(config.mPictureSize); - } + if (aConfig.mMode == kPictureMode) { + mCurrentConfiguration.mPictureSize = aConfig.mPictureSize; + } else /* if config.mMode == kVideoMode */ { + // The following is best-effort; we don't currently support taking + // pictures while in video mode, but we should at least return + // sane values to OnConfigurationChange() handlers... + SetPictureSizeImpl(aConfig.mPictureSize); } return NS_OK; } @@ -377,8 +406,19 @@ nsGonkCameraControl::SetConfigurationImpl(const Configuration& aConfig) return NS_ERROR_INVALID_ARG; } + Configuration config; + nsresult rv = ValidateConfiguration(aConfig, config); + if (rv == NS_ERROR_ALREADY_INITIALIZED) { + // Configuration did not change, so no need to stop/start the preview + // or push parameters to the camera hardware + OnConfigurationChange(); + return NS_OK; + } else if (NS_WARN_IF(NS_FAILED(rv))) { + return rv; + } + // Stop any currently running preview - nsresult rv = PausePreview(); + rv = PausePreview(); if (NS_FAILED(rv)) { DOM_CAMERA_LOGW("PausePreview() in SetConfigurationImpl() failed (0x%x)\n", rv); if (rv == NS_ERROR_NOT_INITIALIZED) { @@ -389,7 +429,7 @@ nsGonkCameraControl::SetConfigurationImpl(const Configuration& aConfig) } DOM_CAMERA_LOGT("%s:%d\n", __func__, __LINE__); - rv = SetConfigurationInternal(aConfig); + rv = SetConfigurationInternal(config); if (NS_WARN_IF(NS_FAILED(rv))) { StopPreviewImpl(); return rv; @@ -813,6 +853,12 @@ nsGonkCameraControl::AutoFocusImpl() if (mCameraHw->AutoFocus() != OK) { return NS_ERROR_FAILURE; } + + ReentrantMonitorAutoEnter mon(mReentrantMonitor); + mAutoFocusPending = true; + if (mAutoFocusCompleteTimer) { + mAutoFocusCompleteTimer->Cancel(); + } return NS_OK; } @@ -1110,7 +1156,13 @@ nsGonkCameraControl::PullParametersImpl() DOM_CAMERA_LOGI("Pulling camera parameters\n"); RETURN_IF_NO_CAMERA_HW(); - return mCameraHw->PullParameters(mParams); + nsresult rv = mCameraHw->PullParameters(mParams); + mParams.Get(CAMERA_PARAM_THUMBNAILSIZE, mLastThumbnailSize); + mParams.Get(CAMERA_PARAM_PICTURE_SIZE, mCurrentConfiguration.mPictureSize); + mParams.Get(CAMERA_PARAM_PREVIEWSIZE, mCurrentConfiguration.mPreviewSize); + mParams.Get(CAMERA_PARAM_VIDEOSIZE, mLastRecorderSize); + + return rv; } nsresult @@ -1229,6 +1281,7 @@ nsGonkCameraControl::StartRecordingImpl(DeviceStorageFileDescriptor* aFileDescri #endif OnRecorderStateChange(CameraControlListener::kRecorderStarted); + mCapturePoster = aOptions->createPoster; return NS_OK; } @@ -1273,6 +1326,9 @@ nsGonkCameraControl::StopRecordingImpl() return NS_OK; } #endif + if (mCapturePoster.exchange(false)) { + OnPoster(nullptr, 0); + } OnRecorderStateChange(CameraControlListener::kRecorderStopped); { @@ -1290,6 +1346,48 @@ nsGonkCameraControl::StopRecordingImpl() return NS_DispatchToMainThread(new RecordingComplete(mVideoFile.forget())); } +nsresult +nsGonkCameraControl::PauseRecordingImpl() +{ + ReentrantMonitorAutoEnter mon(mRecorderMonitor); + +#ifdef MOZ_WIDGET_GONK + if (!mRecorder) { + return NS_ERROR_NOT_AVAILABLE; + } + + int err = mRecorder->pause(); + switch (err) { + case OK: + break; + case INVALID_OPERATION: + return NS_ERROR_NOT_IMPLEMENTED; + default: + return NS_ERROR_FAILURE; + } +#endif + OnRecorderStateChange(CameraControlListener::kRecorderPaused); + return NS_OK; +} + +nsresult +nsGonkCameraControl::ResumeRecordingImpl() +{ + ReentrantMonitorAutoEnter mon(mRecorderMonitor); + +#ifdef MOZ_WIDGET_GONK + if (!mRecorder) { + return NS_ERROR_NOT_AVAILABLE; + } + + if (mRecorder->resume() != OK) { + return NS_ERROR_FAILURE; + } +#endif + OnRecorderStateChange(CameraControlListener::kRecorderResumed); + return NS_OK; +} + nsresult nsGonkCameraControl::ResumeContinuousFocusImpl() { @@ -1307,30 +1405,118 @@ nsGonkCameraControl::ResumeContinuousFocusImpl() return NS_OK; } +class AutoFocusMovingTimerCallback : public nsITimerCallback +{ +public: + NS_DECL_THREADSAFE_ISUPPORTS + + AutoFocusMovingTimerCallback(nsGonkCameraControl* aCameraControl) + : mCameraControl(aCameraControl) + { } + + NS_IMETHODIMP + Notify(nsITimer* aTimer) + { + mCameraControl->OnAutoFocusComplete(true, true); + return NS_OK; + } + +protected: + virtual ~AutoFocusMovingTimerCallback() + { } + + RefPtr mCameraControl; +}; + +NS_IMPL_ISUPPORTS(AutoFocusMovingTimerCallback, nsITimerCallback); + void -nsGonkCameraControl::OnAutoFocusComplete(bool aSuccess) +nsGonkCameraControl::OnAutoFocusMoving(bool aIsMoving) +{ + CameraControlImpl::OnAutoFocusMoving(aIsMoving); + + if (!aIsMoving) { + /* Some drivers do not signal us with the status of the continuous auto focus + operation, only the moving signal which comes first. As a result we need to + arm a timer to detect the driver behaviour and if necessary generate the + signal ourselves to update the application state. */ + int32_t expiredCount = 0; + + { + ReentrantMonitorAutoEnter mon(mReentrantMonitor); + + if (mAutoFocusCompleteTimer) { + mAutoFocusCompleteTimer->Cancel(); + + if (!mAutoFocusPending) { + RefPtr timerCb = new AutoFocusMovingTimerCallback(this); + nsresult rv = mAutoFocusCompleteTimer->InitWithCallback(timerCb, + kAutoFocusCompleteTimeoutMs, + nsITimer::TYPE_ONE_SHOT); + NS_WARN_IF(NS_FAILED(rv)); + } + return; + } + + if (!mAutoFocusPending) { + expiredCount = mAutoFocusCompleteExpired; + } + } + + if (expiredCount == kAutoFocusCompleteTimeoutLimit) { + OnAutoFocusComplete(true, true); + } + } +} + +void +nsGonkCameraControl::OnAutoFocusComplete(bool aSuccess, bool aExpired) { class AutoFocusComplete : public nsRunnable { public: - AutoFocusComplete(nsGonkCameraControl* aCameraControl, bool aSuccess) + AutoFocusComplete(nsGonkCameraControl* aCameraControl, bool aSuccess, bool aExpired) : mCameraControl(aCameraControl) , mSuccess(aSuccess) + , mExpired(aExpired) { } NS_IMETHODIMP Run() override { - mCameraControl->OnAutoFocusComplete(mSuccess); + mCameraControl->OnAutoFocusComplete(mSuccess, mExpired); return NS_OK; } protected: RefPtr mCameraControl; bool mSuccess; + bool mExpired; }; if (NS_GetCurrentThread() == mCameraThread) { + { + ReentrantMonitorAutoEnter mon(mReentrantMonitor); + + if (mAutoFocusPending) { + mAutoFocusPending = false; + } else if (mAutoFocusCompleteTimer) { + if (aExpired) { + NS_WARNING("Camera timed out waiting for OnAutoFocusComplete"); + ++mAutoFocusCompleteExpired; + } else { + mAutoFocusCompleteTimer->Cancel(); + --mAutoFocusCompleteExpired; + } + + if (mAutoFocusCompleteExpired == kAutoFocusCompleteTimeoutLimit || + mAutoFocusCompleteExpired == -kAutoFocusCompleteTimeoutLimit) + { + mAutoFocusCompleteTimer = nullptr; + } + } + } + /** * Auto focusing can change some of the camera's parameters, so * we need to pull a new set before notifying any clients. @@ -1344,7 +1530,7 @@ nsGonkCameraControl::OnAutoFocusComplete(bool aSuccess) * Because the callback needs to call PullParametersImpl(), * we need to dispatch this callback through the Camera Thread. */ - mCameraThread->Dispatch(new AutoFocusComplete(this, aSuccess), NS_DISPATCH_NORMAL); + mCameraThread->Dispatch(new AutoFocusComplete(this, aSuccess, aExpired), NS_DISPATCH_NORMAL); } bool @@ -1372,6 +1558,11 @@ nsGonkCameraControl::OnFacesDetected(camera_frame_metadata_t* aMetaData) nsTArray faces; uint32_t numFaces = aMetaData->number_of_faces; + if (numFaces == 0 && mPrevFacesDetected == 0) { + return; + } + mPrevFacesDetected = numFaces; + DOM_CAMERA_LOGI("Camera detected %d face(s)", numFaces); faces.SetCapacity(numFaces); @@ -1429,14 +1620,10 @@ nsGonkCameraControl::OnTakePictureComplete(uint8_t* aData, uint32_t aLength) { ReentrantMonitorAutoEnter mon(mReentrantMonitor); - uint8_t* data = new uint8_t[aLength]; - - memcpy(data, aData, aLength); - nsString s(NS_LITERAL_STRING("image/")); s.Append(mFileFormat); DOM_CAMERA_LOGI("Got picture, type '%s', %u bytes\n", NS_ConvertUTF16toUTF8(s).get(), aLength); - OnTakePictureComplete(data, aLength, s); + OnTakePictureComplete(aData, aLength, s); if (mResumePreviewAfterTakingPicture) { nsresult rv = StartPreview(); @@ -1911,11 +2098,13 @@ nsGonkCameraControl::SetupRecording(int aFd, int aRotation, NS_ERROR_INVALID_ARG); // adjust rotation by camera sensor offset - int r = aRotation; - r += mCameraHw->GetSensorOrientation(); - r = RationalizeRotation(r); - DOM_CAMERA_LOGI("setting video rotation to %d degrees (mapped from %d)\n", r, aRotation); - snprintf(buffer, SIZE, "video-param-rotation-angle-degrees=%d", r); + mVideoRotation = aRotation; + mVideoRotation += mCameraHw->GetSensorOrientation(); + mVideoRotation = RationalizeRotation(mVideoRotation); + DOM_CAMERA_LOGI("setting video rotation to %d degrees (mapped from %d)\n", + mVideoRotation, aRotation); + snprintf(buffer, SIZE, "video-param-rotation-angle-degrees=%d", + mVideoRotation); CHECK_SETARG_RETURN(mRecorder->setParameters(String8(buffer)), NS_ERROR_INVALID_ARG); @@ -1983,6 +2172,7 @@ nsGonkCameraControl::LoadRecorderProfiles() nsTArray::size_type bestIndexMatch = 0; int bestAreaMatch = 0; + uint32_t bestPriorityMatch = UINT32_MAX; // Limit profiles to those video sizes supported by the camera hardware... for (nsTArray::size_type i = 0; i < profiles.Length(); ++i) { @@ -1997,17 +2187,22 @@ nsGonkCameraControl::LoadRecorderProfiles() if (static_cast(width) == sizes[n].width && static_cast(height) == sizes[n].height) { mRecorderProfiles.Put(profiles[i]->GetName(), profiles[i]); + + // "Best" or default profile is the one with the lowest priority + // value and largest area. int area = width * height; - if (area > bestAreaMatch) { + uint32_t priority = profiles[i]->GetPriority(); + if (bestPriorityMatch > priority || + (bestPriorityMatch == priority && area > bestAreaMatch)) { bestIndexMatch = i; bestAreaMatch = area; + bestPriorityMatch = priority; } break; } } } - // Default profile is the one with the largest area. if (bestAreaMatch > 0) { nsAutoString name; name.AssignASCII("default"); @@ -2058,6 +2253,137 @@ nsGonkCameraControl::OnRateLimitPreview(bool aLimit) CameraControlImpl::OnRateLimitPreview(aLimit); } +void +nsGonkCameraControl::CreatePoster(Image* aImage, uint32_t aWidth, uint32_t aHeight, int32_t aRotation) +{ + class PosterRunnable : public nsRunnable { + public: + PosterRunnable(nsGonkCameraControl* aTarget, Image* aImage, + uint32_t aWidth, uint32_t aHeight, int32_t aRotation) + : mTarget(aTarget) + , mImage(aImage) + , mWidth(aWidth) + , mHeight(aHeight) + , mRotation(aRotation) + , mDst(nullptr) + , mDstLength(0) + { } + + virtual ~PosterRunnable() + { + mTarget->OnPoster(mDst, mDstLength); + } + + NS_IMETHODIMP Run() override + { +#ifdef MOZ_WIDGET_GONK + // NV21 (yuv420sp) is 12 bits / pixel + size_t srcLength = (mWidth * mHeight * 3 + 1) / 2; + + // ARGB is 32 bits / pixel + size_t tmpLength = mWidth * mHeight * sizeof(uint32_t); + nsAutoArrayPtr tmp; + tmp = new uint8_t[tmpLength]; + + GrallocImage* nativeImage = static_cast(mImage.get()); + android::sp graphicBuffer = nativeImage->GetGraphicBuffer(); + + void* graphicSrc = nullptr; + graphicBuffer->lock(GraphicBuffer::USAGE_SW_READ_MASK, &graphicSrc); + + uint32_t stride = mWidth * 4; + int err = libyuv::ConvertToARGB(static_cast(graphicSrc), + srcLength, tmp, stride, 0, 0, + mWidth, mHeight, mWidth, mHeight, + libyuv::kRotate0, libyuv::FOURCC_NV21); + + graphicBuffer->unlock(); + graphicSrc = nullptr; + graphicBuffer.clear(); + nativeImage = nullptr; + mImage = nullptr; + + if (NS_WARN_IF(err < 0)) { + DOM_CAMERA_LOGE("CreatePoster: to ARGB failed (%d)\n", err); + return NS_OK; + } + + nsCOMPtr encoder = + do_CreateInstance("@mozilla.org/image/encoder;2?type=image/jpeg"); + if (NS_WARN_IF(!encoder)) { + DOM_CAMERA_LOGE("CreatePoster: no JPEG encoder\n"); + return NS_OK; + } + + nsString opt; + nsresult rv = encoder->InitFromData(tmp, tmpLength, mWidth, + mHeight, stride, + imgIEncoder::INPUT_FORMAT_HOSTARGB, + opt); + if (NS_WARN_IF(NS_FAILED(rv))) { + DOM_CAMERA_LOGE("CreatePoster: encoder init failed (0x%x)\n", + rv); + return NS_OK; + } + + nsCOMPtr stream = do_QueryInterface(encoder); + if (NS_WARN_IF(!stream)) { + DOM_CAMERA_LOGE("CreatePoster: to input stream failed\n"); + return NS_OK; + } + + uint64_t length = 0; + rv = stream->Available(&length); + if (NS_WARN_IF(NS_FAILED(rv))) { + DOM_CAMERA_LOGE("CreatePoster: get length failed (0x%x)\n", + rv); + return NS_OK; + } + + rv = NS_ReadInputStreamToBuffer(stream, &mDst, length); + if (NS_WARN_IF(NS_FAILED(rv))) { + DOM_CAMERA_LOGE("CreatePoster: read failed (0x%x)\n", rv); + mDst = nullptr; + return NS_OK; + } + + mDstLength = length; +#endif + return NS_OK; + } + + private: + RefPtr mTarget; + RefPtr mImage; + int32_t mWidth; + int32_t mHeight; + int32_t mRotation; + void* mDst; + size_t mDstLength; + }; + + nsCOMPtr event = new PosterRunnable(this, aImage, + aWidth, + aHeight, + aRotation); + + nsCOMPtr target + = do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID); + MOZ_ASSERT(target); + + target->Dispatch(event, NS_DISPATCH_NORMAL); +} + +void +nsGonkCameraControl::OnPoster(void* aData, uint32_t aLength) +{ + RefPtr blobImpl; + if (aData) { + blobImpl = new BlobImplMemory(aData, aLength, NS_LITERAL_STRING("image/jpeg")); + } + CameraControlImpl::OnPoster(blobImpl); +} + void nsGonkCameraControl::OnNewPreviewFrame(layers::TextureClient* aBuffer) { @@ -2072,6 +2398,14 @@ nsGonkCameraControl::OnNewPreviewFrame(layers::TextureClient* aBuffer) mCurrentConfiguration.mPreviewSize.height); videoImage->SetData(data); + if (mCapturePoster.exchange(false)) { + CreatePoster(frame, + mCurrentConfiguration.mPreviewSize.width, + mCurrentConfiguration.mPreviewSize.height, + mVideoRotation); + return; + } + OnNewPreviewFrame(frame, mCurrentConfiguration.mPreviewSize.width, mCurrentConfiguration.mPreviewSize.height); #endif @@ -2107,7 +2441,7 @@ OnTakePictureError(nsGonkCameraControl* gc) void OnAutoFocusComplete(nsGonkCameraControl* gc, bool aSuccess) { - gc->OnAutoFocusComplete(aSuccess); + gc->OnAutoFocusComplete(aSuccess, false); } void diff --git a/dom/camera/GonkCameraControl.h b/dom/camera/GonkCameraControl.h index 2f8c942b09..e3a2e82804 100644 --- a/dom/camera/GonkCameraControl.h +++ b/dom/camera/GonkCameraControl.h @@ -34,6 +34,7 @@ #include "FallbackCameraPlatform.h" #endif +class nsITimer; namespace android { class GonkCameraHardware; @@ -46,6 +47,7 @@ namespace mozilla { namespace layers { class TextureClient; class ImageContainer; + class Image; } class nsGonkCameraControl : public CameraControlImpl @@ -53,11 +55,13 @@ class nsGonkCameraControl : public CameraControlImpl public: nsGonkCameraControl(uint32_t aCameraId); - void OnAutoFocusComplete(bool aSuccess); + void OnAutoFocusMoving(bool aIsMoving); + void OnAutoFocusComplete(bool aSuccess, bool aExpired); void OnFacesDetected(camera_frame_metadata_t* aMetaData); void OnTakePictureComplete(uint8_t* aData, uint32_t aLength); void OnTakePictureError(); void OnRateLimitPreview(bool aLimit); + void OnPoster(void* aData, uint32_t aLength); void OnNewPreviewFrame(layers::TextureClient* aBuffer); #ifdef MOZ_WIDGET_GONK void OnRecorderEvent(int msg, int ext1, int ext2); @@ -134,6 +138,8 @@ protected: virtual nsresult StartRecordingImpl(DeviceStorageFileDescriptor* aFileDescriptor, const StartRecordingOptions* aOptions = nullptr) override; virtual nsresult StopRecordingImpl() override; + virtual nsresult PauseRecordingImpl() override; + virtual nsresult ResumeRecordingImpl() override; virtual nsresult ResumeContinuousFocusImpl() override; virtual nsresult PushParametersImpl() override; virtual nsresult PullParametersImpl() override; @@ -147,6 +153,8 @@ protected: nsresult PausePreview(); nsresult GetSupportedSize(const Size& aSize, const nsTArray& supportedSizes, Size& best); + void CreatePoster(layers::Image* aImage, uint32_t aWidth, uint32_t aHeight, int32_t aRotation); + nsresult LoadRecorderProfiles(); static PLDHashOperator Enumerate(const nsAString& aProfileName, RecorderProfile* aProfile, @@ -171,6 +179,7 @@ protected: Size mLastThumbnailSize; Size mLastRecorderSize; + Size mRequestedPreviewSize; uint32_t mPreviewFps; bool mResumePreviewAfterTakingPicture; bool mFlashSupported; @@ -196,6 +205,15 @@ protected: RefPtr mVideoFile; nsString mFileFormat; + Atomic mCapturePoster; + int32_t mVideoRotation; + + bool mAutoFocusPending; + nsCOMPtr mAutoFocusCompleteTimer; + int32_t mAutoFocusCompleteExpired; + + uint32_t mPrevFacesDetected; + // Guards against calling StartPreviewImpl() while in OnTakePictureComplete(). ReentrantMonitor mReentrantMonitor; diff --git a/dom/camera/GonkRecorder.cpp b/dom/camera/GonkRecorder.cpp index b07e300dd2..71e50725fa 100644 --- a/dom/camera/GonkRecorder.cpp +++ b/dom/camera/GonkRecorder.cpp @@ -20,6 +20,7 @@ #include "CameraCommon.h" #include "GonkCameraSource.h" #include "GonkRecorder.h" +#include "mozilla/CondVar.h" #define RE_LOGD(fmt, ...) DOM_CAMERA_LOGA("[%s:%d]" fmt,__FILE__,__LINE__, ## __VA_ARGS__) #define RE_LOGV(fmt, ...) DOM_CAMERA_LOGI("[%s:%d]" fmt,__FILE__,__LINE__, ## __VA_ARGS__) @@ -54,6 +55,132 @@ #define RES_720P (720 * 1280) namespace android { +struct GonkRecorder::WrappedMediaSource : MediaSource { +public: + WrappedMediaSource(const sp &encoder); + status_t start(MetaData *params = NULL) override; + status_t stop() override; + sp getFormat() override; + status_t read(MediaBuffer **buffer, const ReadOptions *options = NULL) override; + void block(); + status_t resume(); + +protected: + virtual ~WrappedMediaSource() {}; + +private: + WrappedMediaSource(const WrappedMediaSource &); + WrappedMediaSource &operator=(const WrappedMediaSource &); + + sp mEncoder; + mozilla::Mutex mMutex; + mozilla::CondVar mCondVar; + bool mWait; + bool mResume; + status_t mResumeStatus; +}; + +GonkRecorder::WrappedMediaSource::WrappedMediaSource(const sp &encoder) + : mEncoder(encoder) + , mMutex("GonkRecorder::WrappedMediaSource::mMutex") + , mCondVar(mMutex, "GonkRecorder::WrappedMediaSource::mCondVar") + , mWait(false) + , mResume(false) + , mResumeStatus(UNKNOWN_ERROR) +{ +} + +status_t +GonkRecorder::WrappedMediaSource::start(MetaData *params) +{ + return mEncoder->start(params); +} + +status_t +GonkRecorder::WrappedMediaSource::stop() +{ + { + // Ensure the writer thread is not blocked first. + MutexAutoLock lock(mMutex); + mWait = false; + mCondVar.Notify(); + } + return mEncoder->stop(); +} + +sp +GonkRecorder::WrappedMediaSource::getFormat() +{ + return mEncoder->getFormat(); +} + +status_t +GonkRecorder::WrappedMediaSource::read(MediaBuffer **buffer, const ReadOptions *options) +{ + MutexAutoLock lock(mMutex); + while (mWait) { + mCondVar.Wait(); + } + + status_t rv = UNKNOWN_ERROR; + MediaBuffer *buf = NULL; + + do { + rv = mEncoder->read(&buf, options); + if (!mResume) { + break; + } + + if (rv != OK || !buf) { + mResume = false; + mResumeStatus = UNKNOWN_ERROR; + mCondVar.Notify(); + break; + } + + int32_t isSync = 0; + buf->meta_data()->findInt32(kKeyIsSyncFrame, &isSync); + if (isSync) { + mResume = false; + mResumeStatus = OK; + mCondVar.Notify(); + break; + } + + buf->release(); + buf = NULL; + } while(true); + + *buffer = buf; + return rv; +} + +void +GonkRecorder::WrappedMediaSource::block() +{ + MutexAutoLock lock(mMutex); + mWait = true; +} + +status_t +GonkRecorder::WrappedMediaSource::resume() +{ + MutexAutoLock lock(mMutex); + if (!mWait) { + return UNKNOWN_ERROR; + } + + mWait = false; + mResume = true; + mCondVar.Notify(); + + do { + mCondVar.Wait(); + } while(mResume); + + return mResumeStatus; +} + GonkRecorder::GonkRecorder() : mWriter(NULL), mOutputFd(-1), @@ -1335,11 +1462,13 @@ status_t GonkRecorder::setupMPEG4Recording( int32_t videoWidth, int32_t videoHeight, int32_t videoBitRate, int32_t *totalBitRate, - sp *mediaWriter) { + sp *mediaWriter, + sp *mediaSource) { mediaWriter->clear(); *totalBitRate = 0; status_t err = OK; sp writer = new MPEG4Writer(outputFd); + sp writerSource; if (mVideoSource < VIDEO_SOURCE_LIST_END) { @@ -1355,7 +1484,10 @@ status_t GonkRecorder::setupMPEG4Recording( return err; } - writer->addSource(encoder); + sp cameraSource = reinterpret_cast(mediaSource.get()); + writerSource = new WrappedMediaSource(encoder); + + writer->addSource(writerSource); *totalBitRate += videoBitRate; } @@ -1391,6 +1523,7 @@ status_t GonkRecorder::setupMPEG4Recording( writer->setListener(mListener); *mediaWriter = writer; + *mediaSource = writerSource; return OK; } @@ -1422,7 +1555,8 @@ status_t GonkRecorder::startMPEG4Recording() { int32_t totalBitRate; status_t err = setupMPEG4Recording( mOutputFd, mVideoWidth, mVideoHeight, - mVideoBitRate, &totalBitRate, &mWriter); + mVideoBitRate, &totalBitRate, &mWriter, + &mWriterSource); if (err != OK) { return err; } @@ -1451,20 +1585,56 @@ status_t GonkRecorder::pause() { if (mWriter == NULL) { return UNKNOWN_ERROR; } - mWriter->pause(); - - if (mStarted) { + if (!mStarted) { + return OK; + } + // Pause is not properly supported by all writers although + // for B2G we only currently use 3GPP/MPEG4 + int err = INVALID_OPERATION; + switch (mOutputFormat) { + case OUTPUT_FORMAT_DEFAULT: + case OUTPUT_FORMAT_THREE_GPP: + case OUTPUT_FORMAT_MPEG_4: + err = mWriter->pause(); + break; + default: + break; + } + if (err == OK) { mStarted = false; } + return err; +} - - return OK; +status_t GonkRecorder::resume() { + RE_LOGV("resume"); + if (mWriter == NULL) { + return UNKNOWN_ERROR; + } + if (mStarted) { + return OK; + } + /* While the writer is paused, it will continue to pull frames + from the encoder. This ensures continuity on the timestamps of + the encoded frames, etc. When we want to resume however, we must + ensure that the first read frame is a key frame. */ + mWriterSource->block(); + int err = mWriter->start(NULL); + if (err != OK) { + return err; + } + err = mWriterSource->resume(); + if (err == OK) { + mStarted = true; + } + return err; } status_t GonkRecorder::stop() { RE_LOGV("stop"); status_t err = OK; + mWriterSource.clear(); if (mWriter != NULL) { err = mWriter->stop(); mWriter.clear(); diff --git a/dom/camera/GonkRecorder.h b/dom/camera/GonkRecorder.h index b97a02a6b2..a43a43ab79 100644 --- a/dom/camera/GonkRecorder.h +++ b/dom/camera/GonkRecorder.h @@ -59,6 +59,7 @@ struct GonkRecorder { virtual status_t prepare(); virtual status_t start(); virtual status_t pause(); + virtual status_t resume(); virtual status_t stop(); virtual status_t close(); virtual status_t reset(); @@ -70,10 +71,13 @@ protected: virtual ~GonkRecorder(); private: + struct WrappedMediaSource; + sp mListener; String16 mClientName; uid_t mClientUid; sp mWriter; + sp mWriterSource; int mOutputFd; sp mAudioSourceNode; @@ -123,7 +127,8 @@ private: int32_t videoWidth, int32_t videoHeight, int32_t videoBitRate, int32_t *totalBitRate, - sp *mediaWriter); + sp *mediaWriter, + sp *mediaSource); void setupMPEG4MetaData(int64_t startTimeUs, int32_t totalBitRate, sp *meta); status_t startMPEG4Recording(); diff --git a/dom/camera/GonkRecorderProfiles.cpp b/dom/camera/GonkRecorderProfiles.cpp index 86aa532e69..61ed6dc23c 100644 --- a/dom/camera/GonkRecorderProfiles.cpp +++ b/dom/camera/GonkRecorderProfiles.cpp @@ -31,9 +31,10 @@ namespace mozilla { struct ProfileConfig { const char* name; int quality; + uint32_t priority; }; -#define DEF_GONK_RECORDER_PROFILE(e, n) { n, e }, +#define DEF_GONK_RECORDER_PROFILE(e, n, p) { n, e, p }, static const ProfileConfig ProfileList[] = { #include "GonkRecorderProfiles.def" }; @@ -44,9 +45,10 @@ struct ProfileConfigDetect { const char* name; uint32_t width; uint32_t height; + uint32_t priority; }; -#define DEF_GONK_RECORDER_PROFILE_DETECT(n, w, h) { n, w, h }, +#define DEF_GONK_RECORDER_PROFILE_DETECT(n, w, h, p) { n, w, h, p }, static const ProfileConfigDetect ProfileListDetect[] = { #include "GonkRecorderProfiles.def" }; @@ -322,6 +324,7 @@ GonkRecorderProfile::GetProfileHashtable(uint32_t aCameraId) DOM_CAMERA_LOGI("Profile %d '%s' supported by platform\n", p.quality, p.name); profile->mName.AssignASCII(p.name); + profile->mPriority = p.priority; profiles->Put(profile->GetName(), profile); } @@ -351,6 +354,7 @@ GonkRecorderProfile::GetProfileHashtable(uint32_t aCameraId) if (s.width == p.width && s.height == p.height) { DOM_CAMERA_LOGI("Profile %d '%s' supported by platform\n", q, p.name); profile->mName.AssignASCII(p.name); + profile->mPriority = p.priority; profiles->Put(profile->GetName(), profile); break; } diff --git a/dom/camera/GonkRecorderProfiles.def b/dom/camera/GonkRecorderProfiles.def index 6c2b2998dd..9eafc0e8ef 100644 --- a/dom/camera/GonkRecorderProfiles.def +++ b/dom/camera/GonkRecorderProfiles.def @@ -19,20 +19,24 @@ */ #ifndef DEF_GONK_RECORDER_PROFILE -#define DEF_GONK_RECORDER_PROFILE(e, n) +#define DEF_GONK_RECORDER_PROFILE(e, n, p) #endif #ifndef DEF_GONK_RECORDER_PROFILE_DETECT -#define DEF_GONK_RECORDER_PROFILE_DETECT(n, w, h) +#define DEF_GONK_RECORDER_PROFILE_DETECT(n, w, h, p) #endif -DEF_GONK_RECORDER_PROFILE(CAMCORDER_QUALITY_LOW, "low") -DEF_GONK_RECORDER_PROFILE(CAMCORDER_QUALITY_HIGH, "high") -DEF_GONK_RECORDER_PROFILE(CAMCORDER_QUALITY_QCIF, "qcif") -DEF_GONK_RECORDER_PROFILE(CAMCORDER_QUALITY_CIF, "cif") -DEF_GONK_RECORDER_PROFILE(CAMCORDER_QUALITY_480P, "480p") -DEF_GONK_RECORDER_PROFILE(CAMCORDER_QUALITY_720P, "720p") -DEF_GONK_RECORDER_PROFILE(CAMCORDER_QUALITY_1080P, "1080p") +/* Enum value, name, and priority. The supported profile with the + * lowest priority and then largest area is selected as the default. + */ + +DEF_GONK_RECORDER_PROFILE(CAMCORDER_QUALITY_LOW, "low", 900) +DEF_GONK_RECORDER_PROFILE(CAMCORDER_QUALITY_HIGH, "high", 900) +DEF_GONK_RECORDER_PROFILE(CAMCORDER_QUALITY_QCIF, "qcif", 300) +DEF_GONK_RECORDER_PROFILE(CAMCORDER_QUALITY_CIF, "cif", 300) +DEF_GONK_RECORDER_PROFILE(CAMCORDER_QUALITY_480P, "480p", 200) +DEF_GONK_RECORDER_PROFILE(CAMCORDER_QUALITY_720P, "720p", 100) +DEF_GONK_RECORDER_PROFILE(CAMCORDER_QUALITY_1080P, "1080p", 0) /** * The following profiles do not appear in all versions of the @@ -40,15 +44,15 @@ DEF_GONK_RECORDER_PROFILE(CAMCORDER_QUALITY_1080P, "1080p") * profiles may have more than one resolution, depending on the camera. */ -DEF_GONK_RECORDER_PROFILE_DETECT("4kuhd", 3840, 2160) -DEF_GONK_RECORDER_PROFILE_DETECT("fwvga", 864, 480) -DEF_GONK_RECORDER_PROFILE_DETECT("fwvga", 854, 480) -DEF_GONK_RECORDER_PROFILE_DETECT("wvga", 800, 480) -DEF_GONK_RECORDER_PROFILE_DETECT("wvga", 768, 480) -DEF_GONK_RECORDER_PROFILE_DETECT("vga", 640, 480) -DEF_GONK_RECORDER_PROFILE_DETECT("hvga", 480, 320) -DEF_GONK_RECORDER_PROFILE_DETECT("wqvga", 400, 240) -DEF_GONK_RECORDER_PROFILE_DETECT("qvga", 320, 240) +DEF_GONK_RECORDER_PROFILE_DETECT("4kuhd", 3840, 2160, 800) +DEF_GONK_RECORDER_PROFILE_DETECT("fwvga", 864, 480, 200) +DEF_GONK_RECORDER_PROFILE_DETECT("fwvga", 854, 480, 200) +DEF_GONK_RECORDER_PROFILE_DETECT("wvga", 800, 480, 200) +DEF_GONK_RECORDER_PROFILE_DETECT("wvga", 768, 480, 200) +DEF_GONK_RECORDER_PROFILE_DETECT("vga", 640, 480, 200) +DEF_GONK_RECORDER_PROFILE_DETECT("hvga", 480, 320, 300) +DEF_GONK_RECORDER_PROFILE_DETECT("wqvga", 400, 240, 300) +DEF_GONK_RECORDER_PROFILE_DETECT("qvga", 320, 240, 300) #undef DEF_GONK_RECORDER_PROFILE #undef DEF_GONK_RECORDER_PROFILE_DETECT diff --git a/dom/camera/ICameraControl.h b/dom/camera/ICameraControl.h index 8551e7bdab..05fc5a1a31 100644 --- a/dom/camera/ICameraControl.h +++ b/dom/camera/ICameraControl.h @@ -116,6 +116,11 @@ public: struct Size { uint32_t width; uint32_t height; + + bool Equals(const Size& aSize) const + { + return width == aSize.width && height == aSize.height; + } }; struct Region { @@ -138,6 +143,7 @@ public: uint64_t maxFileSizeBytes; uint64_t maxVideoLengthMs; bool autoEnableLowLightTorch; + bool createPoster; }; struct Configuration { @@ -218,6 +224,7 @@ public: const nsString& GetName() const { return mName; } const nsString& GetContainer() const { return mContainer; } const nsString& GetMimeType() const { return mMimeType; } + uint32_t GetPriority() const { return mPriority; } virtual const Video& GetVideo() const = 0; virtual const Audio& GetAudio() const = 0; @@ -228,6 +235,7 @@ public: nsString mName; nsString mContainer; nsString mMimeType; + uint32_t mPriority; private: DISALLOW_EVIL_CONSTRUCTORS(RecorderProfile); @@ -255,6 +263,8 @@ public: virtual nsresult StartRecording(DeviceStorageFileDescriptor* aFileDescriptor, const StartRecordingOptions* aOptions = nullptr) = 0; virtual nsresult StopRecording() = 0; + virtual nsresult PauseRecording() = 0; + virtual nsresult ResumeRecording() = 0; virtual nsresult StartFaceDetection() = 0; virtual nsresult StopFaceDetection() = 0; virtual nsresult ResumeContinuousFocus() = 0; diff --git a/dom/camera/moz.build b/dom/camera/moz.build index 38789edc00..e4e3b75e09 100644 --- a/dom/camera/moz.build +++ b/dom/camera/moz.build @@ -63,6 +63,7 @@ else: LOCAL_INCLUDES += [ '../base', + '/media/libyuv/include', ] include('/ipc/chromium/chromium-config.mozbuild') diff --git a/dom/camera/test/camera_common.js b/dom/camera/test/camera_common.js index edd7c6f62e..f67f1e5faa 100644 --- a/dom/camera/test/camera_common.js +++ b/dom/camera/test/camera_common.js @@ -80,6 +80,8 @@ function CameraTestSuite() { this.rejectTakePicture = this._rejectTakePicture.bind(this); this.rejectStartRecording = this._rejectStartRecording.bind(this); this.rejectStopRecording = this._rejectStopRecording.bind(this); + this.rejectPauseRecording = this._rejectPauseRecording.bind(this); + this.rejectResumeRecording = this._rejectResumeRecording.bind(this); this.rejectPreviewStarted = this._rejectPreviewStarted.bind(this); var self = this; @@ -409,6 +411,14 @@ CameraTestSuite.prototype = { return this.logError('stop recording failed', e); }, + _rejectPauseRecording: function(e) { + return this.logError('pause recording failed', e); + }, + + _rejectResumeRecording: function(e) { + return this.logError('resume recording failed', e); + }, + _rejectPreviewStarted: function(e) { return this.logError('preview start failed', e); }, diff --git a/dom/camera/test/test_camera_configuration.html b/dom/camera/test/test_camera_configuration.html index 9135bf3413..e0ba0ab9da 100644 --- a/dom/camera/test/test_camera_configuration.html +++ b/dom/camera/test/test_camera_configuration.html @@ -111,7 +111,7 @@ suite.test('picture-mode', function() { suite.hw.params['preview-size'] = '1x1'; suite.hw.params['picture-size'] = '1x1'; suite.hw.params['preview-size-values'] = '640x480,320x240,1x1'; - suite.hw.params['picture-size-values'] = '640x480,320x240,1x1'; + suite.hw.params['picture-size-values'] = '1280x960,640x480,320x240,1x1'; suite.hw.params['video-size-values'] = '320x240'; var setConfig = { @@ -123,6 +123,19 @@ suite.test('picture-mode', function() { }; var expConfig = { + mode: 'picture', + recorderProfile: 'qvga', + previewSize: { + width: 640, + height: 480 + }, + pictureSize: { + width: 1280, + height: 960 + } + }; + + var postConfig = { mode: 'picture', recorderProfile: 'qvga', previewSize: { @@ -135,7 +148,47 @@ suite.test('picture-mode', function() { } }; - return setAndVerifyConfig(setConfig, expConfig); + function syncPreview() { + return new Promise(function(resolve, reject) { + function onEvent(e) { + if (e.newState === 'started') { + resolve(); + } + } + suite.camera.addEventListener('previewstatechange', onEvent); + }); + } + + function reconfigure(p) { + // The preview restarting confirms the configuration actually happened + var sync = new Promise(function(resolve, reject) { + var i = 0; + var expState = ['started', 'stopped', 'started']; + + function onEvent(e) { + ok(e.newState === expState[i], 'preview event state ' + expState[i] + + ' === ' + e.newState); + ++i; + if (i === expState.length) { return; } + suite.camera.removeEventListener('previewstatechange', onEvent); + resolve(); + } + + suite.camera.addEventListener('previewstatechange', onEvent); + }); + + var configure = suite.camera.setConfiguration(postConfig) + .then(resolveReconfigure); + return Promise.all([sync, configure]); + } + + function resolveReconfigure(cfg) { + verifyConfig(cfg, postConfig); + } + + return setAndVerifyConfig(setConfig, expConfig) + .then(syncPreview) + .then(reconfigure); }); suite.test('picture-mode-larger-picture-size', function() { diff --git a/dom/camera/test/test_camera_fake_parameters.html b/dom/camera/test/test_camera_fake_parameters.html index da45ce7b01..df98f2fce8 100644 --- a/dom/camera/test/test_camera_fake_parameters.html +++ b/dom/camera/test/test_camera_fake_parameters.html @@ -527,6 +527,33 @@ suite.test('bug-1052851', function() { .then(resolve, suite.rejectGetCamera); }); +suite.test('bug-1124338', function() { + function triggerAutoFocus(p) { + var sync = new Promise(function(resolve, reject) { + function onEvent(e) { + suite.camera.removeEventListener('focus', onEvent); + var thumbnailSize = suite.camera.getThumbnailSize(); + ok(thumbnailSize.width == 640 && thumbnailSize.height == 480, 'thumbnail size reset with auto focus'); + resolve(); + } + suite.camera.addEventListener('focus', onEvent); + }); + + var initThumbnailSize = suite.camera.getThumbnailSize(); + ok(initThumbnailSize.width == 320 && initThumbnailSize.height == 240, 'initial thumbnail size incorrect'); + suite.hw.params['jpeg-thumbnail-width'] = '640'; + suite.hw.params['jpeg-thumbnail-height'] = '480'; + suite.hw.fireAutoFocusComplete(false); + return sync; + } + + suite.hw.params['jpeg-thumbnail-size-values'] = '320x240,640x480'; + suite.hw.params['jpeg-thumbnail-width'] = '320'; + suite.hw.params['jpeg-thumbnail-height'] = '240'; + return suite.getCamera() + .then(triggerAutoFocus) +}); + suite.setup() .then(suite.run); diff --git a/dom/camera/test/test_camera_hardware_auto_focus_moving_cb.html b/dom/camera/test/test_camera_hardware_auto_focus_moving_cb.html index 5e7116425d..b977cfdba2 100644 --- a/dom/camera/test/test_camera_hardware_auto_focus_moving_cb.html +++ b/dom/camera/test/test_camera_hardware_auto_focus_moving_cb.html @@ -34,8 +34,34 @@ suite.test('auto-focus-moving', function() { return sync; } + function waitAutoFocusComplete(p) { + var sync = new Promise(function(resolve, reject) { + function onEvent(e) { + suite.camera.removeEventListener('focus', onEvent); + ok(e.newState === 'focused', 'autofocus event state focused == ' + e.newState); + resolve(); + } + suite.camera.addEventListener('focus', onEvent); + }); + + // Missing the fireAutoFocusComplete but it should timeout on its own + suite.hw.fireAutoFocusMoving(false); + return sync; + } + + function runAutoFocusCycle(p) { + return triggerAutoFocusMoving(p) + .then(waitAutoFocusComplete); + } + + /* If the driver doesn't supply an onAutoFocusComplete notification, + gecko will timeout and provide it. After three times, it will no + longer rely upon a timeout and fire it immediately. */ return suite.getCamera() - .then(triggerAutoFocusMoving); + .then(runAutoFocusCycle) + .then(runAutoFocusCycle) + .then(runAutoFocusCycle) + .then(runAutoFocusCycle); }); suite.setup() diff --git a/dom/camera/test/test_camera_record.html b/dom/camera/test/test_camera_record.html index b012669bf7..a2b801ee06 100644 --- a/dom/camera/test/test_camera_record.html +++ b/dom/camera/test/test_camera_record.html @@ -45,6 +45,50 @@ suite.test('recording', function() { return Promise.all([domPromise, eventPromise]); } + function pauseRecording(p) { + var eventPromise = new Promise(function(resolve, reject) { + function onEvent(evt) { + ok(evt.newState === 'Paused', 'recorder state change event = ' + evt.newState); + suite.camera.removeEventListener('recorderstatechange', onEvent); + resolve(); + } + suite.camera.addEventListener('recorderstatechange', onEvent); + }); + + var domPromise = new Promise(function(resolve, reject) { + try { + suite.camera.pauseRecording(); + resolve(); + } catch(e) { + reject(e); + } + }); + + return Promise.all([domPromise, eventPromise]); + } + + function resumeRecording(p) { + var eventPromise = new Promise(function(resolve, reject) { + function onEvent(evt) { + ok(evt.newState === 'Resumed', 'recorder state change event = ' + evt.newState); + suite.camera.removeEventListener('recorderstatechange', onEvent); + resolve(); + } + suite.camera.addEventListener('recorderstatechange', onEvent); + }); + + var domPromise = new Promise(function(resolve, reject) { + try { + suite.camera.resumeRecording(); + resolve(); + } catch(e) { + reject(e); + } + }); + + return Promise.all([domPromise, eventPromise]); + } + function stopRecording(p) { var eventPromise = new Promise(function(resolve, reject) { function onEvent(evt) { @@ -70,7 +114,9 @@ suite.test('recording', function() { return suite.getCamera(undefined, baseConfig) .then(cleanup, suite.rejectGetCamera) .then(startRecording) - .then(stopRecording, suite.rejectStartRecording) + .then(pauseRecording, suite.rejectStartRecording) + .then(resumeRecording, suite.rejectPauseRecording) + .then(stopRecording, suite.rejectResumeRecording) .catch(suite.rejectStopRecording); }); diff --git a/dom/canvas/CanvasRenderingContext2D.cpp b/dom/canvas/CanvasRenderingContext2D.cpp index 5f098325e5..0f321079d3 100644 --- a/dom/canvas/CanvasRenderingContext2D.cpp +++ b/dom/canvas/CanvasRenderingContext2D.cpp @@ -1027,7 +1027,7 @@ CanvasRenderingContext2D::ParseColor(const nsAString& aString, mCanvasElement, nullptr, presShell); } - unused << nsRuleNode::ComputeColor( + Unused << nsRuleNode::ComputeColor( value, presShell ? presShell->GetPresContext() : nullptr, parentContext, *aColor); } @@ -4892,7 +4892,7 @@ CanvasRenderingContext2D::DrawWindow(nsGlobalWindow& window, double x, } nsCOMPtr shell = presContext->PresShell(); - unused << shell->RenderDocument(r, renderDocFlags, backgroundColor, thebes); + Unused << shell->RenderDocument(r, renderDocFlags, backgroundColor, thebes); if (drawDT) { RefPtr snapshot = drawDT->Snapshot(); RefPtr data = snapshot->GetDataSurface(); diff --git a/dom/datastore/DataStoreService.cpp b/dom/datastore/DataStoreService.cpp index e2078f30ac..6fd496caad 100644 --- a/dom/datastore/DataStoreService.cpp +++ b/dom/datastore/DataStoreService.cpp @@ -1349,7 +1349,7 @@ DataStoreService::EnableDataStore(uint32_t aAppId, const nsAString& aName, ContentParent::GetAll(children); for (uint32_t i = 0; i < children.Length(); i++) { if (children[i]->NeedsDataStoreInfos()) { - unused << children[i]->SendDataStoreNotify(aAppId, nsAutoString(aName), + Unused << children[i]->SendDataStoreNotify(aAppId, nsAutoString(aName), nsAutoString(aManifestURL)); } } diff --git a/dom/devicestorage/DeviceStorageRequestChild.cpp b/dom/devicestorage/DeviceStorageRequestChild.cpp index 038a9a447d..24feb40946 100644 --- a/dom/devicestorage/DeviceStorageRequestChild.cpp +++ b/dom/devicestorage/DeviceStorageRequestChild.cpp @@ -95,22 +95,6 @@ DeviceStorageRequestChild:: break; } - case DeviceStorageResponseValue::TAvailableStorageResponse: - { - DS_LOG_INFO("available %u", mRequest->GetId()); - AvailableStorageResponse r = aValue; - mRequest->Resolve(r.mountState()); - break; - } - - case DeviceStorageResponseValue::TStorageStatusResponse: - { - DS_LOG_INFO("status %u", mRequest->GetId()); - StorageStatusResponse r = aValue; - mRequest->Resolve(r.storageStatus()); - break; - } - case DeviceStorageResponseValue::TFormatStorageResponse: { DS_LOG_INFO("format %u", mRequest->GetId()); diff --git a/dom/devicestorage/DeviceStorageRequestParent.cpp b/dom/devicestorage/DeviceStorageRequestParent.cpp index e878e5df90..e51aac823b 100644 --- a/dom/devicestorage/DeviceStorageRequestParent.cpp +++ b/dom/devicestorage/DeviceStorageRequestParent.cpp @@ -24,7 +24,7 @@ DeviceStorageRequestParent::DeviceStorageRequestParent( const DeviceStorageParams& aParams) : mParams(aParams) , mMutex("DeviceStorageRequestParent::mMutex") - , mActorDestoryed(false) + , mActorDestroyed(false) { MOZ_COUNT_CTOR(DeviceStorageRequestParent); @@ -164,32 +164,6 @@ DeviceStorageRequestParent::Dispatch() break; } - case DeviceStorageParams::TDeviceStorageAvailableParams: - { - DeviceStorageAvailableParams p = mParams; - - RefPtr dsf = - new DeviceStorageFile(p.type(), p.storageName()); - RefPtr r - = new PostAvailableResultEvent(this, dsf); - DebugOnly rv = NS_DispatchToMainThread(r); - MOZ_ASSERT(NS_SUCCEEDED(rv)); - break; - } - - case DeviceStorageParams::TDeviceStorageStatusParams: - { - DeviceStorageStatusParams p = mParams; - - RefPtr dsf = - new DeviceStorageFile(p.type(), p.storageName()); - RefPtr r - = new PostStatusResultEvent(this, dsf); - DebugOnly rv = NS_DispatchToMainThread(r); - MOZ_ASSERT(NS_SUCCEEDED(rv)); - break; - } - case DeviceStorageParams::TDeviceStorageFormatParams: { DeviceStorageFormatParams p = mParams; @@ -418,7 +392,7 @@ void DeviceStorageRequestParent::ActorDestroy(ActorDestroyReason) { MutexAutoLock lock(mMutex); - mActorDestoryed = true; + mActorDestroyed = true; int32_t count = mRunnables.Length(); for (int32_t index = 0; index < count; index++) { mRunnables[index]->Cancel(); @@ -441,7 +415,7 @@ DeviceStorageRequestParent::PostFreeSpaceResultEvent::CancelableRun() { MOZ_ASSERT(NS_IsMainThread()); FreeSpaceStorageResponse response(mFreeSpace); - unused << mParent->Send__delete__(mParent, response); + Unused << mParent->Send__delete__(mParent, response); return NS_OK; } @@ -463,7 +437,7 @@ DeviceStorageRequestParent::PostUsedSpaceResultEvent::CancelableRun() { MOZ_ASSERT(NS_IsMainThread()); UsedSpaceStorageResponse response(mUsedSpace); - unused << mParent->Send__delete__(mParent, response); + Unused << mParent->Send__delete__(mParent, response); return NS_OK; } @@ -481,7 +455,7 @@ DeviceStorageRequestParent::PostErrorEvent::CancelableRun() { MOZ_ASSERT(NS_IsMainThread()); ErrorResponse response(mError); - unused << mParent->Send__delete__(mParent, response); + Unused << mParent->Send__delete__(mParent, response); return NS_OK; } @@ -498,7 +472,7 @@ DeviceStorageRequestParent::PostSuccessEvent::CancelableRun() { MOZ_ASSERT(NS_IsMainThread()); SuccessResponse response; - unused << mParent->Send__delete__(mParent, response); + Unused << mParent->Send__delete__(mParent, response); return NS_OK; } @@ -535,14 +509,14 @@ DeviceStorageRequestParent::PostBlobSuccessEvent::CancelableRun() { BlobParent* actor = cp->GetOrCreateActorForBlobImpl(blob); if (!actor) { ErrorResponse response(NS_LITERAL_STRING(POST_ERROR_EVENT_UNKNOWN)); - unused << mParent->Send__delete__(mParent, response); + Unused << mParent->Send__delete__(mParent, response); return NS_OK; } BlobResponse response; response.blobParent() = actor; - unused << mParent->Send__delete__(mParent, response); + Unused << mParent->Send__delete__(mParent, response); return NS_OK; } @@ -566,7 +540,7 @@ DeviceStorageRequestParent::PostEnumerationSuccessEvent::CancelableRun() { MOZ_ASSERT(NS_IsMainThread()); EnumerationResponse response(mStorageType, mRelPath, mPaths); - unused << mParent->Send__delete__(mParent, response); + Unused << mParent->Send__delete__(mParent, response); return NS_OK; } @@ -893,7 +867,7 @@ DeviceStorageRequestParent::PostPathResultEvent::CancelableRun() MOZ_ASSERT(NS_IsMainThread()); SuccessResponse response; - unused << mParent->Send__delete__(mParent, response); + Unused << mParent->Send__delete__(mParent, response); return NS_OK; } @@ -916,63 +890,7 @@ DeviceStorageRequestParent::PostFileDescriptorResultEvent::CancelableRun() MOZ_ASSERT(NS_IsMainThread()); FileDescriptorResponse response(mFileDescriptor); - unused << mParent->Send__delete__(mParent, response); - return NS_OK; -} - -DeviceStorageRequestParent::PostAvailableResultEvent:: - PostAvailableResultEvent(DeviceStorageRequestParent* aParent, - DeviceStorageFile* aFile) - : CancelableRunnable(aParent) - , mFile(aFile) -{ -} - -DeviceStorageRequestParent::PostAvailableResultEvent:: - ~PostAvailableResultEvent() -{ -} - -nsresult -DeviceStorageRequestParent::PostAvailableResultEvent::CancelableRun() -{ - MOZ_ASSERT(NS_IsMainThread()); - - nsString state = NS_LITERAL_STRING("unavailable"); - if (mFile) { - mFile->GetStatus(state); - } - - AvailableStorageResponse response(state); - unused << mParent->Send__delete__(mParent, response); - return NS_OK; -} - -DeviceStorageRequestParent::PostStatusResultEvent:: - PostStatusResultEvent(DeviceStorageRequestParent* aParent, - DeviceStorageFile* aFile) - : CancelableRunnable(aParent) - , mFile(aFile) -{ -} - -DeviceStorageRequestParent::PostStatusResultEvent:: - ~PostStatusResultEvent() -{ -} - -nsresult -DeviceStorageRequestParent::PostStatusResultEvent::CancelableRun() -{ - MOZ_ASSERT(NS_IsMainThread()); - - nsString state = NS_LITERAL_STRING("undefined"); - if (mFile) { - mFile->GetStorageStatus(state); - } - - StorageStatusResponse response(state); - unused << mParent->Send__delete__(mParent, response); + Unused << mParent->Send__delete__(mParent, response); return NS_OK; } @@ -1000,7 +918,7 @@ DeviceStorageRequestParent::PostFormatResultEvent::CancelableRun() } FormatStorageResponse response(state); - unused << mParent->Send__delete__(mParent, response); + Unused << mParent->Send__delete__(mParent, response); return NS_OK; } @@ -1028,7 +946,7 @@ DeviceStorageRequestParent::PostMountResultEvent::CancelableRun() } MountStorageResponse response(state); - unused << mParent->Send__delete__(mParent, response); + Unused << mParent->Send__delete__(mParent, response); return NS_OK; } @@ -1056,7 +974,7 @@ DeviceStorageRequestParent::PostUnmountResultEvent::CancelableRun() } UnmountStorageResponse response(state); - unused << mParent->Send__delete__(mParent, response); + Unused << mParent->Send__delete__(mParent, response); return NS_OK; } diff --git a/dom/devicestorage/DeviceStorageRequestParent.h b/dom/devicestorage/DeviceStorageRequestParent.h index ef433a2e92..84901120ce 100644 --- a/dom/devicestorage/DeviceStorageRequestParent.h +++ b/dom/devicestorage/DeviceStorageRequestParent.h @@ -242,26 +242,6 @@ private: uint64_t mUsedSpace; }; - class PostAvailableResultEvent : public CancelableRunnable - { - public: - PostAvailableResultEvent(DeviceStorageRequestParent* aParent, DeviceStorageFile* aFile); - virtual ~PostAvailableResultEvent(); - virtual nsresult CancelableRun(); - private: - RefPtr mFile; - }; - - class PostStatusResultEvent : public CancelableRunnable - { - public: - PostStatusResultEvent(DeviceStorageRequestParent* aParent, DeviceStorageFile* aFile); - virtual ~PostStatusResultEvent(); - virtual nsresult CancelableRun(); - private: - RefPtr mFile; - }; - class PostFormatResultEvent : public CancelableRunnable { public: @@ -295,7 +275,7 @@ private: protected: bool AddRunnable(CancelableRunnable* aRunnable) { MutexAutoLock lock(mMutex); - if (mActorDestoryed) + if (mActorDestroyed) return false; mRunnables.AppendElement(aRunnable); @@ -308,7 +288,7 @@ protected: } Mutex mMutex; - bool mActorDestoryed; + bool mActorDestroyed; nsTArray > mRunnables; }; diff --git a/dom/devicestorage/PDeviceStorageRequest.ipdl b/dom/devicestorage/PDeviceStorageRequest.ipdl index 80677af3aa..f85d7fcbae 100644 --- a/dom/devicestorage/PDeviceStorageRequest.ipdl +++ b/dom/devicestorage/PDeviceStorageRequest.ipdl @@ -53,16 +53,6 @@ struct UsedSpaceStorageResponse uint64_t usedBytes; }; -struct AvailableStorageResponse -{ - nsString mountState; -}; - -struct StorageStatusResponse -{ - nsString storageStatus; -}; - struct FormatStorageResponse { nsString mountState; @@ -87,8 +77,6 @@ union DeviceStorageResponseValue EnumerationResponse; FreeSpaceStorageResponse; UsedSpaceStorageResponse; - AvailableStorageResponse; - StorageStatusResponse; FormatStorageResponse; MountStorageResponse; UnmountStorageResponse; diff --git a/dom/devicestorage/nsDeviceStorage.cpp b/dom/devicestorage/nsDeviceStorage.cpp index 7a973c427f..fe5f43d0f4 100644 --- a/dom/devicestorage/nsDeviceStorage.cpp +++ b/dom/devicestorage/nsDeviceStorage.cpp @@ -2158,6 +2158,7 @@ public: DeviceStorageAvailableRequest() { mAccess = DEVICE_STORAGE_ACCESS_READ; + mSendToParent = false; DS_LOG_INFO(""); } @@ -2169,15 +2170,6 @@ public: } return Resolve(state); } - -protected: - nsresult CreateSendParams(DeviceStorageParams& aParams) override - { - DeviceStorageAvailableParams params(mFile->mStorageType, - mFile->mStorageName); - aParams = params; - return NS_OK; - } }; class DeviceStorageStatusRequest final @@ -2187,6 +2179,7 @@ public: DeviceStorageStatusRequest() { mAccess = DEVICE_STORAGE_ACCESS_READ; + mSendToParent = false; DS_LOG_INFO(""); } @@ -2198,15 +2191,6 @@ public: } return Resolve(state); } - -protected: - nsresult CreateSendParams(DeviceStorageParams& aParams) override - { - DeviceStorageStatusParams params(mFile->mStorageType, - mFile->mStorageName); - aParams = params; - return NS_OK; - } }; class DeviceStorageWatchRequest final diff --git a/dom/events/EventDispatcher.cpp b/dom/events/EventDispatcher.cpp index f7369e33bd..ec10403fca 100644 --- a/dom/events/EventDispatcher.cpp +++ b/dom/events/EventDispatcher.cpp @@ -255,7 +255,7 @@ void EventTargetChainItem::PreHandleEvent(EventChainPreVisitor& aVisitor) { aVisitor.Reset(); - unused << mTarget->PreHandleEvent(aVisitor); + Unused << mTarget->PreHandleEvent(aVisitor); SetForceContentDispatch(aVisitor.mForceContentDispatch); SetWantsWillHandleEvent(aVisitor.mWantsWillHandleEvent); SetMayHaveListenerManager(aVisitor.mMayHaveListenerManager); diff --git a/dom/events/IMEStateManager.cpp b/dom/events/IMEStateManager.cpp index 8eb58272ab..25c0c8fdf4 100644 --- a/dom/events/IMEStateManager.cpp +++ b/dom/events/IMEStateManager.cpp @@ -417,7 +417,7 @@ IMEStateManager::OnChangeFocusInternal(nsPresContext* aPresContext, ("ISM: IMEStateManager::OnChangeFocusInternal(), notifying previous " "focused child process of parent process or another child process " "getting focus")); - unused << sActiveTabParent->SendStopIMEStateManagement(); + Unused << sActiveTabParent->SendStopIMEStateManagement(); } nsCOMPtr widget = @@ -445,7 +445,7 @@ IMEStateManager::OnChangeFocusInternal(nsPresContext* aPresContext, // to be restored by the child process asynchronously. Therefore, // some key events which are fired immediately after closing menu // may not be handled by IME. - unused << newTabParent-> + Unused << newTabParent-> SendMenuKeyboardListenerInstalled(sInstalledMenuKeyboardListener); setIMEState = sInstalledMenuKeyboardListener; } else if (focusActuallyChanging) { diff --git a/dom/events/TextComposition.cpp b/dom/events/TextComposition.cpp index f492a0a260..534390f06f 100644 --- a/dom/events/TextComposition.cpp +++ b/dom/events/TextComposition.cpp @@ -140,7 +140,7 @@ TextComposition::OnCompositionEventDiscarded( if (mTabParent) { // The composition event should be discarded in the child process too. - unused << mTabParent->SendCompositionEvent(*aCompositionEvent); + Unused << mTabParent->SendCompositionEvent(*aCompositionEvent); } // XXX If composition events are discarded, should we dispatch them with @@ -218,7 +218,7 @@ TextComposition::DispatchCompositionEvent( // If the content is a container of TabParent, composition should be in the // remote process. if (mTabParent) { - unused << mTabParent->SendCompositionEvent(*aCompositionEvent); + Unused << mTabParent->SendCompositionEvent(*aCompositionEvent); aCompositionEvent->mFlags.mPropagationStopped = true; if (aCompositionEvent->CausesDOMTextEvent()) { mLastData = aCompositionEvent->mData; @@ -386,7 +386,7 @@ TextComposition::HandleSelectionEvent(nsPresContext* aPresContext, // If the content is a container of TabParent, composition should be in the // remote process. if (aTabParent) { - unused << aTabParent->SendSelectionEvent(*aSelectionEvent); + Unused << aTabParent->SendSelectionEvent(*aSelectionEvent); aSelectionEvent->mFlags.mPropagationStopped = true; return; } diff --git a/dom/fetch/FetchDriver.cpp b/dom/fetch/FetchDriver.cpp index 9d891b4a3b..cdc62db8ec 100644 --- a/dom/fetch/FetchDriver.cpp +++ b/dom/fetch/FetchDriver.cpp @@ -781,8 +781,8 @@ FetchDriver::AsyncOnChannelRedirect(nsIChannel* aOldChannel, // be ignored. MOZ_ASSERT(!mFoundOpaqueRedirect); mFoundOpaqueRedirect = true; - unused << OnStartRequest(aOldChannel, nullptr); - unused << OnStopRequest(aOldChannel, nullptr, NS_OK); + Unused << OnStartRequest(aOldChannel, nullptr); + Unused << OnStopRequest(aOldChannel, nullptr, NS_OK); aOldChannel->Cancel(NS_BINDING_FAILED); diff --git a/dom/fetch/Request.cpp b/dom/fetch/Request.cpp index d5fe048b7f..434f4651e0 100644 --- a/dom/fetch/Request.cpp +++ b/dom/fetch/Request.cpp @@ -90,7 +90,7 @@ GetRequestURLFromDocument(nsIDocument* aDocument, const nsAString& aInput, // This fails with URIs with weird protocols, even when they are valid, // so we ignore the failure nsAutoCString credentials; - unused << resolvedURI->GetUserPass(credentials); + Unused << resolvedURI->GetUserPass(credentials); if (!credentials.IsEmpty()) { aRv.ThrowTypeError(&aInput); return; @@ -129,7 +129,7 @@ GetRequestURLFromChrome(const nsAString& aInput, nsAString& aRequestURL, // This fails with URIs with weird protocols, even when they are valid, // so we ignore the failure nsAutoCString credentials; - unused << uri->GetUserPass(credentials); + Unused << uri->GetUserPass(credentials); if (!credentials.IsEmpty()) { aRv.ThrowTypeError(&aInput); return; diff --git a/dom/filehandle/ActorsParent.cpp b/dom/filehandle/ActorsParent.cpp index 59108d0842..e3413cff76 100644 --- a/dom/filehandle/ActorsParent.cpp +++ b/dom/filehandle/ActorsParent.cpp @@ -1003,7 +1003,7 @@ FileHandleThreadPool::Cleanup() MOZ_ASSERT(completeCallback); MOZ_ASSERT(completeCallback->mCallback); - unused << completeCallback->mCallback->Run(); + Unused << completeCallback->mCallback->Run(); } mCompleteCallbacks.Clear(); @@ -1651,7 +1651,7 @@ FileHandle::SendCompleteNotification(bool aAborted) AssertIsOnBackgroundThread(); if (!IsActorDestroyed()) { - unused << SendComplete(aAborted); + Unused << SendComplete(aAborted); } } @@ -2280,7 +2280,7 @@ ProgressRunnable::Run() { AssertIsOnBackgroundThread(); - unused << mCopyFileHandleOp->SendProgress(mProgress, mProgressMax); + Unused << mCopyFileHandleOp->SendProgress(mProgress, mProgressMax); mCopyFileHandleOp = nullptr; diff --git a/dom/filesystem/FileSystemTaskBase.cpp b/dom/filesystem/FileSystemTaskBase.cpp index 83d9a5b265..36ac33211e 100644 --- a/dom/filesystem/FileSystemTaskBase.cpp +++ b/dom/filesystem/FileSystemTaskBase.cpp @@ -111,7 +111,7 @@ FileSystemTaskBase::HandleResult() return; } if (mRequestParent && mRequestParent->IsRunning()) { - unused << mRequestParent->Send__delete__(mRequestParent, + Unused << mRequestParent->Send__delete__(mRequestParent, GetRequestResult()); } else { HandlerCallback(); diff --git a/dom/fmradio/ipc/FMRadioParent.cpp b/dom/fmradio/ipc/FMRadioParent.cpp index 0f5e59ef1e..49abe4bc76 100644 --- a/dom/fmradio/ipc/FMRadioParent.cpp +++ b/dom/fmradio/ipc/FMRadioParent.cpp @@ -98,41 +98,41 @@ FMRadioParent::Notify(const FMRadioEventType& aType) { switch (aType) { case FrequencyChanged: - unused << SendNotifyFrequencyChanged( + Unused << SendNotifyFrequencyChanged( IFMRadioService::Singleton()->GetFrequency()); break; case EnabledChanged: - unused << SendNotifyEnabledChanged( + Unused << SendNotifyEnabledChanged( IFMRadioService::Singleton()->IsEnabled(), IFMRadioService::Singleton()->GetFrequency()); break; case RDSEnabledChanged: - unused << SendNotifyRDSEnabledChanged( + Unused << SendNotifyRDSEnabledChanged( IFMRadioService::Singleton()->IsRDSEnabled()); break; case PIChanged: { Nullable pi = IFMRadioService::Singleton()->GetPi(); - unused << SendNotifyPIChanged(!pi.IsNull(), + Unused << SendNotifyPIChanged(!pi.IsNull(), pi.IsNull() ? 0 : pi.Value()); break; } case PTYChanged: { Nullable pty = IFMRadioService::Singleton()->GetPty(); - unused << SendNotifyPTYChanged(!pty.IsNull(), + Unused << SendNotifyPTYChanged(!pty.IsNull(), pty.IsNull() ? 0 : pty.Value()); break; } case PSChanged: { nsAutoString psname; IFMRadioService::Singleton()->GetPs(psname); - unused << SendNotifyPSChanged(psname); + Unused << SendNotifyPSChanged(psname); break; } case RadiotextChanged: { nsAutoString radiotext; IFMRadioService::Singleton()->GetRt(radiotext); - unused << SendNotifyRadiotextChanged(radiotext); + Unused << SendNotifyRadiotextChanged(radiotext); break; } case NewRDSGroup: { @@ -140,7 +140,7 @@ FMRadioParent::Notify(const FMRadioEventType& aType) DebugOnly rdsgroupset = IFMRadioService::Singleton()->GetRdsgroup(group); MOZ_ASSERT(rdsgroupset); - unused << SendNotifyNewRDSGroup(group); + Unused << SendNotifyNewRDSGroup(group); break; } default: diff --git a/dom/fmradio/ipc/FMRadioRequestParent.cpp b/dom/fmradio/ipc/FMRadioRequestParent.cpp index 0e0fe0c373..0ac19283a8 100644 --- a/dom/fmradio/ipc/FMRadioRequestParent.cpp +++ b/dom/fmradio/ipc/FMRadioRequestParent.cpp @@ -34,7 +34,7 @@ FMRadioRequestParent::Run() MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!"); if (!mActorDestroyed) { - unused << Send__delete__(this, mResponseType); + Unused << Send__delete__(this, mResponseType); } return NS_OK; diff --git a/dom/gamepad/GamepadFunctions.cpp b/dom/gamepad/GamepadFunctions.cpp index 5b8aa035d1..06e31c177f 100644 --- a/dom/gamepad/GamepadFunctions.cpp +++ b/dom/gamepad/GamepadFunctions.cpp @@ -29,7 +29,7 @@ NotifyGamepadChange(const T& aInfo) nsTArray t; ContentParent::GetAll(t); for(uint32_t i = 0; i < t.Length(); ++i) { - unused << t[i]->SendGamepadUpdate(e); + Unused << t[i]->SendGamepadUpdate(e); } // If we have a GamepadService in the main process, send directly to it. if (GamepadService::IsServiceRunning()) { diff --git a/dom/geolocation/nsGeolocation.cpp b/dom/geolocation/nsGeolocation.cpp index 8f6bda9a55..60c6c1e28c 100644 --- a/dom/geolocation/nsGeolocation.cpp +++ b/dom/geolocation/nsGeolocation.cpp @@ -62,7 +62,7 @@ class nsIPrincipal; // the geolocation enabled setting #define GEO_SETTINGS_ENABLED "geolocation.enabled" -using mozilla::unused; // +using mozilla::Unused; // using namespace mozilla; using namespace mozilla::dom; @@ -1271,7 +1271,7 @@ Geolocation::RemoveRequest(nsGeolocationRequest* aRequest) (mPendingCallbacks.RemoveElement(aRequest) != mWatchingCallbacks.RemoveElement(aRequest)); - unused << requestWasKnown; + Unused << requestWasKnown; } NS_IMETHODIMP diff --git a/dom/geolocation/nsGeolocationSettings.cpp b/dom/geolocation/nsGeolocationSettings.cpp index fc1e5350fd..2270cadb25 100644 --- a/dom/geolocation/nsGeolocationSettings.cpp +++ b/dom/geolocation/nsGeolocationSettings.cpp @@ -37,7 +37,7 @@ #define GEO_ALA_TYPE_VALUE_FIXED "user-defined" #define GEO_ALA_TYPE_VALUE_NONE "no-location" -using mozilla::unused; +using mozilla::Unused; using namespace mozilla; using namespace mozilla::dom; diff --git a/dom/html/HTMLFormControlsCollection.cpp b/dom/html/HTMLFormControlsCollection.cpp index 8c5c071c0e..5a54dfb78f 100644 --- a/dom/html/HTMLFormControlsCollection.cpp +++ b/dom/html/HTMLFormControlsCollection.cpp @@ -386,15 +386,6 @@ HTMLFormControlsCollection::NamedGetter(const nsAString& aName, MOZ_ASSERT_UNREACHABLE("Should only have Elements and NodeLists here."); } -static PLDHashOperator -CollectNames(const nsAString& aName, - nsISupports* /* unused */, - void* aClosure) -{ - static_cast*>(aClosure)->AppendElement(aName); - return PL_DHASH_NEXT; -} - void HTMLFormControlsCollection::GetSupportedNames(unsigned aFlags, nsTArray& aNames) @@ -407,7 +398,9 @@ HTMLFormControlsCollection::GetSupportedNames(unsigned aFlags, // Just enumerate mNameLookupTable. This won't guarantee order, but // that's OK, because the HTML5 spec doesn't define an order for // this enumeration. - mNameLookupTable.EnumerateRead(CollectNames, &aNames); + for (auto iter = mNameLookupTable.Iter(); !iter.Done(); iter.Next()) { + aNames.AppendElement(iter.Key()); + } } /* virtual */ JSObject* diff --git a/dom/html/HTMLFormElement.cpp b/dom/html/HTMLFormElement.cpp index 51598ec4a5..0409096d06 100644 --- a/dom/html/HTMLFormElement.cpp +++ b/dom/html/HTMLFormElement.cpp @@ -134,17 +134,6 @@ HTMLFormElement::~HTMLFormElement() // nsISupports -static PLDHashOperator -ElementTraverser(const nsAString& key, HTMLInputElement* element, - void* userArg) -{ - nsCycleCollectionTraversalCallback *cb = - static_cast(userArg); - - cb->NoteXPCOMChild(ToSupports(element)); - return PL_DHASH_NEXT; -} - NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLFormElement) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLFormElement, @@ -152,7 +141,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLFormElement, NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mControls) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mImageNameLookupTable) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPastNameLookupTable) - tmp->mSelectedRadioButtons.EnumerateRead(ElementTraverser, &cb); + NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSelectedRadioButtons) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLFormElement, diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp index b8d679507f..d4b220b290 100644 --- a/dom/html/HTMLMediaElement.cpp +++ b/dom/html/HTMLMediaElement.cpp @@ -736,9 +736,11 @@ void HTMLMediaElement::AbortExistingLoads() if (mNetworkState != nsIDOMHTMLMediaElement::NETWORK_EMPTY) { NS_ASSERTION(!mDecoder && !mSrcStream, "How did someone setup a new stream/decoder already?"); + // ChangeNetworkState() will call UpdateAudioChannelPlayingState() + // indirectly which depends on mPaused. So we need to update mPaused first. + mPaused = true; ChangeNetworkState(nsIDOMHTMLMediaElement::NETWORK_EMPTY); ChangeReadyState(nsIDOMHTMLMediaElement::HAVE_NOTHING); - mPaused = true; if (fireTimeUpdate) { // Since we destroyed the decoder above, the current playback position @@ -1498,7 +1500,7 @@ HTMLMediaElement::Seek(double aTime, } // Clamp the seek target to inside the seekable ranges. - RefPtr seekable = new dom::TimeRanges(); + RefPtr seekable = new dom::TimeRanges(ToSupports(OwnerDoc())); media::TimeIntervals seekableIntervals = mDecoder->GetSeekable(); if (seekableIntervals.IsInvalid()) { aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); @@ -1567,6 +1569,11 @@ HTMLMediaElement::Seek(double aTime, // MediaDecoderReaders. mPlayingBeforeSeek = IsPotentiallyPlaying(); + // Set the Variable if the Seekstarted while active playing + if (mPlayingThroughTheAudioChannel) { + mPlayingThroughTheAudioChannelBeforeSeek = true; + } + // The media backend is responsible for dispatching the timeupdate // event if it changes the playback position as a result of the seek. LOG(LogLevel::Debug, ("%p SetCurrentTime(%f) starting seek", this, aTime)); @@ -1621,9 +1628,8 @@ NS_IMETHODIMP HTMLMediaElement::GetDuration(double* aDuration) already_AddRefed HTMLMediaElement::Seekable() const { - RefPtr ranges = new TimeRanges(); - if (mMediaSource || - (mDecoder && mReadyState > nsIDOMHTMLMediaElement::HAVE_NOTHING)) { + RefPtr ranges = new TimeRanges(ToSupports(OwnerDoc())); + if (mDecoder && mReadyState > nsIDOMHTMLMediaElement::HAVE_NOTHING) { mDecoder->GetSeekable().ToTimeRanges(ranges); } return ranges.forget(); @@ -1646,7 +1652,7 @@ NS_IMETHODIMP HTMLMediaElement::GetPaused(bool* aPaused) already_AddRefed HTMLMediaElement::Played() { - RefPtr ranges = new TimeRanges(); + RefPtr ranges = new TimeRanges(ToSupports(OwnerDoc())); uint32_t timeRangeCount = 0; if (mPlayed) { @@ -1740,36 +1746,6 @@ NS_IMETHODIMP HTMLMediaElement::SetVolume(double aVolume) return rv.StealNSResult(); } -// Helper struct with arguments for our hash iterator. -typedef struct MOZ_STACK_CLASS { - JSContext* cx; - JS::Handle tags; - bool error; -} MetadataIterCx; - -PLDHashOperator -HTMLMediaElement::BuildObjectFromTags(nsCStringHashKey::KeyType aKey, - nsCString aValue, - void* aUserArg) -{ - MetadataIterCx* args = static_cast(aUserArg); - - nsString wideValue = NS_ConvertUTF8toUTF16(aValue); - JS::Rooted string(args->cx, JS_NewUCStringCopyZ(args->cx, wideValue.Data())); - if (!string) { - NS_WARNING("Failed to perform string copy"); - args->error = true; - return PL_DHASH_STOP; - } - if (!JS_DefineProperty(args->cx, args->tags, aKey.Data(), string, JSPROP_ENUMERATE)) { - NS_WARNING("Failed to set metadata property"); - args->error = true; - return PL_DHASH_STOP; - } - - return PL_DHASH_NEXT; -} - void HTMLMediaElement::MozGetMetadata(JSContext* cx, JS::MutableHandle aRetval, @@ -1786,12 +1762,16 @@ HTMLMediaElement::MozGetMetadata(JSContext* cx, return; } if (mTags) { - MetadataIterCx iter = {cx, tags, false}; - mTags->EnumerateRead(BuildObjectFromTags, static_cast(&iter)); - if (iter.error) { - NS_WARNING("couldn't create metadata object!"); - aRv.Throw(NS_ERROR_FAILURE); - return; + for (auto iter = mTags->ConstIter(); !iter.Done(); iter.Next()) { + nsString wideValue = NS_ConvertUTF8toUTF16(iter.UserData()); + JS::Rooted string(cx, + JS_NewUCStringCopyZ(cx, wideValue.Data())); + if (!string || !JS_DefineProperty(cx, tags, iter.Key().Data(), string, + JSPROP_ENUMERATE)) { + NS_WARNING("couldn't create metadata object!"); + aRv.Throw(NS_ERROR_FAILURE); + return; + } } } @@ -2055,7 +2035,7 @@ HTMLMediaElement::HTMLMediaElement(already_AddRefed& aNo mDefaultPlaybackRate(1.0), mPlaybackRate(1.0), mPreservesPitch(true), - mPlayed(new TimeRanges), + mPlayed(new TimeRanges(ToSupports(OwnerDoc()))), mCurrentPlayRangeStart(-1.0), mBegun(false), mLoadedDataFired(false), @@ -3546,10 +3526,6 @@ void HTMLMediaElement::PlaybackEnded() void HTMLMediaElement::SeekStarted() { DispatchAsyncEvent(NS_LITERAL_STRING("seeking")); - // Set the Variable if the Seekstarted while active playing - if(mPlayingThroughTheAudioChannel) { - mPlayingThroughTheAudioChannelBeforeSeek = true; - } } void HTMLMediaElement::SeekCompleted() @@ -4458,7 +4434,7 @@ HTMLMediaElement::CopyInnerTo(Element* aDest) already_AddRefed HTMLMediaElement::Buffered() const { - RefPtr ranges = new TimeRanges(); + RefPtr ranges = new TimeRanges(ToSupports(OwnerDoc())); if (mReadyState > nsIDOMHTMLMediaElement::HAVE_NOTHING) { if (mDecoder) { media::TimeIntervals buffered = mDecoder->GetBuffered(); diff --git a/dom/html/HTMLPropertiesCollection.cpp b/dom/html/HTMLPropertiesCollection.cpp index 813ee9956e..252b89a22e 100644 --- a/dom/html/HTMLPropertiesCollection.cpp +++ b/dom/html/HTMLPropertiesCollection.cpp @@ -73,14 +73,6 @@ NS_INTERFACE_MAP_END NS_IMPL_CYCLE_COLLECTING_ADDREF(HTMLPropertiesCollection) NS_IMPL_CYCLE_COLLECTING_RELEASE(HTMLPropertiesCollection) - -static PLDHashOperator -SetPropertyListDocument(const nsAString& aKey, PropertyNodeList* aEntry, void* aData) -{ - aEntry->SetDocument(static_cast(aData)); - return PL_DHASH_NEXT; -} - void HTMLPropertiesCollection::SetDocument(nsIDocument* aDocument) { if (mDoc) { @@ -90,7 +82,9 @@ HTMLPropertiesCollection::SetDocument(nsIDocument* aDocument) { if (mDoc) { mDoc->AddMutationObserver(this); } - mNamedItemEntries.EnumerateRead(SetPropertyListDocument, aDocument); + for (auto iter = mNamedItemEntries.Iter(); !iter.Done(); iter.Next()) { + iter.UserData()->SetDocument(aDocument); + } mIsDirty = true; } @@ -192,13 +186,6 @@ HTMLPropertiesCollection::ContentRemoved(nsIDocument *aDocument, mIsDirty = true; } -static PLDHashOperator -MarkDirty(const nsAString& aKey, PropertyNodeList* aEntry, void* aData) -{ - aEntry->SetDirty(); - return PL_DHASH_NEXT; -} - void HTMLPropertiesCollection::EnsureFresh() { @@ -210,7 +197,9 @@ HTMLPropertiesCollection::EnsureFresh() mProperties.Clear(); mNames->Clear(); // We don't clear NamedItemEntries because the PropertyNodeLists must be live. - mNamedItemEntries.EnumerateRead(MarkDirty, nullptr); + for (auto iter = mNamedItemEntries.Iter(); !iter.Done(); iter.Next()) { + iter.UserData()->SetDirty(); + } if (!mRoot->HasAttr(kNameSpaceID_None, nsGkAtoms::itemscope)) { return; } diff --git a/dom/html/TimeRanges.cpp b/dom/html/TimeRanges.cpp index d0ce5a6e39..c817b53e20 100644 --- a/dom/html/TimeRanges.cpp +++ b/dom/html/TimeRanges.cpp @@ -12,16 +12,27 @@ namespace mozilla { namespace dom { -NS_IMPL_ISUPPORTS(TimeRanges, nsIDOMTimeRanges) +NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(TimeRanges, mParent) +NS_IMPL_CYCLE_COLLECTING_ADDREF(TimeRanges) +NS_IMPL_CYCLE_COLLECTING_RELEASE(TimeRanges) +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TimeRanges) + NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY + NS_INTERFACE_MAP_ENTRY(nsIDOMTimeRanges) + NS_INTERFACE_MAP_ENTRY(nsISupports) +NS_INTERFACE_MAP_END TimeRanges::TimeRanges() + : mParent(nullptr) +{ +} + +TimeRanges::TimeRanges(nsISupports* aParent) + : mParent(aParent) { - MOZ_COUNT_CTOR(TimeRanges); } TimeRanges::~TimeRanges() { - MOZ_COUNT_DTOR(TimeRanges); } NS_IMETHODIMP @@ -166,10 +177,16 @@ TimeRanges::Find(double aTime, double aTolerance /* = 0 */) return NoIndex; } -bool -TimeRanges::WrapObject(JSContext* aCx, JS::Handle aGivenProto, JS::MutableHandle aReflector) +JSObject* +TimeRanges::WrapObject(JSContext* aCx, JS::Handle aGivenProto) { - return TimeRangesBinding::Wrap(aCx, this, aGivenProto, aReflector); + return TimeRangesBinding::Wrap(aCx, this, aGivenProto); +} + +nsISupports* +TimeRanges::GetParentObject() const +{ + return mParent; } void diff --git a/dom/html/TimeRanges.h b/dom/html/TimeRanges.h index 0e138f6051..5e9bb6f004 100644 --- a/dom/html/TimeRanges.h +++ b/dom/html/TimeRanges.h @@ -25,13 +25,16 @@ namespace dom { // Implements media TimeRanges: // http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#timeranges -class TimeRanges final : public nsIDOMTimeRanges +class TimeRanges final : public nsIDOMTimeRanges, + public nsWrapperCache { public: - NS_DECL_ISUPPORTS + NS_DECL_CYCLE_COLLECTING_ISUPPORTS + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TimeRanges) NS_DECL_NSIDOMTIMERANGES TimeRanges(); + explicit TimeRanges(nsISupports* aParent); void Add(double aStart, double aEnd); @@ -50,7 +53,9 @@ public: // Mutate this TimeRange to be the intersection of this and aOtherRanges. void Intersection(const TimeRanges* aOtherRanges); - bool WrapObject(JSContext* aCx, JS::Handle aGivenProto, JS::MutableHandle aReflector); + virtual JSObject* WrapObject(JSContext* aCx, JS::Handle aGivenProto) override; + + nsISupports* GetParentObject() const; uint32_t Length() const { @@ -90,6 +95,8 @@ private: nsAutoTArray mRanges; + nsCOMPtr mParent; + public: typedef nsTArray::index_type index_type; static const index_type NoIndex = index_type(-1); diff --git a/dom/indexedDB/ActorsParent.cpp b/dom/indexedDB/ActorsParent.cpp index 6987a411f0..ee9d4decb6 100644 --- a/dom/indexedDB/ActorsParent.cpp +++ b/dom/indexedDB/ActorsParent.cpp @@ -5298,7 +5298,7 @@ public: void CloseDatabaseWhenIdle(const nsACString& aDatabaseId) { - unused << CloseDatabaseWhenIdleInternal(aDatabaseId); + Unused << CloseDatabaseWhenIdleInternal(aDatabaseId); } void @@ -9571,7 +9571,7 @@ RecvPIndexedDBPermissionRequestConstructor( } if (permission != PermissionRequestBase::kPermissionPrompt) { - unused << + Unused << PIndexedDBPermissionRequestParent::Send__delete__(actor, permission); } @@ -9829,7 +9829,7 @@ DatabaseConnection::RollbackWriteTransaction() // This may fail if SQLite already rolled back the transaction so ignore any // errors. - unused << stmt->Execute(); + Unused << stmt->Execute(); mInWriteTransaction = false; } @@ -9957,7 +9957,7 @@ DatabaseConnection::RollbackSavepoint() // This may fail if SQLite already rolled back the savepoint so ignore any // errors. - unused << stmt->Execute(); + Unused << stmt->Execute(); return NS_OK; } @@ -10047,7 +10047,7 @@ DatabaseConnection::DoIdleProcessing(bool aNeedsCheckpoint) // Release the connection's normal transaction. It's possible that it could // fail, but that isn't a problem here. - unused << rollbackStmt->Execute(); + Unused << rollbackStmt->Execute(); mInReadTransaction = false; } @@ -10072,7 +10072,7 @@ DatabaseConnection::DoIdleProcessing(bool aNeedsCheckpoint) // Truncate the WAL if we were asked to or if we managed to free some space. if (aNeedsCheckpoint || freedSomePages) { rv = CheckpointInternal(CheckpointMode::Truncate); - unused << NS_WARN_IF(NS_FAILED(rv)); + Unused << NS_WARN_IF(NS_FAILED(rv)); } // Finally try to restart the read transaction if we rolled it back earlier. @@ -10198,7 +10198,7 @@ DatabaseConnection::ReclaimFreePagesWhileIdle( MOZ_ASSERT(mInWriteTransaction); // Something failed, make sure we roll everything back. - unused << aRollbackStatement->Execute(); + Unused << aRollbackStatement->Execute(); mInWriteTransaction = false; @@ -11166,7 +11166,7 @@ ConnectionPool::Start(const nsID& aBackgroundChildLoggingId, } if (!transactionInfo->mBlockedOn.Count()) { - unused << ScheduleTransaction(transactionInfo, + Unused << ScheduleTransaction(transactionInfo, /* aFromQueuedTransactions */ false); } @@ -11259,7 +11259,7 @@ ConnectionPool::WaitForDatabasesToComplete(nsTArray&& aDatabaseIds, } if (mayRunCallbackImmediately) { - unused << aCallback->Run(); + Unused << aCallback->Run(); return; } @@ -11331,7 +11331,7 @@ ConnectionPool::Cleanup() MOZ_ASSERT(completeCallback); MOZ_ASSERT(completeCallback->mCallback); - unused << completeCallback->mCallback->Run(); + Unused << completeCallback->mCallback->Run(); } mCompleteCallbacks.Clear(); @@ -11857,7 +11857,7 @@ ConnectionPool::NoteClosedDatabase(DatabaseInfo* aDatabaseInfo) for (uint32_t index = 0, count = scheduledTransactions.Length(); index < count; index++) { - unused << ScheduleTransaction(scheduledTransactions[index], + Unused << ScheduleTransaction(scheduledTransactions[index], /* aFromQueuedTransactions */ false); } @@ -11922,7 +11922,7 @@ ConnectionPool::MaybeFireCallback(DatabasesCompleteCallback* aCallback) } } - unused << aCallback->mCallback->Run(); + Unused << aCallback->mCallback->Run(); return true; } @@ -12201,7 +12201,7 @@ FinishCallbackWrapper::Run() mHasRunOnce = true; - unused << mCallback->Run(); + Unused << mCallback->Run(); MOZ_ALWAYS_TRUE(NS_SUCCEEDED( mOwningThread->Dispatch(this, NS_DISPATCH_NORMAL))); @@ -12499,7 +12499,7 @@ TransactionInfo::Schedule() MOZ_ASSERT(connectionPool); connectionPool->AssertIsOnOwningThread(); - unused << + Unused << connectionPool->ScheduleTransaction(this, /* aFromQueuedTransactions */ false); } @@ -12889,7 +12889,7 @@ WaitForTransactionsHelper::WaitForTransactions() { MOZ_ASSERT(mState == State::Initial); - unused << this->Run(); + Unused << this->Run(); } void @@ -13121,7 +13121,7 @@ Database::Invalidate() mInvalidated = true; if (mActorWasAlive && !mActorDestroyed) { - unused << SendInvalidate(); + Unused << SendInvalidate(); } if (!Helper::InvalidateTransactions(mTransactions)) { @@ -14727,7 +14727,7 @@ NormalTransaction::SendCompleteNotification(nsresult aResult) AssertIsOnBackgroundThread(); if (!IsActorDestroyed()) { - unused << SendComplete(aResult); + Unused << SendComplete(aResult); } } @@ -15026,7 +15026,7 @@ VersionChangeTransaction::SendCompleteNotification(nsresult aResult) openDatabaseOp->mState = OpenDatabaseOp::State::SendingResults; if (!IsActorDestroyed()) { - unused << SendComplete(aResult); + Unused << SendComplete(aResult); } MOZ_ALWAYS_TRUE(NS_SUCCEEDED(openDatabaseOp->Run())); @@ -16822,7 +16822,7 @@ QuotaClient::PerformIdleMaintenance() if (kRunningXPCShellTests) { // We don't want user activity to impact this code if we're running tests. - unused << Observe(nullptr, OBSERVER_TOPIC_IDLE, nullptr); + Unused << Observe(nullptr, OBSERVER_TOPIC_IDLE, nullptr); } else if (!mIdleObserverRegistered) { nsCOMPtr idleService = do_GetService(kIdleServiceContractId); @@ -17967,7 +17967,7 @@ AutoProgressHandler::Unregister() nsCOMPtr oldHandler; nsresult rv = mConnection->RemoveProgressHandler(getter_AddRefs(oldHandler)); - unused << NS_WARN_IF(NS_FAILED(rv)); + Unused << NS_WARN_IF(NS_FAILED(rv)); MOZ_ASSERT_IF(NS_SUCCEEDED(rv), oldHandler == this); } @@ -20904,7 +20904,7 @@ OpenDatabaseOp::SendBlockedNotification() MOZ_ASSERT(mState == State::WaitingForOtherDatabasesToClose); if (!IsActorDestroyed()) { - unused << SendBlocked(mMetadata->mCommonMetadata.version()); + Unused << SendBlocked(mMetadata->mCommonMetadata.version()); } } @@ -21067,7 +21067,7 @@ OpenDatabaseOp::SendResults() response = ClampResultCode(mResultCode); } - unused << + Unused << PBackgroundIDBFactoryRequestParent::Send__delete__(this, response); } @@ -21793,7 +21793,7 @@ DeleteDatabaseOp::SendBlockedNotification() MOZ_ASSERT(mState == State::WaitingForOtherDatabasesToClose); if (!IsActorDestroyed()) { - unused << SendBlocked(0); + Unused << SendBlocked(0); } } @@ -21812,7 +21812,7 @@ DeleteDatabaseOp::SendResults() response = ClampResultCode(mResultCode); } - unused << + Unused << PBackgroundIDBFactoryRequestParent::Send__delete__(this, response); } @@ -22886,7 +22886,7 @@ CreateFileOp::SendResults() response = ClampResultCode(mResultCode); } - unused << + Unused << PBackgroundIDBDatabaseRequestParent::Send__delete__(this, response); } @@ -27246,7 +27246,7 @@ PermissionRequestHelper::OnPromptComplete(PermissionValue aPermissionValue) MOZ_ASSERT(NS_IsMainThread()); if (!mActorDestroyed) { - unused << + Unused << PIndexedDBPermissionRequestParent::Send__delete__(this, aPermissionValue); } } diff --git a/dom/ipc/Blob.cpp b/dom/ipc/Blob.cpp index c5b45b24da..1715fe420f 100644 --- a/dom/ipc/Blob.cpp +++ b/dom/ipc/Blob.cpp @@ -273,7 +273,7 @@ CancelableRunnableWrapper::Cancel() return NS_ERROR_UNEXPECTED; } - unused << Run(); + Unused << Run(); MOZ_ASSERT(!mRunnable); return NS_OK; @@ -4108,7 +4108,7 @@ BlobParent::NoteDyingRemoteBlobImpl() mBlobImpl = nullptr; mRemoteBlobImpl = nullptr; - unused << PBlobParent::Send__delete__(this); + Unused << PBlobParent::Send__delete__(this); } void diff --git a/dom/ipc/ColorPickerParent.cpp b/dom/ipc/ColorPickerParent.cpp index 000bb171b5..3d68c21d1b 100644 --- a/dom/ipc/ColorPickerParent.cpp +++ b/dom/ipc/ColorPickerParent.cpp @@ -12,7 +12,7 @@ #include "mozilla/dom/Element.h" #include "mozilla/dom/TabParent.h" -using mozilla::unused; +using mozilla::Unused; using namespace mozilla::dom; NS_IMPL_ISUPPORTS(ColorPickerParent::ColorPickerShownCallback, @@ -22,7 +22,7 @@ NS_IMETHODIMP ColorPickerParent::ColorPickerShownCallback::Update(const nsAString& aColor) { if (mColorPickerParent) { - unused << mColorPickerParent->SendUpdate(nsString(aColor)); + Unused << mColorPickerParent->SendUpdate(nsString(aColor)); } return NS_OK; } @@ -31,7 +31,7 @@ NS_IMETHODIMP ColorPickerParent::ColorPickerShownCallback::Done(const nsAString& aColor) { if (mColorPickerParent) { - unused << mColorPickerParent->Send__delete__(mColorPickerParent, + Unused << mColorPickerParent->Send__delete__(mColorPickerParent, nsString(aColor)); } return NS_OK; @@ -68,7 +68,7 @@ bool ColorPickerParent::RecvOpen() { if (!CreateColorPicker()) { - unused << Send__delete__(this, mInitialColor); + Unused << Send__delete__(this, mInitialColor); return true; } diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index cd91b89087..5a7fb4a93e 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -346,7 +346,7 @@ private: } // The XPCOM refcount drives the IPC lifecycle; see also // DeallocPCycleCollectWithLogsChild. - unused << Send__delete__(this); + Unused << Send__delete__(this); } nsresult UnimplementedProperty() @@ -807,7 +807,7 @@ ContentChild::ProvideWindowCommon(TabChild* aTabOpener, ipcContext->get_PopupIPCTabContext().opener() = aTabOpener; } - unused << SendPBrowserConstructor( + Unused << SendPBrowserConstructor( // We release this ref in DeallocPBrowserChild RefPtr(newChild).forget().take(), tabId, *ipcContext, aChromeFlags, @@ -2451,7 +2451,7 @@ OnFinishNuwaPreparation() } // This will create the actor. - unused << mozilla::dom::NuwaChild::GetSingleton(); + Unused << mozilla::dom::NuwaChild::GetSingleton(); MakeNuwaProcess(); } @@ -2576,17 +2576,17 @@ ContentChild::RecvFileSystemUpdate(const nsString& aFsName, } #else // Remove warnings about unused arguments - unused << aFsName; - unused << aVolumeName; - unused << aState; - unused << aMountGeneration; - unused << aIsMediaPresent; - unused << aIsSharing; - unused << aIsFormatting; - unused << aIsFake; - unused << aIsUnmounting; - unused << aIsRemovable; - unused << aIsHotSwappable; + Unused << aFsName; + Unused << aVolumeName; + Unused << aState; + Unused << aMountGeneration; + Unused << aIsMediaPresent; + Unused << aIsSharing; + Unused << aIsFormatting; + Unused << aIsFake; + Unused << aIsUnmounting; + Unused << aIsRemovable; + Unused << aIsHotSwappable; #endif return true; } @@ -2601,7 +2601,7 @@ ContentChild::RecvVolumeRemoved(const nsString& aFsName) } #else // Remove warnings about unused arguments - unused << aFsName; + Unused << aFsName; #endif return true; } @@ -2793,7 +2793,7 @@ ContentChild::RecvGatherProfile() profileCString = EmptyCString(); } - unused << SendProfile(profileCString); + Unused << SendProfile(profileCString); return true; } @@ -2904,7 +2904,7 @@ ContentChild::RecvShutdown() // Ignore errors here. If this fails, the parent will kill us after a // timeout. - unused << SendFinishShutdown(); + Unused << SendFinishShutdown(); return true; } diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index f6806f1f49..7c5c6d9fb6 100755 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -531,13 +531,13 @@ public: private: virtual bool RecvCloseGCLog() override { - unused << mSink->CloseGCLog(); + Unused << mSink->CloseGCLog(); return true; } virtual bool RecvCloseCCLog() override { - unused << mSink->CloseCCLog(); + Unused << mSink->CloseCCLog(); return true; } @@ -548,7 +548,7 @@ private: nsCOMPtr gcLog, ccLog; mSink->GetGcLog(getter_AddRefs(gcLog)); mSink->GetCcLog(getter_AddRefs(ccLog)); - unused << mCallback->OnDump(gcLog, ccLog, /* parent = */ false); + Unused << mCallback->OnDump(gcLog, ccLog, /* parent = */ false); return true; } @@ -1516,7 +1516,7 @@ ContentParent::Init() // If accessibility is running in chrome process then start it in content // process. if (nsIPresShell::IsAccessibilityActive()) { - unused << SendActivateA11y(); + Unused << SendActivateA11y(); } #endif } @@ -1533,7 +1533,7 @@ ContentParent::ForwardKnownInfo() RefPtr vs = nsVolumeService::GetSingleton(); if (vs && !mIsForBrowser) { vs->GetVolumesForIPC(&volumeInfo); - unused << SendVolumes(volumeInfo); + Unused << SendVolumes(volumeInfo); } #endif /* MOZ_WIDGET_GONK */ @@ -2212,7 +2212,7 @@ ContentParent::NotifyTabDestroyed(const TabId& aTabId, // Need to close undeleted ContentPermissionRequestParents before tab is closed. for (auto& permissionRequestParent : parentArray) { nsTArray emptyChoices; - unused << PContentPermissionRequestParent::Send__delete__(permissionRequestParent, + Unused << PContentPermissionRequestParent::Send__delete__(permissionRequestParent, false, emptyChoices); } @@ -2493,7 +2493,7 @@ ContentParent::InitInternal(ProcessPriority aInitialPriority, nsCString vendor(gAppData->vendor); // Sending all information to content process. - unused << SendAppInfo(version, buildID, name, UAName, ID, vendor); + Unused << SendAppInfo(version, buildID, name, UAName, ID, vendor); } // Initialize the message manager (and load delayed scripts) now that we @@ -2533,7 +2533,7 @@ ContentParent::InitInternal(ProcessPriority aInitialPriority, if (gAppData) { // Sending all information to content process. - unused << SendAppInit(); + Unused << SendAppInit(); } nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance(); @@ -2545,21 +2545,21 @@ ContentParent::InitInternal(ProcessPriority aInitialPriority, for (uint32_t i = 0; i < agentSheets.Length(); i++) { URIParams uri; SerializeURI(agentSheets[i]->GetSheetURI(), uri); - unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::AGENT_SHEET); + Unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::AGENT_SHEET); } nsCOMArray& userSheets = *sheetService->UserStyleSheets(); for (uint32_t i = 0; i < userSheets.Length(); i++) { URIParams uri; SerializeURI(userSheets[i]->GetSheetURI(), uri); - unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::USER_SHEET); + Unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::USER_SHEET); } nsCOMArray& authorSheets = *sheetService->AuthorStyleSheets(); for (uint32_t i = 0; i < authorSheets.Length(); i++) { URIParams uri; SerializeURI(authorSheets[i]->GetSheetURI(), uri); - unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::AUTHOR_SHEET); + Unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::AUTHOR_SHEET); } } @@ -3014,7 +3014,7 @@ ContentParent::OnNewProcessCreated(uint32_t aPid, sNuwaPrefUpdates->Length() : 0; // Resend pref updates to the forked child. for (size_t i = 0; i < numNuwaPrefUpdates; i++) { - mozilla::unused << content->SendPreferenceUpdate(sNuwaPrefUpdates->ElementAt(i)); + mozilla::Unused << content->SendPreferenceUpdate(sNuwaPrefUpdates->ElementAt(i)); } // Update offline settings. @@ -3028,8 +3028,8 @@ ContentParent::OnNewProcessCreated(uint32_t aPid, RecvGetXPCOMProcessAttributes(&isOffline, &isConnected, &isLangRTL, &unusedDictionaries, &clipboardCaps, &domainPolicy, &initialData); - mozilla::unused << content->SendSetOffline(isOffline); - mozilla::unused << content->SendSetConnectivity(isConnected); + mozilla::Unused << content->SendSetOffline(isOffline); + mozilla::Unused << content->SendSetConnectivity(isConnected); MOZ_ASSERT(!clipboardCaps.supportsSelectionClipboard() && !clipboardCaps.supportsFindClipboard(), "Unexpected values"); @@ -3093,7 +3093,7 @@ ContentParent::Observe(nsISupports* aSubject, if (!strcmp(aTopic, "memory-pressure") && !StringEndsWith(nsDependentString(aData), NS_LITERAL_STRING("-no-forward"))) { - unused << SendFlushMemory(nsDependentString(aData)); + Unused << SendFlushMemory(nsDependentString(aData)); } // listening for remotePrefs... else if (!strcmp(aTopic, "nsPref:changed")) { @@ -3135,28 +3135,29 @@ ContentParent::Observe(nsISupports* aSubject, else if (!strcmp(aTopic, "alertfinished") || !strcmp(aTopic, "alertclickcallback") || !strcmp(aTopic, "alertshow") || - !strcmp(aTopic, "alertdisablecallback")) { + !strcmp(aTopic, "alertdisablecallback") || + !strcmp(aTopic, "alertsettingscallback")) { if (!SendNotifyAlertsObserver(nsDependentCString(aTopic), nsDependentString(aData))) return NS_ERROR_NOT_AVAILABLE; } else if (!strcmp(aTopic, "child-gc-request")){ - unused << SendGarbageCollect(); + Unused << SendGarbageCollect(); } else if (!strcmp(aTopic, "child-cc-request")){ - unused << SendCycleCollect(); + Unused << SendCycleCollect(); } else if (!strcmp(aTopic, "child-mmu-request")){ - unused << SendMinimizeMemoryUsage(); + Unused << SendMinimizeMemoryUsage(); } else if (!strcmp(aTopic, "last-pb-context-exited")) { - unused << SendLastPrivateDocShellDestroyed(); + Unused << SendLastPrivateDocShellDestroyed(); } else if (!strcmp(aTopic, "file-watcher-update")) { nsCString creason; CopyUTF16toUTF8(aData, creason); DeviceStorageFile* file = static_cast(aSubject); - unused << SendFilePathUpdate(file->mStorageType, file->mStorageName, file->mPath, creason); + Unused << SendFilePathUpdate(file->mStorageType, file->mStorageName, file->mPath, creason); } #ifdef MOZ_WIDGET_GONK else if(!strcmp(aTopic, NS_VOLUME_STATE_CHANGED)) { @@ -3189,17 +3190,17 @@ ContentParent::Observe(nsISupports* aSubject, vol->GetIsRemovable(&isRemovable); vol->GetIsHotSwappable(&isHotSwappable); - unused << SendFileSystemUpdate(volName, mountPoint, state, + Unused << SendFileSystemUpdate(volName, mountPoint, state, mountGeneration, isMediaPresent, isSharing, isFormatting, isFake, isUnmounting, isRemovable, isHotSwappable); } else if (!strcmp(aTopic, "phone-state-changed")) { nsString state(aData); - unused << SendNotifyPhoneStateChange(state); + Unused << SendNotifyPhoneStateChange(state); } else if(!strcmp(aTopic, NS_VOLUME_REMOVED)) { nsString volName(aData); - unused << SendVolumeRemoved(volName); + Unused << SendVolumeRemoved(volName); } #endif #ifdef ACCESSIBILITY @@ -3207,11 +3208,11 @@ ContentParent::Observe(nsISupports* aSubject, // gets initiated in chrome process. else if (aData && (*aData == '1') && !strcmp(aTopic, "a11y-init-or-shutdown")) { - unused << SendActivateA11y(); + Unused << SendActivateA11y(); } #endif else if (!strcmp(aTopic, "app-theme-changed")) { - unused << SendOnAppThemeChanged(); + Unused << SendOnAppThemeChanged(); } #ifdef MOZ_ENABLE_PROFILER_SPS else if (!strcmp(aTopic, "profiler-started")) { @@ -3222,21 +3223,21 @@ ContentParent::Observe(nsISupports* aSubject, params->GetInterval(&interval); const nsTArray& features = params->GetFeatures(); const nsTArray& threadFilterNames = params->GetThreadFilterNames(); - unused << SendStartProfiler(entries, interval, features, threadFilterNames); + Unused << SendStartProfiler(entries, interval, features, threadFilterNames); } else if (!strcmp(aTopic, "profiler-stopped")) { - unused << SendStopProfiler(); + Unused << SendStopProfiler(); } else if (!strcmp(aTopic, "profiler-paused")) { - unused << SendPauseProfiler(true); + Unused << SendPauseProfiler(true); } else if (!strcmp(aTopic, "profiler-resumed")) { - unused << SendPauseProfiler(false); + Unused << SendPauseProfiler(false); } else if (!strcmp(aTopic, "profiler-subprocess-gather")) { mGatherer = static_cast(aSubject); mGatherer->WillGatherOOPProfile(); - unused << SendGatherProfile(); + Unused << SendGatherProfile(); } else if (!strcmp(aTopic, "profiler-subprocess")) { nsCOMPtr pse = do_QueryInterface(aSubject); @@ -3249,7 +3250,7 @@ ContentParent::Observe(nsISupports* aSubject, } #endif else if (!strcmp(aTopic, "gmp-changed")) { - unused << SendNotifyGMPsChanged(); + Unused << SendNotifyGMPsChanged(); } return NS_OK; } @@ -4157,7 +4158,7 @@ ContentParent::RecvGetSystemMemory(const uint64_t& aGetterId) memoryTotal = mozilla::hal::GetTotalSystemMemoryLevel(); #endif - unused << SendSystemMemoryAvailable(aGetterId, memoryTotal); + Unused << SendSystemMemoryAvailable(aGetterId, memoryTotal); return true; } @@ -4213,6 +4214,20 @@ ContentParent::RecvLoadURIExternal(const URIParams& uri) return true; } +bool +ContentParent::HasNotificationPermission(const IPC::Principal& aPrincipal) +{ +#ifdef MOZ_CHILD_PERMISSIONS + uint32_t permission = mozilla::CheckPermission(this, aPrincipal, + "desktop-notification"); + if (permission != nsIPermissionManager::ALLOW_ACTION) { + return false; + } +#endif /* MOZ_CHILD_PERMISSIONS */ + + return true; +} + bool ContentParent::RecvShowAlertNotification(const nsString& aImageUrl, const nsString& aTitle, const nsString& aText, const bool& aTextClickable, @@ -4222,13 +4237,9 @@ ContentParent::RecvShowAlertNotification(const nsString& aImageUrl, const nsStri const IPC::Principal& aPrincipal, const bool& aInPrivateBrowsing) { -#ifdef MOZ_CHILD_PERMISSIONS - uint32_t permission = mozilla::CheckPermission(this, aPrincipal, - "desktop-notification"); - if (permission != nsIPermissionManager::ALLOW_ACTION) { + if (!HasNotificationPermission(aPrincipal)) { return true; } -#endif /* MOZ_CHILD_PERMISSIONS */ nsCOMPtr sysAlerts(do_GetService(NS_ALERTSERVICE_CONTRACTID)); if (sysAlerts) { @@ -4243,13 +4254,9 @@ bool ContentParent::RecvCloseAlert(const nsString& aName, const IPC::Principal& aPrincipal) { -#ifdef MOZ_CHILD_PERMISSIONS - uint32_t permission = mozilla::CheckPermission(this, aPrincipal, - "desktop-notification"); - if (permission != nsIPermissionManager::ALLOW_ACTION) { + if (!HasNotificationPermission(aPrincipal)) { return true; } -#endif nsCOMPtr sysAlerts(do_GetService(NS_ALERTSERVICE_CONTRACTID)); if (sysAlerts) { @@ -4262,15 +4269,18 @@ ContentParent::RecvCloseAlert(const nsString& aName, bool ContentParent::RecvDisableNotifications(const IPC::Principal& aPrincipal) { -#ifdef MOZ_CHILD_PERMISSIONS - uint32_t permission = mozilla::CheckPermission(this, aPrincipal, - "desktop-notification"); - if (permission != nsIPermissionManager::ALLOW_ACTION) { - return true; + if (HasNotificationPermission(aPrincipal)) { + Unused << Notification::RemovePermission(aPrincipal); } -#endif + return true; +} - unused << Notification::RemovePermission(aPrincipal); +bool +ContentParent::RecvOpenNotificationSettings(const IPC::Principal& aPrincipal) +{ + if (HasNotificationPermission(aPrincipal)) { + Unused << Notification::OpenSettings(aPrincipal); + } return true; } @@ -4423,7 +4433,7 @@ ContentParent::RecvSetGeolocationHigherAccuracy(const bool& aEnable) NS_IMETHODIMP ContentParent::HandleEvent(nsIDOMGeoPosition* postion) { - unused << SendGeolocationUpdate(GeoPosition(postion)); + Unused << SendGeolocationUpdate(GeoPosition(postion)); return NS_OK; } @@ -4434,7 +4444,7 @@ ContentParent::HandleEvent(nsIDOMGeoPositionError* postionError) nsresult rv; rv = postionError->GetCode(&errorCode); NS_ENSURE_SUCCESS(rv,rv); - unused << SendGeolocationError(errorCode); + Unused << SendGeolocationError(errorCode); return NS_OK; } @@ -5003,7 +5013,7 @@ ContentParent::NotifyUpdatedDictionaries() spellChecker->GetDictionaryList(&dictionaries); for (size_t i = 0; i < processes.Length(); ++i) { - unused << processes[i]->SendUpdateDictionaryList(dictionaries); + Unused << processes[i]->SendUpdateDictionaryList(dictionaries); } } @@ -5129,7 +5139,7 @@ ContentParent::RecvPOfflineCacheUpdateConstructor(POfflineCacheUpdateParent* aAc nsresult rv = update->Schedule(aManifestURI, aDocumentURI, aLoadingPrincipal, aStickDocument); if (NS_FAILED(rv) && IsAlive()) { // Inform the child of failure. - unused << update->SendFinish(false, false); + Unused << update->SendFinish(false, false); } return true; @@ -5207,7 +5217,7 @@ ContentParent::MaybeInvokeDragSession(TabParent* aParent) this); uint32_t action; session->GetDragAction(&action); - mozilla::unused << SendInvokeDragSession(dataTransfers, action); + mozilla::Unused << SendInvokeDragSession(dataTransfers, action); } } } @@ -5653,7 +5663,7 @@ NS_IMPL_ISUPPORTS(ParentIdleListener, nsIObserver) NS_IMETHODIMP ParentIdleListener::Observe(nsISupports*, const char* aTopic, const char16_t* aData) { - mozilla::unused << mParent->SendNotifyIdleObserver(mObserver, + mozilla::Unused << mParent->SendNotifyIdleObserver(mObserver, nsDependentCString(aTopic), nsDependentString(aData)); return NS_OK; diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h index 1895982a9c..dd29694957 100644 --- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -755,6 +755,8 @@ private: virtual bool RecvSetURITitle(const URIParams& uri, const nsString& title) override; + bool HasNotificationPermission(const IPC::Principal& aPrincipal); + virtual bool RecvShowAlertNotification(const nsString& aImageUrl, const nsString& aTitle, const nsString& aText, const bool& aTextClickable, const nsString& aCookie, const nsString& aName, @@ -768,6 +770,8 @@ private: virtual bool RecvDisableNotifications(const IPC::Principal& aPrincipal) override; + virtual bool RecvOpenNotificationSettings(const IPC::Principal& aPrincipal) override; + virtual bool RecvLoadURIExternal(const URIParams& uri) override; virtual bool RecvSyncMessage(const nsString& aMsg, diff --git a/dom/ipc/ContentProcess.cpp b/dom/ipc/ContentProcess.cpp index 230f8fd295..0cedce12bd 100644 --- a/dom/ipc/ContentProcess.cpp +++ b/dom/ipc/ContentProcess.cpp @@ -58,7 +58,7 @@ SetUpSandboxEnvironment() // Change the gecko defined temp directory to our low integrity one. // Undefine returns a failure if the property is not already set. - unused << nsDirectoryService::gService->Undefine(NS_OS_TEMP_DIR); + Unused << nsDirectoryService::gService->Undefine(NS_OS_TEMP_DIR); rv = nsDirectoryService::gService->Set(NS_OS_TEMP_DIR, lowIntegrityTemp); if (NS_WARN_IF(NS_FAILED(rv))) { return; diff --git a/dom/ipc/FilePickerParent.cpp b/dom/ipc/FilePickerParent.cpp index 4db87ab73c..1090e48a4f 100644 --- a/dom/ipc/FilePickerParent.cpp +++ b/dom/ipc/FilePickerParent.cpp @@ -18,7 +18,7 @@ #include "mozilla/dom/TabParent.h" #include "mozilla/dom/ipc/BlobParent.h" -using mozilla::unused; +using mozilla::Unused; using namespace mozilla::dom; NS_IMPL_ISUPPORTS(FilePickerParent::FilePickerShownCallback, @@ -125,7 +125,7 @@ FilePickerParent::SendFiles(const nsTArray>& aBlobs) InputFiles inblobs; inblobs.blobsParent().SwapElements(blobs); - unused << Send__delete__(this, inblobs, mResult); + Unused << Send__delete__(this, inblobs, mResult); } void @@ -134,7 +134,7 @@ FilePickerParent::Done(int16_t aResult) mResult = aResult; if (mResult != nsIFilePicker::returnOK) { - unused << Send__delete__(this, void_t(), mResult); + Unused << Send__delete__(this, void_t(), mResult); return; } @@ -168,7 +168,7 @@ FilePickerParent::Done(int16_t aResult) mRunnable = new FileSizeAndDateRunnable(this, blobs); // Dispatch to background thread to do I/O: if (!mRunnable->Dispatch()) { - unused << Send__delete__(this, void_t(), nsIFilePicker::returnCancel); + Unused << Send__delete__(this, void_t(), nsIFilePicker::returnCancel); } } @@ -203,7 +203,7 @@ FilePickerParent::RecvOpen(const int16_t& aSelectedType, const nsString& aDisplayDirectory) { if (!CreateFilePicker()) { - unused << Send__delete__(this, void_t(), nsIFilePicker::returnCancel); + Unused << Send__delete__(this, void_t(), nsIFilePicker::returnCancel); return true; } diff --git a/dom/ipc/NuwaChild.cpp b/dom/ipc/NuwaChild.cpp index dfea80b1d0..edf8e95e9d 100644 --- a/dom/ipc/NuwaChild.cpp +++ b/dom/ipc/NuwaChild.cpp @@ -239,7 +239,7 @@ OnNuwaProcessReady() NuwaChild* nuwaChild = NuwaChild::GetSingleton(); MOZ_ASSERT(nuwaChild); - mozilla::unused << nuwaChild->SendNotifyReady(); + mozilla::Unused << nuwaChild->SendNotifyReady(); } NS_EXPORT void diff --git a/dom/ipc/NuwaParent.cpp b/dom/ipc/NuwaParent.cpp index 9d0a6c6c84..e97ce4f8b3 100644 --- a/dom/ipc/NuwaParent.cpp +++ b/dom/ipc/NuwaParent.cpp @@ -125,7 +125,7 @@ NuwaParent::CloneProtocol(Channel* aChannel, actor->ActorConstructed(); // The actor can finally be deleted after fully constructed. - mozilla::unused << actor->Send__delete__(actor); + mozilla::Unused << actor->Send__delete__(actor); }); MOZ_ASSERT(nested); MOZ_ALWAYS_TRUE(NS_SUCCEEDED( @@ -232,7 +232,7 @@ NuwaParent::ForkNewProcess(uint32_t& aPid, RefPtr self = this; nsCOMPtr runnable = NS_NewRunnableFunction([self] () -> void { - mozilla::unused << self->SendFork(); + mozilla::Unused << self->SendFork(); }); MOZ_ASSERT(runnable); MOZ_ALWAYS_TRUE(NS_SUCCEEDED(mWorkerThread->Dispatch(runnable, diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl index 81c3fbc719..64d470b101 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -843,6 +843,8 @@ parent: DisableNotifications(Principal principal); + OpenNotificationSettings(Principal principal); + PPSMContentDownloader(uint32_t aCertType); PExternalHelperApp(OptionalURIParams uri, diff --git a/dom/ipc/PreallocatedProcessManager.cpp b/dom/ipc/PreallocatedProcessManager.cpp index 50c3bb7e1a..df91760a93 100644 --- a/dom/ipc/PreallocatedProcessManager.cpp +++ b/dom/ipc/PreallocatedProcessManager.cpp @@ -308,7 +308,7 @@ SendTestOnlyNotification(const char* aMessage) nsCOMPtr ppmm = do_GetService("@mozilla.org/parentprocessmessagemanager;1"); - mozilla::unused << ppmm->BroadcastAsyncMessage( + mozilla::Unused << ppmm->BroadcastAsyncMessage( message, JS::NullHandleValue, JS::NullHandleValue, cx, 1); } diff --git a/dom/ipc/ProcessHangMonitor.cpp b/dom/ipc/ProcessHangMonitor.cpp index 6bf3c2bc02..fd623dbdf8 100644 --- a/dom/ipc/ProcessHangMonitor.cpp +++ b/dom/ipc/ProcessHangMonitor.cpp @@ -346,7 +346,7 @@ HangMonitorChild::NotifySlowScriptAsync(TabId aTabId, unsigned aLineNo) { if (mIPCOpen) { - unused << SendHangEvidence(SlowScriptData(aTabId, aFileName, aLineNo)); + Unused << SendHangEvidence(SlowScriptData(aTabId, aFileName, aLineNo)); } } @@ -425,7 +425,7 @@ HangMonitorChild::NotifyPluginHangAsync(uint32_t aPluginId) // bounce back to parent on background thread if (mIPCOpen) { - unused << SendHangEvidence(PluginHangData(aPluginId)); + Unused << SendHangEvidence(PluginHangData(aPluginId)); } } @@ -619,7 +619,7 @@ HangMonitorParent::TerminateScript() MOZ_RELEASE_ASSERT(MessageLoop::current() == MonitorLoop()); if (mIPCOpen) { - unused << SendTerminateScript(); + Unused << SendTerminateScript(); } } @@ -629,7 +629,7 @@ HangMonitorParent::BeginStartingDebugger() MOZ_RELEASE_ASSERT(MessageLoop::current() == MonitorLoop()); if (mIPCOpen) { - unused << SendBeginStartingDebugger(); + Unused << SendBeginStartingDebugger(); } } @@ -639,7 +639,7 @@ HangMonitorParent::EndStartingDebugger() MOZ_RELEASE_ASSERT(MessageLoop::current() == MonitorLoop()); if (mIPCOpen) { - unused << SendEndStartingDebugger(); + Unused << SendEndStartingDebugger(); } } diff --git a/dom/ipc/ProcessPriorityManager.cpp b/dom/ipc/ProcessPriorityManager.cpp index cede2ca4bf..5e37801a7c 100644 --- a/dom/ipc/ProcessPriorityManager.cpp +++ b/dom/ipc/ProcessPriorityManager.cpp @@ -1089,11 +1089,11 @@ ParticularProcessPriorityManager::SetPriorityNow(ProcessPriority aPriority, ProcessPriorityManagerImpl::GetSingleton()-> NotifyProcessPriorityChanged(this, oldPriority); - unused << mContentParent->SendNotifyProcessPriorityChanged(mPriority); + Unused << mContentParent->SendNotifyProcessPriorityChanged(mPriority); } if (aPriority < PROCESS_PRIORITY_FOREGROUND) { - unused << mContentParent->SendFlushMemory(NS_LITERAL_STRING("lowering-priority")); + Unused << mContentParent->SendFlushMemory(NS_LITERAL_STRING("lowering-priority")); } FireTestOnlyObserverNotification("process-priority-set", @@ -1307,7 +1307,7 @@ ProcessLRUPool::CalculateLRULevel(uint32_t aLRU) // (End of buffer) int exp; - unused << frexp(static_cast(aLRU), &exp); + Unused << frexp(static_cast(aLRU), &exp); uint32_t level = std::max(exp - 1, 0); return std::min(mLRUPoolLevels - 1, level); diff --git a/dom/ipc/ScreenManagerParent.cpp b/dom/ipc/ScreenManagerParent.cpp index 9f41630860..747d938fcf 100644 --- a/dom/ipc/ScreenManagerParent.cpp +++ b/dom/ipc/ScreenManagerParent.cpp @@ -26,7 +26,7 @@ ScreenManagerParent::ScreenManagerParent(uint32_t* aNumberOfScreens, MOZ_CRASH("Couldn't get nsIScreenManager from ScreenManagerParent."); } - unused << RecvRefresh(aNumberOfScreens, aSystemDefaultScale, aSuccess); + Unused << RecvRefresh(aNumberOfScreens, aSystemDefaultScale, aSuccess); } bool @@ -64,7 +64,7 @@ ScreenManagerParent::RecvScreenRefresh(const uint32_t& aId, } ScreenDetails details; - unused << ExtractScreenDetails(screen, details); + Unused << ExtractScreenDetails(screen, details); *aRetVal = details; *aSuccess = true; diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 3b2ae4063f..57d9e6b11b 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -424,7 +424,7 @@ private: // Check in case ActorDestroy was called after RecvDestroy message. if (mTabChild->IPCOpen()) { - unused << PBrowserChild::Send__delete__(mTabChild); + Unused << PBrowserChild::Send__delete__(mTabChild); } mTabChild = nullptr; @@ -728,7 +728,7 @@ TabChild::Observe(nsISupports *aSubject, bool active = activeStr.EqualsLiteral("active"); if (active != mAudioChannelsActive[audioChannel]) { mAudioChannelsActive[audioChannel] = active; - unused << SendAudioChannelActivityNotification(audioChannel, active); + Unused << SendAudioChannelActivityNotification(audioChannel, active); } } @@ -972,7 +972,7 @@ NS_IMETHODIMP TabChild::SetDimensions(uint32_t aFlags, int32_t aX, int32_t aY, int32_t aCx, int32_t aCy) { - unused << PBrowserChild::SendSetDimensions(aFlags, aX, aY, aCx, aCy); + Unused << PBrowserChild::SendSetDimensions(aFlags, aX, aY, aCx, aCy); return NS_OK; } @@ -2144,7 +2144,7 @@ TabChild::RecvCompositionEvent(const WidgetCompositionEvent& event) WidgetCompositionEvent localEvent(event); localEvent.widget = mPuppetWidget; APZCCallbackHelper::DispatchWidgetEvent(localEvent); - unused << SendOnEventNeedingAckHandled(event.mMessage); + Unused << SendOnEventNeedingAckHandled(event.mMessage); return true; } @@ -2154,7 +2154,7 @@ TabChild::RecvSelectionEvent(const WidgetSelectionEvent& event) WidgetSelectionEvent localEvent(event); localEvent.widget = mPuppetWidget; APZCCallbackHelper::DispatchWidgetEvent(localEvent); - unused << SendOnEventNeedingAckHandled(event.mMessage); + Unused << SendOnEventNeedingAckHandled(event.mMessage); return true; } diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index fd2d361241..4d86913740 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -183,7 +183,7 @@ private: // Our TabParent may have been destroyed already. If so, don't send any // fds over, just go back to the IO thread and close them. if (!tabParent->IsDestroyed()) { - mozilla::unused << tabParent->SendCacheFileDescriptor(mPath, fd); + mozilla::Unused << tabParent->SendCacheFileDescriptor(mPath, fd); } if (!mFD) { @@ -231,7 +231,7 @@ private: // Intentionally leak the runnable (but not the fd) rather // than crash when trying to release a main thread object // off the main thread. - mozilla::unused << mTabParent.forget(); + mozilla::Unused << mTabParent.forget(); CloseFile(); } } @@ -546,7 +546,7 @@ TabParent::DestroyInternal() // If this fails, it's most likely due to a content-process crash, // and auto-cleanup will kick in. Otherwise, the child side will // destroy itself and send back __delete__(). - unused << SendDestroy(); + Unused << SendDestroy(); if (RenderFrameParent* frame = GetRenderFrame()) { RemoveTabParentFromTable(frame->GetLayersId()); @@ -766,7 +766,7 @@ TabParent::LoadURL(nsIURI* aURI) if (mSendOfflineStatus && NS_IsAppOffline(appId)) { // If the app is offline in the parent process // pass that state to the child process as well - unused << SendAppOfflineStatus(appId, true); + Unused << SendAppOfflineStatus(appId, true); } mSendOfflineStatus = false; @@ -776,7 +776,7 @@ TabParent::LoadURL(nsIURI* aURI) return; } - unused << SendLoadURL(spec, configuration, GetShowInfo()); + Unused << SendLoadURL(spec, configuration, GetShowInfo()); // If this app is a packaged app then we can speed startup by sending over // the file descriptor for the "application.zip" file that it will @@ -821,7 +821,7 @@ TabParent::LoadURL(nsIURI* aURI) if (cachedFd) { FileDescriptor::PlatformHandleType handle = FileDescriptor::PlatformHandleType(PR_FileDesc2NativeHandle(cachedFd)); - unused << SendCacheFileDescriptor(path, FileDescriptor(handle)); + Unused << SendCacheFileDescriptor(path, FileDescriptor(handle)); } else #endif { @@ -860,11 +860,11 @@ TabParent::Show(const ScreenIntSize& size, bool aParentIsActive) &success); MOZ_ASSERT(success); AddTabParentToTable(layersId, this); - unused << SendPRenderFrameConstructor(renderFrame); + Unused << SendPRenderFrameConstructor(renderFrame); } } - unused << SendShow(size, GetShowInfo(), textureFactoryIdentifier, + Unused << SendShow(size, GetShowInfo(), textureFactoryIdentifier, layersId, renderFrame, aParentIsActive); } @@ -960,7 +960,7 @@ TabParent::UpdateDimensions(const nsIntRect& rect, const ScreenIntSize& size) CSSRect unscaledRect = devicePixelRect / widgetScale; CSSSize unscaledSize = devicePixelSize / widgetScale; - unused << SendUpdateDimensions(unscaledRect, unscaledSize, + Unused << SendUpdateDimensions(unscaledRect, unscaledSize, widget->SizeMode(), orientation, chromeOffset); } @@ -970,7 +970,7 @@ void TabParent::UpdateFrame(const FrameMetrics& aFrameMetrics) { if (!mIsDestroyed) { - unused << SendUpdateFrame(aFrameMetrics); + Unused << SendUpdateFrame(aFrameMetrics); } } @@ -986,7 +986,7 @@ TabParent::UIResolutionChanged() // fails to cache the values, then mDefaultScale.scale might be invalid. // We don't want to send that value to content. Just send -1 for it too in // that case. - unused << SendUIResolutionChanged(mDPI, mDPI < 0 ? -1.0 : mDefaultScale.scale); + Unused << SendUIResolutionChanged(mDPI, mDPI < 0 ? -1.0 : mDefaultScale.scale); } } @@ -999,7 +999,7 @@ TabParent::ThemeChanged() // LookAndFeel should have the up-to-date values, which we now // send down to the child. We do this for every remote tab for now, // but bug 1156934 has been filed to do it once per content process. - unused << SendThemeChanged(LookAndFeel::GetIntCache()); + Unused << SendThemeChanged(LookAndFeel::GetIntCache()); } } @@ -1009,7 +1009,7 @@ TabParent::HandleAccessKey(nsTArray& aCharCodes, const int32_t& aModifierMask) { if (!mIsDestroyed) { - unused << SendHandleAccessKey(aCharCodes, aIsTrusted, aModifierMask); + Unused << SendHandleAccessKey(aCharCodes, aIsTrusted, aModifierMask); } } @@ -1018,7 +1018,7 @@ TabParent::RequestFlingSnap(const FrameMetrics::ViewID& aScrollId, const mozilla::CSSPoint& aDestination) { if (!mIsDestroyed) { - unused << SendRequestFlingSnap(aScrollId, aDestination); + Unused << SendRequestFlingSnap(aScrollId, aDestination); } } @@ -1026,7 +1026,7 @@ void TabParent::AcknowledgeScrollUpdate(const ViewID& aScrollId, const uint32_t& aScrollGeneration) { if (!mIsDestroyed) { - unused << SendAcknowledgeScrollUpdate(aScrollId, aScrollGeneration); + Unused << SendAcknowledgeScrollUpdate(aScrollId, aScrollGeneration); } } @@ -1035,7 +1035,7 @@ void TabParent::HandleDoubleTap(const CSSPoint& aPoint, const ScrollableLayerGuid &aGuid) { if (!mIsDestroyed) { - unused << SendHandleDoubleTap(aPoint, aModifiers, aGuid); + Unused << SendHandleDoubleTap(aPoint, aModifiers, aGuid); } } @@ -1044,7 +1044,7 @@ void TabParent::HandleSingleTap(const CSSPoint& aPoint, const ScrollableLayerGuid &aGuid) { if (!mIsDestroyed) { - unused << SendHandleSingleTap(aPoint, aModifiers, aGuid); + Unused << SendHandleSingleTap(aPoint, aModifiers, aGuid); } } @@ -1054,7 +1054,7 @@ void TabParent::HandleLongTap(const CSSPoint& aPoint, uint64_t aInputBlockId) { if (!mIsDestroyed) { - unused << SendHandleLongTap(aPoint, aModifiers, aGuid, aInputBlockId); + Unused << SendHandleLongTap(aPoint, aModifiers, aGuid, aInputBlockId); } } @@ -1063,7 +1063,7 @@ void TabParent::NotifyAPZStateChange(ViewID aViewId, int aArg) { if (!mIsDestroyed) { - unused << SendNotifyAPZStateChange(aViewId, aChange, aArg); + Unused << SendNotifyAPZStateChange(aViewId, aChange, aArg); } } @@ -1071,7 +1071,7 @@ void TabParent::NotifyMouseScrollTestEvent(const ViewID& aScrollId, const nsString& aEvent) { if (!mIsDestroyed) { - unused << SendMouseScrollTestEvent(aScrollId, aEvent); + Unused << SendMouseScrollTestEvent(aScrollId, aEvent); } } @@ -1079,7 +1079,7 @@ void TabParent::NotifyFlushComplete() { if (!mIsDestroyed) { - unused << SendNotifyFlushComplete(); + Unused << SendNotifyFlushComplete(); } } @@ -1087,7 +1087,7 @@ void TabParent::Activate() { if (!mIsDestroyed) { - unused << SendActivate(); + Unused << SendActivate(); } } @@ -1095,7 +1095,7 @@ void TabParent::Deactivate() { if (!mIsDestroyed) { - unused << SendDeactivate(); + Unused << SendDeactivate(); } } @@ -1286,7 +1286,7 @@ TabParent::SendMouseEvent(const nsAString& aType, float aX, float aY, int32_t aModifiers, bool aIgnoreRootScrollFrame) { if (!mIsDestroyed) { - unused << PBrowserParent::SendMouseEvent(nsString(aType), aX, aY, + Unused << PBrowserParent::SendMouseEvent(nsString(aType), aX, aY, aButton, aClickCount, aModifiers, aIgnoreRootScrollFrame); } @@ -1300,7 +1300,7 @@ TabParent::SendKeyEvent(const nsAString& aType, bool aPreventDefault) { if (!mIsDestroyed) { - unused << PBrowserParent::SendKeyEvent(nsString(aType), aKeyCode, aCharCode, + Unused << PBrowserParent::SendKeyEvent(nsString(aType), aKeyCode, aCharCode, aModifiers, aPreventDefault); } } @@ -2920,7 +2920,7 @@ NS_IMETHODIMP TabParent::SetDocShellIsActive(bool isActive) { mDocShellIsActive = isActive; - unused << SendSetDocShellIsActive(isActive); + Unused << SendSetDocShellIsActive(isActive); return NS_OK; } @@ -2954,7 +2954,7 @@ TabParent::SetHasContentOpener(bool aHasContentOpener) NS_IMETHODIMP TabParent::NavigateByKey(bool aForward, bool aForDocumentNavigation) { - unused << SendNavigateByKey(aForward, aForDocumentNavigation); + Unused << SendNavigateByKey(aForward, aForDocumentNavigation); return NS_OK; } @@ -3243,7 +3243,7 @@ TabParent::RecvInvokeDragSession(nsTArray&& aTransfers, nsIPresShell* shell = mFrameElement->OwnerDoc()->GetShell(); if (!shell) { if (Manager()->IsContentParent()) { - Manager()->AsContentParent()->SendEndDragSession(true, true); + Unused << Manager()->AsContentParent()->SendEndDragSession(true, true); } return true; } diff --git a/dom/ipc/nsIContentParent.cpp b/dom/ipc/nsIContentParent.cpp index 83d9f2ef5c..78ec33c09c 100644 --- a/dom/ipc/nsIContentParent.cpp +++ b/dom/ipc/nsIContentParent.cpp @@ -122,9 +122,9 @@ nsIContentParent::AllocPBrowserParent(const TabId& aTabId, const bool& aIsForApp, const bool& aIsForBrowser) { - unused << aCpId; - unused << aIsForApp; - unused << aIsForBrowser; + Unused << aCpId; + Unused << aIsForApp; + Unused << aIsForBrowser; if (!CanOpenBrowser(aContext)) { return nullptr; diff --git a/dom/locales/en-US/chrome/dom/dom.properties b/dom/locales/en-US/chrome/dom/dom.properties index a655e29ada..51c4e1f708 100644 --- a/dom/locales/en-US/chrome/dom/dom.properties +++ b/dom/locales/en-US/chrome/dom/dom.properties @@ -109,6 +109,8 @@ MediaLoadSourceMediaNotMatched=Specified "media" attribute of "%1$S" does not ma MediaLoadUnsupportedMimeType=HTTP "Content-Type" of "%1$S" is not supported. Load of media resource %2$S failed. # LOCALIZATION NOTE: %S is the URL of the media resource which failed to load because of error in decoding. MediaLoadDecodeError=Media resource %S could not be decoded. +# LOCALIZATION NOTE: %S is the ID of the MediaStreamTrack passed to MediaStream.addTrack(). Do not translate "MediaStreamTrack" and "AudioChannel". +MediaStreamAddTrackDifferentAudioChannel=MediaStreamTrack %S could not be added since it belongs to a different AudioChannel. # LOCALIZATION NOTE: Do not translate "MediaStream", "stop()" and "MediaStreamTrack" MediaStreamStopDeprecatedWarning=MediaStream.stop() is deprecated and will soon be removed. Use MediaStreamTrack.stop() instead. # LOCALIZATION NOTE: Do not translate "DOMException", "code" and "name" diff --git a/dom/media/AbstractMediaDecoder.h b/dom/media/AbstractMediaDecoder.h index 082273ac1e..3f61aa2c47 100644 --- a/dom/media/AbstractMediaDecoder.h +++ b/dom/media/AbstractMediaDecoder.h @@ -108,7 +108,7 @@ public: // Called by the reader's MediaResource as data arrives over the network. // Must be called on the main thread. - virtual void NotifyDataArrived(bool aThrottleUpdates) = 0; + virtual void NotifyDataArrived() = 0; // Set by Reader if the current audio track can be offloaded virtual void SetPlatformCanOffloadAudio(bool aCanOffloadAudio) {} diff --git a/dom/media/DOMMediaStream.cpp b/dom/media/DOMMediaStream.cpp index 6afcaa62d6..08a700927c 100644 --- a/dom/media/DOMMediaStream.cpp +++ b/dom/media/DOMMediaStream.cpp @@ -36,100 +36,66 @@ using namespace mozilla::layers; const TrackID TRACK_VIDEO_PRIMARY = 1; -/** - * TrackPort is a representation of a MediaStreamTrack-MediaInputPort pair - * that make up a link between the Owned stream and the Playback stream. - * - * Semantically, the track is the identifier/key and the port the value of this - * connection. - * - * The input port can be shared between several TrackPorts. This is the case - * for DOMMediaStream's mPlaybackPort which forwards all tracks in its - * mOwnedStream automatically. - * - * If the MediaStreamTrack is owned by another DOMMediaStream (called A) than - * the one owning the TrackPort (called B), the input port (locked to the - * MediaStreamTrack's TrackID) connects A's mOwnedStream to B's mPlaybackStream. - * - * A TrackPort may never leave the DOMMediaStream it was created in. Internal - * use only. - */ -class DOMMediaStream::TrackPort + +DOMMediaStream::TrackPort::TrackPort(MediaInputPort* aInputPort, + MediaStreamTrack* aTrack, + const InputPortOwnership aOwnership) + : mInputPort(aInputPort) + , mTrack(aTrack) + , mOwnership(aOwnership) { -public: - NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(TrackPort) - NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(TrackPort) + // XXX Bug 1124630. nsDOMCameraControl requires adding a track without and + // input port. + // MOZ_ASSERT(mInputPort); + MOZ_ASSERT(mTrack); - enum class InputPortOwnership { - OWNED = 1, - EXTERNAL - }; + MOZ_COUNT_CTOR(TrackPort); +} - TrackPort(MediaInputPort* aInputPort, - MediaStreamTrack* aTrack, - const InputPortOwnership aOwnership) - : mInputPort(aInputPort) - , mTrack(aTrack) - , mOwnership(aOwnership) - { - MOZ_ASSERT(mInputPort); - MOZ_ASSERT(mTrack); +DOMMediaStream::TrackPort::~TrackPort() +{ + MOZ_COUNT_DTOR(TrackPort); - MOZ_COUNT_CTOR(TrackPort); + if (mOwnership == InputPortOwnership::OWNED && mInputPort) { + mInputPort->Destroy(); + mInputPort = nullptr; } +} -protected: - virtual ~TrackPort() - { - MOZ_COUNT_DTOR(TrackPort); - - if (mOwnership == InputPortOwnership::OWNED && mInputPort) { - mInputPort->Destroy(); - mInputPort = nullptr; - } +void +DOMMediaStream::TrackPort::DestroyInputPort() +{ + if (mInputPort) { + mInputPort->Destroy(); + mInputPort = nullptr; } +} -public: - /** - * Returns the source stream of the input port. - */ - MediaStream* GetSource() const { return mInputPort ? mInputPort->GetSource() - : nullptr; } +MediaStream* +DOMMediaStream::TrackPort::GetSource() const +{ + return mInputPort ? mInputPort->GetSource() : nullptr; +} - /** - * Returns the track ID this track is locked to in the source stream of the - * input port. - */ - TrackID GetSourceTrackId() const { return mInputPort ? mInputPort->GetSourceTrackId() - : TRACK_INVALID; } +TrackID +DOMMediaStream::TrackPort::GetSourceTrackId() const +{ + return mInputPort ? mInputPort->GetSourceTrackId() : TRACK_INVALID; +} - MediaInputPort* GetInputPort() const { return mInputPort; } - MediaStreamTrack* GetTrack() const { return mTrack; } - - /** - * Blocks aTrackId from going into mInputPort unless the port has been - * destroyed. - */ - void BlockTrackId(TrackID aTrackId) - { - if (mInputPort) { - mInputPort->BlockTrackId(aTrackId); - } +void +DOMMediaStream::TrackPort::BlockTrackId(TrackID aTrackId) +{ + if (mInputPort) { + mInputPort->BlockTrackId(aTrackId); } - -private: - RefPtr mInputPort; - RefPtr mTrack; - - // Defines if we've been given ownership of the input port or if it's owned - // externally. The owner is responsible for destroying the port. - const InputPortOwnership mOwnership; -}; +} NS_IMPL_CYCLE_COLLECTION(DOMMediaStream::TrackPort, mTrack) NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(DOMMediaStream::TrackPort, AddRef) NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(DOMMediaStream::TrackPort, Release) + /** * Listener registered on the Owned stream to detect added and ended owned * tracks for keeping the list of MediaStreamTracks in sync with the tracks @@ -238,12 +204,26 @@ public: RefPtr track = mStream->FindPlaybackDOMTrack(aInputStream, aInputTrackID); - if (track) { - LOG(LogLevel::Debug, ("DOMMediaStream %p Playback track; notifying stream listeners.", - mStream)); - mStream->NotifyTrackRemoved(track); - } else { + if (!track) { LOG(LogLevel::Debug, ("DOMMediaStream %p Not a playback track.", mStream)); + return; + } + + LOG(LogLevel::Debug, ("DOMMediaStream %p Playback track; notifying stream listeners.", + mStream)); + mStream->NotifyTrackRemoved(track); + + RefPtr endedPort = mStream->FindPlaybackTrackPort(*track); + NS_ASSERTION(endedPort, "Playback track should have a TrackPort"); + if (endedPort && + endedPort->GetSourceTrackId() != TRACK_ANY && + endedPort->GetSourceTrackId() != TRACK_INVALID && + endedPort->GetSourceTrackId() != TRACK_NONE) { + // If a track connected to a locked-track input port ends, we destroy the + // port to allow our playback stream to finish. + // XXX (bug 1208316) This should not be necessary when MediaStreams don't + // finish but instead become inactive. + endedPort->DestroyInputPort(); } } @@ -399,6 +379,72 @@ DOMMediaStream::WrapObject(JSContext* aCx, JS::Handle aGivenProto) return dom::MediaStreamBinding::Wrap(aCx, this, aGivenProto); } +/* static */ already_AddRefed +DOMMediaStream::Constructor(const GlobalObject& aGlobal, + ErrorResult& aRv) +{ + Sequence> emptyTrackSeq; + return Constructor(aGlobal, emptyTrackSeq, aRv); +} + +/* static */ already_AddRefed +DOMMediaStream::Constructor(const GlobalObject& aGlobal, + const DOMMediaStream& aStream, + ErrorResult& aRv) +{ + nsTArray> tracks; + aStream.GetTracks(tracks); + + Sequence> nonNullTrackSeq; + if (!nonNullTrackSeq.SetLength(tracks.Length(), fallible)) { + MOZ_ASSERT(false); + aRv.Throw(NS_ERROR_OUT_OF_MEMORY); + return nullptr; + } + + for (size_t i = 0; i < tracks.Length(); ++i) { + nonNullTrackSeq[i] = tracks[i]; + } + + return Constructor(aGlobal, nonNullTrackSeq, aRv); +} + +/* static */ already_AddRefed +DOMMediaStream::Constructor(const GlobalObject& aGlobal, + const Sequence>& aTracks, + ErrorResult& aRv) +{ + nsCOMPtr ownerWindow = do_QueryInterface(aGlobal.GetAsSupports()); + if (!ownerWindow) { + aRv.Throw(NS_ERROR_FAILURE); + return nullptr; + } + + RefPtr newStream = new DOMMediaStream(); + newStream->mWindow = ownerWindow; + + for (MediaStreamTrack& track : aTracks) { + if (!newStream->GetPlaybackStream()) { + MOZ_RELEASE_ASSERT(track.GetStream()); + MOZ_RELEASE_ASSERT(track.GetStream()->GetPlaybackStream()); + MOZ_RELEASE_ASSERT(track.GetStream()->GetPlaybackStream()->Graph()); + MediaStreamGraph* graph = track.GetStream()->GetPlaybackStream()->Graph(); + newStream->InitPlaybackStreamCommon(graph); + } + newStream->AddTrack(track); + } + + if (!newStream->GetPlaybackStream()) { + MOZ_ASSERT(aTracks.IsEmpty()); + MediaStreamGraph* graph = + MediaStreamGraph::GetInstance(MediaStreamGraph::SYSTEM_THREAD_DRIVER, + AudioChannel::Normal); + newStream->InitPlaybackStreamCommon(graph); + } + + return newStream.forget(); +} + double DOMMediaStream::CurrentTime() { @@ -416,7 +462,7 @@ DOMMediaStream::GetId(nsAString& aID) const } void -DOMMediaStream::GetAudioTracks(nsTArray >& aTracks) +DOMMediaStream::GetAudioTracks(nsTArray >& aTracks) const { for (const RefPtr& info : mTracks) { AudioStreamTrack* t = info->GetTrack()->AsAudioStreamTrack(); @@ -427,7 +473,7 @@ DOMMediaStream::GetAudioTracks(nsTArray >& aTracks) } void -DOMMediaStream::GetVideoTracks(nsTArray >& aTracks) +DOMMediaStream::GetVideoTracks(nsTArray >& aTracks) const { for (const RefPtr& info : mTracks) { VideoStreamTrack* t = info->GetTrack()->AsVideoStreamTrack(); @@ -438,7 +484,7 @@ DOMMediaStream::GetVideoTracks(nsTArray >& aTracks) } void -DOMMediaStream::GetTracks(nsTArray >& aTracks) +DOMMediaStream::GetTracks(nsTArray >& aTracks) const { for (const RefPtr& info : mTracks) { aTracks.AppendElement(info->GetTrack()); @@ -448,6 +494,8 @@ DOMMediaStream::GetTracks(nsTArray >& aTracks) void DOMMediaStream::AddTrack(MediaStreamTrack& aTrack) { + MOZ_RELEASE_ASSERT(mPlaybackStream); + RefPtr dest = mPlaybackStream->AsProcessedStream(); MOZ_ASSERT(dest); if (!dest) { @@ -457,6 +505,27 @@ DOMMediaStream::AddTrack(MediaStreamTrack& aTrack) LOG(LogLevel::Info, ("DOMMediaStream %p Adding track %p (from stream %p with ID %d)", this, &aTrack, aTrack.GetStream(), aTrack.GetTrackID())); + if (mPlaybackStream->Graph() != + aTrack.GetStream()->mPlaybackStream->Graph()) { + NS_ASSERTION(false, "Cannot combine tracks from different MediaStreamGraphs"); + LOG(LogLevel::Error, ("DOMMediaStream %p Own MSG %p != aTrack's MSG %p", + this, mPlaybackStream->Graph(), + aTrack.GetStream()->mPlaybackStream->Graph())); + + nsAutoString trackId; + aTrack.GetId(trackId); + const char16_t* params[] = { trackId.get() }; + nsCOMPtr pWindow = do_QueryInterface(GetParentObject()); + nsIDocument* document = pWindow ? pWindow->GetExtantDoc() : nullptr; + nsContentUtils::ReportToConsole(nsIScriptError::errorFlag, + NS_LITERAL_CSTRING("Media"), + document, + nsContentUtils::eDOM_PROPERTIES, + "MediaStreamAddTrackDifferentAudioChannel", + params, ArrayLength(params)); + return; + } + if (HasTrack(aTrack)) { LOG(LogLevel::Debug, ("DOMMediaStream %p already contains track %p", this, &aTrack)); return; @@ -527,7 +596,9 @@ DOMMediaStream::InitSourceStream(nsIDOMWindow* aWindow, MediaStreamGraph* aGraph) { mWindow = aWindow; - InitStreamCommon(aGraph->CreateSourceStream(nullptr), aGraph); + InitInputStreamCommon(aGraph->CreateSourceStream(nullptr), aGraph); + InitOwnedStreamCommon(aGraph); + InitPlaybackStreamCommon(aGraph); } void @@ -535,7 +606,9 @@ DOMMediaStream::InitTrackUnionStream(nsIDOMWindow* aWindow, MediaStreamGraph* aGraph) { mWindow = aWindow; - InitStreamCommon(aGraph->CreateTrackUnionStream(nullptr), aGraph); + InitInputStreamCommon(aGraph->CreateTrackUnionStream(nullptr), aGraph); + InitOwnedStreamCommon(aGraph); + InitPlaybackStreamCommon(aGraph); } void @@ -546,34 +619,53 @@ DOMMediaStream::InitAudioCaptureStream(nsIDOMWindow* aWindow, const TrackID AUDIO_TRACK = 1; - InitStreamCommon(aGraph->CreateAudioCaptureStream(this, AUDIO_TRACK), aGraph); + InitInputStreamCommon(aGraph->CreateAudioCaptureStream(this, AUDIO_TRACK), aGraph); + InitOwnedStreamCommon(aGraph); + InitPlaybackStreamCommon(aGraph); CreateOwnDOMTrack(AUDIO_TRACK, MediaSegment::AUDIO); } void -DOMMediaStream::InitStreamCommon(MediaStream* aStream, - MediaStreamGraph* aGraph) +DOMMediaStream::InitInputStreamCommon(MediaStream* aStream, + MediaStreamGraph* aGraph) { + MOZ_ASSERT(!mOwnedStream, "Input stream must be initialized before owned stream"); + mInputStream = aStream; +} + +void +DOMMediaStream::InitOwnedStreamCommon(MediaStreamGraph* aGraph) +{ + MOZ_ASSERT(!mPlaybackStream, "Owned stream must be initialized before playback stream"); // We pass null as the wrapper since it is only used to signal finished // streams. This is only needed for the playback stream. mOwnedStream = aGraph->CreateTrackUnionStream(nullptr); mOwnedStream->SetAutofinish(true); - mOwnedPort = mOwnedStream->AllocateInputPort(mInputStream); - - mPlaybackStream = aGraph->CreateTrackUnionStream(this); - mPlaybackStream->SetAutofinish(true); - mPlaybackPort = mPlaybackStream->AllocateInputPort(mOwnedStream); - - LOG(LogLevel::Debug, ("DOMMediaStream %p Initiated with mInputStream=%p, mOwnedStream=%p, mPlaybackStream=%p", - this, mInputStream, mOwnedStream, mPlaybackStream)); + if (mInputStream) { + mOwnedPort = mOwnedStream->AllocateInputPort(mInputStream); + } // Setup track listeners mOwnedListener = new OwnedStreamListener(this); mOwnedStream->AddListener(mOwnedListener); +} + +void +DOMMediaStream::InitPlaybackStreamCommon(MediaStreamGraph* aGraph) +{ + mPlaybackStream = aGraph->CreateTrackUnionStream(this); + mPlaybackStream->SetAutofinish(true); + if (mOwnedStream) { + mPlaybackPort = mPlaybackStream->AllocateInputPort(mOwnedStream); + } + mPlaybackListener = new PlaybackStreamListener(this); mPlaybackStream->AddListener(mPlaybackListener); + + LOG(LogLevel::Debug, ("DOMMediaStream %p Initiated with mInputStream=%p, mOwnedStream=%p, mPlaybackStream=%p", + this, mInputStream, mOwnedStream, mPlaybackStream)); } already_AddRefed @@ -606,8 +698,9 @@ DOMMediaStream::CreateAudioCaptureStream(nsIDOMWindow* aWindow, void DOMMediaStream::SetTrackEnabled(TrackID aTrackID, bool aEnabled) { - if (mOwnedStream) { - mOwnedStream->SetTrackEnabled(aTrackID, aEnabled); + // XXX Bug 1208371 - This enables/disables the track across clones. + if (mInputStream) { + mInputStream->SetTrackEnabled(aTrackID, aEnabled); } } @@ -683,6 +776,9 @@ DOMMediaStream::RemovePrincipalChangeObserver(PrincipalChangeObserver* aObserver MediaStreamTrack* DOMMediaStream::CreateOwnDOMTrack(TrackID aTrackID, MediaSegment::Type aType) { + MOZ_RELEASE_ASSERT(mInputStream); + MOZ_RELEASE_ASSERT(mOwnedStream); + MOZ_ASSERT(FindOwnedDOMTrack(GetOwnedStream(), aTrackID) == nullptr); MediaStreamTrack* track; @@ -714,6 +810,8 @@ DOMMediaStream::CreateOwnDOMTrack(TrackID aTrackID, MediaSegment::Type aType) MediaStreamTrack* DOMMediaStream::FindOwnedDOMTrack(MediaStream* aOwningStream, TrackID aTrackID) const { + MOZ_RELEASE_ASSERT(mOwnedStream); + if (aOwningStream != mOwnedStream) { return nullptr; } @@ -729,6 +827,8 @@ DOMMediaStream::FindOwnedDOMTrack(MediaStream* aOwningStream, TrackID aTrackID) MediaStreamTrack* DOMMediaStream::FindPlaybackDOMTrack(MediaStream* aInputStream, TrackID aInputTrackID) const { + MOZ_RELEASE_ASSERT(mPlaybackStream); + for (const RefPtr& info : mTracks) { if (info->GetInputPort() == mPlaybackPort && aInputStream == mOwnedStream && @@ -736,7 +836,8 @@ DOMMediaStream::FindPlaybackDOMTrack(MediaStream* aInputStream, TrackID aInputTr // This track is in our owned and playback streams. return info->GetTrack(); } - if (info->GetInputPort()->GetSource() == aInputStream && + if (info->GetInputPort() && + info->GetInputPort()->GetSource() == aInputStream && info->GetSourceTrackId() == aInputTrackID) { // This track is owned externally but in our playback stream. MOZ_ASSERT(aInputTrackID != TRACK_NONE); diff --git a/dom/media/DOMMediaStream.h b/dom/media/DOMMediaStream.h index 020a0a73b0..ba23fb0a7c 100644 --- a/dom/media/DOMMediaStream.h +++ b/dom/media/DOMMediaStream.h @@ -173,7 +173,6 @@ class MediaStreamDirectListener; */ class DOMMediaStream : public DOMEventTargetHelper { - class TrackPort; friend class DOMLocalMediaStream; typedef dom::MediaStreamTrack MediaStreamTrack; typedef dom::AudioStreamTrack AudioStreamTrack; @@ -208,7 +207,83 @@ public: virtual ~TrackListener() {} }; - DOMMediaStream(); + /** + * TrackPort is a representation of a MediaStreamTrack-MediaInputPort pair + * that make up a link between the Owned stream and the Playback stream. + * + * Semantically, the track is the identifier/key and the port the value of this + * connection. + * + * The input port can be shared between several TrackPorts. This is the case + * for DOMMediaStream's mPlaybackPort which forwards all tracks in its + * mOwnedStream automatically. + * + * If the MediaStreamTrack is owned by another DOMMediaStream (called A) than + * the one owning the TrackPort (called B), the input port (locked to the + * MediaStreamTrack's TrackID) connects A's mOwnedStream to B's mPlaybackStream. + * + * A TrackPort may never leave the DOMMediaStream it was created in. Internal + * use only. + */ + class TrackPort + { + public: + NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(TrackPort) + NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(TrackPort) + + /** + * Indicates MediaInputPort ownership to the TrackPort. + * + * OWNED - Owned by the TrackPort itself. TrackPort must destroy the + * input port when it's destructed. + * EXTERNAL - Owned by another entity. It's the caller's responsibility to + * ensure the the MediaInputPort outlives the TrackPort. + */ + enum class InputPortOwnership { + OWNED = 1, + EXTERNAL + }; + + TrackPort(MediaInputPort* aInputPort, + MediaStreamTrack* aTrack, + const InputPortOwnership aOwnership); + + protected: + virtual ~TrackPort(); + + public: + void DestroyInputPort(); + + /** + * Returns the source stream of the input port. + */ + MediaStream* GetSource() const; + + /** + * Returns the track ID this track is locked to in the source stream of the + * input port. + */ + TrackID GetSourceTrackId() const; + + MediaInputPort* GetInputPort() const { return mInputPort; } + MediaStreamTrack* GetTrack() const { return mTrack; } + + /** + * Blocks aTrackId from going into mInputPort unless the port has been + * destroyed. + */ + void BlockTrackId(TrackID aTrackId); + + private: + RefPtr mInputPort; + RefPtr mTrack; + + // Defines if we've been given ownership of the input port or if it's owned + // externally. The owner is responsible for destroying the port. + const InputPortOwnership mOwnership; + }; + + DOMMediaStream(); NS_DECL_ISUPPORTS_INHERITED NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper) @@ -223,13 +298,28 @@ public: virtual JSObject* WrapObject(JSContext* aCx, JS::Handle aGivenProto) override; // WebIDL + + static already_AddRefed + Constructor(const dom::GlobalObject& aGlobal, + ErrorResult& aRv); + + static already_AddRefed + Constructor(const dom::GlobalObject& aGlobal, + const DOMMediaStream& aStream, + ErrorResult& aRv); + + static already_AddRefed + Constructor(const dom::GlobalObject& aGlobal, + const dom::Sequence>& aTracks, + ErrorResult& aRv); + double CurrentTime(); void GetId(nsAString& aID) const; - void GetAudioTracks(nsTArray >& aTracks); - void GetVideoTracks(nsTArray >& aTracks); - void GetTracks(nsTArray >& aTracks); + void GetAudioTracks(nsTArray >& aTracks) const; + void GetVideoTracks(nsTArray >& aTracks) const; + void GetTracks(nsTArray >& aTracks) const; void AddTrack(MediaStreamTrack& aTrack); void RemoveTrack(MediaStreamTrack& aTrack); @@ -357,20 +447,20 @@ public: void AssignId(const nsAString& aID) { mID = aID; } /** - * Create an nsDOMMediaStream whose underlying stream is a SourceMediaStream. + * Create a DOMMediaStream whose underlying input stream is a SourceMediaStream. */ static already_AddRefed CreateSourceStream(nsIDOMWindow* aWindow, MediaStreamGraph* aGraph); /** - * Create an nsDOMMediaStream whose underlying stream is a TrackUnionStream. + * Create a DOMMediaStream whose underlying input stream is a TrackUnionStream. */ static already_AddRefed CreateTrackUnionStream(nsIDOMWindow* aWindow, MediaStreamGraph* aGraph); /** - * Create an nsDOMMediaStream whose underlying stream is an - * AudioCaptureStream + * Create an DOMMediaStream whose underlying input stream is an + * AudioCaptureStream. */ static already_AddRefed CreateAudioCaptureStream( nsIDOMWindow* aWindow, MediaStreamGraph* aGraph); @@ -393,15 +483,14 @@ public: virtual ~OnTracksAvailableCallback() {} virtual void NotifyTracksAvailable(DOMMediaStream* aStream) = 0; }; - // When one track of the appropriate type has been added for each bit set - // in aCallback->GetExpectedTracks(), run aCallback->NotifyTracksAvailable. + // When the initial set of tracks has been added, run + // aCallback->NotifyTracksAvailable. // It is allowed to do anything, including run script. // aCallback may run immediately during this call if tracks are already // available! // We only care about track additions, we'll fire the notification even if // some of the tracks have been removed. // Takes ownership of aCallback. - // If GetExpectedTracks() returns 0, the callback will be fired as soon as there are any tracks. void OnTracksAvailable(OnTracksAvailableCallback* aCallback); /** @@ -425,7 +514,23 @@ protected: void InitSourceStream(nsIDOMWindow* aWindow, MediaStreamGraph* aGraph); void InitTrackUnionStream(nsIDOMWindow* aWindow, MediaStreamGraph* aGraph); void InitAudioCaptureStream(nsIDOMWindow* aWindow, MediaStreamGraph* aGraph); - void InitStreamCommon(MediaStream* aStream, MediaStreamGraph* aGraph); + + // Sets up aStream as mInputStream. A producer may append data to a + // SourceMediaStream input stream, or connect another stream to a + // TrackUnionStream input stream. + void InitInputStreamCommon(MediaStream* aStream, MediaStreamGraph* aGraph); + + // Sets up a new TrackUnionStream as mOwnedStream and connects it to + // mInputStream with a TRACK_ANY MediaInputPort if available. + // If this DOMMediaStream should have an input stream (producing data), + // it has to be initiated before the owned stream. + void InitOwnedStreamCommon(MediaStreamGraph* aGraph); + + // Sets up a new TrackUnionStream as mPlaybackStream and connects it to + // mOwnedStream with a TRACK_ANY MediaInputPort if available. + // If this DOMMediaStream should have an owned stream (producer or clone), + // it has to be initiated before the playback stream. + void InitPlaybackStreamCommon(MediaStreamGraph* aGraph); void CheckTracksAvailable(); diff --git a/dom/media/DecoderTraits.cpp b/dom/media/DecoderTraits.cpp index b11b1217d4..d4a415de78 100644 --- a/dom/media/DecoderTraits.cpp +++ b/dom/media/DecoderTraits.cpp @@ -10,10 +10,6 @@ #include "nsMimeTypes.h" #include "mozilla/Preferences.h" -#ifdef MOZ_ANDROID_OMX -#include "AndroidMediaPluginHost.h" -#endif - #include "OggDecoder.h" #include "OggReader.h" #ifdef MOZ_WAVE @@ -33,8 +29,11 @@ #include "ADTSDecoder.h" #include "ADTSDemuxer.h" +#ifdef MOZ_GSTREAMER +#include "GStreamerDecoder.h" +#include "GStreamerReader.h" +#endif #ifdef MOZ_ANDROID_OMX -#include "AndroidMediaPluginHost.h" #include "AndroidMediaDecoder.h" #include "AndroidMediaReader.h" #include "AndroidMediaPluginHost.h" @@ -189,7 +188,7 @@ static char const *const gWebMCodecs[7] = { #endif /* static */ bool -DecoderTraits::IsWebMType(const nsACString& aType) +DecoderTraits::IsWebMTypeAndEnabled(const nsACString& aType) { #ifdef MOZ_WEBM if (!MediaDecoder::IsWebMEnabled()) { @@ -201,13 +200,32 @@ DecoderTraits::IsWebMType(const nsACString& aType) return false; } +#ifdef MOZ_GSTREAMER +static bool +IsGStreamerSupportedType(const nsACString& aMimeType) +{ + if (DecoderTraits::IsWebMTypeAndEnabled(aMimeType)) + return false; + + if (!MediaDecoder::IsGStreamerEnabled()) + return false; + + if (IsOggType(aMimeType) && !Preferences::GetBool("media.prefer-gstreamer", false)) + return false; + + return GStreamerDecoder::CanHandleMediaType(aMimeType, nullptr); +} +#endif + #ifdef MOZ_OMX_DECODER static const char* const gOmxTypes[] = { "audio/mpeg", "audio/mp4", "audio/amr", "audio/3gpp", + "audio/flac", "video/mp4", + "video/x-m4v", "video/3gpp", "video/3gpp2", "video/quicktime", @@ -266,10 +284,16 @@ static char const *const gMpegAudioCodecs[2] = { }; #ifdef MOZ_OMX_WEBM_DECODER -static char const *const gOMXWebMCodecs[4] = { +static char const *const gOMXWebMCodecs[] = { "vorbis", "vp8", "vp8.0", + // Since Android KK, VP9 SW decoder is supported. + // http://developer.android.com/guide/appendix/media-formats.html +#if ANDROID_VERSION > 18 + "vp9", + "vp9.0", +#endif nullptr }; #endif //MOZ_OMX_WEBM_DECODER @@ -308,7 +332,7 @@ IsAndroidMediaType(const nsACString& aType) } static const char* supportedTypes[] = { - "audio/mpeg", "audio/mp4", "video/mp4", nullptr + "audio/mpeg", "audio/mp4", "video/mp4", "video/x-m4v", nullptr }; return CodecListContains(supportedTypes, aType); } @@ -327,19 +351,12 @@ static bool IsMP4SupportedType(const nsACString& aType, const nsAString& aCodecs = EmptyString()) { -// Currently on B2G, FMP4 is only working for MSE playback. -// For other normal MP4, it still uses current omx decoder. -// Bug 1061034 is a follow-up bug to enable all MP4s with MOZ_FMP4 -#ifdef MOZ_OMX_DECODER - return false; -#else return MP4Decoder::CanHandleMediaType(aType, aCodecs); -#endif } #endif /* static */ bool -DecoderTraits::IsMP4Type(const nsACString& aType) +DecoderTraits::IsMP4TypeAndEnabled(const nsACString& aType) { #ifdef MOZ_FMP4 return IsMP4SupportedType(aType); @@ -351,6 +368,9 @@ static bool IsMP3SupportedType(const nsACString& aType, const nsAString& aCodecs = EmptyString()) { +#ifdef MOZ_OMX_DECODER + return false; +#endif return MP3Decoder::CanHandleMediaType(aType, aCodecs); } @@ -414,7 +434,6 @@ CanPlayStatus DecoderTraits::CanHandleCodecsType(const char* aMIMEType, const nsAString& aRequestedCodecs) { - MOZ_ASSERT(NS_IsMainThread()); char const* const* codecList = nullptr; #ifdef MOZ_RAW if (IsRawType(nsDependentCString(aMIMEType))) { @@ -430,12 +449,12 @@ DecoderTraits::CanHandleCodecsType(const char* aMIMEType, } #endif #if !defined(MOZ_OMX_WEBM_DECODER) - if (IsWebMType(nsDependentCString(aMIMEType))) { + if (IsWebMTypeAndEnabled(nsDependentCString(aMIMEType))) { codecList = gWebMCodecs; } #endif #ifdef MOZ_FMP4 - if (IsMP4Type(nsDependentCString(aMIMEType))) { + if (IsMP4TypeAndEnabled(nsDependentCString(aMIMEType))) { if (IsMP4SupportedType(nsDependentCString(aMIMEType), aRequestedCodecs)) { return CANPLAY_YES; } else { @@ -470,7 +489,7 @@ DecoderTraits::CanHandleCodecsType(const char* aMIMEType, #endif #ifdef MOZ_ANDROID_OMX if (MediaDecoder::IsAndroidMediaEnabled()) { - EnsureAndroidMediaPluginHost()->FindDecoder(nsDependentCString(aMIMEType), &codecList)) + EnsureAndroidMediaPluginHost()->FindDecoder(nsDependentCString(aMIMEType), &codecList); } #endif if (!codecList) { @@ -525,17 +544,23 @@ DecoderTraits::CanHandleMediaType(const char* aMIMEType, return CANPLAY_MAYBE; } #endif - if (IsMP4Type(nsDependentCString(aMIMEType))) { + if (IsMP4TypeAndEnabled(nsDependentCString(aMIMEType))) { return CANPLAY_MAYBE; } #if !defined(MOZ_OMX_WEBM_DECODER) - if (IsWebMType(nsDependentCString(aMIMEType))) { + if (IsWebMTypeAndEnabled(nsDependentCString(aMIMEType))) { return CANPLAY_MAYBE; } #endif if (IsMP3SupportedType(nsDependentCString(aMIMEType))) { return CANPLAY_MAYBE; } +#ifdef MOZ_GSTREAMER + if (GStreamerDecoder::CanHandleMediaType(nsDependentCString(aMIMEType), + aHaveRequestedCodecs ? &aRequestedCodecs : nullptr)) { + return aHaveRequestedCodecs ? CANPLAY_YES : CANPLAY_MAYBE; + } +#endif #ifdef MOZ_OMX_DECODER if (IsOmxSupportedType(nsDependentCString(aMIMEType))) { return CANPLAY_MAYBE; @@ -649,7 +674,7 @@ InstantiateDecoder(const nsACString& aType, MediaDecoderOwner* aOwner) return decoder.forget(); } #endif - if (DecoderTraits::IsWebMType(aType)) { + if (DecoderTraits::IsWebMTypeAndEnabled(aType)) { decoder = new WebMDecoder(aOwner); return decoder.forget(); } @@ -734,7 +759,7 @@ if (IsAACSupportedType(aType)) { decoderReader = new AndroidMediaReader(aDecoder, aType); } else #endif - if (IsWebMType(aType)) { + if (IsWebMTypeAndEnabled(aType)) { decoderReader = Preferences::GetBool("media.format-reader.webm", true) ? static_cast(new MediaFormatReader(aDecoder, new WebMDemuxer(aDecoder->GetResource()))) : new WebMReader(aDecoder); @@ -774,7 +799,7 @@ bool DecoderTraits::IsSupportedInVideoDocument(const nsACString& aType) (IsOmxSupportedType(aType) && !IsB2GSupportOnlyType(aType)) || #endif - IsWebMType(aType) || + IsWebMTypeAndEnabled(aType) || #ifdef MOZ_GSTREAMER IsGStreamerSupportedType(aType) || #endif diff --git a/dom/media/DecoderTraits.h b/dom/media/DecoderTraits.h index 16b7c665d5..a50c79868b 100644 --- a/dom/media/DecoderTraits.h +++ b/dom/media/DecoderTraits.h @@ -38,7 +38,8 @@ public: const nsAString& aRequestedCodecs); // Returns the CanPlayStatus indicating if we can handle this MIME type and - // codecs type natively. + // codecs type natively, excluding any plugins-based reader (such as + // GStreamer) // The MIME type should not include the codecs parameter. // That parameter is passed in aRequestedCodecs. static CanPlayStatus CanHandleCodecsType(const char* aMIMEType, @@ -69,8 +70,8 @@ public: // OnConnected signal. (currently RTSP only) static bool DecoderWaitsForOnConnected(const nsACString& aType); - static bool IsWebMType(const nsACString& aType); - static bool IsMP4Type(const nsACString& aType); + static bool IsWebMTypeAndEnabled(const nsACString& aType); + static bool IsMP4TypeAndEnabled(const nsACString& aType); }; } // namespace mozilla diff --git a/dom/media/MediaDecoder.cpp b/dom/media/MediaDecoder.cpp index 694448bbf4..72e23b10d4 100644 --- a/dom/media/MediaDecoder.cpp +++ b/dom/media/MediaDecoder.cpp @@ -139,8 +139,7 @@ MediaDecoder::NotifyOwnerActivityChanged() { MOZ_ASSERT(NS_IsMainThread()); - if (!mOwner) { - NS_WARNING("MediaDecoder without a decoder owner, can't update dormant"); + if (mShuttingDown) { return; } @@ -168,7 +167,8 @@ MediaDecoder::UpdateDormantState(bool aDormantTimeout, bool aActivity) { MOZ_ASSERT(NS_IsMainThread()); - if (!mDecoderStateMachine || + if (mShuttingDown || + !mDecoderStateMachine || mPlayState == PLAY_STATE_SHUTDOWN || !mOwner->GetVideoFrameContainer() || (mOwner->GetMediaElement() && mOwner->GetMediaElement()->IsBeingDestroyed()) || @@ -254,7 +254,6 @@ MediaDecoder::StartDormantTimer() if (mIsHeuristicDormant || mShuttingDown || - !mOwner || !mOwner->IsHidden() || (mPlayState != PLAY_STATE_PAUSED && !IsEnded())) @@ -469,8 +468,6 @@ MediaDecoder::Shutdown() ChangeState(PLAY_STATE_SHUTDOWN); - mOwner = nullptr; - MediaShutdownManager::Instance().Unregister(this); } @@ -590,12 +587,8 @@ MediaDecoder::Seek(double aTime, SeekTarget::Type aSeekType) CallSeek(target); if (mPlayState == PLAY_STATE_ENDED) { - bool paused = false; - if (mOwner) { - paused = mOwner->GetPaused(); - } PinForSeek(); - ChangeState(paused ? PLAY_STATE_PAUSED : PLAY_STATE_PLAYING); + ChangeState(mOwner->GetPaused() ? PLAY_STATE_PAUSED : PLAY_STATE_PLAYING); } return NS_OK; } @@ -655,14 +648,12 @@ MediaDecoder::MetadataLoaded(nsAutoPtr aInfo, mInfo = aInfo.forget(); ConstructMediaTracks(); - if (mOwner) { - // Make sure the element and the frame (if any) are told about - // our new size. - Invalidate(); - if (aEventVisibility != MediaDecoderEventVisibility::Suppressed) { - mFiredMetadataLoaded = true; - mOwner->MetadataLoaded(mInfo, nsAutoPtr(aTags.forget())); - } + // Make sure the element and the frame (if any) are told about + // our new size. + Invalidate(); + if (aEventVisibility != MediaDecoderEventVisibility::Suppressed) { + mFiredMetadataLoaded = true; + mOwner->MetadataLoaded(mInfo, nsAutoPtr(aTags.forget())); } } @@ -697,11 +688,9 @@ MediaDecoder::FirstFrameLoaded(nsAutoPtr aInfo, mInfo = aInfo.forget(); - if (mOwner) { - Invalidate(); - if (aEventVisibility != MediaDecoderEventVisibility::Suppressed) { - mOwner->FirstFrameLoaded(); - } + Invalidate(); + if (aEventVisibility != MediaDecoderEventVisibility::Suppressed) { + mOwner->FirstFrameLoaded(); } // This can run cache callbacks. @@ -771,10 +760,8 @@ MediaDecoder::ResetConnectionState() if (mShuttingDown) return; - if (mOwner) { - // Notify the media element that connection gets lost. - mOwner->ResetConnectionState(); - } + // Notify the media element that connection gets lost. + mOwner->ResetConnectionState(); // Since we have notified the media element the connection // lost event, the decoder will be reloaded when user tries @@ -789,9 +776,7 @@ MediaDecoder::NetworkError() if (mShuttingDown) return; - if (mOwner) - mOwner->NetworkError(); - + mOwner->NetworkError(); Shutdown(); } @@ -802,9 +787,7 @@ MediaDecoder::DecodeError() if (mShuttingDown) return; - if (mOwner) - mOwner->DecodeError(); - + mOwner->DecodeError(); Shutdown(); } @@ -850,10 +833,7 @@ MediaDecoder::PlaybackEnded() ChangeState(PLAY_STATE_ENDED); InvalidateWithFlags(VideoFrameContainer::INVALIDATE_FORCE); - - if (mOwner) { - mOwner->PlaybackEnded(); - } + mOwner->PlaybackEnded(); // This must be called after |mOwner->PlaybackEnded()| call above, in order // to fire the required durationchange. @@ -922,7 +902,10 @@ void MediaDecoder::NotifySuspendedStatusChanged() { MOZ_ASSERT(NS_IsMainThread()); - if (mResource && mOwner) { + if (mShuttingDown) { + return; + } + if (mResource) { bool suspended = mResource->IsSuspendedByCache(); mOwner->NotifySuspendedByCache(suspended); } @@ -932,10 +915,11 @@ void MediaDecoder::NotifyBytesDownloaded() { MOZ_ASSERT(NS_IsMainThread()); - UpdatePlaybackRate(); - if (mOwner) { - mOwner->DownloadProgressed(); + if (mShuttingDown) { + return; } + UpdatePlaybackRate(); + mOwner->DownloadProgressed(); } void @@ -943,13 +927,15 @@ MediaDecoder::NotifyDownloadEnded(nsresult aStatus) { MOZ_ASSERT(NS_IsMainThread()); + if (mShuttingDown) { + return; + } + DECODER_LOG("NotifyDownloadEnded, status=%x", aStatus); if (aStatus == NS_BINDING_ABORTED) { // Download has been cancelled by user. - if (mOwner) { - mOwner->LoadAborted(); - } + mOwner->LoadAborted(); return; } @@ -969,9 +955,10 @@ void MediaDecoder::NotifyPrincipalChanged() { MOZ_ASSERT(NS_IsMainThread()); - if (mOwner) { - mOwner->NotifyDecoderPrincipalChanged(); + if (mShuttingDown) { + return; } + mOwner->NotifyDecoderPrincipalChanged(); } void @@ -1021,12 +1008,10 @@ MediaDecoder::OnSeekResolved(SeekResolveValue aVal) UpdateLogicalPosition(aVal.mEventVisibility); - if (mOwner) { - if (aVal.mEventVisibility != MediaDecoderEventVisibility::Suppressed) { - mOwner->SeekCompleted(); - if (fireEnded) { - mOwner->PlaybackEnded(); - } + if (aVal.mEventVisibility != MediaDecoderEventVisibility::Suppressed) { + mOwner->SeekCompleted(); + if (fireEnded) { + mOwner->PlaybackEnded(); } } } @@ -1038,10 +1023,8 @@ MediaDecoder::SeekingStarted(MediaDecoderEventVisibility aEventVisibility) if (mShuttingDown) return; - if (mOwner) { - if (aEventVisibility != MediaDecoderEventVisibility::Suppressed) { - mOwner->SeekStarted(); - } + if (aEventVisibility != MediaDecoderEventVisibility::Suppressed) { + mOwner->SeekStarted(); } } @@ -1095,7 +1078,7 @@ MediaDecoder::UpdateLogicalPosition(MediaDecoderEventVisibility aEventVisibility // frame has reflowed and the size updated beforehand. Invalidate(); - if (mOwner && logicalPositionChanged && + if (logicalPositionChanged && aEventVisibility != MediaDecoderEventVisibility::Suppressed) { FireTimeUpdate(); } @@ -1106,6 +1089,10 @@ MediaDecoder::DurationChanged() { MOZ_ASSERT(NS_IsMainThread()); + if (mShuttingDown) { + return; + } + double oldDuration = mDuration; if (IsInfinite()) { mDuration = std::numeric_limits::infinity(); @@ -1126,7 +1113,7 @@ MediaDecoder::DurationChanged() // See https://www.w3.org/Bugs/Public/show_bug.cgi?id=28822 for a discussion // of whether we should fire durationchange on explicit infinity. - if (mOwner && mFiredMetadataLoaded && + if (mFiredMetadataLoaded && (!mozilla::IsInfinite(mDuration) || mExplicitDuration.Ref().isSome())) { mOwner->DispatchAsyncEvent(NS_LITERAL_STRING("durationchange")); } @@ -1252,7 +1239,7 @@ MediaDecoder::SetPlaybackRate(double aPlaybackRate) mPausedForPlaybackRateNull = false; // If the playbackRate is no longer null, restart the playback, iff the // media was playing. - if (mOwner && !mOwner->GetPaused()) { + if (!mOwner->GetPaused()) { Play(); } } @@ -1345,11 +1332,11 @@ void MediaDecoder::AddSizeOfResources(ResourceSizes* aSizes) { } void -MediaDecoder::NotifyDataArrived(bool aThrottleUpdates) { +MediaDecoder::NotifyDataArrived() { MOZ_ASSERT(NS_IsMainThread()); if (mDecoderStateMachine) { - mDecoderStateMachine->DispatchNotifyDataArrived(aThrottleUpdates); + mDecoderStateMachine->DispatchNotifyDataArrived(); } // ReadyState computation depends on MediaDecoder::CanPlayThrough, which @@ -1381,8 +1368,9 @@ void MediaDecoder::FireTimeUpdate() { MOZ_ASSERT(NS_IsMainThread()); - if (!mOwner) + if (mShuttingDown) { return; + } mOwner->FireTimeUpdate(true); } @@ -1578,11 +1566,7 @@ MediaDecoder::ConstructMediaTracks() { MOZ_ASSERT(NS_IsMainThread()); - if (mMediaTracksConstructed) { - return; - } - - if (!mOwner || !mInfo) { + if (mShuttingDown || mMediaTracksConstructed || !mInfo) { return; } @@ -1618,7 +1602,7 @@ MediaDecoder::RemoveMediaTracks() { MOZ_ASSERT(NS_IsMainThread()); - if (!mOwner) { + if (mShuttingDown) { return; } diff --git a/dom/media/MediaDecoder.h b/dom/media/MediaDecoder.h index c51acd05cd..1d48535daf 100644 --- a/dom/media/MediaDecoder.h +++ b/dom/media/MediaDecoder.h @@ -429,7 +429,7 @@ public: // Called as data arrives on the stream and is read into the cache. Called // on the main thread only. - virtual void NotifyDataArrived(bool aThrottleUpdates) override; + virtual void NotifyDataArrived() override; // Called by MediaResource when the principal of the resource has // changed. Called on main thread only. @@ -734,7 +734,8 @@ private: void UpdateReadyState() { - if (mOwner) { + MOZ_ASSERT(NS_IsMainThread()); + if (!mShuttingDown) { mOwner->UpdateReadyState(); } } @@ -854,12 +855,12 @@ protected: // This should only ever be accessed from the main thread. // It is set in Init and cleared in Shutdown when the element goes away. // The decoder does not add a reference the element. - MediaDecoderOwner* mOwner; + MediaDecoderOwner* const mOwner; // Counters related to decode and presentation of frames. FrameStatistics mFrameStats; - RefPtr mVideoFrameContainer; + const RefPtr mVideoFrameContainer; // Data needed to estimate playback data rate. The timeline used for // this estimate is "decode time" (where the "current time" is the diff --git a/dom/media/MediaDecoderReader.cpp b/dom/media/MediaDecoderReader.cpp index 0b47277d2f..66a1e61d68 100644 --- a/dom/media/MediaDecoderReader.cpp +++ b/dom/media/MediaDecoderReader.cpp @@ -68,11 +68,8 @@ MediaDecoderReader::MediaDecoderReader(AbstractMediaDecoder* aDecoder) , mTaskQueue(new TaskQueue(GetMediaThreadPool(MediaThreadType::PLAYBACK), /* aSupportsTailDispatch = */ true)) , mWatchManager(this, mTaskQueue) - , mTimer(new MediaTimer()) , mBuffered(mTaskQueue, TimeIntervals(), "MediaDecoderReader::mBuffered (Canonical)") , mDuration(mTaskQueue, NullableTimeUnit(), "MediaDecoderReader::mDuration (Mirror)") - , mThrottleDuration(TimeDuration::FromMilliseconds(500)) - , mLastThrottledNotify(TimeStamp::Now() - mThrottleDuration) , mIgnoreAudioOutputFormat(false) , mHitAudioDecodeError(false) , mShutdown(false) @@ -183,43 +180,6 @@ MediaDecoderReader::UpdateBuffered() mBuffered = GetBuffered(); } -void -MediaDecoderReader::ThrottledNotifyDataArrived() -{ - MOZ_ASSERT(OnTaskQueue()); - NS_ENSURE_TRUE_VOID(!mShutdown); - - // If it's been long enough since our last update, do it. - if (TimeStamp::Now() - mLastThrottledNotify > mThrottleDuration) { - DoThrottledNotify(); - } else if (!mThrottledNotify.Exists()) { - // Otherwise, schedule an update if one isn't scheduled already. - RefPtr self = this; - mThrottledNotify.Begin( - mTimer->WaitUntil(mLastThrottledNotify + mThrottleDuration, __func__) - ->Then(OwnerThread(), __func__, - [self] () -> void { - self->mThrottledNotify.Complete(); - NS_ENSURE_TRUE_VOID(!self->mShutdown); - self->DoThrottledNotify(); - }, - [self] () -> void { - self->mThrottledNotify.Complete(); - NS_WARNING("throttle callback rejected"); - }) - ); - } -} - -void -MediaDecoderReader::DoThrottledNotify() -{ - MOZ_ASSERT(OnTaskQueue()); - mLastThrottledNotify = TimeStamp::Now(); - mThrottledNotify.DisconnectIfExists(); - NotifyDataArrived(); -} - media::TimeIntervals MediaDecoderReader::GetBuffered() { @@ -399,8 +359,6 @@ MediaDecoderReader::Shutdown() mBaseAudioPromise.RejectIfExists(END_OF_STREAM, __func__); mBaseVideoPromise.RejectIfExists(END_OF_STREAM, __func__); - mThrottledNotify.DisconnectIfExists(); - ReleaseMediaResources(); mDuration.DisconnectIfConnected(); mBuffered.DisconnectAll(); @@ -410,7 +368,6 @@ MediaDecoderReader::Shutdown() RefPtr p; - mTimer = nullptr; mDecoder = nullptr; return mTaskQueue->BeginShutdown(); diff --git a/dom/media/MediaDecoderReader.h b/dom/media/MediaDecoderReader.h index d01b3fe7ec..aef245577e 100644 --- a/dom/media/MediaDecoderReader.h +++ b/dom/media/MediaDecoderReader.h @@ -159,6 +159,14 @@ public: MOZ_CRASH(); } + // By default, the reader return the decoded data. Some readers support + // retuning demuxed data. + virtual bool IsDemuxOnlySupported() const { return false; } + + // Configure the reader to return demuxed or decoded data + // upon calls to Request{Audio,Video}Data. + virtual void SetDemuxOnly(bool /*aDemuxedOnly*/) {} + // The default implementation of AsyncReadMetadata is implemented in terms of // synchronous ReadMetadata() calls. Implementations may also // override AsyncReadMetadata to create a more proper async implementation. @@ -213,18 +221,10 @@ public: virtual size_t SizeOfVideoQueueInFrames(); virtual size_t SizeOfAudioQueueInFrames(); - // In situations where these notifications come from stochastic network - // activity, we can save significant recomputation by throttling the delivery - // of these updates to the reader implementation. We don't want to do this - // throttling when the update comes from MSE code, since that code needs the - // updates to be observable immediately, and is generally less - // trigger-happy with notifications anyway. - void DispatchNotifyDataArrived(bool aThrottleUpdates) + void DispatchNotifyDataArrived() { RefPtr r = NS_NewRunnableMethod( - this, - aThrottleUpdates ? &MediaDecoderReader::ThrottledNotifyDataArrived : - &MediaDecoderReader::NotifyDataArrived); + this, &MediaDecoderReader::NotifyDataArrived); OwnerThread()->Dispatch( r.forget(), AbstractThread::DontAssertDispatchSuccess); @@ -340,9 +340,6 @@ protected: // State-watching manager. WatchManager mWatchManager; - // MediaTimer. - RefPtr mTimer; - // Buffered range. Canonical mBuffered; @@ -352,12 +349,6 @@ protected: // Duration, mirrored from the state machine task queue. Mirror mDuration; - // State for ThrottledNotifyDataArrived. - MozPromiseRequestHolder mThrottledNotify; - const TimeDuration mThrottleDuration; - TimeStamp mLastThrottledNotify; - Maybe> mThrottledInterval; - // Whether we should accept media that we know we can't play // directly, because they have a number of channel higher than // what we support. @@ -406,11 +397,6 @@ private: virtual void NotifyDataArrivedInternal() {} - // Invokes NotifyDataArrived while throttling the calls to occur - // at most every mThrottleDuration ms. - void ThrottledNotifyDataArrived(); - void DoThrottledNotify(); - // Overrides of this function should decodes an unspecified amount of // audio data, enqueuing the audio data in mAudioQueue. Returns true // when there's more audio to decode, false if the audio is finished, diff --git a/dom/media/MediaDecoderStateMachine.h b/dom/media/MediaDecoderStateMachine.h index 61485944d1..abb081aeb6 100644 --- a/dom/media/MediaDecoderStateMachine.h +++ b/dom/media/MediaDecoderStateMachine.h @@ -169,9 +169,9 @@ public: OwnerThread()->Dispatch(runnable.forget()); } - void DispatchNotifyDataArrived(bool aThrottleUpdates) + void DispatchNotifyDataArrived() { - mReader->DispatchNotifyDataArrived(aThrottleUpdates); + mReader->DispatchNotifyDataArrived(); } // Notifies the state machine that should minimize the number of samples @@ -355,6 +355,8 @@ private: // be held. bool IsPlaying() const; + // TODO: Those callback function may receive demuxed-only data. + // Need to figure out a suitable API name for this case. void OnAudioDecoded(MediaData* aAudioSample); void OnVideoDecoded(MediaData* aVideoSample); void OnNotDecoded(MediaData::Type aType, MediaDecoderReader::NotDecodedReason aReason); diff --git a/dom/media/MediaFormatReader.cpp b/dom/media/MediaFormatReader.cpp index 202f315fcb..7b7dac892b 100644 --- a/dom/media/MediaFormatReader.cpp +++ b/dom/media/MediaFormatReader.cpp @@ -77,6 +77,7 @@ MediaFormatReader::MediaFormatReader(AbstractMediaDecoder* aDecoder, , mIsEncrypted(false) , mTrackDemuxersMayBlock(false) , mHardwareAccelerationDisabled(false) + , mDemuxOnly(false) , mVideoFrameContainer(aVideoFrameContainer) { MOZ_ASSERT(aDemuxer); @@ -475,7 +476,7 @@ MediaFormatReader::ShouldSkip(bool aSkipToNextKeyframe, media::TimeUnit aTimeThr RefPtr MediaFormatReader::RequestVideoData(bool aSkipToNextKeyframe, - int64_t aTimeThreshold) + int64_t aTimeThreshold) { MOZ_ASSERT(OnTaskQueue()); MOZ_DIAGNOSTIC_ASSERT(mSeekPromise.IsEmpty(), "No sample requests allowed while seeking"); @@ -503,6 +504,7 @@ MediaFormatReader::RequestVideoData(bool aSkipToNextKeyframe, media::TimeUnit timeThreshold{media::TimeUnit::FromMicroseconds(aTimeThreshold)}; if (ShouldSkip(aSkipToNextKeyframe, timeThreshold)) { + mVideo.mDecodingRequested = false; Flush(TrackInfo::kVideoTrack); RefPtr p = mVideo.mPromise.Ensure(__func__); SkipVideoDemuxToNextKeyFrame(timeThreshold); @@ -510,7 +512,8 @@ MediaFormatReader::RequestVideoData(bool aSkipToNextKeyframe, } RefPtr p = mVideo.mPromise.Ensure(__func__); - ScheduleUpdate(TrackInfo::kVideoTrack); + NotifyDecodingRequested(TrackInfo::kVideoTrack); + return p; } @@ -592,7 +595,7 @@ MediaFormatReader::RequestAudioData() } RefPtr p = mAudio.mPromise.Ensure(__func__); - ScheduleUpdate(TrackType::kAudioTrack); + NotifyDecodingRequested(TrackInfo::kAudioTrack); return p; } @@ -687,6 +690,15 @@ MediaFormatReader::NotifyEndOfStream(TrackType aTrack) ScheduleUpdate(aTrack); } +void +MediaFormatReader::NotifyDecodingRequested(TrackType aTrack) +{ + MOZ_ASSERT(OnTaskQueue()); + auto& decoder = GetDecoderData(aTrack); + decoder.mDecodingRequested = true; + ScheduleUpdate(aTrack); +} + bool MediaFormatReader::NeedInput(DecoderData& aDecoder) { @@ -699,12 +711,12 @@ MediaFormatReader::NeedInput(DecoderData& aDecoder) return !aDecoder.mDraining && !aDecoder.mError && - aDecoder.HasPromise() && + aDecoder.mDecodingRequested && !aDecoder.mDemuxRequest.Exists() && - aDecoder.mOutput.IsEmpty() && + aDecoder.mOutput.Length() <= aDecoder.mDecodeAhead && (aDecoder.mInputExhausted || !aDecoder.mQueuedSamples.IsEmpty() || aDecoder.mTimeThreshold.isSome() || - aDecoder.mNumSamplesInput - aDecoder.mNumSamplesOutput < aDecoder.mDecodeAhead); + aDecoder.mNumSamplesInput - aDecoder.mNumSamplesOutput <= aDecoder.mDecodeAhead); } void @@ -793,8 +805,21 @@ MediaFormatReader::RequestDemuxSamples(TrackType aTrack) } } -void +bool MediaFormatReader::DecodeDemuxedSamples(TrackType aTrack, + MediaRawData* aSample) +{ + MOZ_ASSERT(OnTaskQueue()); + auto& decoder = GetDecoderData(aTrack); + if (NS_FAILED(decoder.mDecoder->Input(aSample))) { + LOG("Unable to pass frame to decoder"); + return false; + } + return true; +} + +void +MediaFormatReader::HandleDemuxedSamples(TrackType aTrack, AbstractMediaDecoder::AutoNotifyDecoded& aA) { MOZ_ASSERT(OnTaskQueue()); @@ -895,12 +920,20 @@ MediaFormatReader::DecodeDemuxedSamples(TrackType aTrack, if (aTrack == TrackInfo::kVideoTrack) { aA.mParsed++; } - if (NS_FAILED(decoder.mDecoder->Input(sample))) { - LOG("Unable to pass frame to decoder"); + + if (mDemuxOnly) { + ReturnOutput(sample, aTrack); + } else if (!DecodeDemuxedSamples(aTrack, sample)) { NotifyError(aTrack); return; } + decoder.mQueuedSamples.RemoveElementAt(0); + if (mDemuxOnly) { + // If demuxed-only case, ReturnOutput will resolve with one demuxed data. + // Then we should stop doing the iteration. + return; + } samplesPending = true; } @@ -1027,16 +1060,23 @@ MediaFormatReader::Update(TrackType aTrack) } if (!NeedInput(decoder)) { - LOGV("No need for additional input"); + LOGV("No need for additional input (pending:%u)", + uint32_t(decoder.mOutput.Length())); return; } needInput = true; + LOGV("Update(%s) ni=%d no=%d ie=%d, in:%llu out:%llu qs=%u pending:%u ahead:%d sid:%u", + TrackTypeToStr(aTrack), needInput, needOutput, decoder.mInputExhausted, + decoder.mNumSamplesInput, decoder.mNumSamplesOutput, + uint32_t(size_t(decoder.mSizeOfQueue)), uint32_t(decoder.mOutput.Length()), + !decoder.HasPromise(), decoder.mLastStreamSourceID); + // Demux samples if we don't have some. RequestDemuxSamples(aTrack); - // Decode all pending demuxed samples. - DecodeDemuxedSamples(aTrack, a); + + HandleDemuxedSamples(aTrack, a); } void @@ -1051,20 +1091,21 @@ MediaFormatReader::ReturnOutput(MediaData* aData, TrackType aTrack) } if (aTrack == TrackInfo::kAudioTrack) { - AudioData* audioData = static_cast(aData); + if (aData->mType != MediaData::RAW_DATA) { + AudioData* audioData = static_cast(aData); - if (audioData->mChannels != mInfo.mAudio.mChannels || - audioData->mRate != mInfo.mAudio.mRate) { - LOG("change of audio format (rate:%d->%d). " - "This is an unsupported configuration", - mInfo.mAudio.mRate, audioData->mRate); - mInfo.mAudio.mRate = audioData->mRate; - mInfo.mAudio.mChannels = audioData->mChannels; + if (audioData->mChannels != mInfo.mAudio.mChannels || + audioData->mRate != mInfo.mAudio.mRate) { + LOG("change of audio format (rate:%d->%d). " + "This is an unsupported configuration", + mInfo.mAudio.mRate, audioData->mRate); + mInfo.mAudio.mRate = audioData->mRate; + mInfo.mAudio.mChannels = audioData->mChannels; + } } - - mAudio.mPromise.Resolve(audioData, __func__); + mAudio.mPromise.Resolve(aData, __func__); } else if (aTrack == TrackInfo::kVideoTrack) { - mVideo.mPromise.Resolve(static_cast(aData), __func__); + mVideo.mPromise.Resolve(aData, __func__); } LOG("Resolved data promise for %s", TrackTypeToStr(aTrack)); } @@ -1211,6 +1252,7 @@ MediaFormatReader::SkipVideoDemuxToNextKeyFrame(media::TimeUnit aTimeThreshold) MOZ_ASSERT(mVideo.mDecoder); MOZ_ASSERT(mVideo.HasPromise()); + MOZ_ASSERT(!mVideo.mDecodingRequested); LOG("Skipping up to %lld", aTimeThreshold.ToMicroseconds()); if (mVideo.mError) { @@ -1236,7 +1278,7 @@ MediaFormatReader::OnVideoSkipCompleted(uint32_t aSkipped) } MOZ_ASSERT(!mVideo.mError); // We have flushed the decoder, no frame could // have been decoded (and as such errored) - ScheduleUpdate(TrackInfo::kVideoTrack); + NotifyDecodingRequested(TrackInfo::kVideoTrack); } void diff --git a/dom/media/MediaFormatReader.h b/dom/media/MediaFormatReader.h index e7b4cf109f..052bd4862e 100644 --- a/dom/media/MediaFormatReader.h +++ b/dom/media/MediaFormatReader.h @@ -78,6 +78,20 @@ public: bool IsWaitingOnCDMResource() override; + // MediaFormatReader supports demuxed-only mode. + bool IsDemuxOnlySupported() const override { return true; } + + void SetDemuxOnly(bool aDemuxedOnly) override + { + if (OnTaskQueue()) { + mDemuxOnly = aDemuxedOnly; + return; + } + nsCOMPtr r = NS_NewRunnableMethodWithArg( + this, &MediaDecoderReader::SetDemuxOnly, aDemuxedOnly); + OwnerThread()->Dispatch(r.forget()); + } + bool UseBufferingHeuristics() override { return mTrackDemuxersMayBlock; @@ -108,9 +122,12 @@ private: bool UpdateReceivedNewData(TrackType aTrack); // Called when new samples need to be demuxed. void RequestDemuxSamples(TrackType aTrack); - // Decode any pending already demuxed samples. - void DecodeDemuxedSamples(TrackType aTrack, + // Handle demuxed samples by the input behavior. + void HandleDemuxedSamples(TrackType aTrack, AbstractMediaDecoder::AutoNotifyDecoded& aA); + // Decode any pending already demuxed samples. + bool DecodeDemuxedSamples(TrackType aTrack, + MediaRawData* aSample); // Drain the current decoder. void DrainDecoder(TrackType aTrack); void NotifyNewOutput(TrackType aTrack, MediaData* aSample); @@ -119,6 +136,7 @@ private: void NotifyError(TrackType aTrack); void NotifyWaitingForData(TrackType aTrack); void NotifyEndOfStream(TrackType aTrack); + void NotifyDecodingRequested(TrackType aTrack); void ExtractCryptoInitData(nsTArray& aInitData); @@ -183,6 +201,7 @@ private: , mReceivedNewData(false) , mDiscontinuity(true) , mDecoderInitialized(false) + , mDecodingRequested(false) , mOutputRequested(false) , mInputExhausted(false) , mError(false) @@ -232,6 +251,7 @@ private: // MediaDataDecoder handler's variables. // False when decoder is created. True when decoder Init() promise is resolved. bool mDecoderInitialized; + bool mDecodingRequested; bool mOutputRequested; bool mInputExhausted; bool mError; @@ -250,6 +270,7 @@ private: // These get overriden in the templated concrete class. // Indicate if we have a pending promise for decoded frame. + // Rejecting the promise will stop the reader from decoding ahead. virtual bool HasPromise() = 0; virtual void RejectPromise(MediaDecoderReader::NotDecodedReason aReason, const char* aMethodName) = 0; @@ -314,6 +335,7 @@ private: { MOZ_ASSERT(mOwner->OnTaskQueue()); mPromise.Reject(aReason, aMethodName); + mDecodingRequested = false; } }; @@ -385,6 +407,9 @@ private: bool mHardwareAccelerationDisabled; + // Set the demuxed-only flag. + Atomic mDemuxOnly; + // Seeking objects. bool IsSeeking() const { return mPendingSeekTime.isSome(); } void AttemptSeek(); diff --git a/dom/media/MediaManager.cpp b/dom/media/MediaManager.cpp index 89be765483..eb6afa22e6 100644 --- a/dom/media/MediaManager.cpp +++ b/dom/media/MediaManager.cpp @@ -1703,7 +1703,7 @@ MediaManager::NotifyRecordingStatusChange(nsPIDOMWindow* aWindow, // Forward recording events to parent process. // The events are gathered in chrome process and used for recording indicator if (!XRE_IsParentProcess()) { - unused << + Unused << dom::ContentChild::GetSingleton()->SendRecordingDeviceEvents(aMsg, requestURL, aIsAudio, diff --git a/dom/media/MediaManager.h b/dom/media/MediaManager.h index 2244643779..0454f7a769 100644 --- a/dom/media/MediaManager.h +++ b/dom/media/MediaManager.h @@ -134,7 +134,7 @@ public: ~GetUserMediaCallbackMediaStreamListener() { - unused << mMediaThread; + Unused << mMediaThread; // It's OK to release mStream on any thread; they have thread-safe // refcounts. } diff --git a/dom/media/MediaResource.cpp b/dom/media/MediaResource.cpp index ff5eca1169..4dda7e935d 100644 --- a/dom/media/MediaResource.cpp +++ b/dom/media/MediaResource.cpp @@ -454,7 +454,7 @@ ChannelMediaResource::CopySegmentToCache(nsIInputStream *aInStream, { CopySegmentClosure* closure = static_cast(aClosure); - closure->mResource->mCallback->NotifyDataArrived(/* aThrottleUpdates = */ true); + closure->mResource->mCallback->NotifyDataArrived(); // Keep track of where we're up to. RESOURCE_LOG("%p [ChannelMediaResource]: CopySegmentToCache at mOffset [%lld] add " diff --git a/dom/media/MediaResourceCallback.h b/dom/media/MediaResourceCallback.h index 4b62e58b8e..f67783c621 100644 --- a/dom/media/MediaResourceCallback.h +++ b/dom/media/MediaResourceCallback.h @@ -50,7 +50,7 @@ public: virtual void NotifyDecodeError() {} // Notify that data arrives on the stream and is read into the cache. - virtual void NotifyDataArrived(bool aThrottleUpdates) {} + virtual void NotifyDataArrived() {} // Notify that MediaResource has received some data. virtual void NotifyBytesDownloaded() {} diff --git a/dom/media/MediaStreamGraph.cpp b/dom/media/MediaStreamGraph.cpp index b57741511b..456bbd9ef2 100644 --- a/dom/media/MediaStreamGraph.cpp +++ b/dom/media/MediaStreamGraph.cpp @@ -2570,7 +2570,7 @@ ProcessedMediaStream::AllocateInputPort(MediaStream* aStream, TrackID aTrackID, mPort->Init(); // The graph holds its reference implicitly mPort->GraphImpl()->SetStreamOrderDirty(); - unused << mPort.forget(); + Unused << mPort.forget(); } virtual void RunDuringShutdown() { diff --git a/dom/media/StreamBuffer.cpp b/dom/media/StreamBuffer.cpp index 3f225c2793..5af63e5b01 100644 --- a/dom/media/StreamBuffer.cpp +++ b/dom/media/StreamBuffer.cpp @@ -77,6 +77,10 @@ StreamBuffer::FindTrack(TrackID aID) } if (mTracks[middle]->GetID() > aID) { + if (middle == 0) { + break; + } + right = middle - 1; } else { left = middle + 1; diff --git a/dom/media/android/AndroidMediaPluginHost.cpp b/dom/media/android/AndroidMediaPluginHost.cpp index 09893ecc64..f42a0e209c 100644 --- a/dom/media/android/AndroidMediaPluginHost.cpp +++ b/dom/media/android/AndroidMediaPluginHost.cpp @@ -10,7 +10,6 @@ #include "AndroidMediaPluginHost.h" #include "nsXPCOMStrings.h" #include "nsISeekableStream.h" -#include "AndroidMediaReader.h" #include "nsIGfxInfo.h" #include "prmem.h" #include "prlink.h" diff --git a/dom/media/fmp4/MP4Demuxer.cpp b/dom/media/fmp4/MP4Demuxer.cpp index 01bc8266d4..d281594181 100644 --- a/dom/media/fmp4/MP4Demuxer.cpp +++ b/dom/media/fmp4/MP4Demuxer.cpp @@ -15,6 +15,11 @@ #include "mp4_demuxer/BufferStream.h" #include "mp4_demuxer/Index.h" +// Used for telemetry +#include "mozilla/Telemetry.h" +#include "mp4_demuxer/AnnexB.h" +#include "mp4_demuxer/H264.h" + PRLogModuleInfo* GetDemuxerLog() { static PRLogModuleInfo* log = nullptr; if (!log) { @@ -66,8 +71,46 @@ private: // Queued samples extracted by the demuxer, but not yet returned. RefPtr mQueuedSample; bool mNeedReIndex; + bool mNeedSPSForTelemetry; }; + +// Returns true if no SPS was found and search for it should continue. +bool +AccumulateSPSTelemetry(const MediaByteBuffer* aExtradata) +{ + mp4_demuxer::SPSData spsdata; + if (mp4_demuxer::H264::DecodeSPSFromExtraData(aExtradata, spsdata)) { + uint8_t constraints = (spsdata.constraint_set0_flag ? (1 << 0) : 0) | + (spsdata.constraint_set1_flag ? (1 << 1) : 0) | + (spsdata.constraint_set2_flag ? (1 << 2) : 0) | + (spsdata.constraint_set3_flag ? (1 << 3) : 0) | + (spsdata.constraint_set4_flag ? (1 << 4) : 0) | + (spsdata.constraint_set5_flag ? (1 << 5) : 0); + Telemetry::Accumulate(Telemetry::VIDEO_DECODED_H264_SPS_CONSTRAINT_SET_FLAG, + constraints); + + // Collect profile_idc values up to 244, otherwise 0 for unknown. + Telemetry::Accumulate(Telemetry::VIDEO_DECODED_H264_SPS_PROFILE, + spsdata.profile_idc <= 244 ? spsdata.profile_idc : 0); + + // Make sure level_idc represents a value between levels 1 and 5.2, + // otherwise collect 0 for unknown level. + Telemetry::Accumulate(Telemetry::VIDEO_DECODED_H264_SPS_LEVEL, + (spsdata.level_idc >= 10 && spsdata.level_idc <= 52) ? + spsdata.level_idc : 0); + + // max_num_ref_frames should be between 0 and 16, anything larger will + // be treated as invalid. + Telemetry::Accumulate(Telemetry::VIDEO_H264_SPS_MAX_NUM_REF_FRAMES, + std::min(spsdata.max_num_ref_frames, 17u)); + + return false; + } + + return true; +} + MP4Demuxer::MP4Demuxer(MediaResource* aResource) : mResource(aResource) , mStream(new mp4_demuxer::ResourceStream(aResource)) @@ -198,6 +241,17 @@ MP4TrackDemuxer::MP4TrackDemuxer(MP4Demuxer* aParent, , mNeedReIndex(true) { EnsureUpToDateIndex(); // Force update of index + + // Collect telemetry from h264 AVCC SPS. + if (mInfo->GetAsVideoInfo() && + (mInfo->mMimeType.EqualsLiteral("video/mp4") || + mInfo->mMimeType.EqualsLiteral("video/avc"))) { + mNeedSPSForTelemetry = + AccumulateSPSTelemetry(mInfo->GetAsVideoInfo()->mExtraData); + } else { + // No SPS to be found. + mNeedSPSForTelemetry = false; + } } UniquePtr @@ -297,6 +351,12 @@ MP4TrackDemuxer::UpdateSamples(nsTArray>& aSamples) { for (size_t i = 0; i < aSamples.Length(); i++) { MediaRawData* sample = aSamples[i]; + // Collect telemetry from h264 Annex B SPS. + if (mNeedSPSForTelemetry && mp4_demuxer::AnnexB::HasSPS(sample)) { + RefPtr extradata = + mp4_demuxer::AnnexB::ExtractExtraData(sample); + mNeedSPSForTelemetry = AccumulateSPSTelemetry(extradata); + } if (sample->mCrypto.mValid) { nsAutoPtr writer(sample->CreateWriter()); writer->mCrypto.mMode = mInfo->mCrypto.mMode; diff --git a/dom/media/gmp/GMPAudioDecoderChild.cpp b/dom/media/gmp/GMPAudioDecoderChild.cpp index 90a2a861a4..2601055291 100644 --- a/dom/media/gmp/GMPAudioDecoderChild.cpp +++ b/dom/media/gmp/GMPAudioDecoderChild.cpp @@ -52,7 +52,7 @@ GMPAudioDecoderChild::Decoded(GMPAudioSamples* aDecodedSamples) samples.mChannelCount() = aDecodedSamples->Channels(); samples.mSamplesPerSecond() = aDecodedSamples->Rate(); - unused << SendDecoded(samples); + Unused << SendDecoded(samples); aDecodedSamples->Destroy(); } @@ -62,7 +62,7 @@ GMPAudioDecoderChild::InputDataExhausted() { MOZ_ASSERT(mPlugin->GMPMessageLoop() == MessageLoop::current()); - unused << SendInputDataExhausted(); + Unused << SendInputDataExhausted(); } void @@ -70,7 +70,7 @@ GMPAudioDecoderChild::DrainComplete() { MOZ_ASSERT(mPlugin->GMPMessageLoop() == MessageLoop::current()); - unused << SendDrainComplete(); + Unused << SendDrainComplete(); } void @@ -78,7 +78,7 @@ GMPAudioDecoderChild::ResetComplete() { MOZ_ASSERT(mPlugin->GMPMessageLoop() == MessageLoop::current()); - unused << SendResetComplete(); + Unused << SendResetComplete(); } void @@ -86,7 +86,7 @@ GMPAudioDecoderChild::Error(GMPErr aError) { MOZ_ASSERT(mPlugin->GMPMessageLoop() == MessageLoop::current()); - unused << SendError(aError); + Unused << SendError(aError); } bool @@ -163,7 +163,7 @@ GMPAudioDecoderChild::RecvDecodingComplete() mPlugin = nullptr; - unused << Send__delete__(this); + Unused << Send__delete__(this); return true; } diff --git a/dom/media/gmp/GMPAudioDecoderParent.cpp b/dom/media/gmp/GMPAudioDecoderParent.cpp index cc6c535d65..b9a8cba8d5 100644 --- a/dom/media/gmp/GMPAudioDecoderParent.cpp +++ b/dom/media/gmp/GMPAudioDecoderParent.cpp @@ -196,7 +196,7 @@ GMPAudioDecoderParent::Shutdown() mIsOpen = false; if (!mActorDestroyed) { - unused << SendDecodingComplete(); + Unused << SendDecodingComplete(); } return NS_OK; diff --git a/dom/media/gmp/GMPContentParent.cpp b/dom/media/gmp/GMPContentParent.cpp index e85f295187..b238445f89 100644 --- a/dom/media/gmp/GMPContentParent.cpp +++ b/dom/media/gmp/GMPContentParent.cpp @@ -95,7 +95,7 @@ GMPContentParent::VideoDecoderDestroyed(GMPVideoDecoderParent* aDecoder) MOZ_ASSERT(GMPThread() == NS_GetCurrentThread()); // If the constructor fails, we'll get called before it's added - unused << NS_WARN_IF(!mVideoDecoders.RemoveElement(aDecoder)); + Unused << NS_WARN_IF(!mVideoDecoders.RemoveElement(aDecoder)); CloseIfUnused(); } @@ -105,7 +105,7 @@ GMPContentParent::VideoEncoderDestroyed(GMPVideoEncoderParent* aEncoder) MOZ_ASSERT(GMPThread() == NS_GetCurrentThread()); // If the constructor fails, we'll get called before it's added - unused << NS_WARN_IF(!mVideoEncoders.RemoveElement(aEncoder)); + Unused << NS_WARN_IF(!mVideoEncoders.RemoveElement(aEncoder)); CloseIfUnused(); } diff --git a/dom/media/gmp/GMPDecryptorChild.cpp b/dom/media/gmp/GMPDecryptorChild.cpp index 0c7e1356ea..590f2fc544 100644 --- a/dom/media/gmp/GMPDecryptorChild.cpp +++ b/dom/media/gmp/GMPDecryptorChild.cpp @@ -360,7 +360,7 @@ GMPDecryptorChild::RecvDecryptingComplete() session->DecryptingComplete(); - unused << Send__delete__(this); + Unused << Send__delete__(this); return true; } diff --git a/dom/media/gmp/GMPDecryptorParent.cpp b/dom/media/gmp/GMPDecryptorParent.cpp index ade26dd7f4..49a2807a1c 100644 --- a/dom/media/gmp/GMPDecryptorParent.cpp +++ b/dom/media/gmp/GMPDecryptorParent.cpp @@ -73,7 +73,7 @@ GMPDecryptorParent::CreateSession(uint32_t aCreateSessionToken, } // Caller should ensure parameters passed in from JS are valid. MOZ_ASSERT(!aInitDataType.IsEmpty() && !aInitData.IsEmpty()); - unused << SendCreateSession(aCreateSessionToken, aPromiseId, aInitDataType, aInitData, aSessionType); + Unused << SendCreateSession(aCreateSessionToken, aPromiseId, aInitDataType, aInitData, aSessionType); } void @@ -88,7 +88,7 @@ GMPDecryptorParent::LoadSession(uint32_t aPromiseId, } // Caller should ensure parameters passed in from JS are valid. MOZ_ASSERT(!aSessionId.IsEmpty()); - unused << SendLoadSession(aPromiseId, aSessionId); + Unused << SendLoadSession(aPromiseId, aSessionId); } void @@ -105,7 +105,7 @@ GMPDecryptorParent::UpdateSession(uint32_t aPromiseId, } // Caller should ensure parameters passed in from JS are valid. MOZ_ASSERT(!aSessionId.IsEmpty() && !aResponse.IsEmpty()); - unused << SendUpdateSession(aPromiseId, aSessionId, aResponse); + Unused << SendUpdateSession(aPromiseId, aSessionId, aResponse); } void @@ -121,7 +121,7 @@ GMPDecryptorParent::CloseSession(uint32_t aPromiseId, } // Caller should ensure parameters passed in from JS are valid. MOZ_ASSERT(!aSessionId.IsEmpty()); - unused << SendCloseSession(aPromiseId, aSessionId); + Unused << SendCloseSession(aPromiseId, aSessionId); } void @@ -137,7 +137,7 @@ GMPDecryptorParent::RemoveSession(uint32_t aPromiseId, } // Caller should ensure parameters passed in from JS are valid. MOZ_ASSERT(!aSessionId.IsEmpty()); - unused << SendRemoveSession(aPromiseId, aSessionId); + Unused << SendRemoveSession(aPromiseId, aSessionId); } void @@ -153,7 +153,7 @@ GMPDecryptorParent::SetServerCertificate(uint32_t aPromiseId, } // Caller should ensure parameters passed in from JS are valid. MOZ_ASSERT(!aServerCert.IsEmpty()); - unused << SendSetServerCertificate(aPromiseId, aServerCert); + Unused << SendSetServerCertificate(aPromiseId, aServerCert); } void @@ -177,7 +177,7 @@ GMPDecryptorParent::Decrypt(uint32_t aId, aCrypto.mEncryptedSizes, aCrypto.mSessionIds); - unused << SendDecrypt(aId, aBuffer, data); + Unused << SendDecrypt(aId, aBuffer, data); } bool @@ -413,7 +413,7 @@ GMPDecryptorParent::Shutdown() mIsOpen = false; if (!mActorDestroyed) { - unused << SendDecryptingComplete(); + Unused << SendDecryptingComplete(); } } diff --git a/dom/media/gmp/GMPParent.cpp b/dom/media/gmp/GMPParent.cpp index 1713a1b7d3..305bd9e830 100644 --- a/dom/media/gmp/GMPParent.cpp +++ b/dom/media/gmp/GMPParent.cpp @@ -120,7 +120,7 @@ void GMPParent::Crash() { if (mState != GMPStateNotLoaded) { - unused << SendCrashPluginNow(); + Unused << SendCrashPluginNow(); } } @@ -229,7 +229,7 @@ GMPParent::EnsureAsyncShutdownTimeoutSet() rv = mAsyncShutdownTimeout->InitWithFuncCallback( &AbortWaitingForGMPAsyncShutdown, this, timeout, nsITimer::TYPE_ONE_SHOT); - unused << NS_WARN_IF(NS_FAILED(rv)); + Unused << NS_WARN_IF(NS_FAILED(rv)); return rv; } diff --git a/dom/media/gmp/GMPStorageParent.cpp b/dom/media/gmp/GMPStorageParent.cpp index c4f04ede08..2ec2210772 100644 --- a/dom/media/gmp/GMPStorageParent.cpp +++ b/dom/media/gmp/GMPStorageParent.cpp @@ -620,21 +620,21 @@ GMPStorageParent::RecvOpen(const nsCString& aRecordName) // or shared across origin. LOGD(("GMPStorageParent[%p]::RecvOpen(record='%s') failed; null nodeId", this, aRecordName.get())); - unused << SendOpenComplete(aRecordName, GMPGenericErr); + Unused << SendOpenComplete(aRecordName, GMPGenericErr); return true; } if (aRecordName.IsEmpty()) { LOGD(("GMPStorageParent[%p]::RecvOpen(record='%s') failed; record name empty", this, aRecordName.get())); - unused << SendOpenComplete(aRecordName, GMPGenericErr); + Unused << SendOpenComplete(aRecordName, GMPGenericErr); return true; } if (mStorage->IsOpen(aRecordName)) { LOGD(("GMPStorageParent[%p]::RecvOpen(record='%s') failed; record in use", this, aRecordName.get())); - unused << SendOpenComplete(aRecordName, GMPRecordInUse); + Unused << SendOpenComplete(aRecordName, GMPRecordInUse); return true; } @@ -642,7 +642,7 @@ GMPStorageParent::RecvOpen(const nsCString& aRecordName) MOZ_ASSERT(GMP_FAILED(err) || mStorage->IsOpen(aRecordName)); LOGD(("GMPStorageParent[%p]::RecvOpen(record='%s') complete; rv=%d", this, aRecordName.get(), err)); - unused << SendOpenComplete(aRecordName, err); + Unused << SendOpenComplete(aRecordName, err); return true; } @@ -661,12 +661,12 @@ GMPStorageParent::RecvRead(const nsCString& aRecordName) if (!mStorage->IsOpen(aRecordName)) { LOGD(("GMPStorageParent[%p]::RecvRead(record='%s') failed; record not open", this, aRecordName.get())); - unused << SendReadComplete(aRecordName, GMPClosedErr, data); + Unused << SendReadComplete(aRecordName, GMPClosedErr, data); } else { GMPErr rv = mStorage->Read(aRecordName, data); LOGD(("GMPStorageParent[%p]::RecvRead(record='%s') read %d bytes rv=%d", this, aRecordName.get(), data.Length(), rv)); - unused << SendReadComplete(aRecordName, rv, data); + Unused << SendReadComplete(aRecordName, rv, data); } return true; @@ -686,14 +686,14 @@ GMPStorageParent::RecvWrite(const nsCString& aRecordName, if (!mStorage->IsOpen(aRecordName)) { LOGD(("GMPStorageParent[%p]::RecvWrite(record='%s') failed record not open", this, aRecordName.get())); - unused << SendWriteComplete(aRecordName, GMPClosedErr); + Unused << SendWriteComplete(aRecordName, GMPClosedErr); return true; } if (aBytes.Length() > GMP_MAX_RECORD_SIZE) { LOGD(("GMPStorageParent[%p]::RecvWrite(record='%s') failed record too big", this, aRecordName.get())); - unused << SendWriteComplete(aRecordName, GMPQuotaExceededErr); + Unused << SendWriteComplete(aRecordName, GMPQuotaExceededErr); return true; } @@ -701,7 +701,7 @@ GMPStorageParent::RecvWrite(const nsCString& aRecordName, LOGD(("GMPStorageParent[%p]::RecvWrite(record='%s') write complete rv=%d", this, aRecordName.get(), rv)); - unused << SendWriteComplete(aRecordName, rv); + Unused << SendWriteComplete(aRecordName, rv); return true; } @@ -719,7 +719,7 @@ GMPStorageParent::RecvGetRecordNames() LOGD(("GMPStorageParent[%p]::RecvGetRecordNames() status=%d numRecords=%d", this, status, recordNames.Length())); - unused << SendRecordNames(recordNames, status); + Unused << SendRecordNames(recordNames, status); return true; } @@ -755,7 +755,7 @@ GMPStorageParent::Shutdown() return; } mShutdown = true; - unused << SendShutdown(); + Unused << SendShutdown(); mStorage = nullptr; diff --git a/dom/media/gmp/GMPTimerParent.cpp b/dom/media/gmp/GMPTimerParent.cpp index 03fe05f20b..8e58490481 100644 --- a/dom/media/gmp/GMPTimerParent.cpp +++ b/dom/media/gmp/GMPTimerParent.cpp @@ -114,7 +114,7 @@ GMPTimerParent::TimerExpired(Context* aContext) uint32_t id = aContext->mId; mTimers.RemoveEntry(aContext); if (id) { - unused << SendTimerExpired(id); + Unused << SendTimerExpired(id); } } diff --git a/dom/media/gmp/GMPVideoDecoderChild.cpp b/dom/media/gmp/GMPVideoDecoderChild.cpp index 912bcbb799..e97cb3f1d8 100644 --- a/dom/media/gmp/GMPVideoDecoderChild.cpp +++ b/dom/media/gmp/GMPVideoDecoderChild.cpp @@ -208,7 +208,7 @@ GMPVideoDecoderChild::RecvDecodingComplete() mPlugin = nullptr; - unused << Send__delete__(this); + Unused << Send__delete__(this); return true; } diff --git a/dom/media/gmp/GMPVideoDecoderParent.cpp b/dom/media/gmp/GMPVideoDecoderParent.cpp index 5f0c89fe91..2b58bb2e6d 100644 --- a/dom/media/gmp/GMPVideoDecoderParent.cpp +++ b/dom/media/gmp/GMPVideoDecoderParent.cpp @@ -243,7 +243,7 @@ GMPVideoDecoderParent::Shutdown() mIsOpen = false; if (!mActorDestroyed) { - unused << SendDecodingComplete(); + Unused << SendDecodingComplete(); } return NS_OK; diff --git a/dom/media/gmp/GMPVideoEncoderChild.cpp b/dom/media/gmp/GMPVideoEncoderChild.cpp index 3ea262264a..54e715f776 100644 --- a/dom/media/gmp/GMPVideoEncoderChild.cpp +++ b/dom/media/gmp/GMPVideoEncoderChild.cpp @@ -178,7 +178,7 @@ GMPVideoEncoderChild::RecvEncodingComplete() } if (!mVideoEncoder) { - unused << Send__delete__(this); + Unused << Send__delete__(this); return false; } @@ -189,7 +189,7 @@ GMPVideoEncoderChild::RecvEncodingComplete() mPlugin = nullptr; - unused << Send__delete__(this); + Unused << Send__delete__(this); return true; } diff --git a/dom/media/gmp/GMPVideoEncoderParent.cpp b/dom/media/gmp/GMPVideoEncoderParent.cpp index f93fbcda87..311ecef99c 100644 --- a/dom/media/gmp/GMPVideoEncoderParent.cpp +++ b/dom/media/gmp/GMPVideoEncoderParent.cpp @@ -233,7 +233,7 @@ GMPVideoEncoderParent::Shutdown() mIsOpen = false; if (!mActorDestroyed) { - unused << SendEncodingComplete(); + Unused << SendEncodingComplete(); } } diff --git a/dom/media/gstreamer/GStreamerFormatHelper.cpp b/dom/media/gstreamer/GStreamerFormatHelper.cpp index 6b1d280057..d7649b806a 100644 --- a/dom/media/gstreamer/GStreamerFormatHelper.cpp +++ b/dom/media/gstreamer/GStreamerFormatHelper.cpp @@ -72,7 +72,7 @@ static char const * const sDefaultCodecCaps[][2] = { {"audio/mpeg", "audio/mpeg, layer=(int)3"} }; -static char const * const sPluginBlacklist[] = { +static char const * const sPluginBlockList[] = { "flump3dec", "h264parse", }; @@ -217,32 +217,32 @@ GstCaps* GStreamerFormatHelper::ConvertFormatsToCaps(const char* aMIMEType, } /* static */ bool -GStreamerFormatHelper::IsBlacklistEnabled() +GStreamerFormatHelper::IsBlockListEnabled() { - static bool sBlacklistEnabled; - static bool sBlacklistEnabledCached = false; + static bool sBlockListEnabled; + static bool sBlockListEnabledCached = false; - if (!sBlacklistEnabledCached) { - Preferences::AddBoolVarCache(&sBlacklistEnabled, + if (!sBlockListEnabledCached) { + Preferences::AddBoolVarCache(&sBlockListEnabled, "media.gstreamer.enable-blacklist", true); - sBlacklistEnabledCached = true; + sBlockListEnabledCached = true; } - return sBlacklistEnabled; + return sBlockListEnabled; } /* static */ bool -GStreamerFormatHelper::IsPluginFeatureBlacklisted(GstPluginFeature *aFeature) +GStreamerFormatHelper::IsPluginFeatureBlocked(GstPluginFeature *aFeature) { - if (!IsBlacklistEnabled()) { + if (!IsBlockListEnabled()) { return false; } const gchar *factoryName = gst_plugin_feature_get_name(aFeature); - for (unsigned int i = 0; i < G_N_ELEMENTS(sPluginBlacklist); i++) { - if (!strcmp(factoryName, sPluginBlacklist[i])) { + for (unsigned int i = 0; i < G_N_ELEMENTS(sPluginBlockList); i++) { + if (!strcmp(factoryName, sPluginBlockList[i])) { LOG("rejecting disabled plugin %s", factoryName); return true; } @@ -268,7 +268,7 @@ static gboolean FactoryFilter(GstPluginFeature *aFeature, gpointer) return gst_plugin_feature_get_rank(aFeature) >= GST_RANK_MARGINAL && - !GStreamerFormatHelper::IsPluginFeatureBlacklisted(aFeature); + !GStreamerFormatHelper::IsPluginFeatureBlocked(aFeature); } /** diff --git a/dom/media/gstreamer/GStreamerFormatHelper.h b/dom/media/gstreamer/GStreamerFormatHelper.h index 55ddcfb523..d8a04dd438 100644 --- a/dom/media/gstreamer/GStreamerFormatHelper.h +++ b/dom/media/gstreamer/GStreamerFormatHelper.h @@ -29,8 +29,8 @@ class GStreamerFormatHelper { bool CanHandleContainerCaps(GstCaps* aCaps); bool CanHandleCodecCaps(GstCaps* aCaps); - static bool IsBlacklistEnabled(); - static bool IsPluginFeatureBlacklisted(GstPluginFeature *aFeature); + static bool IsBlockListEnabled(); + static bool IsPluginFeatureBlocked(GstPluginFeature *aFeature); static GstCaps* ConvertFormatsToCaps(const char* aMIMEType, const nsAString* aCodecs); diff --git a/dom/media/gstreamer/GStreamerReader.cpp b/dom/media/gstreamer/GStreamerReader.cpp index 69eb1f7b1b..58bd4dcaa3 100644 --- a/dom/media/gstreamer/GStreamerReader.cpp +++ b/dom/media/gstreamer/GStreamerReader.cpp @@ -258,7 +258,7 @@ GValueArray *GStreamerReader::ElementFilter(GstURIDecodeBin *aBin, GValue *value = &aFactories->values[i]; GstPluginFeature *factory = GST_PLUGIN_FEATURE(g_value_peek_pointer(value)); - if (!GStreamerFormatHelper::IsPluginFeatureBlacklisted(factory)) { + if (!GStreamerFormatHelper::IsPluginFeatureBlocked(factory)) { g_value_array_append(filtered, value); } } @@ -952,7 +952,7 @@ media::TimeIntervals GStreamerReader::GetBuffered() void GStreamerReader::ReadAndPushData(guint aLength) { int64_t offset1 = mResource.Tell(); - unused << offset1; + Unused << offset1; nsresult rv = NS_OK; GstBuffer* buffer = gst_buffer_new_and_alloc(aLength); @@ -974,7 +974,7 @@ void GStreamerReader::ReadAndPushData(guint aLength) } int64_t offset2 = mResource.Tell(); - unused << offset2; + Unused << offset2; #if GST_VERSION_MAJOR >= 1 gst_buffer_unmap(buffer, &info); @@ -1206,7 +1206,7 @@ void GStreamerReader::Eos(GstAppSink* aSink) * This callback is called while the pipeline is automatically built, after a * new element has been added to the pipeline. We use it to find the * uridecodebin instance used by playbin and connect to it to apply our - * blacklist. + * block list. */ void GStreamerReader::PlayElementAddedCb(GstBin *aBin, GstElement *aElement, @@ -1243,7 +1243,7 @@ GStreamerReader::ShouldAutoplugFactory(GstElementFactory* aFactory, GstCaps* aCa /** * This is called by uridecodebin (running inside playbin), after it has found - * candidate factories to continue decoding the stream. We apply the blacklist + * candidate factories to continue decoding the stream. We apply the block list * here, disallowing known-crashy plugins. */ GValueArray* diff --git a/dom/media/gstreamer/GStreamerReader.h b/dom/media/gstreamer/GStreamerReader.h index 43afbaa988..5de06a946e 100644 --- a/dom/media/gstreamer/GStreamerReader.h +++ b/dom/media/gstreamer/GStreamerReader.h @@ -84,8 +84,8 @@ private: /* * We attach this callback to playbin so that when uridecodebin is - * constructed, we can then list for its autoplug-sort signal to blacklist - * the elements it can construct. + * constructed, we can then list for its autoplug-sort signal to block + * list the elements it can construct. */ static void ElementAddedCb(GstBin *aPlayBin, GstElement *aElement, @@ -185,7 +185,7 @@ private: static bool ShouldAutoplugFactory(GstElementFactory* aFactory, GstCaps* aCaps); /* Called by decodebin during autoplugging. We use it to apply our - * container/codec blacklist. + * container/codec block list. */ static GValueArray* AutoplugSortCb(GstElement* aElement, GstPad* aPad, GstCaps* aCaps, diff --git a/dom/media/gtest/TestMediaFormatReader.cpp b/dom/media/gtest/TestMediaFormatReader.cpp index 453c6dc3fd..95f720ba7d 100644 --- a/dom/media/gtest/TestMediaFormatReader.cpp +++ b/dom/media/gtest/TestMediaFormatReader.cpp @@ -153,7 +153,7 @@ void SetPref(const char* a, T value); template <> void SetPref(const char* aPrefKey, bool aValue) { - unused << Preferences::SetBool(aPrefKey, aValue); + Unused << Preferences::SetBool(aPrefKey, aValue); } template @@ -242,4 +242,4 @@ TEST(MediaFormatReader, RequestVideoRawData) &MediaFormatReaderBinding::OnMetadataNotRead); }; b->RunTestAndWait(testCase); -} \ No newline at end of file +} diff --git a/dom/media/mediasource/MediaSource.cpp b/dom/media/mediasource/MediaSource.cpp index a9a5f388ae..a35d87f13f 100644 --- a/dom/media/mediasource/MediaSource.cpp +++ b/dom/media/mediasource/MediaSource.cpp @@ -27,6 +27,11 @@ #include "nsThreadUtils.h" #include "mozilla/Logging.h" #include "nsServiceManagerUtils.h" +#include "gfxPlatform.h" + +#ifdef MOZ_WIDGET_ANDROID +#include "AndroidBridge.h" +#endif struct JSContext; class JSObject; @@ -65,6 +70,22 @@ static const char* const gMediaSourceTypes[6] = { nullptr }; +// Returns true if we should enable MSE webm regardless of preferences. +// 1. If MP4/H264 isn't supported: +// * Windows XP +// * Windows Vista and Server 2008 without the optional "Platform Update Supplement" +// * N/KN editions (Europe and Korea) of Windows 7/8/8.1/10 without the +// optional "Windows Media Feature Pack" +// 2. If H264 hardware acceleration is not available. +static bool +IsWebMForced() +{ + bool mp4supported = + DecoderTraits::IsMP4TypeAndEnabled(NS_LITERAL_CSTRING("video/mp4")); + bool hwsupported = gfxPlatform::GetPlatform()->CanUseHardwareVideoDecoding(); + return !mp4supported || !hwsupported; +} + static nsresult IsTypeSupported(const nsAString& aType) { @@ -84,7 +105,7 @@ IsTypeSupported(const nsAString& aType) for (uint32_t i = 0; gMediaSourceTypes[i]; ++i) { if (mimeType.EqualsASCII(gMediaSourceTypes[i])) { - if (DecoderTraits::IsMP4Type(mimeTypeUTF8)) { + if (DecoderTraits::IsMP4TypeAndEnabled(mimeTypeUTF8)) { if (!Preferences::GetBool("media.mediasource.mp4.enabled", false)) { return NS_ERROR_DOM_NOT_SUPPORTED_ERR; } @@ -94,9 +115,9 @@ IsTypeSupported(const nsAString& aType) return NS_ERROR_DOM_INVALID_STATE_ERR; } return NS_OK; - } else if (DecoderTraits::IsWebMType(mimeTypeUTF8)) { - if (!Preferences::GetBool("media.mediasource.webm.enabled", false) || - Preferences::GetBool("media.mediasource.format-reader", false)) { + } else if (DecoderTraits::IsWebMTypeAndEnabled(mimeTypeUTF8)) { + if (!(Preferences::GetBool("media.mediasource.webm.enabled", false) || + IsWebMForced())) { return NS_ERROR_DOM_NOT_SUPPORTED_ERR; } if (hasCodecs && diff --git a/dom/media/mediasource/SourceBuffer.cpp b/dom/media/mediasource/SourceBuffer.cpp index 076d92fbf7..a78ad159a2 100644 --- a/dom/media/mediasource/SourceBuffer.cpp +++ b/dom/media/mediasource/SourceBuffer.cpp @@ -97,19 +97,31 @@ SourceBuffer::SetTimestampOffset(double aTimestampOffset, ErrorResult& aRv) } } -already_AddRefed +TimeRanges* SourceBuffer::GetBuffered(ErrorResult& aRv) { MOZ_ASSERT(NS_IsMainThread()); + // http://w3c.github.io/media-source/index.html#widl-SourceBuffer-buffered + // 1. If this object has been removed from the sourceBuffers attribute of the parent media source then throw an InvalidStateError exception and abort these steps. if (!IsAttached()) { aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); return nullptr; } - media::TimeIntervals ranges = mContentManager->Buffered(); - MSE_DEBUGV("ranges=%s", DumpTimeRanges(ranges).get()); - RefPtr tr = new dom::TimeRanges(); - ranges.ToTimeRanges(tr); - return tr.forget(); + bool rangeChanged = true; + media::TimeIntervals intersection = mContentManager->Buffered(); + MSE_DEBUGV("intersection=%s", DumpTimeRanges(intersection).get()); + if (mBuffered) { + media::TimeIntervals currentValue(mBuffered); + rangeChanged = (intersection != currentValue); + MSE_DEBUGV("currentValue=%s", DumpTimeRanges(currentValue).get()); + } + // 5. If intersection ranges does not contain the exact same range information as the current value of this attribute, then update the current value of this attribute to intersection ranges. + if (rangeChanged) { + mBuffered = new TimeRanges(ToSupports(this)); + intersection.ToTimeRanges(mBuffered); + } + // 6. Return the current value of this attribute. + return mBuffered; } media::TimeIntervals @@ -270,7 +282,7 @@ SourceBuffer::Ended() mContentManager->Ended(); // We want the MediaSourceReader to refresh its buffered range as it may // have been modified (end lined up). - mMediaSource->GetDecoder()->NotifyDataArrived(/* aThrottleUpdates = */ false); + mMediaSource->GetDecoder()->NotifyDataArrived(); } SourceBuffer::SourceBuffer(MediaSource* aMediaSource, const nsACString& aType) @@ -278,7 +290,6 @@ SourceBuffer::SourceBuffer(MediaSource* aMediaSource, const nsACString& aType) , mMediaSource(aMediaSource) , mUpdating(false) , mActive(false) - , mReportedOffset(0) , mType(aType) { MOZ_ASSERT(NS_IsMainThread()); @@ -431,9 +442,7 @@ SourceBuffer::AppendDataCompletedWithSuccess(bool aHasActiveTracks) } if (mActive) { // Tell our parent decoder that we have received new data. - // The information provided do not matter much so long as it is monotonically - // increasing. - mMediaSource->GetDecoder()->NotifyDataArrived(/* aThrottleUpdates = */ false); + mMediaSource->GetDecoder()->NotifyDataArrived(); // Send progress event. mMediaSource->GetDecoder()->NotifyBytesDownloaded(); } @@ -584,11 +593,13 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(SourceBuffer) manager->Detach(); } NS_IMPL_CYCLE_COLLECTION_UNLINK(mMediaSource) + NS_IMPL_CYCLE_COLLECTION_UNLINK(mBuffered) NS_IMPL_CYCLE_COLLECTION_UNLINK_END_INHERITED(DOMEventTargetHelper) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(SourceBuffer, DOMEventTargetHelper) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMediaSource) + NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mBuffered) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_ADDREF_INHERITED(SourceBuffer, DOMEventTargetHelper) diff --git a/dom/media/mediasource/SourceBuffer.h b/dom/media/mediasource/SourceBuffer.h index 355bd98113..1cd8c23a61 100644 --- a/dom/media/mediasource/SourceBuffer.h +++ b/dom/media/mediasource/SourceBuffer.h @@ -147,7 +147,7 @@ public: return mUpdating; } - already_AddRefed GetBuffered(ErrorResult& aRv); + TimeRanges* GetBuffered(ErrorResult& aRv); media::TimeIntervals GetTimeIntervals(); double TimestampOffset() const @@ -269,10 +269,10 @@ private: mozilla::Atomic mActive; - int64_t mReportedOffset; - MozPromiseRequestHolder mPendingAppend; const nsCString mType; + + RefPtr mBuffered; }; } // namespace dom diff --git a/dom/media/systemservices/CamerasChild.cpp b/dom/media/systemservices/CamerasChild.cpp index 8c7b39b593..44ad63cdad 100644 --- a/dom/media/systemservices/CamerasChild.cpp +++ b/dom/media/systemservices/CamerasChild.cpp @@ -630,7 +630,7 @@ CamerasChild::Shutdown() // CamerasChild (this) will remain alive and is only deleted by the // IPC layer when SendAllDone returns. media::NewRunnableFrom([this]() -> nsresult { - unused << this->SendAllDone(); + Unused << this->SendAllDone(); return NS_OK; }); CamerasSingleton::Thread()->Dispatch(deleteRunnable, NS_DISPATCH_NORMAL); diff --git a/dom/media/systemservices/CamerasParent.cpp b/dom/media/systemservices/CamerasParent.cpp index 4b96fe60e2..091ad659de 100644 --- a/dom/media/systemservices/CamerasParent.cpp +++ b/dom/media/systemservices/CamerasParent.cpp @@ -404,7 +404,7 @@ CamerasParent::CloseEngines() auto capNum = mCallbacks[0]->mCapturerId; LOG(("Forcing shutdown of engine %d, capturer %d", capEngine, capNum)); StopCapture(capEngine, capNum); - unused << ReleaseCaptureDevice(capEngine, capNum); + Unused << ReleaseCaptureDevice(capEngine, capNum); } for (int i = 0; i < CaptureEngine::MaxEngine; i++) { @@ -474,11 +474,11 @@ CamerasParent::RecvNumberOfCaptureDevices(const int& aCapEngine) } if (num < 0) { LOG(("RecvNumberOfCaptureDevices couldn't find devices")); - unused << self->SendReplyFailure(); + Unused << self->SendReplyFailure(); return NS_ERROR_FAILURE; } else { LOG(("RecvNumberOfCaptureDevices: %d", num)); - unused << self->SendReplyNumberOfCaptureDevices(num); + Unused << self->SendReplyNumberOfCaptureDevices(num); return NS_OK; } }); @@ -513,12 +513,12 @@ CamerasParent::RecvNumberOfCapabilities(const int& aCapEngine, } if (num < 0) { LOG(("RecvNumberOfCapabilities couldn't find capabilities")); - unused << self->SendReplyFailure(); + Unused << self->SendReplyFailure(); return NS_ERROR_FAILURE; } else { LOG(("RecvNumberOfCapabilities: %d", num)); } - unused << self->SendReplyNumberOfCapabilities(num); + Unused << self->SendReplyNumberOfCapabilities(num); return NS_OK; }); self->mPBackgroundThread->Dispatch(ipc_runnable, NS_DISPATCH_NORMAL); @@ -565,10 +565,10 @@ CamerasParent::RecvGetCaptureCapability(const int &aCapEngine, webrtcCaps.rawType, webrtcCaps.codecType)); if (error) { - unused << self->SendReplyFailure(); + Unused << self->SendReplyFailure(); return NS_ERROR_FAILURE; } - unused << self->SendReplyGetCaptureCapability(capCap); + Unused << self->SendReplyGetCaptureCapability(capCap); return NS_OK; }); self->mPBackgroundThread->Dispatch(ipc_runnable, NS_DISPATCH_NORMAL); @@ -610,12 +610,12 @@ CamerasParent::RecvGetCaptureDevice(const int& aCapEngine, } if (error) { LOG(("GetCaptureDevice failed: %d", error)); - unused << self->SendReplyFailure(); + Unused << self->SendReplyFailure(); return NS_ERROR_FAILURE; } LOG(("Returning %s name %s id", name.get(), uniqueId.get())); - unused << self->SendReplyGetCaptureDevice(name, uniqueId); + Unused << self->SendReplyGetCaptureDevice(name, uniqueId); return NS_OK; }); self->mPBackgroundThread->Dispatch(ipc_runnable, NS_DISPATCH_NORMAL); @@ -646,11 +646,11 @@ CamerasParent::RecvAllocateCaptureDevice(const int& aCapEngine, return NS_ERROR_FAILURE; } if (error) { - unused << self->SendReplyFailure(); + Unused << self->SendReplyFailure(); return NS_ERROR_FAILURE; } else { LOG(("Allocated device nr %d", numdev)); - unused << self->SendReplyAllocateCaptureDevice(numdev); + Unused << self->SendReplyAllocateCaptureDevice(numdev); return NS_OK; } }); @@ -689,10 +689,10 @@ CamerasParent::RecvReleaseCaptureDevice(const int& aCapEngine, return NS_ERROR_FAILURE; } if (error) { - unused << self->SendReplyFailure(); + Unused << self->SendReplyFailure(); return NS_ERROR_FAILURE; } else { - unused << self->SendReplySuccess(); + Unused << self->SendReplySuccess(); LOG(("Freed device nr %d", numdev)); return NS_OK; } @@ -752,10 +752,10 @@ CamerasParent::RecvStartCapture(const int& aCapEngine, return NS_ERROR_FAILURE; } if (!error) { - unused << self->SendReplySuccess(); + Unused << self->SendReplySuccess(); return NS_OK; } else { - unused << self->SendReplyFailure(); + Unused << self->SendReplyFailure(); return NS_ERROR_FAILURE; } }); diff --git a/dom/media/systemservices/MediaParent.cpp b/dom/media/systemservices/MediaParent.cpp index b619b24e76..84a32d41d5 100644 --- a/dom/media/systemservices/MediaParent.cpp +++ b/dom/media/systemservices/MediaParent.cpp @@ -447,7 +447,7 @@ Parent::RecvGetOriginKey(const uint32_t& aRequestId, if (!sIPCServingParent) { return NS_OK; } - unused << sIPCServingParent->SendGetOriginKeyResponse(aRequestId, aKey); + Unused << sIPCServingParent->SendGetOriginKeyResponse(aRequestId, aKey); } else { RefPtr mgr = MediaManager::GetInstance(); if (!mgr) { diff --git a/dom/media/systemservices/MediaSystemResourceManagerParent.cpp b/dom/media/systemservices/MediaSystemResourceManagerParent.cpp index 0029874373..4523a30164 100644 --- a/dom/media/systemservices/MediaSystemResourceManagerParent.cpp +++ b/dom/media/systemservices/MediaSystemResourceManagerParent.cpp @@ -32,7 +32,7 @@ MediaSystemResourceManagerParent::RecvAcquire(const uint32_t& aId, MOZ_ASSERT(!request); if (request) { // Send fail response - mozilla::unused << SendResponse(aId, false /* fail */); + mozilla::Unused << SendResponse(aId, false /* fail */); return true; } diff --git a/dom/media/systemservices/MediaSystemResourceService.cpp b/dom/media/systemservices/MediaSystemResourceService.cpp index 29f17da17c..1c07e34cfa 100644 --- a/dom/media/systemservices/MediaSystemResourceService.cpp +++ b/dom/media/systemservices/MediaSystemResourceService.cpp @@ -95,7 +95,7 @@ MediaSystemResourceService::Acquire(media::MediaSystemResourceManagerParent* aPa resource->mResourceCount == 0) { // Resource does not exit // Send fail response - mozilla::unused << aParent->SendResponse(aId, false /* fail */); + mozilla::Unused << aParent->SendResponse(aId, false /* fail */); return; } @@ -105,12 +105,12 @@ MediaSystemResourceService::Acquire(media::MediaSystemResourceManagerParent* aPa resource->mAcquiredRequests.push_back( MediaSystemResourceRequest(aParent, aId)); // Send success response - mozilla::unused << aParent->SendResponse(aId, true /* success */); + mozilla::Unused << aParent->SendResponse(aId, true /* success */); return; } else if (!aWillWait) { // Resource is not available and do not wait. // Send fail response - mozilla::unused << aParent->SendResponse(aId, false /* fail */); + mozilla::Unused << aParent->SendResponse(aId, false /* fail */); return; } // Wait until acquire. @@ -247,7 +247,7 @@ MediaSystemResourceService::UpdateRequests(MediaSystemResourceType aResourceType MediaSystemResourceRequest& request = waitingRequests.front(); MOZ_ASSERT(request.mParent); // Send response - mozilla::unused << request.mParent->SendResponse(request.mId, true /* success */); + mozilla::Unused << request.mParent->SendResponse(request.mId, true /* success */); // Move request to mAcquiredRequests acquiredRequests.push_back(waitingRequests.front()); waitingRequests.pop_front(); diff --git a/dom/media/test/manifest.js b/dom/media/test/manifest.js index 095a200750..9af88213ce 100644 --- a/dom/media/test/manifest.js +++ b/dom/media/test/manifest.js @@ -9,6 +9,7 @@ var gSmallTests = [ { name:"small-shot.m4a", type:"audio/mp4", duration:0.29 }, { name:"small-shot.mp3", type:"audio/mpeg", duration:0.27 }, { name:"small-shot-mp3.mp4", type:"audio/mp4; codecs=mp3", duration:0.34 }, + { name:"small-shot.flac", type:"audio/flac", duration:0.197 }, { name:"r11025_s16_c1.wav", type:"audio/x-wav", duration:1.0 }, { name:"320x240.ogv", type:"video/ogg", width:320, height:240, duration:0.266 }, { name:"seek.webm", type:"video/webm", width:320, height:240, duration:3.966 }, diff --git a/dom/media/test/mochitest.ini b/dom/media/test/mochitest.ini index 35ff6a79aa..16c7c5acec 100644 --- a/dom/media/test/mochitest.ini +++ b/dom/media/test/mochitest.ini @@ -233,6 +233,7 @@ support-files = small-shot.mp3^headers^ small-shot.ogg small-shot.ogg^headers^ + small-shot.flac sound.ogg sound.ogg^headers^ spacestorm-1000Hz-100ms.ogg diff --git a/dom/media/test/small-shot.flac b/dom/media/test/small-shot.flac new file mode 100644 index 0000000000000000000000000000000000000000..0da7c9044e52afd588d4e7ea91da627ce0f09aff GIT binary patch literal 16430 zcmeI(XHb*bzc_G2)PTWX3MBzq^CW~Wkc1+Lg)|ZfJs@BskRV+Nh`j(ICLv%#O(-H& z2#9oPvI_#z6-1V%t{7cVbg`~&^}6@o`Op9Lea&~~%$f6jPMgo0=ggToVGI^YMMVV- zQGxudwx~eYYxEIUeHU6EO+{rM^|KF`6UO0kVnaEo=!g(1 z!i2mD7>|`y|n|*Uj1hu-JivoLG*Lq<<5#v;BZk#!%#jPR&+$dDXo7$`7r6e z%w5E2R%jH;mlYDiN(ldV7}=Rg*@bhk$ASNC(0xfBe(pqy&o11*dvl?9_)vC{j~Jt65jjg8$%m!&0bG zg6vLN+Dll6*mO}v<(|q0Rfr04{c%-6;r!d9#z7f(uif;#`g-1`<~`o}Yx8QQ^Olwe zM&Cxus{grZY1Eouo7)jyN-HZ}uBba1nz7j;c_#7g@VnOimwd-Cl6BsJrLdt3pNj4yAkNjq9)u?G|6m^}mlvV4`e;nYSKmd0XY z$o8YWai~WX3TwUqk&g6nCLp6`kstW5TlCQz8woq&)rL&9_a~OCd39TlsGfg6s@=#l zL^```g!$^Ia!UdTg~Oo+G;=k}zRd}c%gXRlQoY!jQe8;^b_9fC^29cqk?I=R&+Q2c z55i`SnsfB5Wgh=rE7r4izHs$ z0UrFI1HQRDHG;~DuU}ZMC$<%gd-2nmMI{kg-ZNoS2Mm|rT4`$Z`f~-Muyd)1RIy2t z_Ukb7-v-RSU`%-C<~(N_pmoFnH(?!81iE-BA^RctF9~srf2gY@ZPx5ibSKc!k8-}f zsJecA_9)vTM4J5WnBk^i*@AYmX#Hrngf0fW0iBmRp4wh1zd#+djS zfHtNu@fO+qgD>@lKP&9Z{qgVp2>!$p1MwbxJB_Oo&~VW~)X4pVfff&PR>w+);qXK8 z>UD|kz8&D)@}ORh1%7u6a?GiYjGBErae07=;10$v;`KeA zPjk$7#udHK0HT?=vh)x>*35+DoX>PJ#_t5TY(_#agVLu414>~|$?7h&o=x7hE~S=} zc;Tib9gwBbk4O4bkfR1-4|SR-0!isiI{lT{Er<6SShM`fZ-* zzd1<<*Qd$@hUJ6fqvg)tTL*NlK&0kH4ti@54c9(`FiIa5PGp4WU#?R%-Oq&{eXe&t zt1|t7u;A>shrOqqVAZV{g%76E8?-!*-yw*Dn0o*zC0mlcLB0jL!UvaC>j8xKJ-BP<0d@sb4Ol6^14-%GDn51?KoPJZPRXpFPNS$P=c9nnZ3E zEAfpRo*-%C49AT-!8(G~;4X|LbkULJ-HylWyf>ch=Wg7Xhy zc&^p6nJ@*@=y0$75As|k7oZXwci$nnYaZxXlpL;G2_t6D4V*>)P)ko3lc~5sn@*GPg5tcDW zs0kdNV%FygGLoyro6-ib{w><>t)WX3juO6O)_q6KDfWlB=GS|L5e46#$b0QAw##)z3%kgjApz+;$o*Q;nQ7_iOtw}bmLb3@*!CBy?UZ1 zMVV>9n>T>>;JM9%?i;+);jhqSc+P8HzE$SN8t;PcqhgnK%`|#v;`E`E(cw7XgP!QuK~2bY5h_X8aCN6#XUrSdJH@3iq{T5N83zXplR zFw9kwZ>VFxkbm_hys@}r9pxw>4fw>1UC1U=aUiY-RjylYd7t-q4;tL3Wf=;ut92`G z1gbiLx|pW&1E^{g?estn?C#8!6M(eztJJ8xeS4$&fy+r5i`rvi$P=HQeDBX7@~wM@ zwS_A1A0IES|4r?}_if*oRNkw^Mc`I2^qNK6e_lf$k7&oM$W$CRILokr!-mi=PYGc9 z+~!{bbL7`jtlB2cvkt8M-t1bLyuT_L(Y9z~64?>theZF`-qro(nCNVL9rE4yt81@y zMCFfaQGX$hOrOm;XxI9fQ{ZN?O48hS(24s{OUjynT|Qkj069|piRyFZw-kh*(x()% zLNZkzWk=>n(P)3)9U17%^84qGPhiMj@1Ap|rEAWA%}@wj<1SVSy4-TG3H{e_Y-~qMrHNC?bzT33XiG9V1 ziSaOTsmavuZjpD~6c|PynKv|@_e)0%Lf{cQT(mRc%i}Owq)`;!T~qG+EO5SjARTE> zA^v4C7dh@?V@NC3squ9N(T#q@n-(sJrbcpHXtu^8>ABMrX6C&z++62`bao z#cayULjiIK6`$U;xKdk{mHYX0LkU#t^LrXK&O8GB@}0SFlq}O~Sde|xcORx8|Mgcn zJ&`K1$E?WUUyQp|!U?%jrtlC4R}r&oj05VaKfc9YofZ*x7T4UZEXYA{VYs>dp~ z*&JWgjx%{xA1t8xYJ>i0ZQV`Xcb+4PRj(>_Y|voDh>l z{1Ww;_(En$A#r`sj7;0D^o(+)2Tc4x0$=CGo+yS>5p_PYcJnL;WA1G%{5?>_((f*h z*NE1%$^7{3Y{9qv4F^wt*tq z^vG&2P;$+Z3H>97{0*(suV86B4~VP`2&kt`eo5%lcRbPDof2{t4ipO7GpKHt(+6Cu zg0uOEX&o1uxg#faRZ%prHf~{XitXoI^-(JGKRs$r^$XsClhQ0rtz`UBM%|VYAmA3z3k5&C zg04j4ug3Q3r$TJbK<>Qsy&|W9oj3FcmmR92y)uCX#KNb}^A6O`3Yaqz-LSvqgY?b- z;2aK-$Q!b30q=d;t9o3y!A2wtOQ_KS%1{WEsd+1BmSi?Hak);(ug zK68_*kf6v@d(3jajkU!7=(5hTz(s<8A-w@fQg-}lrk26p^g0yZ6e1coS#bp-o?rXW z+NUnjAx1XSc>y=&9)HCuj-i7tSr;)|H0Ace#I`=(hWQ&gBH((j;Dwo^?K(}zP6J2P zvh6Yu--!3#F z5DR*&&5lL~Cz-xBz(3XaHd(!1JMjqW!DIM(?>qZbBXhJ?dK}5Maf_zTif$sLaHP=n z%fUr(i9&MwdcfY}d&8r{3|nc?Q&Z0eLlTb7XS{Jp{LsY3c!_G$f{AQucJHKg$VYK4 z@I8{z;J>ZC0p*AozKI+Q-0o^J-fZk*cd=I^bj!)W&e!7-$Wztvi?=P+KC#;q(;&y0 z-YtpGK|CD)(w-`O*&}0uncKnGV{+k1R$Q+`s>k(^*H~H8K6O>_)Z^mSTnAzFaT|!> z{R2d7?Ky^70w_2JYGmG(RN}5YWbp45$U2dSYL{xOYLjZC>W!bJO|`Yf@odNPeHV%F^i(2xTv!Ay*dG2x3M2w$H6ig=hg+(DL9s5tY{`+*=S(i zMFSaAbK#0yWAx#KIc2bmOrD^<@?On4`#2;hpumV%^(HgNdgeXv&`^Ma-vHmP-x*fx zfZUCLV?MyeP9Bs7r`-qk2m}oVnTdtzuF)b9^@!o1o| zv_E0gHd)ah9lAp9CO>W&EefhI%x&U$2G;e9^9Qrgy)kE`yLrCM->C=H$8?AX5~@be z4xJ_WYSTDJUC5mhPCL)1KCgY=9VZEPGxQc`4e!W=e4l;gn!f* zO<_B2TBIFK*whf0FzxPHRI=kCV^Xqx^F5^7u&0>;0`BXlt zp#>f9QH3#Ed9+(RqHdTG!M;y0PGEPnn_b=y$>Z439=84qvACW{HU z<>K+uv%;Y|YTATdF|MP=(2^z)JUAa_ellziXfg8DOU7N;Z)tA~uJcl%iknaO&#RB{ zf8^0d#2=atR|n5h1vhe%%7DgEKM(c0U)JA>ov^-;G!9(Cc$&!4_e! z9MR1Wu|_N6o26&!!rY!`(ejy%_U_P=6DRuzDZ+}?p$9w{|Hd%FzzebRmbwKmP*R(3 zNUIu}Sz$bHo>`HWO`s14qIG=&E*C_Lifxx0FpUvfo?dsG?)5K1sxk~aDZ|)!n^(v^ z9b=`0=do1+<)cP(_A(Biqp$xvc8EFp#?Atl+KxyaN_2}NRCZB6;OHg0uV;RH;GGGd zyYII*+uzo3c$j<%-{OMIVchA5#f~Jpn-sg-y~Q6Wcu!tNuE-T-fB~yBZpO~X?`wVx z#zjziBqcCSjgtXCozY`3ngjLj=tLGnif4qkKHHRca^^5rwIZQ8W3a)IYaSmF+b*3C z8kSs%$40S4G?darwzqwVCtN1nYyxOdN_!LkQ*^e46(E|;E~w-w8- zSftOfXr2?$j;w=Tnd3uw7Vzi~^JYASm&jOADt&ygiONRx7(t8= z5Io~YGdk>547$^I9XOTKXWdY(wk5~(5>7$dNwL)?=>fUl9~pR@Z_s8+>_F46sf{?(;F+*M2$g(Gd@W+z7{-m!3n)jjDnsI{KW6~W|ddQaGl+&T+ zwR?f6Gp_tS?-3wZe1RfPPlPXJGrVbiGBrQsCy(Y>RQHpl3R4c#I)$tb+_KRyCLf((*$w1wZicWi zT3@>T`I$VYt22=DU)7iH|2#~1)zt<|7;dGl=RcL)A$r|Z{|q8gb-TZn{aAp=z6#M# zDW+ZL-Zov+mz+)yn`T`x3MR{0yRtNS&Ic~7hNwTfeR|;KY~Yc^C<8Osy3ah{Cwm5^ z)BY1czGb9r=z--M{rz&oCkoaM_PgllR0i43f2@!OY zOtTIR@!#b(Dl}5iHq;=GbSXHj1t`%=^T4(jlI!Ox05aMcgSaK2v zp?==!AF*!57iL2b%Oc@B&lLB{N>LBRgBInXJ`n%*LBCa0hI`Zc zT=7UyQIoc$w;HI)gDRG;ORd;L8Af+ddjX9Z=ioYlmvWy!kG4|8w;`M*FL69lcng&y zRFAlkFitY*DB z38e&J#>}*n9@nuPQSIFlYtqN@Y2!01cfKP#I;}jI=(_V8|J_R#pnW;HQIeOQooHEk z?_xjbePSX5C0A61_ezf7fuSYO#>r~Xfl%3y9*U3M;#`j3>4+YC=zzr}G`lbFNE=kJ zpge5Vco-VF-tcBfb|y?KWS@X<7r-W>ok-sehfELFfOwAQp426Da-=i2@kb&6yqYmH z;lk)!Bs2=py*eFFAuU`%Pnk)jKh)sc-(79&4qrT;mOU(r0NL(ule=Ev-4Z4?={i7$ z6&^0Bj`b~4FCfMyIy4Q0*;iBwU8+}11e#~?79dtJLhtEtb& zZMxSCIZAPY{0~1oG(CD@lJ9jr|zibbPeHZMbLuiRX}e5^-H9 z$j+h{A#vu6QwG$$+Q!Rp7vhR457I<4|9~0> z5=QhyUi65T*@8*3(Ets$SjeV&WZtBA6gUdd}lS45dQXv97y=f>KcE76#54R_j+B zRk+VJwj5P#Od{3_}#HkAJY D4)Xk* literal 0 HcmV?d00001 diff --git a/dom/media/test/test_can_play_type_mpeg.html b/dom/media/test/test_can_play_type_mpeg.html index 6afa1476c8..448e1a7319 100644 --- a/dom/media/test/test_can_play_type_mpeg.html +++ b/dom/media/test/test_can_play_type_mpeg.html @@ -26,11 +26,13 @@ function check_mp4(v, enabled) { } check("video/mp4", "maybe"); + check("video/x-m4v", "maybe"); check("audio/mp4", "maybe"); check("audio/x-m4a", "maybe"); // Not the MIME type that other browsers respond to, so we won't either. check("audio/m4a", ""); + check("video/m4v", ""); // Only Safari responds affirmatively to "audio/aac", // so we'll let x-m4a cover aac support. check("audio/aac", ""); diff --git a/dom/media/webaudio/AnalyserNode.cpp b/dom/media/webaudio/AnalyserNode.cpp index e7fd2bc42b..a485a4ca38 100644 --- a/dom/media/webaudio/AnalyserNode.cpp +++ b/dom/media/webaudio/AnalyserNode.cpp @@ -118,7 +118,7 @@ AnalyserNode::AnalyserNode(AudioContext* aContext) // Enough chunks must be recorded to handle the case of fftSize being // increased to maximum immediately before getFloatTimeDomainData() is // called, for example. - unused << mChunks.SetLength(CHUNK_COUNT, fallible); + Unused << mChunks.SetLength(CHUNK_COUNT, fallible); AllocateBuffer(); } diff --git a/dom/media/webaudio/BufferDecoder.h b/dom/media/webaudio/BufferDecoder.h index 623956400b..5277627451 100644 --- a/dom/media/webaudio/BufferDecoder.h +++ b/dom/media/webaudio/BufferDecoder.h @@ -57,7 +57,7 @@ public: virtual MediaDecoderOwner* GetOwner() final override; - virtual void NotifyDataArrived(bool) final override {}; + virtual void NotifyDataArrived() final override {}; private: virtual ~BufferDecoder(); diff --git a/dom/media/webrtc/MediaEngineGonkVideoSource.cpp b/dom/media/webrtc/MediaEngineGonkVideoSource.cpp index e6f243f70b..e9971485c0 100644 --- a/dom/media/webrtc/MediaEngineGonkVideoSource.cpp +++ b/dom/media/webrtc/MediaEngineGonkVideoSource.cpp @@ -590,7 +590,7 @@ MediaEngineGonkVideoSource::OnUserError(UserContext aContext, nsresult aError) } void -MediaEngineGonkVideoSource::OnTakePictureComplete(uint8_t* aData, uint32_t aLength, const nsAString& aMimeType) +MediaEngineGonkVideoSource::OnTakePictureComplete(const uint8_t* aData, uint32_t aLength, const nsAString& aMimeType) { // It needs to start preview because Gonk camera will stop preview while // taking picture. @@ -601,7 +601,7 @@ MediaEngineGonkVideoSource::OnTakePictureComplete(uint8_t* aData, uint32_t aLeng class GenerateBlobRunnable : public nsRunnable { public: GenerateBlobRunnable(nsTArray>& aCallbacks, - uint8_t* aData, + const uint8_t* aData, uint32_t aLength, const nsAString& aMimeType) : mPhotoDataLength(aLength) diff --git a/dom/media/webrtc/MediaEngineGonkVideoSource.h b/dom/media/webrtc/MediaEngineGonkVideoSource.h index ceda534731..433667189e 100644 --- a/dom/media/webrtc/MediaEngineGonkVideoSource.h +++ b/dom/media/webrtc/MediaEngineGonkVideoSource.h @@ -81,7 +81,7 @@ public: void GetRotation(); bool OnNewPreviewFrame(layers::Image* aImage, uint32_t aWidth, uint32_t aHeight) override; void OnUserError(UserContext aContext, nsresult aError) override; - void OnTakePictureComplete(uint8_t* aData, uint32_t aLength, const nsAString& aMimeType) override; + void OnTakePictureComplete(const uint8_t* aData, uint32_t aLength, const nsAString& aMimeType) override; void AllocImpl(); void DeallocImpl(); diff --git a/dom/media/webspeech/synth/nsSynthVoiceRegistry.cpp b/dom/media/webspeech/synth/nsSynthVoiceRegistry.cpp index 73c046c4ed..580ec00483 100644 --- a/dom/media/webspeech/synth/nsSynthVoiceRegistry.cpp +++ b/dom/media/webspeech/synth/nsSynthVoiceRegistry.cpp @@ -352,7 +352,7 @@ nsSynthVoiceRegistry::RemoveVoice(nsISpeechService* aService, GetAllSpeechSynthActors(ssplist); for (uint32_t i = 0; i < ssplist.Length(); ++i) - unused << ssplist[i]->SendVoiceRemoved(nsString(aUri)); + Unused << ssplist[i]->SendVoiceRemoved(nsString(aUri)); return NS_OK; } @@ -382,7 +382,7 @@ nsSynthVoiceRegistry::SetDefaultVoice(const nsAString& aUri, GetAllSpeechSynthActors(ssplist); for (uint32_t i = 0; i < ssplist.Length(); ++i) { - unused << ssplist[i]->SendSetDefaultVoice(nsString(aUri), aIsDefault); + Unused << ssplist[i]->SendSetDefaultVoice(nsString(aUri), aIsDefault); } } @@ -502,7 +502,7 @@ nsSynthVoiceRegistry::AddVoiceImpl(nsISpeechService* aService, aQueuesUtterances); for (uint32_t i = 0; i < ssplist.Length(); ++i) { - unused << ssplist[i]->SendVoiceAdded(ssvoice); + Unused << ssplist[i]->SendVoiceAdded(ssvoice); } } @@ -752,7 +752,7 @@ nsSynthVoiceRegistry::SetIsSpeaking(bool aIsSpeaking) nsTArray ssplist; GetAllSpeechSynthActors(ssplist); for (uint32_t i = 0; i < ssplist.Length(); ++i) { - unused << ssplist[i]->SendIsSpeakingChanged(aIsSpeaking); + Unused << ssplist[i]->SendIsSpeakingChanged(aIsSpeaking); } } diff --git a/dom/messagechannel/MessagePort.cpp b/dom/messagechannel/MessagePort.cpp index 4c833589b7..b8ec9e7e42 100644 --- a/dom/messagechannel/MessagePort.cpp +++ b/dom/messagechannel/MessagePort.cpp @@ -240,7 +240,7 @@ public: PBackgroundChild* actor = mozilla::ipc::BackgroundChild::GetForCurrentThread(); if (actor) { - unused << actor->SendMessagePortForceClose(aIdentifier.uuid(), + Unused << actor->SendMessagePortForceClose(aIdentifier.uuid(), aIdentifier.destinationUuid(), aIdentifier.sequenceId()); return; diff --git a/dom/messagechannel/MessagePortParent.cpp b/dom/messagechannel/MessagePortParent.cpp index e34ce3f2cc..46074ee032 100644 --- a/dom/messagechannel/MessagePortParent.cpp +++ b/dom/messagechannel/MessagePortParent.cpp @@ -103,7 +103,7 @@ MessagePortParent::RecvStopSendingData() } mCanSendData = false; - unused << SendStopSendingDataConfirmed(); + Unused << SendStopSendingDataConfirmed(); return true; } @@ -122,7 +122,7 @@ MessagePortParent::RecvClose() MOZ_ASSERT(!mEntangled); - unused << Send__delete__(this); + Unused << Send__delete__(this); return true; } @@ -149,7 +149,7 @@ void MessagePortParent::CloseAndDelete() { Close(); - unused << Send__delete__(this); + Unused << Send__delete__(this); } void diff --git a/dom/messagechannel/MessagePortService.cpp b/dom/messagechannel/MessagePortService.cpp index c96c6e718b..d061f68361 100644 --- a/dom/messagechannel/MessagePortService.cpp +++ b/dom/messagechannel/MessagePortService.cpp @@ -207,7 +207,7 @@ MessagePortService::DisentanglePort( return false; } - unused << data->mParent->Entangled(array); + Unused << data->mParent->Entangled(array); return true; } @@ -325,7 +325,7 @@ MessagePortService::PostMessages( } data->mMessages.Clear(); - unused << data->mParent->SendReceiveData(messages); + Unused << data->mParent->SendReceiveData(messages); } return true; diff --git a/dom/mobilemessage/ipc/SmsIPCService.cpp b/dom/mobilemessage/ipc/SmsIPCService.cpp index 6dddfb65d0..ce6c0eceb2 100644 --- a/dom/mobilemessage/ipc/SmsIPCService.cpp +++ b/dom/mobilemessage/ipc/SmsIPCService.cpp @@ -73,7 +73,7 @@ SendCursorRequest(const IPCMobileMessageCursor& aRequest, // Add an extra ref for IPDL. Will be released in // SmsChild::DeallocPMobileMessageCursor(). RefPtr actorCopy(actor); - mozilla::unused << actorCopy.forget().take(); + mozilla::Unused << actorCopy.forget().take(); smsChild->SendPMobileMessageCursorConstructor(actor, aRequest); diff --git a/dom/mobilemessage/ipc/SmsParent.cpp b/dom/mobilemessage/ipc/SmsParent.cpp index 3c5911bbc7..8870fdf767 100644 --- a/dom/mobilemessage/ipc/SmsParent.cpp +++ b/dom/mobilemessage/ipc/SmsParent.cpp @@ -225,7 +225,7 @@ SmsParent::Observe(nsISupports* aSubject, const char* aTopic, return NS_OK; } - unused << SendNotifyReceivedMessage(msgData); + Unused << SendNotifyReceivedMessage(msgData); return NS_OK; } @@ -236,7 +236,7 @@ SmsParent::Observe(nsISupports* aSubject, const char* aTopic, return NS_OK; } - unused << SendNotifyRetrievingMessage(msgData); + Unused << SendNotifyRetrievingMessage(msgData); return NS_OK; } @@ -247,7 +247,7 @@ SmsParent::Observe(nsISupports* aSubject, const char* aTopic, return NS_OK; } - unused << SendNotifySendingMessage(msgData); + Unused << SendNotifySendingMessage(msgData); return NS_OK; } @@ -258,7 +258,7 @@ SmsParent::Observe(nsISupports* aSubject, const char* aTopic, return NS_OK; } - unused << SendNotifySentMessage(msgData); + Unused << SendNotifySentMessage(msgData); return NS_OK; } @@ -269,7 +269,7 @@ SmsParent::Observe(nsISupports* aSubject, const char* aTopic, return NS_OK; } - unused << SendNotifyFailedMessage(msgData); + Unused << SendNotifyFailedMessage(msgData); return NS_OK; } @@ -280,7 +280,7 @@ SmsParent::Observe(nsISupports* aSubject, const char* aTopic, return NS_OK; } - unused << SendNotifyDeliverySuccessMessage(msgData); + Unused << SendNotifyDeliverySuccessMessage(msgData); return NS_OK; } @@ -291,7 +291,7 @@ SmsParent::Observe(nsISupports* aSubject, const char* aTopic, return NS_OK; } - unused << SendNotifyDeliveryErrorMessage(msgData); + Unused << SendNotifyDeliveryErrorMessage(msgData); return NS_OK; } @@ -309,7 +309,7 @@ SmsParent::Observe(nsISupports* aSubject, const char* aTopic, MobileMessageData msgData = static_cast(smsMsg.get())->GetData(); - unused << SendNotifyReceivedSilentMessage(msgData); + Unused << SendNotifyReceivedSilentMessage(msgData); return NS_OK; } @@ -320,7 +320,7 @@ SmsParent::Observe(nsISupports* aSubject, const char* aTopic, return NS_OK; } - unused << SendNotifyReadSuccessMessage(msgData); + Unused << SendNotifyReadSuccessMessage(msgData); return NS_OK; } @@ -331,7 +331,7 @@ SmsParent::Observe(nsISupports* aSubject, const char* aTopic, return NS_OK; } - unused << SendNotifyReadErrorMessage(msgData); + Unused << SendNotifyReadErrorMessage(msgData); return NS_OK; } @@ -342,7 +342,7 @@ SmsParent::Observe(nsISupports* aSubject, const char* aTopic, return NS_OK; } - unused << SendNotifyDeletedMessageInfo( + Unused << SendNotifyDeletedMessageInfo( static_cast(deletedInfo.get())->GetData()); return NS_OK; } diff --git a/dom/network/TCPServerSocketParent.cpp b/dom/network/TCPServerSocketParent.cpp index 7c78bed15c..b2b873a216 100644 --- a/dom/network/TCPServerSocketParent.cpp +++ b/dom/network/TCPServerSocketParent.cpp @@ -109,7 +109,7 @@ TCPServerSocketParent::SendCallbackAccept(TCPSocketParent *socket) if (mNeckoParent) { if (mNeckoParent->SendPTCPSocketConstructor(socket, host, port)) { - mozilla::unused << PTCPServerSocketParent::SendCallbackAccept(socket); + mozilla::Unused << PTCPServerSocketParent::SendCallbackAccept(socket); } else { NS_ERROR("Sending data from PTCPSocketParent was failed."); @@ -142,7 +142,7 @@ TCPServerSocketParent::ActorDestroy(ActorDestroyReason why) bool TCPServerSocketParent::RecvRequestDelete() { - mozilla::unused << Send__delete__(this); + mozilla::Unused << Send__delete__(this); return true; } diff --git a/dom/network/TCPSocket.cpp b/dom/network/TCPSocket.cpp index 988770d81e..350ffff52e 100644 --- a/dom/network/TCPSocket.cpp +++ b/dom/network/TCPSocket.cpp @@ -400,7 +400,7 @@ TCPSocket::NotifyCopyComplete(nsresult aStatus) mAsyncCopierActive = false; mMultiplexStream->RemoveStream(0); if (mSocketBridgeParent) { - mozilla::unused << mSocketBridgeParent->SendUpdateBufferedAmount(BufferedAmount(), + mozilla::Unused << mSocketBridgeParent->SendUpdateBufferedAmount(BufferedAmount(), mTrackingNumber); } diff --git a/dom/network/TCPSocketChild.cpp b/dom/network/TCPSocketChild.cpp index 3c31467fb2..e93b448db2 100644 --- a/dom/network/TCPSocketChild.cpp +++ b/dom/network/TCPSocketChild.cpp @@ -231,7 +231,7 @@ TCPSocketChild::GetPort(uint16_t* aPort) bool TCPSocketChild::RecvRequestDelete() { - mozilla::unused << Send__delete__(this); + mozilla::Unused << Send__delete__(this); return true; } diff --git a/dom/network/TCPSocketParent.cpp b/dom/network/TCPSocketParent.cpp index 74cac2785f..08cd0dfef5 100644 --- a/dom/network/TCPSocketParent.cpp +++ b/dom/network/TCPSocketParent.cpp @@ -37,7 +37,7 @@ namespace dom { static void FireInteralError(mozilla::net::PTCPSocketParent* aActor, uint32_t aLineNo) { - mozilla::unused << + mozilla::Unused << aActor->SendCallback(NS_LITERAL_STRING("onerror"), TCPError(NS_LITERAL_STRING("InvalidStateError"), NS_LITERAL_STRING("Internal error")), static_cast(TCPReadyState::Connecting)); @@ -135,7 +135,7 @@ NS_IMETHODIMP_(MozExternalRefCountType) TCPSocketParent::Release(void) { nsrefcnt refcnt = TCPSocketParentBase::Release(); if (refcnt == 1 && mIPCOpen) { - mozilla::unused << PTCPSocketParent::SendRequestDelete(); + mozilla::Unused << PTCPSocketParent::SendRequestDelete(); return 1; } return refcnt; @@ -335,7 +335,7 @@ TCPSocketParent::FireStringDataEvent(const nsACString& aData, TCPReadyState aRea void TCPSocketParent::SendEvent(const nsAString& aType, CallbackData aData, TCPReadyState aReadyState) { - mozilla::unused << PTCPSocketParent::SendCallback(nsString(aType), aData, + mozilla::Unused << PTCPSocketParent::SendCallback(nsString(aType), aData, static_cast(aReadyState)); } @@ -379,7 +379,7 @@ TCPSocketParent::ActorDestroy(ActorDestroyReason why) bool TCPSocketParent::RecvRequestDelete() { - mozilla::unused << Send__delete__(this); + mozilla::Unused << Send__delete__(this); return true; } diff --git a/dom/network/UDPSocket.h b/dom/network/UDPSocket.h index b1d2963e4e..0013d41f0b 100644 --- a/dom/network/UDPSocket.h +++ b/dom/network/UDPSocket.h @@ -18,12 +18,10 @@ struct JSContext; -#if defined(PR_LOGGING) // // set NSPR_LOG_MODULES=UDPSocket:5 // extern PRLogModuleInfo *gUDPSocketLog; -#endif #define UDPSOCKET_LOG(args) MOZ_LOG(gUDPSocketLog, mozilla::LogLevel::Debug, args) #define UDPSOCKET_LOG_ENABLED() MOZ_LOG_TEST(gUDPSocketLog, mozilla::LogLevel::Debug) diff --git a/dom/network/UDPSocketChild.cpp b/dom/network/UDPSocketChild.cpp index 03c01aae87..dd24003ffc 100644 --- a/dom/network/UDPSocketChild.cpp +++ b/dom/network/UDPSocketChild.cpp @@ -17,12 +17,10 @@ using mozilla::net::gNeckoChild; -#if defined(PR_LOGGING) // // set NSPR_LOG_MODULES=UDPSocket:5 // extern PRLogModuleInfo *gUDPSocketLog; -#endif #define UDPSOCKET_LOG(args) MOZ_LOG(gUDPSocketLog, mozilla::LogLevel::Debug, args) #define UDPSOCKET_LOG_ENABLED() MOZ_LOG_TEST(gUDPSocketLog, mozilla::LogLevel::Debug) @@ -341,7 +339,7 @@ UDPSocketChild::RecvCallbackOpened(const UDPAddressInfo& aAddressInfo) UDPSOCKET_LOG(("%s: %s:%u", __FUNCTION__, mLocalAddress.get(), mLocalPort)); nsresult rv = mSocket->CallListenerOpened(); - mozilla::unused << NS_WARN_IF(NS_FAILED(rv)); + mozilla::Unused << NS_WARN_IF(NS_FAILED(rv)); return true; } @@ -350,7 +348,7 @@ bool UDPSocketChild::RecvCallbackClosed() { nsresult rv = mSocket->CallListenerClosed(); - mozilla::unused << NS_WARN_IF(NS_FAILED(rv)); + mozilla::Unused << NS_WARN_IF(NS_FAILED(rv)); return true; } @@ -363,7 +361,7 @@ UDPSocketChild::RecvCallbackReceivedData(const UDPAddressInfo& aAddressInfo, aAddressInfo.addr().get(), aAddressInfo.port(), aData.Length())); nsresult rv = mSocket->CallListenerReceivedData(aAddressInfo.addr(), aAddressInfo.port(), aData.Elements(), aData.Length()); - mozilla::unused << NS_WARN_IF(NS_FAILED(rv)); + mozilla::Unused << NS_WARN_IF(NS_FAILED(rv)); return true; } @@ -375,7 +373,7 @@ UDPSocketChild::RecvCallbackError(const nsCString& aMessage, { UDPSOCKET_LOG(("%s: %s:%s:%u", __FUNCTION__, aMessage.get(), aFilename.get(), aLineNumber)); nsresult rv = mSocket->CallListenerError(aMessage, aFilename, aLineNumber); - mozilla::unused << NS_WARN_IF(NS_FAILED(rv)); + mozilla::Unused << NS_WARN_IF(NS_FAILED(rv)); return true; } diff --git a/dom/network/UDPSocketParent.cpp b/dom/network/UDPSocketParent.cpp index 3741972aac..1c9d0edef4 100644 --- a/dom/network/UDPSocketParent.cpp +++ b/dom/network/UDPSocketParent.cpp @@ -22,12 +22,10 @@ #include "nsIScriptSecurityManager.h" #include "mozilla/ipc/PBackgroundParent.h" -#if defined(PR_LOGGING) // // set NSPR_LOG_MODULES=UDPSocket:5 // extern PRLogModuleInfo *gUDPSocketLog; -#endif #define UDPSOCKET_LOG(args) MOZ_LOG(gUDPSocketLog, mozilla::LogLevel::Debug, args) #define UDPSOCKET_LOG_ENABLED() MOZ_LOG_TEST(gUDPSocketLog, mozilla::LogLevel::Debug) @@ -107,7 +105,7 @@ UDPSocketParent::Init(const IPC::Principal& aPrincipal, MOZ_ASSERT_IF(mBackgroundManager, !aPrincipal); // will be used once we move all UDPSocket to PBackground, or // if we add in Principal checking for mtransport - unused << mBackgroundManager; + Unused << mBackgroundManager; mPrincipal = aPrincipal; if (net::UsingNeckoIPCSecurity() && @@ -193,7 +191,7 @@ UDPSocketParent::RecvBind(const UDPAddressInfo& aAddressInfo, } UDPSOCKET_LOG(("%s: SendCallbackOpened: %s:%u", __FUNCTION__, addr.get(), port)); - mozilla::unused << SendCallbackOpened(UDPAddressInfo(addr, port)); + mozilla::Unused << SendCallbackOpened(UDPAddressInfo(addr, port)); return true; } @@ -394,7 +392,7 @@ UDPSocketParent::RecvClose() nsresult rv = mSocket->Close(); mSocket = nullptr; - mozilla::unused << NS_WARN_IF(NS_FAILED(rv)); + mozilla::Unused << NS_WARN_IF(NS_FAILED(rv)); return true; } @@ -402,7 +400,7 @@ UDPSocketParent::RecvClose() bool UDPSocketParent::RecvRequestDelete() { - mozilla::unused << Send__delete__(this); + mozilla::Unused << Send__delete__(this); return true; } @@ -467,7 +465,7 @@ UDPSocketParent::OnPacketReceived(nsIUDPSocket* aSocket, nsIUDPMessage* aMessage infallibleArray.SwapElements(fallibleArray); // compose callback - mozilla::unused << SendCallbackReceivedData(UDPAddressInfo(ip, port), infallibleArray); + mozilla::Unused << SendCallbackReceivedData(UDPAddressInfo(ip, port), infallibleArray); return NS_OK; } @@ -477,7 +475,7 @@ UDPSocketParent::OnStopListening(nsIUDPSocket* aSocket, nsresult aStatus) { // underlying socket is dead, send state update to child process if (mIPCOpen) { - mozilla::unused << SendCallbackClosed(); + mozilla::Unused << SendCallbackClosed(); } return NS_OK; } @@ -489,7 +487,7 @@ UDPSocketParent::FireInternalError(uint32_t aLineNo) return; } - mozilla::unused << SendCallbackError(NS_LITERAL_CSTRING("Internal error"), + mozilla::Unused << SendCallbackError(NS_LITERAL_CSTRING("Internal error"), NS_LITERAL_CSTRING(__FILE__), aLineNo); } diff --git a/dom/nfc/gonk/NfcMessageHandler.cpp b/dom/nfc/gonk/NfcMessageHandler.cpp index 46f41ecab3..f8b7c3574f 100644 --- a/dom/nfc/gonk/NfcMessageHandler.cpp +++ b/dom/nfc/gonk/NfcMessageHandler.cpp @@ -55,7 +55,7 @@ NfcMessageHandler::Marshall(Parcel& aParcel, const CommandOptions& aOptions) bool NfcMessageHandler::Unmarshall(const Parcel& aParcel, EventOptions& aOptions) { - mozilla::unused << htonl(aParcel.readInt32()); // parcel size + mozilla::Unused << htonl(aParcel.readInt32()); // parcel size int32_t type = aParcel.readInt32(); bool isNtf = type >> 31; int32_t msgType = type & ~(1 << 31); diff --git a/dom/nfc/gonk/NfcService.cpp b/dom/nfc/gonk/NfcService.cpp index 22f1c59756..1c26610c27 100644 --- a/dom/nfc/gonk/NfcService.cpp +++ b/dom/nfc/gonk/NfcService.cpp @@ -108,7 +108,7 @@ NfcConsumer::Start() // If we could not cleanup properly before and an old // instance of the daemon is still running, we kill it // here. - unused << NS_WARN_IF(property_set("ctl.stop", "nfcd") < 0); + Unused << NS_WARN_IF(property_set("ctl.stop", "nfcd") < 0); mHandler = new NfcMessageHandler(); @@ -592,8 +592,8 @@ NfcService::Shutdown() } // |CleanupRunnable| will take care of these pointers - unused << mNfcConsumer.forget(); - unused << mThread.forget(); + Unused << mNfcConsumer.forget(); + Unused << mThread.forget(); return NS_OK; } diff --git a/dom/notification/Notification.cpp b/dom/notification/Notification.cpp index d5cca36e9e..5d05aef2e3 100644 --- a/dom/notification/Notification.cpp +++ b/dom/notification/Notification.cpp @@ -171,7 +171,7 @@ public: result); n->SetStoredState(true); - unused << NS_WARN_IF(result.Failed()); + Unused << NS_WARN_IF(result.Failed()); if (!result.Failed()) { notifications.AppendElement(n.forget()); } @@ -221,7 +221,7 @@ public: rv = notificationStorage->Get(mOrigin, mTag, mCallback); //XXXnsm Is it guaranteed mCallback will be called in case of failure? - unused << NS_WARN_IF(NS_FAILED(rv)); + Unused << NS_WARN_IF(NS_FAILED(rv)); return rv; } }; @@ -1164,13 +1164,13 @@ NotificationObserver::Observe(nsISupports* aSubject, const char* aTopic, IPC::Principal(mPrincipal)); return NS_OK; } else if (!strcmp("alertsettingscallback", aTopic)) { - nsCOMPtr obs = mozilla::services::GetObserverService(); - if (!obs) { - return NS_ERROR_FAILURE; + if (XRE_IsParentProcess()) { + return Notification::OpenSettings(mPrincipal); } - - // Notify other observers so they can show settings UI. - obs->NotifyObservers(mPrincipal, "notifications-open-settings", nullptr); + // `ContentParent::RecvOpenNotificationSettings` notifies observers in the + // parent process. + ContentChild::GetSingleton()->SendOpenNotificationSettings( + IPC::Principal(mPrincipal)); return NS_OK; } @@ -1794,7 +1794,7 @@ public: result); n->SetStoredState(true); - unused << NS_WARN_IF(result.Failed()); + Unused << NS_WARN_IF(result.Failed()); if (!result.Failed()) { notifications.AppendElement(n.forget()); } @@ -2376,6 +2376,19 @@ Notification::RemovePermission(nsIPrincipal* aPrincipal) return NS_OK; } +/* static */ nsresult +Notification::OpenSettings(nsIPrincipal* aPrincipal) +{ + MOZ_ASSERT(XRE_IsParentProcess()); + nsCOMPtr obs = mozilla::services::GetObserverService(); + if (!obs) { + return NS_ERROR_FAILURE; + } + // Notify other observers so they can show settings UI. + obs->NotifyObservers(aPrincipal, "notifications-open-settings", nullptr); + return NS_OK; +} + } // namespace dom } // namespace mozilla diff --git a/dom/notification/Notification.h b/dom/notification/Notification.h index 76f06cbbf6..e48a842d92 100644 --- a/dom/notification/Notification.h +++ b/dom/notification/Notification.h @@ -287,6 +287,7 @@ public: bool DispatchNotificationClickEvent(); static nsresult RemovePermission(nsIPrincipal* aPrincipal); + static nsresult OpenSettings(nsIPrincipal* aPrincipal); protected: Notification(nsIGlobalObject* aGlobal, const nsAString& aID, const nsAString& aTitle, const nsAString& aBody, diff --git a/dom/plugins/base/nsNPAPIPluginInstance.cpp b/dom/plugins/base/nsNPAPIPluginInstance.cpp index 034f4391fb..7b1d696001 100644 --- a/dom/plugins/base/nsNPAPIPluginInstance.cpp +++ b/dom/plugins/base/nsNPAPIPluginInstance.cpp @@ -565,7 +565,7 @@ nsresult nsNPAPIPluginInstance::SetWindow(NPWindow* window) // That is somewhat complex to check, so we just use "unused" // to suppress any compiler warnings in build configurations // where the logging is a no-op. - mozilla::unused << error; + mozilla::Unused << error; mInPluginInitCall = oldVal; diff --git a/dom/plugins/base/nsPluginTags.cpp b/dom/plugins/base/nsPluginTags.cpp index 3a2eeae6fa..b5a1f7c42e 100644 --- a/dom/plugins/base/nsPluginTags.cpp +++ b/dom/plugins/base/nsPluginTags.cpp @@ -163,7 +163,7 @@ IsEnabledStateLockedForPlugin(nsIInternalPluginTag* aTag, return NS_ERROR_FAILURE; } - unused << prefs->PrefIsLocked(GetStatePrefNameForPlugin(aTag).get(), + Unused << prefs->PrefIsLocked(GetStatePrefNameForPlugin(aTag).get(), aIsEnabledStateLocked); return NS_OK; diff --git a/dom/plugins/ipc/BrowserStreamParent.cpp b/dom/plugins/ipc/BrowserStreamParent.cpp index 71531c0ef7..f3eade194d 100644 --- a/dom/plugins/ipc/BrowserStreamParent.cpp +++ b/dom/plugins/ipc/BrowserStreamParent.cpp @@ -55,7 +55,7 @@ BrowserStreamParent::RecvAsyncNPP_NewStreamResult(const NPError& rv, if (mState == DEFERRING_DESTROY) { // We've been asked to destroy ourselves before init was complete. mState = DYING; - unused << SendNPP_DestroyStream(mDeferredDestroyReason); + Unused << SendNPP_DestroyStream(mDeferredDestroyReason); return true; } @@ -73,7 +73,7 @@ BrowserStreamParent::RecvAsyncNPP_NewStreamResult(const NPError& rv, if (error != NPERR_NO_ERROR) { surrogate->DestroyAsyncStream(mStream); - unused << PBrowserStreamParent::Send__delete__(this); + Unused << PBrowserStreamParent::Send__delete__(this); } return true; @@ -151,7 +151,7 @@ BrowserStreamParent::NPP_DestroyStream(NPReason reason) mDeferredDestroyReason = reason; } else { mState = DYING; - unused << SendNPP_DestroyStream(reason); + Unused << SendNPP_DestroyStream(reason); } } @@ -213,7 +213,7 @@ BrowserStreamParent::StreamAsFile(const char* fname) nsNPAPIPlugin::RetainStream(mStream, getter_AddRefs(mStreamPeer)); } - unused << SendNPP_StreamAsFile(nsCString(fname)); + Unused << SendNPP_StreamAsFile(nsCString(fname)); return; } diff --git a/dom/plugins/ipc/PluginInstanceParent.cpp b/dom/plugins/ipc/PluginInstanceParent.cpp index bd67c6c7ce..a6fb579b9b 100644 --- a/dom/plugins/ipc/PluginInstanceParent.cpp +++ b/dom/plugins/ipc/PluginInstanceParent.cpp @@ -848,7 +848,7 @@ PluginInstanceParent::EndUpdateBackground(gfxContext* aCtx, XSync(DefaultXDisplay(), False); #endif - unused << SendUpdateBackground(BackgroundDescriptor(), aRect); + Unused << SendUpdateBackground(BackgroundDescriptor(), aRect); return NS_OK; } @@ -901,7 +901,7 @@ PluginInstanceParent::DestroyBackground() // If this fails, there's no problem: |bd| will be destroyed along // with the old background surface. - unused << SendPPluginBackgroundDestroyerConstructor(pbd); + Unused << SendPPluginBackgroundDestroyerConstructor(pbd); } mozilla::plugins::SurfaceDescriptor @@ -1183,7 +1183,7 @@ PluginInstanceParent::NPP_URLRedirectNotify(const char* url, int32_t status, return; PStreamNotifyParent* streamNotify = static_cast(notifyData); - unused << streamNotify->SendRedirectNotify(NullableString(url), status); + Unused << streamNotify->SendRedirectNotify(NullableString(url), status); } int16_t @@ -1433,7 +1433,7 @@ PluginInstanceParent::NPP_NewStream(NPMIMEType type, NPStream* stream, err = NPERR_GENERIC_ERROR; } if (NPERR_NO_ERROR != err) { - unused << PBrowserStreamParent::Send__delete__(bs); + Unused << PBrowserStreamParent::Send__delete__(bs); } } @@ -1556,7 +1556,7 @@ PluginInstanceParent::NPP_URLNotify(const char* url, NPReason reason, PStreamNotifyParent* streamNotify = static_cast(notifyData); - unused << PStreamNotifyParent::Send__delete__(streamNotify, reason); + Unused << PStreamNotifyParent::Send__delete__(streamNotify, reason); } bool @@ -1838,7 +1838,7 @@ PluginInstanceParent::PluginWindowHookProc(HWND hWnd, switch (message) { case WM_SETFOCUS: // Let the child plugin window know it should take focus. - unused << self->CallSetPluginFocus(); + Unused << self->CallSetPluginFocus(); break; case WM_CLOSE: diff --git a/dom/plugins/ipc/PluginInstanceParent.h b/dom/plugins/ipc/PluginInstanceParent.h index d9bcfea50a..9499c1ade9 100644 --- a/dom/plugins/ipc/PluginInstanceParent.h +++ b/dom/plugins/ipc/PluginInstanceParent.h @@ -307,7 +307,7 @@ public: gfxContext** aCtx); nsresult EndUpdateBackground(gfxContext* aCtx, const nsIntRect& aRect); - void DidComposite() { unused << SendNPP_DidComposite(); } + void DidComposite() { Unused << SendNPP_DidComposite(); } virtual PluginAsyncSurrogate* GetAsyncSurrogate() override; diff --git a/dom/plugins/ipc/PluginModuleChild.cpp b/dom/plugins/ipc/PluginModuleChild.cpp index c33d7569ff..ca8a058757 100644 --- a/dom/plugins/ipc/PluginModuleChild.cpp +++ b/dom/plugins/ipc/PluginModuleChild.cpp @@ -2534,6 +2534,6 @@ PluginModuleChild::RecvGatherProfile() profileCString = nsCString("", 0); } - unused << SendProfile(profileCString); + Unused << SendProfile(profileCString); return true; } diff --git a/dom/plugins/ipc/PluginModuleParent.cpp b/dom/plugins/ipc/PluginModuleParent.cpp index a712d753c7..3a75426af4 100755 --- a/dom/plugins/ipc/PluginModuleParent.cpp +++ b/dom/plugins/ipc/PluginModuleParent.cpp @@ -878,7 +878,7 @@ PluginModuleParent::TimeoutChanged(const char* aPref, void* aModule) // The timeout value used by the child for its parent MOZ_ASSERT(module->IsChrome()); int32_t timeoutSecs = Preferences::GetInt(kParentTimeoutPref, 0); - unused << static_cast(module)->SendSetParentHangTimeout(timeoutSecs); + Unused << static_cast(module)->SendSetParentHangTimeout(timeoutSecs); } else if (!strcmp(aPref, kContentTimeoutPref)) { MOZ_ASSERT(!module->IsChrome()); int32_t timeoutSecs = Preferences::GetInt(kContentTimeoutPref, 0); @@ -1712,7 +1712,7 @@ PluginModuleParent::SetPluginFuncs(NPPluginFuncs* aFuncs) // Provide 'NPP_URLRedirectNotify', 'NPP_ClearSiteData', and // 'NPP_GetSitesWithData' functionality if it is supported by the plugin. bool urlRedirectSupported = false; - unused << CallOptionalFunctionsSupported(&urlRedirectSupported, + Unused << CallOptionalFunctionsSupported(&urlRedirectSupported, &mClearSiteDataSupported, &mGetSitesWithDataSupported); if (urlRedirectSupported) { @@ -1757,7 +1757,7 @@ PluginModuleParent::NPP_Destroy(NPP instance, NPError retval = parentInstance->Destroy(); instance->pdata = nullptr; - unused << PluginInstanceParent::Call__delete__(parentInstance); + Unused << PluginInstanceParent::Call__delete__(parentInstance); return retval; } @@ -2100,7 +2100,7 @@ PluginModuleChromeParent::CachedSettingChanged() { PluginSettings settings; GetSettings(&settings); - unused << SendSettingChanged(settings); + Unused << SendSettingChanged(settings); } /* static */ void @@ -2353,7 +2353,7 @@ PluginModuleChromeParent::RecvNP_InitializeResult(const NPError& aError) if (NS_SUCCEEDED(mozilla::widget::GetAudioSessionData(id, sessionName, iconPath))) { - unused << SendSetAudioSessionData(id, sessionName, iconPath); + Unused << SendSetAudioSessionData(id, sessionName, iconPath); } #endif @@ -2822,7 +2822,7 @@ void PluginModuleParent::ProcessRemoteNativeEventsInInterruptCall() { #if defined(OS_WIN) - unused << SendProcessNativeEventsInInterruptCall(); + Unused << SendProcessNativeEventsInInterruptCall(); return; #endif NS_NOTREACHED( @@ -3118,9 +3118,9 @@ PluginProfilerObserver::Observe(nsISupports *aSubject, params->GetInterval(&interval); const nsTArray& features = params->GetFeatures(); const nsTArray& threadFilterNames = params->GetThreadFilterNames(); - unused << mPmp->SendStartProfiler(entries, interval, features, threadFilterNames); + Unused << mPmp->SendStartProfiler(entries, interval, features, threadFilterNames); } else if (!strcmp(aTopic, "profiler-stopped")) { - unused << mPmp->SendStopProfiler(); + Unused << mPmp->SendStopProfiler(); } else if (!strcmp(aTopic, "profiler-subprocess-gather")) { RefPtr gatherer = static_cast(aSubject); mPmp->GatherAsyncProfile(gatherer); @@ -3161,7 +3161,7 @@ PluginModuleChromeParent::GatherAsyncProfile(ProfileGatherer* aGatherer) { mGatherer = aGatherer; mGatherer->WillGatherOOPProfile(); - unused << SendGatherProfile(); + Unused << SendGatherProfile(); } void diff --git a/dom/plugins/ipc/PluginScriptableObjectParent.cpp b/dom/plugins/ipc/PluginScriptableObjectParent.cpp index 17498b7f38..d7b31567a6 100644 --- a/dom/plugins/ipc/PluginScriptableObjectParent.cpp +++ b/dom/plugins/ipc/PluginScriptableObjectParent.cpp @@ -715,7 +715,7 @@ PluginScriptableObjectParent::Unprotect() if (mType == LocalObject) { if (--mProtectCount == 0) { - unused << PluginScriptableObjectParent::Send__delete__(this); + Unused << PluginScriptableObjectParent::Send__delete__(this); } } } @@ -735,7 +735,7 @@ PluginScriptableObjectParent::DropNPObject() instance->UnregisterNPObject(mObject); mObject = nullptr; - unused << SendUnprotect(); + Unused << SendUnprotect(); } void diff --git a/dom/plugins/ipc/PluginWidgetChild.cpp b/dom/plugins/ipc/PluginWidgetChild.cpp index be19eb450c..6c0c343306 100644 --- a/dom/plugins/ipc/PluginWidgetChild.cpp +++ b/dom/plugins/ipc/PluginWidgetChild.cpp @@ -41,7 +41,7 @@ PluginWidgetChild::ProxyShutdown() mWidget = nullptr; auto tab = static_cast(Manager()); if (!tab->IsDestroyed()) { - unused << Send__delete__(this); + Unused << Send__delete__(this); } } } diff --git a/dom/presentation/provider/MulticastDNSDeviceProvider.cpp b/dom/presentation/provider/MulticastDNSDeviceProvider.cpp index 49bc704104..b4359220a7 100644 --- a/dom/presentation/provider/MulticastDNSDeviceProvider.cpp +++ b/dom/presentation/provider/MulticastDNSDeviceProvider.cpp @@ -54,7 +54,7 @@ GetAndroidDeviceName(nsACString& aRetVal) nsCOMPtr infoService = do_GetService("@mozilla.org/system-info;1"); MOZ_ASSERT(infoService, "Could not find a system info service"); - unused << NS_WARN_IF(NS_FAILED(infoService->GetPropertyAsACString( + Unused << NS_WARN_IF(NS_FAILED(infoService->GetPropertyAsACString( NS_LITERAL_STRING("device"), aRetVal))); } #endif // MOZ_WIDGET_ANDROID @@ -203,11 +203,11 @@ MulticastDNSDeviceProvider::Init() // FIXME: Bug 1185806 - Provide a common device name setting. if (mServiceName.IsEmpty()) { GetAndroidDeviceName(mServiceName); - unused << Preferences::SetCString(PREF_PRESENTATION_DEVICE_NAME, mServiceName); + Unused << Preferences::SetCString(PREF_PRESENTATION_DEVICE_NAME, mServiceName); } #endif // MOZ_WIDGET_ANDROID - unused << mPresentationServer->SetId(mServiceName); + Unused << mPresentationServer->SetId(mServiceName); if (mDiscoveryEnabled && NS_WARN_IF(NS_FAILED(rv = ForceDiscovery()))) { return rv; @@ -337,7 +337,7 @@ MulticastDNSDeviceProvider::StopDiscovery(nsresult aReason) MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(mDiscoveryTimer); - unused << mDiscoveryTimer->Cancel(); + Unused << mDiscoveryTimer->Cancel(); if (mDiscoveryRequest) { mDiscoveryRequest->Cancel(aReason); @@ -383,7 +383,7 @@ MulticastDNSDeviceProvider::AddDevice(const nsACString& aId, nsCOMPtr listener; if (NS_SUCCEEDED(GetListener(getter_AddRefs(listener))) && listener) { - unused << listener->AddDevice(device); + Unused << listener->AddDevice(device); } mDevices.AppendElement(device); @@ -411,7 +411,7 @@ MulticastDNSDeviceProvider::UpdateDevice(const uint32_t aIndex, nsCOMPtr listener; if (NS_SUCCEEDED(GetListener(getter_AddRefs(listener))) && listener) { - unused << listener->UpdateDevice(device); + Unused << listener->UpdateDevice(device); } return NS_OK; @@ -434,7 +434,7 @@ MulticastDNSDeviceProvider::RemoveDevice(const uint32_t aIndex) nsCOMPtr listener; if (NS_SUCCEEDED(GetListener(getter_AddRefs(listener))) && listener) { - unused << listener->RemoveDevice(device); + Unused << listener->RemoveDevice(device); } return NS_OK; @@ -580,7 +580,7 @@ MulticastDNSDeviceProvider::ForceDiscovery() // if it's already discovering, extend existing discovery timeout. if (mIsDiscovering) { - unused << mDiscoveryTimer->Cancel(); + Unused << mDiscoveryTimer->Cancel(); NS_WARN_IF(NS_FAILED(mDiscoveryTimer->Init(this, mDiscveryTimeoutMs, @@ -885,7 +885,7 @@ MulticastDNSDeviceProvider::OnSessionRequest(nsITCPDeviceInfo* aDeviceInfo, MOZ_ASSERT(NS_IsMainThread()); nsAutoCString address; - unused << aDeviceInfo->GetAddress(address); + Unused << aDeviceInfo->GetAddress(address); LOG_I("OnSessionRequest: %s", address.get()); @@ -898,9 +898,9 @@ MulticastDNSDeviceProvider::OnSessionRequest(nsITCPDeviceInfo* aDeviceInfo, // this device will not be listed in available device list and cannot // be used for requesting session. nsAutoCString id; - unused << aDeviceInfo->GetId(id); + Unused << aDeviceInfo->GetId(id); uint16_t port; - unused << aDeviceInfo->GetPort(&port); + Unused << aDeviceInfo->GetPort(&port); device = new Device(id, /* aName = */ id, @@ -913,7 +913,7 @@ MulticastDNSDeviceProvider::OnSessionRequest(nsITCPDeviceInfo* aDeviceInfo, nsCOMPtr listener; if (NS_SUCCEEDED(GetListener(getter_AddRefs(listener))) && listener) { - unused << listener->OnSessionRequest(device, aUrl, aPresentationId, + Unused << listener->OnSessionRequest(device, aUrl, aPresentationId, aControlChannel); } diff --git a/dom/speakermanager/SpeakerManagerService.cpp b/dom/speakermanager/SpeakerManagerService.cpp index 78e7902496..4c2f8348c0 100644 --- a/dom/speakermanager/SpeakerManagerService.cpp +++ b/dom/speakermanager/SpeakerManagerService.cpp @@ -128,7 +128,7 @@ SpeakerManagerService::Notify() nsTArray children; ContentParent::GetAll(children); for (uint32_t i = 0; i < children.Length(); i++) { - unused << children[i]->SendSpeakerManagerNotify(); + Unused << children[i]->SendSpeakerManagerNotify(); } for (uint32_t i = 0; i < mRegisteredSpeakerManagers.Length(); i++) { diff --git a/dom/storage/DOMStorageCache.cpp b/dom/storage/DOMStorageCache.cpp index a7787d816f..61b7d86559 100644 --- a/dom/storage/DOMStorageCache.cpp +++ b/dom/storage/DOMStorageCache.cpp @@ -533,7 +533,7 @@ DOMStorageCache::RemoveItem(const DOMStorage* aStorage, const nsAString& aKey, // Recalculate the cached data size const int64_t delta = -(static_cast(aOld.Length()) + static_cast(aKey.Length())); - unused << ProcessUsageDelta(aStorage, delta); + Unused << ProcessUsageDelta(aStorage, delta); data.mKeys.Remove(aKey); if (Persist(aStorage)) { @@ -572,7 +572,7 @@ DOMStorageCache::Clear(const DOMStorage* aStorage) bool hadData = !!data.mKeys.Count(); if (hadData) { - unused << ProcessUsageDelta(aStorage, -data.mOriginQuotaUsage); + Unused << ProcessUsageDelta(aStorage, -data.mOriginQuotaUsage); data.mKeys.Clear(); } diff --git a/dom/storage/DOMStorageIPC.cpp b/dom/storage/DOMStorageIPC.cpp index 7bd72eff60..4b13fc490a 100644 --- a/dom/storage/DOMStorageIPC.cpp +++ b/dom/storage/DOMStorageIPC.cpp @@ -309,7 +309,7 @@ private: if (db) { InfallibleTArray scopes; db->GetScopesHavingData(&scopes); - mozilla::unused << mParent->SendScopesHavingData(scopes); + mozilla::Unused << mParent->SendScopesHavingData(scopes); } // We need to check if the device is in a low disk space situation, so @@ -323,7 +323,7 @@ private: bool lowDiskSpace = false; diskSpaceWatcher->GetIsDiskFull(&lowDiskSpace); if (lowDiskSpace) { - mozilla::unused << mParent->SendObserve( + mozilla::Unused << mParent->SendObserve( nsDependentCString("low-disk-space"), EmptyCString()); } @@ -519,7 +519,7 @@ DOMStorageDBParent::RecvAsyncAddItem(const nsCString& aScope, nsresult rv = db->AsyncAddItem(NewCache(aScope), aKey, aValue); if (NS_FAILED(rv) && mIPCOpen) { - mozilla::unused << SendError(rv); + mozilla::Unused << SendError(rv); } return true; @@ -537,7 +537,7 @@ DOMStorageDBParent::RecvAsyncUpdateItem(const nsCString& aScope, nsresult rv = db->AsyncUpdateItem(NewCache(aScope), aKey, aValue); if (NS_FAILED(rv) && mIPCOpen) { - mozilla::unused << SendError(rv); + mozilla::Unused << SendError(rv); } return true; @@ -554,7 +554,7 @@ DOMStorageDBParent::RecvAsyncRemoveItem(const nsCString& aScope, nsresult rv = db->AsyncRemoveItem(NewCache(aScope), aKey); if (NS_FAILED(rv) && mIPCOpen) { - mozilla::unused << SendError(rv); + mozilla::Unused << SendError(rv); } return true; @@ -570,7 +570,7 @@ DOMStorageDBParent::RecvAsyncClear(const nsCString& aScope) nsresult rv = db->AsyncClear(NewCache(aScope)); if (NS_FAILED(rv) && mIPCOpen) { - mozilla::unused << SendError(rv); + mozilla::Unused << SendError(rv); } return true; @@ -599,7 +599,7 @@ DOMStorageDBParent::Observe(const char* aTopic, if (!(static_cast(Manager())->IsNuwaProcess() && ContentParent::IsNuwaReady())) { #endif - mozilla::unused << SendObserve(nsDependentCString(aTopic), + mozilla::Unused << SendObserve(nsDependentCString(aTopic), nsCString(aScopePrefix)); #ifdef MOZ_NUWA_PROCESS } @@ -659,10 +659,10 @@ private: switch (mType) { case loadItem: - mozilla::unused << mParent->SendLoadItem(mScope, mKey, mValue); + mozilla::Unused << mParent->SendLoadItem(mScope, mKey, mValue); break; case loadDone: - mozilla::unused << mParent->SendLoadDone(mScope, mRv); + mozilla::Unused << mParent->SendLoadDone(mScope, mRv); break; } @@ -731,7 +731,7 @@ private: return NS_OK; } - mozilla::unused << mParent->SendLoadUsage(mScope, mUsage); + mozilla::Unused << mParent->SendLoadUsage(mScope, mUsage); return NS_OK; } diff --git a/dom/svg/nsSVGElement.cpp b/dom/svg/nsSVGElement.cpp index a8a9ba1e55..371088f77c 100644 --- a/dom/svg/nsSVGElement.cpp +++ b/dom/svg/nsSVGElement.cpp @@ -1358,7 +1358,7 @@ nsSVGElement::UpdateAnimatedContentStyleRule() SMIL_MAPPED_ATTR_STYLERULE_ATOM, animContentStyleRule.get(), ReleaseStyleRule); - unused << animContentStyleRule.forget(); + Unused << animContentStyleRule.forget(); MOZ_ASSERT(rv == NS_OK, "SetProperty failed (or overwrote something)"); } diff --git a/dom/webidl/CameraControl.webidl b/dom/webidl/CameraControl.webidl index 772c9af6d4..8e17792950 100644 --- a/dom/webidl/CameraControl.webidl +++ b/dom/webidl/CameraControl.webidl @@ -109,6 +109,11 @@ dictionary CameraStartRecordingOptions will be left as-is on stopRecording(). If the camera does not support this setting, it will be ignored. */ boolean autoEnableLowLightTorch = false; + + /* If true, a poster JPG will be created from the recording and issued + via the poster event. PosterCreated or PosterFailed recording state + changes will indicate whether or not it was created. */ + boolean createPoster = false; }; /* @@ -243,9 +248,25 @@ interface CameraControl : MediaStream recording limits (see CameraStartRecordingOptions) was reached. event type is CameraStateChangeEvent where: - 'newState' is the new recorder state */ + 'newState' is one of the following states: + 'Started' if the recording has begun capturing data + 'Stopped' when the recording has completed (success and failure) + 'Paused' if the recording is paused + 'Resumed' if the recording is resumed after pausing + 'PosterCreated' if a poster was requested and created + 'PosterFailed' if a poster was requested and failed to create + 'FileSizeLimitReached' if stopped due to file size limit + 'VideoLengthLimitReached' if stopped due to a time limit + 'TrackCompleted' if audio or video track complete when stopping + 'TrackFailed' if audio or video track incomplete when stopping + 'MediaRecorderFailed' if failed due to local error + 'MediaServerFailed' if failed due to media server */ attribute EventHandler onrecorderstatechange; + /* the event dispatched when a poster is successfully captured; it is of the + type BlobEvent, where the data attribute contains the poster. */ + attribute EventHandler onposter; + /* the event dispatched when the viewfinder stops or starts, useful for synchronizing other UI elements. @@ -340,10 +361,21 @@ interface CameraControl : MediaStream DeviceStorage storageArea, DOMString filename); - /* stop precording video. */ + /* stop recording video. */ [Throws] void stopRecording(); + /* pause recording video. The camera remains active but audio and video + frames are no longer saved in the output file. If called when not + recording or already paused, it fails silently. */ + [Throws] + void pauseRecording(); + + /* resume recording video while paused. If called when not recording or + not paused, it fails silently. */ + [Throws] + void resumeRecording(); + /* call in or after the takePicture() onSuccess callback to resume the camera preview stream. */ [Throws] diff --git a/dom/webidl/MediaStream.webidl b/dom/webidl/MediaStream.webidl index a795ad0f54..0dd779c60d 100644 --- a/dom/webidl/MediaStream.webidl +++ b/dom/webidl/MediaStream.webidl @@ -27,10 +27,10 @@ dictionary MediaStreamConstraints { DOMString? peerIdentity = null; }; -// [Exposed=Window, -// Constructor, -// Constructor (MediaStream stream), -// Constructor (sequence tracks)] +[Exposed=Window, + Constructor, + Constructor (MediaStream stream), + Constructor (sequence tracks)] interface MediaStream : EventTarget { readonly attribute DOMString id; sequence getAudioTracks (); diff --git a/dom/webidl/SourceBuffer.webidl b/dom/webidl/SourceBuffer.webidl index 9104d0b69a..a1d9f98cfd 100644 --- a/dom/webidl/SourceBuffer.webidl +++ b/dom/webidl/SourceBuffer.webidl @@ -20,7 +20,7 @@ interface SourceBuffer : EventTarget { [SetterThrows] attribute SourceBufferAppendMode mode; readonly attribute boolean updating; - [NewObject, Throws] + [Throws] readonly attribute TimeRanges buffered; [SetterThrows] attribute double timestampOffset; diff --git a/dom/workers/ServiceWorkerManager.cpp b/dom/workers/ServiceWorkerManager.cpp index a4f6700f66..7788206c52 100644 --- a/dom/workers/ServiceWorkerManager.cpp +++ b/dom/workers/ServiceWorkerManager.cpp @@ -1216,7 +1216,7 @@ private: swm->MaybeRemoveRegistration(mRegistration); // Ensures that the job can't do anything useful from this point on. mRegistration = nullptr; - unused << NS_WARN_IF(NS_FAILED(aRv)); + Unused << NS_WARN_IF(NS_FAILED(aRv)); Done(aRv); } @@ -2175,7 +2175,7 @@ private: UnregisterAndDone() { nsresult rv = Unregister(); - unused << NS_WARN_IF(NS_FAILED(rv)); + Unused << NS_WARN_IF(NS_FAILED(rv)); Done(rv); } }; @@ -3943,7 +3943,7 @@ ServiceWorkerManager::Observe(nsISupports* aSubject, RefPtr runnable = new TeardownRunnable(mActor); nsresult rv = NS_DispatchToMainThread(runnable); - unused << NS_WARN_IF(NS_FAILED(rv)); + Unused << NS_WARN_IF(NS_FAILED(rv)); mActor = nullptr; } return NS_OK; diff --git a/dom/workers/ServiceWorkerManagerChild.cpp b/dom/workers/ServiceWorkerManagerChild.cpp index d8da4df0cb..a4d1d3678e 100644 --- a/dom/workers/ServiceWorkerManagerChild.cpp +++ b/dom/workers/ServiceWorkerManagerChild.cpp @@ -63,7 +63,7 @@ ServiceWorkerManagerChild::RecvNotifyUnregister(const PrincipalInfo& aPrincipalI } nsresult rv = swm->Unregister(principal, nullptr, aScope); - unused << NS_WARN_IF(NS_FAILED(rv)); + Unused << NS_WARN_IF(NS_FAILED(rv)); return true; } diff --git a/dom/workers/ServiceWorkerManagerParent.cpp b/dom/workers/ServiceWorkerManagerParent.cpp index c9ec8a285a..3885e4e510 100644 --- a/dom/workers/ServiceWorkerManagerParent.cpp +++ b/dom/workers/ServiceWorkerManagerParent.cpp @@ -297,7 +297,7 @@ ServiceWorkerManagerParent::RecvShutdown() mService->UnregisterActor(this); mService = nullptr; - unused << Send__delete__(this); + Unused << Send__delete__(this); return true; } diff --git a/dom/workers/ServiceWorkerManagerService.cpp b/dom/workers/ServiceWorkerManagerService.cpp index 24c77fb6d6..7e28a5f949 100644 --- a/dom/workers/ServiceWorkerManagerService.cpp +++ b/dom/workers/ServiceWorkerManagerService.cpp @@ -95,7 +95,7 @@ ServiceWorkerManagerService::PropagateRegistration( MOZ_ASSERT(parent); if (parent->ID() != aParentID) { - unused << parent->SendNotifyRegister(aData); + Unused << parent->SendNotifyRegister(aData); #ifdef DEBUG } else { parentFound = true; @@ -122,7 +122,7 @@ ServiceWorkerManagerService::PropagateSoftUpdate( MOZ_ASSERT(parent); nsString scope(aScope); - unused << parent->SendNotifySoftUpdate(aOriginAttributes, + Unused << parent->SendNotifySoftUpdate(aOriginAttributes, scope); #ifdef DEBUG if (parent->ID() == aParentID) { @@ -160,7 +160,7 @@ ServiceWorkerManagerService::PropagateUnregister( if (parent->ID() != aParentID) { nsString scope(aScope); - unused << parent->SendNotifyUnregister(aPrincipalInfo, scope); + Unused << parent->SendNotifyUnregister(aPrincipalInfo, scope); #ifdef DEBUG } else { parentFound = true; @@ -186,7 +186,7 @@ ServiceWorkerManagerService::PropagateRemove(uint64_t aParentID, if (parent->ID() != aParentID) { nsCString host(aHost); - unused << parent->SendNotifyRemove(host); + Unused << parent->SendNotifyRemove(host); #ifdef DEBUG } else { parentFound = true; @@ -216,7 +216,7 @@ ServiceWorkerManagerService::PropagateRemoveAll(uint64_t aParentID) MOZ_ASSERT(parent); if (parent->ID() != aParentID) { - unused << parent->SendNotifyRemoveAll(); + Unused << parent->SendNotifyRemoveAll(); #ifdef DEBUG } else { parentFound = true; diff --git a/dom/workers/ServiceWorkerPeriodicUpdater.cpp b/dom/workers/ServiceWorkerPeriodicUpdater.cpp index 30c1fa292f..941cc5a54a 100644 --- a/dom/workers/ServiceWorkerPeriodicUpdater.cpp +++ b/dom/workers/ServiceWorkerPeriodicUpdater.cpp @@ -72,7 +72,7 @@ ServiceWorkerPeriodicUpdater::Observe(nsISupports* aSubject, nsTArray children; ContentParent::GetAll(children); for (uint32_t i = 0; i < children.Length(); i++) { - unused << children[i]->SendUpdateServiceWorkerRegistrations(); + Unused << children[i]->SendUpdateServiceWorkerRegistrations(); } } diff --git a/dom/workers/ServiceWorkerScriptCache.cpp b/dom/workers/ServiceWorkerScriptCache.cpp index 80b94cc246..938ca853bb 100644 --- a/dom/workers/ServiceWorkerScriptCache.cpp +++ b/dom/workers/ServiceWorkerScriptCache.cpp @@ -737,7 +737,7 @@ CompareNetwork::OnStreamComplete(nsIStreamLoader* aLoader, nsISupports* aContext nsAutoCString maxScope; // Note: we explicitly don't check for the return value here, because the // absence of the header is not an error condition. - unused << httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("Service-Worker-Allowed"), + Unused << httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("Service-Worker-Allowed"), maxScope); mManager->SetMaxScope(maxScope); diff --git a/dom/xbl/nsBindingManager.cpp b/dom/xbl/nsBindingManager.cpp index 2d7a8f1e9c..19807b4ab2 100644 --- a/dom/xbl/nsBindingManager.cpp +++ b/dom/xbl/nsBindingManager.cpp @@ -407,7 +407,7 @@ nsBindingManager::DoProcessAttachedQueue() NS_ADDREF_THIS(); // We drop our reference to the timer here, since the timer callback is // responsible for releasing the object. - unused << timer.forget().take(); + Unused << timer.forget().take(); } } diff --git a/embedding/components/printingui/ipc/PrintProgressDialogChild.cpp b/embedding/components/printingui/ipc/PrintProgressDialogChild.cpp index fd7ae15ad3..874a5b8ea9 100644 --- a/embedding/components/printingui/ipc/PrintProgressDialogChild.cpp +++ b/embedding/components/printingui/ipc/PrintProgressDialogChild.cpp @@ -9,7 +9,7 @@ class nsIWebProgress; class nsIRequest; -using mozilla::unused; +using mozilla::Unused; namespace mozilla { namespace embedding { @@ -31,7 +31,7 @@ PrintProgressDialogChild::~PrintProgressDialogChild() // progress, it'll drop references to us and destroy us. We need to signal // the parent to decrement its refcount, as well as prevent it from attempting // to contact us further. - unused << Send__delete__(this); + Unused << Send__delete__(this); MOZ_COUNT_DTOR(PrintProgressDialogChild); } @@ -53,7 +53,7 @@ PrintProgressDialogChild::OnStateChange(nsIWebProgress* aProgress, uint32_t aStateFlags, nsresult aStatus) { - unused << SendStateChange(aStateFlags, aStatus); + Unused << SendStateChange(aStateFlags, aStatus); return NS_OK; } @@ -65,7 +65,7 @@ PrintProgressDialogChild::OnProgressChange(nsIWebProgress * aProgress, int32_t aCurTotalProgress, int32_t aMaxTotalProgress) { - unused << SendProgressChange(aCurSelfProgress, aMaxSelfProgress, + Unused << SendProgressChange(aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress); return NS_OK; } @@ -109,7 +109,7 @@ NS_IMETHODIMP PrintProgressDialogChild::GetDocTitle(char16_t* *aDocTitle) NS_IMETHODIMP PrintProgressDialogChild::SetDocTitle(const char16_t* aDocTitle) { mDocTitle = aDocTitle; - unused << SendDocTitleChange(nsString(aDocTitle)); + Unused << SendDocTitleChange(nsString(aDocTitle)); return NS_OK; } @@ -124,7 +124,7 @@ NS_IMETHODIMP PrintProgressDialogChild::GetDocURL(char16_t **aDocURL) NS_IMETHODIMP PrintProgressDialogChild::SetDocURL(const char16_t* aDocURL) { mDocURL = aDocURL; - unused << SendDocURLChange(nsString(aDocURL)); + Unused << SendDocURLChange(nsString(aDocURL)); return NS_OK; } diff --git a/embedding/components/printingui/ipc/PrintProgressDialogParent.cpp b/embedding/components/printingui/ipc/PrintProgressDialogParent.cpp index 47f1d67301..3572cd1bcf 100644 --- a/embedding/components/printingui/ipc/PrintProgressDialogParent.cpp +++ b/embedding/components/printingui/ipc/PrintProgressDialogParent.cpp @@ -7,7 +7,7 @@ #include "nsIWebProgressListener.h" #include "PrintProgressDialogParent.h" -using mozilla::unused; +using mozilla::Unused; namespace mozilla { namespace embedding { @@ -99,7 +99,7 @@ PrintProgressDialogParent::Observe(nsISupports *aSubject, const char *aTopic, const char16_t *aData) { if (mActive) { - unused << SendDialogOpened(); + Unused << SendDialogOpened(); } else { NS_WARNING("The print progress dialog finished opening, but communications " "with the child have been closed."); diff --git a/embedding/components/printingui/ipc/PrintSettingsDialogChild.cpp b/embedding/components/printingui/ipc/PrintSettingsDialogChild.cpp index 0bd10cefe5..ee9c5de59c 100644 --- a/embedding/components/printingui/ipc/PrintSettingsDialogChild.cpp +++ b/embedding/components/printingui/ipc/PrintSettingsDialogChild.cpp @@ -4,7 +4,7 @@ #include "PrintSettingsDialogChild.h" -using mozilla::unused; +using mozilla::Unused; namespace mozilla { namespace embedding { diff --git a/embedding/components/printingui/ipc/PrintingParent.cpp b/embedding/components/printingui/ipc/PrintingParent.cpp index fa3c53620d..85ed1bd44e 100644 --- a/embedding/components/printingui/ipc/PrintingParent.cpp +++ b/embedding/components/printingui/ipc/PrintingParent.cpp @@ -118,9 +118,9 @@ PrintingParent::RecvShowPrintDialog(PPrintSettingsDialogParent* aDialog, // with an async message which frees the child process from // its nested event loop. if (NS_FAILED(rv)) { - mozilla::unused << aDialog->Send__delete__(aDialog, rv); + mozilla::Unused << aDialog->Send__delete__(aDialog, rv); } else { - mozilla::unused << aDialog->Send__delete__(aDialog, resultData); + mozilla::Unused << aDialog->Send__delete__(aDialog, resultData); } return true; } diff --git a/embedding/components/printingui/ipc/nsPrintingProxy.cpp b/embedding/components/printingui/ipc/nsPrintingProxy.cpp index d68e88d451..512fab24e7 100644 --- a/embedding/components/printingui/ipc/nsPrintingProxy.cpp +++ b/embedding/components/printingui/ipc/nsPrintingProxy.cpp @@ -57,7 +57,7 @@ nsPrintingProxy::GetInstance() nsresult nsPrintingProxy::Init() { - mozilla::unused << ContentChild::GetSingleton()->SendPPrintingConstructor(this); + mozilla::Unused << ContentChild::GetSingleton()->SendPPrintingConstructor(this); return NS_OK; } @@ -103,7 +103,7 @@ nsPrintingProxy::ShowPrintDialog(nsIDOMWindow *parent, RefPtr dialog = new PrintSettingsDialogChild(); SendPPrintSettingsDialogConstructor(dialog); - mozilla::unused << SendShowPrintDialog(dialog, pBrowser, inSettings); + mozilla::Unused << SendShowPrintDialog(dialog, pBrowser, inSettings); while(!dialog->returned()) { NS_ProcessNextEvent(nullptr, true); @@ -149,7 +149,7 @@ nsPrintingProxy::ShowProgress(nsIDOMWindow* parent, SendPPrintProgressDialogConstructor(dialogChild); - mozilla::unused << SendShowProgress(pBrowser, dialogChild, + mozilla::Unused << SendShowProgress(pBrowser, dialogChild, isForPrinting, notifyOnOpen, &rv); if (NS_FAILED(rv)) { return rv; @@ -191,7 +191,7 @@ nsPrintingProxy::SavePrintSettings(nsIPrintSettings* aPS, rv = po->SerializeToPrintData(aPS, nullptr, &settings); NS_ENSURE_SUCCESS(rv, rv); - unused << SendSavePrintSettings(settings, aUsePrinterNamePrefix, aFlags, + Unused << SendSavePrintSettings(settings, aUsePrinterNamePrefix, aFlags, &rv); return rv; } diff --git a/extensions/cookie/nsPermissionManager.cpp b/extensions/cookie/nsPermissionManager.cpp index fe7ac538c0..cd51955ebe 100644 --- a/extensions/cookie/nsPermissionManager.cpp +++ b/extensions/cookie/nsPermissionManager.cpp @@ -45,7 +45,7 @@ static nsPermissionManager *gPermissionManager = nullptr; using mozilla::dom::ContentParent; using mozilla::dom::ContentChild; -using mozilla::unused; // ha! +using mozilla::Unused; // ha! static bool IsChildProcess() @@ -780,7 +780,7 @@ nsPermissionManager::AddInternal(nsIPrincipal* aPrincipal, aExpireType == nsIPermissionManager::EXPIRE_SESSION) continue; if (cp->NeedsPermissionsUpdate()) - unused << cp->SendAddPermission(permission); + Unused << cp->SendAddPermission(permission); } } diff --git a/gfx/gl/SharedSurface.cpp b/gfx/gl/SharedSurface.cpp index 5631be1772..db0294bc8a 100644 --- a/gfx/gl/SharedSurface.cpp +++ b/gfx/gl/SharedSurface.cpp @@ -363,7 +363,7 @@ SurfaceFactory::StartRecycling(layers::SharedSurfaceTextureClient* tc) bool didInsert = mRecycleTotalPool.insert(tc); MOZ_RELEASE_ASSERT(didInsert); - mozilla::unused << didInsert; + mozilla::Unused << didInsert; } void @@ -375,7 +375,7 @@ SurfaceFactory::StopRecycling(layers::SharedSurfaceTextureClient* tc) bool didErase = mRecycleTotalPool.erase(tc); MOZ_RELEASE_ASSERT(didErase); - mozilla::unused << didErase; + mozilla::Unused << didErase; } /*static*/ void diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index 5f0a025e78..66853ab04d 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -895,7 +895,7 @@ AsyncPanZoomController::Destroy() PCompositorParent* compositor = GetSharedFrameMetricsCompositor(); // Only send the release message if the SharedFrameMetrics has been created. if (compositor && mSharedFrameMetricsBuffer) { - unused << compositor->SendReleaseSharedCompositorFrameMetrics(mFrameMetrics.GetScrollId(), mAPZCId); + Unused << compositor->SendReleaseSharedCompositorFrameMetrics(mFrameMetrics.GetScrollId(), mAPZCId); } { // scope the lock diff --git a/gfx/layers/client/CompositableClient.h b/gfx/layers/client/CompositableClient.h index 1544a82d74..6e0351f1f8 100644 --- a/gfx/layers/client/CompositableClient.h +++ b/gfx/layers/client/CompositableClient.h @@ -234,7 +234,7 @@ public: TextureDumpMode aCompress); protected: CompositableChild* mCompositableChild; - CompositableForwarder* mForwarder; + RefPtr mForwarder; // Some layers may want to enforce some flags to all their textures // (like disallowing tiling) TextureFlags mTextureFlags; diff --git a/gfx/layers/client/TextureClient.cpp b/gfx/layers/client/TextureClient.cpp index 79e3574b34..f7f18fa431 100644 --- a/gfx/layers/client/TextureClient.cpp +++ b/gfx/layers/client/TextureClient.cpp @@ -8,6 +8,7 @@ #include "Layers.h" // for Layer, etc #include "gfx2DGlue.h" #include "gfxPlatform.h" // for gfxPlatform +#include "mozilla/Atomics.h" #include "mozilla/ipc/SharedMemory.h" // for SharedMemory, etc #include "mozilla/layers/CompositableForwarder.h" #include "mozilla/layers/ISurfaceAllocator.h" @@ -101,7 +102,9 @@ public: TextureChild() : mForwarder(nullptr) + , mMonitor("TextureChild") , mTextureClient(nullptr) + , mDestroyed(false) , mMainThreadOnly(false) , mIPCOpen(false) { @@ -118,7 +121,10 @@ public: void WaitForCompositorRecycle() { - mWaitForRecycle = mTextureClient; + { + MonitorAutoLock mon(mMonitor); + mWaitForRecycle = mDestroyed ? nullptr : mTextureClient; + } RECYCLE_LOG("[CLIENT] Wait for recycle %p\n", mWaitForRecycle.get()); SendClientRecycle(); } @@ -148,10 +154,19 @@ private: Release(); } + void SetTextureClient(TextureClient* aTextureClient) { + MonitorAutoLock mon(mMonitor); + mTextureClient = aTextureClient; + } + RefPtr mForwarder; RefPtr mWaitForRecycle; + + // Monitor protecting mTextureClient. + Monitor mMonitor; TextureClient* mTextureClient; UniquePtr mKeep; + Atomic mDestroyed; bool mMainThreadOnly; bool mIPCOpen; @@ -210,7 +225,7 @@ TextureClient::AddFlags(TextureFlags aFlags) MOZ_ASSERT(!IsSharedWithCompositor() || ((GetFlags() & TextureFlags::RECYCLE) && !IsAddedToCompositableClient())); mFlags |= aFlags; - if (mValid && mActor && mActor->IPCOpen()) { + if (mValid && mActor && !mActor->mDestroyed && mActor->IPCOpen()) { mActor->SendRecycleTexture(mFlags); } } @@ -221,7 +236,7 @@ TextureClient::RemoveFlags(TextureFlags aFlags) MOZ_ASSERT(!IsSharedWithCompositor() || ((GetFlags() & TextureFlags::RECYCLE) && !IsAddedToCompositableClient())); mFlags &= ~aFlags; - if (mValid && mActor && mActor->IPCOpen()) { + if (mValid && mActor && !mActor->mDestroyed && mActor->IPCOpen()) { mActor->SendRecycleTexture(mFlags); } } @@ -234,7 +249,7 @@ TextureClient::RecycleTexture(TextureFlags aFlags) mAddedToCompositableClient = false; if (mFlags != aFlags) { mFlags = aFlags; - if (mValid && mActor && mActor->IPCOpen()) { + if (mValid && mActor && !mActor->mDestroyed && mActor->IPCOpen()) { mActor->SendRecycleTexture(mFlags); } } @@ -276,10 +291,10 @@ bool TextureClient::InitIPDLActor(CompositableForwarder* aForwarder) { MOZ_ASSERT(aForwarder && aForwarder->GetMessageLoop() == mAllocator->GetMessageLoop()); - if (mActor && mActor->GetForwarder() == aForwarder) { + if (mActor && !mActor->mDestroyed && mActor->GetForwarder() == aForwarder) { return true; } - MOZ_ASSERT(!mActor, "Cannot use a texture on several IPC channels."); + MOZ_ASSERT(!mActor || mActor->mDestroyed, "Cannot use a texture on several IPC channels."); SurfaceDescriptor desc; if (!ToSurfaceDescriptor(desc)) { @@ -366,13 +381,18 @@ TextureClient::CreateForDrawing(CompositableForwarder* aAllocator, TextureFlags aTextureFlags, TextureAllocationFlags aAllocFlags) { - LayersBackend parentBackend = aAllocator->GetCompositorBackendType(); - gfx::BackendType moz2DBackend = BackendTypeForBackendSelector(parentBackend, aSelector); + MOZ_ASSERT(aAllocator->IPCOpen()); + if (!aAllocator || !aAllocator->IPCOpen()) { + return nullptr; + } if (!gfx::Factory::AllowedSurfaceSize(aSize)) { return nullptr; } + LayersBackend parentBackend = aAllocator->GetCompositorBackendType(); + gfx::BackendType moz2DBackend = BackendTypeForBackendSelector(parentBackend, aSelector); + RefPtr texture; #if defined(MOZ_WIDGET_GONK) || defined(XP_WIN) @@ -476,6 +496,11 @@ TextureClient::CreateForRawBufferAccess(ISurfaceAllocator* aAllocator, TextureFlags aTextureFlags, TextureAllocationFlags aAllocFlags) { + MOZ_ASSERT(aAllocator->IPCOpen()); + if (!aAllocator || !aAllocator->IPCOpen()) { + return nullptr; + } + if (!gfx::Factory::AllowedSurfaceSize(aSize)) { return nullptr; } @@ -499,6 +524,11 @@ TextureClient::CreateForYCbCr(ISurfaceAllocator* aAllocator, StereoMode aStereoMode, TextureFlags aTextureFlags) { + MOZ_ASSERT(aAllocator->IPCOpen()); + if (!aAllocator || !aAllocator->IPCOpen()) { + return nullptr; + } + if (!gfx::Factory::AllowedSurfaceSize(aYSize)) { return nullptr; } @@ -528,6 +558,11 @@ TextureClient::CreateWithBufferSize(ISurfaceAllocator* aAllocator, size_t aSize, TextureFlags aTextureFlags) { + MOZ_ASSERT(aAllocator->IPCOpen()); + if (!aAllocator || !aAllocator->IPCOpen()) { + return nullptr; + } + RefPtr texture; if (aAllocator->IsSameProcess()) { texture = new MemoryTextureClient(aAllocator, gfx::SurfaceFormat::YUV, @@ -574,6 +609,9 @@ TextureClient::KeepUntilFullDeallocation(UniquePtr aKeep, bool aMainT void TextureClient::ForceRemove(bool sync) { + if (mActor && mActor->mDestroyed) { + mActor = nullptr; + } if (mValid && mActor) { FinalizeOnIPDLThread(); if (sync || GetFlags() & TextureFlags::DEALLOCATE_CLIENT) { @@ -625,15 +663,20 @@ void TextureClient::Finalize() { MOZ_ASSERT(!IsLocked()); + // Always make a temporary strong reference to the actor before we use it, // in case TextureChild::ActorDestroy might null mActor concurrently. RefPtr actor = mActor; if (actor) { + if (actor->mDestroyed) { + actor = nullptr; + return; + } // The actor has a raw pointer to us, actor->mTextureClient. // Null it before RemoveTexture calls to avoid invalid actor->mTextureClient // when calling TextureChild::ActorDestroy() - actor->mTextureClient = nullptr; + actor->SetTextureClient(nullptr); // `actor->mWaitForRecycle` may not be null, as we may be being called from setting // this RefPtr to null! Clearing it here will double-Release() it. diff --git a/gfx/layers/composite/TextureHost.cpp b/gfx/layers/composite/TextureHost.cpp index 310aecc5bf..87d208cf0a 100644 --- a/gfx/layers/composite/TextureHost.cpp +++ b/gfx/layers/composite/TextureHost.cpp @@ -776,7 +776,7 @@ TextureParent::CompositorRecycle() mTextureHost->ClearRecycleCallback(); if (mTextureHost->GetFlags() & TextureFlags::RECYCLE) { - mozilla::unused << SendCompositorRecycle(); + mozilla::Unused << SendCompositorRecycle(); // Don't forget to prepare for the next reycle // if TextureClient request it. mWaitForClientRecycle = mTextureHost; diff --git a/gfx/layers/ipc/CompositorChild.cpp b/gfx/layers/ipc/CompositorChild.cpp index 1ff4a0ba9a..8706e804f5 100644 --- a/gfx/layers/ipc/CompositorChild.cpp +++ b/gfx/layers/ipc/CompositorChild.cpp @@ -29,7 +29,7 @@ using mozilla::layers::LayerTransactionChild; using mozilla::dom::TabChildBase; -using mozilla::unused; +using mozilla::Unused; namespace mozilla { namespace layers { @@ -511,7 +511,7 @@ CompositorChild::RecvRemotePaintIsReady() TabChildBase* tabChildBase = static_cast(iTabChildBase.get()); TabChild* tabChild = static_cast(tabChildBase); MOZ_ASSERT(tabChild); - unused << tabChild->SendRemotePaintIsReady(); + Unused << tabChild->SendRemotePaintIsReady(); mWeakTabChild = nullptr; return true; } @@ -522,7 +522,7 @@ CompositorChild::RequestNotifyAfterRemotePaint(TabChild* aTabChild) { MOZ_ASSERT(aTabChild, "NULL TabChild not allowed in CompositorChild::RequestNotifyAfterRemotePaint"); mWeakTabChild = do_GetWeakReference( static_cast(aTabChild) ); - unused << SendRequestNotifyAfterRemotePaint(); + Unused << SendRequestNotifyAfterRemotePaint(); } void diff --git a/gfx/layers/ipc/CompositorLRU.cpp b/gfx/layers/ipc/CompositorLRU.cpp index ac934a992e..59fafc31e3 100644 --- a/gfx/layers/ipc/CompositorLRU.cpp +++ b/gfx/layers/ipc/CompositorLRU.cpp @@ -22,7 +22,7 @@ mozilla::StaticRefPtr CompositorLRU::sSingleton; void CompositorLRU::Init() { - unused << GetSingleton(); + Unused << GetSingleton(); } CompositorLRU* @@ -55,13 +55,13 @@ CompositorLRU::Add(PCompositorParent* aCompositor, const uint64_t& aId) } if (mLRUSize == 0) { - unused << aCompositor->SendClearCachedResources(aId); + Unused << aCompositor->SendClearCachedResources(aId); return; } if (mLRU.Length() == mLRUSize) { CompositorLayerPair victim = mLRU.LastElement(); - unused << victim.first->SendClearCachedResources(victim.second); + Unused << victim.first->SendClearCachedResources(victim.second); mLRU.RemoveElement(victim); } mLRU.InsertElementAt(0, std::make_pair(aCompositor, aId)); diff --git a/gfx/layers/ipc/CompositorParent.cpp b/gfx/layers/ipc/CompositorParent.cpp index 8a0973e51d..94eff04217 100644 --- a/gfx/layers/ipc/CompositorParent.cpp +++ b/gfx/layers/ipc/CompositorParent.cpp @@ -1093,7 +1093,7 @@ CompositorParent::CompositeToTarget(DrawTarget* aTarget, const gfx::IntRect* aRe // to local pages, hide every plugin associated with the window. if (!hasRemoteContent && BrowserTabsRemoteAutostart() && mCachedPluginData.Length()) { - unused << SendHideAllPlugins((uintptr_t)GetWidget()); + Unused << SendHideAllPlugins((uintptr_t)GetWidget()); mCachedPluginData.Clear(); #if defined(XP_WIN) // Wait for confirmation the hide operation is complete. @@ -1355,7 +1355,7 @@ bool CompositorParent::RecvRequestOverfill() { uint32_t overfillRatio = mCompositor->GetFillRatio(); - unused << SendOverfill(overfillRatio); + Unused << SendOverfill(overfillRatio); return true; } @@ -1839,14 +1839,14 @@ CompositorParent::DidComposite(TimeStamp& aCompositeStart, TimeStamp& aCompositeEnd) { if (mPendingTransaction) { - unused << SendDidComposite(0, mPendingTransaction, aCompositeStart, aCompositeEnd); + Unused << SendDidComposite(0, mPendingTransaction, aCompositeStart, aCompositeEnd); mPendingTransaction = 0; } if (mLayerManager) { nsTArray notifications; mLayerManager->ExtractImageCompositeNotifications(¬ifications); if (!notifications.IsEmpty()) { - unused << ImageBridgeParent::NotifyImageComposites(notifications); + Unused << ImageBridgeParent::NotifyImageComposites(notifications); } } @@ -2039,7 +2039,7 @@ CrossProcessCompositorParent::ShadowLayersUpdated( // Send the 'remote paint ready' message to the content thread if it has already asked. if(mNotifyAfterRemotePaint) { - unused << SendRemotePaintIsReady(); + Unused << SendRemotePaintIsReady(); mNotifyAfterRemotePaint = false; } @@ -2112,7 +2112,7 @@ CompositorParent::UpdatePluginWindowState(uint64_t aId) mPluginsLayerOffset = nsIntPoint(0,0); mPluginsLayerVisibleRegion.SetEmpty(); uintptr_t parentWidget = (uintptr_t)lts.mParent->GetWidget(); - unused << lts.mParent->SendHideAllPlugins(parentWidget); + Unused << lts.mParent->SendHideAllPlugins(parentWidget); lts.mUpdatedPluginDataAvailable = false; PLUGINS_LOG("[%" PRIu64 "] hide all", aId); } else { @@ -2136,7 +2136,7 @@ CompositorParent::UpdatePluginWindowState(uint64_t aId) } mPluginsLayerOffset = offset; mPluginsLayerVisibleRegion = visibleRegion; - unused << + Unused << lts.mParent->SendUpdatePluginConfigurations(offset, visibleRegion, lts.mPluginData); lts.mUpdatedPluginDataAvailable = false; @@ -2165,7 +2165,7 @@ CrossProcessCompositorParent::DidComposite(uint64_t aId, sIndirectLayerTreesLock->AssertCurrentThreadOwns(); LayerTransactionParent *layerTree = sIndirectLayerTrees[aId].mLayerTree; if (layerTree && layerTree->GetPendingTransactionId()) { - unused << SendDidComposite(aId, layerTree->GetPendingTransactionId(), aCompositeStart, aCompositeEnd); + Unused << SendDidComposite(aId, layerTree->GetPendingTransactionId(), aCompositeStart, aCompositeEnd); layerTree->SetPendingTransactionId(0); } } diff --git a/gfx/layers/ipc/ISurfaceAllocator.cpp b/gfx/layers/ipc/ISurfaceAllocator.cpp index d724750fda..c22726b418 100644 --- a/gfx/layers/ipc/ISurfaceAllocator.cpp +++ b/gfx/layers/ipc/ISurfaceAllocator.cpp @@ -99,6 +99,9 @@ ISurfaceAllocator::AllocSurfaceDescriptor(const gfx::IntSize& aSize, gfxContentType aContent, SurfaceDescriptor* aBuffer) { + if (!IPCOpen()) { + return false; + } return AllocSurfaceDescriptorWithCaps(aSize, aContent, DEFAULT_BUFFER_CAPS, aBuffer); } @@ -108,6 +111,9 @@ ISurfaceAllocator::AllocSurfaceDescriptorWithCaps(const gfx::IntSize& aSize, uint32_t aCaps, SurfaceDescriptor* aBuffer) { + if (!IPCOpen()) { + return false; + } gfx::SurfaceFormat format = gfxPlatform::GetPlatform()->Optimal2DFormatForContent(aContent); size_t size = ImageDataSerializer::ComputeMinBufferSize(aSize, format); @@ -154,6 +160,11 @@ ISurfaceAllocator::IsShmem(SurfaceDescriptor* aSurface) void ISurfaceAllocator::DestroySharedSurface(SurfaceDescriptor* aSurface) { + MOZ_ASSERT(IPCOpen()); + if (!IPCOpen()) { + return; + } + MOZ_ASSERT(aSurface); if (!aSurface) { return; @@ -207,6 +218,10 @@ struct ShmemSectionHeapAllocation bool ISurfaceAllocator::AllocShmemSection(size_t aSize, mozilla::layers::ShmemSection* aShmemSection) { + MOZ_ASSERT(IPCOpen()); + if (!IPCOpen()) { + return false; + } // For now we only support sizes of 4. If we want to support different sizes // some more complicated bookkeeping should be added. MOZ_ASSERT(aSize == sSupportedBlockSize); @@ -277,6 +292,11 @@ ISurfaceAllocator::AllocShmemSection(size_t aSize, mozilla::layers::ShmemSection void ISurfaceAllocator::FreeShmemSection(mozilla::layers::ShmemSection& aShmemSection) { + MOZ_ASSERT(IPCOpen()); + if (!IPCOpen()) { + return; + } + MOZ_ASSERT(aShmemSection.size() == sSupportedBlockSize); MOZ_ASSERT(aShmemSection.offset() < sShmemPageSize - sSupportedBlockSize); @@ -301,6 +321,10 @@ ISurfaceAllocator::FreeShmemSection(mozilla::layers::ShmemSection& aShmemSection void ISurfaceAllocator::ShrinkShmemSectionHeap() { + if (!IPCOpen()) { + return; + } + // The loop will terminate as we either increase i, or decrease size // every time through. size_t i = 0; @@ -327,18 +351,33 @@ ISurfaceAllocator::AllocGrallocBuffer(const gfx::IntSize& aSize, uint32_t aUsage, MaybeMagicGrallocBufferHandle* aHandle) { + MOZ_ASSERT(IPCOpen()); + if (!IPCOpen()) { + return false; + } + return SharedBufferManagerChild::GetSingleton()->AllocGrallocBuffer(aSize, aFormat, aUsage, aHandle); } void ISurfaceAllocator::DeallocGrallocBuffer(MaybeMagicGrallocBufferHandle* aHandle) { + MOZ_ASSERT(IPCOpen()); + if (!IPCOpen()) { + return; + } + SharedBufferManagerChild::GetSingleton()->DeallocGrallocBuffer(*aHandle); } void ISurfaceAllocator::DropGrallocBuffer(MaybeMagicGrallocBufferHandle* aHandle) { + MOZ_ASSERT(IPCOpen()); + if (!IPCOpen()) { + return; + } + SharedBufferManagerChild::GetSingleton()->DropGrallocBuffer(*aHandle); } diff --git a/gfx/layers/ipc/ImageBridgeParent.cpp b/gfx/layers/ipc/ImageBridgeParent.cpp index 3b3a6c3fd8..23c4f466ca 100644 --- a/gfx/layers/ipc/ImageBridgeParent.cpp +++ b/gfx/layers/ipc/ImageBridgeParent.cpp @@ -286,7 +286,7 @@ ImageBridgeParent::DeallocPImageContainerParent(PImageContainerParent* actor) void ImageBridgeParent::SendAsyncMessage(const InfallibleTArray& aMessage) { - mozilla::unused << SendParentAsyncMessages(aMessage); + mozilla::Unused << SendParentAsyncMessages(aMessage); } bool diff --git a/gfx/layers/ipc/ImageContainerParent.cpp b/gfx/layers/ipc/ImageContainerParent.cpp index 8d11d80594..f1bc194f46 100644 --- a/gfx/layers/ipc/ImageContainerParent.cpp +++ b/gfx/layers/ipc/ImageContainerParent.cpp @@ -22,7 +22,7 @@ ImageContainerParent::~ImageContainerParent() bool ImageContainerParent::RecvAsyncDelete() { - unused << PImageContainerParent::Send__delete__(this); + Unused << PImageContainerParent::Send__delete__(this); return true; } diff --git a/gfx/layers/ipc/LayerTransactionParent.cpp b/gfx/layers/ipc/LayerTransactionParent.cpp index 8a366e2672..77b5ad6f4f 100644 --- a/gfx/layers/ipc/LayerTransactionParent.cpp +++ b/gfx/layers/ipc/LayerTransactionParent.cpp @@ -1017,7 +1017,7 @@ LayerTransactionParent::SendFenceHandleIfPresent(PTextureParent* aTexture, void LayerTransactionParent::SendAsyncMessage(const InfallibleTArray& aMessage) { - mozilla::unused << SendParentAsyncMessages(aMessage); + mozilla::Unused << SendParentAsyncMessages(aMessage); } void @@ -1025,7 +1025,7 @@ LayerTransactionParent::ReplyRemoveTexture(const OpReplyRemoveTexture& aReply) { InfallibleTArray messages; messages.AppendElement(aReply); - mozilla::unused << SendParentAsyncMessages(messages); + mozilla::Unused << SendParentAsyncMessages(messages); } } // namespace layers diff --git a/gfx/layers/ipc/SharedBufferManagerParent.cpp b/gfx/layers/ipc/SharedBufferManagerParent.cpp index 7698a121ad..5232b2abfb 100644 --- a/gfx/layers/ipc/SharedBufferManagerParent.cpp +++ b/gfx/layers/ipc/SharedBufferManagerParent.cpp @@ -316,7 +316,7 @@ void SharedBufferManagerParent::DropGrallocBufferImpl(mozilla::layers::SurfaceDe NS_ASSERTION(key != -1, "Invalid buffer key"); NS_ASSERTION(mBuffers.count(key) == 1, "No such buffer"); mBuffers.erase(key); - mozilla::unused << SendDropGrallocBuffer(handle); + mozilla::Unused << SendDropGrallocBuffer(handle); #endif } diff --git a/gfx/layers/ipc/SharedPlanarYCbCrImage.cpp b/gfx/layers/ipc/SharedPlanarYCbCrImage.cpp index a697ad14fd..0fab48f0b9 100644 --- a/gfx/layers/ipc/SharedPlanarYCbCrImage.cpp +++ b/gfx/layers/ipc/SharedPlanarYCbCrImage.cpp @@ -65,7 +65,7 @@ SharedPlanarYCbCrImage::GetTextureClient(CompositableClient* aClient) uint8_t* SharedPlanarYCbCrImage::GetBuffer() { - return mTextureClient->GetBuffer(); + return mTextureClient ? mTextureClient->GetBuffer() : nullptr; } already_AddRefed @@ -133,6 +133,9 @@ void SharedPlanarYCbCrImage::SetDataNoCopy(const Data &aData) { MOZ_ASSERT(mTextureClient, "This Image should have already allocated data"); + if (!mTextureClient) { + return; + } mData = aData; mSize = aData.mPicSize; /* SetDataNoCopy is used to update YUV plane offsets without (re)allocating diff --git a/gfx/vr/gfxVR.cpp b/gfx/vr/gfxVR.cpp index f06068fb97..878f56350a 100644 --- a/gfx/vr/gfxVR.cpp +++ b/gfx/vr/gfxVR.cpp @@ -112,7 +112,7 @@ VRHMDManager::ManagerInit() // the >= 0.6.0 one failed to load; otherwise // we might initialize oculus twice bool useOculus050 = true; - unused << useOculus050; + Unused << useOculus050; #if defined(XP_WIN) mgr = new VRHMDManagerOculus(); diff --git a/hal/sandbox/SandboxHal.cpp b/hal/sandbox/SandboxHal.cpp index 65d5c5738b..4699cedd3b 100644 --- a/hal/sandbox/SandboxHal.cpp +++ b/hal/sandbox/SandboxHal.cpp @@ -322,8 +322,8 @@ GetCurrentSwitchState(SwitchDevice aDevice) void NotifySwitchStateFromInputDevice(SwitchDevice aDevice, SwitchState aState) { - unused << aDevice; - unused << aState; + Unused << aDevice; + Unused << aState; NS_RUNTIMEABORT("Only the main process may notify switch state change."); } @@ -545,7 +545,7 @@ public: } void Notify(const BatteryInformation& aBatteryInfo) override { - unused << SendNotifyBatteryChange(aBatteryInfo); + Unused << SendNotifyBatteryChange(aBatteryInfo); } virtual bool @@ -568,7 +568,7 @@ public: } void Notify(const NetworkInformation& aNetworkInfo) override { - unused << SendNotifyNetworkChange(aNetworkInfo); + Unused << SendNotifyNetworkChange(aNetworkInfo); } virtual bool @@ -610,7 +610,7 @@ public: } void Notify(const ScreenConfiguration& aScreenConfiguration) override { - unused << SendNotifyScreenConfigurationChange(aScreenConfiguration); + Unused << SendNotifyScreenConfigurationChange(aScreenConfiguration); } virtual bool @@ -776,7 +776,7 @@ public: } void Notify(const SensorData& aSensorData) override { - unused << SendNotifySensorChange(aSensorData); + Unused << SendNotifySensorChange(aSensorData); } virtual bool @@ -816,7 +816,7 @@ public: void Notify(const WakeLockInformation& aWakeLockInfo) override { - unused << SendNotifyWakeLockChange(aWakeLockInfo); + Unused << SendNotifyWakeLockChange(aWakeLockInfo); } virtual bool @@ -836,7 +836,7 @@ public: void Notify(const SwitchEvent& aSwitchEvent) override { - unused << SendNotifySwitchChange(aSwitchEvent); + Unused << SendNotifySwitchChange(aSwitchEvent); } virtual bool @@ -849,12 +849,12 @@ public: void Notify(const int64_t& aClockDeltaMS) override { - unused << SendNotifySystemClockChange(aClockDeltaMS); + Unused << SendNotifySystemClockChange(aClockDeltaMS); } void Notify(const SystemTimezoneChangeInformation& aSystemTimezoneChangeInfo) override { - unused << SendNotifySystemTimezoneChange(aSystemTimezoneChangeInfo); + Unused << SendNotifySystemTimezoneChange(aSystemTimezoneChangeInfo); } virtual bool diff --git a/ipc/glue/BackgroundImpl.cpp b/ipc/glue/BackgroundImpl.cpp index 8bacd870c7..b701f40c88 100644 --- a/ipc/glue/BackgroundImpl.cpp +++ b/ipc/glue/BackgroundImpl.cpp @@ -750,7 +750,7 @@ private: { if (mTransport) { CRASH_IN_CHILD_PROCESS("Leaking transport!"); - unused << mTransport.forget(); + Unused << mTransport.forget(); } } @@ -1955,7 +1955,7 @@ ChildImpl::OpenMainProcessActorRunnable::Run() parentActor->SetOtherProcessId(base::GetCurrentProcId()); // Now that Open() has succeeded transfer the ownership of the actors to IPDL. - unused << parentActor.forget(); + Unused << parentActor.forget(); auto threadLocalInfo = static_cast(PR_GetThreadPrivate(sThreadLocalIndex)); diff --git a/ipc/glue/CrossProcessMutex_posix.cpp b/ipc/glue/CrossProcessMutex_posix.cpp index b5b8aa5433..3418a785cc 100644 --- a/ipc/glue/CrossProcessMutex_posix.cpp +++ b/ipc/glue/CrossProcessMutex_posix.cpp @@ -117,7 +117,7 @@ CrossProcessMutex::~CrossProcessMutex() if (count == 0) { // Nothing can be done if the destroy fails so ignore return code. - unused << pthread_mutex_destroy(mMutex); + Unused << pthread_mutex_destroy(mMutex); } MOZ_COUNT_DTOR(CrossProcessMutex); diff --git a/ipc/glue/ProcessUtils_linux.cpp b/ipc/glue/ProcessUtils_linux.cpp index cb0132cf66..c4eb81bf8f 100644 --- a/ipc/glue/ProcessUtils_linux.cpp +++ b/ipc/glue/ProcessUtils_linux.cpp @@ -170,7 +170,7 @@ static void CloseFileDescriptors(FdArray& aFds) { for (size_t i = 0; i < aFds.length(); i++) { - unused << HANDLE_EINTR(close(aFds[i])); + Unused << HANDLE_EINTR(close(aFds[i])); } } diff --git a/ipc/glue/Shmem.cpp b/ipc/glue/Shmem.cpp index 97dc099ecb..1f90afe91c 100644 --- a/ipc/glue/Shmem.cpp +++ b/ipc/glue/Shmem.cpp @@ -323,8 +323,8 @@ Shmem::AssertInvariants() const char checkMappingBack = *(reinterpret_cast(mData) + mSize - 1); // avoid "unused" warnings for these variables: - unused << checkMappingFront; - unused << checkMappingBack; + Unused << checkMappingFront; + Unused << checkMappingBack; } void diff --git a/ipc/hal/DaemonRunnables.h b/ipc/hal/DaemonRunnables.h index 70d651ad1a..03d6fa01a3 100644 --- a/ipc/hal/DaemonRunnables.h +++ b/ipc/hal/DaemonRunnables.h @@ -57,7 +57,7 @@ public: if (!runnable) { return; } - unused << NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(runnable))); + Unused << NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(runnable))); } NS_IMETHODIMP Run() override @@ -113,7 +113,7 @@ public: if (!runnable) { return; } - unused << NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(runnable))); + Unused << NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(runnable))); } NS_IMETHODIMP Run() override @@ -176,7 +176,7 @@ public: if (!runnable) { return; } - unused << NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(runnable))); + Unused << NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(runnable))); } NS_IMETHODIMP Run() override @@ -251,7 +251,7 @@ public: if (!runnable) { return; } - unused << NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(runnable))); + Unused << NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(runnable))); } NS_IMETHODIMP Run() override @@ -311,7 +311,7 @@ public: if (!runnable) { return; } - unused << NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(runnable))); + Unused << NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(runnable))); } NS_IMETHODIMP Run() override @@ -378,7 +378,7 @@ public: if (!runnable) { return; } - unused << NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(runnable))); + Unused << NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(runnable))); } NS_IMETHODIMP Run() override @@ -448,7 +448,7 @@ public: if (!runnable) { return; } - unused << NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(runnable))); + Unused << NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(runnable))); } NS_IMETHODIMP Run() override @@ -520,7 +520,7 @@ public: if (!runnable) { return; } - unused << NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(runnable))); + Unused << NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(runnable))); } NS_IMETHODIMP Run() override @@ -594,7 +594,7 @@ public: if (!runnable) { return; } - unused << NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(runnable))); + Unused << NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(runnable))); } NS_IMETHODIMP Run() override @@ -670,7 +670,7 @@ public: if (!runnable) { return; } - unused << NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(runnable))); + Unused << NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(runnable))); } NS_IMETHODIMP Run() override @@ -752,7 +752,7 @@ public: if (!runnable) { return; } - unused << NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(runnable))); + Unused << NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(runnable))); } NS_IMETHODIMP Run() override diff --git a/ipc/ipdl/test/cxx/TestBadActor.cpp b/ipc/ipdl/test/cxx/TestBadActor.cpp index fb004cfedf..ba5103fe32 100644 --- a/ipc/ipdl/test/cxx/TestBadActor.cpp +++ b/ipc/ipdl/test/cxx/TestBadActor.cpp @@ -16,7 +16,7 @@ TestBadActorParent::Main() if (!child) fail("Sending constructor"); - unused << child->Call__delete__(child); + Unused << child->Call__delete__(child); } PTestBadActorSubParent* diff --git a/ipc/ipdl/test/cxx/TestDataStructures.cpp b/ipc/ipdl/test/cxx/TestDataStructures.cpp index 1280e4d196..eb206dda13 100644 --- a/ipc/ipdl/test/cxx/TestDataStructures.cpp +++ b/ipc/ipdl/test/cxx/TestDataStructures.cpp @@ -452,7 +452,7 @@ bool TestDataStructuresParent::RecvTest18(RegionArray&& ra) // if |ra| has been realloc()d and given a different allocator // chunk, this next line will nondeterministically crash or // iloop - while (const nsIntRect* sr = it.Next()) unused << sr; + while (const nsIntRect* sr = it.Next()) Unused << sr; } return true; diff --git a/js/ipc/WrapperOwner.cpp b/js/ipc/WrapperOwner.cpp index 3d3c364040..6009307035 100644 --- a/js/ipc/WrapperOwner.cpp +++ b/js/ipc/WrapperOwner.cpp @@ -895,7 +895,7 @@ WrapperOwner::drop(JSObject* obj) cpows_.remove(objId); if (active()) - unused << SendDropObject(objId); + Unused << SendDropObject(objId); decref(); } diff --git a/js/src/jsmath.cpp b/js/src/jsmath.cpp index cb3e4485a8..898e22bfa3 100644 --- a/js/src/jsmath.cpp +++ b/js/src/jsmath.cpp @@ -805,7 +805,7 @@ js::random_generateSeed(uint64_t* seedBuffer, size_t length) ssize_t size = length * sizeof(seedBuffer[0]); ssize_t nread = read(fd, (char *) seedBuffer, size); MOZ_ASSERT(nread == size, "Can't read /dev/urandom?!"); - mozilla::unused << nread; + mozilla::Unused << nread; close(fd); } #else diff --git a/js/src/vm/Stopwatch.cpp b/js/src/vm/Stopwatch.cpp index 71f83e3b6f..a4e7098121 100644 --- a/js/src/vm/Stopwatch.cpp +++ b/js/src/vm/Stopwatch.cpp @@ -237,7 +237,7 @@ AutoStopwatch::~AutoStopwatch() return; } - mozilla::unused << exit(); // Sadly, there is nothing we can do about an error at this point. + mozilla::Unused << exit(); // Sadly, there is nothing we can do about an error at this point. for (auto group = groups_.begin(); group < groups_.end(); group++) releaseGroup(*group); diff --git a/js/xpconnect/loader/mozJSSubScriptLoader.cpp b/js/xpconnect/loader/mozJSSubScriptLoader.cpp index 5c8ab3280b..99cbb644e5 100644 --- a/js/xpconnect/loader/mozJSSubScriptLoader.cpp +++ b/js/xpconnect/loader/mozJSSubScriptLoader.cpp @@ -831,7 +831,7 @@ ScriptPrecompiler::OnStreamComplete(nsIStreamLoader* aLoader, return NS_OK; } - unused << runnable.forget(); + Unused << runnable.forget(); notifier.Disarm(); return NS_OK; diff --git a/js/xpconnect/src/XPCWrappedNative.cpp b/js/xpconnect/src/XPCWrappedNative.cpp index 39f4be5548..273e1465b8 100644 --- a/js/xpconnect/src/XPCWrappedNative.cpp +++ b/js/xpconnect/src/XPCWrappedNative.cpp @@ -996,7 +996,7 @@ XPCWrappedNative::SystemIsBeingShutDown() } // We leak the tearoff mNative // (for the same reason we leak mIdentity - see above). - unused << to->TakeNative().take(); + Unused << to->TakeNative().take(); to->SetInterface(nullptr); } diff --git a/layout/base/FrameLayerBuilder.cpp b/layout/base/FrameLayerBuilder.cpp index e1a5bb3c89..2947835641 100644 --- a/layout/base/FrameLayerBuilder.cpp +++ b/layout/base/FrameLayerBuilder.cpp @@ -2366,7 +2366,7 @@ ContainerState::PreparePaintedLayerForUse(PaintedLayer* aLayer, aData->mAnimatedGeometryRootPosition = animatedGeometryRootTopLeft; } #else - unused << didResetScrollPositionForLayerPixelAlignment; + Unused << didResetScrollPositionForLayerPixelAlignment; #endif } diff --git a/layout/base/nsRefreshDriver.cpp b/layout/base/nsRefreshDriver.cpp index e4f266f34b..a00ad9e1c1 100644 --- a/layout/base/nsRefreshDriver.cpp +++ b/layout/base/nsRefreshDriver.cpp @@ -395,7 +395,7 @@ private: // send the unobserveVsync message to disable vsync event. We don't need // to handle the cleanup stuff of this actor. PVsyncChild::ActorDestroy() // will be called and clean up this actor. - unused << mVsyncChild->SendUnobserve(); + Unused << mVsyncChild->SendUnobserve(); mVsyncChild->SetVsyncObserver(nullptr); mVsyncChild = nullptr; } @@ -414,7 +414,7 @@ private: if (XRE_IsParentProcess()) { mVsyncDispatcher->SetParentRefreshTimer(mVsyncObserver); } else { - unused << mVsyncChild->SendObserve(); + Unused << mVsyncChild->SendObserve(); } } @@ -423,7 +423,7 @@ private: if (XRE_IsParentProcess()) { mVsyncDispatcher->SetParentRefreshTimer(nullptr); } else { - unused << mVsyncChild->SendUnobserve(); + Unused << mVsyncChild->SendUnobserve(); } } diff --git a/layout/base/nsStyleSheetService.cpp b/layout/base/nsStyleSheetService.cpp index 00bea0a02c..579f743a6f 100644 --- a/layout/base/nsStyleSheetService.cpp +++ b/layout/base/nsStyleSheetService.cpp @@ -169,7 +169,7 @@ nsStyleSheetService::LoadAndRegisterSheet(nsIURI *aSheetURI, SerializeURI(aSheetURI, uri); for (uint32_t i = 0; i < children.Length(); i++) { - unused << children[i]->SendLoadAndRegisterSheet(uri, aSheetType); + Unused << children[i]->SendLoadAndRegisterSheet(uri, aSheetType); } } } @@ -307,7 +307,7 @@ nsStyleSheetService::UnregisterSheet(nsIURI *aSheetURI, uint32_t aSheetType) SerializeURI(aSheetURI, uri); for (uint32_t i = 0; i < children.Length(); i++) { - unused << children[i]->SendUnregisterSheet(uri, aSheetType); + Unused << children[i]->SendUnregisterSheet(uri, aSheetType); } } diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index 72ad2a1adf..28ea90d417 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -843,7 +843,7 @@ nsComboboxControlFrame::Reflow(nsPresContext* aPresContext, if (NS_SUCCEEDED(aPresContext->PresShell()->PostReflowCallback(resize))) { // The reflow callback queue doesn't AddRef so we keep it alive until // it's released in its ReflowFinished / ReflowCallbackCanceled. - unused << resize.forget(); + Unused << resize.forget(); } // Get the width of the vertical scrollbar. That will be the inline diff --git a/layout/generic/nsColumnSetFrame.cpp b/layout/generic/nsColumnSetFrame.cpp index 8f8d720739..9985c2a817 100644 --- a/layout/generic/nsColumnSetFrame.cpp +++ b/layout/generic/nsColumnSetFrame.cpp @@ -142,7 +142,7 @@ nsColumnSetFrame::PaintColumnRule(nsRenderingContext* aCtx, // couldn't ignore the DrawResult that PaintBorderWithStyleBorder returns. MOZ_ASSERT(border.mBorderImageSource.GetType() == eStyleImageType_Null); - unused << + Unused << nsCSSRendering::PaintBorderWithStyleBorder(presContext, *aCtx, this, aDirtyRect, lineRect, border, StyleContext(), diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index b40e1fd2db..cfb85893d4 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -2927,7 +2927,7 @@ ScrollFrameHelper::BuildDisplayList(nsDisplayListBuilder* aBuilder, // dirty rect here. nsRect dirtyRect = aDirtyRect.Intersect(mScrollPort); - unused << DecideScrollableLayer(aBuilder, &dirtyRect, + Unused << DecideScrollableLayer(aBuilder, &dirtyRect, /* aAllowCreateDisplayPort = */ !mIsRoot); bool usingDisplayPort = aBuilder->IsPaintingToWindow() && diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index 6d23c3e137..c22b39cb10 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -1345,7 +1345,7 @@ nsImageFrame::DisplayAltFeedback(nsRenderingContext& aRenderingContext, // couldn't ignore the DrawResult that PaintBorderWithStyleBorder returns. MOZ_ASSERT(recessedBorder.mBorderImageSource.GetType() == eStyleImageType_Null); - unused << + Unused << nsCSSRendering::PaintBorderWithStyleBorder(PresContext(), aRenderingContext, this, inner, inner, recessedBorder, mStyleContext, diff --git a/layout/ipc/VsyncParent.cpp b/layout/ipc/VsyncParent.cpp index 1252406996..6f25eb4a52 100644 --- a/layout/ipc/VsyncParent.cpp +++ b/layout/ipc/VsyncParent.cpp @@ -68,7 +68,7 @@ VsyncParent::DispatchVsyncEvent(TimeStamp aTimeStamp) // NotifyVsync(). We use mObservingVsync and mDestroyed flags to skip this // notification. if (mObservingVsync && !mDestroyed) { - unused << SendNotify(aTimeStamp); + Unused << SendNotify(aTimeStamp); } } diff --git a/layout/mathml/nsMathMLChar.cpp b/layout/mathml/nsMathMLChar.cpp index f0fc145ac2..f8b2f4e53b 100644 --- a/layout/mathml/nsMathMLChar.cpp +++ b/layout/mathml/nsMathMLChar.cpp @@ -2031,7 +2031,7 @@ void nsDisplayMathMLCharDebug::Paint(nsDisplayListBuilder* aBuilder, // Since this is used only for debugging, we don't need to worry about // tracking the DrawResult. - unused << + Unused << nsCSSRendering::PaintBorder(presContext, *aCtx, mFrame, mVisibleRect, rect, styleContext, flags, skipSides); diff --git a/media/libstagefright/binding/SinfParser.cpp b/media/libstagefright/binding/SinfParser.cpp index 4cf55a6acf..5f1036cf4d 100644 --- a/media/libstagefright/binding/SinfParser.cpp +++ b/media/libstagefright/binding/SinfParser.cpp @@ -39,7 +39,7 @@ SinfParser::ParseSchm(Box& aBox) return; } - mozilla::unused << reader->ReadU32(); // flags -- ignore + mozilla::Unused << reader->ReadU32(); // flags -- ignore mSinf.mDefaultEncryptionType = reader->ReadU32(); reader->DiscardRemaining(); @@ -64,7 +64,7 @@ SinfParser::ParseTenc(Box& aBox) return; } - mozilla::unused << reader->ReadU32(); // flags -- ignore + mozilla::Unused << reader->ReadU32(); // flags -- ignore uint32_t isEncrypted = reader->ReadU24(); mSinf.mDefaultIVSize = reader->ReadU8(); diff --git a/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp b/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp index e9ea4d1176..18c15587d4 100644 --- a/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp +++ b/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp @@ -256,7 +256,7 @@ OnStatsReport_m(WebrtcGlobalChild* aThisChild, } } - unused << aThisChild->SendGetStatsResult(aRequestId, stats); + Unused << aThisChild->SendGetStatsResult(aRequestId, stats); return; } @@ -327,7 +327,7 @@ static void OnGetLogging_m(WebrtcGlobalChild* aThisChild, nsLogs.AppendElement(NS_LITERAL_STRING("+++++++ END ++++++++"), fallible); } - unused << aThisChild->SendGetLogResult(aRequestId, nsLogs); + Unused << aThisChild->SendGetLogResult(aRequestId, nsLogs); return; } @@ -585,7 +585,7 @@ WebrtcGlobalInformation::SetDebugLevel(const GlobalObject& aGlobal, int32_t aLev sLastSetLevel = aLevel; for (auto& cp : WebrtcContentParents::GetAll()){ - unused << cp->SendSetDebugMode(aLevel); + Unused << cp->SendSetDebugMode(aLevel); } } @@ -603,7 +603,7 @@ WebrtcGlobalInformation::SetAecDebug(const GlobalObject& aGlobal, bool aEnable) sLastAECDebug = aEnable; for (auto& cp : WebrtcContentParents::GetAll()){ - unused << cp->SendSetAecLogging(aEnable); + Unused << cp->SendSetAecLogging(aEnable); } } diff --git a/mfbt/AlreadyAddRefed.h b/mfbt/AlreadyAddRefed.h index b2c35d3403..d02e8ae54f 100644 --- a/mfbt/AlreadyAddRefed.h +++ b/mfbt/AlreadyAddRefed.h @@ -102,7 +102,7 @@ struct MOZ_MUST_USE MOZ_NON_AUTOABLE already_AddRefed // Specialize the unused operator<< for already_AddRefed, to allow // nsCOMPtr foo; - // unused << foo.forget(); + // Unused << foo.forget(); // Note that nsCOMPtr is the XPCOM reference counting smart pointer class. friend void operator<<(const mozilla::unused_t& aUnused, const already_AddRefed& aRhs) diff --git a/mfbt/tests/TestSplayTree.cpp b/mfbt/tests/TestSplayTree.cpp index 9b07d274b1..6f136df73b 100644 --- a/mfbt/tests/TestSplayTree.cpp +++ b/mfbt/tests/TestSplayTree.cpp @@ -119,7 +119,7 @@ static SplayTree testNoCopy; int main() { - mozilla::unused << testNoCopy; + mozilla::Unused << testNoCopy; SplayTree tree; diff --git a/mfbt/tests/TestTuple.cpp b/mfbt/tests/TestTuple.cpp index 2fee47b1a6..0d99106235 100644 --- a/mfbt/tests/TestTuple.cpp +++ b/mfbt/tests/TestTuple.cpp @@ -24,7 +24,7 @@ using mozilla::Pair; using mozilla::Tie; using mozilla::Tuple; using mozilla::UniquePtr; -using mozilla::unused; +using mozilla::Unused; using std::pair; #if (_MSC_VER == 1800) @@ -55,9 +55,9 @@ TestConstruction() { // Default construction Tuple<> a; - unused << a; + Unused << a; Tuple b; - unused << b; + Unused << b; // Construction from elements int x = 1, y = 1; diff --git a/mfbt/unused.cpp b/mfbt/unused.cpp index cee781c4cb..4acfa7a14b 100644 --- a/mfbt/unused.cpp +++ b/mfbt/unused.cpp @@ -8,6 +8,6 @@ namespace mozilla { -const unused_t unused = unused_t(); +const unused_t Unused = unused_t(); } // namespace mozilla diff --git a/mfbt/unused.h b/mfbt/unused.h index e9db127c3a..e693e32ac7 100644 --- a/mfbt/unused.h +++ b/mfbt/unused.h @@ -15,7 +15,7 @@ namespace mozilla { // // Suppress GCC warnings about unused return values with -// unused << SomeFuncDeclaredWarnUnusedReturnValue(); +// Unused << SomeFuncDeclaredWarnUnusedReturnValue(); // struct unused_t { @@ -24,13 +24,13 @@ struct unused_t operator<<(const T& /*unused*/) const {} }; -extern MFBT_DATA const unused_t unused; +extern MFBT_DATA const unused_t Unused; } // namespace mozilla #endif // __cplusplus -// An alternative to mozilla::unused for use in (a) C code and (b) code where +// An alternative to mozilla::Unused for use in (a) C code and (b) code where // linking with unused.o is difficult. #define MOZ_UNUSED(expr) \ do { if (expr) { (void)0; } } while (0) diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index e4019b8706..8e18640806 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -1741,8 +1741,8 @@ pref("network.http.diagnostics", false); pref("network.http.pacing.requests.enabled", true); pref("network.http.pacing.requests.min-parallelism", 6); -pref("network.http.pacing.requests.hz", 100); -pref("network.http.pacing.requests.burst", 32); +pref("network.http.pacing.requests.hz", 80); +pref("network.http.pacing.requests.burst", 10); // TCP Keepalive config for HTTP connections. pref("network.http.tcp_keepalive.short_lived_connections", true); diff --git a/netwerk/base/ARefBase.h b/netwerk/base/ARefBase.h new file mode 100644 index 0000000000..8b9582268a --- /dev/null +++ b/netwerk/base/ARefBase.h @@ -0,0 +1,30 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ + +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_net_ARefBase_h +#define mozilla_net_ARefBase_h + +namespace mozilla { namespace net { + +// This is an abstract class that can be pointed to by either +// nsCOMPtr or nsRefPtr. nsHttpConnectionMgr uses it for generic +// objects that need to be reference counted - similiar to nsISupports +// but it may or may not be xpcom. + +class ARefBase +{ +public: + ARefBase() {} + virtual ~ARefBase() {} + + NS_IMETHOD_ (MozExternalRefCountType) AddRef() = 0; + NS_IMETHOD_ (MozExternalRefCountType) Release() = 0; +}; + +} // namespace net +} // namespace mozilla + +#endif diff --git a/netwerk/base/EventTokenBucket.cpp b/netwerk/base/EventTokenBucket.cpp index 088b7636d0..22b7dc0d6a 100644 --- a/netwerk/base/EventTokenBucket.cpp +++ b/netwerk/base/EventTokenBucket.cpp @@ -90,7 +90,6 @@ EventTokenBucket::EventTokenBucket(uint32_t eventsPerSecond, , mFineGrainResetTimerArmed(false) #endif { - MOZ_COUNT_CTOR(EventTokenBucket); mLastUpdate = TimeStamp::Now(); MOZ_ASSERT(NS_IsMainThread()); @@ -112,7 +111,6 @@ EventTokenBucket::~EventTokenBucket() SOCKET_LOG(("EventTokenBucket::dtor %p events=%d\n", this, mEvents.GetSize())); - MOZ_COUNT_DTOR(EventTokenBucket); if (mTimer && mTimerArmed) mTimer->Cancel(); diff --git a/netwerk/base/EventTokenBucket.h b/netwerk/base/EventTokenBucket.h index eba7552514..fe760e76d2 100644 --- a/netwerk/base/EventTokenBucket.h +++ b/netwerk/base/EventTokenBucket.h @@ -7,6 +7,7 @@ #ifndef NetEventTokenBucket_h__ #define NetEventTokenBucket_h__ +#include "ARefBase.h" #include "nsCOMPtr.h" #include "nsDeque.h" #include "nsITimer.h" @@ -59,7 +60,7 @@ namespace net { class EventTokenBucket; -class ATokenBucketEvent +class ATokenBucketEvent { public: virtual void OnTokenBucketAdmitted() = 0; @@ -67,10 +68,8 @@ public: class TokenBucketCancelable; -class EventTokenBucket : public nsITimerCallback +class EventTokenBucket : public nsITimerCallback, public ARefBase { - virtual ~EventTokenBucket(); - public: NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_NSITIMERCALLBACK @@ -93,6 +92,8 @@ public: nsresult SubmitEvent(ATokenBucketEvent *event, nsICancelable **cancelable); private: + virtual ~EventTokenBucket(); + friend class RunNotifyEvent; friend class SetTimerEvent; diff --git a/netwerk/cache2/CacheIndex.cpp b/netwerk/cache2/CacheIndex.cpp index 754d617c7e..5352377ed3 100644 --- a/netwerk/cache2/CacheIndex.cpp +++ b/netwerk/cache2/CacheIndex.cpp @@ -2980,7 +2980,7 @@ CacheIndex::FinishUpdate(bool aSucceeded) NS_WARNING(("CacheIndex::FinishUpdate() - Leaking mDirEnumerator!")); // This can happen only in case dispatching event to IO thread failed in // CacheIndex::PreShutdown(). - unused << mDirEnumerator.forget(); // Leak it since dir enumerator is not threadsafe + Unused << mDirEnumerator.forget(); // Leak it since dir enumerator is not threadsafe } else { mDirEnumerator->Close(); mDirEnumerator = nullptr; diff --git a/netwerk/dns/DNSRequestChild.cpp b/netwerk/dns/DNSRequestChild.cpp index 8437c81670..3550955810 100644 --- a/netwerk/dns/DNSRequestChild.cpp +++ b/netwerk/dns/DNSRequestChild.cpp @@ -264,7 +264,7 @@ DNSRequestChild::RecvLookupCompleted(const DNSRequestResponse& reply) mTarget->Dispatch(event, NS_DISPATCH_NORMAL); } - unused << Send__delete__(this); + Unused << Send__delete__(this); return true; } diff --git a/netwerk/dns/DNSRequestParent.cpp b/netwerk/dns/DNSRequestParent.cpp index fc47c089f8..0d650f0a7f 100644 --- a/netwerk/dns/DNSRequestParent.cpp +++ b/netwerk/dns/DNSRequestParent.cpp @@ -46,7 +46,7 @@ DNSRequestParent::DoAsyncResolve(const nsACString &hostname, uint32_t flags, if (NS_FAILED(rv) && !mIPCClosed) { mIPCClosed = true; - unused << SendLookupCompleted(DNSRequestResponse(rv)); + Unused << SendLookupCompleted(DNSRequestResponse(rv)); } } @@ -116,9 +116,9 @@ DNSRequestParent::OnLookupComplete(nsICancelable *request, array.AppendElement(addr); } - unused << SendLookupCompleted(DNSRequestResponse(DNSRecord(cname, array))); + Unused << SendLookupCompleted(DNSRequestResponse(DNSRecord(cname, array))); } else { - unused << SendLookupCompleted(DNSRequestResponse(status)); + Unused << SendLookupCompleted(DNSRequestResponse(status)); } mIPCClosed = true; diff --git a/netwerk/ipc/RemoteOpenFileChild.cpp b/netwerk/ipc/RemoteOpenFileChild.cpp index b55c0a04d3..6be664fd5e 100644 --- a/netwerk/ipc/RemoteOpenFileChild.cpp +++ b/netwerk/ipc/RemoteOpenFileChild.cpp @@ -125,15 +125,15 @@ RemoteOpenFileChild::~RemoteOpenFileChild() NS_DISPATCH_NORMAL))); } } else { - using mozilla::unused; + using mozilla::Unused; NS_WARNING("RemoteOpenFileChild released after thread shutdown, leaking " "its members!"); - unused << mURI.forget(); - unused << mAppURI.forget(); - unused << mListener.forget(); - unused << mTabChild.forget(); + Unused << mURI.forget(); + Unused << mAppURI.forget(); + Unused << mListener.forget(); + Unused << mTabChild.forget(); } } diff --git a/netwerk/ipc/RemoteOpenFileParent.cpp b/netwerk/ipc/RemoteOpenFileParent.cpp index e21562e521..c0596d9beb 100644 --- a/netwerk/ipc/RemoteOpenFileParent.cpp +++ b/netwerk/ipc/RemoteOpenFileParent.cpp @@ -53,7 +53,7 @@ RemoteOpenFileParent::OpenSendCloseDelete() } // Sending a potentially invalid file descriptor is just fine. - unused << Send__delete__(this, fileDescriptor); + Unused << Send__delete__(this, fileDescriptor); // Current process's file descriptor is closed by FileDescriptor destructor. #endif // OS_TYPE diff --git a/netwerk/mime/nsMimeTypes.h b/netwerk/mime/nsMimeTypes.h index 3717617ba9..c887107ef4 100644 --- a/netwerk/mime/nsMimeTypes.h +++ b/netwerk/mime/nsMimeTypes.h @@ -82,6 +82,7 @@ #define AUDIO_MP3 "audio/mpeg" #define AUDIO_MP4 "audio/mp4" #define AUDIO_AMR "audio/amr" +#define AUDIO_FLAC "audio/flac" #define AUDIO_3GPP "audio/3gpp" #define AUDIO_MIDI "audio/x-midi" #define AUDIO_MATROSKA "audio/x-matroska" diff --git a/netwerk/protocol/data/DataChannelChild.cpp b/netwerk/protocol/data/DataChannelChild.cpp index 9b260ba06d..58d5518f8b 100644 --- a/netwerk/protocol/data/DataChannelChild.cpp +++ b/netwerk/protocol/data/DataChannelChild.cpp @@ -53,7 +53,7 @@ DataChannelChild::CompleteRedirectSetup(nsIStreamListener *aListener, } if (mIPCOpen) { - unused << Send__delete__(this); + Unused << Send__delete__(this); } return NS_OK; } diff --git a/netwerk/protocol/ftp/FTPChannelParent.cpp b/netwerk/protocol/ftp/FTPChannelParent.cpp index a35e0deb14..3b5df98fb4 100644 --- a/netwerk/protocol/ftp/FTPChannelParent.cpp +++ b/netwerk/protocol/ftp/FTPChannelParent.cpp @@ -688,7 +688,7 @@ FTPChannelParent::NotifyDiversionFailed(nsresult aErrorCode, mChannel = nullptr; if (!mIPCClosed) { - unused << SendDeleteSelf(); + Unused << SendDeleteSelf(); } } diff --git a/netwerk/protocol/http/ConnectionDiagnostics.cpp b/netwerk/protocol/http/ConnectionDiagnostics.cpp index 28873c7608..a331e3dbfa 100644 --- a/netwerk/protocol/http/ConnectionDiagnostics.cpp +++ b/netwerk/protocol/http/ConnectionDiagnostics.cpp @@ -28,7 +28,7 @@ nsHttpConnectionMgr::PrintDiagnostics() } void -nsHttpConnectionMgr::OnMsgPrintDiagnostics(int32_t, void *) +nsHttpConnectionMgr::OnMsgPrintDiagnostics(int32_t, ARefBase *) { MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread); diff --git a/netwerk/protocol/http/HttpChannelChild.cpp b/netwerk/protocol/http/HttpChannelChild.cpp index 33dd3b7c6b..fa2a5fdcf3 100644 --- a/netwerk/protocol/http/HttpChannelChild.cpp +++ b/netwerk/protocol/http/HttpChannelChild.cpp @@ -1832,7 +1832,7 @@ HttpChannelChild::ContinueAsyncOpen() PFileDescriptorSetChild* fdSet = gNeckoChild->Manager()->SendPFileDescriptorSetConstructor(fds[0]); for (uint32_t i = 1; i < fds.Length(); ++i) { - unused << fdSet->SendAddFileDescriptor(fds[i]); + Unused << fdSet->SendAddFileDescriptor(fds[i]); } optionalFDs = fdSet; diff --git a/netwerk/protocol/http/HttpChannelParent.cpp b/netwerk/protocol/http/HttpChannelParent.cpp index 28e280c5ef..63d40f870b 100644 --- a/netwerk/protocol/http/HttpChannelParent.cpp +++ b/netwerk/protocol/http/HttpChannelParent.cpp @@ -437,7 +437,7 @@ HttpChannelParent::DoAsyncOpen( const URIParams& aURI, fdSetActor->ForgetFileDescriptors(fds); MOZ_ASSERT(!fds.IsEmpty()); - unused << fdSetActor->Send__delete__(fdSetActor); + Unused << fdSetActor->Send__delete__(fdSetActor); } else if (aFds.type() == OptionalFileDescriptorSet::TArrayOfFileDescriptor) { const_cast(aFds). get_ArrayOfFileDescriptor().SwapElements(fds); @@ -1259,7 +1259,7 @@ NS_IMETHODIMP HttpChannelParent::NotifyTrackingProtectionDisabled() { if (!mIPCClosed) - unused << SendNotifyTrackingProtectionDisabled(); + Unused << SendNotifyTrackingProtectionDisabled(); return NS_OK; } @@ -1267,7 +1267,7 @@ NS_IMETHODIMP HttpChannelParent::Delete() { if (!mIPCClosed) - unused << SendDeleteSelf(); + Unused << SendDeleteSelf(); return NS_OK; } @@ -1327,7 +1327,7 @@ HttpChannelParent::CompleteRedirect(bool succeeded) if (succeeded && !mIPCClosed) { // TODO: check return value: assume child dead if failed - unused << SendRedirect3Complete(); + Unused << SendRedirect3Complete(); } mRedirectChannel = nullptr; @@ -1548,7 +1548,7 @@ HttpChannelParent::NotifyDiversionFailed(nsresult aErrorCode, mChannel = nullptr; if (!mIPCClosed) { - unused << SendDeleteSelf(); + Unused << SendDeleteSelf(); } } @@ -1614,7 +1614,7 @@ HttpChannelParent::ReportSecurityMessage(const nsAString& aMessageTag, NS_IMETHODIMP HttpChannelParent::IssueWarning(uint32_t aWarning, bool aAsError) { - unused << SendIssueDeprecationWarning(aWarning, aAsError); + Unused << SendIssueDeprecationWarning(aWarning, aAsError); return NS_OK; } diff --git a/netwerk/protocol/http/HttpChannelParentListener.cpp b/netwerk/protocol/http/HttpChannelParentListener.cpp index e63487ca10..e924c4b921 100644 --- a/netwerk/protocol/http/HttpChannelParentListener.cpp +++ b/netwerk/protocol/http/HttpChannelParentListener.cpp @@ -14,7 +14,7 @@ #include "nsIHttpEventSink.h" #include "nsIPackagedAppChannelListener.h" -using mozilla::unused; +using mozilla::Unused; namespace mozilla { namespace net { diff --git a/netwerk/protocol/http/SpdySession31.cpp b/netwerk/protocol/http/SpdySession31.cpp index 955fd06168..766f863e69 100644 --- a/netwerk/protocol/http/SpdySession31.cpp +++ b/netwerk/protocol/http/SpdySession31.cpp @@ -792,20 +792,6 @@ SpdySession31::GenerateSettings() numberOfEntries++; } - RefPtr ci; - uint32_t cwnd = 0; - GetConnectionInfo(getter_AddRefs(ci)); - if (ci) - cwnd = gHttpHandler->ConnMgr()->GetSpdyCWNDSetting(ci); - if (cwnd) { - packet[12 + 8 * numberOfEntries] = PERSISTED_VALUE; - packet[15 + 8 * numberOfEntries] = SETTINGS_TYPE_CWND; - LOG(("SpdySession31::GenerateSettings %p sending CWND %u\n", this, cwnd)); - cwnd = PR_htonl(cwnd); - memcpy(packet + 16 + 8 * numberOfEntries, &cwnd, 4); - numberOfEntries++; - } - // Advertise the Push RWIN and on each client SYN_STREAM pipeline // a window update with it in order to use larger initial windows with pulled // streams. @@ -1442,16 +1428,6 @@ SpdySession31::HandleSettings(SpdySession31 *self) self->ProcessPending(); break; - case SETTINGS_TYPE_CWND: - if (flags & PERSIST_VALUE) - { - RefPtr ci; - self->GetConnectionInfo(getter_AddRefs(ci)); - if (ci) - gHttpHandler->ConnMgr()->ReportSpdyCWNDSetting(ci, value); - } - break; - case SETTINGS_TYPE_INITIAL_WINDOW: { int32_t delta = value - self->mServerInitialStreamWindow; diff --git a/netwerk/protocol/http/nsHttpConnection.h b/netwerk/protocol/http/nsHttpConnection.h index 4d1623ba55..c4a3324f89 100644 --- a/netwerk/protocol/http/nsHttpConnection.h +++ b/netwerk/protocol/http/nsHttpConnection.h @@ -14,6 +14,7 @@ #include "prinrval.h" #include "TunnelUtils.h" #include "mozilla/Mutex.h" +#include "ARefBase.h" #include "nsIAsyncInputStream.h" #include "nsIAsyncOutputStream.h" @@ -43,6 +44,7 @@ class nsHttpConnection final : public nsAHttpSegmentReader , public nsITransportEventSink , public nsIInterfaceRequestor , public NudgeTunnelCallback + , public ARefBase { virtual ~nsHttpConnection(); diff --git a/netwerk/protocol/http/nsHttpConnectionInfo.h b/netwerk/protocol/http/nsHttpConnectionInfo.h index 243e7c482e..ea7716da82 100644 --- a/netwerk/protocol/http/nsHttpConnectionInfo.h +++ b/netwerk/protocol/http/nsHttpConnectionInfo.h @@ -12,6 +12,7 @@ #include "nsCOMPtr.h" #include "nsStringFwd.h" #include "mozilla/Logging.h" +#include "ARefBase.h" extern PRLogModuleInfo *gHttpLog; @@ -30,7 +31,7 @@ extern PRLogModuleInfo *gHttpLog; namespace mozilla { namespace net { -class nsHttpConnectionInfo +class nsHttpConnectionInfo: public ARefBase { public: nsHttpConnectionInfo(const nsACString &originHost, @@ -164,7 +165,7 @@ private: bool mUsingConnect; // if will use CONNECT with http proxy nsCString mNPNToken; -// for nsRefPtr +// for RefPtr NS_INLINE_DECL_THREADSAFE_REFCOUNTING(nsHttpConnectionInfo) }; diff --git a/netwerk/protocol/http/nsHttpConnectionMgr.cpp b/netwerk/protocol/http/nsHttpConnectionMgr.cpp index 99ed8faeca..dffda0cb8b 100644 --- a/netwerk/protocol/http/nsHttpConnectionMgr.cpp +++ b/netwerk/protocol/http/nsHttpConnectionMgr.cpp @@ -144,12 +144,25 @@ nsHttpConnectionMgr::Init(uint16_t maxConns, return EnsureSocketThreadTarget(); } +class BoolWrapper : public ARefBase +{ +public: + BoolWrapper() : mBool(false) {} + NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BoolWrapper) + +public: // intentional! + bool mBool; + +private: + virtual ~BoolWrapper() {} +}; + nsresult nsHttpConnectionMgr::Shutdown() { LOG(("nsHttpConnectionMgr::Shutdown\n")); - bool shutdown = false; + RefPtr shutdownWrapper = new BoolWrapper(); { ReentrantMonitorAutoEnter mon(mReentrantMonitor); @@ -158,7 +171,7 @@ nsHttpConnectionMgr::Shutdown() return NS_OK; nsresult rv = PostEvent(&nsHttpConnectionMgr::OnMsgShutdown, - 0, &shutdown); + 0, shutdownWrapper); // release our reference to the STS to prevent further events // from being posted. this is how we indicate that we are @@ -173,14 +186,41 @@ nsHttpConnectionMgr::Shutdown() } // wait for shutdown event to complete - while (!shutdown) + while (!shutdownWrapper->mBool) { NS_ProcessNextEvent(NS_GetCurrentThread()); + } return NS_OK; } +class ConnEvent : public nsRunnable +{ +public: + ConnEvent(nsHttpConnectionMgr *mgr, + nsConnEventHandler handler, int32_t iparam, ARefBase *vparam) + : mMgr(mgr) + , mHandler(handler) + , mIParam(iparam) + , mVParam(vparam) {} + + NS_IMETHOD Run() + { + (mMgr->*mHandler)(mIParam, mVParam); + return NS_OK; + } + +private: + virtual ~ConnEvent() {} + + RefPtr mMgr; + nsConnEventHandler mHandler; + int32_t mIParam; + RefPtr mVParam; +}; + nsresult -nsHttpConnectionMgr::PostEvent(nsConnEventHandler handler, int32_t iparam, void *vparam) +nsHttpConnectionMgr::PostEvent(nsConnEventHandler handler, + int32_t iparam, ARefBase *vparam) { EnsureSocketThreadTarget(); @@ -192,7 +232,7 @@ nsHttpConnectionMgr::PostEvent(nsConnEventHandler handler, int32_t iparam, void rv = NS_ERROR_NOT_INITIALIZED; } else { - nsCOMPtr event = new nsConnEvent(this, handler, iparam, vparam); + nsCOMPtr event = new ConnEvent(this, handler, iparam, vparam); rv = mSocketThreadTarget->Dispatch(event, NS_DISPATCH_NORMAL); } return rv; @@ -290,37 +330,22 @@ nsresult nsHttpConnectionMgr::AddTransaction(nsHttpTransaction *trans, int32_t priority) { LOG(("nsHttpConnectionMgr::AddTransaction [trans=%p %d]\n", trans, priority)); - - NS_ADDREF(trans); - nsresult rv = PostEvent(&nsHttpConnectionMgr::OnMsgNewTransaction, priority, trans); - if (NS_FAILED(rv)) - NS_RELEASE(trans); - return rv; + return PostEvent(&nsHttpConnectionMgr::OnMsgNewTransaction, priority, trans); } nsresult nsHttpConnectionMgr::RescheduleTransaction(nsHttpTransaction *trans, int32_t priority) { LOG(("nsHttpConnectionMgr::RescheduleTransaction [trans=%p %d]\n", trans, priority)); - - NS_ADDREF(trans); - nsresult rv = PostEvent(&nsHttpConnectionMgr::OnMsgReschedTransaction, priority, trans); - if (NS_FAILED(rv)) - NS_RELEASE(trans); - return rv; + return PostEvent(&nsHttpConnectionMgr::OnMsgReschedTransaction, priority, trans); } nsresult nsHttpConnectionMgr::CancelTransaction(nsHttpTransaction *trans, nsresult reason) { LOG(("nsHttpConnectionMgr::CancelTransaction [trans=%p reason=%x]\n", trans, reason)); - - NS_ADDREF(trans); - nsresult rv = PostEvent(&nsHttpConnectionMgr::OnMsgCancelTransaction, - static_cast(reason), trans); - if (NS_FAILED(rv)) - NS_RELEASE(trans); - return rv; + return PostEvent(&nsHttpConnectionMgr::OnMsgCancelTransaction, + static_cast(reason), trans); } nsresult @@ -347,30 +372,18 @@ nsHttpConnectionMgr::VerifyTraffic() return PostEvent(&nsHttpConnectionMgr::OnMsgVerifyTraffic); } - nsresult nsHttpConnectionMgr::DoShiftReloadConnectionCleanup(nsHttpConnectionInfo *aCI) { - RefPtr connInfo(aCI); - - nsresult rv = PostEvent(&nsHttpConnectionMgr::OnMsgDoShiftReloadConnectionCleanup, - 0, connInfo); - if (NS_SUCCEEDED(rv)) - unused << connInfo.forget(); - return rv; + return PostEvent(&nsHttpConnectionMgr::OnMsgDoShiftReloadConnectionCleanup, + 0, aCI); } -class SpeculativeConnectArgs +class SpeculativeConnectArgs : public ARefBase { - virtual ~SpeculativeConnectArgs() {} - public: SpeculativeConnectArgs() { mOverridesOK = false; } - - // Added manually so we can use nsRefPtr without inheriting from - // nsISupports - NS_IMETHOD_(MozExternalRefCountType) AddRef(void); - NS_IMETHOD_(MozExternalRefCountType) Release(void); + NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SpeculativeConnectArgs) public: // intentional! RefPtr mTrans; @@ -382,16 +395,11 @@ public: // intentional! bool mIsFromPredictor; bool mAllow1918; - // As above, added manually so we can use nsRefPtr without inheriting from - // nsISupports -protected: - ThreadSafeAutoRefCnt mRefCnt; +private: + virtual ~SpeculativeConnectArgs() {} NS_DECL_OWNINGTHREAD }; -NS_IMPL_ADDREF(SpeculativeConnectArgs) -NS_IMPL_RELEASE(SpeculativeConnectArgs) - nsresult nsHttpConnectionMgr::SpeculativeConnect(nsHttpConnectionInfo *ci, nsIInterfaceRequestor *callbacks, @@ -441,11 +449,7 @@ nsHttpConnectionMgr::SpeculativeConnect(nsHttpConnectionInfo *ci, overrider->GetAllow1918(&args->mAllow1918); } - nsresult rv = - PostEvent(&nsHttpConnectionMgr::OnMsgSpeculativeConnect, 0, args); - if (NS_SUCCEEDED(rv)) - unused << args.forget(); - return rv; + return PostEvent(&nsHttpConnectionMgr::OnMsgSpeculativeConnect, 0, args); } nsresult @@ -462,58 +466,49 @@ nsresult nsHttpConnectionMgr::ReclaimConnection(nsHttpConnection *conn) { LOG(("nsHttpConnectionMgr::ReclaimConnection [conn=%p]\n", conn)); - - NS_ADDREF(conn); - nsresult rv = PostEvent(&nsHttpConnectionMgr::OnMsgReclaimConnection, 0, conn); - if (NS_FAILED(rv)) - NS_RELEASE(conn); - return rv; + return PostEvent(&nsHttpConnectionMgr::OnMsgReclaimConnection, 0, conn); } // A structure used to marshall 2 pointers across the various necessary // threads to complete an HTTP upgrade. -class nsCompleteUpgradeData +class nsCompleteUpgradeData : public ARefBase { public: -nsCompleteUpgradeData(nsAHttpConnection *aConn, - nsIHttpUpgradeListener *aListener) - : mConn(aConn), mUpgradeListener(aListener) {} + nsCompleteUpgradeData(nsAHttpConnection *aConn, + nsIHttpUpgradeListener *aListener) + : mConn(aConn) + , mUpgradeListener(aListener) { } + + NS_INLINE_DECL_THREADSAFE_REFCOUNTING(nsCompleteUpgradeData) RefPtr mConn; nsCOMPtr mUpgradeListener; +private: + virtual ~nsCompleteUpgradeData() { } }; nsresult nsHttpConnectionMgr::CompleteUpgrade(nsAHttpConnection *aConn, nsIHttpUpgradeListener *aUpgradeListener) { - nsCompleteUpgradeData *data = + RefPtr data = new nsCompleteUpgradeData(aConn, aUpgradeListener); - nsresult rv; - rv = PostEvent(&nsHttpConnectionMgr::OnMsgCompleteUpgrade, 0, data); - if (NS_FAILED(rv)) - delete data; - return rv; + return PostEvent(&nsHttpConnectionMgr::OnMsgCompleteUpgrade, 0, data); } nsresult nsHttpConnectionMgr::UpdateParam(nsParamName name, uint16_t value) { uint32_t param = (uint32_t(name) << 16) | uint32_t(value); - return PostEvent(&nsHttpConnectionMgr::OnMsgUpdateParam, 0, - (void *)(uintptr_t) param); + return PostEvent(&nsHttpConnectionMgr::OnMsgUpdateParam, + static_cast(param), nullptr); } nsresult nsHttpConnectionMgr::ProcessPendingQ(nsHttpConnectionInfo *ci) { LOG(("nsHttpConnectionMgr::ProcessPendingQ [ci=%s]\n", ci->HashKey().get())); - - NS_ADDREF(ci); - nsresult rv = PostEvent(&nsHttpConnectionMgr::OnMsgProcessPendingQ, 0, ci); - if (NS_FAILED(rv)) - NS_RELEASE(ci); - return rv; + return PostEvent(&nsHttpConnectionMgr::OnMsgProcessPendingQ, 0, ci); } nsresult @@ -524,25 +519,19 @@ nsHttpConnectionMgr::ProcessPendingQ() } void -nsHttpConnectionMgr::OnMsgUpdateRequestTokenBucket(int32_t, void *param) +nsHttpConnectionMgr::OnMsgUpdateRequestTokenBucket(int32_t, ARefBase *param) { - RefPtr tokenBucket = - dont_AddRef(static_cast(param)); + EventTokenBucket *tokenBucket = static_cast(param); gHttpHandler->SetRequestTokenBucket(tokenBucket); } nsresult nsHttpConnectionMgr::UpdateRequestTokenBucket(EventTokenBucket *aBucket) { - RefPtr bucket(aBucket); - // Call From main thread when a new EventTokenBucket has been made in order // to post the new value to the socket thread. - nsresult rv = PostEvent(&nsHttpConnectionMgr::OnMsgUpdateRequestTokenBucket, - 0, bucket); - if (NS_SUCCEEDED(rv)) - unused << bucket.forget(); - return rv; + return PostEvent(&nsHttpConnectionMgr::OnMsgUpdateRequestTokenBucket, + 0, aBucket); } PLDHashOperator @@ -744,67 +733,6 @@ nsHttpConnectionMgr::ReportSpdyConnection(nsHttpConnection *conn, PostEvent(&nsHttpConnectionMgr::OnMsgProcessAllSpdyPendingQ); } -void -nsHttpConnectionMgr::ReportSpdyCWNDSetting(nsHttpConnectionInfo *ci, - uint32_t cwndValue) -{ - MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread); - - if (!gHttpHandler->UseSpdyPersistentSettings()) - return; - - if (!ci) - return; - - nsConnectionEntry *ent = mCT.Get(ci->HashKey()); - if (!ent) - return; - - ent = GetSpdyPreferredEnt(ent); - if (!ent) // just to be thorough - but that map should always exist - return; - - cwndValue = std::max(2U, cwndValue); - cwndValue = std::min(128U, cwndValue); - - ent->mSpdyCWND = cwndValue; - ent->mSpdyCWNDTimeStamp = TimeStamp::Now(); - return; -} - -// a value of 0 means no setting is available -uint32_t -nsHttpConnectionMgr::GetSpdyCWNDSetting(nsHttpConnectionInfo *ci) -{ - MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread); - - if (!gHttpHandler->UseSpdyPersistentSettings()) - return 0; - - if (!ci) - return 0; - - nsConnectionEntry *ent = mCT.Get(ci->HashKey()); - if (!ent) - return 0; - - ent = GetSpdyPreferredEnt(ent); - if (!ent) // just to be thorough - but that map should always exist - return 0; - - if (ent->mSpdyCWNDTimeStamp.IsNull()) - return 0; - - // For privacy tracking reasons, and the fact that CWND is not - // meaningful after some time, we don't honor stored CWND after 8 - // hours. - TimeDuration age = TimeStamp::Now() - ent->mSpdyCWNDTimeStamp; - if (age.ToMilliseconds() > (1000 * 60 * 60 * 8)) - return 0; - - return ent->mSpdyCWND; -} - nsHttpConnectionMgr::nsConnectionEntry * nsHttpConnectionMgr::GetSpdyPreferredEnt(nsConnectionEntry *aOriginalEntry) { @@ -1252,7 +1180,7 @@ nsHttpConnectionMgr::SupportsPipelining(nsHttpConnectionInfo *ci) // nsHttpPipelineFeedback used to hold references across events -class nsHttpPipelineFeedback +class nsHttpPipelineFeedback : public ARefBase { public: nsHttpPipelineFeedback(nsHttpConnectionInfo *ci, @@ -1265,14 +1193,14 @@ public: { } - ~nsHttpPipelineFeedback() - { - } RefPtr mConnInfo; RefPtr mConn; nsHttpConnectionMgr::PipelineFeedbackInfoType mInfo; uint32_t mData; +private: + ~nsHttpPipelineFeedback() {} + NS_INLINE_DECL_THREADSAFE_REFCOUNTING(nsHttpPipelineFeedback) }; void @@ -1286,18 +1214,13 @@ nsHttpConnectionMgr::PipelineFeedbackInfo(nsHttpConnectionInfo *ci, // Post this to the socket thread if we are not running there already if (PR_GetCurrentThread() != gSocketThread) { - nsHttpPipelineFeedback *fb = new nsHttpPipelineFeedback(ci, info, - conn, data); - - nsresult rv = PostEvent(&nsHttpConnectionMgr::OnMsgProcessFeedback, - 0, fb); - if (NS_FAILED(rv)) - delete fb; + RefPtr fb = + new nsHttpPipelineFeedback(ci, info, conn, data); + PostEvent(&nsHttpConnectionMgr::OnMsgProcessFeedback, 0, fb); return; } nsConnectionEntry *ent = mCT.Get(ci->HashKey()); - if (ent) ent->OnPipelineFeedbackInfo(info, conn, data); } @@ -1804,11 +1727,19 @@ nsHttpConnectionMgr::TryDispatchTransaction(nsConnectionEntry *ent, // pacing so it can be found on cancel if necessary. // Transactions that cause blocking or bypass it (e.g. js/css) are not rate // limited. - if (gHttpHandler->UseRequestTokenBucket() && - (mNumActiveConns >= mNumSpdyActiveConns) && // just check for robustness sake - ((mNumActiveConns - mNumSpdyActiveConns) >= gHttpHandler->RequestTokenBucketMinParallelism()) && - !(caps & (NS_HTTP_LOAD_AS_BLOCKING | NS_HTTP_LOAD_UNBLOCKED))) { - if (!trans->TryToRunPacedRequest()) { + if (gHttpHandler->UseRequestTokenBucket()) { + // submit even whitelisted transactions to the token bucket though they will + // not be slowed by it + bool runNow = trans->TryToRunPacedRequest(); + if (!runNow) { + if ((mNumActiveConns - mNumSpdyActiveConns) <= + gHttpHandler->RequestTokenBucketMinParallelism()) { + runNow = true; // white list it + } else if (caps & (NS_HTTP_LOAD_AS_BLOCKING | NS_HTTP_LOAD_UNBLOCKED)) { + runNow = true; // white list it + } + } + if (!runNow) { LOG((" blocked due to rate pacing trans=%p\n", trans)); return NS_ERROR_NOT_AVAILABLE; } @@ -1856,6 +1787,7 @@ nsHttpConnectionMgr::TryDispatchTransaction(nsConnectionEntry *ent, if (!attemptedOptimisticPipeline && (classification == nsHttpTransaction::CLASS_REVALIDATION || classification == nsHttpTransaction::CLASS_SCRIPT)) { + // Assignation kept here for documentation purpose; Never read after attemptedOptimisticPipeline = true; if (AddToShortestPipeline(ent, trans, classification, @@ -1955,6 +1887,44 @@ nsHttpConnectionMgr::DispatchTransaction(nsConnectionEntry *ent, return rv; } +//----------------------------------------------------------------------------- +// ConnectionHandle +// +// thin wrapper around a real connection, used to keep track of references +// to the connection to determine when the connection may be reused. the +// transaction (or pipeline) owns a reference to this handle. this extra +// layer of indirection greatly simplifies consumer code, avoiding the +// need for consumer code to know when to give the connection back to the +// connection manager. +// +class ConnectionHandle : public nsAHttpConnection +{ +public: + NS_DECL_THREADSAFE_ISUPPORTS + NS_DECL_NSAHTTPCONNECTION(mConn) + + explicit ConnectionHandle(nsHttpConnection *conn) { NS_ADDREF(mConn = conn); } + nsHttpConnection *mConn; + +private: + virtual ~ConnectionHandle(); +}; + +nsAHttpConnection * +nsHttpConnectionMgr::MakeConnectionHandle(nsHttpConnection *aWrapped) +{ + return new ConnectionHandle(aWrapped); +} + +ConnectionHandle::~ConnectionHandle() +{ + if (mConn) { + gHttpHandler->ReclaimConnection(mConn); + NS_RELEASE(mConn); + } +} + +NS_IMPL_ISUPPORTS0(ConnectionHandle) // Use this method for dispatching nsAHttpTransction's. It can only safely be // used upon first use of a connection when NPN has not negotiated SPDY vs @@ -1994,7 +1964,7 @@ nsHttpConnectionMgr::DispatchAbstractTransaction(nsConnectionEntry *ent, transaction = aTrans; } - RefPtr handle = new nsConnectionHandle(conn); + RefPtr handle = new ConnectionHandle(conn); // give the transaction the indirect reference to the connection. transaction->SetConnection(handle); @@ -2263,7 +2233,7 @@ nsHttpConnectionMgr::ProcessSpdyPendingQCB(const nsACString &key, } void -nsHttpConnectionMgr::OnMsgProcessAllSpdyPendingQ(int32_t, void *) +nsHttpConnectionMgr::OnMsgProcessAllSpdyPendingQ(int32_t, ARefBase *) { MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread); LOG(("nsHttpConnectionMgr::OnMsgProcessAllSpdyPendingQ\n")); @@ -2304,7 +2274,7 @@ nsHttpConnectionMgr::GetSpdyPreferredConn(nsConnectionEntry *ent) //----------------------------------------------------------------------------- void -nsHttpConnectionMgr::OnMsgShutdown(int32_t, void *param) +nsHttpConnectionMgr::OnMsgShutdown(int32_t, ARefBase *param) { MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread); LOG(("nsHttpConnectionMgr::OnMsgShutdown\n")); @@ -2327,41 +2297,40 @@ nsHttpConnectionMgr::OnMsgShutdown(int32_t, void *param) // signal shutdown complete nsCOMPtr runnable = - new nsConnEvent(this, &nsHttpConnectionMgr::OnMsgShutdownConfirm, - 0, param); + new ConnEvent(this, &nsHttpConnectionMgr::OnMsgShutdownConfirm, + 0, param); NS_DispatchToMainThread(runnable); } void -nsHttpConnectionMgr::OnMsgShutdownConfirm(int32_t priority, void *param) +nsHttpConnectionMgr::OnMsgShutdownConfirm(int32_t priority, ARefBase *param) { MOZ_ASSERT(NS_IsMainThread()); LOG(("nsHttpConnectionMgr::OnMsgShutdownConfirm\n")); - bool *shutdown = static_cast(param); - *shutdown = true; + BoolWrapper *shutdown = static_cast(param); + shutdown->mBool = true; } void -nsHttpConnectionMgr::OnMsgNewTransaction(int32_t priority, void *param) +nsHttpConnectionMgr::OnMsgNewTransaction(int32_t priority, ARefBase *param) { LOG(("nsHttpConnectionMgr::OnMsgNewTransaction [trans=%p]\n", param)); - nsHttpTransaction *trans = (nsHttpTransaction *) param; + nsHttpTransaction *trans = static_cast(param); trans->SetPriority(priority); nsresult rv = ProcessNewTransaction(trans); if (NS_FAILED(rv)) trans->Close(rv); // for whatever its worth - NS_RELEASE(trans); } void -nsHttpConnectionMgr::OnMsgReschedTransaction(int32_t priority, void *param) +nsHttpConnectionMgr::OnMsgReschedTransaction(int32_t priority, ARefBase *param) { MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread); LOG(("nsHttpConnectionMgr::OnMsgReschedTransaction [trans=%p]\n", param)); - nsHttpTransaction *trans = (nsHttpTransaction *) param; + nsHttpTransaction *trans = static_cast(param); trans->SetPriority(priority); nsConnectionEntry *ent = LookupConnectionEntry(trans->ConnectionInfo(), @@ -2374,19 +2343,16 @@ nsHttpConnectionMgr::OnMsgReschedTransaction(int32_t priority, void *param) InsertTransactionSorted(ent->mPendingQ, trans); } } - - NS_RELEASE(trans); } void -nsHttpConnectionMgr::OnMsgCancelTransaction(int32_t reason, void *param) +nsHttpConnectionMgr::OnMsgCancelTransaction(int32_t reason, ARefBase *param) { MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread); LOG(("nsHttpConnectionMgr::OnMsgCancelTransaction [trans=%p]\n", param)); nsresult closeCode = static_cast(reason); - RefPtr trans = - dont_AddRef(static_cast(param)); + nsHttpTransaction *trans = static_cast(param); // // if the transaction owns a connection and the transaction is not done, @@ -2404,7 +2370,7 @@ nsHttpConnectionMgr::OnMsgCancelTransaction(int32_t reason, void *param) int32_t index = ent->mPendingQ.IndexOf(trans); if (index >= 0) { LOG(("nsHttpConnectionMgr::OnMsgCancelTransaction [trans=%p]" - " found in pending queue\n", trans.get())); + " found in pending queue\n", trans)); ent->mPendingQ.RemoveElementAt(index); nsHttpTransaction *temp = trans; NS_RELEASE(temp); // b/c NS_RELEASE nulls its argument! @@ -2439,7 +2405,7 @@ nsHttpConnectionMgr::OnMsgCancelTransaction(int32_t reason, void *param) if (liveTransaction && liveTransaction->IsNullTransaction()) { LOG(("nsHttpConnectionMgr::OnMsgCancelTransaction [trans=%p] " "also canceling Null Transaction %p on conn %p\n", - trans.get(), liveTransaction, activeConn)); + trans, liveTransaction, activeConn)); activeConn->CloseTransaction(liveTransaction, closeCode); } } @@ -2447,10 +2413,10 @@ nsHttpConnectionMgr::OnMsgCancelTransaction(int32_t reason, void *param) } void -nsHttpConnectionMgr::OnMsgProcessPendingQ(int32_t, void *param) +nsHttpConnectionMgr::OnMsgProcessPendingQ(int32_t, ARefBase *param) { MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread); - nsHttpConnectionInfo *ci = (nsHttpConnectionInfo *) param; + nsHttpConnectionInfo *ci = static_cast(param); if (!ci) { LOG(("nsHttpConnectionMgr::OnMsgProcessPendingQ [ci=nullptr]\n")); @@ -2469,30 +2435,22 @@ nsHttpConnectionMgr::OnMsgProcessPendingQ(int32_t, void *param) // for the specified connection info. walk the connection table... mCT.Enumerate(ProcessOneTransactionCB, this); } - - NS_RELEASE(ci); } nsresult -nsHttpConnectionMgr::CancelTransactions(nsHttpConnectionInfo *aCI, nsresult code) +nsHttpConnectionMgr::CancelTransactions(nsHttpConnectionInfo *ci, nsresult code) { - RefPtr ci(aCI); LOG(("nsHttpConnectionMgr::CancelTransactions %s\n",ci->HashKey().get())); int32_t intReason = static_cast(code); - nsresult rv = PostEvent(&nsHttpConnectionMgr::OnMsgCancelTransactions, intReason, ci); - if (NS_SUCCEEDED(rv)) { - unused << ci.forget(); - } - return rv; + return PostEvent(&nsHttpConnectionMgr::OnMsgCancelTransactions, intReason, ci); } void -nsHttpConnectionMgr::OnMsgCancelTransactions(int32_t code, void *param) +nsHttpConnectionMgr::OnMsgCancelTransactions(int32_t code, ARefBase *param) { nsresult reason = static_cast(code); - RefPtr ci = - dont_AddRef(static_cast(param)); + nsHttpConnectionInfo *ci = static_cast(param); nsConnectionEntry *ent = mCT.Get(ci->HashKey()); LOG(("nsHttpConnectionMgr::OnMsgCancelTransactions %s %p\n", ci->HashKey().get(), ent)); @@ -2512,7 +2470,7 @@ nsHttpConnectionMgr::OnMsgCancelTransactions(int32_t code, void *param) } void -nsHttpConnectionMgr::OnMsgPruneDeadConnections(int32_t, void *) +nsHttpConnectionMgr::OnMsgPruneDeadConnections(int32_t, ARefBase *) { MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread); LOG(("nsHttpConnectionMgr::OnMsgPruneDeadConnections\n")); @@ -2527,7 +2485,7 @@ nsHttpConnectionMgr::OnMsgPruneDeadConnections(int32_t, void *) } void -nsHttpConnectionMgr::OnMsgPruneNoTraffic(int32_t, void *) +nsHttpConnectionMgr::OnMsgPruneNoTraffic(int32_t, ARefBase *) { MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread); LOG(("nsHttpConnectionMgr::OnMsgPruneNoTraffic\n")); @@ -2539,7 +2497,7 @@ nsHttpConnectionMgr::OnMsgPruneNoTraffic(int32_t, void *) } void -nsHttpConnectionMgr::OnMsgVerifyTraffic(int32_t, void *) +nsHttpConnectionMgr::OnMsgVerifyTraffic(int32_t, ARefBase *) { MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread); LOG(("nsHttpConnectionMgr::OnMsgVerifyTraffic\n")); @@ -2571,13 +2529,12 @@ nsHttpConnectionMgr::OnMsgVerifyTraffic(int32_t, void *) } void -nsHttpConnectionMgr::OnMsgDoShiftReloadConnectionCleanup(int32_t, void *param) +nsHttpConnectionMgr::OnMsgDoShiftReloadConnectionCleanup(int32_t, ARefBase *param) { LOG(("nsHttpConnectionMgr::OnMsgDoShiftReloadConnectionCleanup\n")); MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread); - RefPtr ci = - dont_AddRef(static_cast(param)); + nsHttpConnectionInfo *ci = static_cast(param); mCT.Enumerate(ClosePersistentConnectionsCB, this); if (ci) @@ -2585,12 +2542,12 @@ nsHttpConnectionMgr::OnMsgDoShiftReloadConnectionCleanup(int32_t, void *param) } void -nsHttpConnectionMgr::OnMsgReclaimConnection(int32_t, void *param) +nsHttpConnectionMgr::OnMsgReclaimConnection(int32_t, ARefBase *param) { MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread); LOG(("nsHttpConnectionMgr::OnMsgReclaimConnection [conn=%p]\n", param)); - nsHttpConnection *conn = (nsHttpConnection *) param; + nsHttpConnection *conn = static_cast(param); // // 1) remove the connection from the active list @@ -2611,8 +2568,7 @@ nsHttpConnectionMgr::OnMsgReclaimConnection(int32_t, void *param) } MOZ_ASSERT(ent); - nsHttpConnectionInfo *ci = nullptr; - NS_ADDREF(ci = ent->mConnInfo); + RefPtr ci(ent->mConnInfo); // If the connection is in the active list, remove that entry // and the reference held by the mActiveConns list. @@ -2678,15 +2634,14 @@ nsHttpConnectionMgr::OnMsgReclaimConnection(int32_t, void *param) conn->Close(NS_ERROR_ABORT); } - OnMsgProcessPendingQ(0, ci); // releases |ci| - NS_RELEASE(conn); + OnMsgProcessPendingQ(0, ci); } void -nsHttpConnectionMgr::OnMsgCompleteUpgrade(int32_t, void *param) +nsHttpConnectionMgr::OnMsgCompleteUpgrade(int32_t, ARefBase *param) { MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread); - nsCompleteUpgradeData *data = (nsCompleteUpgradeData *) param; + nsCompleteUpgradeData *data = static_cast(param); LOG(("nsHttpConnectionMgr::OnMsgCompleteUpgrade " "this=%p conn=%p listener=%p\n", this, data->mConn.get(), data->mUpgradeListener.get())); @@ -2704,14 +2659,14 @@ nsHttpConnectionMgr::OnMsgCompleteUpgrade(int32_t, void *param) data->mUpgradeListener->OnTransportAvailable(socketTransport, socketIn, socketOut); - delete data; } void -nsHttpConnectionMgr::OnMsgUpdateParam(int32_t, void *param) +nsHttpConnectionMgr::OnMsgUpdateParam(int32_t inParam, ARefBase *) { - uint16_t name = (NS_PTR_TO_INT32(param) & 0xFFFF0000) >> 16; - uint16_t value = NS_PTR_TO_INT32(param) & 0x0000FFFF; + uint32_t param = static_cast(inParam); + uint16_t name = ((param) & 0xFFFF0000) >> 16; + uint16_t value = param & 0x0000FFFF; switch (name) { case MAX_CONNECTIONS: @@ -2745,13 +2700,11 @@ nsHttpConnectionMgr::nsConnectionEntry::~nsConnectionEntry() } void -nsHttpConnectionMgr::OnMsgProcessFeedback(int32_t, void *param) +nsHttpConnectionMgr::OnMsgProcessFeedback(int32_t, ARefBase *param) { MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread); - nsHttpPipelineFeedback *fb = (nsHttpPipelineFeedback *)param; - + nsHttpPipelineFeedback *fb = static_cast(param); PipelineFeedbackInfo(fb->mConnInfo, fb->mInfo, fb->mConn, fb->mData); - delete fb; } // Read Timeout Tick handlers @@ -2864,19 +2817,6 @@ nsHttpConnectionMgr::TimeoutTickCB(const nsACString &key, return PL_DHASH_NEXT; } -//----------------------------------------------------------------------------- -// nsHttpConnectionMgr::nsConnectionHandle - -nsHttpConnectionMgr::nsConnectionHandle::~nsConnectionHandle() -{ - if (mConn) { - gHttpHandler->ReclaimConnection(mConn); - NS_RELEASE(mConn); - } -} - -NS_IMPL_ISUPPORTS0(nsHttpConnectionMgr::nsConnectionHandle) - // GetOrCreateConnectionEntry finds a ent for a particular CI for use in // dispatching a transaction according to these rules // 1] use an ent that matches the ci that can be dispatched immediately @@ -2917,36 +2857,34 @@ nsHttpConnectionMgr::GetOrCreateConnectionEntry(nsHttpConnectionInfo *specificCI } nsresult -nsHttpConnectionMgr::nsConnectionHandle::OnHeadersAvailable(nsAHttpTransaction *trans, - nsHttpRequestHead *req, - nsHttpResponseHead *resp, - bool *reset) +ConnectionHandle::OnHeadersAvailable(nsAHttpTransaction *trans, + nsHttpRequestHead *req, + nsHttpResponseHead *resp, + bool *reset) { return mConn->OnHeadersAvailable(trans, req, resp, reset); } void -nsHttpConnectionMgr::nsConnectionHandle::CloseTransaction(nsAHttpTransaction *trans, nsresult reason) +ConnectionHandle::CloseTransaction(nsAHttpTransaction *trans, nsresult reason) { mConn->CloseTransaction(trans, reason); } nsresult -nsHttpConnectionMgr:: -nsConnectionHandle::TakeTransport(nsISocketTransport **aTransport, - nsIAsyncInputStream **aInputStream, - nsIAsyncOutputStream **aOutputStream) +ConnectionHandle::TakeTransport(nsISocketTransport **aTransport, + nsIAsyncInputStream **aInputStream, + nsIAsyncOutputStream **aOutputStream) { return mConn->TakeTransport(aTransport, aInputStream, aOutputStream); } void -nsHttpConnectionMgr::OnMsgSpeculativeConnect(int32_t, void *param) +nsHttpConnectionMgr::OnMsgSpeculativeConnect(int32_t, ARefBase *param) { MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread); - RefPtr args = - dont_AddRef(static_cast(param)); + SpeculativeConnectArgs *args = static_cast(param); LOG(("nsHttpConnectionMgr::OnMsgSpeculativeConnect [ci=%s]\n", args->mTrans->ConnectionInfo()->HashKey().get())); @@ -2990,25 +2928,25 @@ nsHttpConnectionMgr::OnMsgSpeculativeConnect(int32_t, void *param) } bool -nsHttpConnectionMgr::nsConnectionHandle::IsPersistent() +ConnectionHandle::IsPersistent() { return mConn->IsPersistent(); } bool -nsHttpConnectionMgr::nsConnectionHandle::IsReused() +ConnectionHandle::IsReused() { return mConn->IsReused(); } void -nsHttpConnectionMgr::nsConnectionHandle::DontReuse() +ConnectionHandle::DontReuse() { mConn->DontReuse(); } nsresult -nsHttpConnectionMgr::nsConnectionHandle::PushBack(const char *buf, uint32_t bufLen) +ConnectionHandle::PushBack(const char *buf, uint32_t bufLen) { return mConn->PushBack(buf, bufLen); } @@ -3461,10 +3399,7 @@ nsHalfOpenSocket::OnOutputStreamReady(nsIAsyncOutputStream *out) // otherwise just put this in the persistent connection pool LOG(("nsHalfOpenSocket::OnOutputStreamReady no transaction match " "returning conn %p to pool\n", conn.get())); - RefPtr copy(conn); - // forget() to effectively addref because onmsg*() will drop a ref - gHttpHandler->ConnMgr()->OnMsgReclaimConnection( - 0, conn.forget().take()); + gHttpHandler->ConnMgr()->OnMsgReclaimConnection(0, conn); } } @@ -3579,7 +3514,7 @@ nsHttpConnectionMgr::nsHalfOpenSocket::GetInterface(const nsIID &iid, nsHttpConnection * -nsHttpConnectionMgr::nsConnectionHandle::TakeHttpConnection() +ConnectionHandle::TakeHttpConnection() { // return our connection object to the caller and clear it internally // do not drop our reference - the caller now owns it. @@ -3591,19 +3526,19 @@ nsHttpConnectionMgr::nsConnectionHandle::TakeHttpConnection() } uint32_t -nsHttpConnectionMgr::nsConnectionHandle::CancelPipeline(nsresult reason) +ConnectionHandle::CancelPipeline(nsresult reason) { // no pipeline to cancel return 0; } nsAHttpTransaction::Classifier -nsHttpConnectionMgr::nsConnectionHandle::Classification() +ConnectionHandle::Classification() { if (mConn) return mConn->Classification(); - LOG(("nsConnectionHandle::Classification this=%p " + LOG(("ConnectionHandle::Classification this=%p " "has null mConn using CLASS_SOLO default", this)); return nsAHttpTransaction::CLASS_SOLO; } @@ -3619,7 +3554,6 @@ nsConnectionEntry::nsConnectionEntry(nsHttpConnectionInfo *ci) , mYellowConnection(nullptr) , mGreenDepth(kPipelineOpen) , mPipeliningPenalty(0) - , mSpdyCWND(0) , mUsingSpdy(false) , mTestedSpdy(false) , mInPreferredHash(false) diff --git a/netwerk/protocol/http/nsHttpConnectionMgr.h b/netwerk/protocol/http/nsHttpConnectionMgr.h index f8679c1302..555704f6cf 100644 --- a/netwerk/protocol/http/nsHttpConnectionMgr.h +++ b/netwerk/protocol/http/nsHttpConnectionMgr.h @@ -17,6 +17,7 @@ #include "mozilla/TimeStamp.h" #include "mozilla/Attributes.h" #include "AlternateServices.h" +#include "ARefBase.h" #include "nsIObserver.h" #include "nsITimer.h" @@ -31,6 +32,10 @@ struct HttpRetParams; //----------------------------------------------------------------------------- +// message handlers have this signature +class nsHttpConnectionMgr; +typedef void (nsHttpConnectionMgr:: *nsConnEventHandler)(int32_t, ARefBase *); + class nsHttpConnectionMgr final : public nsIObserver , public AltSvcCache { @@ -242,11 +247,6 @@ public: // bit different. void ReportSpdyConnection(nsHttpConnection *, bool usingSpdy); - // A spdy server can supply cwnd information for the session that is used - // in future sessions to speed up the opening portions of the connection. - void ReportSpdyCWNDSetting(nsHttpConnectionInfo *host, uint32_t cwndValue); - uint32_t GetSpdyCWNDSetting(nsHttpConnectionInfo *host); - bool SupportsPipelining(nsHttpConnectionInfo *); bool GetConnectionData(nsTArray *); @@ -366,11 +366,6 @@ private: // nsTArray mCoalescingKeys; - // The value of a recevied SPDY settings type 5 previously received - // for this connection entry and the time it was set. - uint32_t mSpdyCWND; - TimeStamp mSpdyCWNDTimeStamp; - // To have the UsingSpdy flag means some host with the same connection // entry has done NPN=spdy/* at some point. It does not mean every // connection is currently using spdy. @@ -399,32 +394,9 @@ private: void ResetIPFamilyPreference(); }; - // nsConnectionHandle - // - // thin wrapper around a real connection, used to keep track of references - // to the connection to determine when the connection may be reused. the - // transaction (or pipeline) owns a reference to this handle. this extra - // layer of indirection greatly simplifies consumer code, avoiding the - // need for consumer code to know when to give the connection back to the - // connection manager. - // - class nsConnectionHandle : public nsAHttpConnection - { - virtual ~nsConnectionHandle(); - - public: - NS_DECL_THREADSAFE_ISUPPORTS - NS_DECL_NSAHTTPCONNECTION(mConn) - - explicit nsConnectionHandle(nsHttpConnection *conn) { NS_ADDREF(mConn = conn); } - - nsHttpConnection *mConn; - }; public: - static nsAHttpConnection *MakeConnectionHandle(nsHttpConnection *aWrapped) - { - return new nsConnectionHandle(aWrapped); - } + static nsAHttpConnection *MakeConnectionHandle(nsHttpConnection *aWrapped); + private: // nsHalfOpenSocket is used to hold the state of an opening TCP socket @@ -532,7 +504,7 @@ private: uint16_t mMaxRequestDelay; // in seconds uint16_t mMaxPipelinedRequests; uint16_t mMaxOptimisticPipelinedRequests; - bool mIsShuttingDown; + Atomic mIsShuttingDown; //------------------------------------------------------------------------- // NOTE: these members are only accessed on the socket transport thread @@ -603,72 +575,30 @@ private: const nsACString &key, nsAutoPtr &ent, void *closure); - // message handlers have this signature - typedef void (nsHttpConnectionMgr:: *nsConnEventHandler)(int32_t, void *); - - // nsConnEvent - // - // subclass of nsRunnable used to marshall events to the socket transport - // thread. this class is used to implement PostEvent. - // - class nsConnEvent; - friend class nsConnEvent; - class nsConnEvent : public nsRunnable - { - public: - nsConnEvent(nsHttpConnectionMgr *mgr, - nsConnEventHandler handler, - int32_t iparam, - void *vparam) - : mMgr(mgr) - , mHandler(handler) - , mIParam(iparam) - , mVParam(vparam) - { - NS_ADDREF(mMgr); - } - - NS_IMETHOD Run() - { - (mMgr->*mHandler)(mIParam, mVParam); - return NS_OK; - } - - private: - virtual ~nsConnEvent() - { - NS_RELEASE(mMgr); - } - - nsHttpConnectionMgr *mMgr; - nsConnEventHandler mHandler; - int32_t mIParam; - void *mVParam; - }; - + // used to marshall events to the socket transport thread. nsresult PostEvent(nsConnEventHandler handler, int32_t iparam = 0, - void *vparam = nullptr); + ARefBase *vparam = nullptr); // message handlers - void OnMsgShutdown (int32_t, void *); - void OnMsgShutdownConfirm (int32_t, void *); - void OnMsgNewTransaction (int32_t, void *); - void OnMsgReschedTransaction (int32_t, void *); - void OnMsgCancelTransaction (int32_t, void *); - void OnMsgCancelTransactions (int32_t, void *); - void OnMsgProcessPendingQ (int32_t, void *); - void OnMsgPruneDeadConnections (int32_t, void *); - void OnMsgSpeculativeConnect (int32_t, void *); - void OnMsgReclaimConnection (int32_t, void *); - void OnMsgCompleteUpgrade (int32_t, void *); - void OnMsgUpdateParam (int32_t, void *); - void OnMsgDoShiftReloadConnectionCleanup (int32_t, void *); - void OnMsgProcessFeedback (int32_t, void *); - void OnMsgProcessAllSpdyPendingQ (int32_t, void *); - void OnMsgUpdateRequestTokenBucket (int32_t, void *); - void OnMsgVerifyTraffic (int32_t, void *); - void OnMsgPruneNoTraffic (int32_t, void *); + void OnMsgShutdown (int32_t, ARefBase *); + void OnMsgShutdownConfirm (int32_t, ARefBase *); + void OnMsgNewTransaction (int32_t, ARefBase *); + void OnMsgReschedTransaction (int32_t, ARefBase *); + void OnMsgCancelTransaction (int32_t, ARefBase *); + void OnMsgCancelTransactions (int32_t, ARefBase *); + void OnMsgProcessPendingQ (int32_t, ARefBase *); + void OnMsgPruneDeadConnections (int32_t, ARefBase *); + void OnMsgSpeculativeConnect (int32_t, ARefBase *); + void OnMsgReclaimConnection (int32_t, ARefBase *); + void OnMsgCompleteUpgrade (int32_t, ARefBase *); + void OnMsgUpdateParam (int32_t, ARefBase *); + void OnMsgDoShiftReloadConnectionCleanup (int32_t, ARefBase *); + void OnMsgProcessFeedback (int32_t, ARefBase *); + void OnMsgProcessAllSpdyPendingQ (int32_t, ARefBase *); + void OnMsgUpdateRequestTokenBucket (int32_t, ARefBase *); + void OnMsgVerifyTraffic (int32_t, ARefBase *); + void OnMsgPruneNoTraffic (int32_t, ARefBase *); // Total number of active connections in all of the ConnectionEntry objects // that are accessed from mCT connection table. @@ -720,7 +650,7 @@ private: void *closure); // For diagnostics - void OnMsgPrintDiagnostics(int32_t, void *); + void OnMsgPrintDiagnostics(int32_t, ARefBase *); static PLDHashOperator PrintDiagnosticsCB(const nsACString &key, nsAutoPtr &ent, void *closure); diff --git a/netwerk/protocol/http/nsHttpTransaction.h b/netwerk/protocol/http/nsHttpTransaction.h index 4cb8ecd8a3..8cc3ac946e 100644 --- a/netwerk/protocol/http/nsHttpTransaction.h +++ b/netwerk/protocol/http/nsHttpTransaction.h @@ -16,6 +16,7 @@ #include "TimingStruct.h" #include "Http2Push.h" #include "mozilla/net/DNS.h" +#include "ARefBase.h" #ifdef MOZ_WIDGET_GONK #include "nsINetworkInterface.h" @@ -45,6 +46,7 @@ class nsHttpTransaction final : public nsAHttpTransaction , public ATokenBucketEvent , public nsIInputStreamCallback , public nsIOutputStreamCallback + , public ARefBase { public: NS_DECL_THREADSAFE_ISUPPORTS diff --git a/netwerk/protocol/res/SubstitutingProtocolHandler.cpp b/netwerk/protocol/res/SubstitutingProtocolHandler.cpp index 5f6e82c077..e719cb228b 100644 --- a/netwerk/protocol/res/SubstitutingProtocolHandler.cpp +++ b/netwerk/protocol/res/SubstitutingProtocolHandler.cpp @@ -169,7 +169,7 @@ SubstitutingProtocolHandler::SendSubstitution(const nsACString& aRoot, nsIURI* a } for (uint32_t i = 0; i < parents.Length(); i++) { - unused << parents[i]->SendRegisterChromeItem(mapping); + Unused << parents[i]->SendRegisterChromeItem(mapping); } } diff --git a/netwerk/protocol/res/nsResProtocolHandler.cpp b/netwerk/protocol/res/nsResProtocolHandler.cpp index 9dbef19b47..a5d5572aff 100644 --- a/netwerk/protocol/res/nsResProtocolHandler.cpp +++ b/netwerk/protocol/res/nsResProtocolHandler.cpp @@ -19,7 +19,7 @@ using mozilla::dom::ContentParent; using mozilla::LogLevel; -using mozilla::unused; +using mozilla::Unused; #define kAPP NS_LITERAL_CSTRING("app") #define kGRE NS_LITERAL_CSTRING("gre") diff --git a/netwerk/protocol/rtsp/controller/RtspControllerParent.cpp b/netwerk/protocol/rtsp/controller/RtspControllerParent.cpp index aa1923b6ad..915d086a74 100644 --- a/netwerk/protocol/rtsp/controller/RtspControllerParent.cpp +++ b/netwerk/protocol/rtsp/controller/RtspControllerParent.cpp @@ -23,7 +23,7 @@ PRLogModuleInfo* gRtspLog; #define SEND_DISCONNECT_IF_ERROR(rv) \ if (NS_FAILED(rv) && mIPCOpen && mTotalTracks > 0ul) { \ for (uint32_t i = 0; i < mTotalTracks; i++) { \ - unused << SendOnDisconnected(i, rv); \ + Unused << SendOnDisconnected(i, rv); \ } \ } diff --git a/netwerk/protocol/websocket/WebSocketEventListenerParent.cpp b/netwerk/protocol/websocket/WebSocketEventListenerParent.cpp index ef1d57188e..9a55671af4 100644 --- a/netwerk/protocol/websocket/WebSocketEventListenerParent.cpp +++ b/netwerk/protocol/websocket/WebSocketEventListenerParent.cpp @@ -35,7 +35,7 @@ WebSocketEventListenerParent::RecvClose() { if (mService) { UnregisterListener(); - unused << Send__delete__(this); + Unused << Send__delete__(this); } return true; @@ -61,7 +61,7 @@ WebSocketEventListenerParent::WebSocketCreated(uint32_t aWebSocketSerialID, const nsAString& aURI, const nsACString& aProtocols) { - unused << SendWebSocketCreated(aWebSocketSerialID, nsString(aURI), + Unused << SendWebSocketCreated(aWebSocketSerialID, nsString(aURI), nsCString(aProtocols)); return NS_OK; } @@ -72,7 +72,7 @@ WebSocketEventListenerParent::WebSocketOpened(uint32_t aWebSocketSerialID, const nsACString& aProtocols, const nsACString& aExtensions) { - unused << SendWebSocketOpened(aWebSocketSerialID, nsString(aEffectiveURI), + Unused << SendWebSocketOpened(aWebSocketSerialID, nsString(aEffectiveURI), nsCString(aProtocols), nsCString(aExtensions)); return NS_OK; } @@ -83,7 +83,7 @@ WebSocketEventListenerParent::WebSocketClosed(uint32_t aWebSocketSerialID, uint16_t aCode, const nsAString& aReason) { - unused << SendWebSocketClosed(aWebSocketSerialID, aWasClean, aCode, + Unused << SendWebSocketClosed(aWebSocketSerialID, aWasClean, aCode, nsString(aReason)); return NS_OK; } @@ -93,7 +93,7 @@ WebSocketEventListenerParent::WebSocketMessageAvailable(uint32_t aWebSocketSeria const nsACString& aData, uint16_t aMessageType) { - unused << SendWebSocketMessageAvailable(aWebSocketSerialID, nsCString(aData), + Unused << SendWebSocketMessageAvailable(aWebSocketSerialID, nsCString(aData), aMessageType); return NS_OK; } @@ -107,7 +107,7 @@ WebSocketEventListenerParent::FrameReceived(uint32_t aWebSocketSerialID, } WebSocketFrame* frame = static_cast(aFrame); - unused << SendFrameReceived(aWebSocketSerialID, frame->Data()); + Unused << SendFrameReceived(aWebSocketSerialID, frame->Data()); return NS_OK; } @@ -120,7 +120,7 @@ WebSocketEventListenerParent::FrameSent(uint32_t aWebSocketSerialID, } WebSocketFrame* frame = static_cast(aFrame); - unused << SendFrameSent(aWebSocketSerialID, frame->Data()); + Unused << SendFrameSent(aWebSocketSerialID, frame->Data()); return NS_OK; } diff --git a/netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp b/netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp index 845b8f02f2..8e88610d25 100644 --- a/netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp +++ b/netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp @@ -43,7 +43,7 @@ public: NS_WARN_IF_FALSE(thread, "Couldn't get the main thread!"); if (thread) { nsIWyciwygChannel *chan = static_cast(mChannel); - mozilla::unused << mChannel.forget(); + mozilla::Unused << mChannel.forget(); NS_ProxyRelease(thread, chan); } } diff --git a/netwerk/sctp/datachannel/DataChannel.cpp b/netwerk/sctp/datachannel/DataChannel.cpp index f33603f145..de654f9a06 100644 --- a/netwerk/sctp/datachannel/DataChannel.cpp +++ b/netwerk/sctp/datachannel/DataChannel.cpp @@ -2390,7 +2390,7 @@ public: if (!NS_IsMainThread() && mConnection) { MOZ_ASSERT(false); // explicitly leak the connection if destroyed off mainthread - unused << mConnection.forget().take(); + Unused << mConnection.forget().take(); } } diff --git a/netwerk/test/TestOpen.cpp b/netwerk/test/TestOpen.cpp index 9b40041ea3..867b2610e2 100644 --- a/netwerk/test/TestOpen.cpp +++ b/netwerk/test/TestOpen.cpp @@ -79,7 +79,7 @@ main(int argc, char **argv) uint32_t read; while (NS_SUCCEEDED(stream->Read(buf, sizeof(buf), &read)) && read) { - unused << fwrite(buf, 1, read, outfile); + Unused << fwrite(buf, 1, read, outfile); } printf("Done\n"); diff --git a/netwerk/test/TestProtocols.cpp b/netwerk/test/TestProtocols.cpp index fa8ff15099..9de713d9c2 100644 --- a/netwerk/test/TestProtocols.cpp +++ b/netwerk/test/TestProtocols.cpp @@ -311,7 +311,7 @@ TestAuthPrompt::PromptUsernameAndPassword(const char16_t *dialogTitle, int n; printf("Enter username: "); - unused << fgets(buf, sizeof(buf), stdin); + Unused << fgets(buf, sizeof(buf), stdin); n = strlen(buf); buf[n-1] = '\0'; // trim trailing newline *user = NS_StringCloneData(NS_ConvertUTF8toUTF16(buf)); @@ -808,7 +808,7 @@ nsresult LoadURLFromConsole() { char buffer[1024]; printf("Enter URL (\"q\" to start): "); - unused << scanf("%s", buffer); + Unused << scanf("%s", buffer); if (buffer[0]=='q') gAskUserForInput = false; else diff --git a/parser/html/nsHtml5Atom.cpp b/parser/html/nsHtml5Atom.cpp index 16c65139d8..4d84bcb68c 100644 --- a/parser/html/nsHtml5Atom.cpp +++ b/parser/html/nsHtml5Atom.cpp @@ -25,7 +25,7 @@ nsHtml5Atom::nsHtml5Atom(const nsAString& aString) NS_ASSERTION(Equals(aString), "correct data"); // Take ownership of buffer - mozilla::unused << buf.forget(); + mozilla::Unused << buf.forget(); } nsHtml5Atom::~nsHtml5Atom() diff --git a/security/manager/ssl/DataStorage.cpp b/security/manager/ssl/DataStorage.cpp index ce81ab879c..f85b00a639 100644 --- a/security/manager/ssl/DataStorage.cpp +++ b/security/manager/ssl/DataStorage.cpp @@ -116,7 +116,7 @@ DataStorage::Reader::~Reader() MonitorAutoLock readyLock(mDataStorage->mReadyMonitor); mDataStorage->mReady = true; nsresult rv = mDataStorage->mReadyMonitor.NotifyAll(); - unused << NS_WARN_IF(NS_FAILED(rv)); + Unused << NS_WARN_IF(NS_FAILED(rv)); } // This is for tests. @@ -125,7 +125,7 @@ DataStorage::Reader::~Reader() &DataStorage::NotifyObservers, "data-storage-ready"); nsresult rv = NS_DispatchToMainThread(job, NS_DISPATCH_NORMAL); - unused << NS_WARN_IF(NS_FAILED(rv)); + Unused << NS_WARN_IF(NS_FAILED(rv)); } NS_IMETHODIMP @@ -501,7 +501,7 @@ DataStorage::Remove(const nsCString& aKey, DataStorageType aType) table.Remove(aKey); if (aType == DataStorage_Persistent && !mPendingWrite) { - unused << AsyncSetTimer(lock); + Unused << AsyncSetTimer(lock); } } @@ -635,7 +635,7 @@ DataStorage::TimerCallback(nsITimer* aTimer, void* aClosure) { RefPtr aDataStorage = (DataStorage*)aClosure; MutexAutoLock lock(aDataStorage->mMutex); - unused << aDataStorage->AsyncWriteData(lock); + Unused << aDataStorage->AsyncWriteData(lock); } // We only initialize the timer on the worker thread because it's not safe @@ -673,7 +673,7 @@ DataStorage::SetTimer() rv = mTimer->InitWithFuncCallback(TimerCallback, this, mTimerDelay, nsITimer::TYPE_ONE_SHOT); - unused << NS_WARN_IF(NS_FAILED(rv)); + Unused << NS_WARN_IF(NS_FAILED(rv)); } void @@ -709,7 +709,7 @@ DataStorage::ShutdownTimer() MOZ_ASSERT(!NS_IsMainThread()); MutexAutoLock lock(mMutex); nsresult rv = mTimer->Cancel(); - unused << NS_WARN_IF(NS_FAILED(rv)); + Unused << NS_WARN_IF(NS_FAILED(rv)); mTimer = nullptr; } @@ -736,10 +736,10 @@ DataStorage::Observe(nsISupports* aSubject, const char* aTopic, MutexAutoLock lock(mMutex); rv = AsyncWriteData(lock); mShuttingDown = true; - unused << NS_WARN_IF(NS_FAILED(rv)); + Unused << NS_WARN_IF(NS_FAILED(rv)); if (mTimer) { rv = DispatchShutdownTimer(lock); - unused << NS_WARN_IF(NS_FAILED(rv)); + Unused << NS_WARN_IF(NS_FAILED(rv)); } } // Run the thread to completion and prevent any further events diff --git a/security/manager/ssl/PSMContentListener.cpp b/security/manager/ssl/PSMContentListener.cpp index 0afb26a359..faa9f6542a 100644 --- a/security/manager/ssl/PSMContentListener.cpp +++ b/security/manager/ssl/PSMContentListener.cpp @@ -243,7 +243,7 @@ PSMContentDownloaderParent::RecvOnStopRequest(const nsresult& code) } if (mIPCOpen) { - mozilla::unused << Send__delete__(this); + mozilla::Unused << Send__delete__(this); } return true; } @@ -254,7 +254,7 @@ PSMContentDownloaderParent::OnStopRequest(nsIRequest* request, nsISupports* cont nsresult rv = PSMContentStreamListener::OnStopRequest(request, context, code); if (mIPCOpen) { - mozilla::unused << Send__delete__(this); + mozilla::Unused << Send__delete__(this); } return rv; } @@ -265,7 +265,7 @@ PSMContentDownloaderParent::RecvDivertToParentUsing(mozilla::net::PChannelDivert MOZ_ASSERT(diverter); auto p = static_cast(diverter); p->DivertTo(this); - mozilla::unused << p->Send__delete__(p); + mozilla::Unused << p->Send__delete__(p); return true; } @@ -309,7 +309,7 @@ PSMContentDownloaderChild::OnStartRequest(nsIRequest* request, nsISupports* cont return NS_ERROR_FAILURE; } - mozilla::unused << SendOnStartRequest(contentLength); + mozilla::Unused << SendOnStartRequest(contentLength); return NS_OK; } @@ -326,7 +326,7 @@ PSMContentDownloaderChild::OnDataAvailable(nsIRequest* request, return rv; } - mozilla::unused << SendOnDataAvailable(chunk, aSourceOffset, aLength); + mozilla::Unused << SendOnDataAvailable(chunk, aSourceOffset, aLength); return NS_OK; } @@ -335,7 +335,7 @@ PSMContentDownloaderChild::OnStopRequest(nsIRequest* request, nsISupports* context, nsresult aStatus) { - mozilla::unused << SendOnStopRequest(aStatus); + mozilla::Unused << SendOnStopRequest(aStatus); return NS_OK; } diff --git a/security/manager/ssl/SSLServerCertVerification.cpp b/security/manager/ssl/SSLServerCertVerification.cpp index cda07f9a45..6d9603bb9d 100644 --- a/security/manager/ssl/SSLServerCertVerification.cpp +++ b/security/manager/ssl/SSLServerCertVerification.cpp @@ -454,7 +454,7 @@ CertErrorRunnable::CheckCertOverrides() mFdForLogging, this)); // "Use" mFdForLogging in non-PR_LOGGING builds, too, to suppress // clang's -Wunused-private-field build warning for this variable: - unused << mFdForLogging; + Unused << mFdForLogging; if (!NS_IsMainThread()) { NS_ERROR("CertErrorRunnable::CheckCertOverrides called off main thread"); diff --git a/security/manager/ssl/SharedSSLState.cpp b/security/manager/ssl/SharedSSLState.cpp index 8c70d7b8a5..bb22929b5e 100644 --- a/security/manager/ssl/SharedSSLState.cpp +++ b/security/manager/ssl/SharedSSLState.cpp @@ -22,7 +22,7 @@ using mozilla::psm::SyncRunnableBase; using mozilla::Atomic; -using mozilla::unused; +using mozilla::Unused; namespace { diff --git a/security/manager/ssl/nsKeygenHandlerContent.cpp b/security/manager/ssl/nsKeygenHandlerContent.cpp index 3f3b422fe8..6aa5ce7d8f 100644 --- a/security/manager/ssl/nsKeygenHandlerContent.cpp +++ b/security/manager/ssl/nsKeygenHandlerContent.cpp @@ -19,7 +19,7 @@ #include "nsKeygenHandler.h" using mozilla::dom::ContentChild; -using mozilla::unused; +using mozilla::Unused; NS_IMPL_ISUPPORTS(nsKeygenFormProcessorContent, nsIFormProcessor) @@ -45,7 +45,7 @@ nsKeygenFormProcessorContent::ProcessValue(nsIDOMHTMLElement* aElement, nsString oldValue(aValue); nsString newValue; - unused << child->SendKeygenProcessValue(oldValue, challengeValue, + Unused << child->SendKeygenProcessValue(oldValue, challengeValue, keyTypeValue, keyParamsValue, &newValue); @@ -70,7 +70,7 @@ nsKeygenFormProcessorContent::ProvideContent(const nsAString& aFormType, nsAString& aAttribute) { nsString attribute; - unused << + Unused << ContentChild::GetSingleton()->SendKeygenProvideContent(&attribute, &aContent); aAttribute.Assign(attribute); diff --git a/security/manager/ssl/nsSmartCardMonitor.cpp b/security/manager/ssl/nsSmartCardMonitor.cpp index 018d5addea..da13f289b5 100644 --- a/security/manager/ssl/nsSmartCardMonitor.cpp +++ b/security/manager/ssl/nsSmartCardMonitor.cpp @@ -152,7 +152,7 @@ SmartCardThreadList::Add(SmartCardMonitoringThread* thread) SmartCardThreadEntry* current = new SmartCardThreadEntry(thread, head, nullptr, &head); // OK to forget current here, it's on the list. - unused << current; + Unused << current; return thread->Start(); } diff --git a/security/sandbox/linux/Sandbox.cpp b/security/sandbox/linux/Sandbox.cpp index 2582aa8d0e..1949430e18 100644 --- a/security/sandbox/linux/Sandbox.cpp +++ b/security/sandbox/linux/Sandbox.cpp @@ -166,7 +166,7 @@ InstallSigSysHandler(void) struct sigaction act; // Ensure that the Chromium handler is installed. - unused << sandbox::Trap::Registry(); + Unused << sandbox::Trap::Registry(); // If the signal handling state isn't as expected, crash now instead // of crashing later (and more confusingly) when SIGSYS happens. @@ -437,7 +437,7 @@ BroadcastSetThreadSandbox(const sock_fprog* aFilter) signum, oldHandler); MOZ_CRASH(); } - unused << closedir(taskdp); + Unused << closedir(taskdp); // And now, deprivilege the main thread: SetThreadSandbox(); gSetSandboxFilter = nullptr; diff --git a/security/sandbox/linux/SandboxUtil.cpp b/security/sandbox/linux/SandboxUtil.cpp index 623d41ac60..f202a60e41 100644 --- a/security/sandbox/linux/SandboxUtil.cpp +++ b/security/sandbox/linux/SandboxUtil.cpp @@ -89,7 +89,7 @@ UnshareUserNamespace() MOZ_CRASH("Failed to write /proc/self/uid_map"); } - unused << WriteStringToFile("/proc/self/setgroups", "deny", 4); + Unused << WriteStringToFile("/proc/self/setgroups", "deny", 4); len = size_t(snprintf(buf, sizeof(buf), "%u %u 1\n", gid, gid)); MOZ_ASSERT(len < sizeof(buf)); diff --git a/security/sandbox/linux/glue/SandboxCrash.cpp b/security/sandbox/linux/glue/SandboxCrash.cpp index 81efdbc537..71dd50f369 100644 --- a/security/sandbox/linux/glue/SandboxCrash.cpp +++ b/security/sandbox/linux/glue/SandboxCrash.cpp @@ -48,11 +48,11 @@ SandboxLogJSStack(void) // Don't stop unwinding if an attribute can't be read. fileName.SetIsVoid(true); - unused << frame->GetFilename(fileName); + Unused << frame->GetFilename(fileName); lineNumber = 0; - unused << frame->GetLineNumber(&lineNumber); + Unused << frame->GetLineNumber(&lineNumber); funName.SetIsVoid(true); - unused << frame->GetName(funName); + Unused << frame->GetName(funName); if (!funName.IsVoid() || !fileName.IsVoid()) { SANDBOX_LOG_ERROR("JS frame %d: %s %s line %d", i, diff --git a/toolkit/components/parentalcontrols/nsParentalControlsServiceDefault.cpp b/toolkit/components/parentalcontrols/nsParentalControlsServiceDefault.cpp index ddb8a5a5e6..4af3c8a599 100644 --- a/toolkit/components/parentalcontrols/nsParentalControlsServiceDefault.cpp +++ b/toolkit/components/parentalcontrols/nsParentalControlsServiceDefault.cpp @@ -13,7 +13,7 @@ NS_IMPL_ISUPPORTS(nsParentalControlsService, nsIParentalControlsService) nsParentalControlsService::nsParentalControlsService() : mEnabled(false) { - mozilla::unused << mEnabled; + mozilla::Unused << mEnabled; } nsParentalControlsService::~nsParentalControlsService() diff --git a/toolkit/components/perfmonitoring/nsPerformanceStats.cpp b/toolkit/components/perfmonitoring/nsPerformanceStats.cpp index 5bbf1cf084..45b88cffae 100644 --- a/toolkit/components/perfmonitoring/nsPerformanceStats.cpp +++ b/toolkit/components/perfmonitoring/nsPerformanceStats.cpp @@ -437,12 +437,12 @@ nsPerformanceStatsService::Dispose() // Clear up and disconnect from JSAPI. js::DisposePerformanceMonitoring(mRuntime); - mozilla::unused << js::SetStopwatchIsMonitoringCPOW(mRuntime, false); - mozilla::unused << js::SetStopwatchIsMonitoringJank(mRuntime, false); + mozilla::Unused << js::SetStopwatchIsMonitoringCPOW(mRuntime, false); + mozilla::Unused << js::SetStopwatchIsMonitoringJank(mRuntime, false); - mozilla::unused << js::SetStopwatchStartCallback(mRuntime, nullptr, nullptr); - mozilla::unused << js::SetStopwatchCommitCallback(mRuntime, nullptr, nullptr); - mozilla::unused << js::SetGetPerformanceGroupsCallback(mRuntime, nullptr, nullptr); + mozilla::Unused << js::SetStopwatchStartCallback(mRuntime, nullptr, nullptr); + mozilla::Unused << js::SetStopwatchCommitCallback(mRuntime, nullptr, nullptr); + mozilla::Unused << js::SetGetPerformanceGroupsCallback(mRuntime, nullptr, nullptr); // At this stage, the JS VM may still be holding references to // instances of PerformanceGroup on the stack. To let the service be @@ -672,7 +672,7 @@ nsPerformanceStatsService::GetSnapshot(JSContext* cx, nsIPerformanceSnapshot * * js::GetPerfMonitoringTestCpuRescheduling(JS_GetRuntime(cx), &mProcessStayed, &mProcessMoved); if (++mProcessUpdateCounter % 10 == 0) { - mozilla::unused << UpdateTelemetry(); + mozilla::Unused << UpdateTelemetry(); } snapshot.forget(aSnapshot); @@ -984,7 +984,7 @@ nsPerformanceGroup::nsPerformanceGroup(nsPerformanceStatsService* service, , mService(service) , mScope(scope) { - mozilla::unused << mService->mGroups.PutEntry(this); + mozilla::Unused << mService->mGroups.PutEntry(this); #if defined(DEBUG) if (scope == GroupScope::ADDON) { diff --git a/toolkit/components/places/History.cpp b/toolkit/components/places/History.cpp index 7086e8a4ac..c17b86d87a 100644 --- a/toolkit/components/places/History.cpp +++ b/toolkit/components/places/History.cpp @@ -46,7 +46,7 @@ using namespace mozilla::dom; using namespace mozilla::ipc; -using mozilla::unused; +using mozilla::Unused; namespace mozilla { namespace places { @@ -1985,7 +1985,7 @@ History::NotifyVisited(nsIURI* aURI) URIParams uri; SerializeURI(aURI, uri); for (uint32_t i = 0; i < cplist.Length(); ++i) { - unused << cplist[i]->SendNotifyVisited(uri); + Unused << cplist[i]->SendNotifyVisited(uri); } } } diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index 65abbeab7a..aea3a1365e 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -1481,7 +1481,7 @@ "description": "SPDY: KB read per connection" }, "SPDY_SETTINGS_UL_BW": { - "expires_in_version": "never", + "expires_in_version": "42", "kind": "exponential", "high": "10000", "n_buckets": 100, @@ -1489,7 +1489,7 @@ "description": "SPDY: Settings Upload Bandwidth" }, "SPDY_SETTINGS_DL_BW": { - "expires_in_version": "never", + "expires_in_version": "42", "kind": "exponential", "high": "10000", "n_buckets": 100, @@ -1497,7 +1497,7 @@ "description": "SPDY: Settings Download Bandwidth" }, "SPDY_SETTINGS_RTT": { - "expires_in_version": "never", + "expires_in_version": "42", "kind": "exponential", "high": "1000", "n_buckets": 100, @@ -1510,10 +1510,10 @@ "high": "5000", "n_buckets": 100, "extended_statistics_ok": true, - "description": "SPDY: Settings Max Streams parameter" + "description": "H2: Settings Max Streams parameter" }, "SPDY_SETTINGS_CWND": { - "expires_in_version": "never", + "expires_in_version": "42", "kind": "exponential", "high": "500", "n_buckets": 50, @@ -1521,7 +1521,7 @@ "description": "SPDY: Settings CWND (packets)" }, "SPDY_SETTINGS_RETRANS": { - "expires_in_version": "never", + "expires_in_version": "42", "kind": "exponential", "high": "100", "n_buckets": 50, diff --git a/toolkit/components/terminator/nsTerminator.cpp b/toolkit/components/terminator/nsTerminator.cpp index 6302e32341..52829e5b71 100644 --- a/toolkit/components/terminator/nsTerminator.cpp +++ b/toolkit/components/terminator/nsTerminator.cpp @@ -219,8 +219,8 @@ void RunWriter(void* arg) tmpFilePath.AppendLiteral(".tmp"); // Cleanup any file leftover from a previous run - unused << PR_Delete(tmpFilePath.get()); - unused << PR_Delete(destinationPath.get()); + Unused << PR_Delete(tmpFilePath.get()); + Unused << PR_Delete(destinationPath.get()); while (true) { // diff --git a/toolkit/content/devicestorage.properties b/toolkit/content/devicestorage.properties index 083db33604..5129a585c8 100644 --- a/toolkit/content/devicestorage.properties +++ b/toolkit/content/devicestorage.properties @@ -1,4 +1,4 @@ # Extensions we recognize for DeviceStorage storage areas pictures=*.jpe; *.jpg; *.jpeg; *.gif; *.png; *.bmp; -music=*.mp3; *.oga; *.ogg; *.m4a; *.m4b; *.m4p; *.m4r; *.3gp; *.3gpp; *.mp4; *.m3u; *.pls; *.opus; *.amr; *.wav; *.lcka; *.mka; +music=*.mp3; *.oga; *.ogg; *.m4a; *.m4b; *.m4p; *.m4r; *.3gp; *.3gpp; *.mp4; *.m3u; *.pls; *.opus; *.amr; *.wav; *.lcka; *.mka; *.flac; videos=*.mp4; *.mpeg; *.mpg; *.ogv; *.ogx; *.webm; *.3gp; *.3gpp; *.3g2; *.ogg; *.m4v; *.ts; *.m2ts; *.avi; *.divx; *.mkv; diff --git a/toolkit/system/gnome/nsPackageKitService.cpp b/toolkit/system/gnome/nsPackageKitService.cpp index ed89153fa3..bfd8285740 100644 --- a/toolkit/system/gnome/nsPackageKitService.cpp +++ b/toolkit/system/gnome/nsPackageKitService.cpp @@ -158,7 +158,7 @@ InstallPackagesProxyCallCallback(GObject *aSourceObject, } g_object_unref(proxy); - unused << observer.forget().take(); + Unused << observer.forget().take(); } static void diff --git a/toolkit/xre/glxtest.cpp b/toolkit/xre/glxtest.cpp index 95e817f1a2..dcdf52c6df 100644 --- a/toolkit/xre/glxtest.cpp +++ b/toolkit/xre/glxtest.cpp @@ -83,8 +83,8 @@ static func_ptr_type cast(void *ptr) static void fatal_error(const char *str) { - mozilla::unused << write(write_end_of_the_pipe, str, strlen(str)); - mozilla::unused << write(write_end_of_the_pipe, "\n", 1); + mozilla::Unused << write(write_end_of_the_pipe, str, strlen(str)); + mozilla::Unused << write(write_end_of_the_pipe, "\n", 1); _exit(EXIT_FAILURE); } @@ -98,7 +98,7 @@ x_error_handler(Display *, XErrorEvent *ev) ev->error_code, ev->request_code, ev->minor_code); - mozilla::unused << write(write_end_of_the_pipe, buf, length); + mozilla::Unused << write(write_end_of_the_pipe, buf, length); _exit(EXIT_FAILURE); return 0; } @@ -251,7 +251,7 @@ void glxtest() dlclose(libgl); ///// Finally write data to the pipe - mozilla::unused << write(write_end_of_the_pipe, buf, length); + mozilla::Unused << write(write_end_of_the_pipe, buf, length); } } diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index ba5016135f..ccef3b9bc6 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -243,7 +243,7 @@ int (*RunGTest)() = 0; } // namespace mozilla using namespace mozilla; -using mozilla::unused; +using mozilla::Unused; using mozilla::scache::StartupCache; using mozilla::dom::ContentParent; using mozilla::dom::ContentChild; @@ -4411,7 +4411,7 @@ XRE_CreateStatsObject() // Note: purposely leaked base::StatisticsRecorder* statistics_recorder = new base::StatisticsRecorder(); MOZ_LSAN_INTENTIONALLY_LEAK_OBJECT(statistics_recorder); - unused << statistics_recorder; + Unused << statistics_recorder; } int diff --git a/tools/memory-profiler/UncensoredAllocator.cpp b/tools/memory-profiler/UncensoredAllocator.cpp index d137eec2ca..8d87c709c8 100644 --- a/tools/memory-profiler/UncensoredAllocator.cpp +++ b/tools/memory-profiler/UncensoredAllocator.cpp @@ -79,7 +79,7 @@ MallocHook::Initialize() mMallocHook.malloc_hook = SampleNative; ReplaceMallocBridge* bridge = ReplaceMallocBridge::Get(3); if (bridge) { - mozilla::unused << bridge->RegisterHook("memory-profiler", nullptr, nullptr); + mozilla::Unused << bridge->RegisterHook("memory-profiler", nullptr, nullptr); } if (!mEnabledTLS.initialized()) { bool success = mEnabledTLS.init(); diff --git a/tools/profiler/tasktracer/GeckoTaskTracer.cpp b/tools/profiler/tasktracer/GeckoTaskTracer.cpp index f366032287..60001edbeb 100644 --- a/tools/profiler/tasktracer/GeckoTaskTracer.cpp +++ b/tools/profiler/tasktracer/GeckoTaskTracer.cpp @@ -218,7 +218,7 @@ InitTaskTracer(uint32_t aFlags) sTraceInfos = new nsTArray>(); if (!sTraceInfoTLS.initialized()) { - unused << sTraceInfoTLS.init(); + Unused << sTraceInfoTLS.init(); } } diff --git a/uriloader/exthandler/ExternalHelperAppParent.cpp b/uriloader/exthandler/ExternalHelperAppParent.cpp index cd5b41d80d..69f70e052f 100644 --- a/uriloader/exthandler/ExternalHelperAppParent.cpp +++ b/uriloader/exthandler/ExternalHelperAppParent.cpp @@ -101,7 +101,7 @@ void ExternalHelperAppParent::Delete() { if (!mIPCClosed) { - unused << Send__delete__(this); + Unused << Send__delete__(this); } } @@ -154,7 +154,7 @@ ExternalHelperAppParent::RecvDivertToParentUsing(PChannelDiverterParent* diverte auto p = static_cast(diverter); p->DivertTo(this); mDiverted = true; - unused << p->Send__delete__(p); + Unused << p->Send__delete__(p); return true; } @@ -228,7 +228,7 @@ NS_IMETHODIMP ExternalHelperAppParent::Cancel(nsresult aStatus) { mStatus = aStatus; - unused << SendCancel(aStatus); + Unused << SendCancel(aStatus); return NS_OK; } diff --git a/uriloader/exthandler/nsExternalHelperAppService.cpp b/uriloader/exthandler/nsExternalHelperAppService.cpp index 641cd2d14c..3d4542299a 100644 --- a/uriloader/exthandler/nsExternalHelperAppService.cpp +++ b/uriloader/exthandler/nsExternalHelperAppService.cpp @@ -541,6 +541,7 @@ static nsExtraMimeTypeEntry extraMimeEntries [] = { AUDIO_OGG, "opus", "Opus Audio" }, #ifdef MOZ_WIDGET_GONK { AUDIO_AMR, "amr", "Adaptive Multi-Rate Audio" }, + { AUDIO_FLAC, "flac", "FLAC Audio" }, { VIDEO_AVI, "avi", "Audio Video Interleave" }, { VIDEO_AVI, "divx", "Audio Video Interleave" }, { VIDEO_MPEG_TS, "ts", "MPEG Transport Stream" }, diff --git a/uriloader/prefetch/OfflineCacheUpdateParent.cpp b/uriloader/prefetch/OfflineCacheUpdateParent.cpp index 96721306d1..ab54fc39da 100644 --- a/uriloader/prefetch/OfflineCacheUpdateParent.cpp +++ b/uriloader/prefetch/OfflineCacheUpdateParent.cpp @@ -156,7 +156,7 @@ OfflineCacheUpdateParent::UpdateStateChanged(nsIOfflineCacheUpdate *aUpdate, uin uint64_t byteProgress; aUpdate->GetByteProgress(&byteProgress); - unused << SendNotifyStateEvent(state, byteProgress); + Unused << SendNotifyStateEvent(state, byteProgress); if (state == nsIOfflineCacheUpdateObserver::STATE_FINISHED) { // Tell the child the particulars after the update has finished. @@ -167,7 +167,7 @@ OfflineCacheUpdateParent::UpdateStateChanged(nsIOfflineCacheUpdate *aUpdate, uin bool succeeded; aUpdate->GetSucceeded(&succeeded); - unused << SendFinish(succeeded, isUpgrade); + Unused << SendFinish(succeeded, isUpgrade); } return NS_OK; @@ -186,7 +186,7 @@ OfflineCacheUpdateParent::ApplicationCacheAvailable(nsIApplicationCache *aApplic nsCString cacheGroupId; aApplicationCache->GetGroupID(cacheGroupId); - unused << SendAssociateDocuments(cacheGroupId, cacheClientId); + Unused << SendAssociateDocuments(cacheGroupId, cacheClientId); return NS_OK; } diff --git a/uriloader/prefetch/nsOfflineCacheUpdateService.cpp b/uriloader/prefetch/nsOfflineCacheUpdateService.cpp index 2a4c9ae6a6..2589f7c66f 100644 --- a/uriloader/prefetch/nsOfflineCacheUpdateService.cpp +++ b/uriloader/prefetch/nsOfflineCacheUpdateService.cpp @@ -399,7 +399,7 @@ nsOfflineCacheUpdateService::ScheduleOnDocumentStop(nsIURI *aManifestURI, NS_ENSURE_SUCCESS(rv, rv); // The update will release when it has scheduled itself. - unused << update.forget(); + Unused << update.forget(); return NS_OK; } diff --git a/widget/PuppetWidget.cpp b/widget/PuppetWidget.cpp index d9fa697d66..8a44bcdf9f 100644 --- a/widget/PuppetWidget.cpp +++ b/widget/PuppetWidget.cpp @@ -336,11 +336,11 @@ PuppetWidget::DispatchInputEvent(WidgetInputEvent* aEvent) switch (aEvent->mClass) { case eMouseEventClass: - unused << + Unused << mTabChild->SendDispatchMouseEvent(*aEvent->AsMouseEvent()); break; case eKeyboardEventClass: - unused << + Unused << mTabChild->SendDispatchKeyboardEvent(*aEvent->AsKeyboardEvent()); break; default: @@ -365,7 +365,7 @@ PuppetWidget::DispatchAPZAwareEvent(WidgetInputEvent* aEvent) switch (aEvent->mClass) { case eWheelEventClass: - unused << + Unused << mTabChild->SendDispatchWheelEvent(*aEvent->AsWheelEvent()); break; default: diff --git a/widget/ScreenProxy.cpp b/widget/ScreenProxy.cpp index 6481e85d9f..3f750e1546 100644 --- a/widget/ScreenProxy.cpp +++ b/widget/ScreenProxy.cpp @@ -147,7 +147,7 @@ ScreenProxy::EnsureCacheIsValid() // Kick off a synchronous IPC call to the parent to get the // most up-to-date information. ScreenDetails details; - unused << mScreenManager->SendScreenRefresh(mId, &details, &success); + Unused << mScreenManager->SendScreenRefresh(mId, &details, &success); if (!success) { NS_WARNING("Updating a ScreenProxy in the child process failed on parent side."); return false; diff --git a/widget/cocoa/TextInputHandler.mm b/widget/cocoa/TextInputHandler.mm index 3e58bfa709..794435e81f 100644 --- a/widget/cocoa/TextInputHandler.mm +++ b/widget/cocoa/TextInputHandler.mm @@ -2315,7 +2315,7 @@ IMEInputHandler::OnCurrentTextInputSourceChange(CFNotificationCenterRef aCenter, nsTArray children; dom::ContentParent::GetAll(children); for (uint32_t i = 0; i < children.Length(); i++) { - unused << children[i]->SendBidiKeyboardNotify(tis.IsForRTLLanguage()); + Unused << children[i]->SendBidiKeyboardNotify(tis.IsForRTLLanguage()); } sCachedIsForRTLLangage = tis.IsForRTLLanguage(); } diff --git a/widget/cocoa/nsAppShell.mm b/widget/cocoa/nsAppShell.mm index 0f753530ca..bd1e083652 100644 --- a/widget/cocoa/nsAppShell.mm +++ b/widget/cocoa/nsAppShell.mm @@ -28,7 +28,6 @@ #include "nsCocoaFeatures.h" #include "nsCocoaUtils.h" #include "nsChildView.h" -#include "nsMenuBarX.h" #include "nsToolkit.h" #include "TextInputHandler.h" #include "mozilla/HangMonitor.h" @@ -658,7 +657,6 @@ nsAppShell::Run(void) mStarted = true; AddScreenWakeLockListener(); - nsMenuBarX::ResetNativeApplicationMenu(); NS_OBJC_TRY_ABORT([NSApp run]); diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index 977d96f854..08269c011a 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -1666,6 +1666,7 @@ nsChildView::NotifyIMEInternal(const IMENotification& aIMENotification) case NOTIFY_IME_OF_SELECTION_CHANGE: NS_ENSURE_TRUE(mTextInputHandler, NS_ERROR_NOT_AVAILABLE); mTextInputHandler->OnSelectionChange(aIMENotification); + return NS_OK; default: return NS_ERROR_NOT_IMPLEMENTED; } @@ -1763,6 +1764,7 @@ nsChildView::GetInputContext() break; } // If mTextInputHandler is null, set CLOSED instead... + MOZ_FALLTHROUGH; default: mInputContext.mIMEState.mOpen = IMEState::CLOSED; break; diff --git a/widget/cocoa/nsClipboard.mm b/widget/cocoa/nsClipboard.mm index 83e830c74b..abc7031e88 100644 --- a/widget/cocoa/nsClipboard.mm +++ b/widget/cocoa/nsClipboard.mm @@ -59,7 +59,7 @@ GetDataFromPasteboard(NSPasteboard* aPasteboard, NSString* aType) } @catch (NSException* e) { NS_WARNING(nsPrintfCString("Exception raised while getting data from the pasteboard: \"%s - %s\"", [[e name] UTF8String], [[e reason] UTF8String]).get()); - mozilla::unused << e; + mozilla::Unused << e; } return data; } diff --git a/widget/cocoa/nsMenuBarX.mm b/widget/cocoa/nsMenuBarX.mm index 239052cf41..0c254660d2 100644 --- a/widget/cocoa/nsMenuBarX.mm +++ b/widget/cocoa/nsMenuBarX.mm @@ -33,6 +33,7 @@ NativeMenuItemTarget* nsMenuBarX::sNativeEventTarget = nil; nsMenuBarX* nsMenuBarX::sLastGeckoMenuBarPainted = nullptr; // Weak nsMenuBarX* nsMenuBarX::sCurrentPaintDelayedMenuBar = nullptr; // Weak NSMenu* sApplicationMenu = nil; +BOOL sApplicationMenuIsFallback = NO; BOOL gSomeMenuBarPainted = NO; // We keep references to the first quit and pref item content nodes we find, which @@ -186,6 +187,7 @@ void nsMenuBarX::ConstructFallbackNativeMenus() [quitMenuItem setTarget:nsMenuBarX::sNativeEventTarget]; [quitMenuItem setTag:eCommand_ID_Quit]; [sApplicationMenu addItem:quitMenuItem]; + sApplicationMenuIsFallback = YES; } uint32_t nsMenuBarX::GetMenuCount() @@ -207,6 +209,11 @@ nsresult nsMenuBarX::InsertMenuAtIndex(nsMenuX* aMenu, uint32_t aIndex) { NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT; + // If we've only yet created a fallback global Application menu (using + // ContructFallbackNativeMenus()), destroy it before recreating it properly. + if (sApplicationMenu && sApplicationMenuIsFallback) { + ResetNativeApplicationMenu(); + } // If we haven't created a global Application menu yet, do it. if (!sApplicationMenu) { nsresult rv = NS_OK; // avoid warning about rv being unused @@ -506,6 +513,7 @@ void nsMenuBarX::ResetNativeApplicationMenu() [sApplicationMenu removeItemAtIndex:c]; [sApplicationMenu release]; sApplicationMenu = nil; + sApplicationMenuIsFallback = NO; } // Hide the item in the menu by setting the 'hidden' attribute. Returns it in |outHiddenNode| so @@ -922,29 +930,12 @@ static BOOL gMenuItemsExecuteCommands = YES; { NS_OBJC_BEGIN_TRY_ABORT_BLOCK; - // menuGroupOwner below is an nsMenuBarX object, which we sometimes access - // after it's been deleted, causing crashes (see bug 704866 and bug 670914). - // To fix this "correctly", in nsMenuBarX::~nsMenuBarX() we'd need to - // iterate through every NSMenuItem in nsMenuBarX::mNativeMenu and its - // submenus, which might be quite time consuming. (For every NSMenuItem - // that has a "representedObject" that's a MenuItemInfo object, we'd need - // need to null out its "menuGroupOwner" if it's the same as the nsMenuBarX - // object being destroyed.) But if the nsMenuBarX object being destroyed - // corresponds to the currently focused window, it's likely that the - // nsMenuBarX destructor will null out sLastGeckoMenuBarPainted. So we can - // probably eliminate most of these crashes if we use this variable being - // null as an indicator that we're likely to crash below when we dereference - // menuGroupOwner. - if (!nsMenuBarX::sLastGeckoMenuBarPainted) { + if (!gMenuItemsExecuteCommands) { return; } int tag = [sender tag]; - if (!gMenuItemsExecuteCommands) { - return; - } - nsMenuGroupOwnerX* menuGroupOwner = nullptr; nsMenuBarX* menuBar = nullptr; MenuItemInfo* info = [sender representedObject]; diff --git a/widget/cocoa/nsMenuGroupOwnerX.h b/widget/cocoa/nsMenuGroupOwnerX.h index 5972fa9ddc..04b039f404 100644 --- a/widget/cocoa/nsMenuGroupOwnerX.h +++ b/widget/cocoa/nsMenuGroupOwnerX.h @@ -34,6 +34,7 @@ public: uint32_t RegisterForCommand(nsMenuItemX* aItem); void UnregisterCommand(uint32_t aCommandID); nsMenuItemX* GetMenuItemForCommandID(uint32_t inCommandID); + void AddMenuItemInfoToSet(MenuItemInfo* info); NS_DECL_ISUPPORTS NS_DECL_NSIMUTATIONOBSERVER @@ -51,6 +52,12 @@ protected: // stores mapping of command IDs to menu objects nsDataHashtable mCommandToMenuObjectTable; + + // Stores references to all the MenuItemInfo objects created with weak + // references to us. They may live longer than we do, so when we're + // destroyed we need to clear all their weak references. This avoids + // crashes in -[NativeMenuItemTarget menuItemHit:]. See bug 1131473. + NSMutableSet* mInfoSet; }; #endif // nsMenuGroupOwner_h_ diff --git a/widget/cocoa/nsMenuGroupOwnerX.mm b/widget/cocoa/nsMenuGroupOwnerX.mm index e067d588f0..661a52bd80 100644 --- a/widget/cocoa/nsMenuGroupOwnerX.mm +++ b/widget/cocoa/nsMenuGroupOwnerX.mm @@ -32,12 +32,22 @@ NS_IMPL_ISUPPORTS(nsMenuGroupOwnerX, nsIMutationObserver) nsMenuGroupOwnerX::nsMenuGroupOwnerX() : mCurrentCommandID(eCommand_ID_Last) { + mInfoSet = [[NSMutableSet setWithCapacity:10] retain]; } nsMenuGroupOwnerX::~nsMenuGroupOwnerX() { MOZ_ASSERT(mContentToObserverTable.Count() == 0, "have outstanding mutation observers!\n"); + + // The MenuItemInfo objects in mInfoSet may live longer than we do. So when + // we get destroyed we need to invalidate all their mMenuGroupOwner pointers. + NSEnumerator* counter = [mInfoSet objectEnumerator]; + MenuItemInfo* info; + while ((info = (MenuItemInfo*) [counter nextObject])) { + [info setMenuGroupOwner:nil]; + } + [mInfoSet release]; } @@ -244,3 +254,8 @@ nsMenuItemX* nsMenuGroupOwnerX::GetMenuItemForCommandID(uint32_t inCommandID) else return nullptr; } + +void nsMenuGroupOwnerX::AddMenuItemInfoToSet(MenuItemInfo* info) +{ + [mInfoSet addObject:info]; +} diff --git a/widget/cocoa/nsMenuX.mm b/widget/cocoa/nsMenuX.mm index 5be2cdadc0..de9c01880f 100644 --- a/widget/cocoa/nsMenuX.mm +++ b/widget/cocoa/nsMenuX.mm @@ -62,7 +62,6 @@ int32_t nsMenuX::sIndexingMenuLevel = 0; - (id) initWithMenuGroupOwner:(nsMenuGroupOwnerX *)aMenuGroupOwner { if ((self = [super init]) != nil) { - mMenuGroupOwner = nullptr; [self setMenuGroupOwner:aMenuGroupOwner]; } return self; @@ -83,6 +82,9 @@ int32_t nsMenuX::sIndexingMenuLevel = 0; { // weak reference as the nsMenuGroupOwnerX owns all of its sub-objects mMenuGroupOwner = aMenuGroupOwner; + if (aMenuGroupOwner) { + aMenuGroupOwner->AddMenuItemInfoToSet(self); + } } @end diff --git a/widget/cocoa/nsNativeThemeCocoa.mm b/widget/cocoa/nsNativeThemeCocoa.mm index 906443f47c..308a6d7975 100644 --- a/widget/cocoa/nsNativeThemeCocoa.mm +++ b/widget/cocoa/nsNativeThemeCocoa.mm @@ -3576,7 +3576,7 @@ nsNativeThemeCocoa::ThemeSupportsWidget(nsPresContext* aPresContext, nsIFrame* a if (aFrame && aFrame->GetWritingMode().IsVertical()) { return false; } - // fall through + MOZ_FALLTHROUGH; case NS_THEME_LISTBOX: diff --git a/widget/gonk/ProcessOrientation.cpp b/widget/gonk/ProcessOrientation.cpp index 3a281dca39..7175ea8c4a 100644 --- a/widget/gonk/ProcessOrientation.cpp +++ b/widget/gonk/ProcessOrientation.cpp @@ -325,9 +325,9 @@ ProcessOrientation::OnSensorChanged(const SensorData& event, // Avoid unused-but-set compile warnings for these variables, when LOGD is // a no-op, as it is by default: - unused << isAccelerating; - unused << isFlat; - unused << isSwinging; + Unused << isAccelerating; + Unused << isFlat; + Unused << isSwinging; // Tell the listener. if (mProposedRotation != oldProposedRotation && mProposedRotation >= 0) { diff --git a/widget/gtk/nsAppShell.cpp b/widget/gtk/nsAppShell.cpp index 4ab8e231ea..5c7a7168a4 100644 --- a/widget/gtk/nsAppShell.cpp +++ b/widget/gtk/nsAppShell.cpp @@ -22,7 +22,7 @@ #include "WakeLockListener.h" #endif -using mozilla::unused; +using mozilla::Unused; #define NOTIFY_TOKEN 0xFA @@ -53,7 +53,7 @@ nsAppShell::EventProcessorCallback(GIOChannel *source, nsAppShell *self = static_cast(data); unsigned char c; - unused << read(self->mPipeFDs[0], &c, 1); + Unused << read(self->mPipeFDs[0], &c, 1); NS_ASSERTION(c == (unsigned char) NOTIFY_TOKEN, "wrong token"); self->NativeEventCallback(); @@ -167,7 +167,7 @@ void nsAppShell::ScheduleNativeEventCallback() { unsigned char buf[] = { NOTIFY_TOKEN }; - unused << write(mPipeFDs[1], buf, 1); + Unused << write(mPipeFDs[1], buf, 1); } bool diff --git a/widget/gtk/nsSound.cpp b/widget/gtk/nsSound.cpp index f745cc1863..5bfe0eda05 100644 --- a/widget/gtk/nsSound.cpp +++ b/widget/gtk/nsSound.cpp @@ -81,7 +81,7 @@ struct ScopedCanberraFile { } void forget() { - mozilla::unused << mFile.forget(); + mozilla::Unused << mFile.forget(); } nsIFile* operator->() { return mFile; } operator nsIFile*() { return mFile; } diff --git a/widget/nsBaseDragService.cpp b/widget/nsBaseDragService.cpp index 7c179b7239..9f88e01ec2 100644 --- a/widget/nsBaseDragService.cpp +++ b/widget/nsBaseDragService.cpp @@ -369,7 +369,7 @@ nsBaseDragService::EndDragSession(bool aDoneDrag) } for (uint32_t i = 0; i < mChildProcesses.Length(); ++i) { - mozilla::unused << mChildProcesses[i]->SendEndDragSession(aDoneDrag, + mozilla::Unused << mChildProcesses[i]->SendEndDragSession(aDoneDrag, mUserCancelled); } mChildProcesses.Clear(); diff --git a/widget/nsDragServiceProxy.cpp b/widget/nsDragServiceProxy.cpp index 86bc1c8354..7f0bb0e0a0 100644 --- a/widget/nsDragServiceProxy.cpp +++ b/widget/nsDragServiceProxy.cpp @@ -66,7 +66,7 @@ nsDragServiceProxy::InvokeDragSession(nsIDOMNode* aDOMNode, nsContentUtils::GetSurfaceData(dataSurface, &length, &stride); nsDependentCString dragImage(surfaceData.get(), length); - mozilla::unused << + mozilla::Unused << child->SendInvokeDragSession(dataTransfers, aActionType, dragImage, size.width, size.height, stride, static_cast(dataSurface->GetFormat()), @@ -76,7 +76,7 @@ nsDragServiceProxy::InvokeDragSession(nsIDOMNode* aDOMNode, } } - mozilla::unused << child->SendInvokeDragSession(dataTransfers, aActionType, + mozilla::Unused << child->SendInvokeDragSession(dataTransfers, aActionType, nsCString(), 0, 0, 0, 0, 0, 0); StartDragSession(); diff --git a/widget/nsScreenManagerProxy.cpp b/widget/nsScreenManagerProxy.cpp index f6bc2478c0..6f0893f10e 100644 --- a/widget/nsScreenManagerProxy.cpp +++ b/widget/nsScreenManagerProxy.cpp @@ -28,7 +28,7 @@ nsScreenManagerProxy::nsScreenManagerProxy() , mCacheWillInvalidate(false) { bool success = false; - unused << ContentChild::GetSingleton()->SendPScreenManagerConstructor( + Unused << ContentChild::GetSingleton()->SendPScreenManagerConstructor( this, &mNumberOfScreens, &mSystemDefaultScale, @@ -64,7 +64,7 @@ nsScreenManagerProxy::GetPrimaryScreen(nsIScreen** outScreen) if (!mPrimaryScreen) { ScreenDetails details; bool success = false; - unused << SendGetPrimaryScreen(&details, &success); + Unused << SendGetPrimaryScreen(&details, &success); if (!success) { return NS_ERROR_FAILURE; } @@ -92,7 +92,7 @@ nsScreenManagerProxy::ScreenForRect(int32_t inLeft, { bool success = false; ScreenDetails details; - unused << SendScreenForRect(inLeft, inTop, inWidth, inHeight, &details, &success); + Unused << SendScreenForRect(inLeft, inTop, inWidth, inHeight, &details, &success); if (!success) { return NS_ERROR_FAILURE; } @@ -126,7 +126,7 @@ nsScreenManagerProxy::ScreenForNativeWidget(void* aWidget, // for it. bool success = false; ScreenDetails details; - unused << SendScreenForBrowser(tabChild->GetTabId(), &details, &success); + Unused << SendScreenForBrowser(tabChild->GetTabId(), &details, &success); if (!success) { return NS_ERROR_FAILURE; } @@ -177,7 +177,7 @@ nsScreenManagerProxy::EnsureCacheIsValid() bool success = false; // Kick off a synchronous IPC call to the parent to get the // most up-to-date information. - unused << SendRefresh(&mNumberOfScreens, &mSystemDefaultScale, &success); + Unused << SendRefresh(&mNumberOfScreens, &mSystemDefaultScale, &success); if (!success) { NS_WARNING("Refreshing nsScreenManagerProxy failed in the parent process."); return false; diff --git a/widget/windows/nsWindowGfx.cpp b/widget/windows/nsWindowGfx.cpp index 447feb6102..dca34886bc 100644 --- a/widget/windows/nsWindowGfx.cpp +++ b/widget/windows/nsWindowGfx.cpp @@ -205,7 +205,7 @@ bool nsWindow::OnPaint(HDC aDC, uint32_t aNestingLevel) PluginInstanceParent* instance = reinterpret_cast( ::GetPropW(mWnd, L"PluginInstanceParentProperty")); if (instance) { - unused << instance->CallUpdateWindow(); + Unused << instance->CallUpdateWindow(); } else { // We should never get here since in-process plugins should have // subclassed our HWND and handled WM_PAINT, but in some cases that diff --git a/xpcom/base/SystemMemoryReporter.cpp b/xpcom/base/SystemMemoryReporter.cpp index 3438686dbd..f866126fa8 100644 --- a/xpcom/base/SystemMemoryReporter.cpp +++ b/xpcom/base/SystemMemoryReporter.cpp @@ -728,10 +728,10 @@ private: uint64_t size; // Ignore the header line. - unused << fgets(buffer, kBufferLen, iommu); + Unused << fgets(buffer, kBufferLen, iommu); // Ignore the separator line. - unused << fgets(buffer, kBufferLen, iommu); + Unused << fgets(buffer, kBufferLen, iommu); const char* const kSep = "----"; const size_t kSepLen = 4; @@ -748,7 +748,7 @@ private: } // Ignore the orphaned header. - unused << fgets(buffer, kBufferLen, iommu); + Unused << fgets(buffer, kBufferLen, iommu); // Read orphaned entries. while (fgets(buffer, kBufferLen, iommu) && @@ -775,7 +775,7 @@ private: } uint64_t size = 0; - unused << fscanf(sizeFile, "%" SCNu64, &size); + Unused << fscanf(sizeFile, "%" SCNu64, &size); fclose(sizeFile); return size; @@ -1017,7 +1017,7 @@ private: // Bypass the header line. char buff[1024]; - unused << fgets(buff, 1024, memFile); + Unused << fgets(buff, 1024, memFile); while (fscanf(memFile, kScanFormat, &gpuaddr, &useraddr, &size, &id, flags, type, usage, &sglen) == kNumFields) { diff --git a/xpcom/base/nsDumpUtils.cpp b/xpcom/base/nsDumpUtils.cpp index 35b0a3862b..160a1df61a 100644 --- a/xpcom/base/nsDumpUtils.cpp +++ b/xpcom/base/nsDumpUtils.cpp @@ -60,7 +60,7 @@ DumpSignalHandler(int aSignum) if (sDumpPipeWriteFd != -1) { uint8_t signum = static_cast(aSignum); - unused << write(sDumpPipeWriteFd, &signum, sizeof(signum)); + Unused << write(sDumpPipeWriteFd, &signum, sizeof(signum)); } } diff --git a/xpcom/base/nsMemoryInfoDumper.cpp b/xpcom/base/nsMemoryInfoDumper.cpp index b82de853de..9d84f47a6c 100644 --- a/xpcom/base/nsMemoryInfoDumper.cpp +++ b/xpcom/base/nsMemoryInfoDumper.cpp @@ -342,7 +342,7 @@ public: private: ~nsDumpGCAndCCLogsCallbackHolder() { - unused << mCallback->OnFinish(); + Unused << mCallback->OnFinish(); } nsCOMPtr mCallback; @@ -372,7 +372,7 @@ nsMemoryInfoDumper::DumpGCAndCCLogsToFile(const nsAString& aIdentifier, logSink->SetFilenameIdentifier(identifier); logSink->SetProcessIdentifier(cp->Pid()); - unused << cp->CycleCollectWithLogs(aDumpAllTraces, logSink, + Unused << cp->CycleCollectWithLogs(aDumpAllTraces, logSink, callbackHolder); } } diff --git a/xpcom/ds/nsAtomTable.cpp b/xpcom/ds/nsAtomTable.cpp index b0d0f04687..366da496b2 100644 --- a/xpcom/ds/nsAtomTable.cpp +++ b/xpcom/ds/nsAtomTable.cpp @@ -367,7 +367,7 @@ AtomImpl::AtomImpl(const nsAString& aString, uint32_t aHash) NS_ASSERTION(Equals(aString), "correct data"); // Take ownership of buffer - mozilla::unused << buf.forget(); + mozilla::Unused << buf.forget(); } AtomImpl::AtomImpl(nsStringBuffer* aStringBuffer, uint32_t aLength, diff --git a/xpcom/tests/TestTArray.cpp b/xpcom/tests/TestTArray.cpp index e8f0d18208..15ac976004 100644 --- a/xpcom/tests/TestTArray.cpp +++ b/xpcom/tests/TestTArray.cpp @@ -1113,7 +1113,7 @@ static bool test_SetLengthAndRetainStorage_no_ctor() { } while (0) // Setup test arrays. - FOR_EACH(; unused << , .SetLength(N, fallible)); + FOR_EACH(; Unused << , .SetLength(N, fallible)); for (int n = 0; n < N; ++n) { FOR_EACH(;, [n] = n); } diff --git a/xpcom/tests/gtest/TestCloneInputStream.cpp b/xpcom/tests/gtest/TestCloneInputStream.cpp index 9aaa93c4ae..3c213b42f2 100644 --- a/xpcom/tests/gtest/TestCloneInputStream.cpp +++ b/xpcom/tests/gtest/TestCloneInputStream.cpp @@ -106,7 +106,7 @@ TEST(CloneInputStream, NonCloneableInput_Fallback) // but AFAICT, gtest does not support async test completion. uint64_t available; do { - mozilla::unused << PR_Sleep(PR_INTERVAL_NO_WAIT); + mozilla::Unused << PR_Sleep(PR_INTERVAL_NO_WAIT); rv = stream->Available(&available); ASSERT_TRUE(NS_SUCCEEDED(rv)); } while(available < inputString.Length()); diff --git a/xpcom/threads/AbstractThread.cpp b/xpcom/threads/AbstractThread.cpp index 24af1c875b..50eb76ea46 100644 --- a/xpcom/threads/AbstractThread.cpp +++ b/xpcom/threads/AbstractThread.cpp @@ -60,7 +60,7 @@ public: nsresult rv = mTarget->Dispatch(r, NS_DISPATCH_NORMAL); MOZ_DIAGNOSTIC_ASSERT(aFailureHandling == DontAssertDispatchSuccess || NS_SUCCEEDED(rv)); - unused << rv; + Unused << rv; } virtual bool IsCurrentThreadIn() override diff --git a/xpcom/threads/TaskQueue.h b/xpcom/threads/TaskQueue.h index 7f5226aa0c..6b3ebd009e 100644 --- a/xpcom/threads/TaskQueue.h +++ b/xpcom/threads/TaskQueue.h @@ -46,7 +46,7 @@ public: MonitorAutoLock mon(mQueueMonitor); nsresult rv = DispatchLocked(Move(aRunnable), AbortIfFlushing, aFailureHandling, aReason); MOZ_DIAGNOSTIC_ASSERT(aFailureHandling == DontAssertDispatchSuccess || NS_SUCCEEDED(rv)); - unused << rv; + Unused << rv; } // Puts the queue in a shutdown state and returns immediately. The queue will