diff --git a/dom/fs/parent/FileSystemManagerParent.cpp b/dom/fs/parent/FileSystemManagerParent.cpp index eab29615e3c5..1650a082927b 100644 --- a/dom/fs/parent/FileSystemManagerParent.cpp +++ b/dom/fs/parent/FileSystemManagerParent.cpp @@ -149,7 +149,7 @@ mozilla::ipc::IPCResult FileSystemManagerParent::RecvGetAccessHandle( RandomAccessStreamParams streamParams = mozilla::ipc::SerializeRandomAccessStream( - WrapMovingNotNullUnchecked(std::move(stream))); + WrapMovingNotNullUnchecked(std::move(stream)), nullptr); auto accessHandleParent = MakeRefPtr(this, aRequest.entryId()); diff --git a/dom/quota/FileStreams.cpp b/dom/quota/FileStreams.cpp index 6b75bf5715b9..dea6eff9f709 100644 --- a/dom/quota/FileStreams.cpp +++ b/dom/quota/FileStreams.cpp @@ -102,7 +102,8 @@ NS_IMETHODIMP FileQuotaStreamWithWrite::Write( return NS_OK; } -mozilla::ipc::RandomAccessStreamParams FileRandomAccessStream::Serialize() { +mozilla::ipc::RandomAccessStreamParams FileRandomAccessStream::Serialize( + nsIInterfaceRequestor* aCallbacks) { MOZ_RELEASE_ASSERT(XRE_IsParentProcess()); MOZ_RELEASE_ASSERT(!mDeserialized); MOZ_ASSERT(mOpenParams.localFile); @@ -114,10 +115,10 @@ mozilla::ipc::RandomAccessStreamParams FileRandomAccessStream::Serialize() { mPersistenceType, mOriginMetadata, mClientType, mOpenParams.localFile); MOZ_ASSERT(quotaObject); - IPCQuotaObject ipcQuotaObject = quotaObject->Serialize(); + IPCQuotaObject ipcQuotaObject = quotaObject->Serialize(aCallbacks); mozilla::ipc::RandomAccessStreamParams randomAccessStreamParams = - nsFileRandomAccessStream::Serialize(); + nsFileRandomAccessStream::Serialize(aCallbacks); MOZ_ASSERT( randomAccessStreamParams.type() == diff --git a/dom/quota/FileStreams.h b/dom/quota/FileStreams.h index 473c3085dfba..9a91b474c53f 100644 --- a/dom/quota/FileStreams.h +++ b/dom/quota/FileStreams.h @@ -141,7 +141,8 @@ class FileRandomAccessStream // Serialize this FileRandomAccessStream. This method works only in the // parent process and only with streams which haven't been previously // deserialized. - mozilla::ipc::RandomAccessStreamParams Serialize() override; + mozilla::ipc::RandomAccessStreamParams Serialize( + nsIInterfaceRequestor* aCallbacks) override; // Deserialize this FileRandomAccessStream. This method works in both the // child and parent. diff --git a/dom/quota/QuotaObject.cpp b/dom/quota/QuotaObject.cpp index 2227c1c99842..df81cacb8393 100644 --- a/dom/quota/QuotaObject.cpp +++ b/dom/quota/QuotaObject.cpp @@ -12,6 +12,7 @@ #include "mozilla/dom/quota/RemoteQuotaObjectChild.h" #include "mozilla/dom/quota/RemoteQuotaObjectParent.h" #include "mozilla/ipc/BackgroundParent.h" +#include "nsIInterfaceRequestor.h" #include "RemoteQuotaObject.h" namespace mozilla::dom::quota { @@ -24,7 +25,7 @@ RemoteQuotaObject* QuotaObject::AsRemoteQuotaObject() { return mIsRemote ? static_cast(this) : nullptr; } -IPCQuotaObject QuotaObject::Serialize() { +IPCQuotaObject QuotaObject::Serialize(nsIInterfaceRequestor* aCallbacks) { MOZ_RELEASE_ASSERT(XRE_IsParentProcess()); MOZ_RELEASE_ASSERT(!NS_IsMainThread()); MOZ_RELEASE_ASSERT(!mozilla::ipc::IsOnBackgroundThread()); @@ -60,25 +61,3 @@ RefPtr QuotaObject::Deserialize(IPCQuotaObject& aQuotaObject) { } } // namespace mozilla::dom::quota - -namespace IPC { - -void ParamTraits::Write( - MessageWriter* aWriter, mozilla::dom::quota::QuotaObject* aParam) { - mozilla::dom::quota::IPCQuotaObject ipcQuotaObject = aParam->Serialize(); - - WriteParam(aWriter, std::move(ipcQuotaObject)); -} - -bool ParamTraits::Read( - MessageReader* aReader, RefPtr* aResult) { - mozilla::dom::quota::IPCQuotaObject ipcQuotaObject; - if (!ReadParam(aReader, &ipcQuotaObject)) { - return false; - } - - *aResult = mozilla::dom::quota::QuotaObject::Deserialize(ipcQuotaObject); - return true; -} - -} // namespace IPC diff --git a/dom/quota/QuotaObject.h b/dom/quota/QuotaObject.h index 00a6d9c239d2..96397faf66e3 100644 --- a/dom/quota/QuotaObject.h +++ b/dom/quota/QuotaObject.h @@ -7,9 +7,10 @@ #ifndef DOM_QUOTA_QUOTAOBJECT_H_ #define DOM_QUOTA_QUOTAOBJECT_H_ -#include "chrome/common/ipc_message_utils.h" #include "nsISupportsImpl.h" +class nsIInterfaceRequestor; + namespace mozilla::dom::quota { class CanonicalQuotaObject; @@ -39,7 +40,7 @@ class QuotaObject { // and only with objects which haven't been previously deserialized. // The serial event target where this method is called should be highly // available, as it will be used to process requests from the remote variant. - IPCQuotaObject Serialize(); + IPCQuotaObject Serialize(nsIInterfaceRequestor* aCallbacks); // Deserialize a QuotaObject. This method works in both the child and parent. // The deserialized QuotaObject can only be used on the calling serial event @@ -66,12 +67,4 @@ class QuotaObject { } // namespace mozilla::dom::quota -template <> -struct IPC::ParamTraits { - static void Write(IPC::MessageWriter* aWriter, - mozilla::dom::quota::QuotaObject* aParam); - static bool Read(IPC::MessageReader* aReader, - RefPtr* aResult); -}; - #endif // DOM_QUOTA_QUOTAOBJECT_H_ diff --git a/dom/quota/RemoteQuotaObject.cpp b/dom/quota/RemoteQuotaObject.cpp index 922b3bfb496a..3fa3370fc121 100644 --- a/dom/quota/RemoteQuotaObject.cpp +++ b/dom/quota/RemoteQuotaObject.cpp @@ -41,6 +41,8 @@ void RemoteQuotaObject::Close() { MOZ_ASSERT(!mActor); } +const nsAString& RemoteQuotaObject::Path() const { return EmptyString(); } + bool RemoteQuotaObject::MaybeUpdateSize(int64_t aSize, bool aTruncate) { MOZ_ASSERT(!NS_IsMainThread()); MOZ_ASSERT(!mozilla::ipc::IsOnBackgroundThread()); diff --git a/dom/quota/RemoteQuotaObject.h b/dom/quota/RemoteQuotaObject.h index ec60dc7969d6..48ae0c51f341 100644 --- a/dom/quota/RemoteQuotaObject.h +++ b/dom/quota/RemoteQuotaObject.h @@ -24,7 +24,7 @@ class RemoteQuotaObject final : public QuotaObject { void Close(); - const nsAString& Path() const override { return EmptyString(); } + const nsAString& Path() const override; // This method should never be called on the main thread or the PBackground // thread or a DOM worker thread (It does sync IPC). diff --git a/ipc/glue/RandomAccessStreamUtils.cpp b/ipc/glue/RandomAccessStreamUtils.cpp index f4ac27bae678..d5e66daae625 100644 --- a/ipc/glue/RandomAccessStreamUtils.cpp +++ b/ipc/glue/RandomAccessStreamUtils.cpp @@ -12,15 +12,17 @@ #include "mozilla/dom/quota/FileStreams.h" #include "mozilla/ipc/RandomAccessStreamParams.h" #include "nsFileStreams.h" +#include "nsIInterfaceRequestor.h" #include "nsIRandomAccessStream.h" namespace mozilla::ipc { RandomAccessStreamParams SerializeRandomAccessStream( - MovingNotNull> aStream) { + MovingNotNull> aStream, + nsIInterfaceRequestor* aCallbacks) { NotNull> stream = std::move(aStream); - RandomAccessStreamParams streamParams = stream->Serialize(); + RandomAccessStreamParams streamParams = stream->Serialize(aCallbacks); MOZ_ASSERT(streamParams.type() != RandomAccessStreamParams::T__None); @@ -28,13 +30,14 @@ RandomAccessStreamParams SerializeRandomAccessStream( } Maybe SerializeRandomAccessStream( - nsCOMPtr aStream) { + nsCOMPtr aStream, + nsIInterfaceRequestor* aCallbacks) { if (!aStream) { return Nothing(); } return Some(SerializeRandomAccessStream( - WrapMovingNotNullUnchecked(std::move(aStream)))); + WrapMovingNotNullUnchecked(std::move(aStream)), aCallbacks)); } Result>, bool> diff --git a/ipc/glue/RandomAccessStreamUtils.h b/ipc/glue/RandomAccessStreamUtils.h index 2fb20a8063d3..3ca79537eb44 100644 --- a/ipc/glue/RandomAccessStreamUtils.h +++ b/ipc/glue/RandomAccessStreamUtils.h @@ -10,6 +10,7 @@ template class nsCOMPtr; +class nsIInterfaceRequestor; class nsIRandomAccessStream; namespace mozilla { @@ -29,10 +30,11 @@ class RandomAccessStreamParams; // Serialize an nsIRandomAccessStream to be sent over IPC infallibly. RandomAccessStreamParams SerializeRandomAccessStream( - MovingNotNull> aStream); + MovingNotNull> aStream, + nsIInterfaceRequestor* aCallbacks); Maybe SerializeRandomAccessStream( - nsCOMPtr aStream); + nsCOMPtr aStream, nsIInterfaceRequestor* aCallbacks); // Deserialize an nsIRandomAccessStream received from an actor call. These // methods work in both the child and parent. diff --git a/ipc/gtest/TestRandomAccessStreamUtils.cpp b/ipc/gtest/TestRandomAccessStreamUtils.cpp index 9836cccc16f6..899c528a3097 100644 --- a/ipc/gtest/TestRandomAccessStreamUtils.cpp +++ b/ipc/gtest/TestRandomAccessStreamUtils.cpp @@ -105,7 +105,7 @@ TEST(RandomAccessStreamUtils, NullRandomAccessStream_MaybeSerialize) nsCOMPtr stream; Maybe streamParams = - SerializeRandomAccessStream(stream); + SerializeRandomAccessStream(stream, nullptr); ASSERT_TRUE(streamParams.isNothing()); @@ -139,7 +139,7 @@ TEST(RandomAccessStreamUtils, FileRandomAccessStream_Serialize) ASSERT_EQ(numWritten, dataSize); RandomAccessStreamParams streamParams = SerializeRandomAccessStream( - WrapMovingNotNullUnchecked(std::move(stream))); + WrapMovingNotNullUnchecked(std::move(stream)), nullptr); ASSERT_EQ(streamParams.type(), RandomAccessStreamParams::TFileRandomAccessStreamParams); @@ -187,7 +187,7 @@ TEST(RandomAccessStreamUtils, FileRandomAccessStream_MaybeSerialize) ASSERT_EQ(numWritten, dataSize); Maybe streamParams = - SerializeRandomAccessStream(stream); + SerializeRandomAccessStream(stream, nullptr); ASSERT_TRUE(streamParams); ASSERT_EQ(streamParams->type(), diff --git a/netwerk/base/nsFileStreams.cpp b/netwerk/base/nsFileStreams.cpp index 742f1482ba4b..f574d13f823d 100644 --- a/netwerk/base/nsFileStreams.cpp +++ b/netwerk/base/nsFileStreams.cpp @@ -901,7 +901,8 @@ nsIInputStream* nsFileRandomAccessStream::InputStream() { return this; } nsIOutputStream* nsFileRandomAccessStream::OutputStream() { return this; } -RandomAccessStreamParams nsFileRandomAccessStream::Serialize() { +RandomAccessStreamParams nsFileRandomAccessStream::Serialize( + nsIInterfaceRequestor* aCallbacks) { FileRandomAccessStreamParams params; if (NS_SUCCEEDED(DoPendingOpen())) { diff --git a/xpcom/io/nsIRandomAccessStream.idl b/xpcom/io/nsIRandomAccessStream.idl index e515e091e90f..20421def17e4 100644 --- a/xpcom/io/nsIRandomAccessStream.idl +++ b/xpcom/io/nsIRandomAccessStream.idl @@ -7,6 +7,7 @@ #include "nsISeekableStream.idl" interface nsIInputStream; +interface nsIInterfaceRequestor; interface nsIOutputStream; %{C++ @@ -55,7 +56,7 @@ interface nsIRandomAccessStream : nsISeekableStream */ [notxpcom, nostdcall] nsIOutputStream outputStream(); - [notxpcom, nostdcall] RandomAccessStreamParams serialize(); + [notxpcom, nostdcall] RandomAccessStreamParams serialize(in nsIInterfaceRequestor aCallbacks); [notxpcom, nostdcall] bool deserialize(inout RandomAccessStreamParamsRef params); };