Bug 1251714 - use UniquePtr instead of ScopedDeletePtr in media/; r=jesup
authorNathan Froyd <froydnj@mozilla.com>
Wed, 02 Mar 2016 15:28:27 -0500
changeset 286685 181f18c5d1adeb37fec7cf68e43803e2fa1629ba
parent 286684 972b36a3a3056c219c68a93b055565c9e90472da
child 286686 efefdfec4198412a48e8c16aaa2c3cb704f7e7fb
push id18000
push usercbook@mozilla.com
push dateFri, 04 Mar 2016 12:40:23 +0000
treeherderfx-team@365dff9e6e1f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup
bugs1251714
milestone47.0a1
Bug 1251714 - use UniquePtr instead of ScopedDeletePtr in media/; r=jesup UniquePtr is more standard than ScopedDeletePtr; using standard constructs whenever possible is preferable. This patch merits a couple explanations: - Where it made sense, I tried to convert: T* foo() { UniquePtr<T> x = ...; ... return x.release(); } into: UniquePtr<T> foo() with corresponding changes inside |foo|'s body. - The attentive reader will note that: auto x = MakeUnique<T>(...); is used sometimes and: UniquePtr<T> x(new T(...)); is used sometimes. I would prefer to use the former, but was stymied in several places due to protected constructors. (MakeUnique doesn't have access to those protected constructors, natch.)
media/mtransport/nricectx.h
media/mtransport/nricemediastream.cpp
media/mtransport/nricemediastream.h
media/mtransport/test/buffered_stun_socket_unittest.cpp
media/mtransport/test/ice_unittest.cpp
media/mtransport/test/multi_tcp_socket_unittest.cpp
media/mtransport/test/proxy_tunnel_socket_unittest.cpp
media/mtransport/test/stunserver.cpp
media/mtransport/test/stunserver.h
media/mtransport/test/turn_unittest.cpp
media/mtransport/transportflow.cpp
media/mtransport/transportflow.h
media/mtransport/transportlayerdtls.cpp
media/mtransport/transportlayerdtls.h
media/mtransport/transportlayerice.h
media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.cpp
media/webrtc/signaling/src/media-conduit/WebrtcMediaCodecVP8VideoCodec.cpp
media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
media/webrtc/signaling/src/peerconnection/MediaPipelineFactory.cpp
media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h
media/webrtc/signaling/test/mediaconduit_unittests.cpp
media/webrtc/signaling/test/signaling_unittests.cpp
--- a/media/mtransport/nricectx.h
+++ b/media/mtransport/nricectx.h
@@ -53,18 +53,18 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 #include <string>
 #include <vector>
 
 #include "sigslot.h"
 
 #include "prnetdb.h"
 
 #include "mozilla/RefPtr.h"
-#include "mozilla/Scoped.h"
 #include "mozilla/TimeStamp.h"
+#include "mozilla/UniquePtr.h"
 #include "nsAutoPtr.h"
 #include "nsIEventTarget.h"
 #include "nsITimer.h"
 
 #include "m_cpp_utils.h"
 
 typedef struct nr_ice_ctx_ nr_ice_ctx;
 typedef struct nr_ice_peer_ctx_ nr_ice_peer_ctx;
@@ -94,26 +94,25 @@ extern const char kNrIceTransportTcp[];
 
 class NrIceStunServer {
  public:
   explicit NrIceStunServer(const PRNetAddr& addr) : has_addr_(true) {
     memcpy(&addr_, &addr, sizeof(addr));
   }
 
    // The main function to use. Will take either an address or a hostname.
-  static NrIceStunServer* Create(const std::string& addr, uint16_t port,
+  static UniquePtr<NrIceStunServer> Create(const std::string& addr, uint16_t port,
       const char *transport = kNrIceTransportUdp) {
-    ScopedDeletePtr<NrIceStunServer> server(
-        new NrIceStunServer(transport));
+    UniquePtr<NrIceStunServer> server(new NrIceStunServer(transport));
 
     nsresult rv = server->Init(addr, port);
     if (NS_FAILED(rv))
       return nullptr;
 
-    return server.forget();
+    return server;
   }
 
   nsresult ToNicerStunStruct(nr_ice_stun_server* server) const;
 
  protected:
   explicit NrIceStunServer(const char *transport) :
       addr_(), transport_(transport) {}
 
@@ -141,28 +140,27 @@ class NrIceStunServer {
   std::string host_;
   uint16_t port_;
   PRNetAddr addr_;
   std::string transport_;
 };
 
 class NrIceTurnServer : public NrIceStunServer {
  public:
-  static NrIceTurnServer *Create(const std::string& addr, uint16_t port,
-                                 const std::string& username,
-                                 const std::vector<unsigned char>& password,
-                                 const char *transport = kNrIceTransportUdp) {
-    ScopedDeletePtr<NrIceTurnServer> server(
-        new NrIceTurnServer(username, password, transport));
+  static UniquePtr<NrIceTurnServer> Create(const std::string& addr, uint16_t port,
+                                           const std::string& username,
+                                           const std::vector<unsigned char>& password,
+                                           const char *transport = kNrIceTransportUdp) {
+    UniquePtr<NrIceTurnServer> server(new NrIceTurnServer(username, password, transport));
 
     nsresult rv = server->Init(addr, port);
     if (NS_FAILED(rv))
       return nullptr;
 
-    return server.forget();
+    return server;
   }
 
   nsresult ToNicerTurnStruct(nr_ice_turn_server *server) const;
 
  private:
   NrIceTurnServer(const std::string& username,
                   const std::vector<unsigned char>& password,
                   const char *transport) :
--- a/media/mtransport/nricemediastream.cpp
+++ b/media/mtransport/nricemediastream.cpp
@@ -41,17 +41,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 */
 
 
 #include <string>
 #include <vector>
 
 #include "logging.h"
 #include "nsError.h"
-#include "mozilla/Scoped.h"
 
 // nICEr includes
 extern "C" {
 #include "nr_api.h"
 #include "registry.h"
 #include "async_timer.h"
 #include "ice_util.h"
 #include "transport_addr.h"
@@ -164,23 +163,23 @@ static bool ToNrIceCandidate(const nr_ic
   out->tcp_type = tcp_type;
   out->codeword = candc.codeword;
   return true;
 }
 
 // Make an NrIceCandidate from the candidate |cand|.
 // This is not a member fxn because we want to hide the
 // defn of nr_ice_candidate but we pass by reference.
-static NrIceCandidate* MakeNrIceCandidate(const nr_ice_candidate& candc) {
-  ScopedDeletePtr<NrIceCandidate> out(new NrIceCandidate());
+static UniquePtr<NrIceCandidate> MakeNrIceCandidate(const nr_ice_candidate& candc) {
+  UniquePtr<NrIceCandidate> out(new NrIceCandidate());
 
-  if (!ToNrIceCandidate(candc, out)) {
+  if (!ToNrIceCandidate(candc, out.get())) {
     return nullptr;
   }
-  return out.forget();
+  return out;
 }
 
 // NrIceMediaStream
 RefPtr<NrIceMediaStream>
 NrIceMediaStream::Create(NrIceCtx *ctx,
                          const std::string& name,
                          int components) {
   RefPtr<NrIceMediaStream> stream =
@@ -254,18 +253,18 @@ nsresult NrIceMediaStream::ParseTrickleC
     }
   }
 
   return NS_OK;
 }
 
 // Returns NS_ERROR_NOT_AVAILABLE if component is unpaired or disabled.
 nsresult NrIceMediaStream::GetActivePair(int component,
-                                         NrIceCandidate **localp,
-                                         NrIceCandidate **remotep) {
+                                         UniquePtr<NrIceCandidate>* localp,
+                                         UniquePtr<NrIceCandidate>* remotep) {
   int r;
   nr_ice_candidate *local_int;
   nr_ice_candidate *remote_int;
 
   if (!stream_) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
@@ -275,30 +274,30 @@ nsresult NrIceMediaStream::GetActivePair
                                      &local_int, &remote_int);
   // If result is R_REJECTED then component is unpaired or disabled.
   if (r == R_REJECTED)
     return NS_ERROR_NOT_AVAILABLE;
 
   if (r)
     return NS_ERROR_FAILURE;
 
-  ScopedDeletePtr<NrIceCandidate> local(
+  UniquePtr<NrIceCandidate> local(
       MakeNrIceCandidate(*local_int));
   if (!local)
     return NS_ERROR_FAILURE;
 
-  ScopedDeletePtr<NrIceCandidate> remote(
+  UniquePtr<NrIceCandidate> remote(
       MakeNrIceCandidate(*remote_int));
   if (!remote)
     return NS_ERROR_FAILURE;
 
   if (localp)
-    *localp = local.forget();
+    *localp = Move(local);
   if (remotep)
-    *remotep = remote.forget();
+    *remotep = Move(remote);
 
   return NS_OK;
 }
 
 
 nsresult NrIceMediaStream::GetCandidatePairs(std::vector<NrIceCandidatePair>*
                                              out_pairs) const {
   MOZ_ASSERT(out_pairs);
--- a/media/mtransport/nricemediastream.h
+++ b/media/mtransport/nricemediastream.h
@@ -45,17 +45,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 #define nricemediastream_h__
 
 #include <string>
 #include <vector>
 
 #include "sigslot.h"
 
 #include "mozilla/RefPtr.h"
-#include "mozilla/Scoped.h"
+#include "mozilla/UniquePtr.h"
 #include "nsCOMPtr.h"
 #include "nsIEventTarget.h"
 #include "nsITimer.h"
 
 #include "m_cpp_utils.h"
 
 
 namespace mozilla {
@@ -154,17 +154,18 @@ class NrIceMediaStream {
   nsresult ParseTrickleCandidate(const std::string& candidate);
 
   // Disable a component
   nsresult DisableComponent(int component);
 
   // Get the candidate pair currently active. It's the
   // caller's responsibility to free these.
   nsresult GetActivePair(int component,
-                         NrIceCandidate** local, NrIceCandidate** remote);
+                         UniquePtr<NrIceCandidate>* local,
+                         UniquePtr<NrIceCandidate>* remote);
 
   // The number of components
   size_t components() const { return components_; }
 
   // The underlying nICEr stream
   nr_ice_media_stream *stream() { return stream_; }
   // Signals to indicate events. API users can (and should)
   // register for these.
--- a/media/mtransport/test/buffered_stun_socket_unittest.cpp
+++ b/media/mtransport/test/buffered_stun_socket_unittest.cpp
@@ -7,18 +7,16 @@
 // Original author: ekr@rtfm.com
 
 #include <iostream>
 
 #include "nspr.h"
 #include "nss.h"
 #include "ssl.h"
 
-#include "mozilla/Scoped.h"
-
 extern "C" {
 #include "nr_api.h"
 #include "nr_socket.h"
 #include "nr_socket_buffered_stun.h"
 #include "transport_addr.h"
 #include "stun.h"
 }
 
--- a/media/mtransport/test/ice_unittest.cpp
+++ b/media/mtransport/test/ice_unittest.cpp
@@ -17,17 +17,16 @@
 #include "sigslot.h"
 
 #include "logging.h"
 #include "nspr.h"
 #include "nss.h"
 #include "ssl.h"
 
 #include "mozilla/Preferences.h"
-#include "mozilla/Scoped.h"
 #include "nsThreadUtils.h"
 #include "nsXPCOM.h"
 
 #include "nricectx.h"
 #include "nricemediastream.h"
 #include "nriceresolverfake.h"
 #include "nriceresolver.h"
 #include "nrinterfaceprioritizer.h"
@@ -466,17 +465,17 @@ class IceTestPeer : public sigslot::has_
   void SetStunServer(const std::string addr, uint16_t port,
                      const char* transport = kNrIceTransportUdp) {
     if (addr.empty()) {
       // Happens when MOZ_DISABLE_NONLOCAL_CONNECTIONS is set
       return;
     }
 
     std::vector<NrIceStunServer> stun_servers;
-    ScopedDeletePtr<NrIceStunServer> server(NrIceStunServer::Create(
+    UniquePtr<NrIceStunServer> server(NrIceStunServer::Create(
         addr, port, transport));
     stun_servers.push_back(*server);
     SetStunServers(stun_servers);
   }
 
   void SetStunServers(const std::vector<NrIceStunServer> &servers) {
     ASSERT_TRUE(NS_SUCCEEDED(ice_ctx_->SetStunServers(servers)));
   }
@@ -495,17 +494,17 @@ class IceTestPeer : public sigslot::has_
   }
 
 
   void SetTurnServer(const std::string addr, uint16_t port,
                      const std::string username,
                      const std::vector<unsigned char> password,
                      const char* transport) {
     std::vector<NrIceTurnServer> turn_servers;
-    ScopedDeletePtr<NrIceTurnServer> server(NrIceTurnServer::Create(
+    UniquePtr<NrIceTurnServer> server(NrIceTurnServer::Create(
         addr, port, username, password, transport));
     turn_servers.push_back(*server);
     ASSERT_TRUE(NS_SUCCEEDED(ice_ctx_->SetTurnServers(turn_servers)));
   }
 
   void SetTurnServers(const std::vector<NrIceTurnServer> servers) {
     ASSERT_TRUE(NS_SUCCEEDED(ice_ctx_->SetTurnServers(servers)));
   }
@@ -839,18 +838,18 @@ class IceTestPeer : public sigslot::has_
     for (size_t i=0; i < streams_.size(); ++i) {
       if (!streams_[i]) {
         continue;
       }
 
       for (size_t j=0; j < streams_[i]->components(); ++j) {
         std::cerr << "Stream " << i << " component " << j+1 << std::endl;
 
-        NrIceCandidate *local;
-        NrIceCandidate *remote;
+        UniquePtr<NrIceCandidate> local;
+        UniquePtr<NrIceCandidate> remote;
 
         nsresult res = streams_[i]->GetActivePair(j+1, &local, &remote);
         if (res == NS_ERROR_NOT_AVAILABLE) {
           std::cerr << "Component unpaired or disabled." << std::endl;
         } else {
           ASSERT_TRUE(NS_SUCCEEDED(res));
           DumpCandidate("Local  ", *local);
           /* Depending on timing, and the whims of the network
@@ -871,18 +870,16 @@ class IceTestPeer : public sigslot::has_
             ASSERT_NE(NrIceCandidate::ICE_SERVER_REFLEXIVE, remote->type);
             ASSERT_NE(NrIceCandidate::ICE_RELAYED, remote->type);
           } else {
             ASSERT_EQ(expected_remote_type_, remote->type);
           }
           if (!expected_remote_addr_.empty()) {
             ASSERT_EQ(expected_remote_addr_, remote->cand_addr.host);
           }
-          delete local;
-          delete remote;
         }
       }
     }
   }
 
   void DumpAndCheckActiveCandidates() {
     test_utils_->sts_target()->Dispatch(
       WrapRunnable(this, &IceTestPeer::DumpAndCheckActiveCandidates_s),
@@ -1310,22 +1307,22 @@ class IceGatherTest : public StunTest {
 
   void TearDown() override {
     peer_ = nullptr;
     StunTest::TearDown();
   }
 
   void EnsurePeer(const unsigned int flags = ICE_TEST_PEER_OFFERER) {
     if (!peer_) {
-      peer_ = new IceTestPeer("P1", test_utils_,
-                              flags & ICE_TEST_PEER_OFFERER,
-                              flags & ICE_TEST_PEER_ALLOW_LOOPBACK,
-                              flags & ICE_TEST_PEER_ENABLED_TCP,
-                              flags & ICE_TEST_PEER_ALLOW_LINK_LOCAL,
-                              flags & ICE_TEST_PEER_HIDE_NON_DEFAULT);
+      peer_ = MakeUnique<IceTestPeer>("P1", test_utils_,
+                                      flags & ICE_TEST_PEER_OFFERER,
+                                      flags & ICE_TEST_PEER_ALLOW_LOOPBACK,
+                                      flags & ICE_TEST_PEER_ENABLED_TCP,
+                                      flags & ICE_TEST_PEER_ALLOW_LINK_LOCAL,
+                                      flags & ICE_TEST_PEER_HIDE_NON_DEFAULT);
       peer_->AddStream(1);
     }
   }
 
   void Gather(unsigned int waitTime = kDefaultTimeout) {
     EnsurePeer();
     peer_->Gather();
 
@@ -1448,17 +1445,17 @@ class IceGatherTest : public StunTest {
               << candidates.size() << std::endl;
 
     for (auto c : candidates) {
       std::cerr << "Candidate: " << c << std::endl;
     }
   }
 
  protected:
-  mozilla::ScopedDeletePtr<IceTestPeer> peer_;
+  mozilla::UniquePtr<IceTestPeer> peer_;
 };
 
 class IceConnectTest : public StunTest {
  public:
   IceConnectTest() :
     initted_(false),
     use_nat_(false),
     filtering_type_(TestNat::ENDPOINT_INDEPENDENT),
@@ -1488,20 +1485,20 @@ class IceConnectTest : public StunTest {
 
   void RemoveStream(size_t index) {
     p1_->RemoveStream(index);
     p2_->RemoveStream(index);
   }
 
   void Init(bool allow_loopback, bool enable_tcp, bool default_only = false) {
     if (!initted_) {
-      p1_ = new IceTestPeer("P1", test_utils_, true, allow_loopback,
-                            enable_tcp, false, default_only);
-      p2_ = new IceTestPeer("P2", test_utils_, false, allow_loopback,
-                            enable_tcp, false, default_only);
+      p1_ = MakeUnique<IceTestPeer>("P1", test_utils_, true, allow_loopback,
+                                    enable_tcp, false, default_only);
+      p2_ = MakeUnique<IceTestPeer>("P2", test_utils_, false, allow_loopback,
+                                    enable_tcp, false, default_only);
     }
     initted_ = true;
   }
 
   bool Gather(unsigned int waitTime = kDefaultTimeout,
               bool setupStunServers = true) {
     Init(false, false);
     if (use_nat_) {
@@ -1588,18 +1585,18 @@ class IceConnectTest : public StunTest {
     }
   }
 
   void Connect() {
     // IceTestPeer::Connect grabs attributes from the first arg, and gives them
     // to |this|, meaning that p2_->Connect(p1_, ...) simulates p1 sending an
     // offer to p2. Order matters here because it determines which peer is
     // controlling.
-    p2_->Connect(p1_, TRICKLE_NONE);
-    p1_->Connect(p2_, TRICKLE_NONE);
+    p2_->Connect(p1_.get(), TRICKLE_NONE);
+    p1_->Connect(p2_.get(), TRICKLE_NONE);
 
     ASSERT_TRUE_WAIT(p1_->ready_ct() == 1 && p2_->ready_ct() == 1,
                      kDefaultTimeout);
     ASSERT_TRUE_WAIT(p1_->ice_complete() && p2_->ice_complete(),
                      kDefaultTimeout);
     AssertCheckingReached();
 
     p1_->DumpAndCheckActiveCandidates();
@@ -1619,21 +1616,21 @@ class IceConnectTest : public StunTest {
   }
 
   void SetExpectedRemoteCandidateAddr(const std::string& addr) {
     p1_->SetExpectedRemoteCandidateAddr(addr);
     p2_->SetExpectedRemoteCandidateAddr(addr);
   }
 
   void ConnectP1(TrickleMode mode = TRICKLE_NONE) {
-    p1_->Connect(p2_, mode);
+    p1_->Connect(p2_.get(), mode);
   }
 
   void ConnectP2(TrickleMode mode = TRICKLE_NONE) {
-    p2_->Connect(p1_, mode);
+    p2_->Connect(p1_.get(), mode);
   }
 
   void WaitForComplete(int expected_streams = 1) {
     ASSERT_TRUE_WAIT(p1_->ready_ct() == expected_streams &&
                      p2_->ready_ct() == expected_streams, kDefaultTimeout);
     ASSERT_TRUE_WAIT(p1_->ice_complete() && p2_->ice_complete(),
                      kDefaultTimeout);
   }
@@ -1644,18 +1641,18 @@ class IceConnectTest : public StunTest {
   }
 
   void WaitForGather() {
     ASSERT_TRUE_WAIT(p1_->gathering_complete(), kDefaultTimeout);
     ASSERT_TRUE_WAIT(p2_->gathering_complete(), kDefaultTimeout);
   }
 
   void ConnectTrickle(TrickleMode trickle = TRICKLE_SIMULATE) {
-    p2_->Connect(p1_, trickle);
-    p1_->Connect(p2_, trickle);
+    p2_->Connect(p1_.get(), trickle);
+    p1_->Connect(p2_.get(), trickle);
   }
 
   void SimulateTrickle(size_t stream) {
     p1_->SimulateTrickle(stream);
     p2_->SimulateTrickle(stream);
     ASSERT_TRUE_WAIT(p1_->is_ready(stream), kDefaultTimeout);
     ASSERT_TRUE_WAIT(p2_->is_ready(stream), kDefaultTimeout);
   }
@@ -1671,18 +1668,18 @@ class IceConnectTest : public StunTest {
   void VerifyConnected() {
   }
 
   void CloseP1() {
     p1_->Close();
   }
 
   void ConnectThenDelete() {
-    p2_->Connect(p1_, TRICKLE_NONE, false);
-    p1_->Connect(p2_, TRICKLE_NONE, true);
+    p2_->Connect(p1_.get(), TRICKLE_NONE, false);
+    p1_->Connect(p2_.get(), TRICKLE_NONE, true);
     test_utils_->sts_target()->Dispatch(WrapRunnable(this,
                                                     &IceConnectTest::CloseP1),
                                        NS_DISPATCH_SYNC);
     p2_->StartChecks();
 
     // Wait to see if we crash
     PR_Sleep(PR_MillisecondsToInterval(kDefaultTimeout));
   }
@@ -1696,18 +1693,18 @@ class IceConnectTest : public StunTest {
         NS_DISPATCH_SYNC);
     ASSERT_EQ(1u, p1_->sent());
     ASSERT_TRUE_WAIT(p2_->received() == 1, 1000);
   }
 
  protected:
   bool initted_;
   nsCOMPtr<nsIEventTarget> target_;
-  mozilla::ScopedDeletePtr<IceTestPeer> p1_;
-  mozilla::ScopedDeletePtr<IceTestPeer> p2_;
+  mozilla::UniquePtr<IceTestPeer> p1_;
+  mozilla::UniquePtr<IceTestPeer> p2_;
   bool use_nat_;
   TestNat::NatBehavior filtering_type_;
   TestNat::NatBehavior mapping_type_;
   bool block_udp_;
 };
 
 class PrioritizerTest : public StunTest {
  public:
@@ -1855,17 +1852,17 @@ TEST_F(IceGatherTest, TestGatherFakeStun
   Gather();
 }
 
 TEST_F(IceGatherTest, TestGatherStunServerIpAddressDefaultRouteOnly) {
   if (stun_server_address_.empty()) {
     return;
   }
 
-  peer_ = new IceTestPeer("P1", test_utils_, true, false, false, false, true);
+  peer_ = MakeUnique<IceTestPeer>("P1", test_utils_, true, false, false, false, true);
   peer_->AddStream(1);
   peer_->SetStunServer(stun_server_address_, kDefaultStunServerPort);
   peer_->SetFakeResolver(stun_server_address_, stun_server_hostname_);
   Gather();
   ASSERT_FALSE(StreamHasMatchingCandidate(0, " host "));
 }
 
 TEST_F(IceGatherTest, TestGatherFakeStunServerHostname) {
@@ -2044,25 +2041,25 @@ TEST_F(IceGatherTest, TestGatherDisableC
 
 TEST_F(IceGatherTest, TestGatherVerifyNoLoopback) {
   Gather();
   ASSERT_FALSE(StreamHasMatchingCandidate(0, "127.0.0.1"));
 }
 
 TEST_F(IceGatherTest, TestGatherAllowLoopback) {
   // Set up peer with loopback allowed.
-  peer_ = new IceTestPeer("P1", test_utils_, true, true);
+  peer_ = MakeUnique<IceTestPeer>("P1", test_utils_, true, true);
   peer_->AddStream(1);
   Gather();
   ASSERT_TRUE(StreamHasMatchingCandidate(0, "127.0.0.1"));
 }
 
 TEST_F(IceGatherTest, TestGatherTcpDisabled) {
   // Set up peer with tcp disabled.
-  peer_ = new IceTestPeer("P1", test_utils_, true, false, false);
+  peer_ = MakeUnique<IceTestPeer>("P1", test_utils_, true, false, false);
   peer_->AddStream(1);
   Gather();
   ASSERT_FALSE(StreamHasMatchingCandidate(0, " TCP "));
   ASSERT_TRUE(StreamHasMatchingCandidate(0, " UDP "));
 }
 
 // Verify that a bogus candidate doesn't cause crashes on the
 // main thread. See bug 856433.
@@ -2155,17 +2152,17 @@ TEST_F(IceGatherTest, TestStunServerTric
   ASSERT_FALSE(StreamHasMatchingCandidate(0, "192.0.2.1"));
   WaitForGather();
   ASSERT_TRUE(StreamHasMatchingCandidate(0, "192.0.2.1"));
 }
 
 // Test default route only with our fake STUN server and
 // apparently NATted.
 TEST_F(IceGatherTest, TestFakeStunServerNatedDefaultRouteOnly) {
-  peer_ = new IceTestPeer("P1", test_utils_, true, false, false, false, true);
+  peer_ = MakeUnique<IceTestPeer>("P1", test_utils_, true, false, false, false, true);
   peer_->AddStream(1);
   UseFakeStunUdpServerWithResponse("192.0.2.1", 3333);
   Gather(0);
   WaitForGather();
   DumpCandidates(0);
   ASSERT_FALSE(StreamHasMatchingCandidate(0, "host"));
   ASSERT_TRUE(StreamHasMatchingCandidate(0, "srflx"));
   NrIceCandidate default_candidate;
@@ -2173,17 +2170,17 @@ TEST_F(IceGatherTest, TestFakeStunServer
   if (NS_SUCCEEDED(rv)) {
     ASSERT_NE(NrIceCandidate::ICE_HOST, default_candidate.type);
   }
 }
 
 // Test default route only with our fake STUN server and
 // apparently non-NATted.
 TEST_F(IceGatherTest, TestFakeStunServerNoNatDefaultRouteOnly) {
-  peer_ = new IceTestPeer("P1", test_utils_, true, false, false, false, true);
+  peer_ = MakeUnique<IceTestPeer>("P1", test_utils_, true, false, false, false, true);
   peer_->AddStream(1);
   UseTestStunServer();
   Gather(0);
   WaitForGather();
   DumpCandidates(0);
   ASSERT_FALSE(StreamHasMatchingCandidate(0, "host"));
   ASSERT_TRUE(StreamHasMatchingCandidate(0, "srflx"));
 }
@@ -3052,20 +3049,18 @@ TEST_F(IceConnectTest, TestHostCandPairi
 
   int host_net = p1_->GetCandidatesPrivateIpv4Range(0);
   if (host_net <= 0) {
     // TODO bug 1226838: make this work with multiple private IPs
     FAIL() << "This test needs exactly one private IPv4 host candidate to work" << std::endl;
   }
 
   ConnectTrickle();
-  AddNonPairableCandidates(p1_->ControlTrickle(0), p1_, 0, host_net,
-                           test_utils_);
-  AddNonPairableCandidates(p2_->ControlTrickle(0), p2_, 0, host_net,
-                           test_utils_);
+  AddNonPairableCandidates(p1_->ControlTrickle(0), p1_.get(), 0, host_net, test_utils_);
+  AddNonPairableCandidates(p2_->ControlTrickle(0), p2_.get(), 0, host_net, test_utils_);
 
   std::vector<NrIceCandidatePair> pairs;
   p1_->GetCandidatePairs(0, &pairs);
   for (auto p : pairs) {
     std::cerr << "Verifying pair:" << std::endl;
     p1_->DumpCandidatePair(p);
     nr_transport_addr addr;
     nr_str_port_to_transport_addr(p.local.local_addr.host.c_str(), 0, IPPROTO_UDP, &addr);
@@ -3116,18 +3111,18 @@ TEST_F(IceConnectTest, TestSrflxCandPair
     ASSERT_TRUE(nr_transport_addr_get_private_addr_range(&addr) == 0);
   }
 }
 
 TEST_F(IceConnectTest, TestPollCandPairsDuringConnect) {
   AddStream("first", 1);
   ASSERT_TRUE(Gather());
 
-  p2_->Connect(p1_, TRICKLE_NONE, false);
-  p1_->Connect(p2_, TRICKLE_NONE, false);
+  p2_->Connect(p1_.get(), TRICKLE_NONE, false);
+  p1_->Connect(p2_.get(), TRICKLE_NONE, false);
 
   std::vector<NrIceCandidatePair> pairs1;
   std::vector<NrIceCandidatePair> pairs2;
 
   p1_->StartChecks();
   p1_->UpdateAndValidateCandidatePairs(0, &pairs1);
   p2_->UpdateAndValidateCandidatePairs(0, &pairs2);
 
@@ -3141,18 +3136,18 @@ TEST_F(IceConnectTest, TestPollCandPairs
   ASSERT_TRUE(ContainsSucceededPair(pairs1));
   ASSERT_TRUE(ContainsSucceededPair(pairs2));
 }
 
 TEST_F(IceConnectTest, TestRLogRingBuffer) {
   AddStream("first", 1);
   ASSERT_TRUE(Gather());
 
-  p2_->Connect(p1_, TRICKLE_NONE, false);
-  p1_->Connect(p2_, TRICKLE_NONE, false);
+  p2_->Connect(p1_.get(), TRICKLE_NONE, false);
+  p1_->Connect(p2_.get(), TRICKLE_NONE, false);
 
   std::vector<NrIceCandidatePair> pairs1;
   std::vector<NrIceCandidatePair> pairs2;
 
   p1_->StartChecks();
   p1_->UpdateAndValidateCandidatePairs(0, &pairs1);
   p2_->UpdateAndValidateCandidatePairs(0, &pairs2);
 
--- a/media/mtransport/test/multi_tcp_socket_unittest.cpp
+++ b/media/mtransport/test/multi_tcp_socket_unittest.cpp
@@ -2,17 +2,16 @@
 /* vim: set ts=2 et sw=2 tw=80: */
 /* 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/. */
 
 #include <iostream>
 #include <vector>
 
-#include "mozilla/Scoped.h"
 #include "mozilla/Atomics.h"
 #include "runnable_utils.h"
 #include "nss.h"
 #include "pk11pub.h"
 
 extern "C" {
 #include "nr_api.h"
 #include "nr_socket.h"
@@ -101,17 +100,17 @@ class MultiTcpSocketTest : public Mtrans
                 uint16_t stun_server_port, nr_socket **sock) {
     nr_transport_addr local;
     // Get start of port range for test
     static unsigned short port_s = GetRandomPort();
     int r;
 
     if (!stun_server_addr.empty()) {
       std::vector<NrIceStunServer> stun_servers;
-      ScopedDeletePtr<NrIceStunServer> server(NrIceStunServer::Create(
+      UniquePtr<NrIceStunServer> server(NrIceStunServer::Create(
           stun_server_addr, stun_server_port, kNrIceTransportTcp));
       stun_servers.push_back(*server);
 
       ASSERT_TRUE(NS_SUCCEEDED(ice_ctx_->SetStunServers(stun_servers)));
     }
 
     r = 1;
     for (int tries=10; tries && r; --tries) {
--- a/media/mtransport/test/proxy_tunnel_socket_unittest.cpp
+++ b/media/mtransport/test/proxy_tunnel_socket_unittest.cpp
@@ -7,18 +7,16 @@
 // Original authors: ekr@rtfm.com; ryan@tokbox.com
 
 #include <iostream>
 
 #include "nspr.h"
 #include "nss.h"
 #include "ssl.h"
 
-#include "mozilla/Scoped.h"
-
 extern "C" {
 #include "nr_api.h"
 #include "nr_socket.h"
 #include "nr_proxy_tunnel.h"
 #include "transport_addr.h"
 #include "stun.h"
 }
 
--- a/media/mtransport/test/stunserver.cpp
+++ b/media/mtransport/test/stunserver.cpp
@@ -73,17 +73,18 @@ nrappkit copyright:
    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    POSSIBILITY OF SUCH DAMAGE.
 
 
    ekr@rtfm.com  Thu Dec 20 20:14:49 2001
 */
 #include "logging.h"
-#include "mozilla/Scoped.h"
+#include "mozilla/UniquePtr.h"
+#include "mozilla/unused.h"
 #include "databuffer.h"
 
 extern "C" {
 #include "nr_api.h"
 #include "async_wait.h"
 #include "async_timer.h"
 #include "nr_socket.h"
 #include "nr_socket_local.h"
@@ -169,25 +170,25 @@ static nr_socket_vtbl nr_socket_wrapped_
   0,
   0,
   nr_socket_wrapped_close,
   0,
   0
 };
 
 int nr_socket_wrapped_create(nr_socket *inner, nr_socket **outp) {
-  ScopedDeletePtr<nr_socket_wrapped> wrapped(new nr_socket_wrapped());
+  auto wrapped = MakeUnique<nr_socket_wrapped>();
 
   wrapped->sock_ = inner;
 
   int r = nr_socket_create_int(wrapped.get(), &nr_socket_wrapped_vtbl, outp);
   if (r)
     return r;
 
-  wrapped.forget();
+  Unused << wrapped.release();
   return 0;
 }
 
 
 // Instance static.
 // Note: Calling Create() at static init time is not going to be safe, since
 // we have no reason to expect this will be initted to a nullptr yet.
 TestStunServer *TestStunServer::instance;
@@ -318,51 +319,51 @@ int TestStunServer::Initialize(int addre
   }
 
   listen_addr_ = addr_string;
   listen_port_ = instance_port;
 
   return 0;
 }
 
-TestStunServer* TestStunServer::Create(int address_family) {
+UniquePtr<TestStunServer> TestStunServer::Create(int address_family) {
   NR_reg_init(NR_REG_MODE_LOCAL);
 
-  ScopedDeletePtr<TestStunServer> server(new TestStunServer());
+  UniquePtr<TestStunServer> server(new TestStunServer());
 
   if (server->Initialize(address_family))
     return nullptr;
 
   NR_SOCKET fd;
   int r = nr_socket_getfd(server->listen_sock_, &fd);
   if (r) {
     MOZ_MTLOG(ML_ERROR, "Couldn't get fd");
     return nullptr;
   }
 
   NR_ASYNC_WAIT(fd, NR_ASYNC_WAIT_READ, &TestStunServer::readable_cb, server.get());
 
-  return server.forget();
+  return server;
 }
 
 void TestStunServer::ConfigurePort(uint16_t port) {
   instance_port = port;
 }
 
 TestStunServer* TestStunServer::GetInstance(int address_family) {
   switch (address_family) {
     case AF_INET:
       if (!instance)
-        instance = Create(address_family);
+        instance = Create(address_family).release();
 
       MOZ_ASSERT(instance);
       return instance;
     case AF_INET6:
       if (!instance6)
-        instance6 = Create(address_family);
+        instance6 = Create(address_family).release();
 
       return instance6;
     default:
       MOZ_CRASH();
   }
 }
 
 void TestStunServer::ShutdownInstance() {
@@ -530,23 +531,23 @@ void TestStunServer::Reset() {
 void TestStunTcpServer::ConfigurePort(uint16_t port) {
   instance_port = port;
 }
 
 TestStunTcpServer* TestStunTcpServer::GetInstance(int address_family) {
   switch (address_family) {
     case AF_INET:
       if (!instance)
-        instance = Create(address_family);
+        instance = Create(address_family).release();
 
       MOZ_ASSERT(instance);
       return instance;
     case AF_INET6:
       if (!instance6)
-        instance6 = Create(address_family);
+        instance6 = Create(address_family).release();
 
       return instance6;
     default:
       MOZ_CRASH();
   }
 }
 
 void TestStunTcpServer::ShutdownInstance() {
@@ -627,34 +628,34 @@ void TestStunTcpServer::accept_cb(NR_SOC
     return;
   }
 
   server->connections_[fd] = wrapsock;
 
   NR_ASYNC_WAIT(fd, NR_ASYNC_WAIT_READ, &TestStunServer::readable_cb, server);
 }
 
-TestStunTcpServer* TestStunTcpServer::Create(int address_family) {
+  UniquePtr<TestStunTcpServer> TestStunTcpServer::Create(int address_family) {
   NR_reg_init(NR_REG_MODE_LOCAL);
 
-  ScopedDeletePtr<TestStunTcpServer> server(new TestStunTcpServer());
+  UniquePtr<TestStunTcpServer> server(new TestStunTcpServer());
 
   if (server->Initialize(address_family)) {
     return nullptr;
   }
 
   NR_SOCKET fd;
   if(nr_socket_getfd(server->listen_sock_, &fd)) {
     MOZ_MTLOG(ML_ERROR, "Couldn't get tcp fd");
     return nullptr;
   }
 
   NR_ASYNC_WAIT(fd, NR_ASYNC_WAIT_READ, &TestStunTcpServer::accept_cb, server.get());
 
-  return server.forget();
+  return server;
 }
 
 TestStunTcpServer::~TestStunTcpServer() {
   for (auto it = connections_.begin(); it != connections_.end();) {
     NR_ASYNC_CANCEL(it->first, NR_ASYNC_WAIT_READ);
     nr_socket_destroy(&it->second);
     connections_.erase(it++);
   }
--- a/media/mtransport/test/stunserver.h
+++ b/media/mtransport/test/stunserver.h
@@ -8,16 +8,17 @@
 
 #ifndef stunserver_h__
 #define stunserver_h__
 
 #include <map>
 #include <string>
 #include "prio.h"
 #include "nsError.h"
+#include "mozilla/UniquePtr.h"
 
 typedef struct nr_stun_server_ctx_ nr_stun_server_ctx;
 typedef struct nr_socket_ nr_socket;
 typedef struct nr_local_addr_ nr_local_addr;
 
 
 namespace mozilla {
 
@@ -26,17 +27,17 @@ class TestStunServer {
   // Generally, you should only call API in this class from the same thread that
   // the initial |GetInstance| call was made from.
   static TestStunServer *GetInstance(int address_family = AF_INET);
   static void ShutdownInstance();
   // |ConfigurePort| will only have an effect if called before the first call
   // to |GetInstance| (possibly following a |ShutdownInstance| call)
   static void ConfigurePort(uint16_t port);
   // AF_INET, AF_INET6
-  static TestStunServer *Create(int address_family);
+  static UniquePtr<TestStunServer> Create(int address_family);
 
   virtual ~TestStunServer();
 
   void SetActive(bool active);
   void SetDelay(uint32_t delay_ms);
   void SetDropInitialPackets(uint32_t count);
   const std::string& addr() const { return listen_addr_; }
   uint16_t port() const { return listen_port_; }
@@ -105,17 +106,17 @@ class TestStunTcpServer: public TestStun
   virtual nr_socket* GetSendingSocket(nr_socket *sock);
 
  protected:
   TestStunTcpServer() {}
   static void accept_cb(NR_SOCKET sock, int how, void *cb_arg);
 
  private:
   virtual int TryOpenListenSocket(nr_local_addr *addr, uint16_t port);
-  static TestStunTcpServer *Create(int address_family);
+  static UniquePtr<TestStunTcpServer> Create(int address_family);
 
   static TestStunTcpServer *instance;
   static TestStunTcpServer *instance6;
   static uint16_t instance_port;
 
   std::map<NR_SOCKET, nr_socket*> connections_;
 };
 } // End of namespace mozilla
--- a/media/mtransport/test/turn_unittest.cpp
+++ b/media/mtransport/test/turn_unittest.cpp
@@ -44,17 +44,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 
 #include "sigslot.h"
 
 #include "logging.h"
 #include "nspr.h"
 #include "nss.h"
 #include "ssl.h"
 
-#include "mozilla/Scoped.h"
 #include "nsThreadUtils.h"
 #include "nsXPCOM.h"
 
 #include "runnable_utils.h"
 
 #define GTEST_HAS_RTTI 0
 #include "gtest/gtest.h"
 #include "gtest_utils.h"
--- a/media/mtransport/transportflow.cpp
+++ b/media/mtransport/transportflow.cpp
@@ -30,24 +30,24 @@ TransportFlow::~TransportFlow() {
 
   // Push the destruction onto the STS thread. Note that there
   // 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
   // ensures automatic destruction of the queue at exit of
   // DestroyFinal.
-  nsAutoPtr<std::deque<TransportLayer*> > layers_tmp(layers_.forget());
+  nsAutoPtr<std::deque<TransportLayer*>> layers_tmp(layers_.release());
   RUN_ON_THREAD(target_,
                 WrapRunnableNM(&TransportFlow::DestroyFinal, layers_tmp),
                 NS_DISPATCH_NORMAL);
 }
 
 void TransportFlow::DestroyFinal(nsAutoPtr<std::deque<TransportLayer *> > layers) {
-  ClearLayers(layers);
+  ClearLayers(layers.get());
 }
 
 void TransportFlow::ClearLayers(std::queue<TransportLayer *>* layers) {
   while (!layers->empty()) {
     delete layers->front();
     layers->pop();
   }
 }
@@ -56,17 +56,17 @@ void TransportFlow::ClearLayers(std::deq
   while (!layers->empty()) {
     delete layers->front();
     layers->pop_front();
   }
 }
 
 nsresult TransportFlow::PushLayer(TransportLayer *layer) {
   CheckThread();
-  ScopedDeletePtr<TransportLayer> layer_tmp(layer);  // Destroy on failure.
+  UniquePtr<TransportLayer> layer_tmp(layer);  // Destroy on failure.
 
   // Don't allow pushes once we are in error state.
   if (state_ == TransportLayer::TS_ERROR) {
     MOZ_MTLOG(ML_ERROR, id_ + ": Can't call PushLayer in error state for flow");
     return NS_ERROR_FAILURE;
   }
 
   nsresult rv = layer->Init();
@@ -85,17 +85,17 @@ nsresult TransportFlow::PushLayer(Transp
 
   TransportLayer *old_layer = layers_->empty() ? nullptr : layers_->front();
 
   // Re-target my signals to the new layer
   if (old_layer) {
     old_layer->SignalStateChange.disconnect(this);
     old_layer->SignalPacketReceived.disconnect(this);
   }
-  layers_->push_front(layer_tmp.forget());
+  layers_->push_front(layer_tmp.release());
   layer->Inserted(this, old_layer);
 
   layer->SignalStateChange.connect(this, &TransportFlow::StateChange);
   layer->SignalPacketReceived.connect(this, &TransportFlow::PacketReceived);
   StateChangeInt(layer->state());
 
   return NS_OK;
 }
@@ -141,21 +141,21 @@ nsresult TransportFlow::PushLayers(nsAut
     // Push the layer onto the queue.
     layers_->push_front(layer);
     layers->pop();
     layer->Inserted(this, old_layer);
   }
 
   if (NS_FAILED(rv)) {
     // Destroy any layers we could not push.
-    ClearLayers(layers);
+    ClearLayers(layers.get());
 
     // Now destroy the rest of the flow, because it's no longer
     // in an acceptable state.
-    ClearLayers(layers_);
+    ClearLayers(layers_.get());
 
     // Set ourselves to have failed.
     StateChangeInt(TransportLayer::TS_ERROR);
 
     // Return failure.
     return rv;
   }
 
--- a/media/mtransport/transportflow.h
+++ b/media/mtransport/transportflow.h
@@ -10,17 +10,17 @@
 #define transportflow_h__
 
 #include <deque>
 #include <queue>
 #include <string>
 
 #include "nscore.h"
 #include "nsISupportsImpl.h"
-#include "mozilla/Scoped.h"
+#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.
 
 // This code has a confusing hybrid threading model which
@@ -130,14 +130,14 @@ class TransportFlow final : public nsISu
   static void DestroyFinal(nsAutoPtr<std::deque<TransportLayer *> > layers);
 
   // Overload needed because we use deque internally and queue externally.
   static void ClearLayers(std::deque<TransportLayer *>* layers);
   static void ClearLayers(std::queue<TransportLayer *>* layers);
 
   std::string id_;
   TransportLayer::State state_;
-  ScopedDeletePtr<std::deque<TransportLayer *> > layers_;
+  UniquePtr<std::deque<TransportLayer *>> layers_;
   nsCOMPtr<nsIEventTarget> target_;
 };
 
 }  // close namespace
 #endif
--- a/media/mtransport/transportlayerdtls.cpp
+++ b/media/mtransport/transportlayerdtls.cpp
@@ -458,17 +458,17 @@ TransportLayerDtls::SetVerificationDiges
 bool TransportLayerDtls::Setup() {
   CheckThread();
   SECStatus rv;
 
   if (!downward_) {
     MOZ_MTLOG(ML_ERROR, "DTLS layer with nothing below. This is useless");
     return false;
   }
-  nspr_io_adapter_ = new TransportLayerNSPRAdapter(downward_);
+  nspr_io_adapter_ = MakeUnique<TransportLayerNSPRAdapter>(downward_);
 
   if (!identity_) {
     MOZ_MTLOG(ML_ERROR, "Can't start DTLS without an identity");
     return false;
   }
 
   if (verification_mode_ == VERIFY_UNSET) {
     MOZ_MTLOG(ML_ERROR,
--- a/media/mtransport/transportlayerdtls.h
+++ b/media/mtransport/transportlayerdtls.h
@@ -10,17 +10,17 @@
 #define transportlayerdtls_h__
 
 #include <queue>
 #include <set>
 
 #include "sigslot.h"
 
 #include "mozilla/RefPtr.h"
-#include "mozilla/Scoped.h"
+#include "mozilla/UniquePtr.h"
 #include "nsCOMPtr.h"
 #include "nsIEventTarget.h"
 #include "nsITimer.h"
 #include "ScopedNSSTypes.h"
 #include "m_cpp_utils.h"
 #include "dtlsidentity.h"
 #include "transportflow.h"
 #include "transportlayer.h"
@@ -172,17 +172,17 @@ class TransportLayerDtls final : public 
   std::vector<uint16_t> srtp_ciphers_;
 
   Role role_;
   Verification verification_mode_;
   std::vector<RefPtr<VerificationDigest> > digests_;
 
   // Must delete nspr_io_adapter after ssl_fd_ b/c ssl_fd_ causes an alert
   // (ssl_fd_ contains an un-owning pointer to nspr_io_adapter_)
-  ScopedDeletePtr<TransportLayerNSPRAdapter> nspr_io_adapter_;
+  UniquePtr<TransportLayerNSPRAdapter> nspr_io_adapter_;
   ScopedPRFileDesc ssl_fd_;
 
   ScopedCERTCertificate peer_cert_;
   nsCOMPtr<nsITimer> timer_;
   bool auth_hook_called_;
   bool cert_ok_;
 };
 
--- a/media/mtransport/transportlayerice.h
+++ b/media/mtransport/transportlayerice.h
@@ -10,17 +10,16 @@
 #ifndef transportlayerice_h__
 #define transportlayerice_h__
 
 #include <vector>
 
 #include "sigslot.h"
 
 #include "mozilla/RefPtr.h"
-#include "mozilla/Scoped.h"
 #include "nsCOMPtr.h"
 #include "nsIEventTarget.h"
 #include "nsITimer.h"
 
 #include "m_cpp_utils.h"
 
 #include "nricemediastream.h"
 #include "transportflow.h"
--- a/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.cpp
+++ b/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.cpp
@@ -3,17 +3,16 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "WebrtcGmpVideoCodec.h"
 
 #include <iostream>
 #include <vector>
 
 #include "mozilla/Move.h"
-#include "mozilla/Scoped.h"
 #include "mozilla/SyncRunnable.h"
 #include "VideoConduit.h"
 #include "AudioConduit.h"
 #include "runnable_utils.h"
 
 #include "mozIGeckoMediaPluginService.h"
 #include "nsServiceManagerUtils.h"
 #include "GMPVideoDecoderProxy.h"
--- a/media/webrtc/signaling/src/media-conduit/WebrtcMediaCodecVP8VideoCodec.cpp
+++ b/media/webrtc/signaling/src/media-conduit/WebrtcMediaCodecVP8VideoCodec.cpp
@@ -7,17 +7,16 @@
 #include <queue>
 
 #include "CSFLog.h"
 #include "nspr.h"
 
 #include "MediaCodec.h"
 #include "WebrtcMediaCodecVP8VideoCodec.h"
 #include "AndroidJNIWrapper.h"
-#include "mozilla/Scoped.h"
 #include "mozilla/ArrayUtils.h"
 #include "nsThreadUtils.h"
 #include "mozilla/Monitor.h"
 #include "runnable_utils.h"
 
 #include "AudioConduit.h"
 #include "VideoConduit.h"
 #include "libyuv/convert_from.h"
--- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
+++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
@@ -508,21 +508,20 @@ void MediaPipeline::RtpPacketReceived(Tr
     ssrcs_received_.push_back(header.ssrc);
   }
 
   if (filter_ && !filter_->Filter(header)) {
     return;
   }
 
   // Make a copy rather than cast away constness
-  ScopedDeletePtr<unsigned char> inner_data(
-      new unsigned char[len]);
-  memcpy(inner_data, data, len);
+  auto inner_data = MakeUnique<unsigned char[]>(len);
+  memcpy(inner_data.get(), data, len);
   int out_len = 0;
-  nsresult res = rtp_.recv_srtp_->UnprotectRtp(inner_data,
+  nsresult res = rtp_.recv_srtp_->UnprotectRtp(inner_data.get(),
                                                len, len, &out_len);
   if (!NS_SUCCEEDED(res)) {
     char tmp[16];
 
     PR_snprintf(tmp, sizeof(tmp), "%.2x %.2x %.2x %.2x",
                 inner_data[0],
                 inner_data[1],
                 inner_data[2],
@@ -531,17 +530,17 @@ void MediaPipeline::RtpPacketReceived(Tr
     MOZ_MTLOG(ML_NOTICE, "Error unprotecting RTP in " << description_
               << "len= " << len << "[" << tmp << "...]");
 
     return;
   }
   MOZ_MTLOG(ML_DEBUG, description_ << " received RTP packet.");
   increment_rtp_packets_received(out_len);
 
-  (void)conduit_->ReceivedRTPPacket(inner_data, out_len);  // Ignore error codes
+  (void)conduit_->ReceivedRTPPacket(inner_data.get(), out_len);  // Ignore error codes
 }
 
 void MediaPipeline::RtcpPacketReceived(TransportLayer *layer,
                                        const unsigned char *data,
                                        size_t len) {
   if (!transport_->pipeline()) {
     MOZ_MTLOG(ML_DEBUG, "Discarding incoming packet; transport disconnected");
     return;
@@ -567,44 +566,43 @@ void MediaPipeline::RtcpPacketReceived(T
   }
 
   // Filter out everything but RTP/RTCP
   if (data[0] < 128 || data[0] > 191) {
     return;
   }
 
   // Make a copy rather than cast away constness
-  ScopedDeletePtr<unsigned char> inner_data(
-      new unsigned char[len]);
-  memcpy(inner_data, data, len);
+  auto inner_data = MakeUnique<unsigned char[]>(len);
+  memcpy(inner_data.get(), data, len);
   int out_len;
 
-  nsresult res = rtcp_.recv_srtp_->UnprotectRtcp(inner_data,
+  nsresult res = rtcp_.recv_srtp_->UnprotectRtcp(inner_data.get(),
                                                  len,
                                                  len,
                                                  &out_len);
 
   if (!NS_SUCCEEDED(res))
     return;
 
   // We do not filter RTCP for send pipelines, since the webrtc.org code for
   // senders already has logic to ignore RRs that do not apply.
   if (filter_ && direction_ == RECEIVE) {
-    if (!filter_->FilterSenderReport(inner_data, out_len)) {
+    if (!filter_->FilterSenderReport(inner_data.get(), out_len)) {
       MOZ_MTLOG(ML_NOTICE, "Dropping rtcp packet");
       return;
     }
   }
 
   MOZ_MTLOG(ML_DEBUG, description_ << " received RTCP packet.");
   increment_rtcp_packets_received();
 
   MOZ_ASSERT(rtcp_.recv_srtp_);  // This should never happen
 
-  (void)conduit_->ReceivedRTCPPacket(inner_data, out_len);  // Ignore error codes
+  (void)conduit_->ReceivedRTCPPacket(inner_data.get(), out_len);  // Ignore error codes
 }
 
 bool MediaPipeline::IsRtp(const unsigned char *data, size_t len) {
   if (len < 2)
     return false;
 
   // Check if this is a RTCP packet. Logic based on the types listed in
   // media/webrtc/trunk/src/modules/rtp_rtcp/source/rtp_utility.cc
--- a/media/webrtc/signaling/src/peerconnection/MediaPipelineFactory.cpp
+++ b/media/webrtc/signaling/src/peerconnection/MediaPipelineFactory.cpp
@@ -120,33 +120,33 @@ JsepCodecDescToCodecConfig(const JsepCod
 
   uint16_t pt;
 
   if (!desc.GetPtAsInt(&pt)) {
     MOZ_MTLOG(ML_ERROR, "Invalid payload type: " << desc.mDefaultPt);
     return NS_ERROR_INVALID_ARG;
   }
 
-  ScopedDeletePtr<VideoCodecConfigH264> h264Config;
+  UniquePtr<VideoCodecConfigH264> h264Config;
 
   if (desc.mName == "H264") {
-    h264Config = new VideoCodecConfigH264;
+    h264Config = MakeUnique<VideoCodecConfigH264>();
     size_t spropSize = sizeof(h264Config->sprop_parameter_sets);
     strncpy(h264Config->sprop_parameter_sets,
             desc.mSpropParameterSets.c_str(),
             spropSize);
     h264Config->sprop_parameter_sets[spropSize - 1] = '\0';
     h264Config->packetization_mode = desc.mPacketizationMode;
     h264Config->profile_level_id = desc.mProfileLevelId;
     h264Config->tias_bw = 0; // TODO. Issue 165.
   }
 
   VideoCodecConfig* configRaw;
   configRaw = new VideoCodecConfig(
-      pt, desc.mName, desc.mConstraints, h264Config);
+      pt, desc.mName, desc.mConstraints, h264Config.get());
 
   configRaw->mAckFbTypes = desc.mAckFbTypes;
   configRaw->mNackFbTypes = desc.mNackFbTypes;
   configRaw->mCcmFbTypes = desc.mCcmFbTypes;
 
   *aConfig = configRaw;
   return NS_OK;
 }
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h
@@ -152,40 +152,38 @@ class PeerConnectionConfiguration
 public:
   PeerConnectionConfiguration()
   : mBundlePolicy(kBundleBalanced),
     mIceTransportPolicy(NrIceCtx::ICE_POLICY_ALL) {}
 
   bool addStunServer(const std::string& addr, uint16_t port,
                      const char* transport)
   {
-    NrIceStunServer* server(NrIceStunServer::Create(addr, port, transport));
+    UniquePtr<NrIceStunServer> server(NrIceStunServer::Create(addr, port, transport));
     if (!server) {
       return false;
     }
     addStunServer(*server);
-    delete server;
     return true;
   }
   bool addTurnServer(const std::string& addr, uint16_t port,
                      const std::string& username,
                      const std::string& pwd,
                      const char* transport)
   {
     // TODO(ekr@rtfm.com): Need support for SASLprep for
     // username and password. Bug # ???
     std::vector<unsigned char> password(pwd.begin(), pwd.end());
 
-    NrIceTurnServer* server(NrIceTurnServer::Create(addr, port, username, password,
-                                                    transport));
+    UniquePtr<NrIceTurnServer> server(NrIceTurnServer::Create(addr, port, username, password,
+							      transport));
     if (!server) {
       return false;
     }
     addTurnServer(*server);
-    delete server;
     return true;
   }
   void addStunServer(const NrIceStunServer& server) { mStunServers.push_back (server); }
   void addTurnServer(const NrIceTurnServer& server) { mTurnServers.push_back (server); }
   const std::vector<NrIceStunServer>& getStunServers() const { return mStunServers; }
   const std::vector<NrIceTurnServer>& getTurnServers() const { return mTurnServers; }
   void setBundlePolicy(JsepBundlePolicy policy) { mBundlePolicy = policy;}
   JsepBundlePolicy getBundlePolicy() const { return mBundlePolicy; }
--- a/media/webrtc/signaling/test/mediaconduit_unittests.cpp
+++ b/media/webrtc/signaling/test/mediaconduit_unittests.cpp
@@ -6,18 +6,18 @@
 #include <string>
 #include <fstream>
 #include <unistd.h>
 #include <vector>
 #include <math.h>
 
 using namespace std;
 
-#include "mozilla/Scoped.h"
 #include "mozilla/SyncRunnable.h"
+#include "mozilla/UniquePtr.h"
 #include <MediaConduitInterface.h>
 #include "GmpVideoCodec.h"
 #include "nsIEventTarget.h"
 #include "FakeMediaStreamsImpl.h"
 #include "FakeLogging.h"
 #include "nsThreadUtils.h"
 #include "runnable_utils.h"
 #include "signaling/src/common/EncodingConstraints.h"
@@ -87,40 +87,40 @@ public:
   }
   void SetRate(int r) {
     rate = r;
   }
   void Init(RefPtr<mozilla::VideoSessionConduit> aSession)
   {
         mSession = aSession;
         mLen = ((width * height) * 3 / 2);
-        mFrame = (uint8_t*) PR_MALLOC(mLen);
-        memset(mFrame, COLOR, mLen);
+        mFrame = mozilla::MakeUnique<uint8_t[]>(mLen);
+        memset(mFrame.get(), COLOR, mLen);
         numFrames = 121;
   }
 
   void GenerateAndReadSamples()
   {
     do
     {
-      mSession->SendVideoFrame((unsigned char*)mFrame,
+      mSession->SendVideoFrame(reinterpret_cast<unsigned char*>(mFrame.get()),
                                 mLen,
                                 width,
                                 height,
                                 mozilla::kVideoI420,
                                 0);
       PR_Sleep(PR_MillisecondsToInterval(1000/rate));
       vidStatsGlobal.numRawFramesInserted++;
       numFrames--;
     } while(numFrames >= 0);
   }
 
 private:
 RefPtr<mozilla::VideoSessionConduit> mSession;
-mozilla::ScopedDeletePtr<uint8_t> mFrame;
+mozilla::UniquePtr<uint8_t[]> mFrame;
 int mLen;
 int width, height;
 int rate;
 int numFrames;
 };
 
 
 
@@ -285,18 +285,18 @@ void AudioSendAndReceive::GenerateMusic(
     if(i%6==0)j++;
   }
   cerr << "Generating Input Music Done " << endl;
 }
 
 //Hardcoded for 16 bit samples for now
 void AudioSendAndReceive::GenerateAndReadSamples()
 {
-   mozilla::ScopedDeletePtr<int16_t> audioInput(new int16_t [PLAYOUT_SAMPLE_LENGTH]);
-   mozilla::ScopedDeletePtr<int16_t> audioOutput(new int16_t [PLAYOUT_SAMPLE_LENGTH]);
+   auto audioInput = mozilla::MakeUnique<int16_t []>(PLAYOUT_SAMPLE_LENGTH);
+   auto audioOutput = mozilla::MakeUnique<int16_t []>(PLAYOUT_SAMPLE_LENGTH);
    short* inbuf;
    int sampleLengthDecoded = 0;
    unsigned int SAMPLES = (PLAYOUT_SAMPLE_FREQUENCY * 10); //10 seconds
    int CHANNELS = 1; //mono audio
    int sampleLengthInBytes = sizeof(int16_t) * PLAYOUT_SAMPLE_LENGTH;
    //generated audio buffer
    inbuf = (short *)moz_xmalloc(sizeof(short)*SAMPLES*CHANNELS);
    memset(audioInput.get(),0,sampleLengthInBytes);
--- a/media/webrtc/signaling/test/signaling_unittests.cpp
+++ b/media/webrtc/signaling/test/signaling_unittests.cpp
@@ -1683,29 +1683,29 @@ class SignalingAgentTest : public ::test
     }
   }
 
   bool CreateAgent() {
     return CreateAgent(g_stun_server_address, g_stun_server_port);
   }
 
   bool CreateAgent(const std::string stun_addr, uint16_t stun_port) {
-    ScopedDeletePtr<SignalingAgent> agent(
+    UniquePtr<SignalingAgent> agent(
         new SignalingAgent("agent", stun_addr, stun_port));
 
     agent->Init();
 
-    agents_.push_back(agent.forget());
+    agents_.push_back(agent.release());
 
     return true;
   }
 
   void CreateAgentNoInit() {
-    ScopedDeletePtr<SignalingAgent> agent(new SignalingAgent("agent"));
-    agents_.push_back(agent.forget());
+    UniquePtr<SignalingAgent> agent(new SignalingAgent("agent"));
+    agents_.push_back(agent.release());
   }
 
   SignalingAgent *agent(size_t i) {
     return agents_[i];
   }
 
  private:
   std::vector<SignalingAgent *> agents_;
@@ -1744,18 +1744,18 @@ public:
   static void SetUpTestCase() {
   }
 
   void EnsureInit() {
 
     if (init_)
       return;
 
-    a1_ = new SignalingAgent(callerName, stun_addr_, stun_port_);
-    a2_ = new SignalingAgent(calleeName, stun_addr_, stun_port_);
+    a1_ = MakeUnique<SignalingAgent>(callerName, stun_addr_, stun_port_);
+    a2_ = MakeUnique<SignalingAgent>(calleeName, stun_addr_, stun_port_);
 
     if (GetParam() == "no_bundle") {
       a1_->SetBundleEnabled(false);
     } else if(GetParam() == "reject_bundle") {
       a2_->SetBundleEnabled(false);
     } else if (GetParam() == "max-bundle") {
       a1_->SetBundlePolicy(JsepBundlePolicy::kBundleMaxBundle);
       a2_->SetBundlePolicy(JsepBundlePolicy::kBundleMaxBundle);
@@ -2165,18 +2165,18 @@ public:
     a1_->CloseSendStreams();
     a2_->CloseSendStreams();
     a1_->CloseReceiveStreams();
     a2_->CloseReceiveStreams();
   }
 
  protected:
   bool init_;
-  ScopedDeletePtr<SignalingAgent> a1_;  // Canonically "caller"
-  ScopedDeletePtr<SignalingAgent> a2_;  // Canonically "callee"
+  UniquePtr<SignalingAgent> a1_;  // Canonically "caller"
+  UniquePtr<SignalingAgent> a2_;  // Canonically "callee"
   std::string stun_addr_;
   uint16_t stun_port_;
 };
 
 static void SetIntPrefOnMainThread(nsCOMPtr<nsIPrefBranch> prefs,
   const char *pref_name,
   int new_value) {
   MOZ_ASSERT(NS_IsMainThread());