diff --git a/dom/file/TemporaryFileBlobImpl.cpp b/dom/file/TemporaryFileBlobImpl.cpp index 91fca9e4736b..c563b3587d5e 100644 --- a/dom/file/TemporaryFileBlobImpl.cpp +++ b/dom/file/TemporaryFileBlobImpl.cpp @@ -53,28 +53,14 @@ class TemporaryFileInputStream final : public nsFileInputStream { 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."); } diff --git a/dom/file/ipc/IPCBlobInputStream.cpp b/dom/file/ipc/IPCBlobInputStream.cpp index b924b685a99d..655b0b6c6f15 100644 --- a/dom/file/ipc/IPCBlobInputStream.cpp +++ b/dom/file/ipc/IPCBlobInputStream.cpp @@ -563,44 +563,22 @@ IPCBlobInputStream::OnInputStreamReady(nsIAsyncInputStream* aStream) { // 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; diff --git a/dom/indexedDB/FileSnapshot.cpp b/dom/indexedDB/FileSnapshot.cpp index fffb2956710b..09e11520cbca 100644 --- a/dom/indexedDB/FileSnapshot.cpp +++ b/dom/indexedDB/FileSnapshot.cpp @@ -271,23 +271,8 @@ StreamWrapper::IsNonBlocking(bool* _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); } @@ -296,7 +281,7 @@ 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); } diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index bb539324ec6d..e4a9df755e0a 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -247,7 +247,6 @@ #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" @@ -1949,6 +1948,8 @@ void ContentChild::GetAvailableDictionaries(nsTArray& aDictionaries) { PFileDescriptorSetChild* ContentChild::SendPFileDescriptorSetConstructor( const FileDescriptor& aFD) { + MOZ_ASSERT(NS_IsMainThread()); + if (IsShuttingDown()) { return nullptr; } @@ -2195,6 +2196,8 @@ bool ContentChild::DeallocPPrintingChild(PPrintingChild* printing) { PChildToParentStreamChild* ContentChild::SendPChildToParentStreamConstructor( PChildToParentStreamChild* aActor) { + MOZ_ASSERT(NS_IsMainThread()); + if (IsShuttingDown()) { return nullptr; } diff --git a/dom/ipc/ContentChild.h b/dom/ipc/ContentChild.h index fc07bf4504bc..c8cc74f120d8 100644 --- a/dom/ipc/ContentChild.h +++ b/dom/ipc/ContentChild.h @@ -16,6 +16,7 @@ #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" @@ -76,10 +77,12 @@ 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; @@ -255,9 +258,6 @@ class ContentChild final : public PContentChild, bool DeallocPPrintingChild(PPrintingChild*); - PChildToParentStreamChild* SendPChildToParentStreamConstructor( - PChildToParentStreamChild*); - PChildToParentStreamChild* AllocPChildToParentStreamChild(); bool DeallocPChildToParentStreamChild(PChildToParentStreamChild*); @@ -502,9 +502,6 @@ class ContentChild final : public PContentChild, bool IsForBrowser() const { return mIsForBrowser; } - PFileDescriptorSetChild* SendPFileDescriptorSetConstructor( - const FileDescriptor&); - PFileDescriptorSetChild* AllocPFileDescriptorSetChild(const FileDescriptor&); bool DeallocPFileDescriptorSetChild(PFileDescriptorSetChild*); @@ -706,6 +703,11 @@ class ContentChild final : public PContentChild, Endpoint&& aEndpoint); #endif + PChildToParentStreamChild* SendPChildToParentStreamConstructor( + PChildToParentStreamChild* aActor) override; + PFileDescriptorSetChild* SendPFileDescriptorSetConstructor( + const FileDescriptor& aFD) override; + private: static void ForceKillTimerCallback(nsITimer* aTimer, void* aClosure); void StartForceKillTimer(); diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 09e2180070fd..4ceb79f0f2c8 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -6112,6 +6112,19 @@ mozilla::ipc::IPCResult ContentParent::RecvCommitBrowsingContextTransaction( 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 diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h index cc6e12537f97..0838bf070a6c 100644 --- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -15,6 +15,7 @@ #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" @@ -127,18 +128,20 @@ struct CancelContentJSOptions; } \ } -class ContentParent final : public PContentParent, - public nsIObserver, - public nsIDOMGeoPositionCallback, - public nsIDOMGeoPositionErrorCallback, - public nsIInterfaceRequestor, - public gfx::gfxVarReceiver, - public mozilla::LinkedListElement, - 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, + 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; @@ -650,6 +653,11 @@ class ContentParent final : public PContentParent, 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; diff --git a/ipc/glue/BackgroundChildImpl.cpp b/ipc/glue/BackgroundChildImpl.cpp index cac8547a7c98..6cb440f328a9 100644 --- a/ipc/glue/BackgroundChildImpl.cpp +++ b/ipc/glue/BackgroundChildImpl.cpp @@ -758,6 +758,17 @@ bool BackgroundChildImpl::DeallocPMediaTransportChild( 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 diff --git a/ipc/glue/BackgroundChildImpl.h b/ipc/glue/BackgroundChildImpl.h index 88b360b31567..280826cf4b60 100644 --- a/ipc/glue/BackgroundChildImpl.h +++ b/ipc/glue/BackgroundChildImpl.h @@ -8,6 +8,7 @@ #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" @@ -28,7 +29,8 @@ 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; @@ -39,6 +41,11 @@ class BackgroundChildImpl : public PBackgroundChild { // 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(); diff --git a/ipc/glue/BackgroundParentImpl.cpp b/ipc/glue/BackgroundParentImpl.cpp index 6b929a3d99ba..04bf13a4c154 100644 --- a/ipc/glue/BackgroundParentImpl.cpp +++ b/ipc/glue/BackgroundParentImpl.cpp @@ -1310,6 +1310,18 @@ bool BackgroundParentImpl::DeallocPMediaTransportParent( 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 diff --git a/ipc/glue/BackgroundParentImpl.h b/ipc/glue/BackgroundParentImpl.h index 580f5c421ce0..94964b43c29a 100644 --- a/ipc/glue/BackgroundParentImpl.h +++ b/ipc/glue/BackgroundParentImpl.h @@ -8,6 +8,7 @@ #define mozilla_ipc_backgroundparentimpl_h__ #include "mozilla/Attributes.h" +#include "mozilla/ipc/InputStreamUtils.h" #include "mozilla/ipc/PBackgroundParent.h" namespace mozilla { @@ -20,7 +21,14 @@ 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(); diff --git a/ipc/glue/FileDescriptorSetChild.h b/ipc/glue/FileDescriptorSetChild.h index 41be28d7daee..d3c882775195 100644 --- a/ipc/glue/FileDescriptorSetChild.h +++ b/ipc/glue/FileDescriptorSetChild.h @@ -20,6 +20,12 @@ class ContentChild; } // namespace dom +namespace net { + +class SocketProcessChild; + +} // namespace net + namespace ipc { class BackgroundChildImpl; @@ -28,6 +34,7 @@ class FileDescriptor; class FileDescriptorSetChild final : public PFileDescriptorSetChild { friend class BackgroundChildImpl; friend class mozilla::dom::ContentChild; + friend class mozilla::net::SocketProcessChild; friend class PFileDescriptorSetChild; nsTArray mFileDescriptors; diff --git a/ipc/glue/FileDescriptorSetParent.h b/ipc/glue/FileDescriptorSetParent.h index 48b6f3076e04..0510f4982b9e 100644 --- a/ipc/glue/FileDescriptorSetParent.h +++ b/ipc/glue/FileDescriptorSetParent.h @@ -20,6 +20,12 @@ class ContentParent; } // namespace dom +namespace net { + +class SocketProcessParent; + +} // namespace net + namespace ipc { class BackgroundParentImpl; @@ -28,6 +34,7 @@ class FileDescriptor; class FileDescriptorSetParent final : public PFileDescriptorSetParent { friend class BackgroundParentImpl; friend class mozilla::dom::ContentParent; + friend class mozilla::net::SocketProcessParent; friend class PFileDescriptorSetParent; nsTArray mFileDescriptors; diff --git a/ipc/glue/IPCStreamChild.cpp b/ipc/glue/IPCStreamChild.cpp index 3041cf12ea4e..8d159b44773d 100644 --- a/ipc/glue/IPCStreamChild.cpp +++ b/ipc/glue/IPCStreamChild.cpp @@ -8,8 +8,6 @@ #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" @@ -68,29 +66,8 @@ class IPCStreamSourceChild final : public PChildToParentStreamChild, /* 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); diff --git a/ipc/glue/IPCStreamParent.cpp b/ipc/glue/IPCStreamParent.cpp index 3369940658df..e615d290ad37 100644 --- a/ipc/glue/IPCStreamParent.cpp +++ b/ipc/glue/IPCStreamParent.cpp @@ -5,8 +5,6 @@ * 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" @@ -66,30 +64,8 @@ class IPCStreamSourceParent final : public PParentToChildStreamParent, /* 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); diff --git a/ipc/glue/IPCStreamSource.h b/ipc/glue/IPCStreamSource.h index 1623a3f18427..b4284a8a1269 100644 --- a/ipc/glue/IPCStreamSource.h +++ b/ipc/glue/IPCStreamSource.h @@ -14,19 +14,14 @@ 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; @@ -57,29 +52,17 @@ class PParentToChildStreamParent; // 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 ChildToParentStreamActorManager manager. + // This can return nullptr if the provided stream is blocking. + static PChildToParentStreamChild* Create( + nsIAsyncInputStream* aInputStream, + ChildToParentStreamActorManager* 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 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); diff --git a/ipc/glue/IPCStreamUtils.cpp b/ipc/glue/IPCStreamUtils.cpp index bce8b30c2560..fba98891fe2e 100644 --- a/ipc/glue/IPCStreamUtils.cpp +++ b/ipc/glue/IPCStreamUtils.cpp @@ -15,10 +15,12 @@ #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; @@ -355,6 +357,28 @@ bool AutoIPCStream::Serialize(nsIInputStream* aStream, return true; } + BackgroundChildImpl* impl = static_cast(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!"); @@ -397,6 +421,28 @@ bool AutoIPCStream::Serialize(nsIInputStream* aStream, return true; } + BackgroundParentImpl* impl = static_cast(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; diff --git a/ipc/glue/IPCStreamUtils.h b/ipc/glue/IPCStreamUtils.h index 81623cdbfcc5..d30cd4738321 100644 --- a/ipc/glue/IPCStreamUtils.h +++ b/ipc/glue/IPCStreamUtils.h @@ -18,6 +18,11 @@ class ContentChild; class ContentParent; } // namespace dom +namespace net { +class SocketProcessParent; +class SocketProcessChild; +} // namespace net + namespace ipc { class PBackgroundChild; @@ -153,6 +158,11 @@ class AutoIPCStream { // 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); @@ -161,6 +171,10 @@ class AutoIPCStream { 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 diff --git a/ipc/glue/InputStreamUtils.cpp b/ipc/glue/InputStreamUtils.cpp index 6097c2b1d5d1..77882bf9c231 100644 --- a/ipc/glue/InputStreamUtils.cpp +++ b/ipc/glue/InputStreamUtils.cpp @@ -120,7 +120,8 @@ void SerializeInputStreamAsPipeInternal(nsIInputStream* aInputStream, void InputStreamHelper::SerializeInputStream( nsIInputStream* aInputStream, InputStreamParams& aParams, nsTArray& aFileDescriptors, bool aDelayedStart, - uint32_t aMaxSize, uint32_t* aSizeUsed, ContentChild* aManager) { + uint32_t aMaxSize, uint32_t* aSizeUsed, + ParentToChildStreamActorManager* aManager) { SerializeInputStreamInternal(aInputStream, aParams, aFileDescriptors, aDelayedStart, aMaxSize, aSizeUsed, aManager); } @@ -128,54 +129,22 @@ void InputStreamHelper::SerializeInputStream( void InputStreamHelper::SerializeInputStream( nsIInputStream* aInputStream, InputStreamParams& aParams, nsTArray& aFileDescriptors, bool aDelayedStart, - uint32_t aMaxSize, uint32_t* aSizeUsed, PBackgroundChild* aManager) { + uint32_t aMaxSize, uint32_t* aSizeUsed, + ChildToParentStreamActorManager* aManager) { SerializeInputStreamInternal(aInputStream, aParams, aFileDescriptors, aDelayedStart, aMaxSize, aSizeUsed, aManager); } -void InputStreamHelper::SerializeInputStream( +void InputStreamHelper::SerializeInputStreamAsPipe( nsIInputStream* aInputStream, InputStreamParams& aParams, - nsTArray& aFileDescriptors, bool aDelayedStart, - uint32_t aMaxSize, uint32_t* aSizeUsed, ContentParent* aManager) { - SerializeInputStreamInternal(aInputStream, aParams, aFileDescriptors, - aDelayedStart, aMaxSize, aSizeUsed, aManager); -} - -void InputStreamHelper::SerializeInputStream( - nsIInputStream* aInputStream, InputStreamParams& aParams, - nsTArray& aFileDescriptors, bool aDelayedStart, - uint32_t aMaxSize, uint32_t* aSizeUsed, PBackgroundParent* 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) { + 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); } diff --git a/ipc/glue/InputStreamUtils.h b/ipc/glue/InputStreamUtils.h index 5268185da1f0..4fafa5bb1aa2 100644 --- a/ipc/glue/InputStreamUtils.h +++ b/ipc/glue/InputStreamUtils.h @@ -16,11 +16,33 @@ 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 @@ -34,50 +56,24 @@ class InputStreamHelper { nsTArray& aFileDescriptors, bool aDelayedStart, uint32_t aMaxSize, uint32_t* aSizeUsed, - mozilla::dom::ContentChild* aManager); + ParentToChildStreamActorManager* aManager); static void SerializeInputStream(nsIInputStream* aInputStream, InputStreamParams& aParams, nsTArray& aFileDescriptors, bool aDelayedStart, uint32_t aMaxSize, uint32_t* aSizeUsed, - PBackgroundChild* aManager); - - static void SerializeInputStream(nsIInputStream* aInputStream, - InputStreamParams& aParams, - nsTArray& aFileDescriptors, - bool aDelayedStart, uint32_t aMaxSize, - uint32_t* aSizeUsed, - mozilla::dom::ContentParent* aManager); - - static void SerializeInputStream(nsIInputStream* aInputStream, - InputStreamParams& aParams, - nsTArray& 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, ParentToChildStreamActorManager* aManager); - static void SerializeInputStreamAsPipe(nsIInputStream* aInputStream, - InputStreamParams& aParams, - bool aDelayedStart, - PBackgroundChild* 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). diff --git a/ipc/glue/PChildToParentStream.ipdl b/ipc/glue/PChildToParentStream.ipdl index 1ca5e350b8d9..ac0e2ce14253 100644 --- a/ipc/glue/PChildToParentStream.ipdl +++ b/ipc/glue/PChildToParentStream.ipdl @@ -4,6 +4,7 @@ include protocol PBackground; include protocol PContent; +include protocol PSocketProcess; include "mozilla/layers/WebRenderMessageUtils.h"; @@ -16,7 +17,7 @@ namespace ipc { // protocols in sync. protocol PChildToParentStream { - manager PBackground or PContent; + manager PBackground or PContent or PSocketProcess; parent: async Buffer(ByteBuffer aBuffer); diff --git a/ipc/glue/PFileDescriptorSet.ipdl b/ipc/glue/PFileDescriptorSet.ipdl index ef366494fe3a..e56fa4885503 100644 --- a/ipc/glue/PFileDescriptorSet.ipdl +++ b/ipc/glue/PFileDescriptorSet.ipdl @@ -4,13 +4,14 @@ 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); diff --git a/ipc/glue/PParentToChildStream.ipdl b/ipc/glue/PParentToChildStream.ipdl index 181afa0535f6..6040dc8a98c6 100644 --- a/ipc/glue/PParentToChildStream.ipdl +++ b/ipc/glue/PParentToChildStream.ipdl @@ -4,6 +4,7 @@ include protocol PBackground; include protocol PContent; +include protocol PSocketProcess; include "mozilla/layers/WebRenderMessageUtils.h"; @@ -16,7 +17,7 @@ namespace ipc { // protocols in sync. protocol PParentToChildStream { - manager PBackground or PContent; + manager PBackground or PContent or PSocketProcess; child: async Buffer(ByteBuffer aBuffer); diff --git a/ipc/glue/nsIIPCSerializableInputStream.h b/ipc/glue/nsIIPCSerializableInputStream.h index bc5040af4ca3..459ba6518602 100644 --- a/ipc/glue/nsIIPCSerializableInputStream.h +++ b/ipc/glue/nsIIPCSerializableInputStream.h @@ -13,20 +13,12 @@ #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 @@ -45,29 +37,17 @@ class NS_NO_VTABLE nsIIPCSerializableInputStream : public nsISupports { 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::ParentToChildStreamActorManager* 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::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; @@ -76,118 +56,70 @@ class NS_NO_VTABLE nsIIPCSerializableInputStream : public nsISupports { 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 diff --git a/netwerk/base/PartiallySeekableInputStream.cpp b/netwerk/base/PartiallySeekableInputStream.cpp index 34674f1da1b3..5a0aaf21ebca 100644 --- a/netwerk/base/PartiallySeekableInputStream.cpp +++ b/netwerk/base/PartiallySeekableInputStream.cpp @@ -282,7 +282,7 @@ 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); } @@ -291,25 +291,7 @@ 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); } diff --git a/netwerk/base/nsBufferedStreams.cpp b/netwerk/base/nsBufferedStreams.cpp index 0e9e8348d46b..429f35c84407 100644 --- a/netwerk/base/nsBufferedStreams.cpp +++ b/netwerk/base/nsBufferedStreams.cpp @@ -590,38 +590,18 @@ nsBufferedInputStream::GetUnbufferedStream(nsISupports** 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); } diff --git a/netwerk/base/nsFileStreams.cpp b/netwerk/base/nsFileStreams.cpp index dbf32506cdfe..7f3ff2d9c673 100644 --- a/netwerk/base/nsFileStreams.cpp +++ b/netwerk/base/nsFileStreams.cpp @@ -544,7 +544,7 @@ 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; @@ -555,29 +555,7 @@ 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; diff --git a/netwerk/base/nsMIMEInputStream.cpp b/netwerk/base/nsMIMEInputStream.cpp index b423fd30fc6b..e43c7d3bea57 100644 --- a/netwerk/base/nsMIMEInputStream.cpp +++ b/netwerk/base/nsMIMEInputStream.cpp @@ -336,38 +336,18 @@ nsresult nsMIMEInputStreamConstructor(nsISupports* outer, REFNSIID iid, 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); } diff --git a/netwerk/ipc/PSocketProcess.ipdl b/netwerk/ipc/PSocketProcess.ipdl index 1ad1c9be9369..ef35c5bde6e7 100644 --- a/netwerk/ipc/PSocketProcess.ipdl +++ b/netwerk/ipc/PSocketProcess.ipdl @@ -7,6 +7,9 @@ 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; @@ -29,6 +32,9 @@ protocol PSocketProcess { manages PDNSRequest; manages PWebrtcTCPSocket; + manages PFileDescriptorSet; + manages PChildToParentStream; + manages PParentToChildStream; parent: async InitCrashReporter(Shmem shmem, NativeThreadId threadId); @@ -46,6 +52,7 @@ parent: async PWebrtcTCPSocket(TabId? tabId); async PDNSRequest(nsCString hostName, OriginAttributes originAttributes, uint32_t flags); + async PChildToParentStream(); child: async PreferenceUpdate(Pref pref); @@ -58,6 +65,10 @@ child: async InitProfiler(Endpoint aEndpoint); // test-only async SocketProcessTelemetryPing(); + async PParentToChildStream(); + +both: + async PFileDescriptorSet(FileDescriptor fd); }; } // namespace net diff --git a/netwerk/ipc/SocketProcessChild.cpp b/netwerk/ipc/SocketProcessChild.cpp index d827833730d0..69783f829284 100644 --- a/netwerk/ipc/SocketProcessChild.cpp +++ b/netwerk/ipc/SocketProcessChild.cpp @@ -10,8 +10,12 @@ #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" @@ -212,5 +216,51 @@ bool SocketProcessChild::DeallocPWebrtcTCPSocketChild( 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 diff --git a/netwerk/ipc/SocketProcessChild.h b/netwerk/ipc/SocketProcessChild.h index 9417716cfc7a..42ab390ee1ce 100644 --- a/netwerk/ipc/SocketProcessChild.h +++ b/netwerk/ipc/SocketProcessChild.h @@ -7,6 +7,7 @@ #define mozilla_net_SocketProcessChild_h #include "mozilla/net/PSocketProcessChild.h" +#include "mozilla/ipc/InputStreamUtils.h" #include "nsRefPtrHashtable.h" namespace mozilla { @@ -20,7 +21,9 @@ 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(); @@ -48,9 +51,23 @@ class SocketProcessChild final : public PSocketProcessChild { PWebrtcTCPSocketChild* AllocPWebrtcTCPSocketChild(const Maybe& 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. diff --git a/netwerk/ipc/SocketProcessParent.cpp b/netwerk/ipc/SocketProcessParent.cpp index 52d35450accb..b0301a2648d9 100644 --- a/netwerk/ipc/SocketProcessParent.cpp +++ b/netwerk/ipc/SocketProcessParent.cpp @@ -6,6 +6,7 @@ #include "SocketProcessParent.h" #include "SocketProcessHost.h" +#include "mozilla/ipc/FileDescriptorSetParent.h" #include "mozilla/net/DNSRequestParent.h" #include "mozilla/Telemetry.h" #include "mozilla/TelemetryIPC.h" @@ -156,6 +157,53 @@ mozilla::ipc::IPCResult SocketProcessParent::RecvPDNSRequestConstructor( return IPC_OK(); } +PFileDescriptorSetParent* SocketProcessParent::AllocPFileDescriptorSetParent( + const FileDescriptor& aFD) { + return new FileDescriptorSetParent(aFD); +} + +bool SocketProcessParent::DeallocPFileDescriptorSetParent( + PFileDescriptorSetParent* aActor) { + delete static_cast(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: diff --git a/netwerk/ipc/SocketProcessParent.h b/netwerk/ipc/SocketProcessParent.h index b4e6d95fdc33..8208e79c5000 100644 --- a/netwerk/ipc/SocketProcessParent.h +++ b/netwerk/ipc/SocketProcessParent.h @@ -8,6 +8,7 @@ #include "mozilla/UniquePtr.h" #include "mozilla/ipc/CrashReporterHelper.h" +#include "mozilla/ipc/InputStreamUtils.h" #include "mozilla/net/PSocketProcessParent.h" namespace mozilla { @@ -29,7 +30,8 @@ class SocketProcessHost; // by SocketProcessHost. class SocketProcessParent final : public PSocketProcessParent, - public ipc::CrashReporterHelper { + public ipc::CrashReporterHelper, + public ipc::ParentToChildStreamActorManager { public: friend class SocketProcessHost; @@ -70,6 +72,20 @@ class SocketProcessParent final const bool& aMinimizeMemoryUsage, const Maybe& 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 mMemoryReportRequest; diff --git a/xpcom/io/InputStreamLengthWrapper.cpp b/xpcom/io/InputStreamLengthWrapper.cpp index 6d56ae541b1b..4014e907688e 100644 --- a/xpcom/io/InputStreamLengthWrapper.cpp +++ b/xpcom/io/InputStreamLengthWrapper.cpp @@ -260,7 +260,7 @@ 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); } @@ -269,25 +269,7 @@ 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); } diff --git a/xpcom/io/NonBlockingAsyncInputStream.cpp b/xpcom/io/NonBlockingAsyncInputStream.cpp index f7991cc0d408..d861072d0b9d 100644 --- a/xpcom/io/NonBlockingAsyncInputStream.cpp +++ b/xpcom/io/NonBlockingAsyncInputStream.cpp @@ -321,7 +321,7 @@ 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); } @@ -330,25 +330,7 @@ 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); } diff --git a/xpcom/io/SlicedInputStream.cpp b/xpcom/io/SlicedInputStream.cpp index bc1fa637d358..e769b1cb6b69 100644 --- a/xpcom/io/SlicedInputStream.cpp +++ b/xpcom/io/SlicedInputStream.cpp @@ -420,38 +420,20 @@ SlicedInputStream::OnInputStreamReady(nsIAsyncInputStream* aStream) { // 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); } diff --git a/xpcom/io/nsMultiplexInputStream.cpp b/xpcom/io/nsMultiplexInputStream.cpp index 1f6887d30309..0c6a2dd76a3e 100644 --- a/xpcom/io/nsMultiplexInputStream.cpp +++ b/xpcom/io/nsMultiplexInputStream.cpp @@ -990,38 +990,18 @@ nsresult nsMultiplexInputStreamConstructor(nsISupports* aOuter, REFNSIID aIID, 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); } diff --git a/xpcom/io/nsStorageStream.cpp b/xpcom/io/nsStorageStream.cpp index 47c2d518e879..db83213b8e4a 100644 --- a/xpcom/io/nsStorageStream.cpp +++ b/xpcom/io/nsStorageStream.cpp @@ -550,31 +550,17 @@ nsresult nsStorageInputStream::Seek(uint32_t 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); } diff --git a/xpcom/io/nsStringStream.cpp b/xpcom/io/nsStringStream.cpp index 027f9f7c5a1e..449e392607a8 100644 --- a/xpcom/io/nsStringStream.cpp +++ b/xpcom/io/nsStringStream.cpp @@ -389,35 +389,17 @@ nsStringInputStream::Tell(int64_t* aOutWhere) { // 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); } diff --git a/xpcom/tests/gtest/TestNonBlockingAsyncInputStream.cpp b/xpcom/tests/gtest/TestNonBlockingAsyncInputStream.cpp index d4c27f59d952..f808ab3b6493 100644 --- a/xpcom/tests/gtest/TestNonBlockingAsyncInputStream.cpp +++ b/xpcom/tests/gtest/TestNonBlockingAsyncInputStream.cpp @@ -274,15 +274,11 @@ class QIInputStream final : public nsIInputStream, // 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;