From b9ba9be64d46bc419425bbae33d1d8ddf8bc02bd Mon Sep 17 00:00:00 2001 From: Eric Rahm Date: Fri, 21 Feb 2020 22:43:53 +0000 Subject: [PATCH] Bug 1322095 - Part 1b: Update callbacks to support moved args and convert nsAutoPtr usage. r=jya In order to support the update to move args when invoking callbacks we: - Convert anything that was using WrapRunnable with `nsAutoPtr` to `UniquePtr` - Convert anything that was using a non-const ref as a param to either a const ref or a by-val copy Addtionally we convert the remaining `nsAutoPtr` usage to `UniquePtr`. Differential Revision: https://phabricator.services.mozilla.com/D59961 --HG-- extra : moz-landing-system : lando --- dom/media/gmp/GMPServiceParent.cpp | 2 +- dom/network/UDPSocketParent.cpp | 11 ++++---- dom/network/UDPSocketParent.h | 9 ++++--- media/mtransport/nr_socket_prsock.cpp | 19 ++++++------- media/mtransport/nr_socket_prsock.h | 11 ++++---- media/mtransport/nr_timer.cpp | 4 +-- media/mtransport/nricectx.h | 1 - media/mtransport/test/sctp_unittest.cpp | 8 +++--- .../test/test_nr_socket_unittest.cpp | 1 - media/mtransport/test/transport_unittests.cpp | 8 +++--- media/mtransport/transportflow.cpp | 7 +++-- media/mtransport/transportflow.h | 3 +-- media/mtransport/transportlayerloopback.h | 1 - media/mtransport/transportlayersrtp.cpp | 1 - .../src/media-conduit/VideoConduit.cpp | 7 ++--- .../src/media-conduit/VideoConduit.h | 4 +-- .../src/media-conduit/WebrtcGmpVideoCodec.cpp | 27 +++++++++---------- .../src/media-conduit/WebrtcGmpVideoCodec.h | 8 +++--- .../WebrtcMediaCodecVP8VideoCodec.cpp | 2 +- .../WebrtcMediaCodecVP8VideoCodec.h | 1 - .../src/mediapipeline/MediaPipeline.cpp | 8 +++--- .../src/mediapipeline/MediaPipeline.h | 9 ++++--- .../peerconnection/MediaTransportHandler.cpp | 14 +++++----- .../peerconnection/MediaTransportHandler.h | 10 ++++--- .../peerconnection/MediaTransportParent.cpp | 5 ++-- .../src/peerconnection/PeerConnectionImpl.h | 1 - .../WebrtcGlobalInformation.cpp | 1 - netwerk/sctp/datachannel/DataChannel.cpp | 2 +- netwerk/sctp/datachannel/DataChannel.h | 3 ++- 29 files changed, 93 insertions(+), 95 deletions(-) diff --git a/dom/media/gmp/GMPServiceParent.cpp b/dom/media/gmp/GMPServiceParent.cpp index 357786ac9b1a..4fbe0ca73a94 100644 --- a/dom/media/gmp/GMPServiceParent.cpp +++ b/dom/media/gmp/GMPServiceParent.cpp @@ -917,7 +917,7 @@ void GeckoMediaPluginServiceParent::RemoveOnGMPThread( } // May remove when Bug 1043671 is fixed -static void Dummy(RefPtr& aOnDeathsDoor) { +static void Dummy(RefPtr aOnDeathsDoor) { // exists solely to do nothing and let the Runnable kill the GMPParent // when done. } diff --git a/dom/network/UDPSocketParent.cpp b/dom/network/UDPSocketParent.cpp index 0718d05a00d6..e68e628b27a4 100644 --- a/dom/network/UDPSocketParent.cpp +++ b/dom/network/UDPSocketParent.cpp @@ -249,8 +249,9 @@ void UDPSocketParent::DoSendConnectResponse( mozilla::Unused << SendCallbackConnected(aAddressInfo); } -void UDPSocketParent::SendConnectResponse(nsIEventTarget* aThread, - const UDPAddressInfo& aAddressInfo) { +void UDPSocketParent::SendConnectResponse( + const nsCOMPtr& aThread, + const UDPAddressInfo& aAddressInfo) { Unused << NS_WARN_IF(NS_FAILED(aThread->Dispatch( WrapRunnable(RefPtr(this), &UDPSocketParent::DoSendConnectResponse, aAddressInfo), @@ -258,8 +259,8 @@ void UDPSocketParent::SendConnectResponse(nsIEventTarget* aThread, } // Runs on STS thread -void UDPSocketParent::DoConnect(nsCOMPtr& aSocket, - nsCOMPtr& aReturnThread, +void UDPSocketParent::DoConnect(const nsCOMPtr& aSocket, + const nsCOMPtr& aReturnThread, const UDPAddressInfo& aAddressInfo) { UDPSOCKET_LOG(("%s: %s:%u", __FUNCTION__, aAddressInfo.addr().get(), aAddressInfo.port())); @@ -553,7 +554,7 @@ void UDPSocketParent::FireInternalError(uint32_t aLineNo) { NS_LITERAL_CSTRING(__FILE__), aLineNo); } -void UDPSocketParent::SendInternalError(nsIEventTarget* aThread, +void UDPSocketParent::SendInternalError(const nsCOMPtr& aThread, uint32_t aLineNo) { UDPSOCKET_LOG(("SendInternalError: %u", aLineNo)); Unused << NS_WARN_IF(NS_FAILED(aThread->Dispatch( diff --git a/dom/network/UDPSocketParent.h b/dom/network/UDPSocketParent.h index 7d0fd5922da6..394a77c44d05 100644 --- a/dom/network/UDPSocketParent.h +++ b/dom/network/UDPSocketParent.h @@ -38,10 +38,10 @@ class UDPSocketParent : public mozilla::net::PUDPSocketParent, const uint32_t& sendBufferSize); mozilla::ipc::IPCResult RecvConnect(const UDPAddressInfo& aAddressInfo); void DoSendConnectResponse(const UDPAddressInfo& aAddressInfo); - void SendConnectResponse(nsIEventTarget* aThread, + void SendConnectResponse(const nsCOMPtr& aThread, const UDPAddressInfo& aAddressInfo); - void DoConnect(nsCOMPtr& aSocket, - nsCOMPtr& aReturnThread, + void DoConnect(const nsCOMPtr& aSocket, + const nsCOMPtr& aReturnThread, const UDPAddressInfo& aAddressInfo); mozilla::ipc::IPCResult RecvOutgoingData(const UDPData& aData, @@ -66,7 +66,8 @@ class UDPSocketParent : public mozilla::net::PUDPSocketParent, const uint32_t& sendBufferSize); nsresult ConnectInternal(const nsCString& aHost, const uint16_t& aPort); void FireInternalError(uint32_t aLineNo); - void SendInternalError(nsIEventTarget* aThread, uint32_t aLineNo); + void SendInternalError(const nsCOMPtr& aThread, + uint32_t aLineNo); PBackgroundParent* mBackgroundManager; diff --git a/media/mtransport/nr_socket_prsock.cpp b/media/mtransport/nr_socket_prsock.cpp index 0855a5c9fb50..feb17155e315 100644 --- a/media/mtransport/nr_socket_prsock.cpp +++ b/media/mtransport/nr_socket_prsock.cpp @@ -1142,9 +1142,9 @@ NS_IMETHODIMP NrUdpSocketIpc::CallListenerReceivedData( } } - nsAutoPtr buf(new MediaPacket); + auto buf = MakeUnique(); buf->Copy(data.Elements(), data.Length()); - RefPtr msg(new nr_udp_message(addr, buf)); + RefPtr msg(new nr_udp_message(addr, std::move(buf))); RUN_ON_THREAD(sts_thread_, mozilla::WrapRunnable(RefPtr(this), @@ -1323,13 +1323,14 @@ int NrUdpSocketIpc::sendto(const void* msg, size_t len, int flags, return R_WOULDBLOCK; } - nsAutoPtr buf(new MediaPacket); + UniquePtr buf(new MediaPacket); buf->Copy(static_cast(msg), len); - RUN_ON_THREAD(io_thread_, - mozilla::WrapRunnable(RefPtr(this), - &NrUdpSocketIpc::sendto_i, addr, buf), - NS_DISPATCH_NORMAL); + RUN_ON_THREAD( + io_thread_, + mozilla::WrapRunnable(RefPtr(this), + &NrUdpSocketIpc::sendto_i, addr, std::move(buf)), + NS_DISPATCH_NORMAL); return 0; } @@ -1532,7 +1533,7 @@ void NrUdpSocketIpc::connect_i(const nsACString& host, const uint16_t port) { } void NrUdpSocketIpc::sendto_i(const net::NetAddr& addr, - nsAutoPtr buf) { + UniquePtr buf) { ASSERT_ON_THREAD(io_thread_); ReentrantMonitorAutoEnter mon(monitor_); @@ -1564,7 +1565,7 @@ static void ReleaseIOThread_s() { sThread->ReleaseUse(); } // close(), but transfer the socket_child_ reference to die as well // static void NrUdpSocketIpc::destroy_i(dom::UDPSocketChild* aChild, - nsCOMPtr& aStsThread) { + const nsCOMPtr& aStsThread) { RefPtr socket_child_ref = already_AddRefed(aChild); if (socket_child_ref) { diff --git a/media/mtransport/nr_socket_prsock.h b/media/mtransport/nr_socket_prsock.h index 51ea944f7e33..1ce2ffaefbb3 100644 --- a/media/mtransport/nr_socket_prsock.h +++ b/media/mtransport/nr_socket_prsock.h @@ -51,7 +51,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "nspr.h" #include "prio.h" -#include "nsAutoPtr.h" #include "nsCOMPtr.h" #include "nsASocketHandler.h" #include "nsXPCOM.h" @@ -196,13 +195,13 @@ class NrSocket : public NrSocketBase, public nsASocketHandler { }; struct nr_udp_message { - nr_udp_message(const PRNetAddr& from, nsAutoPtr& data) - : from(from), data(data) {} + nr_udp_message(const PRNetAddr& from, UniquePtr&& data) + : from(from), data(std::move(data)) {} NS_INLINE_DECL_THREADSAFE_REFCOUNTING(nr_udp_message); PRNetAddr from; - nsAutoPtr data; + UniquePtr data; private: ~nr_udp_message() {} @@ -272,11 +271,11 @@ class NrUdpSocketIpc : public NrSocketIpc { // Main or private thread executors of the NrSocketBase APIs void create_i(const nsACString& host, const uint16_t port); void connect_i(const nsACString& host, const uint16_t port); - void sendto_i(const net::NetAddr& addr, nsAutoPtr buf); + void sendto_i(const net::NetAddr& addr, UniquePtr buf); void close_i(); #if defined(MOZILLA_INTERNAL_API) && !defined(MOZILLA_XPCOMRT_API) static void destroy_i(dom::UDPSocketChild* aChild, - nsCOMPtr& aStsThread); + const nsCOMPtr& aStsThread); #endif // STS thread executor void recv_callback_s(RefPtr msg); diff --git a/media/mtransport/nr_timer.cpp b/media/mtransport/nr_timer.cpp index b2458f17ec4d..3a69bf7ea689 100644 --- a/media/mtransport/nr_timer.cpp +++ b/media/mtransport/nr_timer.cpp @@ -51,7 +51,6 @@ #include -#include "nsAutoPtr.h" #include "nsCOMPtr.h" #include "nsComponentManagerUtils.h" #include "nsServiceManagerUtils.h" @@ -61,6 +60,7 @@ #include "nsNetCID.h" #include "runnable_utils.h" #include "mozilla/DebugOnly.h" +#include "mozilla/UniquePtr.h" extern "C" { #include "nr_api.h" @@ -177,7 +177,7 @@ static int nr_async_timer_set_zero(NR_async_cb cb, void* arg, char* func, int l, new nrappkitScheduledCallback(cb, arg, func, l)); nsresult rv = GetSTSThread()->Dispatch( - WrapRunnable(nsAutoPtr(callback), + WrapRunnable(UniquePtr(callback), &nrappkitScheduledCallback::Run), NS_DISPATCH_NORMAL); if (NS_FAILED(rv)) return R_FAILED; diff --git a/media/mtransport/nricectx.h b/media/mtransport/nricectx.h index 74c486bdf5d2..4616a6ab6928 100644 --- a/media/mtransport/nricectx.h +++ b/media/mtransport/nricectx.h @@ -61,7 +61,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "mozilla/RefPtr.h" #include "mozilla/UniquePtr.h" -#include "nsAutoPtr.h" #include "nsIEventTarget.h" #include "nsTArray.h" diff --git a/media/mtransport/test/sctp_unittest.cpp b/media/mtransport/test/sctp_unittest.cpp index ed598b6f9d55..6c4bd3e40aae 100644 --- a/media/mtransport/test/sctp_unittest.cpp +++ b/media/mtransport/test/sctp_unittest.cpp @@ -198,14 +198,14 @@ class TransportTestPeer : public sigslot::has_slots<> { int received() const { return received_; } bool connected() const { return connected_; } - static TransportResult SendPacket_s(nsAutoPtr packet, + static TransportResult SendPacket_s(UniquePtr packet, const RefPtr& flow, TransportLayer* layer) { return layer->SendPacket(*packet); } TransportResult SendPacket(const unsigned char* data, size_t len) { - nsAutoPtr packet(new MediaPacket); + UniquePtr packet(new MediaPacket); packet->Copy(data, len); // Uses DISPATCH_NORMAL to avoid possible deadlocks when we're called @@ -215,8 +215,8 @@ class TransportTestPeer : public sigslot::has_slots<> { // a refptr to flow_ to avoid any async deletion issues (since we can't // make 'this' into a refptr as it isn't refcounted) RUN_ON_THREAD(test_utils_->sts_target(), - WrapRunnableNM(&TransportTestPeer::SendPacket_s, packet, - flow_, loopback_), + WrapRunnableNM(&TransportTestPeer::SendPacket_s, + std::move(packet), flow_, loopback_), NS_DISPATCH_NORMAL); return 0; diff --git a/media/mtransport/test/test_nr_socket_unittest.cpp b/media/mtransport/test/test_nr_socket_unittest.cpp index 9a1d2720d0a1..848ef669c694 100644 --- a/media/mtransport/test/test_nr_socket_unittest.cpp +++ b/media/mtransport/test/test_nr_socket_unittest.cpp @@ -23,7 +23,6 @@ extern "C" { #include "nsCOMPtr.h" #include "nsNetCID.h" #include "nsServiceManagerUtils.h" -#include "nsAutoPtr.h" #include "runnable_utils.h" #include diff --git a/media/mtransport/test/transport_unittests.cpp b/media/mtransport/test/transport_unittests.cpp index 13ac04a41879..92f2360037b3 100644 --- a/media/mtransport/test/transport_unittests.cpp +++ b/media/mtransport/test/transport_unittests.cpp @@ -228,7 +228,7 @@ class DtlsRecordParser { buffer_.Copy(data, len); } - bool NextRecord(uint8_t* ct, nsAutoPtr* buffer) { + bool NextRecord(uint8_t* ct, UniquePtr* buffer) { if (!remaining()) return false; CHECK_LENGTH(13U); @@ -240,12 +240,12 @@ class DtlsRecordParser { consume(2); CHECK_LENGTH(length); - MediaPacket* db = new MediaPacket; + auto db = MakeUnique(); db->Copy(ptr(), length); consume(length); *ct = *ctp; - *buffer = db; + *buffer = std::move(db); return true; } @@ -268,7 +268,7 @@ class DtlsRecordInspector : public Inspector { DtlsRecordParser parser(data, len); uint8_t ct; - nsAutoPtr buf; + UniquePtr buf; while (parser.NextRecord(&ct, &buf)) { OnRecord(layer, ct, buf->data(), buf->len()); } diff --git a/media/mtransport/transportflow.cpp b/media/mtransport/transportflow.cpp index 6e48d57a9022..ce6cea7d7e1a 100644 --- a/media/mtransport/transportflow.cpp +++ b/media/mtransport/transportflow.cpp @@ -25,19 +25,18 @@ TransportFlow::~TransportFlow() { // is still some possibility that someone is accessing this // object simultaneously, but as long as smart pointer discipline // is maintained, it shouldn't be possible to access and - // destroy it simultaneously. The conversion to an nsAutoPtr + // destroy it simultaneously. The conversion to a UniquePtr // ensures automatic destruction of the queue at exit of // DestroyFinal. MOZ_RELEASE_ASSERT(target_); - nsAutoPtr> layers_tmp(layers_.release()); DebugOnly rv = target_->Dispatch( - WrapRunnableNM(&TransportFlow::DestroyFinal, layers_tmp), + WrapRunnableNM(&TransportFlow::DestroyFinal, std::move(layers_)), NS_DISPATCH_NORMAL); MOZ_ASSERT(NS_SUCCEEDED(rv)); } void TransportFlow::DestroyFinal( - nsAutoPtr> layers) { + UniquePtr> layers) { ClearLayers(layers.get()); } diff --git a/media/mtransport/transportflow.h b/media/mtransport/transportflow.h index e6b26222a0b7..43253a260b4e 100644 --- a/media/mtransport/transportflow.h +++ b/media/mtransport/transportflow.h @@ -17,7 +17,6 @@ #include "mozilla/UniquePtr.h" #include "transportlayer.h" #include "m_cpp_utils.h" -#include "nsAutoPtr.h" // A stack of transport layers acts as a flow. // Generally, one reads and writes to the top layer. @@ -92,7 +91,7 @@ class TransportFlow final : public nsISupports { void EnsureSameThread(TransportLayer* layer); - static void DestroyFinal(nsAutoPtr> layers); + static void DestroyFinal(UniquePtr> layers); // Overload needed because we use deque internally and queue externally. static void ClearLayers(std::deque* layers); diff --git a/media/mtransport/transportlayerloopback.h b/media/mtransport/transportlayerloopback.h index 7c31851eb2ee..88cb14299fdc 100644 --- a/media/mtransport/transportlayerloopback.h +++ b/media/mtransport/transportlayerloopback.h @@ -16,7 +16,6 @@ #include #include -#include "nsAutoPtr.h" #include "nsCOMPtr.h" #include "nsINamed.h" #include "nsITimer.h" diff --git a/media/mtransport/transportlayersrtp.cpp b/media/mtransport/transportlayersrtp.cpp index 96b744806c7e..983c2aab6a34 100644 --- a/media/mtransport/transportlayersrtp.cpp +++ b/media/mtransport/transportlayersrtp.cpp @@ -14,7 +14,6 @@ #include "mozilla/Assertions.h" #include "transportlayerdtls.h" #include "srtp.h" -#include "nsAutoPtr.h" namespace mozilla { diff --git a/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp b/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp index a0f1d9b3cc19..44b42fe5e09b 100644 --- a/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp +++ b/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp @@ -13,6 +13,7 @@ #include "mozilla/TemplateLib.h" #include "mozilla/media/MediaUtils.h" #include "mozilla/StaticPrefs_media.h" +#include "mozilla/UniquePtr.h" #include "nsComponentManagerUtils.h" #include "nsIPrefBranch.h" #include "nsIGfxInfo.h" @@ -451,7 +452,7 @@ RefPtr VideoSessionConduit::Create( return nullptr; } - nsAutoPtr obj(new WebrtcVideoConduit(aCall, aStsThread)); + auto obj = MakeRefPtr(aCall, aStsThread); if (obj->Init() != kMediaConduitNoError) { CSFLogError(LOGTAG, "%s VideoConduit Init Failed ", __FUNCTION__); return nullptr; @@ -941,7 +942,7 @@ MediaConduitErrorCode WebrtcVideoConduit::ConfigureSendMediaCodec( codecConfig->RtcpFbNackIsSet("") ? 1000 : 0; // Copy the applied config for future reference. - mCurSendCodecConfig = new VideoCodecConfig(*codecConfig); + mCurSendCodecConfig = MakeUnique(*codecConfig); mSendStreamConfig.rtp.rids.clear(); bool has_rid = false; @@ -1797,7 +1798,7 @@ void WebrtcVideoConduit::SelectSendResolution(unsigned short width, } unsigned int framerate = SelectSendFrameRate( - mCurSendCodecConfig, mSendingFramerate, width, height); + mCurSendCodecConfig.get(), mSendingFramerate, width, height); if (mSendingFramerate != framerate) { CSFLogDebug(LOGTAG, "%s: framerate changing to %u (from %u)", __FUNCTION__, framerate, mSendingFramerate); diff --git a/media/webrtc/signaling/src/media-conduit/VideoConduit.h b/media/webrtc/signaling/src/media-conduit/VideoConduit.h index be88701b630a..f372ecad5da1 100644 --- a/media/webrtc/signaling/src/media-conduit/VideoConduit.h +++ b/media/webrtc/signaling/src/media-conduit/VideoConduit.h @@ -9,7 +9,7 @@ #include "mozilla/Attributes.h" #include "mozilla/ReentrantMonitor.h" #include "mozilla/SharedThreadPool.h" -#include "nsAutoPtr.h" +#include "mozilla/UniquePtr.h" #include "nsITimer.h" #include "MediaConduitInterface.h" @@ -523,7 +523,7 @@ class WebrtcVideoConduit nsTArray> mRecvCodecList; // Written only on main thread. Guarded by mMutex, except for reads on main. - nsAutoPtr mCurSendCodecConfig; + UniquePtr mCurSendCodecConfig; bool mUpdateResolution = false; int mSinkWantsPixelCount = std::numeric_limits::max(); diff --git a/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.cpp b/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.cpp index 867c5eba8d61..68e2c92d2ede 100644 --- a/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.cpp +++ b/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.cpp @@ -322,7 +322,8 @@ void WebrtcGmpVideoEncoder::RegetEncoderForResolutionChange( } void WebrtcGmpVideoEncoder::Encode_g( - RefPtr& aEncoder, webrtc::VideoFrame aInputImage, + const RefPtr& aEncoder, + webrtc::VideoFrame aInputImage, std::vector aFrameTypes) { if (!aEncoder->mGMP) { // destroyed via Terminate(), failed to init, or just not initted yet @@ -420,7 +421,7 @@ int32_t WebrtcGmpVideoEncoder::RegisterEncodeCompleteCallback( /* static */ void WebrtcGmpVideoEncoder::ReleaseGmp_g( - RefPtr& aEncoder) { + const RefPtr& aEncoder) { aEncoder->Close_g(); } @@ -743,8 +744,7 @@ int32_t WebrtcGmpVideoDecoder::GmpInitDone(GMPVideoDecoderProxy* aGMP, nsTArray> temp; temp.SwapElements(mQueuedFrames); for (auto& queued : temp) { - Decode_g(RefPtr(this), - nsAutoPtr(queued.release())); + Decode_g(RefPtr(this), std::move(queued)); } } @@ -792,13 +792,13 @@ int32_t WebrtcGmpVideoDecoder::Decode( // know to request a PLI and the video stream will remain frozen unless an IDR // happens to arrive for other reasons. Bug 1492852 tracks implementing a // proper solution. - nsAutoPtr decodeData( - new GMPDecodeData(aInputImage, aMissingFrames, aRenderTimeMs)); + auto decodeData = + MakeUnique(aInputImage, aMissingFrames, aRenderTimeMs); - mGMPThread->Dispatch( - WrapRunnableNM(&WebrtcGmpVideoDecoder::Decode_g, - RefPtr(this), decodeData), - NS_DISPATCH_NORMAL); + mGMPThread->Dispatch(WrapRunnableNM(&WebrtcGmpVideoDecoder::Decode_g, + RefPtr(this), + std::move(decodeData)), + NS_DISPATCH_NORMAL); if (mDecoderStatus != GMPNoErr) { GMP_LOG_ERROR("%s: Decoder status is bad (%u)!", __PRETTY_FUNCTION__, @@ -810,13 +810,12 @@ int32_t WebrtcGmpVideoDecoder::Decode( } /* static */ -// Using nsAutoPtr because WrapRunnable doesn't support move semantics void WebrtcGmpVideoDecoder::Decode_g(const RefPtr& aThis, - nsAutoPtr aDecodeData) { + UniquePtr&& aDecodeData) { if (!aThis->mGMP) { if (aThis->mInitting) { // InitDone hasn't been called yet (race) - aThis->mQueuedFrames.AppendElement(aDecodeData.forget()); + aThis->mQueuedFrames.AppendElement(std::move(aDecodeData)); return; } // destroyed via Terminate(), failed to init, or just not initted yet @@ -909,7 +908,7 @@ int32_t WebrtcGmpVideoDecoder::RegisterDecodeCompleteCallback( /* static */ void WebrtcGmpVideoDecoder::ReleaseGmp_g( - RefPtr& aDecoder) { + const RefPtr& aDecoder) { aDecoder->Close_g(); } diff --git a/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.h b/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.h index a4e9d5a9754e..a9aa6ac538ea 100644 --- a/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.h +++ b/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.h @@ -217,7 +217,7 @@ class WebrtcGmpVideoEncoder : public GMPVideoEncoderCallbackProxy, std::string* aErrorOut); int32_t InitEncoderForSize(unsigned short aWidth, unsigned short aHeight, std::string* aErrorOut); - static void ReleaseGmp_g(RefPtr& aEncoder); + static void ReleaseGmp_g(const RefPtr& aEncoder); void Close_g(); class InitDoneCallback : public GetGMPVideoEncoderCallback { @@ -247,7 +247,7 @@ class WebrtcGmpVideoEncoder : public GMPVideoEncoderCallbackProxy, uint32_t mMaxPayloadSize; }; - static void Encode_g(RefPtr& aEncoder, + static void Encode_g(const RefPtr& aEncoder, webrtc::VideoFrame aInputImage, std::vector aFrameTypes); void RegetEncoderForResolutionChange( @@ -405,7 +405,7 @@ class WebrtcGmpVideoDecoder : public GMPVideoDecoderCallbackProxy { const RefPtr& aInitDone); int32_t GmpInitDone(GMPVideoDecoderProxy* aGMP, GMPVideoHost* aHost, std::string* aErrorOut); - static void ReleaseGmp_g(RefPtr& aDecoder); + static void ReleaseGmp_g(const RefPtr& aDecoder); void Close_g(); class InitDoneCallback : public GetGMPVideoDecoderCallback { @@ -428,7 +428,7 @@ class WebrtcGmpVideoDecoder : public GMPVideoDecoderCallbackProxy { }; static void Decode_g(const RefPtr& aThis, - nsAutoPtr aDecodeData); + UniquePtr&& aDecodeData); nsCOMPtr mMPS; nsCOMPtr mGMPThread; diff --git a/media/webrtc/signaling/src/media-conduit/WebrtcMediaCodecVP8VideoCodec.cpp b/media/webrtc/signaling/src/media-conduit/WebrtcMediaCodecVP8VideoCodec.cpp index 423281d465d1..dfe71eff1c31 100644 --- a/media/webrtc/signaling/src/media-conduit/WebrtcMediaCodecVP8VideoCodec.cpp +++ b/media/webrtc/signaling/src/media-conduit/WebrtcMediaCodecVP8VideoCodec.cpp @@ -170,7 +170,7 @@ static java::sdk::MediaCodec::LocalRef CreateEncoder(const char* aMimeType) { return codec; } -static void ShutdownThread(nsCOMPtr& aThread) { +static void ShutdownThread(const nsCOMPtr& aThread) { aThread->Shutdown(); } diff --git a/media/webrtc/signaling/src/media-conduit/WebrtcMediaCodecVP8VideoCodec.h b/media/webrtc/signaling/src/media-conduit/WebrtcMediaCodecVP8VideoCodec.h index 4f0e0619d2fb..10bfa91fd954 100644 --- a/media/webrtc/signaling/src/media-conduit/WebrtcMediaCodecVP8VideoCodec.h +++ b/media/webrtc/signaling/src/media-conduit/WebrtcMediaCodecVP8VideoCodec.h @@ -9,7 +9,6 @@ #include "mozilla/Mutex.h" #include "nsThreadUtils.h" -#include "nsAutoPtr.h" #include "MediaConduitInterface.h" #include "AudioConduit.h" diff --git a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp index b6d01b30ee06..272737569f93 100644 --- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp +++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp @@ -485,7 +485,7 @@ void MediaPipeline::IncrementRtcpPacketsReceived() { } } -void MediaPipeline::RtpPacketReceived(MediaPacket& packet) { +void MediaPipeline::RtpPacketReceived(const MediaPacket& packet) { if (mDirection == DirectionType::TRANSMIT) { return; } @@ -572,7 +572,7 @@ void MediaPipeline::RtpPacketReceived(MediaPacket& packet) { header.ssrc); // Ignore error codes } -void MediaPipeline::RtcpPacketReceived(MediaPacket& packet) { +void MediaPipeline::RtcpPacketReceived(const MediaPacket& packet) { if (!mTransport->Pipeline()) { MOZ_LOG(gMediaPipelineLog, LogLevel::Debug, ("Discarding incoming packet; transport disconnected")); @@ -620,7 +620,7 @@ void MediaPipeline::RtcpPacketReceived(MediaPacket& packet) { } void MediaPipeline::PacketReceived(const std::string& aTransportId, - MediaPacket& packet) { + const MediaPacket& packet) { if (mTransportId != aTransportId) { return; } @@ -650,7 +650,7 @@ void MediaPipeline::AlpnNegotiated(const std::string& aAlpn, } void MediaPipeline::EncryptedPacketSending(const std::string& aTransportId, - MediaPacket& aPacket) { + const MediaPacket& aPacket) { if (mTransportId == aTransportId) { dom::mozPacketDumpType type; if (aPacket.type() == MediaPacket::SRTP) { diff --git a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.h b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.h index a924df32f484..cd0de8c4f55d 100644 --- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.h +++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.h @@ -207,14 +207,15 @@ class MediaPipeline : public sigslot::has_slots<> { void RtpStateChange(const std::string& aTransportId, TransportLayer::State); void RtcpStateChange(const std::string& aTransportId, TransportLayer::State); virtual void CheckTransportStates(); - void PacketReceived(const std::string& aTransportId, MediaPacket& packet); + void PacketReceived(const std::string& aTransportId, + const MediaPacket& packet); void AlpnNegotiated(const std::string& aAlpn, bool aPrivacyRequested); - void RtpPacketReceived(MediaPacket& packet); - void RtcpPacketReceived(MediaPacket& packet); + void RtpPacketReceived(const MediaPacket& packet); + void RtcpPacketReceived(const MediaPacket& packet); void EncryptedPacketSending(const std::string& aTransportId, - MediaPacket& aPacket); + const MediaPacket& aPacket); void SetDescription_s(const std::string& description); diff --git a/media/webrtc/signaling/src/peerconnection/MediaTransportHandler.cpp b/media/webrtc/signaling/src/peerconnection/MediaTransportHandler.cpp index 27d45977477d..7e9484fbd49b 100644 --- a/media/webrtc/signaling/src/peerconnection/MediaTransportHandler.cpp +++ b/media/webrtc/signaling/src/peerconnection/MediaTransportHandler.cpp @@ -869,12 +869,12 @@ void MediaTransportHandler::OnConnectionStateChange( } void MediaTransportHandler::OnPacketReceived(const std::string& aTransportId, - MediaPacket& aPacket) { + const MediaPacket& aPacket) { if (mCallbackThread && !mCallbackThread->IsOnCurrentThread()) { mCallbackThread->Dispatch( WrapRunnable(RefPtr(this), &MediaTransportHandler::OnPacketReceived, aTransportId, - aPacket), + const_cast(aPacket)), NS_DISPATCH_NORMAL); return; } @@ -883,12 +883,12 @@ void MediaTransportHandler::OnPacketReceived(const std::string& aTransportId, } void MediaTransportHandler::OnEncryptedSending(const std::string& aTransportId, - MediaPacket& aPacket) { + const MediaPacket& aPacket) { if (mCallbackThread && !mCallbackThread->IsOnCurrentThread()) { mCallbackThread->Dispatch( WrapRunnable(RefPtr(this), &MediaTransportHandler::OnEncryptedSending, aTransportId, - aPacket), + const_cast(aPacket)), NS_DISPATCH_NORMAL); return; } @@ -958,12 +958,12 @@ MediaTransportHandlerSTS::GetIceLog(const nsCString& aPattern) { mStsThread, __func__, [=, self = RefPtr(this)] { dom::Sequence converted; RLogConnector* logs = RLogConnector::GetInstance(); - nsAutoPtr> result(new std::deque); + std::deque result; // Might not exist yet. if (logs) { - logs->Filter(aPattern.get(), 0, result); + logs->Filter(aPattern.get(), 0, &result); } - for (auto& line : *result) { + for (auto& line : result) { converted.AppendElement(NS_ConvertUTF8toUTF16(line.c_str()), fallible); } diff --git a/media/webrtc/signaling/src/peerconnection/MediaTransportHandler.h b/media/webrtc/signaling/src/peerconnection/MediaTransportHandler.h index d934febef77c..753cbbb24ead 100644 --- a/media/webrtc/signaling/src/peerconnection/MediaTransportHandler.h +++ b/media/webrtc/signaling/src/peerconnection/MediaTransportHandler.h @@ -123,8 +123,9 @@ class MediaTransportHandler { sigslot::signal1 SignalGatheringStateChange; sigslot::signal1 SignalConnectionStateChange; - sigslot::signal2 SignalPacketReceived; - sigslot::signal2 SignalEncryptedSending; + sigslot::signal2 SignalPacketReceived; + sigslot::signal2 + SignalEncryptedSending; sigslot::signal2 SignalStateChange; sigslot::signal2 SignalRtcpStateChange; @@ -139,9 +140,10 @@ class MediaTransportHandler { void OnAlpnNegotiated(const std::string& aAlpn); void OnGatheringStateChange(dom::RTCIceGatheringState aState); void OnConnectionStateChange(dom::RTCIceConnectionState aState); - void OnPacketReceived(const std::string& aTransportId, MediaPacket& aPacket); + void OnPacketReceived(const std::string& aTransportId, + const MediaPacket& aPacket); void OnEncryptedSending(const std::string& aTransportId, - MediaPacket& aPacket); + const MediaPacket& aPacket); void OnStateChange(const std::string& aTransportId, TransportLayer::State aState); void OnRtcpStateChange(const std::string& aTransportId, diff --git a/media/webrtc/signaling/src/peerconnection/MediaTransportParent.cpp b/media/webrtc/signaling/src/peerconnection/MediaTransportParent.cpp index ff83931285f8..6e222f3e5ca0 100644 --- a/media/webrtc/signaling/src/peerconnection/MediaTransportParent.cpp +++ b/media/webrtc/signaling/src/peerconnection/MediaTransportParent.cpp @@ -61,12 +61,13 @@ class MediaTransportParent::Impl : public sigslot::has_slots<> { mParent->SendOnConnectionStateChange(static_cast(aState))); } - void OnPacketReceived(const std::string& aTransportId, MediaPacket& aPacket) { + void OnPacketReceived(const std::string& aTransportId, + const MediaPacket& aPacket) { NS_ENSURE_TRUE_VOID(mParent->SendOnPacketReceived(aTransportId, aPacket)); } void OnEncryptedSending(const std::string& aTransportId, - MediaPacket& aPacket) { + const MediaPacket& aPacket) { NS_ENSURE_TRUE_VOID(mParent->SendOnEncryptedSending(aTransportId, aPacket)); } diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h index db7566213a0e..44378900d858 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h @@ -12,7 +12,6 @@ #include "prlock.h" #include "mozilla/RefPtr.h" -#include "nsAutoPtr.h" #include "nsComponentManagerUtils.h" #include "nsPIDOMWindow.h" #include "nsIUUIDGenerator.h" diff --git a/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp b/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp index f818f616646e..dafb8f2683b8 100644 --- a/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp +++ b/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp @@ -19,7 +19,6 @@ #include "mozilla/dom/WebrtcGlobalInformationBinding.h" #include "mozilla/dom/ContentChild.h" -#include "nsAutoPtr.h" #include "nsNetCID.h" // NS_SOCKETTRANSPORTSERVICE_CONTRACTID #include "nsServiceManagerUtils.h" // do_GetService #include "mozilla/ErrorResult.h" diff --git a/netwerk/sctp/datachannel/DataChannel.cpp b/netwerk/sctp/datachannel/DataChannel.cpp index 6bbcdeb762d9..470412637706 100644 --- a/netwerk/sctp/datachannel/DataChannel.cpp +++ b/netwerk/sctp/datachannel/DataChannel.cpp @@ -844,7 +844,7 @@ void DataChannelConnection::ProcessQueuedOpens() { } void DataChannelConnection::SctpDtlsInput(const std::string& aTransportId, - MediaPacket& packet) { + const MediaPacket& packet) { if ((packet.type() != MediaPacket::SCTP) || (mTransportId != aTransportId)) { return; } diff --git a/netwerk/sctp/datachannel/DataChannel.h b/netwerk/sctp/datachannel/DataChannel.h index dd8c52f85e33..7a904558303a 100644 --- a/netwerk/sctp/datachannel/DataChannel.h +++ b/netwerk/sctp/datachannel/DataChannel.h @@ -243,7 +243,8 @@ class DataChannelConnection final : public net::NeckoTargetHolder #ifdef SCTP_DTLS_SUPPORTED static void DTLSConnectThread(void* data); void SendPacket(std::unique_ptr&& packet); - void SctpDtlsInput(const std::string& aTransportId, MediaPacket& packet); + void SctpDtlsInput(const std::string& aTransportId, + const MediaPacket& packet); static int SctpDtlsOutput(void* addr, void* buffer, size_t length, uint8_t tos, uint8_t set_df); #endif