Bug 1521879 - Part 1.1: Compensate for changes to how IPC headers are generated in the last rebase. r=mjf
authorByron Campen [:bwc] <docfaraday@gmail.com>
Mon, 25 Feb 2019 21:50:58 +0000
changeset 460999 fd4330c37f1f8ae8ff828c3ae082f95de5895994
parent 460998 f18e61be455d493f10a2cc651cd254859894e02e
child 461000 92aca26a32044148d827ef27cced50f36f86a7e1
push id35613
push usernerli@mozilla.com
push dateTue, 26 Feb 2019 03:52:35 +0000
treeherdermozilla-central@faec87a80ed1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmjf
bugs1521879
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1521879 - Part 1.1: Compensate for changes to how IPC headers are generated in the last rebase. r=mjf Differential Revision: https://phabricator.services.mozilla.com/D19975
CLOBBER
dom/media/moz.build
dom/media/webrtc/MediaTransportChild.h
dom/media/webrtc/MediaTransportParent.h
dom/media/webrtc/WebrtcIPCTraits.h
media/mtransport/mediapacket.cpp
media/webrtc/signaling/src/peerconnection/MediaTransportHandlerIPC.cpp
media/webrtc/signaling/src/peerconnection/MediaTransportHandlerIPC.h
media/webrtc/signaling/src/peerconnection/MediaTransportHandlerParent.cpp
media/webrtc/signaling/src/peerconnection/MediaTransportHandlerParent.h
media/webrtc/signaling/src/peerconnection/MediaTransportParent.cpp
media/webrtc/signaling/src/peerconnection/moz.build
netwerk/ipc/SocketProcessBridgeChild.h
netwerk/ipc/SocketProcessBridgeParent.cpp
netwerk/ipc/SocketProcessBridgeParent.h
--- a/CLOBBER
+++ b/CLOBBER
@@ -17,9 +17,9 @@
 #
 # Modifying this file will now automatically clobber the buildbot machines \o/
 #
 
 # Are you updating CLOBBER because you think it's needed for your WebIDL
 # changes to stick? As of bug 928195, this shouldn't be necessary! Please
 # don't change CLOBBER for WebIDL changes any more.
 
-Bug 1524688: Deleting preprocessed manifests requires clobber.
+Bug 1521879: Adding PMediaTransport.ipdl requires a clobber.
--- a/dom/media/moz.build
+++ b/dom/media/moz.build
@@ -202,16 +202,18 @@ EXPORTS.mozilla.dom += [
     'TextTrackCue.h',
     'TextTrackCueList.h',
     'TextTrackList.h',
     'TextTrackRegion.h',
     'VideoPlaybackQuality.h',
     'VideoStreamTrack.h',
     'VideoTrack.h',
     'VideoTrackList.h',
+    'webrtc/MediaTransportChild.h',
+    'webrtc/MediaTransportParent.h',
 ]
 
 UNIFIED_SOURCES += [
     'ADTSDecoder.cpp',
     'ADTSDemuxer.cpp',
     'AudioCaptureStream.cpp',
     'AudioChannelFormat.cpp',
     'AudioCompactor.cpp',
new file mode 100644
--- /dev/null
+++ b/dom/media/webrtc/MediaTransportChild.h
@@ -0,0 +1,36 @@
+/* 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 _MTRANSPORTCHILD_H__
+#define _MTRANSPORTCHILD_H__
+
+#include "mozilla/dom/PMediaTransportChild.h"
+
+namespace mozilla {
+class MediaTransportHandlerIPC;
+
+class MediaTransportChild : public dom::PMediaTransportChild {
+ public:
+  explicit MediaTransportChild(MediaTransportHandlerIPC* aUser);
+  virtual ~MediaTransportChild();
+  mozilla::ipc::IPCResult RecvOnCandidate(const string& transportId,
+                                          const CandidateInfo& candidateInfo);
+  mozilla::ipc::IPCResult RecvOnAlpnNegotiated(const string& alpn);
+  mozilla::ipc::IPCResult RecvOnGatheringStateChange(const int& state);
+  mozilla::ipc::IPCResult RecvOnConnectionStateChange(const int& state);
+  mozilla::ipc::IPCResult RecvOnPacketReceived(const string& transportId,
+                                               const MediaPacket& packet);
+  mozilla::ipc::IPCResult RecvOnEncryptedSending(const string& transportId,
+                                                 const MediaPacket& packet);
+  mozilla::ipc::IPCResult RecvOnStateChange(const string& transportId,
+                                            const int& state);
+  mozilla::ipc::IPCResult RecvOnRtcpStateChange(const string& transportId,
+                                                const int& state);
+
+ private:
+  RefPtr<MediaTransportHandlerIPC> mUser;
+};
+
+}  // namespace mozilla
+#endif
rename from media/webrtc/signaling/src/peerconnection/MediaTransportHandlerParent.h
rename to dom/media/webrtc/MediaTransportParent.h
--- a/media/webrtc/signaling/src/peerconnection/MediaTransportHandlerParent.h
+++ b/dom/media/webrtc/MediaTransportParent.h
@@ -1,78 +1,62 @@
 /* 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 _MTRANSPORTHANDLER_PARENT_H__
 #define _MTRANSPORTHANDLER_PARENT_H__
 
 #include "mozilla/dom/PMediaTransportParent.h"
-#include "signaling/src/peerconnection/MediaTransportHandler.h"
-#include "sigslot.h"
+#include <memory>
 
 namespace mozilla {
 
-class MediaTransportHandlerParent : public dom::PMediaTransportParent,
-                                    public sigslot::has_slots<> {
+class MediaTransportParent : public dom::PMediaTransportParent {
  public:
-  MediaTransportHandlerParent();
-  virtual ~MediaTransportHandlerParent();
-
-  void OnCandidate(const std::string& aTransportId,
-                   const CandidateInfo& aCandidateInfo);
-  void OnAlpnNegotiated(const std::string& aAlpn);
-  void OnGatheringStateChange(dom::PCImplIceGatheringState aState);
-  void OnConnectionStateChange(dom::PCImplIceConnectionState aState);
-  void OnPacketReceived(const std::string& aTransportId, MediaPacket& aPacket);
-  void OnEncryptedSending(const std::string& aTransportId,
-                          MediaPacket& aPacket);
-  void OnStateChange(const std::string& aTransportId,
-                     TransportLayer::State aState);
-  void OnRtcpStateChange(const std::string& aTransportId,
-                         TransportLayer::State aState);
+  MediaTransportParent();
+  virtual ~MediaTransportParent();
 
   mozilla::ipc::IPCResult RecvGetIceLog(const nsCString& pattern,
-                                        GetIceLogResolver&& aResolve) override;
-  mozilla::ipc::IPCResult RecvClearIceLog() override;
-  mozilla::ipc::IPCResult RecvEnterPrivateMode() override;
-  mozilla::ipc::IPCResult RecvExitPrivateMode() override;
+                                        GetIceLogResolver&& aResolve);
+  mozilla::ipc::IPCResult RecvClearIceLog();
+  mozilla::ipc::IPCResult RecvEnterPrivateMode();
+  mozilla::ipc::IPCResult RecvExitPrivateMode();
   mozilla::ipc::IPCResult RecvCreateIceCtx(
       const string& name, nsTArray<RTCIceServer>&& iceServers,
-      const RTCIceTransportPolicy& icePolicy) override;
+      const RTCIceTransportPolicy& icePolicy);
   mozilla::ipc::IPCResult RecvSetProxyServer(const PBrowserOrId& browserOrId,
-                                             const nsCString& alpn) override;
+                                             const nsCString& alpn);
   mozilla::ipc::IPCResult RecvEnsureProvisionalTransport(
       const string& transportId, const string& localUfrag,
-      const string& localPwd, const int& componentCount) override;
+      const string& localPwd, const int& componentCount);
   mozilla::ipc::IPCResult RecvStartIceGathering(
-      const bool& defaultRouteOnly,
-      const net::NrIceStunAddrArray& stunAddrs) override;
+      const bool& defaultRouteOnly, const net::NrIceStunAddrArray& stunAddrs);
   mozilla::ipc::IPCResult RecvActivateTransport(
       const string& transportId, const string& localUfrag,
       const string& localPwd, const int& componentCount,
       const string& remoteUfrag, const string& remotePwd,
       nsTArray<uint8_t>&& keyDer, nsTArray<uint8_t>&& certDer,
       const int& authType, const bool& dtlsClient,
-      const DtlsDigestList& digests, const bool& privacyRequested) override;
+      const DtlsDigestList& digests, const bool& privacyRequested);
   mozilla::ipc::IPCResult RecvRemoveTransportsExcept(
-      const StringVector& transportIds) override;
-  mozilla::ipc::IPCResult RecvStartIceChecks(
-      const bool& isControlling, const bool& isOfferer,
-      const StringVector& iceOptions) override;
+      const StringVector& transportIds);
+  mozilla::ipc::IPCResult RecvStartIceChecks(const bool& isControlling,
+                                             const bool& isOfferer,
+                                             const StringVector& iceOptions);
   mozilla::ipc::IPCResult RecvSendPacket(const string& transportId,
-                                         const MediaPacket& packet) override;
+                                         const MediaPacket& packet);
   mozilla::ipc::IPCResult RecvAddIceCandidate(const string& transportId,
-                                              const string& candidate) override;
-  mozilla::ipc::IPCResult RecvUpdateNetworkState(const bool& online) override;
+                                              const string& candidate);
+  mozilla::ipc::IPCResult RecvUpdateNetworkState(const bool& online);
   mozilla::ipc::IPCResult RecvGetIceStats(
       const string& transportId, const double& now,
-      const RTCStatsReportInternal& reportIn,
-      GetIceStatsResolver&& aResolve) override;
+      const RTCStatsReportInternal& reportIn, GetIceStatsResolver&& aResolve);
 
-  void ActorDestroy(ActorDestroyReason aWhy) override;
+  void ActorDestroy(ActorDestroyReason aWhy);
 
  private:
-  RefPtr<MediaTransportHandler> mImpl;
-  RefPtr<nsIEventTarget> mStsThread;
+  // Hide the sigslot/MediaTransportHandler stuff from IPC.
+  class Impl;
+  std::unique_ptr<Impl> mImpl;
 };
 }  // namespace mozilla
 #endif  //_MTRANSPORTHANDLER_PARENT_H__
--- a/dom/media/webrtc/WebrtcIPCTraits.h
+++ b/dom/media/webrtc/WebrtcIPCTraits.h
@@ -20,26 +20,26 @@ typedef std::vector<std::string> StringV
 
 namespace IPC {
 
 template <typename T>
 struct ParamTraits<std::vector<T>> {
   typedef std::vector<T> paramType;
 
   static void Write(Message* aMsg, const paramType& aParam) {
-    aMsg->WriteSize(aParam.size());
+    aMsg->WriteUInt32(aParam.size());
     for (const T& elem : aParam) {
       WriteParam(aMsg, elem);
     }
   }
 
   static bool Read(const Message* aMsg, PickleIterator* aIter,
                    paramType* aResult) {
-    size_t size;
-    if (!aMsg->ReadSize(aIter, &size)) {
+    uint32_t size;
+    if (!aMsg->ReadUInt32(aIter, &size)) {
       return false;
     }
     while (size--) {
       // Only works when T is movable. Meh.
       T elem;
       if (!ReadParam(aMsg, aIter, &elem)) {
         return false;
       }
--- a/media/mtransport/mediapacket.cpp
+++ b/media/mtransport/mediapacket.cpp
@@ -22,51 +22,51 @@ void MediaPacket::Copy(const uint8_t* da
   }
   data_.reset(new uint8_t[capacity]);
   len_ = len;
   capacity_ = capacity;
   memcpy(data_.get(), data, len);
 }
 
 void MediaPacket::Serialize(IPC::Message* aMsg) const {
-  aMsg->WriteSize(len_);
-  aMsg->WriteSize(capacity_);
+  aMsg->WriteUInt32(len_);
+  aMsg->WriteUInt32(capacity_);
   if (len_) {
     aMsg->WriteBytes(data_.get(), len_);
   }
-  aMsg->WriteSize(encrypted_len_);
+  aMsg->WriteUInt32(encrypted_len_);
   if (encrypted_len_) {
     aMsg->WriteBytes(encrypted_data_.get(), encrypted_len_);
   }
   aMsg->WriteInt32(sdp_level_.isSome() ? *sdp_level_ : -1);
   aMsg->WriteInt32(type_);
 }
 
 bool MediaPacket::Deserialize(const IPC::Message* aMsg, PickleIterator* aIter) {
   Reset();
-  size_t len;
-  if (!aMsg->ReadSize(aIter, &len)) {
+  uint32_t len;
+  if (!aMsg->ReadUInt32(aIter, &len)) {
     return false;
   }
-  size_t capacity;
-  if (!aMsg->ReadSize(aIter, &capacity)) {
+  uint32_t capacity;
+  if (!aMsg->ReadUInt32(aIter, &capacity)) {
     return false;
   }
   if (len) {
     MOZ_RELEASE_ASSERT(capacity >= len);
     UniquePtr<uint8_t[]> data(new uint8_t[capacity]);
     if (!aMsg->ReadBytesInto(aIter, data.get(), len)) {
       return false;
     }
     data_ = std::move(data);
     len_ = len;
     capacity_ = capacity;
   }
 
-  if (!aMsg->ReadSize(aIter, &len)) {
+  if (!aMsg->ReadUInt32(aIter, &len)) {
     return false;
   }
   if (len) {
     UniquePtr<uint8_t[]> data(new uint8_t[len]);
     if (!aMsg->ReadBytesInto(aIter, data.get(), len)) {
       return false;
     }
     encrypted_data_ = std::move(data);
--- a/media/webrtc/signaling/src/peerconnection/MediaTransportHandlerIPC.cpp
+++ b/media/webrtc/signaling/src/peerconnection/MediaTransportHandlerIPC.cpp
@@ -1,56 +1,34 @@
 /* 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 "MediaTransportHandlerIPC.h"
+#include "mozilla/dom/MediaTransportChild.h"
 #include "nsThreadUtils.h"
 #include "mozilla/net/SocketProcessBridgeChild.h"
 #include "mozilla/RefPtr.h"
 
 namespace mozilla {
 
 static const char* mthipcLogTag = "MediaTransportHandler";
 #ifdef LOGTAG
 #  undef LOGTAG
 #endif
 #define LOGTAG mthipcLogTag
 
-class MediaTransportHandlerChild : public dom::PMediaTransportChild {
- public:
-  explicit MediaTransportHandlerChild(MediaTransportHandlerIPC* aUser);
-  virtual ~MediaTransportHandlerChild();
-  mozilla::ipc::IPCResult RecvOnCandidate(
-      const string& transportId, const CandidateInfo& candidateInfo) override;
-  mozilla::ipc::IPCResult RecvOnAlpnNegotiated(const string& alpn) override;
-  mozilla::ipc::IPCResult RecvOnGatheringStateChange(const int& state) override;
-  mozilla::ipc::IPCResult RecvOnConnectionStateChange(
-      const int& state) override;
-  mozilla::ipc::IPCResult RecvOnPacketReceived(
-      const string& transportId, const MediaPacket& packet) override;
-  mozilla::ipc::IPCResult RecvOnEncryptedSending(
-      const string& transportId, const MediaPacket& packet) override;
-  mozilla::ipc::IPCResult RecvOnStateChange(const string& transportId,
-                                            const int& state) override;
-  mozilla::ipc::IPCResult RecvOnRtcpStateChange(const string& transportId,
-                                                const int& state) override;
-
- private:
-  RefPtr<MediaTransportHandlerIPC> mUser;
-};
-
 MediaTransportHandlerIPC::MediaTransportHandlerIPC(
     nsISerialEventTarget* aCallbackThread)
     : MediaTransportHandler(aCallbackThread) {
   mInitPromise = net::SocketProcessBridgeChild::GetSocketProcessBridge()->Then(
       GetMainThreadSerialEventTarget(), __func__,
       [this, self = RefPtr<MediaTransportHandlerIPC>(this)](
           const RefPtr<net::SocketProcessBridgeChild>& aBridge) {
-        mChild = new MediaTransportHandlerChild(this);
+        mChild = new MediaTransportChild(this);
         // SocketProcessBridgeChild owns mChild! When it is done with it,
         // mChild will let us know it it going away.
         aBridge->SetEventTargetForActor(mChild, GetMainThreadEventTarget());
         aBridge->SendPMediaTransportConstructor(mChild);
         return InitPromise::CreateAndResolve(true, __func__);
       },
       [=](const nsCString& aError) {
         CSFLogError(LOGTAG,
@@ -153,17 +131,17 @@ nsresult MediaTransportHandlerIPC::Creat
   return NS_OK;
 }
 
 void MediaTransportHandlerIPC::Destroy() {
   mInitPromise->Then(
       GetMainThreadSerialEventTarget(), __func__,
       [=, self = RefPtr<MediaTransportHandlerIPC>(this)](bool /*dummy*/) {
         if (mChild) {
-          MediaTransportHandlerChild::Send__delete__(mChild);
+          MediaTransportChild::Send__delete__(mChild);
           mChild = nullptr;
         }
       },
       [](const nsCString& aError) {});
 }
 
 // We will probably be able to move the proxy lookup stuff into
 // this class once we move mtransport to its own process.
@@ -322,79 +300,78 @@ MediaTransportHandlerIPC::GetIceStats(
                        });
         return promise;
       },
       [](const nsCString& aError) {
         return StatsPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
       });
 }
 
-MediaTransportHandlerChild::MediaTransportHandlerChild(
-    MediaTransportHandlerIPC* aUser)
+MediaTransportChild::MediaTransportChild(MediaTransportHandlerIPC* aUser)
     : mUser(aUser) {}
 
-MediaTransportHandlerChild::~MediaTransportHandlerChild() {
+MediaTransportChild::~MediaTransportChild() {
   MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
   mUser->mChild = nullptr;
 }
 
-mozilla::ipc::IPCResult MediaTransportHandlerChild::RecvOnCandidate(
+mozilla::ipc::IPCResult MediaTransportChild::RecvOnCandidate(
     const string& transportId, const CandidateInfo& candidateInfo) {
   MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
   mUser->OnCandidate(transportId, candidateInfo);
   return ipc::IPCResult::Ok();
 }
 
-mozilla::ipc::IPCResult MediaTransportHandlerChild::RecvOnAlpnNegotiated(
+mozilla::ipc::IPCResult MediaTransportChild::RecvOnAlpnNegotiated(
     const string& alpn) {
   MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
   mUser->OnAlpnNegotiated(alpn);
   return ipc::IPCResult::Ok();
 }
 
-mozilla::ipc::IPCResult MediaTransportHandlerChild::RecvOnGatheringStateChange(
+mozilla::ipc::IPCResult MediaTransportChild::RecvOnGatheringStateChange(
     const int& state) {
   MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
   mUser->OnGatheringStateChange(
       static_cast<dom::PCImplIceGatheringState>(state));
   return ipc::IPCResult::Ok();
 }
 
-mozilla::ipc::IPCResult MediaTransportHandlerChild::RecvOnConnectionStateChange(
+mozilla::ipc::IPCResult MediaTransportChild::RecvOnConnectionStateChange(
     const int& state) {
   MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
   mUser->OnConnectionStateChange(
       static_cast<dom::PCImplIceConnectionState>(state));
   return ipc::IPCResult::Ok();
 }
 
-mozilla::ipc::IPCResult MediaTransportHandlerChild::RecvOnPacketReceived(
+mozilla::ipc::IPCResult MediaTransportChild::RecvOnPacketReceived(
     const string& transportId, const MediaPacket& packet) {
   MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
   MediaPacket copy(packet);  // Laaaaaame! Might be safe to const_cast?
   mUser->OnPacketReceived(transportId, copy);
   return ipc::IPCResult::Ok();
 }
 
-mozilla::ipc::IPCResult MediaTransportHandlerChild::RecvOnEncryptedSending(
+mozilla::ipc::IPCResult MediaTransportChild::RecvOnEncryptedSending(
     const string& transportId, const MediaPacket& packet) {
   MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
   MediaPacket copy(packet);  // Laaaaaame! Might be safe to const_cast?
   mUser->OnEncryptedSending(transportId, copy);
   return ipc::IPCResult::Ok();
 }
 
-mozilla::ipc::IPCResult MediaTransportHandlerChild::RecvOnStateChange(
+mozilla::ipc::IPCResult MediaTransportChild::RecvOnStateChange(
     const string& transportId, const int& state) {
   MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
   mUser->OnStateChange(transportId, static_cast<TransportLayer::State>(state));
   return ipc::IPCResult::Ok();
 }
 
-mozilla::ipc::IPCResult MediaTransportHandlerChild::RecvOnRtcpStateChange(
+mozilla::ipc::IPCResult MediaTransportChild::RecvOnRtcpStateChange(
     const string& transportId, const int& state) {
   MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
   mUser->OnRtcpStateChange(transportId,
                            static_cast<TransportLayer::State>(state));
   return ipc::IPCResult::Ok();
 }
 
 }  // namespace mozilla
--- a/media/webrtc/signaling/src/peerconnection/MediaTransportHandlerIPC.h
+++ b/media/webrtc/signaling/src/peerconnection/MediaTransportHandlerIPC.h
@@ -5,17 +5,17 @@
 #ifndef _MTRANSPORTHANDLER_IPC_H__
 #define _MTRANSPORTHANDLER_IPC_H__
 
 #include "signaling/src/peerconnection/MediaTransportHandler.h"
 #include "mozilla/dom/PMediaTransportChild.h"
 
 namespace mozilla {
 
-class MediaTransportHandlerChild;
+class MediaTransportChild;
 
 // Implementation of MediaTransportHandler that uses IPC (PMediaTransport) to
 // talk to mtransport on another process.
 class MediaTransportHandlerIPC : public MediaTransportHandler {
  public:
   explicit MediaTransportHandlerIPC(nsISerialEventTarget* aCallbackThread);
   RefPtr<IceLogPromise> GetIceLog(const nsCString& aPattern) override;
   void ClearIceLog() override;
@@ -67,20 +67,20 @@ class MediaTransportHandlerIPC : public 
 
   void UpdateNetworkState(bool aOnline) override;
 
   RefPtr<StatsPromise> GetIceStats(
       const std::string& aTransportId, DOMHighResTimeStamp aNow,
       std::unique_ptr<dom::RTCStatsReportInternal>&& aReport) override;
 
  private:
-  friend class MediaTransportHandlerChild;
+  friend class MediaTransportChild;
 
   // We do not own this; it will tell us when it is going away.
-  MediaTransportHandlerChild* mChild = nullptr;
+  MediaTransportChild* mChild = nullptr;
 
   // |mChild| can only be initted asynchronously, |mInitPromise| resolves
   // when that happens. The |Then| calls make it convenient to dispatch API
   // calls to main, which is a bonus.
   // Init promise is not exclusive; this lets us call |Then| on it for every
   // API call we get, instead of creating another promise each time.
   typedef MozPromise<bool, nsCString, false> InitPromise;
   RefPtr<InitPromise> mInitPromise;
rename from media/webrtc/signaling/src/peerconnection/MediaTransportHandlerParent.cpp
rename to media/webrtc/signaling/src/peerconnection/MediaTransportParent.cpp
--- a/media/webrtc/signaling/src/peerconnection/MediaTransportHandlerParent.cpp
+++ b/media/webrtc/signaling/src/peerconnection/MediaTransportParent.cpp
@@ -1,125 +1,140 @@
 /* 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 "MediaTransportHandlerParent.h"
+#include "mozilla/dom/MediaTransportParent.h"
 #include "signaling/src/peerconnection/MediaTransportHandler.h"
 
 #include "nss.h"                // For NSS_NoDB_Init
 #include "mozilla/PublicSSL.h"  // For psm::InitializeCipherSuite
+#include "sigslot.h"
 
 namespace mozilla {
 
-MediaTransportHandlerParent::MediaTransportHandlerParent()
-    : mImpl(MediaTransportHandler::Create(GetMainThreadSerialEventTarget())) {
-  // We cannot register PMediaTransportParent's Send* API to these signals,
-  // because this API returns must-use bools, and the params are in some cases
-  // slightly different.
-  mImpl->SignalCandidate.connect(this,
-                                 &MediaTransportHandlerParent::OnCandidate);
-  mImpl->SignalAlpnNegotiated.connect(
-      this, &MediaTransportHandlerParent::OnAlpnNegotiated);
-  mImpl->SignalGatheringStateChange.connect(
-      this, &MediaTransportHandlerParent::OnGatheringStateChange);
-  mImpl->SignalConnectionStateChange.connect(
-      this, &MediaTransportHandlerParent::OnConnectionStateChange);
-  mImpl->SignalPacketReceived.connect(
-      this, &MediaTransportHandlerParent::OnPacketReceived);
-  mImpl->SignalEncryptedSending.connect(
-      this, &MediaTransportHandlerParent::OnEncryptedSending);
-  mImpl->SignalStateChange.connect(this,
-                                   &MediaTransportHandlerParent::OnStateChange);
-  mImpl->SignalRtcpStateChange.connect(
-      this, &MediaTransportHandlerParent::OnRtcpStateChange);
-}
+// Deals with the MediaTransportHandler interface, so MediaTransportParent
+// doesn't have to..
+class MediaTransportParent::Impl : public sigslot::has_slots<> {
+ public:
+  explicit Impl(MediaTransportParent* aParent)
+      : mHandler(
+            MediaTransportHandler::Create(GetMainThreadSerialEventTarget())),
+        mParent(aParent) {
+    mHandler->SignalCandidate.connect(this,
+                                      &MediaTransportParent::Impl::OnCandidate);
+    mHandler->SignalAlpnNegotiated.connect(
+        this, &MediaTransportParent::Impl::OnAlpnNegotiated);
+    mHandler->SignalGatheringStateChange.connect(
+        this, &MediaTransportParent::Impl::OnGatheringStateChange);
+    mHandler->SignalConnectionStateChange.connect(
+        this, &MediaTransportParent::Impl::OnConnectionStateChange);
+    mHandler->SignalPacketReceived.connect(
+        this, &MediaTransportParent::Impl::OnPacketReceived);
+    mHandler->SignalEncryptedSending.connect(
+        this, &MediaTransportParent::Impl::OnEncryptedSending);
+    mHandler->SignalStateChange.connect(
+        this, &MediaTransportParent::Impl::OnStateChange);
+    mHandler->SignalRtcpStateChange.connect(
+        this, &MediaTransportParent::Impl::OnRtcpStateChange);
+  }
 
-MediaTransportHandlerParent::~MediaTransportHandlerParent() {
-  MOZ_RELEASE_ASSERT(!mImpl);
-}
+  virtual ~Impl() {
+    disconnect_all();
+    mHandler->Destroy();
+    mHandler = nullptr;
+  }
 
-void MediaTransportHandlerParent::OnCandidate(
-    const std::string& aTransportId, const CandidateInfo& aCandidateInfo) {
-  NS_ENSURE_TRUE_VOID(SendOnCandidate(aTransportId, aCandidateInfo));
-}
+  void OnCandidate(const std::string& aTransportId,
+                   const CandidateInfo& aCandidateInfo) {
+    NS_ENSURE_TRUE_VOID(mParent->SendOnCandidate(aTransportId, aCandidateInfo));
+  }
+
+  void OnAlpnNegotiated(const std::string& aAlpn) {
+    NS_ENSURE_TRUE_VOID(mParent->SendOnAlpnNegotiated(aAlpn));
+  }
 
-void MediaTransportHandlerParent::OnAlpnNegotiated(const std::string& aAlpn) {
-  NS_ENSURE_TRUE_VOID(SendOnAlpnNegotiated(aAlpn));
-}
+  void OnGatheringStateChange(dom::PCImplIceGatheringState aState) {
+    NS_ENSURE_TRUE_VOID(
+        mParent->SendOnGatheringStateChange(static_cast<int>(aState)));
+  }
 
-void MediaTransportHandlerParent::OnGatheringStateChange(
-    dom::PCImplIceGatheringState aState) {
-  NS_ENSURE_TRUE_VOID(SendOnGatheringStateChange(static_cast<int>(aState)));
-}
+  void OnConnectionStateChange(dom::PCImplIceConnectionState aState) {
+    NS_ENSURE_TRUE_VOID(
+        mParent->SendOnConnectionStateChange(static_cast<int>(aState)));
+  }
 
-void MediaTransportHandlerParent::OnConnectionStateChange(
-    dom::PCImplIceConnectionState aState) {
-  NS_ENSURE_TRUE_VOID(SendOnConnectionStateChange(static_cast<int>(aState)));
-}
+  void OnPacketReceived(const std::string& aTransportId, MediaPacket& aPacket) {
+    NS_ENSURE_TRUE_VOID(mParent->SendOnPacketReceived(aTransportId, aPacket));
+  }
+
+  void OnEncryptedSending(const std::string& aTransportId,
+                          MediaPacket& aPacket) {
+    NS_ENSURE_TRUE_VOID(mParent->SendOnEncryptedSending(aTransportId, aPacket));
+  }
 
-void MediaTransportHandlerParent::OnPacketReceived(
-    const std::string& aTransportId, MediaPacket& aPacket) {
-  NS_ENSURE_TRUE_VOID(SendOnPacketReceived(aTransportId, aPacket));
-}
+  void OnStateChange(const std::string& aTransportId,
+                     TransportLayer::State aState) {
+    NS_ENSURE_TRUE_VOID(mParent->SendOnStateChange(aTransportId, aState));
+  }
 
-void MediaTransportHandlerParent::OnEncryptedSending(
-    const std::string& aTransportId, MediaPacket& aPacket) {
-  NS_ENSURE_TRUE_VOID(SendOnEncryptedSending(aTransportId, aPacket));
-}
+  void OnRtcpStateChange(const std::string& aTransportId,
+                         TransportLayer::State aState) {
+    NS_ENSURE_TRUE_VOID(mParent->SendOnRtcpStateChange(aTransportId, aState));
+  }
 
-void MediaTransportHandlerParent::OnStateChange(const std::string& aTransportId,
-                                                TransportLayer::State aState) {
-  NS_ENSURE_TRUE_VOID(SendOnStateChange(aTransportId, aState));
-}
+  RefPtr<MediaTransportHandler> mHandler;
+
+ private:
+  MediaTransportParent* mParent;
+};
 
-void MediaTransportHandlerParent::OnRtcpStateChange(
-    const std::string& aTransportId, TransportLayer::State aState) {
-  NS_ENSURE_TRUE_VOID(SendOnRtcpStateChange(aTransportId, aState));
-}
+MediaTransportParent::MediaTransportParent() : mImpl(new Impl(this)) {}
 
-mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvGetIceLog(
+MediaTransportParent::~MediaTransportParent() {}
+
+mozilla::ipc::IPCResult MediaTransportParent::RecvGetIceLog(
     const nsCString& pattern, GetIceLogResolver&& aResolve) {
   MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
-  mImpl->GetIceLog(pattern)->Then(
+  mImpl->mHandler->GetIceLog(pattern)->Then(
       GetMainThreadSerialEventTarget(), __func__,
       // IPDL doesn't give us a reject function, so we cannot reject async, so
       // we are forced to resolve with an empty result. Laaaaaaame.
       [aResolve = std::move(aResolve)](
           MediaTransportHandler::IceLogPromise::ResolveOrRejectValue&&
               aResult) mutable {
         WebrtcGlobalLog logLines;
         if (aResult.IsResolve()) {
           logLines = std::move(aResult.ResolveValue());
         }
         aResolve(logLines);
       });
 
   return ipc::IPCResult::Ok();
 }
 
-mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvClearIceLog() {
+mozilla::ipc::IPCResult MediaTransportParent::RecvClearIceLog() {
   MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
-  mImpl->ClearIceLog();
+  mImpl->mHandler->ClearIceLog();
   return ipc::IPCResult::Ok();
 }
 
-mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvEnterPrivateMode() {
+mozilla::ipc::IPCResult MediaTransportParent::RecvEnterPrivateMode() {
   MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
-  mImpl->EnterPrivateMode();
+  mImpl->mHandler->EnterPrivateMode();
   return ipc::IPCResult::Ok();
 }
 
-mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvExitPrivateMode() {
+mozilla::ipc::IPCResult MediaTransportParent::RecvExitPrivateMode() {
   MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
-  mImpl->ExitPrivateMode();
+  mImpl->mHandler->ExitPrivateMode();
   return ipc::IPCResult::Ok();
 }
 
-mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvCreateIceCtx(
+mozilla::ipc::IPCResult MediaTransportParent::RecvCreateIceCtx(
     const string& name, nsTArray<RTCIceServer>&& iceServers,
     const RTCIceTransportPolicy& icePolicy) {
   MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
   static bool nssStarted = false;
   if (!nssStarted) {
     if (NSS_NoDB_Init(nullptr) != SECSuccess) {
       MOZ_CRASH();
       return ipc::IPCResult::Fail(WrapNotNull(this), __func__,
@@ -132,111 +147,110 @@ mozilla::ipc::IPCResult MediaTransportHa
                                   "InitializeCipherSuite failed");
     }
 
     mozilla::psm::DisableMD5();
   }
 
   nssStarted = true;
 
-  nsresult rv = mImpl->CreateIceCtx(name, iceServers, icePolicy);
+  nsresult rv = mImpl->mHandler->CreateIceCtx(name, iceServers, icePolicy);
   if (NS_FAILED(rv)) {
     return ipc::IPCResult::Fail(WrapNotNull(this), __func__,
                                 "MediaTransportHandler::Init failed");
   }
   return ipc::IPCResult::Ok();
 }
 
-mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvSetProxyServer(
+mozilla::ipc::IPCResult MediaTransportParent::RecvSetProxyServer(
     const PBrowserOrId& browserOrId, const nsCString& alpn) {
   MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
-  mImpl->SetProxyServer(NrSocketProxyConfig(browserOrId, alpn));
+  mImpl->mHandler->SetProxyServer(NrSocketProxyConfig(browserOrId, alpn));
   return ipc::IPCResult::Ok();
 }
 
-mozilla::ipc::IPCResult
-MediaTransportHandlerParent::RecvEnsureProvisionalTransport(
+mozilla::ipc::IPCResult MediaTransportParent::RecvEnsureProvisionalTransport(
     const string& transportId, const string& localUfrag, const string& localPwd,
     const int& componentCount) {
   MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
-  mImpl->EnsureProvisionalTransport(transportId, localUfrag, localPwd,
-                                    componentCount);
+  mImpl->mHandler->EnsureProvisionalTransport(transportId, localUfrag, localPwd,
+                                              componentCount);
   return ipc::IPCResult::Ok();
 }
 
-mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvStartIceGathering(
+mozilla::ipc::IPCResult MediaTransportParent::RecvStartIceGathering(
     const bool& defaultRouteOnly, const net::NrIceStunAddrArray& stunAddrs) {
   MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
-  mImpl->StartIceGathering(defaultRouteOnly, stunAddrs);
+  mImpl->mHandler->StartIceGathering(defaultRouteOnly, stunAddrs);
   return ipc::IPCResult::Ok();
 }
 
-mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvActivateTransport(
+mozilla::ipc::IPCResult MediaTransportParent::RecvActivateTransport(
     const string& transportId, const string& localUfrag, const string& localPwd,
     const int& componentCount, const string& remoteUfrag,
     const string& remotePwd, nsTArray<uint8_t>&& keyDer,
     nsTArray<uint8_t>&& certDer, const int& authType, const bool& dtlsClient,
     const DtlsDigestList& digests, const bool& privacyRequested) {
   MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
-  mImpl->ActivateTransport(transportId, localUfrag, localPwd, componentCount,
-                           remoteUfrag, remotePwd, keyDer, certDer,
-                           static_cast<SSLKEAType>(authType), dtlsClient,
-                           digests, privacyRequested);
+  mImpl->mHandler->ActivateTransport(
+      transportId, localUfrag, localPwd, componentCount, remoteUfrag, remotePwd,
+      keyDer, certDer, static_cast<SSLKEAType>(authType), dtlsClient, digests,
+      privacyRequested);
   return ipc::IPCResult::Ok();
 }
 
-mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvRemoveTransportsExcept(
+mozilla::ipc::IPCResult MediaTransportParent::RecvRemoveTransportsExcept(
     const StringVector& transportIds) {
   MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
   std::set<std::string> ids(transportIds.begin(), transportIds.end());
-  mImpl->RemoveTransportsExcept(ids);
+  mImpl->mHandler->RemoveTransportsExcept(ids);
   return ipc::IPCResult::Ok();
 }
 
-mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvStartIceChecks(
+mozilla::ipc::IPCResult MediaTransportParent::RecvStartIceChecks(
     const bool& isControlling, const bool& isOfferer,
     const StringVector& iceOptions) {
   MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
-  mImpl->StartIceChecks(isControlling, isOfferer, iceOptions);
+  mImpl->mHandler->StartIceChecks(isControlling, isOfferer, iceOptions);
   return ipc::IPCResult::Ok();
 }
 
-mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvSendPacket(
+mozilla::ipc::IPCResult MediaTransportParent::RecvSendPacket(
     const string& transportId, const MediaPacket& packet) {
   MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
   MediaPacket copy(packet);  // Laaaaaaame.
-  mImpl->SendPacket(transportId, std::move(copy));
+  mImpl->mHandler->SendPacket(transportId, std::move(copy));
   return ipc::IPCResult::Ok();
 }
 
-mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvAddIceCandidate(
+mozilla::ipc::IPCResult MediaTransportParent::RecvAddIceCandidate(
     const string& transportId, const string& candidate) {
   MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
-  mImpl->AddIceCandidate(transportId, candidate);
+  mImpl->mHandler->AddIceCandidate(transportId, candidate);
   return ipc::IPCResult::Ok();
 }
 
-mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvUpdateNetworkState(
+mozilla::ipc::IPCResult MediaTransportParent::RecvUpdateNetworkState(
     const bool& online) {
   MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
-  mImpl->UpdateNetworkState(online);
+  mImpl->mHandler->UpdateNetworkState(online);
   return ipc::IPCResult::Ok();
 }
 
-mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvGetIceStats(
+mozilla::ipc::IPCResult MediaTransportParent::RecvGetIceStats(
     const string& transportId, const double& now,
     const RTCStatsReportInternal& reportIn, GetIceStatsResolver&& aResolve) {
   MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
   // Copy, because we are handed a const reference (lame), and put in a
   // unique_ptr because RTCStatsReportInternal doesn't have move semantics
   // (also lame).
   std::unique_ptr<dom::RTCStatsReportInternal> report(
       new dom::RTCStatsReportInternal(reportIn));
 
-  mImpl->GetIceStats(transportId, now, std::move(report))
+  mImpl->mHandler->GetIceStats(transportId, now, std::move(report))
       ->Then(
           GetMainThreadSerialEventTarget(), __func__,
           // IPDL doesn't give us a reject function, so we cannot reject async,
           // so we are forced to resolve with an unmodified result. Laaaaaaame.
           [aResolve = std::move(aResolve),
            reportIn](MediaTransportHandler::StatsPromise::ResolveOrRejectValue&&
                          aResult) {
             if (aResult.IsResolve()) {
@@ -245,16 +259,13 @@ mozilla::ipc::IPCResult MediaTransportHa
             } else {
               aResolve(MovableRTCStatsReportInternal(reportIn));
             }
           });
 
   return ipc::IPCResult::Ok();
 }
 
-void MediaTransportHandlerParent::ActorDestroy(ActorDestroyReason aWhy) {
+void MediaTransportParent::ActorDestroy(ActorDestroyReason aWhy) {
   MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
-  disconnect_all();
-  mImpl->Destroy();
-  mImpl = nullptr;
 }
 
 }  // namespace mozilla
--- a/media/webrtc/signaling/src/peerconnection/moz.build
+++ b/media/webrtc/signaling/src/peerconnection/moz.build
@@ -20,17 +20,17 @@ LOCAL_INCLUDES += [
     '/media/webrtc/trunk',
     '/media/webrtc/trunk/webrtc',
     '/netwerk/srtp/src/include',
 ]
 
 UNIFIED_SOURCES += [
     'MediaTransportHandler.cpp',
     'MediaTransportHandlerIPC.cpp',
-    'MediaTransportHandlerParent.cpp',
+    'MediaTransportParent.cpp',
     'PacketDumper.cpp',
     'PeerConnectionCtx.cpp',
     'PeerConnectionImpl.cpp',
     'PeerConnectionMedia.cpp',
     'TransceiverImpl.cpp',
     'WebrtcGlobalInformation.cpp',
 ]
 
--- a/netwerk/ipc/SocketProcessBridgeChild.h
+++ b/netwerk/ipc/SocketProcessBridgeChild.h
@@ -29,18 +29,18 @@ class SocketProcessBridgeChild final : p
 
   mozilla::ipc::IPCResult RecvTest();
   void ActorDestroy(ActorDestroyReason aWhy) override;
   void DeferredDestroy();
   bool IsShuttingDown() const { return mShuttingDown; };
   bool Inited() const { return mInited; };
   ProcessId SocketProcessPid() const { return mSocketProcessPid; };
 
-  dom::PMediaTransportChild* AllocPMediaTransportChild() override;
-  bool DeallocPMediaTransportChild(dom::PMediaTransportChild* aActor) override;
+  dom::PMediaTransportChild* AllocPMediaTransportChild();
+  bool DeallocPMediaTransportChild(dom::PMediaTransportChild* aActor);
 
  private:
   DISALLOW_COPY_AND_ASSIGN(SocketProcessBridgeChild);
   static bool Create(Endpoint<PSocketProcessBridgeChild>&& aEndpoint);
   explicit SocketProcessBridgeChild(
       Endpoint<PSocketProcessBridgeChild>&& aEndpoint);
   virtual ~SocketProcessBridgeChild();
 
--- a/netwerk/ipc/SocketProcessBridgeParent.cpp
+++ b/netwerk/ipc/SocketProcessBridgeParent.cpp
@@ -3,19 +3,17 @@
  * 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 "SocketProcessBridgeParent.h"
 #include "SocketProcessLogging.h"
 
 #include "mozilla/ipc/BackgroundParent.h"
 #include "SocketProcessChild.h"
-#ifdef MOZ_WEBRTC
-#  include "signaling/src/peerconnection/MediaTransportHandlerParent.h"
-#endif
+#include "mozilla/dom/MediaTransportParent.h"
 
 namespace mozilla {
 namespace net {
 
 SocketProcessBridgeParent::SocketProcessBridgeParent(
     ProcessId aId, Endpoint<PSocketProcessBridgeParent>&& aEndpoint)
     : mId(aId) {
   LOG((
@@ -57,17 +55,17 @@ void SocketProcessBridgeParent::ActorDes
 
 void SocketProcessBridgeParent::DeferredDestroy() {
   SocketProcessChild::GetSingleton()->DestroySocketProcessBridgeParent(mId);
 }
 
 dom::PMediaTransportParent*
 SocketProcessBridgeParent::AllocPMediaTransportParent() {
 #ifdef MOZ_WEBRTC
-  return new MediaTransportHandlerParent;
+  return new MediaTransportParent;
 #endif
   return nullptr;
 }
 
 bool SocketProcessBridgeParent::DeallocPMediaTransportParent(
     dom::PMediaTransportParent* aActor) {
 #ifdef MOZ_WEBRTC
   delete aActor;
--- a/netwerk/ipc/SocketProcessBridgeParent.h
+++ b/netwerk/ipc/SocketProcessBridgeParent.h
@@ -24,19 +24,18 @@ class SocketProcessBridgeParent final : 
 
   mozilla::ipc::IPCResult RecvTest();
   mozilla::ipc::IPCResult RecvInitBackground(
       Endpoint<PBackgroundParent>&& aEndpoint);
 
   void ActorDestroy(ActorDestroyReason aWhy) override;
   void DeferredDestroy();
 
-  dom::PMediaTransportParent* AllocPMediaTransportParent() override;
-  bool DeallocPMediaTransportParent(
-      dom::PMediaTransportParent* aActor) override;
+  dom::PMediaTransportParent* AllocPMediaTransportParent();
+  bool DeallocPMediaTransportParent(dom::PMediaTransportParent* aActor);
 
  private:
   ~SocketProcessBridgeParent();
 
   ProcessId mId;
 };
 
 }  // namespace net