From f7cb24cc7e44cfa64adf197af98fd5cfeb292df2 Mon Sep 17 00:00:00 2001 From: Razvan Maries Date: Mon, 29 Jun 2020 13:59:16 +0300 Subject: [PATCH] Backed out 8 changesets (bug 1648141) for build bustages on RemoteLazyInputStreamThread.cpp. CLOSED TREE Backed out changeset e9b4ca0ee700 (bug 1648141) Backed out changeset b9bb847cee47 (bug 1648141) Backed out changeset 11dfce46ec14 (bug 1648141) Backed out changeset d824d2f67f27 (bug 1648141) Backed out changeset e5b8292e7095 (bug 1648141) Backed out changeset c1a3d5fa0c61 (bug 1648141) Backed out changeset 24fdb83db3cd (bug 1648141) Backed out changeset 749d894dde52 (bug 1648141) --- build/clang-plugin/ThreadAllows.txt | 2 +- dom/broadcastchannel/PBroadcastChannel.ipdl | 2 +- dom/clients/manager/PClientHandle.ipdl | 2 +- dom/clients/manager/PClientManager.ipdl | 2 +- dom/clients/manager/PClientSource.ipdl | 2 +- dom/fetch/FetchTypes.ipdlh | 6 +- dom/fetch/InternalRequest.cpp | 4 +- dom/fetch/InternalResponse.cpp | 4 +- dom/file/TemporaryFileBlobImpl.cpp | 8 +- dom/file/ipc/IPCBlob.ipdlh | 25 ++- ...InputStream.cpp => IPCBlobInputStream.cpp} | 147 +++++++++--------- ...LazyInputStream.h => IPCBlobInputStream.h} | 36 +++-- ...mChild.cpp => IPCBlobInputStreamChild.cpp} | 110 +++++++------ ...treamChild.h => IPCBlobInputStreamChild.h} | 43 +++-- ...arent.cpp => IPCBlobInputStreamParent.cpp} | 104 ++++++------- ...eamParent.h => IPCBlobInputStreamParent.h} | 49 +++--- ...rage.cpp => IPCBlobInputStreamStorage.cpp} | 51 +++--- ...mStorage.h => IPCBlobInputStreamStorage.h} | 24 +-- ...hread.cpp => IPCBlobInputStreamThread.cpp} | 101 ++++++------ ...eamThread.h => IPCBlobInputStreamThread.h} | 28 ++-- dom/file/ipc/IPCBlobUtils.cpp | 125 +++++++++++++-- dom/file/ipc/IPCBlobUtils.h | 122 ++++++++------- dom/file/ipc/PFileCreator.ipdl | 2 +- ...utStream.ipdl => PIPCBlobInputStream.ipdl} | 5 +- dom/file/ipc/PTemporaryIPCBlob.ipdl | 2 +- dom/file/ipc/RemoteLazyInputStreamUtils.cpp | 119 -------------- dom/file/ipc/RemoteLazyInputStreamUtils.h | 54 ------- dom/file/ipc/moz.build | 27 ++-- ...tStream.idl => mozIIPCBlobInputStream.idl} | 5 +- dom/filehandle/PBackgroundFileHandle.ipdl | 2 +- dom/filesystem/PFileSystemRequest.ipdl | 2 +- dom/indexedDB/ActorsChild.cpp | 5 +- dom/indexedDB/ActorsParent.cpp | 27 ++-- dom/indexedDB/PBackgroundIDBCursor.ipdl | 2 +- dom/indexedDB/PBackgroundIDBDatabase.ipdl | 2 +- dom/indexedDB/PBackgroundIDBRequest.ipdl | 2 +- dom/indexedDB/PBackgroundIDBSharedTypes.ipdlh | 2 +- ...BackgroundIDBVersionChangeTransaction.ipdl | 2 +- dom/ipc/ContentChild.cpp | 12 +- dom/ipc/ContentChild.h | 4 +- dom/ipc/ContentParent.cpp | 2 +- dom/ipc/DOMTypes.ipdlh | 4 +- dom/ipc/PBrowser.ipdl | 2 +- dom/ipc/PContent.ipdl | 6 +- dom/ipc/PFilePicker.ipdl | 2 +- dom/localstorage/LSObject.cpp | 48 +++--- dom/localstorage/LocalStorageCommon.h | 37 +++-- dom/localstorage/LocalStorageManager2.cpp | 15 +- dom/localstorage/PBackgroundLSRequest.ipdl | 3 +- dom/messagechannel/PMessagePort.ipdl | 2 +- .../FetchEventOpProxyParent.cpp | 21 ++- .../ServiceWorkerPrivateImpl.cpp | 6 +- .../test_fileReaderSync_when_closing.html | 4 +- gfx/thebes/gfxPlatformFontList.cpp | 6 +- ipc/glue/BackgroundChildImpl.cpp | 13 +- ipc/glue/BackgroundChildImpl.h | 6 +- ipc/glue/BackgroundParentImpl.cpp | 19 +-- ipc/glue/BackgroundParentImpl.h | 10 +- ipc/glue/InputStreamParams.ipdlh | 12 +- ipc/glue/InputStreamUtils.cpp | 37 ++--- ipc/glue/PBackground.ipdl | 10 +- layout/build/nsLayoutStatics.cpp | 4 +- netwerk/base/nsIFileStreams.idl | 2 +- netwerk/ipc/PSocketProcess.ipdl | 6 +- netwerk/ipc/SocketProcessChild.cpp | 12 +- netwerk/ipc/SocketProcessChild.h | 4 +- netwerk/ipc/SocketProcessParent.cpp | 19 ++- netwerk/ipc/SocketProcessParent.h | 8 +- netwerk/protocol/http/HttpBaseChannel.cpp | 15 +- .../webrequest/WebRequestUpload.jsm | 2 +- xpcom/io/nsICloneableInputStream.idl | 2 +- 71 files changed, 763 insertions(+), 849 deletions(-) rename dom/file/ipc/{RemoteLazyInputStream.cpp => IPCBlobInputStream.cpp} (84%) rename dom/file/ipc/{RemoteLazyInputStream.h => IPCBlobInputStream.h} (78%) rename dom/file/ipc/{RemoteLazyInputStreamChild.cpp => IPCBlobInputStreamChild.cpp} (74%) rename dom/file/ipc/{RemoteLazyInputStreamChild.h => IPCBlobInputStreamChild.h} (67%) rename dom/file/ipc/{RemoteLazyInputStreamParent.cpp => IPCBlobInputStreamParent.cpp} (57%) rename dom/file/ipc/{RemoteLazyInputStreamParent.h => IPCBlobInputStreamParent.h} (58%) rename dom/file/ipc/{RemoteLazyInputStreamStorage.cpp => IPCBlobInputStreamStorage.cpp} (74%) rename dom/file/ipc/{RemoteLazyInputStreamStorage.h => IPCBlobInputStreamStorage.h} (71%) rename dom/file/ipc/{RemoteLazyInputStreamThread.cpp => IPCBlobInputStreamThread.cpp} (58%) rename dom/file/ipc/{RemoteLazyInputStreamThread.h => IPCBlobInputStreamThread.h} (56%) rename dom/file/ipc/{PRemoteLazyInputStream.ipdl => PIPCBlobInputStream.ipdl} (94%) delete mode 100644 dom/file/ipc/RemoteLazyInputStreamUtils.cpp delete mode 100644 dom/file/ipc/RemoteLazyInputStreamUtils.h rename dom/file/ipc/{mozIRemoteLazyInputStream.idl => mozIIPCBlobInputStream.idl} (74%) diff --git a/build/clang-plugin/ThreadAllows.txt b/build/clang-plugin/ThreadAllows.txt index 9d732ea2ab7e..cb07842ba3be 100644 --- a/build/clang-plugin/ThreadAllows.txt +++ b/build/clang-plugin/ThreadAllows.txt @@ -22,6 +22,7 @@ Compositor Cookie CrashRep Inject DDMediaLogs +DOM File DOMCacheThread DataChannel IO DataStorage @@ -63,7 +64,6 @@ ProcessHangMon ProfSymbolTable ProfilerChild ProxyResolution -RemoteLzyStream RWLockTester RacingServMan RemVidChild diff --git a/dom/broadcastchannel/PBroadcastChannel.ipdl b/dom/broadcastchannel/PBroadcastChannel.ipdl index f82ddc44604d..2999e155340d 100644 --- a/dom/broadcastchannel/PBroadcastChannel.ipdl +++ b/dom/broadcastchannel/PBroadcastChannel.ipdl @@ -5,8 +5,8 @@ include protocol PBackground; include protocol PChildToParentStream; // FIXME: bug 792908 include protocol PFileDescriptorSet; // FIXME: bug 792908 +include protocol PIPCBlobInputStream; // FIXME: bug 792908 include protocol PParentToChildStream; // FIXME: bug 792908 -include protocol PRemoteLazyInputStream; // FIXME: bug 792908 include DOMTypes; diff --git a/dom/clients/manager/PClientHandle.ipdl b/dom/clients/manager/PClientHandle.ipdl index b68a31ef7761..1253653bdb21 100644 --- a/dom/clients/manager/PClientHandle.ipdl +++ b/dom/clients/manager/PClientHandle.ipdl @@ -4,10 +4,10 @@ include protocol PClientManager; include protocol PClientHandleOp; +include protocol PIPCBlobInputStream; include protocol PChildToParentStream; include protocol PParentToChildStream; include protocol PFileDescriptorSet; -include protocol PRemoteLazyInputStream; include ClientIPCTypes; namespace mozilla { diff --git a/dom/clients/manager/PClientManager.ipdl b/dom/clients/manager/PClientManager.ipdl index 0ce05980bedf..84646f46c83d 100644 --- a/dom/clients/manager/PClientManager.ipdl +++ b/dom/clients/manager/PClientManager.ipdl @@ -7,10 +7,10 @@ include protocol PClientHandle; include protocol PClientManagerOp; include protocol PClientNavigateOp; include protocol PClientSource; +include protocol PIPCBlobInputStream; include protocol PChildToParentStream; include protocol PParentToChildStream; include protocol PFileDescriptorSet; -include protocol PRemoteLazyInputStream; include ClientIPCTypes; namespace mozilla { diff --git a/dom/clients/manager/PClientSource.ipdl b/dom/clients/manager/PClientSource.ipdl index 84e3ae9bec0c..41d7cbad59ba 100644 --- a/dom/clients/manager/PClientSource.ipdl +++ b/dom/clients/manager/PClientSource.ipdl @@ -4,10 +4,10 @@ include protocol PClientManager; include protocol PClientSourceOp; +include protocol PIPCBlobInputStream; include protocol PChildToParentStream; include protocol PParentToChildStream; include protocol PFileDescriptorSet; -include protocol PRemoteLazyInputStream; include ClientIPCTypes; namespace mozilla { diff --git a/dom/fetch/FetchTypes.ipdlh b/dom/fetch/FetchTypes.ipdlh index e28b288a2b25..2ea46b1e1dd5 100644 --- a/dom/fetch/FetchTypes.ipdlh +++ b/dom/fetch/FetchTypes.ipdlh @@ -6,7 +6,7 @@ include IPCStream; include ChannelInfo; include PBackgroundSharedTypes; -include protocol PRemoteLazyInputStream; +include protocol PIPCBlobInputStream; using HeadersGuardEnum from "mozilla/dom/FetchIPCTypes.h"; using ReferrerPolicy from "mozilla/dom/FetchIPCTypes.h"; @@ -26,12 +26,12 @@ struct HeadersEntry { }; struct ParentToParentStream { - // Used as a key for RemoteLazyInputStreamStorage + // Used as a key for IPCBlobInputStreamStorage nsID uuid; }; struct ParentToChildStream { - PRemoteLazyInputStream actor; + PIPCBlobInputStream actor; }; struct ChildToParentStream { diff --git a/dom/fetch/InternalRequest.cpp b/dom/fetch/InternalRequest.cpp index 424fbbb24aa4..6424f8c7234a 100644 --- a/dom/fetch/InternalRequest.cpp +++ b/dom/fetch/InternalRequest.cpp @@ -9,12 +9,12 @@ #include "mozilla/ErrorResult.h" #include "mozilla/dom/Document.h" #include "mozilla/dom/FetchTypes.h" +#include "mozilla/dom/IPCBlobInputStreamChild.h" #include "mozilla/dom/ScriptSettings.h" #include "mozilla/dom/WorkerCommon.h" #include "mozilla/dom/WorkerPrivate.h" #include "mozilla/ipc/IPCStreamUtils.h" #include "mozilla/ipc/PBackgroundChild.h" -#include "mozilla/RemoteLazyInputStreamChild.h" #include "nsIContentPolicy.h" #include "nsStreamUtils.h" @@ -169,7 +169,7 @@ InternalRequest::InternalRequest(const IPCInternalRequest& aIPCRequest) // (constructed on the child side). if (body) { MOZ_ASSERT(body->type() == BodyStreamVariant::TParentToChildStream); - mBodyStream = static_cast( + mBodyStream = static_cast( body->get_ParentToChildStream().actorChild()) ->CreateStream(); } diff --git a/dom/fetch/InternalResponse.cpp b/dom/fetch/InternalResponse.cpp index ab80ab4fc7ab..b5a1ebe39550 100644 --- a/dom/fetch/InternalResponse.cpp +++ b/dom/fetch/InternalResponse.cpp @@ -9,12 +9,12 @@ #include "mozilla/Assertions.h" #include "mozilla/RefPtr.h" #include "mozilla/dom/FetchTypes.h" +#include "mozilla/dom/IPCBlobInputStreamStorage.h" #include "mozilla/dom/InternalHeaders.h" #include "mozilla/dom/cache/CacheTypes.h" #include "mozilla/ipc/PBackgroundSharedTypes.h" #include "mozilla/ipc/IPCStreamUtils.h" #include "mozilla/RandomNum.h" -#include "mozilla/RemoteLazyInputStreamStorage.h" #include "nsIRandomGenerator.h" #include "nsStreamUtils.h" @@ -32,7 +32,7 @@ nsCOMPtr TakeStreamFromStorage( MOZ_ASSERT(aVariant.type() == BodyStreamVariant::TParentToParentStream); const auto& uuid = aVariant.get_ParentToParentStream().uuid(); - auto stream = RemoteLazyInputStreamStorage::Get()->ForgetStream(uuid); + auto stream = IPCBlobInputStreamStorage::Get()->ForgetStream(uuid); MOZ_ASSERT(stream); return stream; diff --git a/dom/file/TemporaryFileBlobImpl.cpp b/dom/file/TemporaryFileBlobImpl.cpp index d491c8ac587d..51d0f128138a 100644 --- a/dom/file/TemporaryFileBlobImpl.cpp +++ b/dom/file/TemporaryFileBlobImpl.cpp @@ -6,7 +6,7 @@ #include "TemporaryFileBlobImpl.h" -#include "RemoteLazyInputStreamThread.h" +#include "IPCBlobInputStreamThread.h" #include "nsFileStreams.h" #include "nsIFile.h" #include "nsIFileStreams.h" @@ -76,9 +76,9 @@ class TemporaryFileInputStream final : public nsFileInputStream { } ~TemporaryFileInputStream() { - // Let's delete the file on the RemoteLazyInputStream Thread. - RefPtr thread = - RemoteLazyInputStreamThread::GetOrCreate(); + // Let's delete the file on the IPCBlob Thread. + RefPtr thread = + IPCBlobInputStreamThread::GetOrCreate(); if (NS_WARN_IF(!thread)) { return; } diff --git a/dom/file/ipc/IPCBlob.ipdlh b/dom/file/ipc/IPCBlob.ipdlh index 68654255e153..b485c0604800 100644 --- a/dom/file/ipc/IPCBlob.ipdlh +++ b/dom/file/ipc/IPCBlob.ipdlh @@ -4,7 +4,7 @@ include protocol PChildToParentStream; include protocol PParentToChildStream; -include protocol PRemoteLazyInputStream; +include protocol PIPCBlobInputStream; include IPCStream; include ProtocolTypes; @@ -13,17 +13,6 @@ using struct mozilla::void_t from "ipc/IPCMessageUtils.h"; namespace mozilla { - -union RemoteLazyStream -{ - // Parent to Child: The child will receive a RemoteLazyInputStream. Nothing - // can be done with it except retrieving the size. - PRemoteLazyInputStream; - - // Child to Parent: Normal serialization. - IPCStream; -}; - namespace dom { // This contains any extra bit for making a File out of a Blob. @@ -41,13 +30,23 @@ struct IPCFile bool isDirectory; }; +union IPCBlobStream +{ + // Parent to Child: The child will receive a IPCBlobInputStream. Nothing + // can be done with it except retrieving the size. + PIPCBlobInputStream; + + // Child to Parent: Normal serialization. + IPCStream; +}; + struct IPCBlob { nsString type; uint64_t size; nsString blobImplType; - RemoteLazyStream inputStream; + IPCBlobStream inputStream; // Nothing is for Blob IPCFile? file; diff --git a/dom/file/ipc/RemoteLazyInputStream.cpp b/dom/file/ipc/IPCBlobInputStream.cpp similarity index 84% rename from dom/file/ipc/RemoteLazyInputStream.cpp rename to dom/file/ipc/IPCBlobInputStream.cpp index 2794393c1dd8..531ff5858964 100644 --- a/dom/file/ipc/RemoteLazyInputStream.cpp +++ b/dom/file/ipc/IPCBlobInputStream.cpp @@ -4,28 +4,29 @@ * 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 "RemoteLazyInputStream.h" -#include "RemoteLazyInputStreamChild.h" -#include "RemoteLazyInputStreamParent.h" +#include "IPCBlobInputStream.h" +#include "IPCBlobInputStreamChild.h" +#include "IPCBlobInputStreamParent.h" +#include "IPCBlobInputStreamStorage.h" #include "mozilla/ipc/InputStreamParams.h" #include "mozilla/net/SocketProcessParent.h" #include "mozilla/SlicedInputStream.h" #include "mozilla/NonBlockingAsyncInputStream.h" +#include "IPCBlobInputStreamThread.h" #include "nsIAsyncInputStream.h" #include "nsIAsyncOutputStream.h" #include "nsIPipe.h" #include "nsNetUtil.h" #include "nsStreamUtils.h" #include "nsStringStream.h" -#include "RemoteLazyInputStreamStorage.h" -#include "RemoteLazyInputStreamThread.h" namespace mozilla { -using namespace dom; using net::SocketProcessParent; -class RemoteLazyInputStream; +namespace dom { + +class IPCBlobInputStream; namespace { @@ -35,7 +36,7 @@ class InputStreamCallbackRunnable final : public CancelableRunnable { // null. static void Execute(nsIInputStreamCallback* aCallback, nsIEventTarget* aEventTarget, - RemoteLazyInputStream* aStream) { + IPCBlobInputStream* aStream) { MOZ_ASSERT(aCallback); RefPtr runnable = @@ -59,7 +60,7 @@ class InputStreamCallbackRunnable final : public CancelableRunnable { private: InputStreamCallbackRunnable(nsIInputStreamCallback* aCallback, - RemoteLazyInputStream* aStream) + IPCBlobInputStream* aStream) : CancelableRunnable("dom::InputStreamCallbackRunnable"), mCallback(aCallback), mStream(aStream) { @@ -68,14 +69,14 @@ class InputStreamCallbackRunnable final : public CancelableRunnable { } nsCOMPtr mCallback; - RefPtr mStream; + RefPtr mStream; }; class FileMetadataCallbackRunnable final : public CancelableRunnable { public: static void Execute(nsIFileMetadataCallback* aCallback, nsIEventTarget* aEventTarget, - RemoteLazyInputStream* aStream) { + IPCBlobInputStream* aStream) { MOZ_ASSERT(aCallback); MOZ_ASSERT(aEventTarget); @@ -96,7 +97,7 @@ class FileMetadataCallbackRunnable final : public CancelableRunnable { private: FileMetadataCallbackRunnable(nsIFileMetadataCallback* aCallback, - RemoteLazyInputStream* aStream) + IPCBlobInputStream* aStream) : CancelableRunnable("dom::FileMetadataCallbackRunnable"), mCallback(aCallback), mStream(aStream) { @@ -105,15 +106,15 @@ class FileMetadataCallbackRunnable final : public CancelableRunnable { } nsCOMPtr mCallback; - RefPtr mStream; + RefPtr mStream; }; } // namespace -NS_IMPL_ADDREF(RemoteLazyInputStream); -NS_IMPL_RELEASE(RemoteLazyInputStream); +NS_IMPL_ADDREF(IPCBlobInputStream); +NS_IMPL_RELEASE(IPCBlobInputStream); -NS_INTERFACE_MAP_BEGIN(RemoteLazyInputStream) +NS_INTERFACE_MAP_BEGIN(IPCBlobInputStream) NS_INTERFACE_MAP_ENTRY(nsIInputStream) NS_INTERFACE_MAP_ENTRY(nsIAsyncInputStream) NS_INTERFACE_MAP_ENTRY(nsIInputStreamCallback) @@ -124,25 +125,25 @@ NS_INTERFACE_MAP_BEGIN(RemoteLazyInputStream) NS_INTERFACE_MAP_ENTRY(nsIAsyncFileMetadata) NS_INTERFACE_MAP_ENTRY(nsIInputStreamLength) NS_INTERFACE_MAP_ENTRY(nsIAsyncInputStreamLength) - NS_INTERFACE_MAP_ENTRY(mozIRemoteLazyInputStream) + NS_INTERFACE_MAP_ENTRY(mozIIPCBlobInputStream) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIInputStream) NS_INTERFACE_MAP_END -RemoteLazyInputStream::RemoteLazyInputStream(RemoteLazyInputStreamChild* aActor) +IPCBlobInputStream::IPCBlobInputStream(IPCBlobInputStreamChild* aActor) : mActor(aActor), mState(eInit), mStart(0), mLength(0), mConsumed(false), - mMutex("RemoteLazyInputStream::mMutex") { + mMutex("IPCBlobInputStream::mMutex") { MOZ_ASSERT(aActor); mLength = aActor->Size(); if (XRE_IsParentProcess()) { nsCOMPtr stream; - RemoteLazyInputStreamStorage::Get()->GetStream(mActor->ID(), 0, mLength, - getter_AddRefs(stream)); + IPCBlobInputStreamStorage::Get()->GetStream(mActor->ID(), 0, mLength, + getter_AddRefs(stream)); if (stream) { mState = eRunning; mRemoteStream = stream; @@ -150,12 +151,12 @@ RemoteLazyInputStream::RemoteLazyInputStream(RemoteLazyInputStreamChild* aActor) } } -RemoteLazyInputStream::~RemoteLazyInputStream() { Close(); } +IPCBlobInputStream::~IPCBlobInputStream() { Close(); } // nsIInputStream interface NS_IMETHODIMP -RemoteLazyInputStream::Available(uint64_t* aLength) { +IPCBlobInputStream::Available(uint64_t* aLength) { nsCOMPtr asyncRemoteStream; { MutexAutoLock lock(mMutex); @@ -186,8 +187,7 @@ RemoteLazyInputStream::Available(uint64_t* aLength) { } NS_IMETHODIMP -RemoteLazyInputStream::Read(char* aBuffer, uint32_t aCount, - uint32_t* aReadCount) { +IPCBlobInputStream::Read(char* aBuffer, uint32_t aCount, uint32_t* aReadCount) { nsCOMPtr asyncRemoteStream; { MutexAutoLock lock(mMutex); @@ -227,8 +227,8 @@ RemoteLazyInputStream::Read(char* aBuffer, uint32_t aCount, } NS_IMETHODIMP -RemoteLazyInputStream::ReadSegments(nsWriteSegmentFun aWriter, void* aClosure, - uint32_t aCount, uint32_t* aResult) { +IPCBlobInputStream::ReadSegments(nsWriteSegmentFun aWriter, void* aClosure, + uint32_t aCount, uint32_t* aResult) { nsCOMPtr asyncRemoteStream; { MutexAutoLock lock(mMutex); @@ -270,13 +270,13 @@ RemoteLazyInputStream::ReadSegments(nsWriteSegmentFun aWriter, void* aClosure, } NS_IMETHODIMP -RemoteLazyInputStream::IsNonBlocking(bool* aNonBlocking) { +IPCBlobInputStream::IsNonBlocking(bool* aNonBlocking) { *aNonBlocking = true; return NS_OK; } NS_IMETHODIMP -RemoteLazyInputStream::Close() { +IPCBlobInputStream::Close() { nsCOMPtr asyncRemoteStream; nsCOMPtr remoteStream; { @@ -313,14 +313,14 @@ RemoteLazyInputStream::Close() { // nsICloneableInputStream interface NS_IMETHODIMP -RemoteLazyInputStream::GetCloneable(bool* aCloneable) { +IPCBlobInputStream::GetCloneable(bool* aCloneable) { MutexAutoLock lock(mMutex); *aCloneable = mState != eClosed; return NS_OK; } NS_IMETHODIMP -RemoteLazyInputStream::Clone(nsIInputStream** aResult) { +IPCBlobInputStream::Clone(nsIInputStream** aResult) { MutexAutoLock lock(mMutex); if (mState == eClosed) { @@ -329,7 +329,7 @@ RemoteLazyInputStream::Clone(nsIInputStream** aResult) { MOZ_ASSERT(mActor); - RefPtr stream = mActor->CreateStream(); + RefPtr stream = mActor->CreateStream(); if (!stream) { return NS_ERROR_FAILURE; } @@ -343,8 +343,8 @@ RemoteLazyInputStream::Clone(nsIInputStream** aResult) { // nsICloneableInputStreamWithRange interface NS_IMETHODIMP -RemoteLazyInputStream::CloneWithRange(uint64_t aStart, uint64_t aLength, - nsIInputStream** aResult) { +IPCBlobInputStream::CloneWithRange(uint64_t aStart, uint64_t aLength, + nsIInputStream** aResult) { MutexAutoLock lock(mMutex); if (mState == eClosed) { @@ -358,7 +358,7 @@ RemoteLazyInputStream::CloneWithRange(uint64_t aStart, uint64_t aLength, MOZ_ASSERT(mActor); - RefPtr stream = mActor->CreateStream(); + RefPtr stream = mActor->CreateStream(); if (!stream) { return NS_ERROR_FAILURE; } @@ -382,18 +382,17 @@ RemoteLazyInputStream::CloneWithRange(uint64_t aStart, uint64_t aLength, // nsIAsyncInputStream interface NS_IMETHODIMP -RemoteLazyInputStream::CloseWithStatus(nsresult aStatus) { return Close(); } +IPCBlobInputStream::CloseWithStatus(nsresult aStatus) { return Close(); } NS_IMETHODIMP -RemoteLazyInputStream::AsyncWait(nsIInputStreamCallback* aCallback, - uint32_t aFlags, uint32_t aRequestedCount, - nsIEventTarget* aEventTarget) { +IPCBlobInputStream::AsyncWait(nsIInputStreamCallback* aCallback, + uint32_t aFlags, uint32_t aRequestedCount, + nsIEventTarget* aEventTarget) { nsCOMPtr asyncRemoteStream; { MutexAutoLock lock(mMutex); - // See RemoteLazyInputStream.h for more information about this state - // machine. + // See IPCBlobInputStream.h for more information about this state machine. switch (mState) { // First call, we need to retrieve the stream from the parent actor. @@ -459,7 +458,7 @@ RemoteLazyInputStream::AsyncWait(nsIInputStreamCallback* aCallback, return NS_OK; } -void RemoteLazyInputStream::StreamReady( +void IPCBlobInputStream::StreamReady( already_AddRefed aInputStream) { nsCOMPtr inputStream = std::move(aInputStream); @@ -530,7 +529,7 @@ void RemoteLazyInputStream::StreamReady( } } -void RemoteLazyInputStream::InitWithExistingRange( +void IPCBlobInputStream::InitWithExistingRange( uint64_t aStart, uint64_t aLength, const MutexAutoLock& aProofOfLock) { MOZ_ASSERT(mActor->Size() >= aStart + aLength); mStart = aStart; @@ -550,7 +549,7 @@ void RemoteLazyInputStream::InitWithExistingRange( // nsIInputStreamCallback NS_IMETHODIMP -RemoteLazyInputStream::OnInputStreamReady(nsIAsyncInputStream* aStream) { +IPCBlobInputStream::OnInputStreamReady(nsIAsyncInputStream* aStream) { nsCOMPtr callback; nsCOMPtr callbackEventTarget; { @@ -582,7 +581,7 @@ RemoteLazyInputStream::OnInputStreamReady(nsIAsyncInputStream* aStream) { // nsIIPCSerializableInputStream -void RemoteLazyInputStream::Serialize( +void IPCBlobInputStream::Serialize( mozilla::ipc::InputStreamParams& aParams, FileDescriptorArray& aFileDescriptors, bool aDelayedStart, uint32_t aMaxSize, uint32_t* aSizeUsed, @@ -591,15 +590,14 @@ void RemoteLazyInputStream::Serialize( *aSizeUsed = 0; // So far we support only socket process serialization. - MOZ_DIAGNOSTIC_ASSERT( - aManager == SocketProcessParent::GetSingleton(), - "Serializing an RemoteLazyInputStream parent to child is " - "wrong! The caller must be fixed! See IPCBlobUtils.h."); + MOZ_DIAGNOSTIC_ASSERT(aManager == SocketProcessParent::GetSingleton(), + "Serializing an IPCBlobInputStream parent to child is " + "wrong! The caller must be fixed! See IPCBlobUtils.h."); SocketProcessParent* socketActor = SocketProcessParent::GetSingleton(); nsresult rv; nsCOMPtr asyncRemoteStream; - RefPtr parentActor; + RefPtr parentActor; { MutexAutoLock lock(mMutex); rv = EnsureAsyncRemoteStream(lock); @@ -611,19 +609,19 @@ void RemoteLazyInputStream::Serialize( MOZ_ASSERT(asyncRemoteStream); - parentActor = RemoteLazyInputStreamParent::Create(asyncRemoteStream, mLength, - 0, &rv, socketActor); + parentActor = IPCBlobInputStreamParent::Create(asyncRemoteStream, mLength, 0, + &rv, socketActor); MOZ_ASSERT(parentActor); - if (!socketActor->SendPRemoteLazyInputStreamConstructor( + if (!socketActor->SendPIPCBlobInputStreamConstructor( parentActor, parentActor->ID(), parentActor->Size())) { MOZ_CRASH("The serialization is not supposed to fail"); } - aParams = mozilla::ipc::RemoteLazyInputStreamParams(parentActor); + aParams = mozilla::ipc::IPCBlobInputStreamParams(parentActor); } -void RemoteLazyInputStream::Serialize( +void IPCBlobInputStream::Serialize( mozilla::ipc::InputStreamParams& aParams, FileDescriptorArray& aFileDescriptors, bool aDelayedStart, uint32_t aMaxSize, uint32_t* aSizeUsed, @@ -633,7 +631,7 @@ void RemoteLazyInputStream::Serialize( MutexAutoLock lock(mMutex); - mozilla::ipc::RemoteLazyInputStreamRef params; + mozilla::ipc::IPCBlobInputStreamRef params; params.id() = mActor->ID(); params.start() = mStart; params.length() = mLength; @@ -641,7 +639,7 @@ void RemoteLazyInputStream::Serialize( aParams = params; } -bool RemoteLazyInputStream::Deserialize( +bool IPCBlobInputStream::Deserialize( const mozilla::ipc::InputStreamParams& aParams, const FileDescriptorArray& aFileDescriptors) { MOZ_CRASH("This should never be called."); @@ -651,8 +649,8 @@ bool RemoteLazyInputStream::Deserialize( // nsIAsyncFileMetadata NS_IMETHODIMP -RemoteLazyInputStream::AsyncFileMetadataWait(nsIFileMetadataCallback* aCallback, - nsIEventTarget* aEventTarget) { +IPCBlobInputStream::AsyncFileMetadataWait(nsIFileMetadataCallback* aCallback, + nsIEventTarget* aEventTarget) { MOZ_ASSERT(!!aCallback == !!aEventTarget); // If we have the callback, we must have the event target. @@ -660,7 +658,7 @@ RemoteLazyInputStream::AsyncFileMetadataWait(nsIFileMetadataCallback* aCallback, return NS_ERROR_FAILURE; } - // See RemoteLazyInputStream.h for more information about this state machine. + // See IPCBlobInputStream.h for more information about this state machine. { MutexAutoLock lock(mMutex); @@ -708,7 +706,7 @@ RemoteLazyInputStream::AsyncFileMetadataWait(nsIFileMetadataCallback* aCallback, // nsIFileMetadata NS_IMETHODIMP -RemoteLazyInputStream::GetSize(int64_t* aRetval) { +IPCBlobInputStream::GetSize(int64_t* aRetval) { nsCOMPtr fileMetadata; { MutexAutoLock lock(mMutex); @@ -722,7 +720,7 @@ RemoteLazyInputStream::GetSize(int64_t* aRetval) { } NS_IMETHODIMP -RemoteLazyInputStream::GetLastModified(int64_t* aRetval) { +IPCBlobInputStream::GetLastModified(int64_t* aRetval) { nsCOMPtr fileMetadata; { MutexAutoLock lock(mMutex); @@ -736,7 +734,7 @@ RemoteLazyInputStream::GetLastModified(int64_t* aRetval) { } NS_IMETHODIMP -RemoteLazyInputStream::GetFileDescriptor(PRFileDesc** aRetval) { +IPCBlobInputStream::GetFileDescriptor(PRFileDesc** aRetval) { nsCOMPtr fileMetadata; { MutexAutoLock lock(mMutex); @@ -749,7 +747,7 @@ RemoteLazyInputStream::GetFileDescriptor(PRFileDesc** aRetval) { return fileMetadata->GetFileDescriptor(aRetval); } -nsresult RemoteLazyInputStream::EnsureAsyncRemoteStream( +nsresult IPCBlobInputStream::EnsureAsyncRemoteStream( const MutexAutoLock& aProofOfLock) { // We already have an async remote stream. if (mAsyncRemoteStream) { @@ -806,8 +804,8 @@ nsresult RemoteLazyInputStream::EnsureAsyncRemoteStream( return rv; } - RefPtr thread = - RemoteLazyInputStreamThread::GetOrCreate(); + RefPtr thread = + IPCBlobInputStreamThread::GetOrCreate(); if (NS_WARN_IF(!thread)) { return NS_ERROR_FAILURE; } @@ -830,7 +828,7 @@ nsresult RemoteLazyInputStream::EnsureAsyncRemoteStream( // nsIInputStreamLength NS_IMETHODIMP -RemoteLazyInputStream::Length(int64_t* aLength) { +IPCBlobInputStream::Length(int64_t* aLength) { MutexAutoLock lock(mMutex); if (mState == eClosed) { @@ -849,8 +847,8 @@ namespace { class InputStreamLengthCallbackRunnable final : public CancelableRunnable { public: static void Execute(nsIInputStreamLengthCallback* aCallback, - nsIEventTarget* aEventTarget, - RemoteLazyInputStream* aStream, int64_t aLength) { + nsIEventTarget* aEventTarget, IPCBlobInputStream* aStream, + int64_t aLength) { MOZ_ASSERT(aCallback); MOZ_ASSERT(aEventTarget); @@ -871,7 +869,7 @@ class InputStreamLengthCallbackRunnable final : public CancelableRunnable { private: InputStreamLengthCallbackRunnable(nsIInputStreamLengthCallback* aCallback, - RemoteLazyInputStream* aStream, + IPCBlobInputStream* aStream, int64_t aLength) : CancelableRunnable("dom::InputStreamLengthCallbackRunnable"), mCallback(aCallback), @@ -882,7 +880,7 @@ class InputStreamLengthCallbackRunnable final : public CancelableRunnable { } nsCOMPtr mCallback; - RefPtr mStream; + RefPtr mStream; const int64_t mLength; }; @@ -891,8 +889,8 @@ class InputStreamLengthCallbackRunnable final : public CancelableRunnable { // nsIAsyncInputStreamLength NS_IMETHODIMP -RemoteLazyInputStream::AsyncLengthWait(nsIInputStreamLengthCallback* aCallback, - nsIEventTarget* aEventTarget) { +IPCBlobInputStream::AsyncLengthWait(nsIInputStreamLengthCallback* aCallback, + nsIEventTarget* aEventTarget) { // If we have the callback, we must have the event target. if (NS_WARN_IF(!!aCallback != !!aEventTarget)) { return NS_ERROR_FAILURE; @@ -921,7 +919,7 @@ RemoteLazyInputStream::AsyncLengthWait(nsIInputStreamLengthCallback* aCallback, return NS_OK; } -void RemoteLazyInputStream::LengthReady(int64_t aLength) { +void IPCBlobInputStream::LengthReady(int64_t aLength) { nsCOMPtr lengthCallback; nsCOMPtr lengthCallbackEventTarget; @@ -954,4 +952,5 @@ void RemoteLazyInputStream::LengthReady(int64_t aLength) { } } +} // namespace dom } // namespace mozilla diff --git a/dom/file/ipc/RemoteLazyInputStream.h b/dom/file/ipc/IPCBlobInputStream.h similarity index 78% rename from dom/file/ipc/RemoteLazyInputStream.h rename to dom/file/ipc/IPCBlobInputStream.h index 19d88e032893..2f7024cd7a5d 100644 --- a/dom/file/ipc/RemoteLazyInputStream.h +++ b/dom/file/ipc/IPCBlobInputStream.h @@ -4,11 +4,11 @@ * 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_RemoteLazyInputStream_h -#define mozilla_RemoteLazyInputStream_h +#ifndef mozilla_dom_IPCBlobInputStream_h +#define mozilla_dom_IPCBlobInputStream_h #include "mozilla/Mutex.h" -#include "mozIRemoteLazyInputStream.h" +#include "mozIIPCBlobInputStream.h" #include "nsIAsyncInputStream.h" #include "nsICloneableInputStream.h" #include "nsIFileStreams.h" @@ -17,8 +17,9 @@ #include "nsCOMPtr.h" namespace mozilla { +namespace dom { -class RemoteLazyInputStreamChild; +class IPCBlobInputStreamChild; #define IPCBLOBINPUTSTREAM_IID \ { \ @@ -27,14 +28,14 @@ class RemoteLazyInputStreamChild; } \ } -class RemoteLazyInputStream final : public nsIAsyncInputStream, - public nsIInputStreamCallback, - public nsICloneableInputStreamWithRange, - public nsIIPCSerializableInputStream, - public nsIAsyncFileMetadata, - public nsIInputStreamLength, - public nsIAsyncInputStreamLength, - public mozIRemoteLazyInputStream { +class IPCBlobInputStream final : public nsIAsyncInputStream, + public nsIInputStreamCallback, + public nsICloneableInputStreamWithRange, + public nsIIPCSerializableInputStream, + public nsIAsyncFileMetadata, + public nsIInputStreamLength, + public nsIAsyncInputStreamLength, + public mozIIPCBlobInputStream { public: NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_NSIINPUTSTREAM @@ -48,13 +49,13 @@ class RemoteLazyInputStream final : public nsIAsyncInputStream, NS_DECL_NSIINPUTSTREAMLENGTH NS_DECL_NSIASYNCINPUTSTREAMLENGTH - explicit RemoteLazyInputStream(RemoteLazyInputStreamChild* aActor); + explicit IPCBlobInputStream(IPCBlobInputStreamChild* aActor); void StreamReady(already_AddRefed aInputStream); void LengthReady(int64_t aLength); - // mozIRemoteLazyInputStream + // mozIIPCBlobInputStream NS_IMETHOD_(nsIInputStream*) GetInternalStream() override { if (mRemoteStream) { return mRemoteStream; @@ -68,14 +69,14 @@ class RemoteLazyInputStream final : public nsIAsyncInputStream, } private: - ~RemoteLazyInputStream(); + ~IPCBlobInputStream(); nsresult EnsureAsyncRemoteStream(const MutexAutoLock& aProofOfLock); void InitWithExistingRange(uint64_t aStart, uint64_t aLength, const MutexAutoLock& aProofOfLock); - RefPtr mActor; + RefPtr mActor; // This is the list of possible states. enum { @@ -125,6 +126,7 @@ class RemoteLazyInputStream final : public nsIAsyncInputStream, Mutex mMutex; }; +} // namespace dom } // namespace mozilla -#endif // mozilla_RemoteLazyInputStream_h +#endif // mozilla_dom_IPCBlobInputStream_h diff --git a/dom/file/ipc/RemoteLazyInputStreamChild.cpp b/dom/file/ipc/IPCBlobInputStreamChild.cpp similarity index 74% rename from dom/file/ipc/RemoteLazyInputStreamChild.cpp rename to dom/file/ipc/IPCBlobInputStreamChild.cpp index 973d32f043c0..a41510d9e90d 100644 --- a/dom/file/ipc/RemoteLazyInputStreamChild.cpp +++ b/dom/file/ipc/IPCBlobInputStreamChild.cpp @@ -4,16 +4,15 @@ * 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 "RemoteLazyInputStreamChild.h" -#include "RemoteLazyInputStreamThread.h" +#include "IPCBlobInputStreamChild.h" +#include "IPCBlobInputStreamThread.h" #include "mozilla/ipc/IPCStreamUtils.h" #include "mozilla/dom/WorkerCommon.h" #include "mozilla/dom/WorkerRef.h" namespace mozilla { - -using namespace dom; +namespace dom { namespace { @@ -21,7 +20,7 @@ namespace { // thread. class ShutdownRunnable final : public CancelableRunnable { public: - explicit ShutdownRunnable(RemoteLazyInputStreamChild* aActor) + explicit ShutdownRunnable(IPCBlobInputStreamChild* aActor) : CancelableRunnable("dom::ShutdownRunnable"), mActor(aActor) {} NS_IMETHOD @@ -31,36 +30,35 @@ class ShutdownRunnable final : public CancelableRunnable { } private: - RefPtr mActor; + RefPtr mActor; }; // This runnable is used in case StreamNeeded() has been called on a non-owning // thread. class StreamNeededRunnable final : public CancelableRunnable { public: - explicit StreamNeededRunnable(RemoteLazyInputStreamChild* aActor) + explicit StreamNeededRunnable(IPCBlobInputStreamChild* aActor) : CancelableRunnable("dom::StreamNeededRunnable"), mActor(aActor) {} NS_IMETHOD Run() override { - MOZ_ASSERT( - mActor->State() != RemoteLazyInputStreamChild::eActiveMigrating && - mActor->State() != RemoteLazyInputStreamChild::eInactiveMigrating); - if (mActor->State() == RemoteLazyInputStreamChild::eActive) { + MOZ_ASSERT(mActor->State() != IPCBlobInputStreamChild::eActiveMigrating && + mActor->State() != IPCBlobInputStreamChild::eInactiveMigrating); + if (mActor->State() == IPCBlobInputStreamChild::eActive) { mActor->SendStreamNeeded(); } return NS_OK; } private: - RefPtr mActor; + RefPtr mActor; }; // When the stream has been received from the parent, we inform the -// RemoteLazyInputStream. +// IPCBlobInputStream. class StreamReadyRunnable final : public CancelableRunnable { public: - StreamReadyRunnable(RemoteLazyInputStream* aDestinationStream, + StreamReadyRunnable(IPCBlobInputStream* aDestinationStream, already_AddRefed aCreatedStream) : CancelableRunnable("dom::StreamReadyRunnable"), mDestinationStream(aDestinationStream), @@ -76,7 +74,7 @@ class StreamReadyRunnable final : public CancelableRunnable { } private: - RefPtr mDestinationStream; + RefPtr mDestinationStream; nsCOMPtr mCreatedStream; }; @@ -84,29 +82,28 @@ class StreamReadyRunnable final : public CancelableRunnable { // thread. class LengthNeededRunnable final : public CancelableRunnable { public: - explicit LengthNeededRunnable(RemoteLazyInputStreamChild* aActor) + explicit LengthNeededRunnable(IPCBlobInputStreamChild* aActor) : CancelableRunnable("dom::LengthNeededRunnable"), mActor(aActor) {} NS_IMETHOD Run() override { - MOZ_ASSERT( - mActor->State() != RemoteLazyInputStreamChild::eActiveMigrating && - mActor->State() != RemoteLazyInputStreamChild::eInactiveMigrating); - if (mActor->State() == RemoteLazyInputStreamChild::eActive) { + MOZ_ASSERT(mActor->State() != IPCBlobInputStreamChild::eActiveMigrating && + mActor->State() != IPCBlobInputStreamChild::eInactiveMigrating); + if (mActor->State() == IPCBlobInputStreamChild::eActive) { mActor->SendLengthNeeded(); } return NS_OK; } private: - RefPtr mActor; + RefPtr mActor; }; // When the stream has been received from the parent, we inform the -// RemoteLazyInputStream. +// IPCBlobInputStream. class LengthReadyRunnable final : public CancelableRunnable { public: - LengthReadyRunnable(RemoteLazyInputStream* aDestinationStream, int64_t aSize) + LengthReadyRunnable(IPCBlobInputStream* aDestinationStream, int64_t aSize) : CancelableRunnable("dom::LengthReadyRunnable"), mDestinationStream(aDestinationStream), mSize(aSize) { @@ -120,15 +117,15 @@ class LengthReadyRunnable final : public CancelableRunnable { } private: - RefPtr mDestinationStream; + RefPtr mDestinationStream; int64_t mSize; }; } // namespace -RemoteLazyInputStreamChild::RemoteLazyInputStreamChild(const nsID& aID, - uint64_t aSize) - : mMutex("RemoteLazyInputStreamChild::mMutex"), +IPCBlobInputStreamChild::IPCBlobInputStreamChild(const nsID& aID, + uint64_t aSize) + : mMutex("IPCBlobInputStreamChild::mMutex"), mID(aID), mSize(aSize), mState(eActive), @@ -142,7 +139,7 @@ RemoteLazyInputStreamChild::RemoteLazyInputStreamChild(const nsID& aID, } RefPtr workerRef = - StrongWorkerRef::Create(workerPrivate, "RemoteLazyInputStreamChild"); + StrongWorkerRef::Create(workerPrivate, "IPCBlobInputStreamChild"); if (!workerRef) { return; } @@ -152,12 +149,12 @@ RemoteLazyInputStreamChild::RemoteLazyInputStreamChild(const nsID& aID, } } -RemoteLazyInputStreamChild::~RemoteLazyInputStreamChild() = default; +IPCBlobInputStreamChild::~IPCBlobInputStreamChild() = default; -void RemoteLazyInputStreamChild::Shutdown() { +void IPCBlobInputStreamChild::Shutdown() { MutexAutoLock lock(mMutex); - RefPtr kungFuDeathGrip = this; + RefPtr kungFuDeathGrip = this; mWorkerRef = nullptr; mPendingOperations.Clear(); @@ -168,7 +165,7 @@ void RemoteLazyInputStreamChild::Shutdown() { } } -void RemoteLazyInputStreamChild::ActorDestroy( +void IPCBlobInputStreamChild::ActorDestroy( IProtocol::ActorDestroyReason aReason) { bool migrating = false; @@ -185,16 +182,15 @@ void RemoteLazyInputStreamChild::ActorDestroy( } } -RemoteLazyInputStreamChild::ActorState RemoteLazyInputStreamChild::State() { +IPCBlobInputStreamChild::ActorState IPCBlobInputStreamChild::State() { MutexAutoLock lock(mMutex); return mState; } -already_AddRefed -RemoteLazyInputStreamChild::CreateStream() { +already_AddRefed IPCBlobInputStreamChild::CreateStream() { bool shouldMigrate = false; - RefPtr stream; + RefPtr stream; { MutexAutoLock lock(mMutex); @@ -206,19 +202,19 @@ RemoteLazyInputStreamChild::CreateStream() { // The stream is active but maybe it is not running in the DOM-File thread. // We should migrate it there. if (mState == eActive && - !RemoteLazyInputStreamThread::IsOnFileEventTarget(mOwningEventTarget)) { + !IPCBlobInputStreamThread::IsOnFileEventTarget(mOwningEventTarget)) { MOZ_ASSERT(mStreams.IsEmpty()); shouldMigrate = true; mState = eActiveMigrating; - RefPtr thread = - RemoteLazyInputStreamThread::GetOrCreate(); + RefPtr thread = + IPCBlobInputStreamThread::GetOrCreate(); MOZ_ASSERT(thread, "We cannot continue without DOMFile thread."); // Create a new actor object to connect to the target thread. - RefPtr newActor = - new RemoteLazyInputStreamChild(mID, mSize); + RefPtr newActor = + new IPCBlobInputStreamChild(mID, mSize); { MutexAutoLock newActorLock(newActor->mMutex); @@ -228,14 +224,14 @@ RemoteLazyInputStreamChild::CreateStream() { newActor->mPendingOperations.SwapElements(mPendingOperations); // Create the actual stream object. - stream = new RemoteLazyInputStream(newActor); + stream = new IPCBlobInputStream(newActor); newActor->mStreams.AppendElement(stream); } // Perform the actual migration. thread->MigrateActor(newActor); } else { - stream = new RemoteLazyInputStream(this); + stream = new IPCBlobInputStream(this); mStreams.AppendElement(stream); } } @@ -249,10 +245,10 @@ RemoteLazyInputStreamChild::CreateStream() { return stream.forget(); } -void RemoteLazyInputStreamChild::ForgetStream(RemoteLazyInputStream* aStream) { +void IPCBlobInputStreamChild::ForgetStream(IPCBlobInputStream* aStream) { MOZ_ASSERT(aStream); - RefPtr kungFuDeathGrip = this; + RefPtr kungFuDeathGrip = this; { MutexAutoLock lock(mMutex); @@ -272,8 +268,8 @@ void RemoteLazyInputStreamChild::ForgetStream(RemoteLazyInputStream* aStream) { mOwningEventTarget->Dispatch(runnable, NS_DISPATCH_NORMAL); } -void RemoteLazyInputStreamChild::StreamNeeded(RemoteLazyInputStream* aStream, - nsIEventTarget* aEventTarget) { +void IPCBlobInputStreamChild::StreamNeeded(IPCBlobInputStream* aStream, + nsIEventTarget* aEventTarget) { MutexAutoLock lock(mMutex); if (mState == eInactive) { @@ -303,11 +299,11 @@ void RemoteLazyInputStreamChild::StreamNeeded(RemoteLazyInputStream* aStream, mOwningEventTarget->Dispatch(runnable.forget(), NS_DISPATCH_NORMAL); } -mozilla::ipc::IPCResult RemoteLazyInputStreamChild::RecvStreamReady( +mozilla::ipc::IPCResult IPCBlobInputStreamChild::RecvStreamReady( const Maybe& aStream) { nsCOMPtr stream = mozilla::ipc::DeserializeIPCStream(aStream); - RefPtr pendingStream; + RefPtr pendingStream; nsCOMPtr eventTarget; { @@ -331,7 +327,7 @@ mozilla::ipc::IPCResult RemoteLazyInputStreamChild::RecvStreamReady( RefPtr runnable = new StreamReadyRunnable(pendingStream, stream.forget()); - // If RemoteLazyInputStream::AsyncWait() has been executed without passing an + // If IPCBlobInputStream::AsyncWait() has been executed without passing an // event target, we run the callback synchronous because any thread could be // result to be the wrong one. See more in nsIAsyncInputStream::asyncWait // documentation. @@ -344,8 +340,8 @@ mozilla::ipc::IPCResult RemoteLazyInputStreamChild::RecvStreamReady( return IPC_OK(); } -void RemoteLazyInputStreamChild::LengthNeeded(RemoteLazyInputStream* aStream, - nsIEventTarget* aEventTarget) { +void IPCBlobInputStreamChild::LengthNeeded(IPCBlobInputStream* aStream, + nsIEventTarget* aEventTarget) { MutexAutoLock lock(mMutex); if (mState == eInactive) { @@ -375,9 +371,9 @@ void RemoteLazyInputStreamChild::LengthNeeded(RemoteLazyInputStream* aStream, mOwningEventTarget->Dispatch(runnable.forget(), NS_DISPATCH_NORMAL); } -mozilla::ipc::IPCResult RemoteLazyInputStreamChild::RecvLengthReady( +mozilla::ipc::IPCResult IPCBlobInputStreamChild::RecvLengthReady( const int64_t& aLength) { - RefPtr pendingStream; + RefPtr pendingStream; nsCOMPtr eventTarget; { @@ -406,15 +402,14 @@ mozilla::ipc::IPCResult RemoteLazyInputStreamChild::RecvLengthReady( return IPC_OK(); } -void RemoteLazyInputStreamChild::Migrated() { +void IPCBlobInputStreamChild::Migrated() { MutexAutoLock lock(mMutex); MOZ_ASSERT(mState == eInactiveMigrating); mWorkerRef = nullptr; mOwningEventTarget = GetCurrentSerialEventTarget(); - MOZ_ASSERT( - RemoteLazyInputStreamThread::IsOnFileEventTarget(mOwningEventTarget)); + MOZ_ASSERT(IPCBlobInputStreamThread::IsOnFileEventTarget(mOwningEventTarget)); // Maybe we have no reasons to keep this actor alive. if (mStreams.IsEmpty()) { @@ -437,4 +432,5 @@ void RemoteLazyInputStreamChild::Migrated() { } } +} // namespace dom } // namespace mozilla diff --git a/dom/file/ipc/RemoteLazyInputStreamChild.h b/dom/file/ipc/IPCBlobInputStreamChild.h similarity index 67% rename from dom/file/ipc/RemoteLazyInputStreamChild.h rename to dom/file/ipc/IPCBlobInputStreamChild.h index 7e86a90ac85a..27d7c31f81e2 100644 --- a/dom/file/ipc/RemoteLazyInputStreamChild.h +++ b/dom/file/ipc/IPCBlobInputStreamChild.h @@ -4,24 +4,22 @@ * 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_RemoteLazyInputStreamChild_h -#define mozilla_RemoteLazyInputStreamChild_h +#ifndef mozilla_dom_IPCBlobInputStreamChild_h +#define mozilla_dom_IPCBlobInputStreamChild_h -#include "mozilla/PRemoteLazyInputStreamChild.h" -#include "mozilla/RemoteLazyInputStream.h" +#include "mozilla/dom/PIPCBlobInputStreamChild.h" +#include "mozilla/dom/IPCBlobInputStream.h" #include "mozilla/Mutex.h" #include "mozilla/UniquePtr.h" #include "nsTArray.h" namespace mozilla { - -class RemoteLazyInputStream; - namespace dom { -class ThreadSafeWorkerRef; -} -class RemoteLazyInputStreamChild final : public PRemoteLazyInputStreamChild { +class IPCBlobInputStream; +class ThreadSafeWorkerRef; + +class IPCBlobInputStreamChild final : public PIPCBlobInputStreamChild { public: enum ActorState { // The actor is connected via IPDL to the parent. @@ -39,29 +37,27 @@ class RemoteLazyInputStreamChild final : public PRemoteLazyInputStreamChild { eInactiveMigrating, }; - NS_INLINE_DECL_THREADSAFE_REFCOUNTING(RemoteLazyInputStreamChild, final) + NS_INLINE_DECL_THREADSAFE_REFCOUNTING(IPCBlobInputStreamChild, final) - RemoteLazyInputStreamChild(const nsID& aID, uint64_t aSize); + IPCBlobInputStreamChild(const nsID& aID, uint64_t aSize); void ActorDestroy(IProtocol::ActorDestroyReason aReason) override; ActorState State(); - already_AddRefed CreateStream(); + already_AddRefed CreateStream(); - void ForgetStream(RemoteLazyInputStream* aStream); + void ForgetStream(IPCBlobInputStream* aStream); const nsID& ID() const { return mID; } uint64_t Size() const { return mSize; } - void StreamNeeded(RemoteLazyInputStream* aStream, - nsIEventTarget* aEventTarget); + void StreamNeeded(IPCBlobInputStream* aStream, nsIEventTarget* aEventTarget); mozilla::ipc::IPCResult RecvStreamReady(const Maybe& aStream); - void LengthNeeded(RemoteLazyInputStream* aStream, - nsIEventTarget* aEventTarget); + void LengthNeeded(IPCBlobInputStream* aStream, nsIEventTarget* aEventTarget); mozilla::ipc::IPCResult RecvLengthReady(const int64_t& aLength); @@ -70,12 +66,12 @@ class RemoteLazyInputStreamChild final : public PRemoteLazyInputStreamChild { void Migrated(); private: - ~RemoteLazyInputStreamChild(); + ~IPCBlobInputStreamChild(); // Raw pointers because these streams keep this actor alive. When the last // stream is unregister, the actor will be deleted. This list is protected by // mutex. - nsTArray mStreams; + nsTArray mStreams; // This mutex protects mStreams because that can be touched in any thread. Mutex mMutex; @@ -87,7 +83,7 @@ class RemoteLazyInputStreamChild final : public PRemoteLazyInputStreamChild { // This struct and the array are used for creating streams when needed. struct PendingOperation { - RefPtr mStream; + RefPtr mStream; nsCOMPtr mEventTarget; enum { eStreamNeeded, @@ -98,9 +94,10 @@ class RemoteLazyInputStreamChild final : public PRemoteLazyInputStreamChild { nsCOMPtr mOwningEventTarget; - RefPtr mWorkerRef; + RefPtr mWorkerRef; }; +} // namespace dom } // namespace mozilla -#endif // mozilla_RemoteLazyInputStreamChild_h +#endif // mozilla_dom_IPCBlobInputStreamChild_h diff --git a/dom/file/ipc/RemoteLazyInputStreamParent.cpp b/dom/file/ipc/IPCBlobInputStreamParent.cpp similarity index 57% rename from dom/file/ipc/RemoteLazyInputStreamParent.cpp rename to dom/file/ipc/IPCBlobInputStreamParent.cpp index aea48fbc178a..e644ed7633bb 100644 --- a/dom/file/ipc/RemoteLazyInputStreamParent.cpp +++ b/dom/file/ipc/IPCBlobInputStreamParent.cpp @@ -4,20 +4,20 @@ * 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 "RemoteLazyInputStreamParent.h" +#include "IPCBlobInputStreamParent.h" +#include "IPCBlobInputStreamStorage.h" #include "mozilla/ipc/IPCStreamUtils.h" #include "mozilla/InputStreamLengthHelper.h" #include "nsContentUtils.h" -#include "RemoteLazyInputStreamStorage.h" namespace mozilla { +namespace dom { template /* static */ -already_AddRefed -RemoteLazyInputStreamParent::Create(nsIInputStream* aInputStream, - uint64_t aSize, uint64_t aChildID, - nsresult* aRv, M* aManager) { +already_AddRefed IPCBlobInputStreamParent::Create( + nsIInputStream* aInputStream, uint64_t aSize, uint64_t aChildID, + nsresult* aRv, M* aManager) { MOZ_ASSERT(aInputStream); MOZ_ASSERT(aRv); @@ -27,55 +27,54 @@ RemoteLazyInputStreamParent::Create(nsIInputStream* aInputStream, return nullptr; } - RemoteLazyInputStreamStorage::Get()->AddStream(aInputStream, id, aSize, - aChildID); + IPCBlobInputStreamStorage::Get()->AddStream(aInputStream, id, aSize, + aChildID); - RefPtr parent = - new RemoteLazyInputStreamParent(id, aSize, aManager); + RefPtr parent = + new IPCBlobInputStreamParent(id, aSize, aManager); return parent.forget(); } /* static */ -already_AddRefed -RemoteLazyInputStreamParent::Create(const nsID& aID, uint64_t aSize, - PBackgroundParent* aManager) { - RefPtr actor = - new RemoteLazyInputStreamParent(aID, aSize, aManager); +already_AddRefed IPCBlobInputStreamParent::Create( + const nsID& aID, uint64_t aSize, PBackgroundParent* aManager) { + RefPtr actor = + new IPCBlobInputStreamParent(aID, aSize, aManager); - actor->mCallback = RemoteLazyInputStreamStorage::Get()->TakeCallback(aID); + actor->mCallback = IPCBlobInputStreamStorage::Get()->TakeCallback(aID); return actor.forget(); } -template already_AddRefed -RemoteLazyInputStreamParent::Create( +template already_AddRefed +IPCBlobInputStreamParent::Create( nsIInputStream*, uint64_t, uint64_t, nsresult*, mozilla::ipc::PBackgroundParent*); /* static */ -already_AddRefed -RemoteLazyInputStreamParent::Create(const nsID& aID, uint64_t aSize, - SocketProcessParent* aManager) { - RefPtr actor = - new RemoteLazyInputStreamParent(aID, aSize, aManager); +already_AddRefed IPCBlobInputStreamParent::Create( + const nsID& aID, uint64_t aSize, SocketProcessParent* aManager) { + RefPtr actor = + new IPCBlobInputStreamParent(aID, aSize, aManager); - actor->mCallback = RemoteLazyInputStreamStorage::Get()->TakeCallback(aID); + actor->mCallback = IPCBlobInputStreamStorage::Get()->TakeCallback(aID); return actor.forget(); } -template already_AddRefed -RemoteLazyInputStreamParent::Create( +template already_AddRefed +IPCBlobInputStreamParent::Create( nsIInputStream*, uint64_t, uint64_t, nsresult*, mozilla::net::SocketProcessParent*); -template already_AddRefed -RemoteLazyInputStreamParent::Create(nsIInputStream*, uint64_t, - uint64_t, nsresult*, - ContentParent*); +template already_AddRefed +IPCBlobInputStreamParent::Create(nsIInputStream*, uint64_t, + uint64_t, nsresult*, + ContentParent*); -RemoteLazyInputStreamParent::RemoteLazyInputStreamParent( - const nsID& aID, uint64_t aSize, ContentParent* aManager) +IPCBlobInputStreamParent::IPCBlobInputStreamParent(const nsID& aID, + uint64_t aSize, + ContentParent* aManager) : mID(aID), mSize(aSize), mContentManager(aManager), @@ -83,8 +82,9 @@ RemoteLazyInputStreamParent::RemoteLazyInputStreamParent( mSocketProcessManager(nullptr), mMigrating(false) {} -RemoteLazyInputStreamParent::RemoteLazyInputStreamParent( - const nsID& aID, uint64_t aSize, PBackgroundParent* aManager) +IPCBlobInputStreamParent::IPCBlobInputStreamParent(const nsID& aID, + uint64_t aSize, + PBackgroundParent* aManager) : mID(aID), mSize(aSize), mContentManager(nullptr), @@ -92,7 +92,7 @@ RemoteLazyInputStreamParent::RemoteLazyInputStreamParent( mSocketProcessManager(nullptr), mMigrating(false) {} -RemoteLazyInputStreamParent::RemoteLazyInputStreamParent( +IPCBlobInputStreamParent::IPCBlobInputStreamParent( const nsID& aID, uint64_t aSize, SocketProcessParent* aManager) : mID(aID), mSize(aSize), @@ -101,7 +101,7 @@ RemoteLazyInputStreamParent::RemoteLazyInputStreamParent( mSocketProcessManager(aManager), mMigrating(false) {} -void RemoteLazyInputStreamParent::ActorDestroy( +void IPCBlobInputStreamParent::ActorDestroy( IProtocol::ActorDestroyReason aReason) { MOZ_ASSERT(mContentManager || mPBackgroundManager || mSocketProcessManager); @@ -109,11 +109,10 @@ void RemoteLazyInputStreamParent::ActorDestroy( mPBackgroundManager = nullptr; mSocketProcessManager = nullptr; - RefPtr callback; + RefPtr callback; mCallback.swap(callback); - RefPtr storage = - RemoteLazyInputStreamStorage::Get(); + RefPtr storage = IPCBlobInputStreamStorage::Get(); if (mMigrating) { if (callback && storage) { @@ -132,20 +131,20 @@ void RemoteLazyInputStreamParent::ActorDestroy( } } -void RemoteLazyInputStreamParent::SetCallback( - RemoteLazyInputStreamParentCallback* aCallback) { +void IPCBlobInputStreamParent::SetCallback( + IPCBlobInputStreamParentCallback* aCallback) { MOZ_ASSERT(aCallback); MOZ_ASSERT(!mCallback); mCallback = aCallback; } -mozilla::ipc::IPCResult RemoteLazyInputStreamParent::RecvStreamNeeded() { +mozilla::ipc::IPCResult IPCBlobInputStreamParent::RecvStreamNeeded() { MOZ_ASSERT(mContentManager || mPBackgroundManager || mSocketProcessManager); nsCOMPtr stream; - RemoteLazyInputStreamStorage::Get()->GetStream(mID, 0, mSize, - getter_AddRefs(stream)); + IPCBlobInputStreamStorage::Get()->GetStream(mID, 0, mSize, + getter_AddRefs(stream)); if (!stream) { if (!SendStreamReady(Nothing())) { return IPC_FAIL(this, "SendStreamReady failed"); @@ -178,12 +177,12 @@ mozilla::ipc::IPCResult RemoteLazyInputStreamParent::RecvStreamNeeded() { return IPC_OK(); } -mozilla::ipc::IPCResult RemoteLazyInputStreamParent::RecvLengthNeeded() { +mozilla::ipc::IPCResult IPCBlobInputStreamParent::RecvLengthNeeded() { MOZ_ASSERT(mContentManager || mPBackgroundManager || mSocketProcessManager); nsCOMPtr stream; - RemoteLazyInputStreamStorage::Get()->GetStream(mID, 0, mSize, - getter_AddRefs(stream)); + IPCBlobInputStreamStorage::Get()->GetStream(mID, 0, mSize, + getter_AddRefs(stream)); if (!stream) { if (!SendLengthReady(-1)) { return IPC_FAIL(this, "SendLengthReady failed"); @@ -198,7 +197,7 @@ mozilla::ipc::IPCResult RemoteLazyInputStreamParent::RecvLengthNeeded() { return IPC_OK(); } - RefPtr self = this; + RefPtr self = this; InputStreamLengthHelper::GetAsyncLength(stream, [self](int64_t aLength) { if (self->mContentManager || self->mPBackgroundManager || self->mSocketProcessManager) { @@ -209,21 +208,22 @@ mozilla::ipc::IPCResult RemoteLazyInputStreamParent::RecvLengthNeeded() { return IPC_OK(); } -mozilla::ipc::IPCResult RemoteLazyInputStreamParent::RecvClose() { +mozilla::ipc::IPCResult IPCBlobInputStreamParent::RecvClose() { MOZ_ASSERT(mContentManager || mPBackgroundManager || mSocketProcessManager); Unused << Send__delete__(this); return IPC_OK(); } -mozilla::ipc::IPCResult RemoteLazyInputStreamParent::Recv__delete__() { +mozilla::ipc::IPCResult IPCBlobInputStreamParent::Recv__delete__() { MOZ_ASSERT(mContentManager || mPBackgroundManager || mSocketProcessManager); mMigrating = true; return IPC_OK(); } -bool RemoteLazyInputStreamParent::HasValidStream() const { - return RemoteLazyInputStreamStorage::Get()->HasStream(mID); +bool IPCBlobInputStreamParent::HasValidStream() const { + return IPCBlobInputStreamStorage::Get()->HasStream(mID); } +} // namespace dom } // namespace mozilla diff --git a/dom/file/ipc/RemoteLazyInputStreamParent.h b/dom/file/ipc/IPCBlobInputStreamParent.h similarity index 58% rename from dom/file/ipc/RemoteLazyInputStreamParent.h rename to dom/file/ipc/IPCBlobInputStreamParent.h index c9d6ea341e5d..81e1d76d96f1 100644 --- a/dom/file/ipc/RemoteLazyInputStreamParent.h +++ b/dom/file/ipc/IPCBlobInputStreamParent.h @@ -4,50 +4,48 @@ * 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_RemoteLazyInputStreamParent_h -#define mozilla_RemoteLazyInputStreamParent_h +#ifndef mozilla_dom_IPCBlobInputStreamParent_h +#define mozilla_dom_IPCBlobInputStreamParent_h -#include "mozilla/PRemoteLazyInputStreamParent.h" +#include "mozilla/dom/PIPCBlobInputStreamParent.h" class nsIInputStream; namespace mozilla { -namespace dom { -class ContentParent; -} - namespace net { class SocketProcessParent; } -class NS_NO_VTABLE RemoteLazyInputStreamParentCallback { +namespace dom { + +class NS_NO_VTABLE IPCBlobInputStreamParentCallback { public: virtual void ActorDestroyed(const nsID& aID) = 0; NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING protected: - virtual ~RemoteLazyInputStreamParentCallback() = default; + virtual ~IPCBlobInputStreamParentCallback() = default; }; -class RemoteLazyInputStreamParent final : public PRemoteLazyInputStreamParent { +class IPCBlobInputStreamParent final : public PIPCBlobInputStreamParent { public: - NS_INLINE_DECL_THREADSAFE_REFCOUNTING(RemoteLazyInputStreamParent, final) + NS_INLINE_DECL_THREADSAFE_REFCOUNTING(IPCBlobInputStreamParent, final) // The size of the inputStream must be passed as argument in order to avoid // the use of nsIInputStream::Available() which could open a fileDescriptor in // case the stream is a nsFileStream. template - static already_AddRefed Create( + static already_AddRefed Create( nsIInputStream* aInputStream, uint64_t aSize, uint64_t aChildID, nsresult* aRv, M* aManager); - static already_AddRefed Create( + static already_AddRefed Create( const nsID& aID, uint64_t aSize, mozilla::ipc::PBackgroundParent* aManager); - static already_AddRefed Create( + static already_AddRefed Create( const nsID& aID, uint64_t aSize, mozilla::net::SocketProcessParent* aManager); @@ -57,7 +55,7 @@ class RemoteLazyInputStreamParent final : public PRemoteLazyInputStreamParent { uint64_t Size() const { return mSize; } - void SetCallback(RemoteLazyInputStreamParentCallback* aCallback); + void SetCallback(IPCBlobInputStreamParentCallback* aCallback); mozilla::ipc::IPCResult RecvStreamNeeded(); @@ -70,31 +68,32 @@ class RemoteLazyInputStreamParent final : public PRemoteLazyInputStreamParent { bool HasValidStream() const; private: - RemoteLazyInputStreamParent(const nsID& aID, uint64_t aSize, - mozilla::dom::ContentParent* aManager); + IPCBlobInputStreamParent(const nsID& aID, uint64_t aSize, + ContentParent* aManager); - RemoteLazyInputStreamParent(const nsID& aID, uint64_t aSize, - mozilla::ipc::PBackgroundParent* aManager); + IPCBlobInputStreamParent(const nsID& aID, uint64_t aSize, + mozilla::ipc::PBackgroundParent* aManager); - RemoteLazyInputStreamParent(const nsID& aID, uint64_t aSize, - mozilla::net::SocketProcessParent* aManager); + IPCBlobInputStreamParent(const nsID& aID, uint64_t aSize, + mozilla::net::SocketProcessParent* aManager); - ~RemoteLazyInputStreamParent() = default; + ~IPCBlobInputStreamParent() = default; const nsID mID; const uint64_t mSize; // Only 1 of these is set. Raw pointer because these managers are keeping // the parent actor alive. The pointers will be nullified in ActorDestroyed. - mozilla::dom::ContentParent* mContentManager; + ContentParent* mContentManager; mozilla::ipc::PBackgroundParent* mPBackgroundManager; mozilla::net::SocketProcessParent* mSocketProcessManager; - RefPtr mCallback; + RefPtr mCallback; bool mMigrating; }; +} // namespace dom } // namespace mozilla -#endif // mozilla_RemoteLazyInputStreamParent_h +#endif // mozilla_dom_IPCBlobInputStreamParent_h diff --git a/dom/file/ipc/RemoteLazyInputStreamStorage.cpp b/dom/file/ipc/IPCBlobInputStreamStorage.cpp similarity index 74% rename from dom/file/ipc/RemoteLazyInputStreamStorage.cpp rename to dom/file/ipc/IPCBlobInputStreamStorage.cpp index 01b80c0d6408..8eaddc218b59 100644 --- a/dom/file/ipc/RemoteLazyInputStreamStorage.cpp +++ b/dom/file/ipc/IPCBlobInputStreamStorage.cpp @@ -4,41 +4,41 @@ * 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 "IPCBlobInputStreamStorage.h" #include "mozilla/SlicedInputStream.h" #include "mozilla/dom/ContentParent.h" #include "mozilla/StaticMutex.h" #include "mozilla/StaticPtr.h" #include "nsIPropertyBag2.h" #include "nsStreamUtils.h" -#include "RemoteLazyInputStreamStorage.h" namespace mozilla { using namespace hal; +namespace dom { + namespace { StaticMutex gMutex; -StaticRefPtr gStorage; +StaticRefPtr gStorage; } // namespace -NS_INTERFACE_MAP_BEGIN(RemoteLazyInputStreamStorage) +NS_INTERFACE_MAP_BEGIN(IPCBlobInputStreamStorage) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIObserver) NS_INTERFACE_MAP_ENTRY(nsIObserver) NS_INTERFACE_MAP_END -NS_IMPL_ADDREF(RemoteLazyInputStreamStorage) -NS_IMPL_RELEASE(RemoteLazyInputStreamStorage) +NS_IMPL_ADDREF(IPCBlobInputStreamStorage) +NS_IMPL_RELEASE(IPCBlobInputStreamStorage) /* static */ -RemoteLazyInputStreamStorage* RemoteLazyInputStreamStorage::Get() { - return gStorage; -} +IPCBlobInputStreamStorage* IPCBlobInputStreamStorage::Get() { return gStorage; } /* static */ -void RemoteLazyInputStreamStorage::Initialize() { +void IPCBlobInputStreamStorage::Initialize() { MOZ_ASSERT(!gStorage); - gStorage = new RemoteLazyInputStreamStorage(); + gStorage = new IPCBlobInputStreamStorage(); nsCOMPtr obs = mozilla::services::GetObserverService(); if (obs) { @@ -48,8 +48,8 @@ void RemoteLazyInputStreamStorage::Initialize() { } NS_IMETHODIMP -RemoteLazyInputStreamStorage::Observe(nsISupports* aSubject, const char* aTopic, - const char16_t* aData) { +IPCBlobInputStreamStorage::Observe(nsISupports* aSubject, const char* aTopic, + const char16_t* aData) { if (!strcmp(aTopic, "xpcom-shutdown")) { nsCOMPtr obs = mozilla::services::GetObserverService(); if (obs) { @@ -85,9 +85,9 @@ RemoteLazyInputStreamStorage::Observe(nsISupports* aSubject, const char* aTopic, return NS_OK; } -void RemoteLazyInputStreamStorage::AddStream(nsIInputStream* aInputStream, - const nsID& aID, uint64_t aSize, - uint64_t aChildID) { +void IPCBlobInputStreamStorage::AddStream(nsIInputStream* aInputStream, + const nsID& aID, uint64_t aSize, + uint64_t aChildID) { MOZ_ASSERT(aInputStream); StreamData* data = new StreamData(); @@ -99,7 +99,7 @@ void RemoteLazyInputStreamStorage::AddStream(nsIInputStream* aInputStream, mStorage.Put(aID, data); } -nsCOMPtr RemoteLazyInputStreamStorage::ForgetStream( +nsCOMPtr IPCBlobInputStreamStorage::ForgetStream( const nsID& aID) { UniquePtr entry; @@ -113,15 +113,15 @@ nsCOMPtr RemoteLazyInputStreamStorage::ForgetStream( return std::move(entry->mInputStream); } -bool RemoteLazyInputStreamStorage::HasStream(const nsID& aID) { +bool IPCBlobInputStreamStorage::HasStream(const nsID& aID) { mozilla::StaticMutexAutoLock lock(gMutex); StreamData* data = mStorage.Get(aID); return !!data; } -void RemoteLazyInputStreamStorage::GetStream(const nsID& aID, uint64_t aStart, - uint64_t aLength, - nsIInputStream** aInputStream) { +void IPCBlobInputStreamStorage::GetStream(const nsID& aID, uint64_t aStart, + uint64_t aLength, + nsIInputStream** aInputStream) { *aInputStream = nullptr; nsCOMPtr inputStream; @@ -175,8 +175,8 @@ void RemoteLazyInputStreamStorage::GetStream(const nsID& aID, uint64_t aStart, clonedStream.forget(aInputStream); } -void RemoteLazyInputStreamStorage::StoreCallback( - const nsID& aID, RemoteLazyInputStreamParentCallback* aCallback) { +void IPCBlobInputStreamStorage::StoreCallback( + const nsID& aID, IPCBlobInputStreamParentCallback* aCallback) { MOZ_ASSERT(aCallback); mozilla::StaticMutexAutoLock lock(gMutex); @@ -187,17 +187,18 @@ void RemoteLazyInputStreamStorage::StoreCallback( } } -already_AddRefed -RemoteLazyInputStreamStorage::TakeCallback(const nsID& aID) { +already_AddRefed +IPCBlobInputStreamStorage::TakeCallback(const nsID& aID) { mozilla::StaticMutexAutoLock lock(gMutex); StreamData* data = mStorage.Get(aID); if (!data) { return nullptr; } - RefPtr callback; + RefPtr callback; data->mCallback.swap(callback); return callback.forget(); } +} // namespace dom } // namespace mozilla diff --git a/dom/file/ipc/RemoteLazyInputStreamStorage.h b/dom/file/ipc/IPCBlobInputStreamStorage.h similarity index 71% rename from dom/file/ipc/RemoteLazyInputStreamStorage.h rename to dom/file/ipc/IPCBlobInputStreamStorage.h index 1b558a2e378c..c53f1863112b 100644 --- a/dom/file/ipc/RemoteLazyInputStreamStorage.h +++ b/dom/file/ipc/IPCBlobInputStreamStorage.h @@ -4,8 +4,8 @@ * 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_RemoteLazyInputStreamStorage_h -#define mozilla_RemoteLazyInputStreamStorage_h +#ifndef mozilla_dom_IPCBlobInputStreamStorage_h +#define mozilla_dom_IPCBlobInputStreamStorage_h #include "mozilla/RefPtr.h" #include "nsClassHashtable.h" @@ -15,10 +15,11 @@ class nsIInputStream; struct nsID; namespace mozilla { +namespace dom { -class RemoteLazyInputStreamParentCallback; +class IPCBlobInputStreamParentCallback; -class RemoteLazyInputStreamStorage final : public nsIObserver { +class IPCBlobInputStreamStorage final : public nsIObserver { public: NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_NSIOBSERVER @@ -26,7 +27,7 @@ class RemoteLazyInputStreamStorage final : public nsIObserver { // This initializes the singleton and it must be called on the main-thread. static void Initialize(); - static RemoteLazyInputStreamStorage* Get(); + static IPCBlobInputStreamStorage* Get(); void AddStream(nsIInputStream* aInputStream, const nsID& aID, uint64_t aSize, uint64_t aChildID); @@ -41,18 +42,18 @@ class RemoteLazyInputStreamStorage final : public nsIObserver { nsIInputStream** aInputStream); void StoreCallback(const nsID& aID, - RemoteLazyInputStreamParentCallback* aCallback); + IPCBlobInputStreamParentCallback* aCallback); - already_AddRefed TakeCallback( + already_AddRefed TakeCallback( const nsID& aID); private: - RemoteLazyInputStreamStorage() = default; - ~RemoteLazyInputStreamStorage() = default; + IPCBlobInputStreamStorage() = default; + ~IPCBlobInputStreamStorage() = default; struct StreamData { nsCOMPtr mInputStream; - RefPtr mCallback; + RefPtr mCallback; // This is the Process ID connected with this inputStream. We need to store // this information in order to delete it if the child crashes/shutdowns. @@ -64,6 +65,7 @@ class RemoteLazyInputStreamStorage final : public nsIObserver { nsClassHashtable mStorage; }; +} // namespace dom } // namespace mozilla -#endif // mozilla_RemoteLazyInputStreamStorage_h +#endif // mozilla_dom_IPCBlobInputStreamStorage_h diff --git a/dom/file/ipc/RemoteLazyInputStreamThread.cpp b/dom/file/ipc/IPCBlobInputStreamThread.cpp similarity index 58% rename from dom/file/ipc/RemoteLazyInputStreamThread.cpp rename to dom/file/ipc/IPCBlobInputStreamThread.cpp index 6eac2bcaeac2..b80a511bfb87 100644 --- a/dom/file/ipc/RemoteLazyInputStreamThread.cpp +++ b/dom/file/ipc/IPCBlobInputStreamThread.cpp @@ -4,7 +4,7 @@ * 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 "RemoteLazyInputStreamThread.h" +#include "IPCBlobInputStreamThread.h" #include "mozilla/SchedulerGroup.h" #include "mozilla/StaticMutex.h" @@ -15,10 +15,14 @@ namespace mozilla { +using namespace ipc; + +namespace dom { + namespace { -StaticMutex gRemoteLazyThreadMutex; -StaticRefPtr gRemoteLazyThread; +StaticMutex gIPCBlobThreadMutex; +StaticRefPtr gIPCBlobThread; bool gShutdownHasStarted = false; class ThreadInitializeRunnable final : public Runnable { @@ -27,24 +31,23 @@ class ThreadInitializeRunnable final : public Runnable { NS_IMETHOD Run() override { - StaticMutexAutoLock lock(gRemoteLazyThreadMutex); - MOZ_ASSERT(gRemoteLazyThread); - gRemoteLazyThread->InitializeOnMainThread(); + mozilla::StaticMutexAutoLock lock(gIPCBlobThreadMutex); + MOZ_ASSERT(gIPCBlobThread); + gIPCBlobThread->InitializeOnMainThread(); return NS_OK; } }; class MigrateActorRunnable final : public Runnable { public: - explicit MigrateActorRunnable(RemoteLazyInputStreamChild* aActor) + explicit MigrateActorRunnable(IPCBlobInputStreamChild* aActor) : Runnable("dom::MigrateActorRunnable"), mActor(aActor) { MOZ_ASSERT(mActor); } NS_IMETHOD Run() override { - MOZ_ASSERT(mActor->State() == - RemoteLazyInputStreamChild::eInactiveMigrating); + MOZ_ASSERT(mActor->State() == IPCBlobInputStreamChild::eInactiveMigrating); PBackgroundChild* actorChild = BackgroundChild::GetOrCreateForCurrentThread(); @@ -52,8 +55,8 @@ class MigrateActorRunnable final : public Runnable { return NS_OK; } - if (actorChild->SendPRemoteLazyInputStreamConstructor(mActor, mActor->ID(), - mActor->Size())) { + if (actorChild->SendPIPCBlobInputStreamConstructor(mActor, mActor->ID(), + mActor->Size())) { mActor->Migrated(); } @@ -63,15 +66,15 @@ class MigrateActorRunnable final : public Runnable { private: ~MigrateActorRunnable() = default; - RefPtr mActor; + RefPtr mActor; }; } // namespace -NS_IMPL_ISUPPORTS(RemoteLazyInputStreamThread, nsIObserver, nsIEventTarget) +NS_IMPL_ISUPPORTS(IPCBlobInputStreamThread, nsIObserver, nsIEventTarget) /* static */ -bool RemoteLazyInputStreamThread::IsOnFileEventTarget( +bool IPCBlobInputStreamThread::IsOnFileEventTarget( nsIEventTarget* aEventTarget) { MOZ_ASSERT(aEventTarget); @@ -82,40 +85,40 @@ bool RemoteLazyInputStreamThread::IsOnFileEventTarget( return true; } - StaticMutexAutoLock lock(gRemoteLazyThreadMutex); - return gRemoteLazyThread && aEventTarget == gRemoteLazyThread->mThread; + mozilla::StaticMutexAutoLock lock(gIPCBlobThreadMutex); + return gIPCBlobThread && aEventTarget == gIPCBlobThread->mThread; } /* static */ -RemoteLazyInputStreamThread* RemoteLazyInputStreamThread::Get() { - StaticMutexAutoLock lock(gRemoteLazyThreadMutex); +IPCBlobInputStreamThread* IPCBlobInputStreamThread::Get() { + mozilla::StaticMutexAutoLock lock(gIPCBlobThreadMutex); if (gShutdownHasStarted) { return nullptr; } - return gRemoteLazyThread; + return gIPCBlobThread; } /* static */ -RemoteLazyInputStreamThread* RemoteLazyInputStreamThread::GetOrCreate() { - StaticMutexAutoLock lock(gRemoteLazyThreadMutex); +IPCBlobInputStreamThread* IPCBlobInputStreamThread::GetOrCreate() { + mozilla::StaticMutexAutoLock lock(gIPCBlobThreadMutex); if (gShutdownHasStarted) { return nullptr; } - if (!gRemoteLazyThread) { - gRemoteLazyThread = new RemoteLazyInputStreamThread(); - if (!gRemoteLazyThread->Initialize()) { + if (!gIPCBlobThread) { + gIPCBlobThread = new IPCBlobInputStreamThread(); + if (!gIPCBlobThread->Initialize()) { return nullptr; } } - return gRemoteLazyThread; + return gIPCBlobThread; } -bool RemoteLazyInputStreamThread::Initialize() { +bool IPCBlobInputStreamThread::Initialize() { nsCOMPtr thread; nsresult rv = NS_NewNamedThread("DOM File", getter_AddRefs(thread)); if (NS_WARN_IF(NS_FAILED(rv))) { @@ -142,7 +145,7 @@ bool RemoteLazyInputStreamThread::Initialize() { return true; } -void RemoteLazyInputStreamThread::InitializeOnMainThread() { +void IPCBlobInputStreamThread::InitializeOnMainThread() { MOZ_ASSERT(NS_IsMainThread()); nsCOMPtr obs = services::GetObserverService(); @@ -158,11 +161,11 @@ void RemoteLazyInputStreamThread::InitializeOnMainThread() { } NS_IMETHODIMP -RemoteLazyInputStreamThread::Observe(nsISupports* aSubject, const char* aTopic, - const char16_t* aData) { +IPCBlobInputStreamThread::Observe(nsISupports* aSubject, const char* aTopic, + const char16_t* aData) { MOZ_ASSERT(!strcmp(aTopic, NS_XPCOM_SHUTDOWN_THREADS_OBSERVER_ID)); - StaticMutexAutoLock lock(gRemoteLazyThreadMutex); + mozilla::StaticMutexAutoLock lock(gIPCBlobThreadMutex); if (mThread) { mThread->Shutdown(); @@ -170,16 +173,15 @@ RemoteLazyInputStreamThread::Observe(nsISupports* aSubject, const char* aTopic, } gShutdownHasStarted = true; - gRemoteLazyThread = nullptr; + gIPCBlobThread = nullptr; return NS_OK; } -void RemoteLazyInputStreamThread::MigrateActor( - RemoteLazyInputStreamChild* aActor) { - MOZ_ASSERT(aActor->State() == RemoteLazyInputStreamChild::eInactiveMigrating); +void IPCBlobInputStreamThread::MigrateActor(IPCBlobInputStreamChild* aActor) { + MOZ_ASSERT(aActor->State() == IPCBlobInputStreamChild::eInactiveMigrating); - StaticMutexAutoLock lock(gRemoteLazyThreadMutex); + mozilla::StaticMutexAutoLock lock(gIPCBlobThreadMutex); if (gShutdownHasStarted) { return; @@ -194,8 +196,8 @@ void RemoteLazyInputStreamThread::MigrateActor( MigrateActorInternal(aActor); } -void RemoteLazyInputStreamThread::MigrateActorInternal( - RemoteLazyInputStreamChild* aActor) { +void IPCBlobInputStreamThread::MigrateActorInternal( + IPCBlobInputStreamChild* aActor) { RefPtr runnable = new MigrateActorRunnable(aActor); mThread->Dispatch(runnable, NS_DISPATCH_NORMAL); } @@ -203,21 +205,21 @@ void RemoteLazyInputStreamThread::MigrateActorInternal( // nsIEventTarget NS_IMETHODIMP_(bool) -RemoteLazyInputStreamThread::IsOnCurrentThreadInfallible() { +IPCBlobInputStreamThread::IsOnCurrentThreadInfallible() { return mThread->IsOnCurrentThread(); } NS_IMETHODIMP -RemoteLazyInputStreamThread::IsOnCurrentThread(bool* aRetval) { +IPCBlobInputStreamThread::IsOnCurrentThread(bool* aRetval) { return mThread->IsOnCurrentThread(aRetval); } NS_IMETHODIMP -RemoteLazyInputStreamThread::Dispatch(already_AddRefed aRunnable, - uint32_t aFlags) { +IPCBlobInputStreamThread::Dispatch(already_AddRefed aRunnable, + uint32_t aFlags) { nsCOMPtr runnable(aRunnable); - StaticMutexAutoLock lock(gRemoteLazyThreadMutex); + mozilla::StaticMutexAutoLock lock(gIPCBlobThreadMutex); if (gShutdownHasStarted) { return NS_ERROR_NOT_INITIALIZED; @@ -227,27 +229,28 @@ RemoteLazyInputStreamThread::Dispatch(already_AddRefed aRunnable, } NS_IMETHODIMP -RemoteLazyInputStreamThread::DispatchFromScript(nsIRunnable* aRunnable, - uint32_t aFlags) { +IPCBlobInputStreamThread::DispatchFromScript(nsIRunnable* aRunnable, + uint32_t aFlags) { nsCOMPtr runnable(aRunnable); return Dispatch(runnable.forget(), aFlags); } NS_IMETHODIMP -RemoteLazyInputStreamThread::DelayedDispatch(already_AddRefed, - uint32_t) { +IPCBlobInputStreamThread::DelayedDispatch(already_AddRefed, + uint32_t) { return NS_ERROR_NOT_IMPLEMENTED; } bool IsOnDOMFileThread() { - StaticMutexAutoLock lock(gRemoteLazyThreadMutex); + mozilla::StaticMutexAutoLock lock(gIPCBlobThreadMutex); MOZ_ASSERT(!gShutdownHasStarted); - MOZ_ASSERT(gRemoteLazyThread); + MOZ_ASSERT(gIPCBlobThread); - return gRemoteLazyThread->IsOnCurrentThreadInfallible(); + return gIPCBlobThread->IsOnCurrentThreadInfallible(); } void AssertIsOnDOMFileThread() { MOZ_ASSERT(IsOnDOMFileThread()); } +} // namespace dom } // namespace mozilla diff --git a/dom/file/ipc/RemoteLazyInputStreamThread.h b/dom/file/ipc/IPCBlobInputStreamThread.h similarity index 56% rename from dom/file/ipc/RemoteLazyInputStreamThread.h rename to dom/file/ipc/IPCBlobInputStreamThread.h index 44e0069c0541..e40f30d25b87 100644 --- a/dom/file/ipc/RemoteLazyInputStreamThread.h +++ b/dom/file/ipc/IPCBlobInputStreamThread.h @@ -4,10 +4,10 @@ * 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_RemoteLazyInputStreamThread_h -#define mozilla_RemoteLazyInputStreamThread_h +#ifndef mozilla_dom_IPCBlobInputStreamThread_h +#define mozilla_dom_IPCBlobInputStreamThread_h -#include "mozilla/RemoteLazyInputStreamChild.h" +#include "mozilla/dom/IPCBlobInputStreamChild.h" #include "nsIEventTarget.h" #include "nsIObserver.h" #include "nsTArray.h" @@ -15,11 +15,12 @@ class nsIThread; namespace mozilla { +namespace dom { -class RemoteLazyInputStreamChild; +class IPCBlobInputStreamChild; -class RemoteLazyInputStreamThread final : public nsIObserver, - public nsIEventTarget { +class IPCBlobInputStreamThread final : public nsIObserver, + public nsIEventTarget { public: NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_NSIOBSERVER @@ -27,32 +28,33 @@ class RemoteLazyInputStreamThread final : public nsIObserver, static bool IsOnFileEventTarget(nsIEventTarget* aEventTarget); - static RemoteLazyInputStreamThread* Get(); + static IPCBlobInputStreamThread* Get(); - static RemoteLazyInputStreamThread* GetOrCreate(); + static IPCBlobInputStreamThread* GetOrCreate(); - void MigrateActor(RemoteLazyInputStreamChild* aActor); + void MigrateActor(IPCBlobInputStreamChild* aActor); bool Initialize(); void InitializeOnMainThread(); private: - ~RemoteLazyInputStreamThread() = default; + ~IPCBlobInputStreamThread() = default; - void MigrateActorInternal(RemoteLazyInputStreamChild* aActor); + void MigrateActorInternal(IPCBlobInputStreamChild* aActor); nsCOMPtr mThread; // This is populated if MigrateActor() is called before the initialization of // the thread. - nsTArray> mPendingActors; + nsTArray> mPendingActors; }; bool IsOnDOMFileThread(); void AssertIsOnDOMFileThread(); +} // namespace dom } // namespace mozilla -#endif // mozilla_RemoteLazyInputStreamThread_h +#endif // mozilla_dom_IPCBlobInputStreamThread_h diff --git a/dom/file/ipc/IPCBlobUtils.cpp b/dom/file/ipc/IPCBlobUtils.cpp index 0862b646c78c..64860f9b2221 100644 --- a/dom/file/ipc/IPCBlobUtils.cpp +++ b/dom/file/ipc/IPCBlobUtils.cpp @@ -5,10 +5,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "IPCBlobUtils.h" -#include "RemoteLazyInputStream.h" -#include "RemoteLazyInputStreamChild.h" -#include "RemoteLazyInputStreamParent.h" -#include "RemoteLazyInputStreamUtils.h" +#include "IPCBlobInputStream.h" +#include "IPCBlobInputStreamChild.h" +#include "IPCBlobInputStreamParent.h" +#include "IPCBlobInputStreamStorage.h" #include "mozilla/dom/IPCBlob.h" #include "mozilla/ipc/BackgroundParent.h" #include "mozilla/ipc/PBackgroundParent.h" @@ -17,7 +17,6 @@ #include "mozilla/dom/ContentChild.h" #include "mozilla/ipc/IPCStreamUtils.h" #include "mozilla/ipc/ProtocolUtils.h" -#include "RemoteLazyInputStreamStorage.h" #include "StreamBlobImpl.h" #include "prtime.h" @@ -31,21 +30,20 @@ namespace IPCBlobUtils { already_AddRefed Deserialize(const IPCBlob& aIPCBlob) { nsCOMPtr inputStream; - const RemoteLazyStream& stream = aIPCBlob.inputStream(); + const IPCBlobStream& stream = aIPCBlob.inputStream(); switch (stream.type()) { // Parent to child: when an nsIInputStream is sent from parent to child, the - // child receives a RemoteLazyInputStream actor. - case RemoteLazyStream::TPRemoteLazyInputStreamChild: { - RemoteLazyInputStreamChild* actor = - static_cast( - stream.get_PRemoteLazyInputStreamChild()); + // child receives a IPCBlobInputStream actor. + case IPCBlobStream::TPIPCBlobInputStreamChild: { + IPCBlobInputStreamChild* actor = static_cast( + stream.get_PIPCBlobInputStreamChild()); inputStream = actor->CreateStream(); break; } // Child to Parent: when a blob is created on the content process send it's // sent to the parent, we have an IPCStream object. - case RemoteLazyStream::TIPCStream: + case IPCBlobStream::TIPCStream: MOZ_ASSERT(XRE_IsParentProcess()); inputStream = DeserializeIPCStream(stream.get_IPCStream()); break; @@ -77,6 +75,103 @@ already_AddRefed Deserialize(const IPCBlob& aIPCBlob) { return blobImpl.forget(); } +template +nsresult SerializeInputStreamParent(nsIInputStream* aInputStream, + uint64_t aSize, uint64_t aChildID, + PIPCBlobInputStreamParent*& aActorParent, + M* aManager) { + // Parent to Child we always send a IPCBlobInputStream. + MOZ_ASSERT(XRE_IsParentProcess()); + + nsCOMPtr stream = aInputStream; + + // In case this is a IPCBlobInputStream, we don't want to create a loop: + // IPCBlobInputStreamParent -> IPCBlobInputStream -> + // IPCBlobInputStreamParent. Let's use the underlying inputStream instead. + nsCOMPtr ipcBlobInputStream = + do_QueryInterface(aInputStream); + if (ipcBlobInputStream) { + stream = ipcBlobInputStream->GetInternalStream(); + // If we don't have an underlying stream, it's better to terminate here + // instead of sending an 'empty' IPCBlobInputStream actor on the other side, + // unable to be used. + if (NS_WARN_IF(!stream)) { + return NS_ERROR_FAILURE; + } + } + + nsresult rv; + RefPtr parentActor = + IPCBlobInputStreamParent::Create(stream, aSize, aChildID, &rv, aManager); + if (!parentActor) { + return rv; + } + + if (!aManager->SendPIPCBlobInputStreamConstructor( + parentActor, parentActor->ID(), parentActor->Size())) { + return NS_ERROR_FAILURE; + } + + aActorParent = parentActor; + return NS_OK; +} + +template +nsresult SerializeInputStreamChild(nsIInputStream* aInputStream, + IPCBlobStream& aIPCBlob, M* aManager) { + AutoIPCStream ipcStream(true /* delayed start */); + if (!ipcStream.Serialize(aInputStream, aManager)) { + return NS_ERROR_FAILURE; + } + + aIPCBlob = ipcStream.TakeValue(); + return NS_OK; +} + +nsresult SerializeInputStream(nsIInputStream* aInputStream, uint64_t aSize, + PIPCBlobInputStreamParent*& aActorParent, + ContentParent* aManager) { + return SerializeInputStreamParent(aInputStream, aSize, aManager->ChildID(), + aActorParent, aManager); +} + +nsresult SerializeInputStream(nsIInputStream* aInputStream, uint64_t aSize, + PIPCBlobInputStreamParent*& aActorParent, + PBackgroundParent* aManager) { + return SerializeInputStreamParent(aInputStream, aSize, + BackgroundParent::GetChildID(aManager), + aActorParent, aManager); +} + +nsresult SerializeInputStream(nsIInputStream* aInputStream, uint64_t aSize, + IPCBlobStream& aIPCBlob, + ContentParent* aManager) { + aIPCBlob = (PIPCBlobInputStreamParent*)nullptr; + return SerializeInputStreamParent(aInputStream, aSize, aManager->ChildID(), + aIPCBlob.get_PIPCBlobInputStreamParent(), + aManager); +} + +nsresult SerializeInputStream(nsIInputStream* aInputStream, uint64_t aSize, + IPCBlobStream& aIPCBlob, + PBackgroundParent* aManager) { + aIPCBlob = (PIPCBlobInputStreamParent*)nullptr; + return SerializeInputStreamParent( + aInputStream, aSize, BackgroundParent::GetChildID(aManager), + aIPCBlob.get_PIPCBlobInputStreamParent(), aManager); +} + +nsresult SerializeInputStream(nsIInputStream* aInputStream, uint64_t aSize, + IPCBlobStream& aIPCBlob, ContentChild* aManager) { + return SerializeInputStreamChild(aInputStream, aIPCBlob, aManager); +} + +nsresult SerializeInputStream(nsIInputStream* aInputStream, uint64_t aSize, + IPCBlobStream& aIPCBlob, + PBackgroundChild* aManager) { + return SerializeInputStreamChild(aInputStream, aIPCBlob, aManager); +} + template nsresult SerializeInternal(BlobImpl* aBlobImpl, M* aManager, IPCBlob& aIPCBlob) { @@ -130,14 +225,12 @@ nsresult SerializeInternal(BlobImpl* aBlobImpl, M* aManager, return rv.StealNSResult(); } - RemoteLazyStream stream; - rv = RemoteLazyInputStreamUtils::SerializeInputStream( - inputStream, aIPCBlob.size(), stream, aManager); + rv = SerializeInputStream(inputStream, aIPCBlob.size(), + aIPCBlob.inputStream(), aManager); if (NS_WARN_IF(rv.Failed())) { return rv.StealNSResult(); } - aIPCBlob.inputStream() = stream; return NS_OK; } diff --git a/dom/file/ipc/IPCBlobUtils.h b/dom/file/ipc/IPCBlobUtils.h index 9028542d3d27..0d4633a115e6 100644 --- a/dom/file/ipc/IPCBlobUtils.h +++ b/dom/file/ipc/IPCBlobUtils.h @@ -48,7 +48,7 @@ * the parent process). * * DocumentLoadListener uses blobs to serialize the POST data back to the - * content process (for insertion into session history). This lets it correctly + * content process (for insertion into session history). This lets it correclty * handle OS files by reference, and avoid copying the underlying buffer data * unless it is read. This can hopefully be removed once SessionHistory is * handled in the parent process. @@ -89,34 +89,34 @@ * in order to do some networking, or whatever. * * For this reason, IPCBlobUtils uses a particular protocol for serializing - * nsIInputStream parent to child: PRemoteLazyInputStream. This protocol keeps - * the original nsIInputStream alive on the parent side, and gives its size and - * a UUID to the child side. The child side creates a RemoteLazyInputStream and - * that is incapsulated into a StreamBlobImpl. + * nsIInputStream parent to child: PIPCBlobInputStream. This protocol keeps the + * original nsIInputStream alive on the parent side, and gives its size and a + * UUID to the child side. The child side creates a IPCBlobInputStream and that + * is incapsulated into a StreamBlobImpl. * * The UUID is useful when the content process sends the same nsIInputStream * back to the parent process because, the only information it has to share is - * the UUID. Each nsIInputStream sent via PRemoteLazyInputStream, is registered - * into the RemoteLazyInputStreamStorage. + * the UUID. Each nsIInputStream sent via PIPCBlobInputStream, is registered + * into the IPCBlobInputStreamStorage. * - * On the content process side, RemoteLazyInputStream is a special inputStream: + * On the content process side, IPCBlobInputStream is a special inputStream: * the only reliable methods are: - * - nsIInputStream.available() - the size is shared by PRemoteLazyInputStream + * - nsIInputStream.available() - the size is shared by PIPCBlobInputStream * actor. * - nsIIPCSerializableInputStream.serialize() - we can give back this stream to * the parent because we know its UUID. * - nsICloneableInputStream.cloneable() and nsICloneableInputStream.clone() - * this stream can be cloned. We just need to have a reference of the - * PRemoteLazyInputStream actor and its UUID. + * PIPCBlobInputStream actor and its UUID. * - nsIAsyncInputStream.asyncWait() - see next section. * * Any other method (read, readSegment and so on) will fail if asyncWait() is * not previously called (see the next section). Basically, this inputStream * cannot be used synchronously for any 'real' reading operation. * - * When the parent receives the serialization of a RemoteLazyInputStream, it is + * When the parent receives the serialization of a IPCBlobInputStream, it is * able to retrieve the correct nsIInputStream using the UUID and - * RemoteLazyInputStreamStorage. + * IPCBlobInputStreamStorage. * * Parent to Child Streams, FileReader and BlobURL * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -124,30 +124,30 @@ * The FileReader and BlobURL scenarios are described here. * * When content process needs to read data from a Blob sent from the parent - * process, it must do it asynchronously using RemoteLazyInputStream as a + * process, it must do it asynchronously using IPCBlobInputStream as a * nsIAsyncInputStream stream. This happens calling - * RemoteLazyInputStream.asyncWait(). At that point, the child actor will send a + * IPCBlobInputStream.asyncWait(). At that point, the child actor will send a * StreamNeeded() IPC message to the parent side. When this is received, the - * parent retrieves the 'real' stream from RemoteLazyInputStreamStorage using - * the UUID, it will serialize the 'real' stream, and it will send it to the - * child side. + * parent retrieves the 'real' stream from IPCBlobInputStreamStorage using the + * UUID, it will serialize the 'real' stream, and it will send it to the child + * side. * * When the 'real' stream is received (RecvStreamReady()), the asyncWait - * callback will be executed and, from that moment, any RemoteLazyInputStream + * callback will be executed and, from that moment, any IPCBlobInputStream * method will be forwarded to the 'real' stream ones. This means that the * reading will be available. * - * RemoteLazyInputStream Thread - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * DOM-File Thread + * ~~~~~~~~~~~~~~~ * - * RemoteLazyInputStreamChild actor can be created in any thread (sort of) and + * IPCBlobInputStreamChild actor can be created in any thread (sort of) and * their top-level IPDL protocol is PBackground. These actors are wrapped by 1 - * or more RemoteLazyInputStream objects in order to expose nsIInputStream + * or more IPCBlobInputStream objects in order to expose nsIInputStream * interface and be thread-safe. * * But IPDL actors are not thread-safe and any SendFoo() method must be executed * on the owning thread. This means that this thread must be kept alive for the - * life-time of the RemoteLazyInputStream. + * life-time of the IPCBlobInputStream. * * In doing this, there are 2 main issues: * a. if a remote Blob is created on a worker (because of a @@ -158,27 +158,27 @@ * used on another thread (note that nsIInputStream could do I/O and usually * they are used on special I/O threads). * - * In order to avoid this, RemoteLazyInputStreamChild are 'migrated' to a - * DOM-File thread. This is done in this way: + * In order to avoid this, IPCBlobInputStreamChild are 'migrated' to a DOM-File + * thread. This is done in this way: * - * 1. If RemoteLazyInputStreamChild actor is not already owned by DOM-File - * thread, it calls Send__delete__ in order to inform the parent side that we - * don't need this IPC channel on the current thread. - * 2. A new RemoteLazyInputStreamChild is created. RemoteLazyInputStreamThread - * is used to assign this actor to the DOM-File thread. - * RemoteLazyInputStreamThread::GetOrCreate() creates the DOM-File thread if - * it doesn't exist yet. Pending operations and RemoteLazyInputStreams are - * moved onto the new actor. - * 3. RemoteLazyInputStreamParent::Recv__delete__ is called on the parent side - * and the parent actor is deleted. Doing this we don't remove the UUID from - * RemoteLazyInputStreamStorage. - * 4. The RemoteLazyInputStream constructor is sent with the new - * RemoteLazyInputStreamChild actor, with the DOM-File thread's PBackground - * as its manager. - * 5. When the new RemoteLazyInputStreamParent actor is created, it will receive + * 1. If IPCBlobInputStreamChild actor is not already owned by DOM-File thread, + * it calls Send__delete__ in order to inform the parent side that we don't + * need this IPC channel on the current thread. + * 2. A new IPCBlobInputStreamChild is created. IPCBlobInputStreamThread is + * used to assign this actor to the DOM-File thread. + * IPCBlobInputStreamThread::GetOrCreate() creates the DOM-File thread if it + * doesn't exist yet. Pending operations and IPCBlobInputStreams are moved + * onto the new actor. + * 3. IPCBlobInputStreamParent::Recv__delete__ is called on the parent side and + * the parent actor is deleted. Doing this we don't remove the UUID from + * IPCBlobInputStreamStorage. + * 4. The IPCBlobInputStream constructor is sent with the new + * IPCBlobInputStreamChild actor, with the DOM-File thread's PBackground as + * its manager. + * 5. When the new IPCBlobInputStreamParent actor is created, it will receive * the same UUID of the previous parent actor. The nsIInputStream will be - * retrieved from RemoteLazyInputStreamStorage. - * 6. In order to avoid leaks, RemoteLazyInputStreamStorage will monitor child + * retrieved from IPCBlobInputStreamStorage. + * 6. In order to avoid leaks, IPCBlobInputStreamStorage will monitor child * processes and in case one of them dies, it will release the * nsIInputStream objects belonging to that process. * @@ -189,9 +189,9 @@ * IPCBlob and nsIAsyncInputStream * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - * RemoteLazyInputStream is always async. If the remote inputStream is not - * async, RemoteLazyInputStream will create a pipe stream around it in order to - * be consistently async. + * IPCBlobInputStream is always async. If the remote inputStream is not async, + * IPCBlobInputStream will create a pipe stream around it in order to be + * consistently async. * * Slicing IPCBlob * ~~~~~~~~~~~~~~~ @@ -204,34 +204,33 @@ * inputStream is seekable, the pipe will not be, and in order to reach the * starting point, SlicedInputStream will do consecutive read()s. * - * This problem is fixed implmenting nsICloneableWithRange in - * RemoteLazyInputStream and using cloneWithRange() when a StreamBlobImpl is - * sliced. When the remote stream is received, it will be sliced directly. + * This problem is fixed implmenting nsICloneableWithRange in IPCBlobInputStream + * and using cloneWithRange() when a StreamBlobImpl is sliced. When the remote + * stream is received, it will be sliced directly. * * If we want to represent the hierarchy of the InputStream classes, instead - * of having: |SlicedInputStream(RemoteLazyInputStream(Async - * Pipe(RemoteStream)))|, we have: |RemoteLazyInputStream(Async - * Pipe(SlicedInputStream(RemoteStream)))|. + * of having: |SlicedInputStream(IPCBlobInputStream(Async Pipe(RemoteStream)))|, + * we have: |IPCBlobInputStream(Async Pipe(SlicedInputStream(RemoteStream)))|. * - * When RemoteLazyInputStream is serialized and sent to the parent process, - * start and range are sent too and SlicedInputStream is used in the parent side - * as well. + * When IPCBlobInputStream is serialized and sent to the parent process, start + * and range are sent too and SlicedInputStream is used in the parent side as + * well. * * Socket Process * ~~~~~~~~~~~~~~ * * The socket process is a separate process used to do networking operations. * When a website sends a blob as the body of a POST/PUT request, we need to - * send the corresponding RemoteLazyInputStream to the socket process. + * send the corresponding IPCBlobInputStream to the socket process. * - * This is the only serialization of RemoteLazyInputStream from parent to child + * This is the only serialization of IPCBlobInputStream from parent to child * process and it works _only_ for the socket process. Do not expose this * serialization to PContent or PBackground or any other top-level IPDL protocol * without a DOM File peer review! * * The main difference between Socket Process is that DOM-File thread is not * used. Here is a list of reasons: - * - DOM-File moves the ownership of the RemoteLazyInputStream actors to + * - DOM-File moves the ownership of the IPCBlobInputStream actors to * PBackground, but in the Socket Process we don't have PBackground (yet?) * - Socket Process is a stable process with a simple life-time configuration: * we can keep the actors on the main-thread because no Workers are involved. @@ -250,6 +249,7 @@ namespace dom { class IPCBlob; class ContentChild; class ContentParent; +class PIPCBlobInputStreamParent; namespace IPCBlobUtils { @@ -270,6 +270,14 @@ nsresult Serialize(BlobImpl* aBlobImpl, mozilla::ipc::PBackgroundParent* aManager, IPCBlob& aIPCBlob); +nsresult SerializeInputStream(nsIInputStream* aInputStream, uint64_t aSize, + PIPCBlobInputStreamParent*& aActorParent, + ContentParent* aManager); + +nsresult SerializeInputStream(nsIInputStream* aInputStream, uint64_t aSize, + PIPCBlobInputStreamParent*& aActorParent, + mozilla::ipc::PBackgroundParent* aManager); + // WARNING: If you pass any actor which does not have P{Content,Background} as // its toplevel protocol, this method will MOZ_CRASH. nsresult SerializeUntyped(BlobImpl* aBlobImpl, mozilla::ipc::IProtocol* aActor, diff --git a/dom/file/ipc/PFileCreator.ipdl b/dom/file/ipc/PFileCreator.ipdl index 2d07b02d0986..3e223d058c65 100644 --- a/dom/file/ipc/PFileCreator.ipdl +++ b/dom/file/ipc/PFileCreator.ipdl @@ -5,7 +5,7 @@ include protocol PBackground; include protocol PChildToParentStream; include protocol PFileDescriptorSet; -include protocol PRemoteLazyInputStream; +include protocol PIPCBlobInputStream; include protocol PParentToChildStream; include IPCBlob; diff --git a/dom/file/ipc/PRemoteLazyInputStream.ipdl b/dom/file/ipc/PIPCBlobInputStream.ipdl similarity index 94% rename from dom/file/ipc/PRemoteLazyInputStream.ipdl rename to dom/file/ipc/PIPCBlobInputStream.ipdl index a2bc3a5ca229..b96594684385 100644 --- a/dom/file/ipc/PRemoteLazyInputStream.ipdl +++ b/dom/file/ipc/PIPCBlobInputStream.ipdl @@ -12,8 +12,9 @@ include protocol PSocketProcess; include IPCStream; namespace mozilla { +namespace dom { -refcounted protocol PRemoteLazyInputStream +refcounted protocol PIPCBlobInputStream { manager PBackground or PContent or PSocketProcess; @@ -43,4 +44,6 @@ both: async __delete__(); }; +} // namespace dom } // namespace mozilla + diff --git a/dom/file/ipc/PTemporaryIPCBlob.ipdl b/dom/file/ipc/PTemporaryIPCBlob.ipdl index 5c57221b9616..82dd285bce26 100644 --- a/dom/file/ipc/PTemporaryIPCBlob.ipdl +++ b/dom/file/ipc/PTemporaryIPCBlob.ipdl @@ -5,8 +5,8 @@ include protocol PBackground; include protocol PChildToParentStream; include protocol PFileDescriptorSet; +include protocol PIPCBlobInputStream; include protocol PParentToChildStream; -include protocol PRemoteLazyInputStream; include IPCBlob; diff --git a/dom/file/ipc/RemoteLazyInputStreamUtils.cpp b/dom/file/ipc/RemoteLazyInputStreamUtils.cpp deleted file mode 100644 index 633711731b5f..000000000000 --- a/dom/file/ipc/RemoteLazyInputStreamUtils.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/* -*- 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 "RemoteLazyInputStreamUtils.h" -#include "RemoteLazyInputStream.h" -#include "RemoteLazyInputStreamChild.h" -#include "RemoteLazyInputStreamParent.h" -#include "mozilla/ipc/BackgroundParent.h" -#include "mozilla/ipc/PBackgroundParent.h" -#include "mozilla/dom/ContentParent.h" -#include "mozilla/ipc/IPCStreamUtils.h" -#include "RemoteLazyInputStreamStorage.h" -#include "StreamBlobImpl.h" - -namespace mozilla { - -namespace { - -template -nsresult SerializeInputStreamParent(nsIInputStream* aInputStream, - uint64_t aSize, uint64_t aChildID, - PRemoteLazyInputStreamParent*& aActorParent, - M* aManager) { - // Parent to Child we always send a RemoteLazyInputStream. - MOZ_ASSERT(XRE_IsParentProcess()); - - nsCOMPtr stream = aInputStream; - - // In case this is a RemoteLazyInputStream, we don't want to create a loop: - // RemoteLazyInputStreamParent -> RemoteLazyInputStream -> - // RemoteLazyInputStreamParent. Let's use the underlying inputStream instead. - nsCOMPtr remoteLazyInputStream = - do_QueryInterface(aInputStream); - if (remoteLazyInputStream) { - stream = remoteLazyInputStream->GetInternalStream(); - // If we don't have an underlying stream, it's better to terminate here - // instead of sending an 'empty' RemoteLazyInputStream actor on the other - // side, unable to be used. - if (NS_WARN_IF(!stream)) { - return NS_ERROR_FAILURE; - } - } - - nsresult rv; - RefPtr parentActor = - RemoteLazyInputStreamParent::Create(stream, aSize, aChildID, &rv, - aManager); - if (!parentActor) { - return rv; - } - - if (!aManager->SendPRemoteLazyInputStreamConstructor( - parentActor, parentActor->ID(), parentActor->Size())) { - return NS_ERROR_FAILURE; - } - - aActorParent = parentActor; - return NS_OK; -} - -} // anonymous namespace - -// static -nsresult RemoteLazyInputStreamUtils::SerializeInputStream( - nsIInputStream* aInputStream, uint64_t aSize, RemoteLazyStream& aOutStream, - ContentParent* aManager) { - PRemoteLazyInputStreamParent* actor = nullptr; - nsresult rv = SerializeInputStreamParent( - aInputStream, aSize, aManager->ChildID(), actor, aManager); - NS_ENSURE_SUCCESS(rv, rv); - - aOutStream = actor; - return NS_OK; -} - -// static -nsresult RemoteLazyInputStreamUtils::SerializeInputStream( - nsIInputStream* aInputStream, uint64_t aSize, RemoteLazyStream& aOutStream, - PBackgroundParent* aManager) { - PRemoteLazyInputStreamParent* actor = nullptr; - nsresult rv = SerializeInputStreamParent( - aInputStream, aSize, BackgroundParent::GetChildID(aManager), actor, - aManager); - NS_ENSURE_SUCCESS(rv, rv); - - aOutStream = actor; - return NS_OK; -} - -// static -nsresult RemoteLazyInputStreamUtils::SerializeInputStream( - nsIInputStream* aInputStream, uint64_t aSize, RemoteLazyStream& aOutStream, - ContentChild* aManager) { - AutoIPCStream ipcStream(true /* delayed start */); - if (!ipcStream.Serialize(aInputStream, aManager)) { - return NS_ERROR_FAILURE; - } - - aOutStream = ipcStream.TakeValue(); - return NS_OK; -} - -// static -nsresult RemoteLazyInputStreamUtils::SerializeInputStream( - nsIInputStream* aInputStream, uint64_t aSize, RemoteLazyStream& aOutStream, - PBackgroundChild* aManager) { - AutoIPCStream ipcStream(true /* delayed start */); - if (!ipcStream.Serialize(aInputStream, aManager)) { - return NS_ERROR_FAILURE; - } - - aOutStream = ipcStream.TakeValue(); - return NS_OK; -} - -} // namespace mozilla diff --git a/dom/file/ipc/RemoteLazyInputStreamUtils.h b/dom/file/ipc/RemoteLazyInputStreamUtils.h deleted file mode 100644 index 416d19129bb7..000000000000 --- a/dom/file/ipc/RemoteLazyInputStreamUtils.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- 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/. */ - -#ifndef mozilla_RemoteLazyInputStreamUtils_h -#define mozilla_RemoteLazyInputStreamUtils_h - -/* - * RemoteLazyInputStream was previously part of the IPCBlob world. - * See IPCBlobUtils.h to know how to use it. As a follow up, the documentation - * will be partially moved here too. - */ - -namespace mozilla { - -class RemoteLazyStream; - -namespace ipc { -class IPCStream; -class PBackgroundChild; -class PBackgroundParent; -} // namespace ipc - -namespace dom { -class ContentChild; -class ContentParent; -} // namespace dom - -class RemoteLazyInputStreamUtils final { - public: - static nsresult SerializeInputStream(nsIInputStream* aInputStream, - uint64_t aSize, - RemoteLazyStream& aOutStream, - dom::ContentParent* aManager); - - static nsresult SerializeInputStream( - nsIInputStream* aInputStream, uint64_t aSize, - RemoteLazyStream& aOutStream, mozilla::ipc::PBackgroundParent* aManager); - - static nsresult SerializeInputStream(nsIInputStream* aInputStream, - uint64_t aSize, - RemoteLazyStream& aOutStream, - dom::ContentChild* aManager); - - static nsresult SerializeInputStream( - nsIInputStream* aInputStream, uint64_t aSize, - RemoteLazyStream& aOutStream, mozilla::ipc::PBackgroundChild* aManager); -}; - -} // namespace mozilla - -#endif // mozilla_RemoteLazyInputStreamUtils_h diff --git a/dom/file/ipc/moz.build b/dom/file/ipc/moz.build index f5f1570cb7e8..a04659ff0015 100644 --- a/dom/file/ipc/moz.build +++ b/dom/file/ipc/moz.build @@ -8,7 +8,7 @@ with Files("**"): BUG_COMPONENT = ("Core", "DOM: File") XPIDL_SOURCES += [ - 'mozIRemoteLazyInputStream.idl', + 'mozIIPCBlobInputStream.idl', ] XPIDL_MODULE = 'dom' @@ -16,29 +16,24 @@ XPIDL_MODULE = 'dom' EXPORTS.mozilla.dom += [ 'FileCreatorChild.h', 'FileCreatorParent.h', + 'IPCBlobInputStream.h', + 'IPCBlobInputStreamChild.h', + 'IPCBlobInputStreamParent.h', + 'IPCBlobInputStreamStorage.h', 'IPCBlobUtils.h', 'TemporaryIPCBlobChild.h', 'TemporaryIPCBlobParent.h', ] -EXPORTS.mozilla += [ - 'RemoteLazyInputStream.h', - 'RemoteLazyInputStreamChild.h', - 'RemoteLazyInputStreamParent.h', - 'RemoteLazyInputStreamStorage.h', - 'RemoteLazyInputStreamUtils.h', -] - UNIFIED_SOURCES += [ 'FileCreatorChild.cpp', 'FileCreatorParent.cpp', + 'IPCBlobInputStream.cpp', + 'IPCBlobInputStreamChild.cpp', + 'IPCBlobInputStreamParent.cpp', + 'IPCBlobInputStreamStorage.cpp', + 'IPCBlobInputStreamThread.cpp', 'IPCBlobUtils.cpp', - 'RemoteLazyInputStream.cpp', - 'RemoteLazyInputStreamChild.cpp', - 'RemoteLazyInputStreamParent.cpp', - 'RemoteLazyInputStreamStorage.cpp', - 'RemoteLazyInputStreamThread.cpp', - 'RemoteLazyInputStreamUtils.cpp', 'TemporaryIPCBlobChild.cpp', 'TemporaryIPCBlobParent.cpp', ] @@ -47,7 +42,7 @@ IPDL_SOURCES += [ 'BlobTypes.ipdlh', 'IPCBlob.ipdlh', 'PFileCreator.ipdl', - 'PRemoteLazyInputStream.ipdl', + 'PIPCBlobInputStream.ipdl', 'PTemporaryIPCBlob.ipdl', ] diff --git a/dom/file/ipc/mozIRemoteLazyInputStream.idl b/dom/file/ipc/mozIIPCBlobInputStream.idl similarity index 74% rename from dom/file/ipc/mozIRemoteLazyInputStream.idl rename to dom/file/ipc/mozIIPCBlobInputStream.idl index 07d77d0cb279..d452d5c52366 100644 --- a/dom/file/ipc/mozIRemoteLazyInputStream.idl +++ b/dom/file/ipc/mozIIPCBlobInputStream.idl @@ -7,11 +7,10 @@ interface nsIInputStream; /* - * A simple interface to get the underlying stream from an - * RemoteLazyInputStream. + * A simple interface to get the underlying stream from an IPCBlobInputStream. */ [scriptable, builtinclass, uuid(4125585f-b0c2-4964-a83c-4b0d99f26d49)] -interface mozIRemoteLazyInputStream : nsISupports +interface mozIIPCBlobInputStream : nsISupports { [notxpcom, noscript] nsIInputStream GetInternalStream(); }; diff --git a/dom/filehandle/PBackgroundFileHandle.ipdl b/dom/filehandle/PBackgroundFileHandle.ipdl index a9a5cb3ba6ec..82863f338a6d 100644 --- a/dom/filehandle/PBackgroundFileHandle.ipdl +++ b/dom/filehandle/PBackgroundFileHandle.ipdl @@ -6,8 +6,8 @@ include protocol PBackgroundFileRequest; include protocol PBackgroundMutableFile; include protocol PChildToParentStream; // FIXME: bug 792908 include protocol PFileDescriptorSet; // FIXME: bug 792908 +include protocol PIPCBlobInputStream; // FIXME: bug 792908 include protocol PParentToChildStream; // FIXME: bug 792908 -include protocol PRemoteLazyInputStream; // FIXME: bug 792908 include IPCBlob; diff --git a/dom/filesystem/PFileSystemRequest.ipdl b/dom/filesystem/PFileSystemRequest.ipdl index 6f173bc107c1..e3867928d484 100644 --- a/dom/filesystem/PFileSystemRequest.ipdl +++ b/dom/filesystem/PFileSystemRequest.ipdl @@ -5,10 +5,10 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ include protocol PBackground; +include protocol PIPCBlobInputStream; include protocol PChildToParentStream; include protocol PParentToChildStream; include protocol PFileDescriptorSet; -include protocol PRemoteLazyInputStream; include IPCBlob; diff --git a/dom/indexedDB/ActorsChild.cpp b/dom/indexedDB/ActorsChild.cpp index 5996e5bae781..6aa4e0dd9759 100644 --- a/dom/indexedDB/ActorsChild.cpp +++ b/dom/indexedDB/ActorsChild.cpp @@ -22,7 +22,7 @@ #include "IndexedDatabaseInlines.h" #include "js/Array.h" // JS::NewArrayObject, JS::SetArrayLength #include "js/Date.h" // JS::NewDateObject, JS::TimeClip -#include +#include #include "mozilla/ArrayAlgorithm.h" #include "mozilla/BasicEvents.h" #include "mozilla/CycleCollectedJSRuntime.h" @@ -2758,8 +2758,7 @@ nsresult BackgroundRequestChild::PreprocessHelper::ProcessStream() { // SnappyUncompressInputStream doesn't support reading from async input // streams. - nsCOMPtr blobInputStream = - do_QueryInterface(mStream); + nsCOMPtr blobInputStream = do_QueryInterface(mStream); MOZ_ASSERT(blobInputStream); nsCOMPtr internalInputStream = diff --git a/dom/indexedDB/ActorsParent.cpp b/dom/indexedDB/ActorsParent.cpp index 0724b3fc3092..5d51523c3769 100644 --- a/dom/indexedDB/ActorsParent.cpp +++ b/dom/indexedDB/ActorsParent.cpp @@ -62,6 +62,7 @@ #include "mozilla/dom/indexedDB/PBackgroundIDBTransactionParent.h" #include "mozilla/dom/indexedDB/PBackgroundIDBVersionChangeTransactionParent.h" #include "mozilla/dom/indexedDB/PBackgroundIndexedDBUtilsParent.h" +#include "mozilla/dom/IPCBlobInputStreamParent.h" #include "mozilla/dom/IPCBlobUtils.h" #include "mozilla/dom/quota/CheckedUnsafePtr.h" #include "mozilla/dom/quota/Client.h" @@ -76,7 +77,6 @@ #include "mozilla/ipc/InputStreamUtils.h" #include "mozilla/ipc/PBackground.h" #include "mozilla/ipc/PBackgroundParent.h" -#include "mozilla/RemoteLazyInputStreamParent.h" #include "mozilla/Scoped.h" #include "mozilla/storage/Variant.h" #include "mozIStorageFunction.h" @@ -6053,7 +6053,7 @@ class Database::StartTransactionOp final }; class Database::UnmapBlobCallback final - : public RemoteLazyInputStreamParentCallback { + : public IPCBlobInputStreamParentCallback { SafeRefPtr mDatabase; public: @@ -13796,12 +13796,11 @@ void Database::MapBlob(const IPCBlob& aIPCBlob, SafeRefPtr aFileInfo) { AssertIsOnBackgroundThread(); - const RemoteLazyStream& stream = aIPCBlob.inputStream(); - MOZ_ASSERT(stream.type() == RemoteLazyStream::TPRemoteLazyInputStreamParent); + const IPCBlobStream& stream = aIPCBlob.inputStream(); + MOZ_ASSERT(stream.type() == IPCBlobStream::TPIPCBlobInputStreamParent); - RemoteLazyInputStreamParent* actor = - static_cast( - stream.get_PRemoteLazyInputStreamParent()); + IPCBlobInputStreamParent* actor = static_cast( + stream.get_PIPCBlobInputStreamParent()); MOZ_ASSERT(!mMappedBlobs.GetWeak(actor->ID())); mMappedBlobs.Put(actor->ID(), AsRefPtr(std::move(aFileInfo))); @@ -13854,25 +13853,25 @@ void Database::Stringify(nsACString& aResult) const { SafeRefPtr Database::GetBlob(const IPCBlob& aIPCBlob) { AssertIsOnBackgroundThread(); - const RemoteLazyStream& stream = aIPCBlob.inputStream(); - MOZ_ASSERT(stream.type() == RemoteLazyStream::TIPCStream); + const IPCBlobStream& stream = aIPCBlob.inputStream(); + MOZ_ASSERT(stream.type() == IPCBlobStream::TIPCStream); const IPCStream& ipcStream = stream.get_IPCStream(); const InputStreamParams& inputStreamParams = ipcStream.stream(); if (inputStreamParams.type() != - InputStreamParams::TRemoteLazyInputStreamParams) { + InputStreamParams::TIPCBlobInputStreamParams) { return nullptr; } - const RemoteLazyInputStreamParams& ipcBlobInputStreamParams = - inputStreamParams.get_RemoteLazyInputStreamParams(); + const IPCBlobInputStreamParams& ipcBlobInputStreamParams = + inputStreamParams.get_IPCBlobInputStreamParams(); if (ipcBlobInputStreamParams.type() != - RemoteLazyInputStreamParams::TRemoteLazyInputStreamRef) { + IPCBlobInputStreamParams::TIPCBlobInputStreamRef) { return nullptr; } - const nsID& id = ipcBlobInputStreamParams.get_RemoteLazyInputStreamRef().id(); + const nsID& id = ipcBlobInputStreamParams.get_IPCBlobInputStreamRef().id(); RefPtr fileInfo; if (!mMappedBlobs.Get(id, getter_AddRefs(fileInfo))) { diff --git a/dom/indexedDB/PBackgroundIDBCursor.ipdl b/dom/indexedDB/PBackgroundIDBCursor.ipdl index f164d73006a5..7421488a1727 100644 --- a/dom/indexedDB/PBackgroundIDBCursor.ipdl +++ b/dom/indexedDB/PBackgroundIDBCursor.ipdl @@ -7,8 +7,8 @@ include protocol PBackgroundIDBVersionChangeTransaction; include protocol PBackgroundMutableFile; include protocol PChildToParentStream; // FIXME: bug 792908 include protocol PFileDescriptorSet; // FIXME: bug 792908 +include protocol PIPCBlobInputStream; // FIXME: bug 792908 include protocol PParentToChildStream; // FIXME: bug 792908 -include protocol PRemoteLazyInputStream; // FIXME: bug 792908 include PBackgroundIDBSharedTypes; diff --git a/dom/indexedDB/PBackgroundIDBDatabase.ipdl b/dom/indexedDB/PBackgroundIDBDatabase.ipdl index ddf764c26b06..efe6e978f6a3 100644 --- a/dom/indexedDB/PBackgroundIDBDatabase.ipdl +++ b/dom/indexedDB/PBackgroundIDBDatabase.ipdl @@ -10,8 +10,8 @@ include protocol PBackgroundIDBVersionChangeTransaction; include protocol PBackgroundMutableFile; include protocol PChildToParentStream; // FIXME: bug 792908 include protocol PFileDescriptorSet; // FIXME: bug 792908 +include protocol PIPCBlobInputStream; // FIXME: bug 792908 include protocol PParentToChildStream; // FIXME: bug 792908 -include protocol PRemoteLazyInputStream; // FIXME: bug 792908 include IPCBlob; include InputStreamParams; diff --git a/dom/indexedDB/PBackgroundIDBRequest.ipdl b/dom/indexedDB/PBackgroundIDBRequest.ipdl index 9c944aea760e..a98ac194235c 100644 --- a/dom/indexedDB/PBackgroundIDBRequest.ipdl +++ b/dom/indexedDB/PBackgroundIDBRequest.ipdl @@ -7,8 +7,8 @@ include protocol PBackgroundIDBVersionChangeTransaction; include protocol PBackgroundMutableFile; include protocol PChildToParentStream; // FIXME: bug 792908 include protocol PFileDescriptorSet; // FIXME: bug 792908 +include protocol PIPCBlobInputStream; // FIXME: bug 792908 include protocol PParentToChildStream; // FIXME: bug 792908 -include protocol PRemoteLazyInputStream; // FIXME: bug 792908 include PBackgroundIDBSharedTypes; diff --git a/dom/indexedDB/PBackgroundIDBSharedTypes.ipdlh b/dom/indexedDB/PBackgroundIDBSharedTypes.ipdlh index f6cc63044ad2..d2cce5bf0093 100644 --- a/dom/indexedDB/PBackgroundIDBSharedTypes.ipdlh +++ b/dom/indexedDB/PBackgroundIDBSharedTypes.ipdlh @@ -6,8 +6,8 @@ include protocol PBackgroundIDBDatabaseFile; include protocol PBackgroundMutableFile; include protocol PChildToParentStream; // FIXME: bug 792908 include protocol PFileDescriptorSet; // FIXME: bug 792908 +include protocol PIPCBlobInputStream; // FIXME: bug 792908 include protocol PParentToChildStream; // FIXME: bug 792908 -include protocol PRemoteLazyInputStream; // FIXME: bug 792908 include DOMTypes; include IPCBlob; diff --git a/dom/indexedDB/PBackgroundIDBVersionChangeTransaction.ipdl b/dom/indexedDB/PBackgroundIDBVersionChangeTransaction.ipdl index b64d0cbbb5ff..35572106273b 100644 --- a/dom/indexedDB/PBackgroundIDBVersionChangeTransaction.ipdl +++ b/dom/indexedDB/PBackgroundIDBVersionChangeTransaction.ipdl @@ -9,8 +9,8 @@ include protocol PBackgroundIDBRequest; include protocol PBackgroundMutableFile; include protocol PChildToParentStream; // FIXME: bug 792908 include protocol PFileDescriptorSet; // FIXME: bug 792908 +include protocol PIPCBlobInputStream; // FIXME: bug 792908 include protocol PParentToChildStream; // FIXME: bug 792908 -include protocol PRemoteLazyInputStream; // FIXME: bug 792908 include PBackgroundIDBSharedTypes; diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 4a3a84cd2408..c0a72bc0f91e 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -51,6 +51,7 @@ #include "mozilla/dom/ExternalHelperAppChild.h" #include "mozilla/dom/GetFilesHelper.h" #include "mozilla/dom/InProcessChild.h" +#include "mozilla/dom/IPCBlobInputStreamChild.h" #include "mozilla/dom/IPCBlobUtils.h" #include "mozilla/dom/JSActorService.h" #include "mozilla/dom/JSProcessActorBinding.h" @@ -97,7 +98,6 @@ #include "mozilla/PerformanceUtils.h" #include "mozilla/plugins/PluginInstanceParent.h" #include "mozilla/plugins/PluginModuleParent.h" -#include "mozilla/RemoteLazyInputStreamChild.h" #include "mozilla/widget/ScreenManager.h" #include "mozilla/widget/WidgetMessageUtils.h" #include "nsBaseDragService.h" @@ -1803,11 +1803,11 @@ bool ContentChild::DeallocPFileDescriptorSetChild( return true; } -already_AddRefed -ContentChild::AllocPRemoteLazyInputStreamChild(const nsID& aID, - const uint64_t& aSize) { - RefPtr actor = - new RemoteLazyInputStreamChild(aID, aSize); +already_AddRefed +ContentChild::AllocPIPCBlobInputStreamChild(const nsID& aID, + const uint64_t& aSize) { + RefPtr actor = + new IPCBlobInputStreamChild(aID, aSize); return actor.forget(); } diff --git a/dom/ipc/ContentChild.h b/dom/ipc/ContentChild.h index b82f37abcdf0..863318ac5679 100644 --- a/dom/ipc/ContentChild.h +++ b/dom/ipc/ContentChild.h @@ -191,8 +191,8 @@ class ContentChild final : public PContentChild, mozilla::ipc::IPCResult RecvSetProcessSandbox( const Maybe& aBroker); - already_AddRefed - AllocPRemoteLazyInputStreamChild(const nsID& aID, const uint64_t& aSize); + already_AddRefed AllocPIPCBlobInputStreamChild( + const nsID& aID, const uint64_t& aSize); PHalChild* AllocPHalChild(); bool DeallocPHalChild(PHalChild*); diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 083080ce1942..281099117c91 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -96,6 +96,7 @@ #include "mozilla/dom/GeolocationBinding.h" #include "mozilla/dom/GeolocationPositionError.h" #include "mozilla/dom/GetFilesHelper.h" +#include "mozilla/dom/IPCBlobInputStreamParent.h" #include "mozilla/dom/IPCBlobUtils.h" #include "mozilla/dom/JSActorService.h" #include "mozilla/dom/JSProcessActorBinding.h" @@ -153,7 +154,6 @@ #include "mozilla/net/NeckoParent.h" #include "mozilla/net/PCookieServiceParent.h" #include "mozilla/plugins/PluginBridge.h" -#include "mozilla/RemoteLazyInputStreamParent.h" #include "mozilla/widget/ScreenManager.h" #include "nsAnonymousTemporaryFile.h" #include "nsAppRunner.h" diff --git a/dom/ipc/DOMTypes.ipdlh b/dom/ipc/DOMTypes.ipdlh index 68bc920a4126..b8aa6b90f8fc 100644 --- a/dom/ipc/DOMTypes.ipdlh +++ b/dom/ipc/DOMTypes.ipdlh @@ -11,7 +11,7 @@ include "mozilla/layers/LayersMessageUtils.h"; include IPCBlob; include IPCStream; -include protocol PRemoteLazyInputStream; +include protocol PIPCBlobInputStream; include ProtocolTypes; using struct mozilla::void_t @@ -314,7 +314,7 @@ struct ReplacementChannelConfigInit nsCString? method; nsIReferrerInfo referrerInfo; TimedChannelInfo? timedChannel; - nullable PRemoteLazyInputStream uploadStream; + nullable PIPCBlobInputStream uploadStream; bool uploadStreamHasHeaders; nsCString? contentType; nsCString? contentLength; diff --git a/dom/ipc/PBrowser.ipdl b/dom/ipc/PBrowser.ipdl index bd9189b32e24..00e3756422fb 100644 --- a/dom/ipc/PBrowser.ipdl +++ b/dom/ipc/PBrowser.ipdl @@ -16,7 +16,7 @@ include protocol PRemotePrintJob; include protocol PChildToParentStream; include protocol PParentToChildStream; include protocol PFileDescriptorSet; -include protocol PRemoteLazyInputStream; +include protocol PIPCBlobInputStream; include protocol PPaymentRequest; include protocol PWindowGlobal; include protocol PBrowserBridge; diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl index 0e7f985793bc..4d70413adb50 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -16,7 +16,7 @@ include protocol PHal; include protocol PHeapSnapshotTempFileHelper; include protocol PProcessHangMonitor; include protocol PImageBridge; -include protocol PRemoteLazyInputStream; +include protocol PIPCBlobInputStream; include protocol PLoginReputation; include protocol PMedia; include protocol PNecko; @@ -393,7 +393,7 @@ nested(upto inside_cpow) sync protocol PContent manages PHal; manages PHandlerService; manages PHeapSnapshotTempFileHelper; - manages PRemoteLazyInputStream; + manages PIPCBlobInputStream; manages PMedia; manages PNecko; manages POfflineCacheUpdate; @@ -757,7 +757,7 @@ child: async RefreshScreens(ScreenDetails[] aScreens); - async PRemoteLazyInputStream(nsID aID, uint64_t aSize); + async PIPCBlobInputStream(nsID aID, uint64_t aSize); /** * This call takes the set of plugins loaded in the chrome process, and diff --git a/dom/ipc/PFilePicker.ipdl b/dom/ipc/PFilePicker.ipdl index 774cc0efe5c9..02c747355f6b 100644 --- a/dom/ipc/PFilePicker.ipdl +++ b/dom/ipc/PFilePicker.ipdl @@ -6,9 +6,9 @@ include protocol PBrowser; include protocol PChildToParentStream; +include protocol PIPCBlobInputStream; include protocol PFileDescriptorSet; include protocol PParentToChildStream; -include protocol PRemoteLazyInputStream; include IPCBlob; diff --git a/dom/localstorage/LSObject.cpp b/dom/localstorage/LSObject.cpp index 933eb987a9d9..0650e7dfd546 100644 --- a/dom/localstorage/LSObject.cpp +++ b/dom/localstorage/LSObject.cpp @@ -7,6 +7,7 @@ #include "LSObject.h" #include "ActorsChild.h" +#include "IPCBlobInputStreamThread.h" #include "LocalStorageCommon.h" #include "mozilla/BasePrincipal.h" #include "mozilla/StaticPrefs_dom.h" @@ -18,7 +19,6 @@ #include "nsContentUtils.h" #include "nsIScriptObjectPrincipal.h" #include "nsThread.h" -#include "RemoteLazyInputStreamThread.h" /** * Automatically cancel and abort synchronous LocalStorage requests (for example @@ -83,16 +83,15 @@ class NestedEventTargetWrapper final : public nsISerialEventTarget { * The normal life-cycle of this method looks like: * - Main Thread: LSObject::DoRequestSynchronously creates a RequestHelper and * invokes StartAndReturnResponse(). It pushes the event queue and Dispatches - * the RequestHelper to the RemoteLazyInputStream thread. - * - RemoteLazyInputStream Thread: RequestHelper::Run is called, invoking - * Start() which invokes LSObject::StartRequest, which gets-or-creates the - * PBackground actor if necessary (which may dispatch a runnable to the nested - * event queue on the main thread), sends LSRequest constructor which is - * provided with a callback reference to the RequestHelper. State advances to - * ResponsePending. - * - RemoteLazyInputStreamThread: LSRequestChild::Recv__delete__ is received, - * which invokes RequestHelepr::OnResponse, advancing the state to Finishing - * and dispatching RequestHelper to its own nested event target. + * the RequestHelper to the DOM File Thread. + * - DOM File Thread: RequestHelper::Run is called, invoking Start() which + * invokes LSObject::StartRequest, which gets-or-creates the PBackground actor + * if necessary (which may dispatch a runnable to the nested event queue on + * the main thread), sends LSRequest constructor which is provided with a + * callback reference to the RequestHelper. State advances to ResponsePending. + * - DOM File Thread:: LSRequestChild::Recv__delete__ is received, which invokes + * RequestHelepr::OnResponse, advancing the state to Finishing and dispatching + * RequestHelper to its own nested event target. * - Main Thread: RequestHelper::Run is called, invoking Finish() which advances * the state to Complete and sets mWaiting to false, allowing the nested event * loop being spun by StartAndReturnResponse to cease spinning and return the @@ -104,12 +103,11 @@ class NestedEventTargetWrapper final : public nsISerialEventTarget { class RequestHelper final : public Runnable, public LSRequestChildCallback { enum class State { /** - * The RequestHelper has been created and dispatched to the - * RemoteLazyInputStream Thread. + * The RequestHelper has been created and dispatched to the DOM File Thread. */ Initial, /** - * Start() has been invoked on the RemoteLazyInputStream Thread and + * Start() has been invoked on the DOM File Thread and * LSObject::StartRequest has been invoked from there, sending an IPC * message to PBackground to service the request. We stay in this state * until a response is received. @@ -219,7 +217,7 @@ void LSObject::Initialize() { MOZ_ASSERT(NS_IsMainThread()); nsCOMPtr domFileThread = - RemoteLazyInputStreamThread::GetOrCreate(); + IPCBlobInputStreamThread::GetOrCreate(); if (NS_WARN_IF(!domFileThread)) { return; } @@ -829,9 +827,9 @@ nsresult LSObject::DoRequestSynchronously(const LSRequestParams& aParams, RefPtr helper = new RequestHelper(this, aParams); - // This will start and finish the request on the RemoteLazyInputStream thread. + // This will start and finish the request on the DOM File thread. // The owning thread is synchronously blocked while the request is - // asynchronously processed on the RemoteLazyInputStream thread. + // asynchronously processed on the DOM File thread. nsresult rv = helper->StartAndReturnResponse(aResponse); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; @@ -898,7 +896,7 @@ nsresult LSObject::EnsureDatabase() { uint64_t datastoreId = prepareDatastoreResponse.datastoreId(); // The datastore is now ready on the parent side (prepared by the asynchronous - // request on the RemoteLazyInputStream thread). + // request on the DOM File thread). // Let's create a direct connection to the datastore (through a database // actor) from the owning thread. // Note that we now can't error out, otherwise parent will keep an extra @@ -963,7 +961,7 @@ nsresult LSObject::EnsureObserver() { uint64_t observerId = prepareObserverResponse.observerId(); // The obsserver is now ready on the parent side (prepared by the asynchronous - // request on the RemoteLazyInputStream thread). + // request on the DOM File thread). // Let's create a direct connection to the observer (through an observer // actor) from the owning thread. // Note that we now can't error out, otherwise parent will keep an extra @@ -1107,8 +1105,8 @@ nsresult RequestHelper::StartAndReturnResponse(LSRequestResponse& aResponse) { // Normally, we would use the standard way of blocking the thread using // a monitor. // The problem is that BackgroundChild::GetOrCreateForCurrentThread() - // called on the RemoteLazyInputStream thread may dispatch a runnable to the - // main thread to finish initialization of PBackground. A monitor would block + // called on the DOM File thread may dispatch a runnable to the main + // thread to finish initialization of PBackground. A monitor would block // the main thread and the runnable would never get executed causing the // helper to be stuck in a wait loop. // However, BackgroundChild::GetOrCreateForCurrentThread() supports passing @@ -1129,8 +1127,8 @@ nsresult RequestHelper::StartAndReturnResponse(LSRequestResponse& aResponse) { new NestedEventTargetWrapper(mNestedEventTarget); nsCOMPtr domFileThread = - XRE_IsParentProcess() ? RemoteLazyInputStreamThread::GetOrCreate() - : RemoteLazyInputStreamThread::Get(); + XRE_IsParentProcess() ? IPCBlobInputStreamThread::GetOrCreate() + : IPCBlobInputStreamThread::Get(); if (NS_WARN_IF(!domFileThread)) { return NS_ERROR_FAILURE; } @@ -1204,8 +1202,8 @@ nsresult RequestHelper::StartAndReturnResponse(LSRequestResponse& aResponse) { // We can check mWaiting here because it's only ever touched on the main // thread. if (NS_WARN_IF(mWaiting)) { - // Don't touch mResponse, mResultCode or mState here! The - // RemoteLazyInputStream Thread may be accessing them at the same moment. + // Don't touch mResponse, mResultCode or mState here! The DOM File Thread + // may be accessing them at the same moment. RefPtr self = this; diff --git a/dom/localstorage/LocalStorageCommon.h b/dom/localstorage/LocalStorageCommon.h index a736092bca53..5abaad076a66 100644 --- a/dom/localstorage/LocalStorageCommon.h +++ b/dom/localstorage/LocalStorageCommon.h @@ -81,16 +81,16 @@ * like directory locking before sending a reply to a synchronous message, then * we would have to block the thread or spin the event loop which is usually a * bad idea, especially in the main process. - * Instead, we can use a special thread in the content process called - * RemoteLazyInputStream thread for communication with the main process using - * asynchronous messages and synchronously block the main thread until the DOM - * File thread is done (the main thread blocking is a bit more complicated, see - * the comment in RequestHelper::StartAndReturnResponse for more details). - * Anyway, the extra hop to the RemoteLazyInputStream thread brings another - * overhead and latency. The final solution is to use a combination of the - * special thread for complex stuff like datastore preparation and synchronous - * IPC messages sent directly from the main thread for database access when data - * is already loaded from disk into memory. + * Instead, we can use a special thread in the content process called DOM File + * thread for communication with the main process using asynchronous messages + * and synchronously block the main thread until the DOM File thread is done + * (the main thread blocking is a bit more complicated, see the comment in + * RequestHelper::StartAndReturnResponse for more details). + * Anyway, the extra hop to the DOM File thread brings another overhead and + * latency. The final solution is to use a combination of the special thread + * for complex stuff like datastore preparation and synchronous IPC messages + * sent directly from the main thread for database access when data is already + * loaded from disk into memory. * * Requests * ~~~~~~~~ @@ -116,13 +116,13 @@ * responses and do safe main thread blocking at the same time. * It inherits from the "Runnable" class, so instances are ref counted and * they are internally used on multiple threads (specifically on the main - * thread and on the RemoteLazyInputStream thread). Anyway, users should create - * and use instances of this class only on the main thread (apart from a special - * case when we need to cancel the request from an internal chromium IPC thread - * to prevent a dead lock involving CPOWs). + * thread and on the DOM File thread). Anyway, users should create and use + * instances of this class only on the main thread (apart from a special case + * when we need to cancel the request from an internal chromium IPC thread to + * prevent a dead lock involving CPOWs). * The actual child actor is represented by the "LSRequestChild" class that * implements the "PBackgroundLSRequestChild" interface. An "LSRequestChild" - * instance is not ref counted and lives on the RemoteLazyInputStream thread. + * instance is not ref counted and lives on the DOM File thread. * Request responses are passed using the "LSRequestChildCallback" interface. * * Preparation of a datastore @@ -157,10 +157,9 @@ * In theory, the datastore preparation request could return a database actor * directly (instead of returning an id intended for database linking to a * datastore). However, as it was explained above, the preparation must be done - * on the RemoteLazyInputStream thread and database objects are used on the main - * thread. The returned actor would have to be migrated from the - * RemoteLazyInputStream thread to the main thread and that's something which - * our IPDL doesn't support yet. + * on the DOM File thread and database objects are used on the main thread. The + * returned actor would have to be migrated from the DOM File thread to the + * main thread and that's something which our IPDL doesn't support yet. * * Exposing local storage * ~~~~~~~~~~~~~~~~~~~~~~ diff --git a/dom/localstorage/LocalStorageManager2.cpp b/dom/localstorage/LocalStorageManager2.cpp index 017250ae86bf..5f51e1af9169 100644 --- a/dom/localstorage/LocalStorageManager2.cpp +++ b/dom/localstorage/LocalStorageManager2.cpp @@ -19,12 +19,12 @@ class AsyncRequestHelper final : public Runnable, public LSRequestChildCallback { enum class State { /** - * The AsyncRequestHelper has been created and dispatched to the - * RemoteLazyInputStream Thread. + * The AsyncRequestHelper has been created and dispatched to the DOM File + * Thread. */ Initial, /** - * Start() has been invoked on the RemoteLazyInputStream Thread and + * Start() has been invoked on the DOM File Thread and * LocalStorageManager2::StartRequest has been invoked from there, sending * an IPC message to PBackground to service the request. We stay in this * state until a response is received. @@ -300,10 +300,9 @@ LocalStorageManager2::Preload(nsIPrincipal* aPrincipal, JSContext* aContext, RefPtr helper = new AsyncRequestHelper(this, promise, params); - // This will start and finish the async request on the RemoteLazyInputStream - // thread. - // This must be done on RemoteLazyInputStream Thread because it's very likely - // that a content process will issue a prepare datastore request for the same + // This will start and finish the async request on the DOM File thread. + // This must be done on DOM File Thread because it's very likely that a + // content process will issue a prepare datastore request for the same // principal while blocking the content process on the main thread. // There would be a potential for deadlock if the preloading was initialized // from the main thread of the parent process and a11y issued a synchronous @@ -407,7 +406,7 @@ nsresult AsyncRequestHelper::Dispatch() { AssertIsOnOwningThread(); nsCOMPtr domFileThread = - RemoteLazyInputStreamThread::GetOrCreate(); + IPCBlobInputStreamThread::GetOrCreate(); if (NS_WARN_IF(!domFileThread)) { return NS_ERROR_FAILURE; } diff --git a/dom/localstorage/PBackgroundLSRequest.ipdl b/dom/localstorage/PBackgroundLSRequest.ipdl index b76574544be5..ca92d32dc52f 100644 --- a/dom/localstorage/PBackgroundLSRequest.ipdl +++ b/dom/localstorage/PBackgroundLSRequest.ipdl @@ -93,8 +93,7 @@ child: * Cancel() would be received by the parent after it had already sent * __delete__. (Which may no longer be fatal thanks to improvements to the * IPC layer, but it would still lead to warnings, etc. And we don't - * expect PBackground to be highly contended nor the RemoteLazyInputStream - * thread.) + * expect PBackground to be highly contended nor the DOM File thread.) */ async Ready(); }; diff --git a/dom/messagechannel/PMessagePort.ipdl b/dom/messagechannel/PMessagePort.ipdl index 1650b383e301..31be5e7622d1 100644 --- a/dom/messagechannel/PMessagePort.ipdl +++ b/dom/messagechannel/PMessagePort.ipdl @@ -5,8 +5,8 @@ include protocol PBackground; include protocol PChildToParentStream; // FIXME: bug 792908 include protocol PFileDescriptorSet; // FIXME: bug 792908 +include protocol PIPCBlobInputStream; // FIXME: bug 792908 include protocol PParentToChildStream; // FIXME: bug 792908 -include protocol PRemoteLazyInputStream; // FIXME: bug 792908 include DOMTypes; include ProtocolTypes; diff --git a/dom/serviceworkers/FetchEventOpProxyParent.cpp b/dom/serviceworkers/FetchEventOpProxyParent.cpp index 988dcb2ace2d..257891307e90 100644 --- a/dom/serviceworkers/FetchEventOpProxyParent.cpp +++ b/dom/serviceworkers/FetchEventOpProxyParent.cpp @@ -19,10 +19,10 @@ #include "mozilla/UniquePtr.h" #include "mozilla/Unused.h" #include "mozilla/dom/FetchEventOpParent.h" +#include "mozilla/dom/IPCBlobInputStreamStorage.h" +#include "mozilla/dom/IPCBlobUtils.h" #include "mozilla/ipc/BackgroundParent.h" #include "mozilla/ipc/IPCStreamUtils.h" -#include "mozilla/RemoteLazyInputStreamUtils.h" -#include "mozilla/RemoteLazyInputStreamStorage.h" namespace mozilla { @@ -47,8 +47,8 @@ nsresult MaybeDeserializeAndWrapForMainThread( MOZ_TRY(nsContentUtils::GenerateUUIDInPlace(uuid)); - RemoteLazyInputStreamStorage::Get()->AddStream(deserialized, uuid, - aBodyStreamSize, 0); + IPCBlobInputStreamStorage::Get()->AddStream(deserialized, uuid, + aBodyStreamSize, 0); return NS_OK; } @@ -80,7 +80,7 @@ nsresult MaybeDeserializeAndWrapForMainThread( auto streamLength = copyRequest.bodySize(); const auto& uuid = copyRequest.body().ref().get_ParentToParentStream().uuid(); - RemoteLazyInputStreamStorage* storage = RemoteLazyInputStreamStorage::Get(); + IPCBlobInputStreamStorage* storage = IPCBlobInputStreamStorage::Get(); storage->GetStream(uuid, 0, streamLength, getter_AddRefs(stream)); storage->ForgetStream(uuid); @@ -91,13 +91,10 @@ nsresult MaybeDeserializeAndWrapForMainThread( MOZ_ASSERT(bgParent); copyRequest.body() = Some(ParentToChildStream()); - - RemoteLazyStream ipdlStream; - MOZ_ALWAYS_SUCCEEDS(RemoteLazyInputStreamUtils::SerializeInputStream( - stream, streamLength, ipdlStream, bgParent)); - - copyRequest.body().ref().get_ParentToChildStream().actorParent() = - ipdlStream; + MOZ_ALWAYS_SUCCEEDS(IPCBlobUtils::SerializeInputStream( + stream, streamLength, + copyRequest.body().ref().get_ParentToChildStream().actorParent(), + bgParent)); } Unused << aManager->SendPFetchEventOpProxyConstructor(actor, copyArgs); diff --git a/dom/serviceworkers/ServiceWorkerPrivateImpl.cpp b/dom/serviceworkers/ServiceWorkerPrivateImpl.cpp index 56d342134ad1..d6dcfd73238a 100644 --- a/dom/serviceworkers/ServiceWorkerPrivateImpl.cpp +++ b/dom/serviceworkers/ServiceWorkerPrivateImpl.cpp @@ -38,6 +38,7 @@ #include "mozilla/dom/ClientIPCTypes.h" #include "mozilla/dom/DOMTypes.h" #include "mozilla/dom/FetchEventOpChild.h" +#include "mozilla/dom/IPCBlobInputStreamStorage.h" #include "mozilla/dom/InternalHeaders.h" #include "mozilla/dom/InternalRequest.h" #include "mozilla/dom/ReferrerInfo.h" @@ -46,7 +47,6 @@ #include "mozilla/ipc/BackgroundChild.h" #include "mozilla/ipc/IPCStreamUtils.h" #include "mozilla/net/CookieJarSettings.h" -#include "mozilla/RemoteLazyInputStreamStorage.h" namespace mozilla { @@ -71,7 +71,7 @@ ServiceWorkerPrivateImpl::RAIIActorPtrHolder::~RAIIActorPtrHolder() { } RemoteWorkerControllerChild* -ServiceWorkerPrivateImpl::RAIIActorPtrHolder::operator->() const { + ServiceWorkerPrivateImpl::RAIIActorPtrHolder::operator->() const { AssertIsOnMainThread(); return get(); @@ -774,7 +774,7 @@ nsresult MaybeStoreStreamForBackgroundThread(nsIInterceptedChannel* aChannel, MOZ_TRY(nsContentUtils::GenerateUUIDInPlace( body->get_ParentToParentStream().uuid())); - RemoteLazyInputStreamStorage::Get()->AddStream( + IPCBlobInputStreamStorage::Get()->AddStream( uploadStream, body->get_ParentToParentStream().uuid(), bodySize, 0); } } diff --git a/dom/workers/test/test_fileReaderSync_when_closing.html b/dom/workers/test/test_fileReaderSync_when_closing.html index d5fadbaa656c..5f3d704b4f5a 100644 --- a/dom/workers/test/test_fileReaderSync_when_closing.html +++ b/dom/workers/test/test_fileReaderSync_when_closing.html @@ -14,8 +14,8 @@ // immediately available (eliminating memory-backed Blobs) and 2) return // NS_BASE_STREAM_WOULD_BLOCK. Under e10s, any Blob/File sourced from the // parent process (as loadChromeScript performs) will be backed by an -// RemoteLazyInputStream and will behave this way on first use (when it is in -// the eInit state). For ease of testing, we reuse script_createFile.js which +// IPCBlobInputStream and will behave this way on first use (when it is in the +// eInit state). For ease of testing, we reuse script_createFile.js which // involves a file on disk, but a memory-backed Blob from the parent process // would be equally fine. Under non-e10s, this File will not do the right // thing because a synchronous nsFileInputStream will be made directly diff --git a/gfx/thebes/gfxPlatformFontList.cpp b/gfx/thebes/gfxPlatformFontList.cpp index c8489f80e5b2..b1a555ca6a5c 100644 --- a/gfx/thebes/gfxPlatformFontList.cpp +++ b/gfx/thebes/gfxPlatformFontList.cpp @@ -33,6 +33,7 @@ #include "mozilla/dom/ContentChild.h" #include "mozilla/dom/ContentParent.h" #include "mozilla/dom/ContentProcessMessageManager.h" +#include "mozilla/dom/IPCBlobUtils.h" #include "mozilla/gfx/2D.h" #include "mozilla/ipc/FileDescriptorUtils.h" #include "mozilla/ResultExtensions.h" @@ -1294,8 +1295,9 @@ gfxFontEntry* gfxPlatformFontList::FindFontForFamily( gfxFontEntry* gfxPlatformFontList::GetOrCreateFontEntry( fontlist::Face* aFace, const fontlist::Family* aFamily) { - return mFontEntries.LookupForAdd(aFace).OrInsert( - [=]() { return CreateFontEntry(aFace, aFamily); }); + return mFontEntries.LookupForAdd(aFace).OrInsert([=]() { + return CreateFontEntry(aFace, aFamily); + }); } void gfxPlatformFontList::AddOtherFamilyName( diff --git a/ipc/glue/BackgroundChildImpl.cpp b/ipc/glue/BackgroundChildImpl.cpp index 3b014cc89032..3b530b01220d 100644 --- a/ipc/glue/BackgroundChildImpl.cpp +++ b/ipc/glue/BackgroundChildImpl.cpp @@ -25,11 +25,13 @@ #include "mozilla/dom/PFileSystemRequestChild.h" #include "mozilla/dom/EndpointForReportChild.h" #include "mozilla/dom/FileSystemTaskBase.h" +#include "mozilla/dom/IPCBlobInputStreamChild.h" #include "mozilla/dom/PMediaTransportChild.h" #include "mozilla/dom/TemporaryIPCBlobChild.h" #include "mozilla/dom/cache/ActorUtils.h" #include "mozilla/dom/indexedDB/PBackgroundIDBFactoryChild.h" #include "mozilla/dom/indexedDB/PBackgroundIndexedDBUtilsChild.h" +#include "mozilla/dom/IPCBlobUtils.h" #include "mozilla/dom/quota/PQuotaChild.h" #include "mozilla/dom/RemoteWorkerChild.h" #include "mozilla/dom/RemoteWorkerControllerChild.h" @@ -54,7 +56,6 @@ #include "mozilla/dom/WebAuthnTransactionChild.h" #include "mozilla/dom/MIDIPortChild.h" #include "mozilla/dom/MIDIManagerChild.h" -#include "mozilla/RemoteLazyInputStreamChild.h" #include "nsID.h" #include "nsTraceRefcnt.h" @@ -382,11 +383,11 @@ bool BackgroundChildImpl::DeallocPFileCreatorChild(PFileCreatorChild* aActor) { return true; } -already_AddRefed -BackgroundChildImpl::AllocPRemoteLazyInputStreamChild(const nsID& aID, - const uint64_t& aSize) { - RefPtr actor = - new RemoteLazyInputStreamChild(aID, aSize); +already_AddRefed +BackgroundChildImpl::AllocPIPCBlobInputStreamChild(const nsID& aID, + const uint64_t& aSize) { + RefPtr actor = + new dom::IPCBlobInputStreamChild(aID, aSize); return actor.forget(); } diff --git a/ipc/glue/BackgroundChildImpl.h b/ipc/glue/BackgroundChildImpl.h index d7234cd6d7f5..d484172f0478 100644 --- a/ipc/glue/BackgroundChildImpl.h +++ b/ipc/glue/BackgroundChildImpl.h @@ -112,9 +112,9 @@ class BackgroundChildImpl : public PBackgroundChild, virtual bool DeallocPBackgroundStorageChild( PBackgroundStorageChild* aActor) override; - virtual already_AddRefed - AllocPRemoteLazyInputStreamChild(const nsID& aID, - const uint64_t& aSize) override; + virtual already_AddRefed + AllocPIPCBlobInputStreamChild(const nsID& aID, + const uint64_t& aSize) override; virtual PTemporaryIPCBlobChild* AllocPTemporaryIPCBlobChild() override; diff --git a/ipc/glue/BackgroundParentImpl.cpp b/ipc/glue/BackgroundParentImpl.cpp index 6412a4db7937..826d19da41f2 100644 --- a/ipc/glue/BackgroundParentImpl.cpp +++ b/ipc/glue/BackgroundParentImpl.cpp @@ -33,6 +33,8 @@ #include "mozilla/dom/TemporaryIPCBlobParent.h" #include "mozilla/dom/cache/ActorUtils.h" #include "mozilla/dom/indexedDB/ActorsParent.h" +#include "mozilla/dom/IPCBlobInputStreamParent.h" +#include "mozilla/dom/IPCBlobUtils.h" #include "mozilla/dom/localstorage/ActorsParent.h" #include "mozilla/dom/quota/ActorsParent.h" #include "mozilla/dom/simpledb/ActorsParent.h" @@ -60,7 +62,6 @@ #include "mozilla/dom/WebAuthnTransactionParent.h" #include "mozilla/Preferences.h" #include "mozilla/psm/VerifySSLServerCertParent.h" -#include "mozilla/RemoteLazyInputStreamParent.h" #include "mozilla/StaticPrefs_dom.h" #include "nsNetUtil.h" #include "nsProxyRelease.h" @@ -622,22 +623,22 @@ bool BackgroundParentImpl::DeallocPTemporaryIPCBlobParent( return true; } -already_AddRefed -BackgroundParentImpl::AllocPRemoteLazyInputStreamParent(const nsID& aID, - const uint64_t& aSize) { +already_AddRefed +BackgroundParentImpl::AllocPIPCBlobInputStreamParent(const nsID& aID, + const uint64_t& aSize) { AssertIsInMainOrSocketProcess(); AssertIsOnBackgroundThread(); - RefPtr actor = - RemoteLazyInputStreamParent::Create(aID, aSize, this); + RefPtr actor = + dom::IPCBlobInputStreamParent::Create(aID, aSize, this); return actor.forget(); } mozilla::ipc::IPCResult -BackgroundParentImpl::RecvPRemoteLazyInputStreamConstructor( - PRemoteLazyInputStreamParent* aActor, const nsID& aID, +BackgroundParentImpl::RecvPIPCBlobInputStreamConstructor( + dom::PIPCBlobInputStreamParent* aActor, const nsID& aID, const uint64_t& aSize) { - if (!static_cast(aActor)->HasValidStream()) { + if (!static_cast(aActor)->HasValidStream()) { return IPC_FAIL_NO_REASON(this); } diff --git a/ipc/glue/BackgroundParentImpl.h b/ipc/glue/BackgroundParentImpl.h index 203321deabb0..517eda4356cc 100644 --- a/ipc/glue/BackgroundParentImpl.h +++ b/ipc/glue/BackgroundParentImpl.h @@ -144,12 +144,12 @@ class BackgroundParentImpl : public PBackgroundParent, virtual already_AddRefed AllocPIdleSchedulerParent() override; - virtual already_AddRefed - AllocPRemoteLazyInputStreamParent(const nsID& aID, - const uint64_t& aSize) override; + virtual already_AddRefed + AllocPIPCBlobInputStreamParent(const nsID& aID, + const uint64_t& aSize) override; - virtual mozilla::ipc::IPCResult RecvPRemoteLazyInputStreamConstructor( - PRemoteLazyInputStreamParent* aActor, const nsID& aID, + virtual mozilla::ipc::IPCResult RecvPIPCBlobInputStreamConstructor( + PIPCBlobInputStreamParent* aActor, const nsID& aID, const uint64_t& aSize) override; virtual PTemporaryIPCBlobParent* AllocPTemporaryIPCBlobParent() override; diff --git a/ipc/glue/InputStreamParams.ipdlh b/ipc/glue/InputStreamParams.ipdlh index 9789b58f5644..d38b600c8c8e 100644 --- a/ipc/glue/InputStreamParams.ipdlh +++ b/ipc/glue/InputStreamParams.ipdlh @@ -6,7 +6,7 @@ include ProtocolTypes; include protocol PChildToParentStream; include protocol PParentToChildStream; -include protocol PRemoteLazyInputStream; +include protocol PIPCBlobInputStream; using struct mozilla::void_t from "ipc/IPCMessageUtils.h"; @@ -49,17 +49,17 @@ struct SlicedInputStreamParams bool closed; }; -struct RemoteLazyInputStreamRef +struct IPCBlobInputStreamRef { nsID id; uint64_t start; uint64_t length; }; -union RemoteLazyInputStreamParams +union IPCBlobInputStreamParams { - RemoteLazyInputStreamRef; - PRemoteLazyInputStream; + IPCBlobInputStreamRef; + PIPCBlobInputStream; }; union IPCRemoteStreamType @@ -89,7 +89,7 @@ union InputStreamParams MIMEInputStreamParams; MultiplexInputStreamParams; SlicedInputStreamParams; - RemoteLazyInputStreamParams; + IPCBlobInputStreamParams; InputStreamLengthWrapperParams; IPCRemoteStreamParams; EncryptedFileInputStreamParams; diff --git a/ipc/glue/InputStreamUtils.cpp b/ipc/glue/InputStreamUtils.cpp index 01614252a59f..a83b1b8ce6fa 100644 --- a/ipc/glue/InputStreamUtils.cpp +++ b/ipc/glue/InputStreamUtils.cpp @@ -10,14 +10,14 @@ #include "mozilla/Assertions.h" #include "mozilla/dom/File.h" +#include "mozilla/dom/IPCBlobInputStream.h" +#include "mozilla/dom/IPCBlobInputStreamChild.h" +#include "mozilla/dom/IPCBlobInputStreamStorage.h" #include "mozilla/dom/quota/DecryptingInputStream_impl.h" #include "mozilla/dom/quota/IPCStreamCipherStrategy.h" #include "mozilla/ipc/IPCStreamDestination.h" #include "mozilla/ipc/IPCStreamSource.h" #include "mozilla/InputStreamLengthHelper.h" -#include "mozilla/RemoteLazyInputStream.h" -#include "mozilla/RemoteLazyInputStreamChild.h" -#include "mozilla/RemoteLazyInputStreamStorage.h" #include "mozilla/SlicedInputStream.h" #include "mozilla/InputStreamLengthWrapper.h" #include "nsBufferedStreams.h" @@ -248,7 +248,7 @@ void InputStreamHelper::PostSerializationActivation(InputStreamParams& aParams, case InputStreamParams::TFileInputStreamParams: break; - case InputStreamParams::TRemoteLazyInputStreamParams: + case InputStreamParams::TIPCBlobInputStreamParams: break; case InputStreamParams::TEncryptedFileInputStreamParams: @@ -273,31 +273,28 @@ void InputStreamHelper::PostSerializationActivation( already_AddRefed InputStreamHelper::DeserializeInputStream( const InputStreamParams& aParams, const nsTArray& aFileDescriptors) { - if (aParams.type() == InputStreamParams::TRemoteLazyInputStreamParams) { - const RemoteLazyInputStreamParams& params = - aParams.get_RemoteLazyInputStreamParams(); + if (aParams.type() == InputStreamParams::TIPCBlobInputStreamParams) { + const IPCBlobInputStreamParams& params = + aParams.get_IPCBlobInputStreamParams(); - // RemoteLazyInputStreamRefs are not deserializable on the parent side, - // because the parent is the only one that has a copy of the original stream - // in the RemoteLazyInputStreamStorage. - if (params.type() == - RemoteLazyInputStreamParams::TRemoteLazyInputStreamRef) { + // IPCBlobInputStreamRefs are not deserializable on the parent side, because + // the parent is the only one that has a copy of the original stream in the + // IPCBlobInputStreamStorage. + if (params.type() == IPCBlobInputStreamParams::TIPCBlobInputStreamRef) { MOZ_ASSERT(XRE_IsParentProcess()); - const RemoteLazyInputStreamRef& ref = - params.get_RemoteLazyInputStreamRef(); + const IPCBlobInputStreamRef& ref = params.get_IPCBlobInputStreamRef(); nsCOMPtr stream; - RemoteLazyInputStreamStorage::Get()->GetStream( + IPCBlobInputStreamStorage::Get()->GetStream( ref.id(), ref.start(), ref.length(), getter_AddRefs(stream)); return stream.forget(); } - // parent -> child serializations receive an RemoteLazyInputStream actor. + // parent -> child serializations receive an IPCBlobInputStream actor. MOZ_ASSERT(params.type() == - RemoteLazyInputStreamParams::TPRemoteLazyInputStreamChild); - RemoteLazyInputStreamChild* actor = - static_cast( - params.get_PRemoteLazyInputStreamChild()); + IPCBlobInputStreamParams::TPIPCBlobInputStreamChild); + IPCBlobInputStreamChild* actor = static_cast( + params.get_PIPCBlobInputStreamChild()); nsCOMPtr stream = actor->CreateStream(); return stream.forget(); } diff --git a/ipc/glue/PBackground.ipdl b/ipc/glue/PBackground.ipdl index 7c5f9daca2e1..599954078b13 100644 --- a/ipc/glue/PBackground.ipdl +++ b/ipc/glue/PBackground.ipdl @@ -25,7 +25,7 @@ include protocol PGamepadEventChannel; include protocol PGamepadTestChannel; include protocol PHttpBackgroundChannel; include protocol PIdleScheduler; -include protocol PRemoteLazyInputStream; +include protocol PIPCBlobInputStream; include protocol PMediaTransport; include protocol PRemoteWorker; include protocol PRemoteWorkerController; @@ -96,7 +96,7 @@ sync protocol PBackground manages PGamepadTestChannel; manages PHttpBackgroundChannel; manages PIdleScheduler; - manages PRemoteLazyInputStream; + manages PIPCBlobInputStream; manages PMediaTransport; manages PRemoteWorker; manages PRemoteWorkerController; @@ -263,9 +263,9 @@ child: async PRemoteWorker(RemoteWorkerData data); both: - // PRemoteLazyInputStream is created on the parent side only if the child - // starts a migration. - async PRemoteLazyInputStream(nsID aID, uint64_t aSize); + // PIPCBlobInputStream is created on the parent side only if the child starts + // a migration. + async PIPCBlobInputStream(nsID aID, uint64_t aSize); async PFileDescriptorSet(FileDescriptor fd); }; diff --git a/layout/build/nsLayoutStatics.cpp b/layout/build/nsLayoutStatics.cpp index a15333f58498..16a48222a156 100644 --- a/layout/build/nsLayoutStatics.cpp +++ b/layout/build/nsLayoutStatics.cpp @@ -109,6 +109,7 @@ #include "mozilla/StaticPresData.h" #include "mozilla/dom/AbstractRange.h" #include "mozilla/dom/Document.h" +#include "mozilla/dom/IPCBlobInputStreamStorage.h" #include "mozilla/dom/WebIDLGlobalNameHash.h" #include "mozilla/dom/U2FTokenManager.h" #ifdef OS_WIN @@ -122,7 +123,6 @@ #include "mozilla/dom/quota/ActorsParent.h" #include "mozilla/dom/localstorage/ActorsParent.h" #include "mozilla/net/UrlClassifierFeatureFactory.h" -#include "mozilla/RemoteLazyInputStreamStorage.h" #include "nsThreadManager.h" #include "mozilla/css/ImageLoader.h" #include "gfxUserFontSet.h" @@ -262,7 +262,7 @@ nsresult nsLayoutStatics::Initialize() { } // This must be initialized on the main-thread. - mozilla::RemoteLazyInputStreamStorage::Initialize(); + mozilla::dom::IPCBlobInputStreamStorage::Initialize(); mozilla::dom::U2FTokenManager::Initialize(); diff --git a/netwerk/base/nsIFileStreams.idl b/netwerk/base/nsIFileStreams.idl index 4b704493ea92..4339e95b0123 100644 --- a/netwerk/base/nsIFileStreams.idl +++ b/netwerk/base/nsIFileStreams.idl @@ -182,7 +182,7 @@ interface nsIFileStream : nsISupports * interface before taking any action that might consume the underlying stream. * For example, once Available(), Read(), or nsIAsyncInputStream::AsyncWait() * are invoked, these methods may return NS_BASE_STREAM_CLOSED. This will - * happen when using RemoteLazyInputStream with an underlying file stream, for + * happen when using IPCBlobInputStream with an underlying file stream, for * example. */ [scriptable, uuid(07f679e4-9601-4bd1-b510-cd3852edb881)] diff --git a/netwerk/ipc/PSocketProcess.ipdl b/netwerk/ipc/PSocketProcess.ipdl index 1f5e58dd5abb..dfbcb5b5b35e 100644 --- a/netwerk/ipc/PSocketProcess.ipdl +++ b/netwerk/ipc/PSocketProcess.ipdl @@ -19,7 +19,7 @@ include protocol PAltSvcTransaction; include protocol PTRRService; include protocol PProxyConfigLookup; include protocol PNativeDNSResolverOverride; -include protocol PRemoteLazyInputStream; +include protocol PIPCBlobInputStream; include MemoryReportTypes; include NeckoChannelParams; @@ -74,7 +74,7 @@ sync protocol PSocketProcess manages PTRRService; manages PProxyConfigLookup; manages PNativeDNSResolverOverride; - manages PRemoteLazyInputStream; + manages PIPCBlobInputStream; parent: async InitCrashReporter(NativeThreadId threadId); @@ -144,7 +144,7 @@ child: async PNativeDNSResolverOverride(); async NotifyObserver(nsCString aTopic, nsString aData); - async PRemoteLazyInputStream(nsID aID, uint64_t aSize); + async PIPCBlobInputStream(nsID aID, uint64_t aSize); both: async PFileDescriptorSet(FileDescriptor fd); diff --git a/netwerk/ipc/SocketProcessChild.cpp b/netwerk/ipc/SocketProcessChild.cpp index e97b45d35f52..a0953c0b6f10 100644 --- a/netwerk/ipc/SocketProcessChild.cpp +++ b/netwerk/ipc/SocketProcessChild.cpp @@ -11,6 +11,7 @@ #include "HttpTransactionChild.h" #include "HttpConnectionMgrChild.h" #include "mozilla/Assertions.h" +#include "mozilla/dom/IPCBlobInputStreamChild.h" #include "mozilla/dom/MemoryReportRequest.h" #include "mozilla/ipc/CrashReporterClient.h" #include "mozilla/ipc/BackgroundChild.h" @@ -27,7 +28,6 @@ #include "mozilla/ipc/PChildToParentStreamChild.h" #include "mozilla/ipc/PParentToChildStreamChild.h" #include "mozilla/Preferences.h" -#include "mozilla/RemoteLazyInputStreamChild.h" #include "mozilla/Telemetry.h" #include "nsDebugImpl.h" #include "nsHttpConnectionInfo.h" @@ -464,11 +464,11 @@ mozilla::ipc::IPCResult SocketProcessChild::RecvNotifyObserver( return IPC_OK(); } -already_AddRefed -SocketProcessChild::AllocPRemoteLazyInputStreamChild(const nsID& aID, - const uint64_t& aSize) { - RefPtr actor = - new RemoteLazyInputStreamChild(aID, aSize); +already_AddRefed +SocketProcessChild::AllocPIPCBlobInputStreamChild(const nsID& aID, + const uint64_t& aSize) { + RefPtr actor = + new dom::IPCBlobInputStreamChild(aID, aSize); return actor.forget(); } diff --git a/netwerk/ipc/SocketProcessChild.h b/netwerk/ipc/SocketProcessChild.h index aa682515862b..9822eb92bbde 100644 --- a/netwerk/ipc/SocketProcessChild.h +++ b/netwerk/ipc/SocketProcessChild.h @@ -123,8 +123,8 @@ class SocketProcessChild final mozilla::ipc::IPCResult RecvNotifyObserver(const nsCString& aTopic, const nsString& aData); - virtual already_AddRefed - AllocPRemoteLazyInputStreamChild(const nsID& aID, const uint64_t& aSize); + virtual already_AddRefed + AllocPIPCBlobInputStreamChild(const nsID& aID, const uint64_t& aSize); protected: friend class SocketProcessImpl; diff --git a/netwerk/ipc/SocketProcessParent.cpp b/netwerk/ipc/SocketProcessParent.cpp index f135a00e662b..99f7a8158b39 100644 --- a/netwerk/ipc/SocketProcessParent.cpp +++ b/netwerk/ipc/SocketProcessParent.cpp @@ -10,6 +10,7 @@ #include "CachePushChecker.h" #include "HttpTransactionParent.h" #include "SocketProcessHost.h" +#include "mozilla/dom/IPCBlobInputStreamParent.h" #include "mozilla/dom/MemoryReportRequest.h" #include "mozilla/ipc/FileDescriptorSetParent.h" #include "mozilla/ipc/IPCStreamAlloc.h" @@ -17,7 +18,6 @@ #include "mozilla/ipc/PParentToChildStreamParent.h" #include "mozilla/net/DNSRequestParent.h" #include "mozilla/net/ProxyConfigLookupParent.h" -#include "mozilla/RemoteLazyInputStreamParent.h" #include "mozilla/Telemetry.h" #include "mozilla/TelemetryIPC.h" #include "nsIAppStartup.h" @@ -388,19 +388,18 @@ void SocketProcessParent::Destroy(UniquePtr&& aParent) { new DeferredDeleteSocketProcessParent(std::move(aParent))); } -already_AddRefed -SocketProcessParent::AllocPRemoteLazyInputStreamParent(const nsID& aID, - const uint64_t& aSize) { - RefPtr actor = - RemoteLazyInputStreamParent::Create(aID, aSize, this); +already_AddRefed +SocketProcessParent::AllocPIPCBlobInputStreamParent(const nsID& aID, + const uint64_t& aSize) { + RefPtr actor = + dom::IPCBlobInputStreamParent::Create(aID, aSize, this); return actor.forget(); } -mozilla::ipc::IPCResult -SocketProcessParent::RecvPRemoteLazyInputStreamConstructor( - PRemoteLazyInputStreamParent* aActor, const nsID& aID, +mozilla::ipc::IPCResult SocketProcessParent::RecvPIPCBlobInputStreamConstructor( + dom::PIPCBlobInputStreamParent* aActor, const nsID& aID, const uint64_t& aSize) { - if (!static_cast(aActor)->HasValidStream()) { + if (!static_cast(aActor)->HasValidStream()) { return IPC_FAIL_NO_REASON(this); } diff --git a/netwerk/ipc/SocketProcessParent.h b/netwerk/ipc/SocketProcessParent.h index 1b892a3f6ac6..a3ec66d0c272 100644 --- a/netwerk/ipc/SocketProcessParent.h +++ b/netwerk/ipc/SocketProcessParent.h @@ -113,11 +113,11 @@ class SocketProcessParent final nsIURI* aPushedURL, OriginAttributes&& aOriginAttributes, nsCString&& aRequestString, CachePushCheckResolver&& aResolver); - already_AddRefed - AllocPRemoteLazyInputStreamParent(const nsID& aID, const uint64_t& aSize); + already_AddRefed AllocPIPCBlobInputStreamParent( + const nsID& aID, const uint64_t& aSize); - mozilla::ipc::IPCResult RecvPRemoteLazyInputStreamConstructor( - PRemoteLazyInputStreamParent* aActor, const nsID& aID, + mozilla::ipc::IPCResult RecvPIPCBlobInputStreamConstructor( + PIPCBlobInputStreamParent* aActor, const nsID& aID, const uint64_t& aSize); private: diff --git a/netwerk/protocol/http/HttpBaseChannel.cpp b/netwerk/protocol/http/HttpBaseChannel.cpp index f276046cdf46..86871e137149 100644 --- a/netwerk/protocol/http/HttpBaseChannel.cpp +++ b/netwerk/protocol/http/HttpBaseChannel.cpp @@ -81,8 +81,8 @@ #include "nsStreamUtils.h" #include "nsThreadUtils.h" #include "nsURLHelper.h" -#include "mozilla/RemoteLazyInputStreamChild.h" -#include "mozilla/RemoteLazyInputStreamUtils.h" +#include "mozilla/dom/IPCBlobUtils.h" +#include "mozilla/dom/IPCBlobInputStreamChild.h" namespace mozilla { namespace net { @@ -3680,8 +3680,9 @@ HttpBaseChannel::ReplacementChannelConfig::ReplacementChannelConfig( method = aInit.method(); referrerInfo = aInit.referrerInfo(); timedChannel = aInit.timedChannel(); - if (RemoteLazyInputStreamChild* actor = - static_cast(aInit.uploadStreamChild())) { + if (dom::IPCBlobInputStreamChild* actor = + static_cast( + aInit.uploadStreamChild())) { uploadStreamLength = actor->Size(); uploadStream = actor->CreateStream(); // actor can be deleted by CreateStream, so don't touch it @@ -3705,10 +3706,8 @@ HttpBaseChannel::ReplacementChannelConfig::Serialize( config.referrerInfo() = referrerInfo; config.timedChannel() = timedChannel; if (uploadStream) { - RemoteLazyStream ipdlStream; - RemoteLazyInputStreamUtils::SerializeInputStream( - uploadStream, uploadStreamLength, ipdlStream, aParent); - config.uploadStreamParent() = ipdlStream; + dom::IPCBlobUtils::SerializeInputStream( + uploadStream, uploadStreamLength, config.uploadStreamParent(), aParent); } config.uploadStreamHasHeaders() = uploadStreamHasHeaders; config.contentType() = contentType; diff --git a/toolkit/components/extensions/webrequest/WebRequestUpload.jsm b/toolkit/components/extensions/webrequest/WebRequestUpload.jsm index eb8a2bc6b538..cc1ddeb06cec 100644 --- a/toolkit/components/extensions/webrequest/WebRequestUpload.jsm +++ b/toolkit/components/extensions/webrequest/WebRequestUpload.jsm @@ -475,7 +475,7 @@ function* getRawDataChunked( // the file, rather than its data. if ( unbuffered instanceof Ci.nsIFileInputStream || - unbuffered instanceof Ci.mozIRemoteLazyInputStream + unbuffered instanceof Ci.mozIIPCBlobInputStream ) { // But this is not actually supported yet. yield { file: "" }; diff --git a/xpcom/io/nsICloneableInputStream.idl b/xpcom/io/nsICloneableInputStream.idl index adefd0f4285b..1dbbed34622a 100644 --- a/xpcom/io/nsICloneableInputStream.idl +++ b/xpcom/io/nsICloneableInputStream.idl @@ -22,7 +22,7 @@ interface nsICloneableInputStream : nsISupports }; // This interface implements cloneWithRange() because for some streams -// (RemoteLazyInputStream only, so far) are more efficient to produce a sub +// (IPCBlobInputStream only, so far) are more efficient to produce a sub // stream with range than doing clone + SlicedInputStream(). [scriptable, builtinclass, uuid(ece853c3-aded-4cef-8f51-0d1493d60bd5)] interface nsICloneableInputStreamWithRange : nsICloneableInputStream