Bug 1596409 - P1.1: Make socket process support IPCStream r=dragana
authorKershaw Chang <kershaw@mozilla.com>
Tue, 03 Dec 2019 13:41:58 +0000
changeset 505063 e4c90781403c2b77ba42eb746e5ec84b61b7096e
parent 505062 06f49efafec511afa622bac9a51ae7e4645ca57b
child 505064 ff9237d7f536de0b011e2d25080e9f76be09ebec
push id36879
push userncsoregi@mozilla.com
push dateTue, 03 Dec 2019 21:53:45 +0000
treeherdermozilla-central@3c08edf74d03 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdragana
bugs1596409
milestone73.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 1596409 - P1.1: Make socket process support IPCStream r=dragana Differential Revision: https://phabricator.services.mozilla.com/D54289
dom/file/TemporaryFileBlobImpl.cpp
dom/file/ipc/IPCBlobInputStream.cpp
dom/indexedDB/FileSnapshot.cpp
dom/ipc/ContentChild.cpp
dom/ipc/ContentChild.h
dom/ipc/ContentParent.cpp
dom/ipc/ContentParent.h
ipc/glue/BackgroundChildImpl.cpp
ipc/glue/BackgroundChildImpl.h
ipc/glue/BackgroundParentImpl.cpp
ipc/glue/BackgroundParentImpl.h
ipc/glue/FileDescriptorSetChild.h
ipc/glue/FileDescriptorSetParent.h
ipc/glue/IPCStreamChild.cpp
ipc/glue/IPCStreamParent.cpp
ipc/glue/IPCStreamSource.h
ipc/glue/IPCStreamUtils.cpp
ipc/glue/IPCStreamUtils.h
ipc/glue/InputStreamUtils.cpp
ipc/glue/InputStreamUtils.h
ipc/glue/PChildToParentStream.ipdl
ipc/glue/PFileDescriptorSet.ipdl
ipc/glue/PParentToChildStream.ipdl
ipc/glue/nsIIPCSerializableInputStream.h
netwerk/base/PartiallySeekableInputStream.cpp
netwerk/base/nsBufferedStreams.cpp
netwerk/base/nsFileStreams.cpp
netwerk/base/nsMIMEInputStream.cpp
netwerk/ipc/PSocketProcess.ipdl
netwerk/ipc/SocketProcessChild.cpp
netwerk/ipc/SocketProcessChild.h
netwerk/ipc/SocketProcessParent.cpp
netwerk/ipc/SocketProcessParent.h
xpcom/io/InputStreamLengthWrapper.cpp
xpcom/io/NonBlockingAsyncInputStream.cpp
xpcom/io/SlicedInputStream.cpp
xpcom/io/nsMultiplexInputStream.cpp
xpcom/io/nsStorageStream.cpp
xpcom/io/nsStringStream.cpp
xpcom/tests/gtest/TestNonBlockingAsyncInputStream.cpp
--- a/dom/file/TemporaryFileBlobImpl.cpp
+++ b/dom/file/TemporaryFileBlobImpl.cpp
@@ -48,38 +48,24 @@ class TemporaryFileInputStream final : p
 
     stream.forget(aInputStream);
     return NS_OK;
   }
 
   void Serialize(InputStreamParams& aParams,
                  FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
                  uint32_t aMaxSize, uint32_t* aSizeUsed,
-                 ContentChild* aManager) override {
+                 ParentToChildStreamActorManager* aManager) override {
     MOZ_CRASH("This inputStream cannot be serialized.");
   }
 
   void Serialize(InputStreamParams& aParams,
                  FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
                  uint32_t aMaxSize, uint32_t* aSizeUsed,
-                 PBackgroundChild* aManager) override {
-    MOZ_CRASH("This inputStream cannot be serialized.");
-  }
-
-  void Serialize(InputStreamParams& aParams,
-                 FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
-                 uint32_t aMaxSize, uint32_t* aSizeUsed,
-                 ContentParent* aManager) override {
-    MOZ_CRASH("This inputStream cannot be serialized.");
-  }
-
-  void Serialize(InputStreamParams& aParams,
-                 FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
-                 uint32_t aMaxSize, uint32_t* aSizeUsed,
-                 PBackgroundParent* aManager) override {
+                 ChildToParentStreamActorManager* aManager) override {
     MOZ_CRASH("This inputStream cannot be serialized.");
   }
 
   bool Deserialize(const InputStreamParams& aParams,
                    const FileDescriptorArray& aFileDescriptors) override {
     MOZ_CRASH("This inputStream cannot be deserialized.");
     return false;
   }
--- a/dom/file/ipc/IPCBlobInputStream.cpp
+++ b/dom/file/ipc/IPCBlobInputStream.cpp
@@ -558,54 +558,32 @@ IPCBlobInputStream::OnInputStreamReady(n
   // be synchronous.
   MOZ_ASSERT(callback);
   InputStreamCallbackRunnable::Execute(callback, callbackEventTarget, this);
   return NS_OK;
 }
 
 // nsIIPCSerializableInputStream
 
-void IPCBlobInputStream::Serialize(mozilla::ipc::InputStreamParams& aParams,
-                                   FileDescriptorArray& aFileDescriptors,
-                                   bool aDelayedStart, uint32_t aMaxSize,
-                                   uint32_t* aSizeUsed,
-                                   ContentChild* aManager) {
+void IPCBlobInputStream::Serialize(
+    mozilla::ipc::InputStreamParams& aParams,
+    FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
+    uint32_t aMaxSize, uint32_t* aSizeUsed,
+    mozilla::ipc::ParentToChildStreamActorManager* aManager) {
   MOZ_ASSERT(aSizeUsed);
   *aSizeUsed = 0;
 
   SerializeInternal(aParams);
 }
 
-void IPCBlobInputStream::Serialize(mozilla::ipc::InputStreamParams& aParams,
-                                   FileDescriptorArray& aFileDescriptors,
-                                   bool aDelayedStart, uint32_t aMaxSize,
-                                   uint32_t* aSizeUsed,
-                                   mozilla::ipc::PBackgroundChild* aManager) {
-  MOZ_ASSERT(aSizeUsed);
-  *aSizeUsed = 0;
-
-  SerializeInternal(aParams);
-}
-
-void IPCBlobInputStream::Serialize(mozilla::ipc::InputStreamParams& aParams,
-                                   FileDescriptorArray& aFileDescriptors,
-                                   bool aDelayedStart, uint32_t aMaxSize,
-                                   uint32_t* aSizeUsed,
-                                   ContentParent* aManager) {
-  MOZ_ASSERT(aSizeUsed);
-  *aSizeUsed = 0;
-
-  SerializeInternal(aParams);
-}
-
-void IPCBlobInputStream::Serialize(mozilla::ipc::InputStreamParams& aParams,
-                                   FileDescriptorArray& aFileDescriptors,
-                                   bool aDelayedStart, uint32_t aMaxSize,
-                                   uint32_t* aSizeUsed,
-                                   mozilla::ipc::PBackgroundParent* aManager) {
+void IPCBlobInputStream::Serialize(
+    mozilla::ipc::InputStreamParams& aParams,
+    FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
+    uint32_t aMaxSize, uint32_t* aSizeUsed,
+    mozilla::ipc::ChildToParentStreamActorManager* aManager) {
   MOZ_ASSERT(aSizeUsed);
   *aSizeUsed = 0;
 
   SerializeInternal(aParams);
 }
 
 void IPCBlobInputStream::SerializeInternal(
     mozilla::ipc::InputStreamParams& aParams) {
--- a/dom/indexedDB/FileSnapshot.cpp
+++ b/dom/indexedDB/FileSnapshot.cpp
@@ -266,42 +266,27 @@ StreamWrapper::ReadSegments(nsWriteSegme
 NS_IMETHODIMP
 StreamWrapper::IsNonBlocking(bool* _retval) {
   return mInputStream->IsNonBlocking(_retval);
 }
 
 void StreamWrapper::Serialize(InputStreamParams& aParams,
                               FileDescriptorArray& aFileDescriptors,
                               bool aDelayedStart, uint32_t aMaxSize,
-                              uint32_t* aSizeUsed, ContentChild* aManager) {
-  SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
-                    aSizeUsed, aManager);
-}
-
-void StreamWrapper::Serialize(InputStreamParams& aParams,
-                              FileDescriptorArray& aFileDescriptors,
-                              bool aDelayedStart, uint32_t aMaxSize,
-                              uint32_t* aSizeUsed, PBackgroundChild* aManager) {
-  SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
-                    aSizeUsed, aManager);
-}
-
-void StreamWrapper::Serialize(InputStreamParams& aParams,
-                              FileDescriptorArray& aFileDescriptors,
-                              bool aDelayedStart, uint32_t aMaxSize,
-                              uint32_t* aSizeUsed, ContentParent* aManager) {
+                              uint32_t* aSizeUsed,
+                              ParentToChildStreamActorManager* aManager) {
   SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
                     aSizeUsed, aManager);
 }
 
 void StreamWrapper::Serialize(InputStreamParams& aParams,
                               FileDescriptorArray& aFileDescriptors,
                               bool aDelayedStart, uint32_t aMaxSize,
                               uint32_t* aSizeUsed,
-                              PBackgroundParent* aManager) {
+                              ChildToParentStreamActorManager* aManager) {
   SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
                     aSizeUsed, aManager);
 }
 
 template <typename M>
 void StreamWrapper::SerializeInternal(InputStreamParams& aParams,
                                       FileDescriptorArray& aFileDescriptors,
                                       bool aDelayedStart, uint32_t aMaxSize,
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -242,17 +242,16 @@
 #  include "mozilla/a11y/DocManager.h"
 #  include "mozilla/a11y/OuterDocAccessible.h"
 #endif
 
 #include "mozilla/dom/File.h"
 #include "mozilla/dom/MediaController.h"
 #include "mozilla/dom/PPresentationChild.h"
 #include "mozilla/dom/PresentationIPCService.h"
-#include "mozilla/ipc/InputStreamUtils.h"
 #include "mozilla/ipc/IPCStreamAlloc.h"
 #include "mozilla/ipc/IPCStreamDestination.h"
 #include "mozilla/ipc/IPCStreamSource.h"
 
 #ifdef MOZ_WEBSPEECH
 #  include "mozilla/dom/PSpeechSynthesisChild.h"
 #endif
 
@@ -1944,16 +1943,18 @@ mozilla::ipc::IPCResult ContentChild::Re
 }
 
 void ContentChild::GetAvailableDictionaries(nsTArray<nsString>& aDictionaries) {
   aDictionaries = mAvailableDictionaries;
 }
 
 PFileDescriptorSetChild* ContentChild::SendPFileDescriptorSetConstructor(
     const FileDescriptor& aFD) {
+  MOZ_ASSERT(NS_IsMainThread());
+
   if (IsShuttingDown()) {
     return nullptr;
   }
 
   return PContentChild::SendPFileDescriptorSetConstructor(aFD);
 }
 
 PFileDescriptorSetChild* ContentChild::AllocPFileDescriptorSetChild(
@@ -2190,16 +2191,18 @@ PPrintingChild* ContentChild::AllocPPrin
 }
 
 bool ContentChild::DeallocPPrintingChild(PPrintingChild* printing) {
   return true;
 }
 
 PChildToParentStreamChild* ContentChild::SendPChildToParentStreamConstructor(
     PChildToParentStreamChild* aActor) {
+  MOZ_ASSERT(NS_IsMainThread());
+
   if (IsShuttingDown()) {
     return nullptr;
   }
 
   return PContentChild::SendPChildToParentStreamConstructor(aActor);
 }
 
 PChildToParentStreamChild* ContentChild::AllocPChildToParentStreamChild() {
--- a/dom/ipc/ContentChild.h
+++ b/dom/ipc/ContentChild.h
@@ -11,16 +11,17 @@
 #include "mozilla/Atomics.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/BrowserBridgeChild.h"
 #include "mozilla/dom/PBrowserOrId.h"
 #include "mozilla/dom/PContentChild.h"
 #include "mozilla/dom/RemoteBrowser.h"
 #include "mozilla/dom/CPOWManagerGetter.h"
 #include "mozilla/StaticPtr.h"
+#include "mozilla/ipc/InputStreamUtils.h"
 #include "mozilla/ipc/Shmem.h"
 #include "mozilla/jsipc/CrossProcessObjectWrappers.h"
 #include "nsAutoPtr.h"
 #include "nsHashKeys.h"
 #include "nsIObserver.h"
 #include "nsTHashtable.h"
 #include "nsStringFwd.h"
 #include "nsTArrayForwardDeclare.h"
@@ -71,20 +72,22 @@ class SharedMap;
 class AlertObserver;
 class ConsoleListener;
 class ClonedMessageData;
 class BrowserChild;
 class GetFilesHelperChild;
 class TabContext;
 enum class MediaControlActions : uint32_t;
 
-class ContentChild final : public PContentChild,
-                           public nsIWindowProvider,
-                           public CPOWManagerGetter,
-                           public mozilla::ipc::IShmemAllocator {
+class ContentChild final
+    : public PContentChild,
+      public nsIWindowProvider,
+      public CPOWManagerGetter,
+      public mozilla::ipc::IShmemAllocator,
+      public mozilla::ipc::ChildToParentStreamActorManager {
   typedef mozilla::dom::ClonedMessageData ClonedMessageData;
   typedef mozilla::ipc::FileDescriptor FileDescriptor;
   typedef mozilla::ipc::PFileDescriptorSetChild PFileDescriptorSetChild;
   typedef mozilla::ipc::URIParams URIParams;
 
   friend class PContentChild;
 
  public:
@@ -250,19 +253,16 @@ class ContentChild final : public PConte
   PNeckoChild* AllocPNeckoChild();
 
   bool DeallocPNeckoChild(PNeckoChild*);
 
   PPrintingChild* AllocPPrintingChild();
 
   bool DeallocPPrintingChild(PPrintingChild*);
 
-  PChildToParentStreamChild* SendPChildToParentStreamConstructor(
-      PChildToParentStreamChild*);
-
   PChildToParentStreamChild* AllocPChildToParentStreamChild();
   bool DeallocPChildToParentStreamChild(PChildToParentStreamChild*);
 
   PParentToChildStreamChild* AllocPParentToChildStreamChild();
   bool DeallocPParentToChildStreamChild(PParentToChildStreamChild*);
 
   PPSMContentDownloaderChild* AllocPPSMContentDownloaderChild(
       const uint32_t& aCertType);
@@ -497,19 +497,16 @@ class ContentChild final : public PConte
 #if defined(XP_WIN) && defined(ACCESSIBILITY)
   uint32_t GetChromeMainThreadId() const { return mMainChromeTid; }
 
   uint32_t GetMsaaID() const { return mMsaaID; }
 #endif
 
   bool IsForBrowser() const { return mIsForBrowser; }
 
-  PFileDescriptorSetChild* SendPFileDescriptorSetConstructor(
-      const FileDescriptor&);
-
   PFileDescriptorSetChild* AllocPFileDescriptorSetChild(const FileDescriptor&);
 
   bool DeallocPFileDescriptorSetChild(PFileDescriptorSetChild*);
 
   mozilla::ipc::IPCResult RecvConstructBrowser(
       ManagedEndpoint<PBrowserChild>&& aBrowserEp,
       ManagedEndpoint<PWindowGlobalChild>&& aWindowEp, const TabId& aTabId,
       const TabId& aSameTabGroupAs, const IPCTabContext& aContext,
@@ -701,16 +698,21 @@ class ContentChild final : public PConte
   uint32_t GetPendingInputEvents() { return mPendingInputEvents; }
 #endif
 
 #if defined(MOZ_SANDBOX) && defined(MOZ_DEBUG) && defined(ENABLE_TESTS)
   mozilla::ipc::IPCResult RecvInitSandboxTesting(
       Endpoint<PSandboxTestingChild>&& aEndpoint);
 #endif
 
+  PChildToParentStreamChild* SendPChildToParentStreamConstructor(
+      PChildToParentStreamChild* aActor) override;
+  PFileDescriptorSetChild* SendPFileDescriptorSetConstructor(
+      const FileDescriptor& aFD) override;
+
  private:
   static void ForceKillTimerCallback(nsITimer* aTimer, void* aClosure);
   void StartForceKillTimer();
 
   void ShutdownInternal();
 
   mozilla::ipc::IPCResult GetResultForRenderingInitFailure(
       base::ProcessId aOtherPid);
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -6107,16 +6107,29 @@ mozilla::ipc::IPCResult ContentParent::R
   aContext->Group()->EachOtherParent(this, [&](ContentParent* aParent) {
     Unused << aParent->SendCommitBrowsingContextTransaction(
         aContext, aTransaction, aParent->GetBrowsingContextFieldEpoch());
   });
 
   aTransaction.Apply(aContext);
   return IPC_OK();
 }
+
+PParentToChildStreamParent* ContentParent::SendPParentToChildStreamConstructor(
+    PParentToChildStreamParent* aActor) {
+  MOZ_ASSERT(NS_IsMainThread());
+  return PContentParent::SendPParentToChildStreamConstructor(aActor);
+}
+
+PFileDescriptorSetParent* ContentParent::SendPFileDescriptorSetConstructor(
+    const FileDescriptor& aFD) {
+  MOZ_ASSERT(NS_IsMainThread());
+  return PContentParent::SendPFileDescriptorSetConstructor(aFD);
+}
+
 }  // namespace dom
 }  // namespace mozilla
 
 NS_IMPL_ISUPPORTS(ParentIdleListener, nsIObserver)
 
 NS_IMETHODIMP
 ParentIdleListener::Observe(nsISupports*, const char* aTopic,
                             const char16_t* aData) {
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -10,16 +10,17 @@
 #include "mozilla/dom/PContentParent.h"
 #include "mozilla/dom/CPOWManagerGetter.h"
 #include "mozilla/dom/ipc/IdType.h"
 #include "mozilla/dom/RemoteBrowser.h"
 #include "mozilla/gfx/gfxVarReceiver.h"
 #include "mozilla/gfx/GPUProcessListener.h"
 #include "mozilla/ipc/BackgroundUtils.h"
 #include "mozilla/ipc/GeckoChildProcessHost.h"
+#include "mozilla/ipc/InputStreamUtils.h"
 #include "mozilla/ipc/PParentToChildStreamParent.h"
 #include "mozilla/ipc/PChildToParentStreamParent.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/DataMutex.h"
 #include "mozilla/FileUtils.h"
 #include "mozilla/HalTypes.h"
 #include "mozilla/LinkedList.h"
 #include "mozilla/MemoryReportingProcess.h"
@@ -122,28 +123,30 @@ struct CancelContentJSOptions;
 
 #define NS_CONTENTPARENT_IID                         \
   {                                                  \
     0xeeec9ebf, 0x8ecf, 0x4e38, {                    \
       0x81, 0xda, 0xb7, 0x34, 0x13, 0x7e, 0xac, 0xf3 \
     }                                                \
   }
 
-class ContentParent final : public PContentParent,
-                            public nsIObserver,
-                            public nsIDOMGeoPositionCallback,
-                            public nsIDOMGeoPositionErrorCallback,
-                            public nsIInterfaceRequestor,
-                            public gfx::gfxVarReceiver,
-                            public mozilla::LinkedListElement<ContentParent>,
-                            public gfx::GPUProcessListener,
-                            public mozilla::MemoryReportingProcess,
-                            public mozilla::dom::ipc::MessageManagerCallback,
-                            public CPOWManagerGetter,
-                            public mozilla::ipc::IShmemAllocator {
+class ContentParent final
+    : public PContentParent,
+      public nsIObserver,
+      public nsIDOMGeoPositionCallback,
+      public nsIDOMGeoPositionErrorCallback,
+      public nsIInterfaceRequestor,
+      public gfx::gfxVarReceiver,
+      public mozilla::LinkedListElement<ContentParent>,
+      public gfx::GPUProcessListener,
+      public mozilla::MemoryReportingProcess,
+      public mozilla::dom::ipc::MessageManagerCallback,
+      public CPOWManagerGetter,
+      public mozilla::ipc::IShmemAllocator,
+      public mozilla::ipc::ParentToChildStreamActorManager {
   typedef mozilla::ipc::GeckoChildProcessHost GeckoChildProcessHost;
   typedef mozilla::ipc::PFileDescriptorSetParent PFileDescriptorSetParent;
   typedef mozilla::ipc::TestShellParent TestShellParent;
   typedef mozilla::ipc::URIParams URIParams;
   typedef mozilla::ipc::PrincipalInfo PrincipalInfo;
   typedef mozilla::dom::ClonedMessageData ClonedMessageData;
   typedef mozilla::dom::BrowsingContextGroup BrowsingContextGroup;
 
@@ -645,16 +648,21 @@ class ContentParent final : public PCont
   mozilla::ipc::IPCResult RecvWindowFocus(BrowsingContext* aContext);
   mozilla::ipc::IPCResult RecvWindowBlur(BrowsingContext* aContext);
   mozilla::ipc::IPCResult RecvWindowPostMessage(
       BrowsingContext* aContext, const ClonedMessageData& aMessage,
       const PostMessageData& aData);
 
   FORWARD_SHMEM_ALLOCATOR_TO(PContentParent)
 
+  PParentToChildStreamParent* SendPParentToChildStreamConstructor(
+      PParentToChildStreamParent* aActor) override;
+  PFileDescriptorSetParent* SendPFileDescriptorSetConstructor(
+      const FileDescriptor& aFD) override;
+
  protected:
   bool CheckBrowsingContextOwnership(BrowsingContext* aBC,
                                      const char* aOperation) const;
 
   void OnChannelConnected(int32_t pid) override;
 
   void ActorDestroy(ActorDestroyReason why) override;
   void ActorDealloc() override;
--- a/ipc/glue/BackgroundChildImpl.cpp
+++ b/ipc/glue/BackgroundChildImpl.cpp
@@ -753,16 +753,27 @@ dom::PMediaTransportChild* BackgroundChi
 }
 
 bool BackgroundChildImpl::DeallocPMediaTransportChild(
     dom::PMediaTransportChild* aActor) {
   delete aActor;
   return true;
 }
 
+PChildToParentStreamChild*
+BackgroundChildImpl::SendPChildToParentStreamConstructor(
+    PChildToParentStreamChild* aActor) {
+  return PBackgroundChild::SendPChildToParentStreamConstructor(aActor);
+}
+
+PFileDescriptorSetChild* BackgroundChildImpl::SendPFileDescriptorSetConstructor(
+    const FileDescriptor& aFD) {
+  return PBackgroundChild::SendPFileDescriptorSetConstructor(aFD);
+}
+
 }  // namespace ipc
 }  // namespace mozilla
 
 mozilla::ipc::IPCResult TestChild::Recv__delete__(const nsCString& aTestArg) {
   MOZ_RELEASE_ASSERT(aTestArg == mTestArg,
                      "BackgroundTest message was corrupted!");
 
   return IPC_OK();
--- a/ipc/glue/BackgroundChildImpl.h
+++ b/ipc/glue/BackgroundChildImpl.h
@@ -3,16 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_ipc_backgroundchildimpl_h__
 #define mozilla_ipc_backgroundchildimpl_h__
 
 #include "mozilla/Attributes.h"
+#include "mozilla/ipc/InputStreamUtils.h"
 #include "mozilla/ipc/PBackgroundChild.h"
 #include "nsRefPtrHashtable.h"
 #include "nsAutoPtr.h"
 
 namespace mozilla {
 namespace dom {
 
 class IDBFileHandle;
@@ -23,27 +24,33 @@ class ThreadLocal;
 
 }  // namespace indexedDB
 }  // namespace dom
 
 namespace ipc {
 
 // Instances of this class should never be created directly. This class is meant
 // to be inherited in BackgroundImpl.
-class BackgroundChildImpl : public PBackgroundChild {
+class BackgroundChildImpl : public PBackgroundChild,
+                            public ChildToParentStreamActorManager {
  public:
   class ThreadLocal;
 
   // Get the ThreadLocal for the current thread if
   // BackgroundChild::GetOrCreateForCurrentThread() has been called and true was
   // returned (e.g. a valid PBackgroundChild actor has been created or is in the
   // process of being created). Otherwise this function returns null.
   // This functions is implemented in BackgroundImpl.cpp.
   static ThreadLocal* GetThreadLocalForCurrentThread();
 
+  PChildToParentStreamChild* SendPChildToParentStreamConstructor(
+      PChildToParentStreamChild* aActor) override;
+  PFileDescriptorSetChild* SendPFileDescriptorSetConstructor(
+      const FileDescriptor& aFD) override;
+
  protected:
   BackgroundChildImpl();
   virtual ~BackgroundChildImpl();
 
   virtual void ProcessingError(Result aCode, const char* aReason) override;
 
   virtual void ActorDestroy(ActorDestroyReason aWhy) override;
 
--- a/ipc/glue/BackgroundParentImpl.cpp
+++ b/ipc/glue/BackgroundParentImpl.cpp
@@ -1305,15 +1305,27 @@ dom::PMediaTransportParent* BackgroundPa
 bool BackgroundParentImpl::DeallocPMediaTransportParent(
     dom::PMediaTransportParent* aActor) {
 #ifdef MOZ_WEBRTC
   delete aActor;
 #endif
   return true;
 }
 
+PParentToChildStreamParent*
+BackgroundParentImpl::SendPParentToChildStreamConstructor(
+    PParentToChildStreamParent* aActor) {
+  return PBackgroundParent::SendPParentToChildStreamConstructor(aActor);
+}
+
+PFileDescriptorSetParent*
+BackgroundParentImpl::SendPFileDescriptorSetConstructor(
+    const FileDescriptor& aFD) {
+  return PBackgroundParent::SendPFileDescriptorSetConstructor(aFD);
+}
+
 }  // namespace ipc
 }  // namespace mozilla
 
 void TestParent::ActorDestroy(ActorDestroyReason aWhy) {
   mozilla::ipc::AssertIsInMainOrSocketProcess();
   AssertIsOnBackgroundThread();
 }
--- a/ipc/glue/BackgroundParentImpl.h
+++ b/ipc/glue/BackgroundParentImpl.h
@@ -3,29 +3,37 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_ipc_backgroundparentimpl_h__
 #define mozilla_ipc_backgroundparentimpl_h__
 
 #include "mozilla/Attributes.h"
+#include "mozilla/ipc/InputStreamUtils.h"
 #include "mozilla/ipc/PBackgroundParent.h"
 
 namespace mozilla {
 
 namespace layout {
 class VsyncParent;
 }  // namespace layout
 
 namespace ipc {
 
 // Instances of this class should never be created directly. This class is meant
 // to be inherited in BackgroundImpl.
-class BackgroundParentImpl : public PBackgroundParent {
+class BackgroundParentImpl : public PBackgroundParent,
+                             public ParentToChildStreamActorManager {
+ public:
+  PParentToChildStreamParent* SendPParentToChildStreamConstructor(
+      PParentToChildStreamParent* aActor) override;
+  PFileDescriptorSetParent* SendPFileDescriptorSetConstructor(
+      const FileDescriptor& aFD) override;
+
  protected:
   BackgroundParentImpl();
   virtual ~BackgroundParentImpl();
 
   virtual void ActorDestroy(ActorDestroyReason aWhy) override;
 
   virtual PBackgroundTestParent* AllocPBackgroundTestParent(
       const nsCString& aTestArg) override;
--- a/ipc/glue/FileDescriptorSetChild.h
+++ b/ipc/glue/FileDescriptorSetChild.h
@@ -15,24 +15,31 @@
 namespace mozilla {
 
 namespace dom {
 
 class ContentChild;
 
 }  // namespace dom
 
+namespace net {
+
+class SocketProcessChild;
+
+}  // namespace net
+
 namespace ipc {
 
 class BackgroundChildImpl;
 class FileDescriptor;
 
 class FileDescriptorSetChild final : public PFileDescriptorSetChild {
   friend class BackgroundChildImpl;
   friend class mozilla::dom::ContentChild;
+  friend class mozilla::net::SocketProcessChild;
   friend class PFileDescriptorSetChild;
 
   nsTArray<FileDescriptor> mFileDescriptors;
 
  public:
   void ForgetFileDescriptors(nsTArray<FileDescriptor>& aFileDescriptors);
 
  private:
--- a/ipc/glue/FileDescriptorSetParent.h
+++ b/ipc/glue/FileDescriptorSetParent.h
@@ -15,24 +15,31 @@
 namespace mozilla {
 
 namespace dom {
 
 class ContentParent;
 
 }  // namespace dom
 
+namespace net {
+
+class SocketProcessParent;
+
+}  // namespace net
+
 namespace ipc {
 
 class BackgroundParentImpl;
 class FileDescriptor;
 
 class FileDescriptorSetParent final : public PFileDescriptorSetParent {
   friend class BackgroundParentImpl;
   friend class mozilla::dom::ContentParent;
+  friend class mozilla::net::SocketProcessParent;
   friend class PFileDescriptorSetParent;
 
   nsTArray<FileDescriptor> mFileDescriptors;
 
  public:
   void ForgetFileDescriptors(nsTArray<FileDescriptor>& aFileDescriptors);
 
  private:
--- a/ipc/glue/IPCStreamChild.cpp
+++ b/ipc/glue/IPCStreamChild.cpp
@@ -3,18 +3,16 @@
 /* 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 "IPCStreamDestination.h"
 #include "IPCStreamSource.h"
 
 #include "mozilla/Unused.h"
-#include "mozilla/dom/ContentChild.h"
-#include "mozilla/ipc/PBackgroundChild.h"
 #include "mozilla/ipc/PChildToParentStreamChild.h"
 #include "mozilla/ipc/PParentToChildStreamChild.h"
 
 namespace mozilla {
 namespace ipc {
 
 // Child to Parent implementation
 // ----------------------------------------------------------------------------
@@ -63,39 +61,18 @@ class IPCStreamSourceChild final : publi
   explicit IPCStreamSourceChild(nsIAsyncInputStream* aInputStream)
       : IPCStreamSource(aInputStream) {}
 };
 
 }  // anonymous namespace
 
 /* static */
 PChildToParentStreamChild* IPCStreamSource::Create(
-    nsIAsyncInputStream* aInputStream, dom::ContentChild* aManager) {
-  MOZ_ASSERT(aInputStream);
-  MOZ_ASSERT(aManager);
-
-  // PContent can only be used on the main thread
-  MOZ_ASSERT(NS_IsMainThread());
-
-  IPCStreamSourceChild* source = IPCStreamSourceChild::Create(aInputStream);
-  if (!source) {
-    return nullptr;
-  }
-
-  if (!aManager->SendPChildToParentStreamConstructor(source)) {
-    return nullptr;
-  }
-
-  source->ActorConstructed();
-  return source;
-}
-
-/* static */
-PChildToParentStreamChild* IPCStreamSource::Create(
-    nsIAsyncInputStream* aInputStream, PBackgroundChild* aManager) {
+    nsIAsyncInputStream* aInputStream,
+    ChildToParentStreamActorManager* aManager) {
   MOZ_ASSERT(aInputStream);
   MOZ_ASSERT(aManager);
 
   IPCStreamSourceChild* source = IPCStreamSourceChild::Create(aInputStream);
   if (!source) {
     return nullptr;
   }
 
--- a/ipc/glue/IPCStreamParent.cpp
+++ b/ipc/glue/IPCStreamParent.cpp
@@ -1,17 +1,15 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=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 "IPCStreamDestination.h"
-#include "mozilla/dom/ContentParent.h"
-#include "mozilla/ipc/PBackgroundParent.h"
 #include "mozilla/ipc/PChildToParentStreamParent.h"
 #include "mozilla/ipc/PParentToChildStreamParent.h"
 #include "mozilla/Unused.h"
 
 namespace mozilla {
 namespace ipc {
 
 // Child to Parent implementation
@@ -61,40 +59,18 @@ class IPCStreamSourceParent final : publ
   explicit IPCStreamSourceParent(nsIAsyncInputStream* aInputStream)
       : IPCStreamSource(aInputStream) {}
 };
 
 }  // anonymous namespace
 
 /* static */
 PParentToChildStreamParent* IPCStreamSource::Create(
-    nsIAsyncInputStream* aInputStream, dom::ContentParent* aManager) {
-  MOZ_ASSERT(aInputStream);
-  MOZ_ASSERT(aManager);
-
-  // PContent can only be used on the main thread
-  MOZ_ASSERT(NS_IsMainThread());
-
-  IPCStreamSourceParent* source = IPCStreamSourceParent::Create(aInputStream);
-  if (!source) {
-    return nullptr;
-  }
-
-  if (!aManager->SendPParentToChildStreamConstructor(source)) {
-    // no delete here, the manager will delete the actor for us.
-    return nullptr;
-  }
-
-  source->ActorConstructed();
-  return source;
-}
-
-/* static */
-PParentToChildStreamParent* IPCStreamSource::Create(
-    nsIAsyncInputStream* aInputStream, PBackgroundParent* aManager) {
+    nsIAsyncInputStream* aInputStream,
+    ParentToChildStreamActorManager* aManager) {
   MOZ_ASSERT(aInputStream);
   MOZ_ASSERT(aManager);
 
   IPCStreamSourceParent* source = IPCStreamSourceParent::Create(aInputStream);
   if (!source) {
     return nullptr;
   }
 
--- a/ipc/glue/IPCStreamSource.h
+++ b/ipc/glue/IPCStreamSource.h
@@ -9,29 +9,24 @@
 
 #include "mozilla/AlreadyAddRefed.h"
 #include "mozilla/dom/WorkerRef.h"
 
 class nsIAsyncInputStream;
 
 namespace mozilla {
 
-namespace dom {
-class ContentChild;
-class ContentParent;
-}  // namespace dom
-
 namespace wr {
 struct ByteBuffer;
 }  // namespace wr
 
 namespace ipc {
 
-class PBackgroundChild;
-class PBackgroundParent;
+class ParentToChildStreamActorManager;
+class ChildToParentStreamActorManager;
 class PChildToParentStreamChild;
 class PParentToChildStreamParent;
 
 // The IPCStream IPC actor is designed to push an nsIInputStream from child to
 // parent or parent to child incrementally.  This is mainly needed for streams
 // such as nsPipe that may not yet have all their data available when the
 // stream must be sent across an IPC boundary.  While many streams are handled
 // by SerializeInputStream(), these streams cannot be serialized and must be
@@ -52,39 +47,27 @@ class PParentToChildStreamParent;
 //  3) The IPCStreamSource actor can only be used on threads that can be
 //     guaranteed to stay alive as long as the actor is alive.  Right now
 //     this limits IPCStream to the main thread and Worker threads.
 //
 // In general you should probably use the AutoIPCStreamSource RAII class
 // defined in InputStreamUtils.h instead of using IPCStreamSource directly.
 class IPCStreamSource {
  public:
-  // Create a IPCStreamSource using a PContent IPC manager on the
-  // main thread.  This can return nullptr if the provided stream is
-  // blocking.
-  static PChildToParentStreamChild* Create(nsIAsyncInputStream* aInputStream,
-                                           dom::ContentChild* aManager);
-
-  // Create a IPCStreamSource using a PBackground IPC manager on the
-  // main thread or a Worker thread.  This can return nullptr if the provided
-  // stream is blocking or if the Worker thread is already shutting down.
-  static PChildToParentStreamChild* Create(nsIAsyncInputStream* aInputStream,
-                                           PBackgroundChild* aManager);
+  // Create a IPCStreamSource using a ChildToParentStreamActorManager manager.
+  // This can return nullptr if the provided stream is blocking.
+  static PChildToParentStreamChild* Create(
+      nsIAsyncInputStream* aInputStream,
+      ChildToParentStreamActorManager* aManager);
 
-  // Create a IPCStreamSource using a PContent IPC manager on the
-  // main thread.  This can return nullptr if the provided stream is
-  // blocking.
-  static PParentToChildStreamParent* Create(nsIAsyncInputStream* aInputStream,
-                                            dom::ContentParent* aManager);
-
-  // Create a IPCStreamSource using a PBackground IPC manager on the
-  // main thread or a Worker thread.  This can return nullptr if the provided
-  // stream is blocking or if the Worker thread is already shutting down.
-  static PParentToChildStreamParent* Create(nsIAsyncInputStream* aInputStream,
-                                            PBackgroundParent* aManager);
+  // Create a IPCStreamSource using a ParentToChildStreamActorManager manager.
+  // This can return nullptr if the provided stream is blocking.
+  static PParentToChildStreamParent* Create(
+      nsIAsyncInputStream* aInputStream,
+      ParentToChildStreamActorManager* aManager);
 
   static IPCStreamSource* Cast(PChildToParentStreamChild* aActor);
 
   static IPCStreamSource* Cast(PParentToChildStreamParent* aActor);
 
   // Start reading data from the nsIAsyncInputStream used to create the actor.
   // This must be called after the actor is passed to the parent.  If you
   // use AutoIPCStream this is handled automatically.
--- a/ipc/glue/IPCStreamUtils.cpp
+++ b/ipc/glue/IPCStreamUtils.cpp
@@ -10,20 +10,22 @@
 
 #include "mozilla/Assertions.h"
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/dom/File.h"
 #include "mozilla/ipc/FileDescriptorSetChild.h"
 #include "mozilla/ipc/FileDescriptorSetParent.h"
 #include "mozilla/ipc/InputStreamUtils.h"
-#include "mozilla/ipc/PBackgroundChild.h"
-#include "mozilla/ipc/PBackgroundParent.h"
+#include "mozilla/net/SocketProcessChild.h"
+#include "mozilla/net/SocketProcessParent.h"
 #include "mozilla/Unused.h"
 #include "nsNetCID.h"
+#include "BackgroundParentImpl.h"
+#include "BackgroundChildImpl.h"
 
 using namespace mozilla::dom;
 
 namespace mozilla {
 namespace ipc {
 
 namespace {
 
@@ -350,16 +352,38 @@ bool AutoIPCStream::Serialize(nsIInputSt
   MOZ_ASSERT(!mTaken);
   MOZ_ASSERT(!IsSet());
 
   // If NormalizeOptionalValue returns false, we don't have to proceed.
   if (!NormalizeOptionalValue(aStream, mValue, mOptionalValue)) {
     return true;
   }
 
+  BackgroundChildImpl* impl = static_cast<BackgroundChildImpl*>(aManager);
+  if (!SerializeInputStreamChild(aStream, impl, mValue, mOptionalValue,
+                                 mDelayedStart)) {
+    MOZ_CRASH("IPCStream creation failed!");
+  }
+
+  return true;
+}
+
+bool AutoIPCStream::Serialize(nsIInputStream* aStream,
+                              net::SocketProcessChild* aManager) {
+  MOZ_ASSERT(aStream || !mValue);
+  MOZ_ASSERT(aManager);
+  MOZ_ASSERT(mValue || mOptionalValue);
+  MOZ_ASSERT(!mTaken);
+  MOZ_ASSERT(!IsSet());
+
+  // If NormalizeOptionalValue returns false, we don't have to proceed.
+  if (!NormalizeOptionalValue(aStream, mValue, mOptionalValue)) {
+    return true;
+  }
+
   if (!SerializeInputStreamChild(aStream, aManager, mValue, mOptionalValue,
                                  mDelayedStart)) {
     MOZ_CRASH("IPCStream creation failed!");
   }
 
   return true;
 }
 
@@ -392,16 +416,38 @@ bool AutoIPCStream::Serialize(nsIInputSt
   MOZ_ASSERT(!mTaken);
   MOZ_ASSERT(!IsSet());
 
   // If NormalizeOptionalValue returns false, we don't have to proceed.
   if (!NormalizeOptionalValue(aStream, mValue, mOptionalValue)) {
     return true;
   }
 
+  BackgroundParentImpl* impl = static_cast<BackgroundParentImpl*>(aManager);
+  if (!SerializeInputStreamParent(aStream, impl, mValue, mOptionalValue,
+                                  mDelayedStart)) {
+    return false;
+  }
+
+  return true;
+}
+
+bool AutoIPCStream::Serialize(nsIInputStream* aStream,
+                              net::SocketProcessParent* aManager) {
+  MOZ_ASSERT(aStream || !mValue);
+  MOZ_ASSERT(aManager);
+  MOZ_ASSERT(mValue || mOptionalValue);
+  MOZ_ASSERT(!mTaken);
+  MOZ_ASSERT(!IsSet());
+
+  // If NormalizeOptionalValue returns false, we don't have to proceed.
+  if (!NormalizeOptionalValue(aStream, mValue, mOptionalValue)) {
+    return true;
+  }
+
   if (!SerializeInputStreamParent(aStream, aManager, mValue, mOptionalValue,
                                   mDelayedStart)) {
     return false;
   }
 
   return true;
 }
 
--- a/ipc/glue/IPCStreamUtils.h
+++ b/ipc/glue/IPCStreamUtils.h
@@ -13,16 +13,21 @@
 
 namespace mozilla {
 
 namespace dom {
 class ContentChild;
 class ContentParent;
 }  // namespace dom
 
+namespace net {
+class SocketProcessParent;
+class SocketProcessChild;
+}  // namespace net
+
 namespace ipc {
 
 class PBackgroundChild;
 class PBackgroundParent;
 
 // Deserialize an IPCStream received from an actor call.  These methods
 // work in both the child and parent.
 already_AddRefed<nsIInputStream> DeserializeIPCStream(const IPCStream& aValue);
@@ -148,24 +153,33 @@ class AutoIPCStream {
   // used on the main thread.
   bool Serialize(nsIInputStream* aStream, dom::ContentChild* aManager);
 
   // Serialize the input stream or create a SendStream actor using the
   // PBackground manager.  If neither of these succeed, then crash.  This can
   // be called on the main thread or Worker threads.
   bool Serialize(nsIInputStream* aStream, PBackgroundChild* aManager);
 
+  // Serialize the input stream or create a SendStream actor using the
+  // SocketProcess manager.  If neither of these succeed, then crash.  This
+  // should only be used on the main thread.
+  bool Serialize(nsIInputStream* aStream, net::SocketProcessChild* aManager);
+
   // Serialize the input stream.
   MOZ_MUST_USE bool Serialize(nsIInputStream* aStream,
                               dom::ContentParent* aManager);
 
   // Serialize the input stream.
   MOZ_MUST_USE bool Serialize(nsIInputStream* aStream,
                               PBackgroundParent* aManager);
 
+  // Serialize the input stream.
+  MOZ_MUST_USE bool Serialize(nsIInputStream* aStream,
+                              net::SocketProcessParent* aManager);
+
   // Get the IPCStream as a non-optional value.  This will
   // assert if a stream has not been serialized or if it has already been taken.
   // This should only be called if the value is being, or has already been, sent
   // to the other side.
   IPCStream& TakeValue();
 
   // Get the Maybe<IPCStream> value. This will assert if the value has already
   // been taken. This should only be called if the value is being, or has
--- a/ipc/glue/InputStreamUtils.cpp
+++ b/ipc/glue/InputStreamUtils.cpp
@@ -115,72 +115,41 @@ void SerializeInputStreamAsPipeInternal(
       aDelayedStart, IPCStreamSource::Create(asyncStream, aManager), length);
 }
 
 }  // namespace
 
 void InputStreamHelper::SerializeInputStream(
     nsIInputStream* aInputStream, InputStreamParams& aParams,
     nsTArray<FileDescriptor>& aFileDescriptors, bool aDelayedStart,
-    uint32_t aMaxSize, uint32_t* aSizeUsed, ContentChild* aManager) {
-  SerializeInputStreamInternal(aInputStream, aParams, aFileDescriptors,
-                               aDelayedStart, aMaxSize, aSizeUsed, aManager);
-}
-
-void InputStreamHelper::SerializeInputStream(
-    nsIInputStream* aInputStream, InputStreamParams& aParams,
-    nsTArray<FileDescriptor>& aFileDescriptors, bool aDelayedStart,
-    uint32_t aMaxSize, uint32_t* aSizeUsed, PBackgroundChild* aManager) {
-  SerializeInputStreamInternal(aInputStream, aParams, aFileDescriptors,
-                               aDelayedStart, aMaxSize, aSizeUsed, aManager);
-}
-
-void InputStreamHelper::SerializeInputStream(
-    nsIInputStream* aInputStream, InputStreamParams& aParams,
-    nsTArray<FileDescriptor>& aFileDescriptors, bool aDelayedStart,
-    uint32_t aMaxSize, uint32_t* aSizeUsed, ContentParent* aManager) {
+    uint32_t aMaxSize, uint32_t* aSizeUsed,
+    ParentToChildStreamActorManager* aManager) {
   SerializeInputStreamInternal(aInputStream, aParams, aFileDescriptors,
                                aDelayedStart, aMaxSize, aSizeUsed, aManager);
 }
 
 void InputStreamHelper::SerializeInputStream(
     nsIInputStream* aInputStream, InputStreamParams& aParams,
     nsTArray<FileDescriptor>& aFileDescriptors, bool aDelayedStart,
-    uint32_t aMaxSize, uint32_t* aSizeUsed, PBackgroundParent* aManager) {
+    uint32_t aMaxSize, uint32_t* aSizeUsed,
+    ChildToParentStreamActorManager* aManager) {
   SerializeInputStreamInternal(aInputStream, aParams, aFileDescriptors,
                                aDelayedStart, aMaxSize, aSizeUsed, aManager);
 }
 
-void InputStreamHelper::SerializeInputStreamAsPipe(nsIInputStream* aInputStream,
-                                                   InputStreamParams& aParams,
-                                                   bool aDelayedStart,
-                                                   ContentChild* aManager) {
-  SerializeInputStreamAsPipeInternal(aInputStream, aParams, aDelayedStart,
-                                     aManager);
-}
-
-void InputStreamHelper::SerializeInputStreamAsPipe(nsIInputStream* aInputStream,
-                                                   InputStreamParams& aParams,
-                                                   bool aDelayedStart,
-                                                   PBackgroundChild* aManager) {
-  SerializeInputStreamAsPipeInternal(aInputStream, aParams, aDelayedStart,
-                                     aManager);
-}
-
-void InputStreamHelper::SerializeInputStreamAsPipe(nsIInputStream* aInputStream,
-                                                   InputStreamParams& aParams,
-                                                   bool aDelayedStart,
-                                                   ContentParent* aManager) {
+void InputStreamHelper::SerializeInputStreamAsPipe(
+    nsIInputStream* aInputStream, InputStreamParams& aParams,
+    bool aDelayedStart, ParentToChildStreamActorManager* aManager) {
   SerializeInputStreamAsPipeInternal(aInputStream, aParams, aDelayedStart,
                                      aManager);
 }
 
 void InputStreamHelper::SerializeInputStreamAsPipe(
     nsIInputStream* aInputStream, InputStreamParams& aParams,
-    bool aDelayedStart, PBackgroundParent* aManager) {
+    bool aDelayedStart, ChildToParentStreamActorManager* aManager) {
   SerializeInputStreamAsPipeInternal(aInputStream, aParams, aDelayedStart,
                                      aManager);
 }
 
 void InputStreamHelper::PostSerializationActivation(InputStreamParams& aParams,
                                                     bool aConsumedByIPC,
                                                     bool aDelayedStart) {
   switch (aParams.type()) {
--- a/ipc/glue/InputStreamUtils.h
+++ b/ipc/glue/InputStreamUtils.h
@@ -11,78 +11,74 @@
 #include "nsCOMPtr.h"
 #include "nsIInputStream.h"
 #include "nsTArray.h"
 
 namespace mozilla {
 namespace ipc {
 
 class FileDescriptor;
+class PFileDescriptorSetChild;
+class PFileDescriptorSetParent;
+class PChildToParentStreamChild;
+class PParentToChildStreamParent;
+
+// Provide two interfaces for sending PParentToChildStream and
+// PFileDescriptorSet constructor messages.
+class ParentToChildStreamActorManager {
+ public:
+  virtual PParentToChildStreamParent* SendPParentToChildStreamConstructor(
+      PParentToChildStreamParent* aActor) = 0;
+  virtual PFileDescriptorSetParent* SendPFileDescriptorSetConstructor(
+      const FileDescriptor& aFD) = 0;
+};
+
+class ChildToParentStreamActorManager {
+ public:
+  virtual PChildToParentStreamChild* SendPChildToParentStreamConstructor(
+      PChildToParentStreamChild* aActor) = 0;
+  virtual PFileDescriptorSetChild* SendPFileDescriptorSetConstructor(
+      const FileDescriptor& aFD) = 0;
+};
 
 // If you want to serialize an inputStream, please use AutoIPCStream.
 class InputStreamHelper {
  public:
-  // These 4 methods allow to serialize an inputStream into InputStreamParams.
+  // These 2 methods allow to serialize an inputStream into InputStreamParams.
   // The manager is needed in case a stream needs to serialize itself as
   // IPCRemoteStream.
   // The stream serializes itself fully only if the resulting IPC message will
   // be smaller than |aMaxSize|. Otherwise, the stream serializes itself as
   // IPCRemoteStream, and, its content will be sent to the other side of the IPC
   // pipe in chunks. This sending can start immediatelly or at the first read
   // based on the value of |aDelayedStart|. The IPC message size is returned
   // into |aSizeUsed|.
   static void SerializeInputStream(nsIInputStream* aInputStream,
                                    InputStreamParams& aParams,
                                    nsTArray<FileDescriptor>& aFileDescriptors,
                                    bool aDelayedStart, uint32_t aMaxSize,
                                    uint32_t* aSizeUsed,
-                                   mozilla::dom::ContentChild* aManager);
-
-  static void SerializeInputStream(nsIInputStream* aInputStream,
-                                   InputStreamParams& aParams,
-                                   nsTArray<FileDescriptor>& aFileDescriptors,
-                                   bool aDelayedStart, uint32_t aMaxSize,
-                                   uint32_t* aSizeUsed,
-                                   PBackgroundChild* aManager);
-
-  static void SerializeInputStream(nsIInputStream* aInputStream,
-                                   InputStreamParams& aParams,
-                                   nsTArray<FileDescriptor>& aFileDescriptors,
-                                   bool aDelayedStart, uint32_t aMaxSize,
-                                   uint32_t* aSizeUsed,
-                                   mozilla::dom::ContentParent* aManager);
+                                   ParentToChildStreamActorManager* aManager);
 
   static void SerializeInputStream(nsIInputStream* aInputStream,
                                    InputStreamParams& aParams,
                                    nsTArray<FileDescriptor>& aFileDescriptors,
                                    bool aDelayedStart, uint32_t aMaxSize,
                                    uint32_t* aSizeUsed,
-                                   PBackgroundParent* aManager);
+                                   ChildToParentStreamActorManager* aManager);
 
   // When a stream wants to serialize itself as IPCRemoteStream, it uses one of
   // these methods.
-  static void SerializeInputStreamAsPipe(nsIInputStream* aInputStream,
-                                         InputStreamParams& aParams,
-                                         bool aDelayedStart,
-                                         mozilla::dom::ContentChild* aManager);
-
-  static void SerializeInputStreamAsPipe(nsIInputStream* aInputStream,
-                                         InputStreamParams& aParams,
-                                         bool aDelayedStart,
-                                         PBackgroundChild* aManager);
+  static void SerializeInputStreamAsPipe(
+      nsIInputStream* aInputStream, InputStreamParams& aParams,
+      bool aDelayedStart, ParentToChildStreamActorManager* aManager);
 
-  static void SerializeInputStreamAsPipe(nsIInputStream* aInputStream,
-                                         InputStreamParams& aParams,
-                                         bool aDelayedStart,
-                                         mozilla::dom::ContentParent* aManager);
-
-  static void SerializeInputStreamAsPipe(nsIInputStream* aInputStream,
-                                         InputStreamParams& aParams,
-                                         bool aDelayedStart,
-                                         PBackgroundParent* aManager);
+  static void SerializeInputStreamAsPipe(
+      nsIInputStream* aInputStream, InputStreamParams& aParams,
+      bool aDelayedStart, ChildToParentStreamActorManager* aManager);
 
   // After the sending of the inputStream into the IPC pipe, some of the
   // InputStreamParams data struct needs to be activated (IPCRemoteStream).
   // These 2 methods do that.
   static void PostSerializationActivation(InputStreamParams& aParams,
                                           bool aConsumedByIPC,
                                           bool aDelayedStart);
 
--- a/ipc/glue/PChildToParentStream.ipdl
+++ b/ipc/glue/PChildToParentStream.ipdl
@@ -1,27 +1,28 @@
 /* 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 protocol PBackground;
 include protocol PContent;
+include protocol PSocketProcess;
 
 include "mozilla/layers/WebRenderMessageUtils.h";
 
 using mozilla::wr::ByteBuffer from "mozilla/webrender/WebRenderTypes.h";
 
 namespace mozilla {
 namespace ipc {
 
 // This is protocol is the opposite of PParentToChildStream. Please keep these
 // protocols in sync.
 protocol PChildToParentStream
 {
-  manager PBackground or PContent;
+  manager PBackground or PContent or PSocketProcess;
 
 parent:
   async Buffer(ByteBuffer aBuffer);
   async Close(nsresult aRv);
 
 child:
   // The remote stream can be used in 2 ways: it can start receiving data
   // immediately after the creation of the child actor, or it can wait until
--- a/ipc/glue/PFileDescriptorSet.ipdl
+++ b/ipc/glue/PFileDescriptorSet.ipdl
@@ -1,21 +1,22 @@
 /* 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 protocol PBackground;
 include protocol PContent;
+include protocol PSocketProcess;
 
 namespace mozilla {
 namespace ipc {
 
 protocol PFileDescriptorSet
 {
-  manager PBackground or PContent;
+  manager PBackground or PContent or PSocketProcess;
 
 both:
   async AddFileDescriptor(FileDescriptor fd);
 
   async __delete__();
 };
 
 } // namespace ipc
--- a/ipc/glue/PParentToChildStream.ipdl
+++ b/ipc/glue/PParentToChildStream.ipdl
@@ -1,27 +1,28 @@
 /* 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 protocol PBackground;
 include protocol PContent;
+include protocol PSocketProcess;
 
 include "mozilla/layers/WebRenderMessageUtils.h";
 
 using mozilla::wr::ByteBuffer from "mozilla/webrender/WebRenderTypes.h";
 
 namespace mozilla {
 namespace ipc {
 
 // This is protocol is the opposite of PChildToParentStream. Please keep these
 // protocols in sync.
 protocol PParentToChildStream
 {
-  manager PBackground or PContent;
+  manager PBackground or PContent or PSocketProcess;
 
 child:
   async Buffer(ByteBuffer aBuffer);
   async Close(nsresult aRv);
 
 parent:
   // The remote stream can be used in 2 ways: it can start receiving data
   // immediately after the creation of the child actor, or it can wait until
--- a/ipc/glue/nsIIPCSerializableInputStream.h
+++ b/ipc/glue/nsIIPCSerializableInputStream.h
@@ -8,30 +8,22 @@
 #define mozilla_ipc_nsIIPCSerializableInputStream_h
 
 #include "mozilla/Attributes.h"
 #include "mozilla/Maybe.h"
 #include "nsISupports.h"
 #include "nsTArrayForwardDeclare.h"
 
 namespace mozilla {
-
-namespace dom {
-
-class ContentChild;
-class ContentParent;
-
-}  // namespace dom
-
 namespace ipc {
 
 class FileDescriptor;
 class InputStreamParams;
-class PBackgroundChild;
-class PBackgroundParent;
+class ChildToParentStreamActorManager;
+class ParentToChildStreamActorManager;
 
 }  // namespace ipc
 
 }  // namespace mozilla
 
 #define NS_IIPCSERIALIZABLEINPUTSTREAM_IID           \
   {                                                  \
     0xb0211b14, 0xea6d, 0x40d4, {                    \
@@ -40,154 +32,94 @@ class PBackgroundParent;
   }
 
 class NS_NO_VTABLE nsIIPCSerializableInputStream : public nsISupports {
  public:
   typedef nsTArray<mozilla::ipc::FileDescriptor> FileDescriptorArray;
 
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_IIPCSERIALIZABLEINPUTSTREAM_IID)
 
-  virtual void Serialize(mozilla::ipc::InputStreamParams& aParams,
-                         FileDescriptorArray& aFileDescriptors,
-                         bool aDelayedStart, uint32_t aMaxSize,
-                         uint32_t* aSizeUsed,
-                         mozilla::dom::ContentChild* aManager) = 0;
-
-  virtual void Serialize(mozilla::ipc::InputStreamParams& aParams,
-                         FileDescriptorArray& aFileDescriptors,
-                         bool aDelayedStart, uint32_t aMaxSize,
-                         uint32_t* aSizeUsed,
-                         mozilla::ipc::PBackgroundChild* aManager) = 0;
+  virtual void Serialize(
+      mozilla::ipc::InputStreamParams& aParams,
+      FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
+      uint32_t aMaxSize, uint32_t* aSizeUsed,
+      mozilla::ipc::ParentToChildStreamActorManager* aManager) = 0;
 
-  virtual void Serialize(mozilla::ipc::InputStreamParams& aParams,
-                         FileDescriptorArray& aFileDescriptors,
-                         bool aDelayedStart, uint32_t aMaxSize,
-                         uint32_t* aSizeUsed,
-                         mozilla::dom::ContentParent* aManager) = 0;
-
-  virtual void Serialize(mozilla::ipc::InputStreamParams& aParams,
-                         FileDescriptorArray& aFileDescriptors,
-                         bool aDelayedStart, uint32_t aMaxSize,
-                         uint32_t* aSizeUsed,
-                         mozilla::ipc::PBackgroundParent* aManager) = 0;
+  virtual void Serialize(
+      mozilla::ipc::InputStreamParams& aParams,
+      FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
+      uint32_t aMaxSize, uint32_t* aSizeUsed,
+      mozilla::ipc::ChildToParentStreamActorManager* aManager) = 0;
 
   virtual bool Deserialize(const mozilla::ipc::InputStreamParams& aParams,
                            const FileDescriptorArray& aFileDescriptors) = 0;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsIIPCSerializableInputStream,
                               NS_IIPCSERIALIZABLEINPUTSTREAM_IID)
 
-#define NS_DECL_NSIIPCSERIALIZABLEINPUTSTREAM                             \
-  virtual void Serialize(mozilla::ipc::InputStreamParams&,                \
-                         FileDescriptorArray&, bool, uint32_t, uint32_t*, \
-                         mozilla::dom::ContentChild*) override;           \
-                                                                          \
-  virtual void Serialize(mozilla::ipc::InputStreamParams&,                \
-                         FileDescriptorArray&, bool, uint32_t, uint32_t*, \
-                         mozilla::ipc::PBackgroundChild*) override;       \
-                                                                          \
-  virtual void Serialize(mozilla::ipc::InputStreamParams&,                \
-                         FileDescriptorArray&, bool, uint32_t, uint32_t*, \
-                         mozilla::dom::ContentParent*) override;          \
-                                                                          \
-  virtual void Serialize(mozilla::ipc::InputStreamParams&,                \
-                         FileDescriptorArray&, bool, uint32_t, uint32_t*, \
-                         mozilla::ipc::PBackgroundParent*) override;      \
-                                                                          \
-  virtual bool Deserialize(const mozilla::ipc::InputStreamParams&,        \
+#define NS_DECL_NSIIPCSERIALIZABLEINPUTSTREAM                                 \
+  virtual void Serialize(                                                     \
+      mozilla::ipc::InputStreamParams&, FileDescriptorArray&, bool, uint32_t, \
+      uint32_t*, mozilla::ipc::ParentToChildStreamActorManager*) override;    \
+                                                                              \
+  virtual void Serialize(                                                     \
+      mozilla::ipc::InputStreamParams&, FileDescriptorArray&, bool, uint32_t, \
+      uint32_t*, mozilla::ipc::ChildToParentStreamActorManager*) override;    \
+                                                                              \
+  virtual bool Deserialize(const mozilla::ipc::InputStreamParams&,            \
                            const FileDescriptorArray&) override;
 
-#define NS_FORWARD_NSIIPCSERIALIZABLEINPUTSTREAM(_to)                          \
-  virtual void Serialize(mozilla::ipc::InputStreamParams& aParams,             \
-                         FileDescriptorArray& aFileDescriptors,                \
-                         bool aDelayedStart, uint32_t aMaxSize,                \
-                         uint32_t* aSizeUsed,                                  \
-                         mozilla::dom::ContentChild* aManager) override {      \
-    _to Serialize(aParams, aFileDescriptors, aDelayedStart, aMaxSize,          \
-                  aSizeUsed, aManager);                                        \
-  }                                                                            \
-                                                                               \
-  virtual void Serialize(mozilla::ipc::InputStreamParams& aParams,             \
-                         FileDescriptorArray& aFileDescriptors,                \
-                         bool aDelayedStart, uint32_t aMaxSize,                \
-                         uint32_t* aSizeUsed,                                  \
-                         mozilla::ipc::PBackgroundChild* aManager) override {  \
-    _to Serialize(aParams, aFileDescriptors, aDelayedStart, aMaxSize,          \
-                  aSizeUsed, aManager);                                        \
-  }                                                                            \
-                                                                               \
-  virtual void Serialize(mozilla::ipc::InputStreamParams& aParams,             \
-                         FileDescriptorArray& aFileDescriptors,                \
-                         bool aDelayedStart, uint32_t aMaxSize,                \
-                         uint32_t* aSizeUsed,                                  \
-                         mozilla::dom::ContentParent* aManager) override {     \
-    _to Serialize(aParams, aFileDescriptors, aDelayedStart, aMaxSize,          \
-                  aSizeUsed, aManager);                                        \
-  }                                                                            \
-                                                                               \
-  virtual void Serialize(mozilla::ipc::InputStreamParams& aParams,             \
-                         FileDescriptorArray& aFileDescriptors,                \
-                         bool aDelayedStart, uint32_t aMaxSize,                \
-                         uint32_t* aSizeUsed,                                  \
-                         mozilla::ipc::PBackgroundParent* aManager) override { \
-    _to Serialize(aParams, aFileDescriptors, aDelayedStart, aMaxSize,          \
-                  aSizeUsed, aManager);                                        \
-  }                                                                            \
-                                                                               \
-  virtual bool Deserialize(const mozilla::ipc::InputStreamParams& aParams,     \
-                           const FileDescriptorArray& aFileDescriptors)        \
-      override {                                                               \
-    return _to Deserialize(aParams, aFileDescriptors);                         \
+#define NS_FORWARD_NSIIPCSERIALIZABLEINPUTSTREAM(_to)                      \
+  virtual void Serialize(                                                  \
+      mozilla::ipc::InputStreamParams& aParams,                            \
+      FileDescriptorArray& aFileDescriptors, bool aDelayedStart,           \
+      uint32_t aMaxSize, uint32_t* aSizeUsed,                              \
+      mozilla::ipc::ParentToChildStreamActorManager* aManager) override {  \
+    _to Serialize(aParams, aFileDescriptors, aDelayedStart, aMaxSize,      \
+                  aSizeUsed, aManager);                                    \
+  }                                                                        \
+                                                                           \
+  virtual void Serialize(                                                  \
+      mozilla::ipc::InputStreamParams& aParams,                            \
+      FileDescriptorArray& aFileDescriptors, bool aDelayedStart,           \
+      uint32_t aMaxSize, uint32_t* aSizeUsed,                              \
+      mozilla::ipc::ChildToParentStreamActorManager* aManager) override {  \
+    _to Serialize(aParams, aFileDescriptors, aDelayedStart, aMaxSize,      \
+                  aSizeUsed, aManager);                                    \
+  }                                                                        \
+                                                                           \
+  virtual bool Deserialize(const mozilla::ipc::InputStreamParams& aParams, \
+                           const FileDescriptorArray& aFileDescriptors)    \
+      override {                                                           \
+    return _to Deserialize(aParams, aFileDescriptors);                     \
   }
 
-#define NS_FORWARD_SAFE_NSIIPCSERIALIZABLEINPUTSTREAM(_to)                     \
-  virtual void Serialize(mozilla::ipc::InputStreamParams& aParams,             \
-                         FileDescriptorArray& aFileDescriptors,                \
-                         bool aDelayedStart, uint32_t aMaxSize,                \
-                         uint32_t* aSizeUsed,                                  \
-                         mozilla::dom::ContentChild* aManager) override {      \
-    if (_to) {                                                                 \
-      _to->Serialize(aParams, aFileDescriptors, aDelayedStart, aMaxSize,       \
-                     aSizeUsed, aManager);                                     \
-    }                                                                          \
-  }                                                                            \
-                                                                               \
-  virtual void Serialize(mozilla::ipc::InputStreamParams& aParams,             \
-                         FileDescriptorArray& aFileDescriptors,                \
-                         bool aDelayedStart, uint32_t aMaxSize,                \
-                         uint32_t* aSizeUsed,                                  \
-                         mozilla::ipc::PBackgroundChild* aManager) override {  \
-    if (_to) {                                                                 \
-      _to->Serialize(aParams, aFileDescriptors, aDelayedStart, aMaxSize,       \
-                     aSizeUsed, aManager);                                     \
-    }                                                                          \
-  }                                                                            \
-                                                                               \
-  virtual void Serialize(mozilla::ipc::InputStreamParams& aParams,             \
-                         FileDescriptorArray& aFileDescriptors,                \
-                         bool aDelayedStart, uint32_t aMaxSize,                \
-                         uint32_t* aSizeUsed,                                  \
-                         mozilla::dom::ContentParent* aManager) override {     \
-    if (_to) {                                                                 \
-      _to->Serialize(aParams, aFileDescriptors, aDelayedStart, aMaxSize,       \
-                     aSizeUsed, aManager);                                     \
-    }                                                                          \
-  }                                                                            \
-                                                                               \
-  virtual void Serialize(mozilla::ipc::InputStreamParams& aParams,             \
-                         FileDescriptorArray& aFileDescriptors,                \
-                         bool aDelayedStart, uint32_t aMaxSize,                \
-                         uint32_t* aSizeUsed,                                  \
-                         mozilla::ipc::PBackgroundParent* aManager) override { \
-    if (_to) {                                                                 \
-      _to->Serialize(aParams, aFileDescriptors, aDelayedStart, aMaxSize,       \
-                     aSizeUsed, aManager);                                     \
-    }                                                                          \
-  }                                                                            \
-                                                                               \
-  virtual bool Deserialize(const mozilla::ipc::InputStreamParams& aParams,     \
-                           const FileDescriptorArray& aFileDescriptors)        \
-      override {                                                               \
-    return _to ? _to->Deserialize(aParams, aFileDescriptors) : false;          \
+#define NS_FORWARD_SAFE_NSIIPCSERIALIZABLEINPUTSTREAM(_to)                 \
+  virtual void Serialize(                                                  \
+      mozilla::ipc::InputStreamParams& aParams,                            \
+      FileDescriptorArray& aFileDescriptors, bool aDelayedStart,           \
+      uint32_t aMaxSize, uint32_t* aSizeUsed,                              \
+      mozilla::ipc::ParentToChildStreamActorManager* aManager) override {  \
+    if (_to) {                                                             \
+      _to->Serialize(aParams, aFileDescriptors, aDelayedStart, aMaxSize,   \
+                     aSizeUsed, aManager);                                 \
+    }                                                                      \
+  }                                                                        \
+                                                                           \
+  virtual void Serialize(                                                  \
+      mozilla::ipc::InputStreamParams& aParams,                            \
+      FileDescriptorArray& aFileDescriptors, bool aDelayedStart,           \
+      uint32_t aMaxSize, uint32_t* aSizeUsed,                              \
+      mozilla::ipc::ChildToParentStreamActorManager* aManager) override {  \
+    if (_to) {                                                             \
+      _to->Serialize(aParams, aFileDescriptors, aDelayedStart, aMaxSize,   \
+                     aSizeUsed, aManager);                                 \
+    }                                                                      \
+  }                                                                        \
+                                                                           \
+  virtual bool Deserialize(const mozilla::ipc::InputStreamParams& aParams, \
+                           const FileDescriptorArray& aFileDescriptors)    \
+      override {                                                           \
+    return _to ? _to->Deserialize(aParams, aFileDescriptors) : false;      \
   }
 
 #endif  // mozilla_ipc_nsIIPCSerializableInputStream_h
--- a/netwerk/base/PartiallySeekableInputStream.cpp
+++ b/netwerk/base/PartiallySeekableInputStream.cpp
@@ -277,44 +277,26 @@ PartiallySeekableInputStream::OnInputStr
 }
 
 // nsIIPCSerializableInputStream
 
 void PartiallySeekableInputStream::Serialize(
     mozilla::ipc::InputStreamParams& aParams,
     FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
     uint32_t aMaxSize, uint32_t* aSizeUsed,
-    mozilla::dom::ContentChild* aManager) {
+    mozilla::ipc::ParentToChildStreamActorManager* aManager) {
   SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
                     aSizeUsed, aManager);
 }
 
 void PartiallySeekableInputStream::Serialize(
     mozilla::ipc::InputStreamParams& aParams,
     FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
     uint32_t aMaxSize, uint32_t* aSizeUsed,
-    mozilla::ipc::PBackgroundChild* aManager) {
-  SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
-                    aSizeUsed, aManager);
-}
-
-void PartiallySeekableInputStream::Serialize(
-    mozilla::ipc::InputStreamParams& aParams,
-    FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
-    uint32_t aMaxSize, uint32_t* aSizeUsed,
-    mozilla::dom::ContentParent* aManager) {
-  SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
-                    aSizeUsed, aManager);
-}
-
-void PartiallySeekableInputStream::Serialize(
-    mozilla::ipc::InputStreamParams& aParams,
-    FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
-    uint32_t aMaxSize, uint32_t* aSizeUsed,
-    mozilla::ipc::PBackgroundParent* aManager) {
+    mozilla::ipc::ChildToParentStreamActorManager* aManager) {
   SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
                     aSizeUsed, aManager);
 }
 
 template <typename M>
 void PartiallySeekableInputStream::SerializeInternal(
     mozilla::ipc::InputStreamParams& aParams,
     FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
--- a/netwerk/base/nsBufferedStreams.cpp
+++ b/netwerk/base/nsBufferedStreams.cpp
@@ -585,48 +585,28 @@ nsBufferedInputStream::GetUnbufferedStre
   mBufferStartOffset += mCursor;
   mFillPoint = mCursor = 0;
 
   nsCOMPtr<nsISupports> stream = mStream;
   stream.forget(aStream);
   return NS_OK;
 }
 
-void nsBufferedInputStream::Serialize(InputStreamParams& aParams,
-                                      FileDescriptorArray& aFileDescriptors,
-                                      bool aDelayedStart, uint32_t aMaxSize,
-                                      uint32_t* aSizeUsed,
-                                      mozilla::dom::ContentChild* aManager) {
+void nsBufferedInputStream::Serialize(
+    InputStreamParams& aParams, FileDescriptorArray& aFileDescriptors,
+    bool aDelayedStart, uint32_t aMaxSize, uint32_t* aSizeUsed,
+    mozilla::ipc::ParentToChildStreamActorManager* aManager) {
   SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
                     aSizeUsed, aManager);
 }
 
-void nsBufferedInputStream::Serialize(InputStreamParams& aParams,
-                                      FileDescriptorArray& aFileDescriptors,
-                                      bool aDelayedStart, uint32_t aMaxSize,
-                                      uint32_t* aSizeUsed,
-                                      PBackgroundChild* aManager) {
-  SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
-                    aSizeUsed, aManager);
-}
-
-void nsBufferedInputStream::Serialize(InputStreamParams& aParams,
-                                      FileDescriptorArray& aFileDescriptors,
-                                      bool aDelayedStart, uint32_t aMaxSize,
-                                      uint32_t* aSizeUsed,
-                                      mozilla::dom::ContentParent* aManager) {
-  SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
-                    aSizeUsed, aManager);
-}
-
-void nsBufferedInputStream::Serialize(InputStreamParams& aParams,
-                                      FileDescriptorArray& aFileDescriptors,
-                                      bool aDelayedStart, uint32_t aMaxSize,
-                                      uint32_t* aSizeUsed,
-                                      PBackgroundParent* aManager) {
+void nsBufferedInputStream::Serialize(
+    InputStreamParams& aParams, FileDescriptorArray& aFileDescriptors,
+    bool aDelayedStart, uint32_t aMaxSize, uint32_t* aSizeUsed,
+    mozilla::ipc::ChildToParentStreamActorManager* aManager) {
   SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
                     aSizeUsed, aManager);
 }
 
 template <typename M>
 void nsBufferedInputStream::SerializeInternal(
     InputStreamParams& aParams, FileDescriptorArray& aFileDescriptors,
     bool aDelayedStart, uint32_t aMaxSize, uint32_t* aSizeUsed, M* aManager) {
--- a/netwerk/base/nsFileStreams.cpp
+++ b/netwerk/base/nsFileStreams.cpp
@@ -539,50 +539,28 @@ NS_IMETHODIMP
 nsFileInputStream::Available(uint64_t* aResult) {
   return nsFileStreamBase::Available(aResult);
 }
 
 void nsFileInputStream::Serialize(InputStreamParams& aParams,
                                   FileDescriptorArray& aFileDescriptors,
                                   bool aDelayedStart, uint32_t aMaxSize,
                                   uint32_t* aSizeUsed,
-                                  mozilla::dom::ContentChild* aManager) {
+                                  ParentToChildStreamActorManager* aManager) {
   MOZ_ASSERT(aSizeUsed);
   *aSizeUsed = 0;
 
   SerializeInternal(aParams, aFileDescriptors);
 }
 
 void nsFileInputStream::Serialize(InputStreamParams& aParams,
                                   FileDescriptorArray& aFileDescriptors,
                                   bool aDelayedStart, uint32_t aMaxSize,
                                   uint32_t* aSizeUsed,
-                                  PBackgroundChild* aManager) {
-  MOZ_ASSERT(aSizeUsed);
-  *aSizeUsed = 0;
-
-  SerializeInternal(aParams, aFileDescriptors);
-}
-
-void nsFileInputStream::Serialize(InputStreamParams& aParams,
-                                  FileDescriptorArray& aFileDescriptors,
-                                  bool aDelayedStart, uint32_t aMaxSize,
-                                  uint32_t* aSizeUsed,
-                                  mozilla::dom::ContentParent* aManager) {
-  MOZ_ASSERT(aSizeUsed);
-  *aSizeUsed = 0;
-
-  SerializeInternal(aParams, aFileDescriptors);
-}
-
-void nsFileInputStream::Serialize(InputStreamParams& aParams,
-                                  FileDescriptorArray& aFileDescriptors,
-                                  bool aDelayedStart, uint32_t aMaxSize,
-                                  uint32_t* aSizeUsed,
-                                  PBackgroundParent* aManager) {
+                                  ChildToParentStreamActorManager* aManager) {
   MOZ_ASSERT(aSizeUsed);
   *aSizeUsed = 0;
 
   SerializeInternal(aParams, aFileDescriptors);
 }
 
 void nsFileInputStream::SerializeInternal(
     InputStreamParams& aParams, FileDescriptorArray& aFileDescriptors) {
--- a/netwerk/base/nsMIMEInputStream.cpp
+++ b/netwerk/base/nsMIMEInputStream.cpp
@@ -331,48 +331,28 @@ nsresult nsMIMEInputStreamConstructor(ns
   if (outer) return NS_ERROR_NO_AGGREGATION;
 
   RefPtr<nsMIMEInputStream> inst = new nsMIMEInputStream();
   if (!inst) return NS_ERROR_OUT_OF_MEMORY;
 
   return inst->QueryInterface(iid, result);
 }
 
-void nsMIMEInputStream::Serialize(InputStreamParams& aParams,
-                                  FileDescriptorArray& aFileDescriptors,
-                                  bool aDelayedStart, uint32_t aMaxSize,
-                                  uint32_t* aSizeUsed,
-                                  mozilla::dom::ContentChild* aManager) {
+void nsMIMEInputStream::Serialize(
+    InputStreamParams& aParams, FileDescriptorArray& aFileDescriptors,
+    bool aDelayedStart, uint32_t aMaxSize, uint32_t* aSizeUsed,
+    mozilla::ipc::ParentToChildStreamActorManager* aManager) {
   SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
                     aSizeUsed, aManager);
 }
 
-void nsMIMEInputStream::Serialize(InputStreamParams& aParams,
-                                  FileDescriptorArray& aFileDescriptors,
-                                  bool aDelayedStart, uint32_t aMaxSize,
-                                  uint32_t* aSizeUsed,
-                                  PBackgroundChild* aManager) {
-  SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
-                    aSizeUsed, aManager);
-}
-
-void nsMIMEInputStream::Serialize(InputStreamParams& aParams,
-                                  FileDescriptorArray& aFileDescriptors,
-                                  bool aDelayedStart, uint32_t aMaxSize,
-                                  uint32_t* aSizeUsed,
-                                  mozilla::dom::ContentParent* aManager) {
-  SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
-                    aSizeUsed, aManager);
-}
-
-void nsMIMEInputStream::Serialize(InputStreamParams& aParams,
-                                  FileDescriptorArray& aFileDescriptors,
-                                  bool aDelayedStart, uint32_t aMaxSize,
-                                  uint32_t* aSizeUsed,
-                                  PBackgroundParent* aManager) {
+void nsMIMEInputStream::Serialize(
+    InputStreamParams& aParams, FileDescriptorArray& aFileDescriptors,
+    bool aDelayedStart, uint32_t aMaxSize, uint32_t* aSizeUsed,
+    mozilla::ipc::ChildToParentStreamActorManager* aManager) {
   SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
                     aSizeUsed, aManager);
 }
 
 template <typename M>
 void nsMIMEInputStream::SerializeInternal(InputStreamParams& aParams,
                                           FileDescriptorArray& aFileDescriptors,
                                           bool aDelayedStart, uint32_t aMaxSize,
--- a/netwerk/ipc/PSocketProcess.ipdl
+++ b/netwerk/ipc/PSocketProcess.ipdl
@@ -2,16 +2,19 @@
 /* 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 protocol PDNSRequest;
 include protocol PSocketProcessBridge;
 include protocol PProfiler;
 include protocol PWebrtcTCPSocket;
+include protocol PFileDescriptorSet;
+include protocol PChildToParentStream;
+include protocol PParentToChildStream;
 
 include MemoryReportTypes;
 include PBrowserOrId;
 include PrefsTypes;
 
 using mozilla::dom::NativeThreadId from "mozilla/dom/TabMessageUtils.h";
 using mozilla::Telemetry::HistogramAccumulation from "mozilla/TelemetryComms.h";
 using mozilla::Telemetry::KeyedHistogramAccumulation from "mozilla/TelemetryComms.h";
@@ -24,16 +27,19 @@ using mozilla::OriginAttributes from "mo
 
 namespace mozilla {
 namespace net {
 
 protocol PSocketProcess
 {
   manages PDNSRequest;
   manages PWebrtcTCPSocket;
+  manages PFileDescriptorSet;
+  manages PChildToParentStream;
+  manages PParentToChildStream;
 
 parent:
   async InitCrashReporter(Shmem shmem, NativeThreadId threadId);
   async AddMemoryReport(MemoryReport aReport);
   async FinishMemoryReport(uint32_t aGeneration);
   // Messages for sending telemetry to parent process.
   async AccumulateChildHistograms(HistogramAccumulation[] accumulations);
   async AccumulateChildKeyedHistograms(KeyedHistogramAccumulation[] accumulations);
@@ -41,24 +47,29 @@ parent:
   async UpdateChildKeyedScalars(KeyedScalarAction[] actions);
   async RecordChildEvents(ChildEventData[] events);
   async RecordDiscardedData(DiscardedData data);
 
   /* tabId is only required for web-proxy support, which isn't always needed */
   async PWebrtcTCPSocket(TabId? tabId);
   async PDNSRequest(nsCString hostName, OriginAttributes originAttributes,
                     uint32_t flags);
+  async PChildToParentStream();
 
 child:
   async PreferenceUpdate(Pref pref);
   async RequestMemoryReport(uint32_t generation,
                             bool anonymize,
                             bool minimizeMemoryUsage,
                             FileDescriptor? DMDFile);
   async SetOffline(bool offline);
   async InitSocketProcessBridgeParent(ProcessId processId, Endpoint<PSocketProcessBridgeParent> endpoint);
   async InitProfiler(Endpoint<PProfilerChild> aEndpoint);
   // test-only
   async SocketProcessTelemetryPing();
+  async PParentToChildStream();
+
+both:
+  async PFileDescriptorSet(FileDescriptor fd);
 };
 
 } // namespace net
 } // namespace mozilla
--- a/netwerk/ipc/SocketProcessChild.cpp
+++ b/netwerk/ipc/SocketProcessChild.cpp
@@ -5,18 +5,22 @@
 
 #include "SocketProcessChild.h"
 #include "SocketProcessLogging.h"
 
 #include "base/task.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/dom/MemoryReportRequest.h"
 #include "mozilla/ipc/CrashReporterClient.h"
+#include "mozilla/ipc/FileDescriptorSetChild.h"
+#include "mozilla/ipc/IPCStreamAlloc.h"
 #include "mozilla/ipc/ProcessChild.h"
 #include "mozilla/net/DNSRequestChild.h"
+#include "mozilla/ipc/PChildToParentStreamChild.h"
+#include "mozilla/ipc/PParentToChildStreamChild.h"
 #include "mozilla/Preferences.h"
 #include "nsDebugImpl.h"
 #include "nsThreadManager.h"
 #include "ProcessUtils.h"
 #include "SocketProcessBridgeParent.h"
 
 #ifdef MOZ_GECKO_PROFILER
 #  include "ChildProfilerController.h"
@@ -207,10 +211,56 @@ bool SocketProcessChild::DeallocPWebrtcT
     PWebrtcTCPSocketChild* aActor) {
 #ifdef MOZ_WEBRTC
   WebrtcTCPSocketChild* child = static_cast<WebrtcTCPSocketChild*>(aActor);
   child->ReleaseIPDLReference();
 #endif
   return true;
 }
 
+PFileDescriptorSetChild* SocketProcessChild::AllocPFileDescriptorSetChild(
+    const FileDescriptor& aFD) {
+  return new FileDescriptorSetChild(aFD);
+}
+
+bool SocketProcessChild::DeallocPFileDescriptorSetChild(
+    PFileDescriptorSetChild* aActor) {
+  delete aActor;
+  return true;
+}
+
+PChildToParentStreamChild*
+SocketProcessChild::AllocPChildToParentStreamChild() {
+  MOZ_CRASH("PChildToParentStreamChild actors should be manually constructed!");
+}
+
+bool SocketProcessChild::DeallocPChildToParentStreamChild(
+    PChildToParentStreamChild* aActor) {
+  delete aActor;
+  return true;
+}
+
+PParentToChildStreamChild*
+SocketProcessChild::AllocPParentToChildStreamChild() {
+  return mozilla::ipc::AllocPParentToChildStreamChild();
+}
+
+bool SocketProcessChild::DeallocPParentToChildStreamChild(
+    PParentToChildStreamChild* aActor) {
+  delete aActor;
+  return true;
+}
+
+PChildToParentStreamChild*
+SocketProcessChild::SendPChildToParentStreamConstructor(
+    PChildToParentStreamChild* aActor) {
+  MOZ_ASSERT(NS_IsMainThread());
+  return PSocketProcessChild::SendPChildToParentStreamConstructor(aActor);
+}
+
+PFileDescriptorSetChild* SocketProcessChild::SendPFileDescriptorSetConstructor(
+    const FileDescriptor& aFD) {
+  MOZ_ASSERT(NS_IsMainThread());
+  return PSocketProcessChild::SendPFileDescriptorSetConstructor(aFD);
+}
+
 }  // namespace net
 }  // namespace mozilla
--- a/netwerk/ipc/SocketProcessChild.h
+++ b/netwerk/ipc/SocketProcessChild.h
@@ -2,30 +2,33 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_net_SocketProcessChild_h
 #define mozilla_net_SocketProcessChild_h
 
 #include "mozilla/net/PSocketProcessChild.h"
+#include "mozilla/ipc/InputStreamUtils.h"
 #include "nsRefPtrHashtable.h"
 
 namespace mozilla {
 class ChildProfilerController;
 }
 
 namespace mozilla {
 namespace net {
 
 class SocketProcessBridgeParent;
 
 // The IPC actor implements PSocketProcessChild in child process.
 // This is allocated and kept alive by SocketProcessImpl.
-class SocketProcessChild final : public PSocketProcessChild {
+class SocketProcessChild final
+    : public PSocketProcessChild,
+      public mozilla::ipc::ChildToParentStreamActorManager {
  public:
   SocketProcessChild();
   ~SocketProcessChild();
 
   static SocketProcessChild* GetSingleton();
 
   bool Init(base::ProcessId aParentPid, const char* aParentBuildID,
             MessageLoop* aIOLoop, IPC::Channel* aChannel);
@@ -43,19 +46,33 @@ class SocketProcessChild final : public 
       Endpoint<mozilla::net::PSocketProcessBridgeParent>&& aEndpoint);
   mozilla::ipc::IPCResult RecvInitProfiler(
       Endpoint<mozilla::PProfilerChild>&& aEndpoint);
   mozilla::ipc::IPCResult RecvSocketProcessTelemetryPing();
 
   PWebrtcTCPSocketChild* AllocPWebrtcTCPSocketChild(const Maybe<TabId>& tabId);
   bool DeallocPWebrtcTCPSocketChild(PWebrtcTCPSocketChild* aActor);
 
+  PFileDescriptorSetChild* AllocPFileDescriptorSetChild(
+      const FileDescriptor& fd);
+  bool DeallocPFileDescriptorSetChild(PFileDescriptorSetChild* aActor);
+
+  PChildToParentStreamChild* AllocPChildToParentStreamChild();
+  bool DeallocPChildToParentStreamChild(PChildToParentStreamChild* aActor);
+  PParentToChildStreamChild* AllocPParentToChildStreamChild();
+  bool DeallocPParentToChildStreamChild(PParentToChildStreamChild* aActor);
+
   void CleanUp();
   void DestroySocketProcessBridgeParent(ProcessId aId);
 
+  PChildToParentStreamChild* SendPChildToParentStreamConstructor(
+      PChildToParentStreamChild* aActor) override;
+  PFileDescriptorSetChild* SendPFileDescriptorSetConstructor(
+      const FileDescriptor& aFD) override;
+
  private:
   // Mapping of content process id and the SocketProcessBridgeParent.
   // This table keeps SocketProcessBridgeParent alive in socket process.
   nsRefPtrHashtable<nsUint32HashKey, SocketProcessBridgeParent>
       mSocketProcessBridgeParentMap;
 
 #ifdef MOZ_GECKO_PROFILER
   RefPtr<ChildProfilerController> mProfilerController;
--- a/netwerk/ipc/SocketProcessParent.cpp
+++ b/netwerk/ipc/SocketProcessParent.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "SocketProcessParent.h"
 
 #include "SocketProcessHost.h"
+#include "mozilla/ipc/FileDescriptorSetParent.h"
 #include "mozilla/net/DNSRequestParent.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/TelemetryIPC.h"
 #ifdef MOZ_WEBRTC
 #  include "mozilla/dom/ContentProcessManager.h"
 #  include "mozilla/dom/BrowserParent.h"
 #  include "mozilla/net/WebrtcTCPSocketParent.h"
 #endif
@@ -151,16 +152,63 @@ already_AddRefed<PDNSRequestParent> Sock
 mozilla::ipc::IPCResult SocketProcessParent::RecvPDNSRequestConstructor(
     PDNSRequestParent* aActor, const nsCString& aHost,
     const OriginAttributes& aOriginAttributes, const uint32_t& aFlags) {
   static_cast<DNSRequestParent*>(aActor)->DoAsyncResolve(
       aHost, aOriginAttributes, aFlags);
   return IPC_OK();
 }
 
+PFileDescriptorSetParent* SocketProcessParent::AllocPFileDescriptorSetParent(
+    const FileDescriptor& aFD) {
+  return new FileDescriptorSetParent(aFD);
+}
+
+bool SocketProcessParent::DeallocPFileDescriptorSetParent(
+    PFileDescriptorSetParent* aActor) {
+  delete static_cast<FileDescriptorSetParent*>(aActor);
+  return true;
+}
+
+PChildToParentStreamParent*
+SocketProcessParent::AllocPChildToParentStreamParent() {
+  return mozilla::ipc::AllocPChildToParentStreamParent();
+}
+
+bool SocketProcessParent::DeallocPChildToParentStreamParent(
+    PChildToParentStreamParent* aActor) {
+  delete aActor;
+  return true;
+}
+
+PParentToChildStreamParent*
+SocketProcessParent::AllocPParentToChildStreamParent() {
+  MOZ_CRASH("PParentToChildStreamChild actors should be manually constructed!");
+}
+
+bool SocketProcessParent::DeallocPParentToChildStreamParent(
+    PParentToChildStreamParent* aActor) {
+  delete aActor;
+  return true;
+}
+
+PParentToChildStreamParent*
+SocketProcessParent::SendPParentToChildStreamConstructor(
+    PParentToChildStreamParent* aActor) {
+  MOZ_ASSERT(NS_IsMainThread());
+  return PSocketProcessParent::SendPParentToChildStreamConstructor(aActor);
+}
+
+PFileDescriptorSetParent*
+SocketProcessParent::SendPFileDescriptorSetConstructor(
+    const FileDescriptor& aFD) {
+  MOZ_ASSERT(NS_IsMainThread());
+  return PSocketProcessParent::SendPFileDescriptorSetConstructor(aFD);
+}
+
 // To ensure that IPDL is finished before SocketParent gets deleted.
 class DeferredDeleteSocketProcessParent : public Runnable {
  public:
   explicit DeferredDeleteSocketProcessParent(
       UniquePtr<SocketProcessParent>&& aParent)
       : Runnable("net::DeferredDeleteSocketProcessParent"),
         mParent(std::move(aParent)) {}
 
--- a/netwerk/ipc/SocketProcessParent.h
+++ b/netwerk/ipc/SocketProcessParent.h
@@ -3,16 +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/. */
 
 #ifndef mozilla_net_SocketProcessParent_h
 #define mozilla_net_SocketProcessParent_h
 
 #include "mozilla/UniquePtr.h"
 #include "mozilla/ipc/CrashReporterHelper.h"
+#include "mozilla/ipc/InputStreamUtils.h"
 #include "mozilla/net/PSocketProcessParent.h"
 
 namespace mozilla {
 
 namespace dom {
 class MemoryReport;
 class MemoryReportRequestHost;
 }  // namespace dom
@@ -24,17 +25,18 @@ class CrashReporterHost;
 namespace net {
 
 class SocketProcessHost;
 
 // IPC actor of socket process in parent process. This is allocated and managed
 // by SocketProcessHost.
 class SocketProcessParent final
     : public PSocketProcessParent,
-      public ipc::CrashReporterHelper<GeckoProcessType_Socket> {
+      public ipc::CrashReporterHelper<GeckoProcessType_Socket>,
+      public ipc::ParentToChildStreamActorManager {
  public:
   friend class SocketProcessHost;
 
   explicit SocketProcessParent(SocketProcessHost* aHost);
   ~SocketProcessParent();
 
   static SocketProcessParent* GetSingleton();
 
@@ -65,16 +67,30 @@ class SocketProcessParent final
       const uint32_t& flags) override;
 
   void ActorDestroy(ActorDestroyReason aWhy) override;
   bool SendRequestMemoryReport(const uint32_t& aGeneration,
                                const bool& aAnonymize,
                                const bool& aMinimizeMemoryUsage,
                                const Maybe<ipc::FileDescriptor>& aDMDFile);
 
+  PFileDescriptorSetParent* AllocPFileDescriptorSetParent(
+      const FileDescriptor& fd);
+  bool DeallocPFileDescriptorSetParent(PFileDescriptorSetParent* aActor);
+
+  PChildToParentStreamParent* AllocPChildToParentStreamParent();
+  bool DeallocPChildToParentStreamParent(PChildToParentStreamParent* aActor);
+  PParentToChildStreamParent* AllocPParentToChildStreamParent();
+  bool DeallocPParentToChildStreamParent(PParentToChildStreamParent* aActor);
+
+  PParentToChildStreamParent* SendPParentToChildStreamConstructor(
+      PParentToChildStreamParent* aActor) override;
+  PFileDescriptorSetParent* SendPFileDescriptorSetConstructor(
+      const FileDescriptor& aFD) override;
+
  private:
   SocketProcessHost* mHost;
   UniquePtr<dom::MemoryReportRequestHost> mMemoryReportRequest;
 
   static void Destroy(UniquePtr<SocketProcessParent>&& aParent);
 };
 
 }  // namespace net
--- a/xpcom/io/InputStreamLengthWrapper.cpp
+++ b/xpcom/io/InputStreamLengthWrapper.cpp
@@ -255,44 +255,26 @@ InputStreamLengthWrapper::OnInputStreamR
 }
 
 // nsIIPCSerializableInputStream
 
 void InputStreamLengthWrapper::Serialize(
     mozilla::ipc::InputStreamParams& aParams,
     FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
     uint32_t aMaxSize, uint32_t* aSizeUsed,
-    mozilla::dom::ContentChild* aManager) {
+    mozilla::ipc::ParentToChildStreamActorManager* aManager) {
   SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
                     aSizeUsed, aManager);
 }
 
 void InputStreamLengthWrapper::Serialize(
     mozilla::ipc::InputStreamParams& aParams,
     FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
     uint32_t aMaxSize, uint32_t* aSizeUsed,
-    mozilla::ipc::PBackgroundChild* aManager) {
-  SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
-                    aSizeUsed, aManager);
-}
-
-void InputStreamLengthWrapper::Serialize(
-    mozilla::ipc::InputStreamParams& aParams,
-    FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
-    uint32_t aMaxSize, uint32_t* aSizeUsed,
-    mozilla::dom::ContentParent* aManager) {
-  SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
-                    aSizeUsed, aManager);
-}
-
-void InputStreamLengthWrapper::Serialize(
-    mozilla::ipc::InputStreamParams& aParams,
-    FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
-    uint32_t aMaxSize, uint32_t* aSizeUsed,
-    mozilla::ipc::PBackgroundParent* aManager) {
+    mozilla::ipc::ChildToParentStreamActorManager* aManager) {
   SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
                     aSizeUsed, aManager);
 }
 
 template <typename M>
 void InputStreamLengthWrapper::SerializeInternal(
     mozilla::ipc::InputStreamParams& aParams,
     FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
--- a/xpcom/io/NonBlockingAsyncInputStream.cpp
+++ b/xpcom/io/NonBlockingAsyncInputStream.cpp
@@ -316,44 +316,26 @@ NonBlockingAsyncInputStream::AsyncWait(n
 }
 
 // nsIIPCSerializableInputStream
 
 void NonBlockingAsyncInputStream::Serialize(
     mozilla::ipc::InputStreamParams& aParams,
     FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
     uint32_t aMaxSize, uint32_t* aSizeUsed,
-    mozilla::dom::ContentChild* aManager) {
+    mozilla::ipc::ParentToChildStreamActorManager* aManager) {
   SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
                     aSizeUsed, aManager);
 }
 
 void NonBlockingAsyncInputStream::Serialize(
     mozilla::ipc::InputStreamParams& aParams,
     FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
     uint32_t aMaxSize, uint32_t* aSizeUsed,
-    mozilla::ipc::PBackgroundChild* aManager) {
-  SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
-                    aSizeUsed, aManager);
-}
-
-void NonBlockingAsyncInputStream::Serialize(
-    mozilla::ipc::InputStreamParams& aParams,
-    FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
-    uint32_t aMaxSize, uint32_t* aSizeUsed,
-    mozilla::dom::ContentParent* aManager) {
-  SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
-                    aSizeUsed, aManager);
-}
-
-void NonBlockingAsyncInputStream::Serialize(
-    mozilla::ipc::InputStreamParams& aParams,
-    FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
-    uint32_t aMaxSize, uint32_t* aSizeUsed,
-    mozilla::ipc::PBackgroundParent* aManager) {
+    mozilla::ipc::ChildToParentStreamActorManager* aManager) {
   SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
                     aSizeUsed, aManager);
 }
 
 template <typename M>
 void NonBlockingAsyncInputStream::SerializeInternal(
     mozilla::ipc::InputStreamParams& aParams,
     FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
--- a/xpcom/io/SlicedInputStream.cpp
+++ b/xpcom/io/SlicedInputStream.cpp
@@ -415,48 +415,30 @@ SlicedInputStream::OnInputStreamReady(ns
   }
 
   return mWeakAsyncInputStream->AsyncWait(
       this, asyncWaitFlags, asyncWaitRequestedCount, asyncWaitEventTarget);
 }
 
 // nsIIPCSerializableInputStream
 
-void SlicedInputStream::Serialize(mozilla::ipc::InputStreamParams& aParams,
-                                  FileDescriptorArray& aFileDescriptors,
-                                  bool aDelayedStart, uint32_t aMaxSize,
-                                  uint32_t* aSizeUsed,
-                                  mozilla::dom::ContentChild* aManager) {
+void SlicedInputStream::Serialize(
+    mozilla::ipc::InputStreamParams& aParams,
+    FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
+    uint32_t aMaxSize, uint32_t* aSizeUsed,
+    mozilla::ipc::ParentToChildStreamActorManager* aManager) {
   SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
                     aSizeUsed, aManager);
 }
 
-void SlicedInputStream::Serialize(mozilla::ipc::InputStreamParams& aParams,
-                                  FileDescriptorArray& aFileDescriptors,
-                                  bool aDelayedStart, uint32_t aMaxSize,
-                                  uint32_t* aSizeUsed,
-                                  mozilla::ipc::PBackgroundChild* aManager) {
-  SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
-                    aSizeUsed, aManager);
-}
-
-void SlicedInputStream::Serialize(mozilla::ipc::InputStreamParams& aParams,
-                                  FileDescriptorArray& aFileDescriptors,
-                                  bool aDelayedStart, uint32_t aMaxSize,
-                                  uint32_t* aSizeUsed,
-                                  mozilla::dom::ContentParent* aManager) {
-  SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
-                    aSizeUsed, aManager);
-}
-
-void SlicedInputStream::Serialize(mozilla::ipc::InputStreamParams& aParams,
-                                  FileDescriptorArray& aFileDescriptors,
-                                  bool aDelayedStart, uint32_t aMaxSize,
-                                  uint32_t* aSizeUsed,
-                                  mozilla::ipc::PBackgroundParent* aManager) {
+void SlicedInputStream::Serialize(
+    mozilla::ipc::InputStreamParams& aParams,
+    FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
+    uint32_t aMaxSize, uint32_t* aSizeUsed,
+    mozilla::ipc::ChildToParentStreamActorManager* aManager) {
   SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
                     aSizeUsed, aManager);
 }
 
 template <typename M>
 void SlicedInputStream::SerializeInternal(
     mozilla::ipc::InputStreamParams& aParams,
     FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
--- a/xpcom/io/nsMultiplexInputStream.cpp
+++ b/xpcom/io/nsMultiplexInputStream.cpp
@@ -985,48 +985,28 @@ nsresult nsMultiplexInputStreamConstruct
     return NS_ERROR_NO_AGGREGATION;
   }
 
   RefPtr<nsMultiplexInputStream> inst = new nsMultiplexInputStream();
 
   return inst->QueryInterface(aIID, aResult);
 }
 
-void nsMultiplexInputStream::Serialize(InputStreamParams& aParams,
-                                       FileDescriptorArray& aFileDescriptors,
-                                       bool aDelayedStart, uint32_t aMaxSize,
-                                       uint32_t* aSizeUsed,
-                                       mozilla::dom::ContentChild* aManager) {
+void nsMultiplexInputStream::Serialize(
+    InputStreamParams& aParams, FileDescriptorArray& aFileDescriptors,
+    bool aDelayedStart, uint32_t aMaxSize, uint32_t* aSizeUsed,
+    mozilla::ipc::ParentToChildStreamActorManager* aManager) {
   SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
                     aSizeUsed, aManager);
 }
 
-void nsMultiplexInputStream::Serialize(InputStreamParams& aParams,
-                                       FileDescriptorArray& aFileDescriptors,
-                                       bool aDelayedStart, uint32_t aMaxSize,
-                                       uint32_t* aSizeUsed,
-                                       PBackgroundChild* aManager) {
-  SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
-                    aSizeUsed, aManager);
-}
-
-void nsMultiplexInputStream::Serialize(InputStreamParams& aParams,
-                                       FileDescriptorArray& aFileDescriptors,
-                                       bool aDelayedStart, uint32_t aMaxSize,
-                                       uint32_t* aSizeUsed,
-                                       mozilla::dom::ContentParent* aManager) {
-  SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
-                    aSizeUsed, aManager);
-}
-
-void nsMultiplexInputStream::Serialize(InputStreamParams& aParams,
-                                       FileDescriptorArray& aFileDescriptors,
-                                       bool aDelayedStart, uint32_t aMaxSize,
-                                       uint32_t* aSizeUsed,
-                                       PBackgroundParent* aManager) {
+void nsMultiplexInputStream::Serialize(
+    InputStreamParams& aParams, FileDescriptorArray& aFileDescriptors,
+    bool aDelayedStart, uint32_t aMaxSize, uint32_t* aSizeUsed,
+    mozilla::ipc::ChildToParentStreamActorManager* aManager) {
   SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
                     aSizeUsed, aManager);
 }
 
 template <typename M>
 void nsMultiplexInputStream::SerializeInternal(
     InputStreamParams& aParams, FileDescriptorArray& aFileDescriptors,
     bool aDelayedStart, uint32_t aMaxSize, uint32_t* aSizeUsed, M* aManager) {
--- a/xpcom/io/nsStorageStream.cpp
+++ b/xpcom/io/nsStorageStream.cpp
@@ -545,41 +545,27 @@ nsresult nsStorageInputStream::Seek(uint
   mSegmentNum = SegNum(aPosition);
   mReadCursor = SegOffset(aPosition);
   uint32_t available = length - aPosition;
   mSegmentEnd = mReadCursor + XPCOM_MIN(mSegmentSize - mReadCursor, available);
   mLogicalCursor = aPosition;
   return NS_OK;
 }
 
-void nsStorageInputStream::Serialize(InputStreamParams& aParams,
-                                     FileDescriptorArray&, bool aDelayedStart,
-                                     uint32_t aMaxSize, uint32_t* aSizeUsed,
-                                     mozilla::dom::ContentChild* aManager) {
-  SerializeInternal(aParams, aDelayedStart, aMaxSize, aSizeUsed, aManager);
-}
-
-void nsStorageInputStream::Serialize(InputStreamParams& aParams,
-                                     FileDescriptorArray&, bool aDelayedStart,
-                                     uint32_t aMaxSize, uint32_t* aSizeUsed,
-                                     mozilla::ipc::PBackgroundChild* aManager) {
-  SerializeInternal(aParams, aDelayedStart, aMaxSize, aSizeUsed, aManager);
-}
-
-void nsStorageInputStream::Serialize(InputStreamParams& aParams,
-                                     FileDescriptorArray&, bool aDelayedStart,
-                                     uint32_t aMaxSize, uint32_t* aSizeUsed,
-                                     mozilla::dom::ContentParent* aManager) {
+void nsStorageInputStream::Serialize(
+    InputStreamParams& aParams, FileDescriptorArray&, bool aDelayedStart,
+    uint32_t aMaxSize, uint32_t* aSizeUsed,
+    mozilla::ipc::ParentToChildStreamActorManager* aManager) {
   SerializeInternal(aParams, aDelayedStart, aMaxSize, aSizeUsed, aManager);
 }
 
 void nsStorageInputStream::Serialize(
     InputStreamParams& aParams, FileDescriptorArray&, bool aDelayedStart,
     uint32_t aMaxSize, uint32_t* aSizeUsed,
-    mozilla::ipc::PBackgroundParent* aManager) {
+    mozilla::ipc::ChildToParentStreamActorManager* aManager) {
   SerializeInternal(aParams, aDelayedStart, aMaxSize, aSizeUsed, aManager);
 }
 
 template <typename M>
 void nsStorageInputStream::SerializeInternal(InputStreamParams& aParams,
                                              bool aDelayedStart,
                                              uint32_t aMaxSize,
                                              uint32_t* aSizeUsed, M* aManager) {
--- a/xpcom/io/nsStringStream.cpp
+++ b/xpcom/io/nsStringStream.cpp
@@ -384,45 +384,27 @@ nsStringInputStream::Tell(int64_t* aOutW
   *aOutWhere = mOffset;
   return NS_OK;
 }
 
 /////////
 // nsIIPCSerializableInputStream implementation
 /////////
 
-void nsStringInputStream::Serialize(InputStreamParams& aParams,
-                                    FileDescriptorArray& /* aFDs */,
-                                    bool aDelayedStart, uint32_t aMaxSize,
-                                    uint32_t* aSizeUsed,
-                                    mozilla::dom::ContentChild* aManager) {
+void nsStringInputStream::Serialize(
+    InputStreamParams& aParams, FileDescriptorArray& /* aFDs */,
+    bool aDelayedStart, uint32_t aMaxSize, uint32_t* aSizeUsed,
+    mozilla::ipc::ParentToChildStreamActorManager* aManager) {
   SerializeInternal(aParams, aDelayedStart, aMaxSize, aSizeUsed, aManager);
 }
 
-void nsStringInputStream::Serialize(InputStreamParams& aParams,
-                                    FileDescriptorArray& /* aFDs */,
-                                    bool aDelayedStart, uint32_t aMaxSize,
-                                    uint32_t* aSizeUsed,
-                                    PBackgroundChild* aManager) {
-  SerializeInternal(aParams, aDelayedStart, aMaxSize, aSizeUsed, aManager);
-}
-
-void nsStringInputStream::Serialize(InputStreamParams& aParams,
-                                    FileDescriptorArray& /* aFDs */,
-                                    bool aDelayedStart, uint32_t aMaxSize,
-                                    uint32_t* aSizeUsed,
-                                    mozilla::dom::ContentParent* aManager) {
-  SerializeInternal(aParams, aDelayedStart, aMaxSize, aSizeUsed, aManager);
-}
-
-void nsStringInputStream::Serialize(InputStreamParams& aParams,
-                                    FileDescriptorArray& /* aFDs */,
-                                    bool aDelayedStart, uint32_t aMaxSize,
-                                    uint32_t* aSizeUsed,
-                                    PBackgroundParent* aManager) {
+void nsStringInputStream::Serialize(
+    InputStreamParams& aParams, FileDescriptorArray& /* aFDs */,
+    bool aDelayedStart, uint32_t aMaxSize, uint32_t* aSizeUsed,
+    mozilla::ipc::ChildToParentStreamActorManager* aManager) {
   SerializeInternal(aParams, aDelayedStart, aMaxSize, aSizeUsed, aManager);
 }
 
 template <typename M>
 void nsStringInputStream::SerializeInternal(InputStreamParams& aParams,
                                             bool aDelayedStart,
                                             uint32_t aMaxSize,
                                             uint32_t* aSizeUsed, M* aManager) {
--- a/xpcom/tests/gtest/TestNonBlockingAsyncInputStream.cpp
+++ b/xpcom/tests/gtest/TestNonBlockingAsyncInputStream.cpp
@@ -269,25 +269,21 @@ class QIInputStream final : public nsIIn
   // nsICloneableInputStream
   NS_IMETHOD GetCloneable(bool*) override { return NS_ERROR_NOT_IMPLEMENTED; }
   NS_IMETHOD Clone(nsIInputStream**) override {
     return NS_ERROR_NOT_IMPLEMENTED;
   }
 
   // nsIIPCSerializableInputStream
   void Serialize(mozilla::ipc::InputStreamParams&, FileDescriptorArray&, bool,
-                 uint32_t, uint32_t*, mozilla::dom::ContentChild*) override {}
+                 uint32_t, uint32_t*,
+                 mozilla::ipc::ParentToChildStreamActorManager*) override {}
   void Serialize(mozilla::ipc::InputStreamParams&, FileDescriptorArray&, bool,
                  uint32_t, uint32_t*,
-                 mozilla::ipc::PBackgroundChild*) override {}
-  void Serialize(mozilla::ipc::InputStreamParams&, FileDescriptorArray&, bool,
-                 uint32_t, uint32_t*, mozilla::dom::ContentParent*) override {}
-  void Serialize(mozilla::ipc::InputStreamParams&, FileDescriptorArray&, bool,
-                 uint32_t, uint32_t*,
-                 mozilla::ipc::PBackgroundParent*) override {}
+                 mozilla::ipc::ChildToParentStreamActorManager*) override {}
   bool Deserialize(const mozilla::ipc::InputStreamParams&,
                    const FileDescriptorArray&) override {
     return false;
   }
 
   // nsISeekableStream
   NS_IMETHOD Seek(int32_t, int64_t) override {
     return NS_ERROR_NOT_IMPLEMENTED;