mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1523702 - Max IPC message size for InputStream serialization, r=smaug
The total size of an IPC inputStream message must be less than 1mb. When we compose the message for the multiplex stream, each sub stream collaborates with its own size, deciding if it's better to be a pipe stream (IPCRemoteStream) or a full serialized one. Differential Revision: https://phabricator.services.mozilla.com/D18543 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
ead2cc5bf9
commit
be2551ab2c
@ -52,24 +52,28 @@ class TemporaryFileInputStream final : public nsFileInputStream {
|
||||
|
||||
void Serialize(InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
|
||||
uint32_t aMaxSize, uint32_t* aSizeUsed,
|
||||
nsIContentChild* aManager) override {
|
||||
MOZ_CRASH("This inputStream cannot be serialized.");
|
||||
}
|
||||
|
||||
void Serialize(InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
|
||||
uint32_t aMaxSize, uint32_t* aSizeUsed,
|
||||
PBackgroundChild* aManager) override {
|
||||
MOZ_CRASH("This inputStream cannot be serialized.");
|
||||
}
|
||||
|
||||
void Serialize(InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
|
||||
uint32_t aMaxSize, uint32_t* aSizeUsed,
|
||||
nsIContentParent* aManager) override {
|
||||
MOZ_CRASH("This inputStream cannot be serialized.");
|
||||
}
|
||||
|
||||
void Serialize(InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
|
||||
uint32_t aMaxSize, uint32_t* aSizeUsed,
|
||||
PBackgroundParent* aManager) override {
|
||||
MOZ_CRASH("This inputStream cannot be serialized.");
|
||||
}
|
||||
|
@ -565,29 +565,45 @@ IPCBlobInputStream::OnInputStreamReady(nsIAsyncInputStream* aStream) {
|
||||
|
||||
void IPCBlobInputStream::Serialize(mozilla::ipc::InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart,
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed,
|
||||
nsIContentChild* aManager) {
|
||||
MOZ_ASSERT(aSizeUsed);
|
||||
*aSizeUsed = 0;
|
||||
|
||||
SerializeInternal(aParams);
|
||||
}
|
||||
|
||||
void IPCBlobInputStream::Serialize(mozilla::ipc::InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart,
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed,
|
||||
mozilla::ipc::PBackgroundChild* aManager) {
|
||||
MOZ_ASSERT(aSizeUsed);
|
||||
*aSizeUsed = 0;
|
||||
|
||||
SerializeInternal(aParams);
|
||||
}
|
||||
|
||||
void IPCBlobInputStream::Serialize(mozilla::ipc::InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart,
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed,
|
||||
nsIContentParent* aManager) {
|
||||
MOZ_ASSERT(aSizeUsed);
|
||||
*aSizeUsed = 0;
|
||||
|
||||
SerializeInternal(aParams);
|
||||
}
|
||||
|
||||
void IPCBlobInputStream::Serialize(mozilla::ipc::InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart,
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed,
|
||||
mozilla::ipc::PBackgroundParent* aManager) {
|
||||
MOZ_ASSERT(aSizeUsed);
|
||||
*aSizeUsed = 0;
|
||||
|
||||
SerializeInternal(aParams);
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,8 @@ class StreamWrapper final : public nsIAsyncInputStream,
|
||||
template <typename M>
|
||||
void SerializeInternal(InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart, M* aManager);
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed, M* aManager);
|
||||
|
||||
bool IsOnOwningThread() const {
|
||||
MOZ_ASSERT(mOwningThread);
|
||||
@ -271,37 +272,51 @@ StreamWrapper::IsNonBlocking(bool* _retval) {
|
||||
|
||||
void StreamWrapper::Serialize(InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart, nsIContentChild* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed, nsIContentChild* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
||||
aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
void StreamWrapper::Serialize(InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart, PBackgroundChild* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed, PBackgroundChild* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
||||
aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
void StreamWrapper::Serialize(InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart, nsIContentParent* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed, nsIContentParent* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
||||
aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
void StreamWrapper::Serialize(InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart, PBackgroundParent* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed,
|
||||
PBackgroundParent* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
||||
aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
template <typename M>
|
||||
void StreamWrapper::SerializeInternal(InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart, M* aManager) {
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed, M* aManager) {
|
||||
MOZ_ASSERT(aSizeUsed);
|
||||
*aSizeUsed = 0;
|
||||
|
||||
nsCOMPtr<nsIIPCSerializableInputStream> stream =
|
||||
do_QueryInterface(mInputStream);
|
||||
|
||||
if (stream) {
|
||||
stream->Serialize(aParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
stream->Serialize(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
||||
aSizeUsed, aManager);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,8 +38,14 @@ bool SerializeInputStreamWithFdsChild(nsIIPCSerializableInputStream* aStream,
|
||||
MOZ_RELEASE_ASSERT(aStream);
|
||||
MOZ_ASSERT(aManager);
|
||||
|
||||
const uint64_t kTooLargeStream = 1024 * 1024;
|
||||
|
||||
uint32_t sizeUsed = 0;
|
||||
AutoTArray<FileDescriptor, 4> fds;
|
||||
aStream->Serialize(aValue.stream(), fds, aDelayedStart, aManager);
|
||||
aStream->Serialize(aValue.stream(), fds, aDelayedStart, kTooLargeStream,
|
||||
&sizeUsed, aManager);
|
||||
|
||||
MOZ_ASSERT(sizeUsed <= kTooLargeStream);
|
||||
|
||||
if (aValue.stream().type() == InputStreamParams::T__None) {
|
||||
MOZ_CRASH("Serialize failed!");
|
||||
@ -67,8 +73,14 @@ bool SerializeInputStreamWithFdsParent(nsIIPCSerializableInputStream* aStream,
|
||||
MOZ_RELEASE_ASSERT(aStream);
|
||||
MOZ_ASSERT(aManager);
|
||||
|
||||
const uint64_t kTooLargeStream = 1024 * 1024;
|
||||
|
||||
uint32_t sizeUsed = 0;
|
||||
AutoTArray<FileDescriptor, 4> fds;
|
||||
aStream->Serialize(aValue.stream(), fds, aDelayedStart, aManager);
|
||||
aStream->Serialize(aValue.stream(), fds, aDelayedStart, kTooLargeStream,
|
||||
&sizeUsed, aManager);
|
||||
|
||||
MOZ_ASSERT(sizeUsed <= kTooLargeStream);
|
||||
|
||||
if (aValue.stream().type() == InputStreamParams::T__None) {
|
||||
MOZ_CRASH("Serialize failed!");
|
||||
|
@ -53,7 +53,8 @@ template <typename M>
|
||||
void SerializeInputStreamInternal(nsIInputStream* aInputStream,
|
||||
InputStreamParams& aParams,
|
||||
nsTArray<FileDescriptor>& aFileDescriptors,
|
||||
bool aDelayedStart, M* aManager) {
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed, M* aManager) {
|
||||
MOZ_ASSERT(aInputStream);
|
||||
MOZ_ASSERT(aManager);
|
||||
|
||||
@ -63,7 +64,8 @@ void SerializeInputStreamInternal(nsIInputStream* aInputStream,
|
||||
MOZ_CRASH("Input stream is not serializable!");
|
||||
}
|
||||
|
||||
serializable->Serialize(aParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
serializable->Serialize(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
||||
aSizeUsed, aManager);
|
||||
|
||||
if (aParams.type() == InputStreamParams::T__None) {
|
||||
MOZ_CRASH("Serialize failed!");
|
||||
@ -118,33 +120,33 @@ void SerializeInputStreamAsPipeInternal(nsIInputStream* aInputStream,
|
||||
void InputStreamHelper::SerializeInputStream(
|
||||
nsIInputStream* aInputStream, InputStreamParams& aParams,
|
||||
nsTArray<FileDescriptor>& aFileDescriptors, bool aDelayedStart,
|
||||
nsIContentChild* aManager) {
|
||||
uint32_t aMaxSize, uint32_t* aSizeUsed, nsIContentChild* aManager) {
|
||||
SerializeInputStreamInternal(aInputStream, aParams, aFileDescriptors,
|
||||
aDelayedStart, aManager);
|
||||
aDelayedStart, aMaxSize, aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
void InputStreamHelper::SerializeInputStream(
|
||||
nsIInputStream* aInputStream, InputStreamParams& aParams,
|
||||
nsTArray<FileDescriptor>& aFileDescriptors, bool aDelayedStart,
|
||||
PBackgroundChild* aManager) {
|
||||
uint32_t aMaxSize, uint32_t* aSizeUsed, PBackgroundChild* aManager) {
|
||||
SerializeInputStreamInternal(aInputStream, aParams, aFileDescriptors,
|
||||
aDelayedStart, aManager);
|
||||
aDelayedStart, aMaxSize, aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
void InputStreamHelper::SerializeInputStream(
|
||||
nsIInputStream* aInputStream, InputStreamParams& aParams,
|
||||
nsTArray<FileDescriptor>& aFileDescriptors, bool aDelayedStart,
|
||||
nsIContentParent* aManager) {
|
||||
uint32_t aMaxSize, uint32_t* aSizeUsed, nsIContentParent* aManager) {
|
||||
SerializeInputStreamInternal(aInputStream, aParams, aFileDescriptors,
|
||||
aDelayedStart, aManager);
|
||||
aDelayedStart, aMaxSize, aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
void InputStreamHelper::SerializeInputStream(
|
||||
nsIInputStream* aInputStream, InputStreamParams& aParams,
|
||||
nsTArray<FileDescriptor>& aFileDescriptors, bool aDelayedStart,
|
||||
PBackgroundParent* aManager) {
|
||||
uint32_t aMaxSize, uint32_t* aSizeUsed, PBackgroundParent* aManager) {
|
||||
SerializeInputStreamInternal(aInputStream, aParams, aFileDescriptors,
|
||||
aDelayedStart, aManager);
|
||||
aDelayedStart, aMaxSize, aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
void InputStreamHelper::SerializeInputStreamAsPipe(nsIInputStream* aInputStream,
|
||||
|
@ -23,32 +23,38 @@ class InputStreamHelper {
|
||||
// These 4 methods allow to serialize an inputStream into InputStreamParams.
|
||||
// The manager is needed in case a stream needs to serialize itself as
|
||||
// IPCRemoteStream.
|
||||
// In case the stream wants to serialize itself as IPCRemoteStream, its
|
||||
// content will be sent to the other side of the IPC pipe in chunks. This
|
||||
// sending can start immediatelly or at the first read based on the value of
|
||||
// |aDelayedStart|.
|
||||
// The stream serializes itself fully only if the resulting IPC message will
|
||||
// be smaller than |aMaxSize|. Otherwise, the stream serializes itself as
|
||||
// IPCRemoteStream, and, its content will be sent to the other side of the IPC
|
||||
// pipe in chunks. This sending can start immediatelly or at the first read
|
||||
// based on the value of |aDelayedStart|. The IPC message size is returned
|
||||
// into |aSizeUsed|.
|
||||
static void SerializeInputStream(nsIInputStream* aInputStream,
|
||||
InputStreamParams& aParams,
|
||||
nsTArray<FileDescriptor>& aFileDescriptors,
|
||||
bool aDelayedStart,
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed,
|
||||
mozilla::dom::nsIContentChild* aManager);
|
||||
|
||||
static void SerializeInputStream(nsIInputStream* aInputStream,
|
||||
InputStreamParams& aParams,
|
||||
nsTArray<FileDescriptor>& aFileDescriptors,
|
||||
bool aDelayedStart,
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed,
|
||||
PBackgroundChild* aManager);
|
||||
|
||||
static void SerializeInputStream(nsIInputStream* aInputStream,
|
||||
InputStreamParams& aParams,
|
||||
nsTArray<FileDescriptor>& aFileDescriptors,
|
||||
bool aDelayedStart,
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed,
|
||||
mozilla::dom::nsIContentParent* aManager);
|
||||
|
||||
static void SerializeInputStream(nsIInputStream* aInputStream,
|
||||
InputStreamParams& aParams,
|
||||
nsTArray<FileDescriptor>& aFileDescriptors,
|
||||
bool aDelayedStart,
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed,
|
||||
PBackgroundParent* aManager);
|
||||
|
||||
// When a stream wants to serialize itself as IPCRemoteStream, it uses one of
|
||||
|
@ -47,22 +47,26 @@ class NS_NO_VTABLE nsIIPCSerializableInputStream : public nsISupports {
|
||||
|
||||
virtual void Serialize(mozilla::ipc::InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart,
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed,
|
||||
mozilla::dom::nsIContentChild* aManager) = 0;
|
||||
|
||||
virtual void Serialize(mozilla::ipc::InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart,
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed,
|
||||
mozilla::ipc::PBackgroundChild* aManager) = 0;
|
||||
|
||||
virtual void Serialize(mozilla::ipc::InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart,
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed,
|
||||
mozilla::dom::nsIContentParent* aManager) = 0;
|
||||
|
||||
virtual void Serialize(mozilla::ipc::InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart,
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed,
|
||||
mozilla::ipc::PBackgroundParent* aManager) = 0;
|
||||
|
||||
virtual bool Deserialize(const mozilla::ipc::InputStreamParams& aParams,
|
||||
@ -72,53 +76,61 @@ class NS_NO_VTABLE nsIIPCSerializableInputStream : public nsISupports {
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIIPCSerializableInputStream,
|
||||
NS_IIPCSERIALIZABLEINPUTSTREAM_IID)
|
||||
|
||||
#define NS_DECL_NSIIPCSERIALIZABLEINPUTSTREAM \
|
||||
virtual void Serialize(mozilla::ipc::InputStreamParams&, \
|
||||
FileDescriptorArray&, bool, \
|
||||
mozilla::dom::nsIContentChild*) override; \
|
||||
\
|
||||
virtual void Serialize(mozilla::ipc::InputStreamParams&, \
|
||||
FileDescriptorArray&, bool, \
|
||||
mozilla::ipc::PBackgroundChild*) override; \
|
||||
\
|
||||
virtual void Serialize(mozilla::ipc::InputStreamParams&, \
|
||||
FileDescriptorArray&, bool, \
|
||||
mozilla::dom::nsIContentParent*) override; \
|
||||
\
|
||||
virtual void Serialize(mozilla::ipc::InputStreamParams&, \
|
||||
FileDescriptorArray&, bool, \
|
||||
mozilla::ipc::PBackgroundParent*) override; \
|
||||
\
|
||||
virtual bool Deserialize(const mozilla::ipc::InputStreamParams&, \
|
||||
#define NS_DECL_NSIIPCSERIALIZABLEINPUTSTREAM \
|
||||
virtual void Serialize(mozilla::ipc::InputStreamParams&, \
|
||||
FileDescriptorArray&, bool, uint32_t, uint32_t*, \
|
||||
mozilla::dom::nsIContentChild*) override; \
|
||||
\
|
||||
virtual void Serialize(mozilla::ipc::InputStreamParams&, \
|
||||
FileDescriptorArray&, bool, uint32_t, uint32_t*, \
|
||||
mozilla::ipc::PBackgroundChild*) override; \
|
||||
\
|
||||
virtual void Serialize(mozilla::ipc::InputStreamParams&, \
|
||||
FileDescriptorArray&, bool, uint32_t, uint32_t*, \
|
||||
mozilla::dom::nsIContentParent*) override; \
|
||||
\
|
||||
virtual void Serialize(mozilla::ipc::InputStreamParams&, \
|
||||
FileDescriptorArray&, bool, uint32_t, uint32_t*, \
|
||||
mozilla::ipc::PBackgroundParent*) override; \
|
||||
\
|
||||
virtual bool Deserialize(const mozilla::ipc::InputStreamParams&, \
|
||||
const FileDescriptorArray&) override;
|
||||
|
||||
#define NS_FORWARD_NSIIPCSERIALIZABLEINPUTSTREAM(_to) \
|
||||
virtual void Serialize(mozilla::ipc::InputStreamParams& aParams, \
|
||||
FileDescriptorArray& aFileDescriptors, \
|
||||
bool aDelayedStart, \
|
||||
bool aDelayedStart, uint32_t aMaxSize, \
|
||||
uint32_t* aSizeUsed, \
|
||||
mozilla::dom::nsIContentChild* aManager) override { \
|
||||
_to Serialize(aParams, aFileDescriptors, aDelayedStart, aManager); \
|
||||
_to Serialize(aParams, aFileDescriptors, aDelayedStart, aMaxSize, \
|
||||
aSizeUsed, aManager); \
|
||||
} \
|
||||
\
|
||||
virtual void Serialize(mozilla::ipc::InputStreamParams& aParams, \
|
||||
FileDescriptorArray& aFileDescriptors, \
|
||||
bool aDelayedStart, \
|
||||
bool aDelayedStart, uint32_t aMaxSize, \
|
||||
uint32_t* aSizeUsed, \
|
||||
mozilla::ipc::PBackgroundChild* aManager) override { \
|
||||
_to Serialize(aParams, aFileDescriptors, aDelayedStart, aManager); \
|
||||
_to Serialize(aParams, aFileDescriptors, aDelayedStart, aMaxSize, \
|
||||
aSizeUsed, aManager); \
|
||||
} \
|
||||
\
|
||||
virtual void Serialize(mozilla::ipc::InputStreamParams& aParams, \
|
||||
FileDescriptorArray& aFileDescriptors, \
|
||||
bool aDelayedStart, \
|
||||
bool aDelayedStart, uint32_t aMaxSize, \
|
||||
uint32_t* aSizeUsed, \
|
||||
mozilla::dom::nsIContentParent* aManager) override { \
|
||||
_to Serialize(aParams, aFileDescriptors, aDelayedStart, aManager); \
|
||||
_to Serialize(aParams, aFileDescriptors, aDelayedStart, aMaxSize, \
|
||||
aSizeUsed, aManager); \
|
||||
} \
|
||||
\
|
||||
virtual void Serialize(mozilla::ipc::InputStreamParams& aParams, \
|
||||
FileDescriptorArray& aFileDescriptors, \
|
||||
bool aDelayedStart, \
|
||||
bool aDelayedStart, uint32_t aMaxSize, \
|
||||
uint32_t* aSizeUsed, \
|
||||
mozilla::ipc::PBackgroundParent* aManager) override { \
|
||||
_to Serialize(aParams, aFileDescriptors, aDelayedStart, aManager); \
|
||||
_to Serialize(aParams, aFileDescriptors, aDelayedStart, aMaxSize, \
|
||||
aSizeUsed, aManager); \
|
||||
} \
|
||||
\
|
||||
virtual bool Deserialize(const mozilla::ipc::InputStreamParams& aParams, \
|
||||
@ -130,37 +142,45 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIIPCSerializableInputStream,
|
||||
#define NS_FORWARD_SAFE_NSIIPCSERIALIZABLEINPUTSTREAM(_to) \
|
||||
virtual void Serialize(mozilla::ipc::InputStreamParams& aParams, \
|
||||
FileDescriptorArray& aFileDescriptors, \
|
||||
bool aDelayedStart, \
|
||||
bool aDelayedStart, uint32_t aMaxSize, \
|
||||
uint32_t* aSizeUsed, \
|
||||
mozilla::dom::nsIContentChild* aManager) override { \
|
||||
if (_to) { \
|
||||
_to->Serialize(aParams, aFileDescriptors, aDelayedStart, aManager); \
|
||||
_to->Serialize(aParams, aFileDescriptors, aDelayedStart, aMaxSize, \
|
||||
aSizeUsed, aManager); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
virtual void Serialize(mozilla::ipc::InputStreamParams& aParams, \
|
||||
FileDescriptorArray& aFileDescriptors, \
|
||||
bool aDelayedStart, \
|
||||
bool aDelayedStart, uint32_t aMaxSize, \
|
||||
uint32_t* aSizeUsed, \
|
||||
mozilla::ipc::PBackgroundChild* aManager) override { \
|
||||
if (_to) { \
|
||||
_to->Serialize(aParams, aFileDescriptors, aDelayedStart, aManager); \
|
||||
_to->Serialize(aParams, aFileDescriptors, aDelayedStart, aMaxSize, \
|
||||
aSizeUsed, aManager); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
virtual void Serialize(mozilla::ipc::InputStreamParams& aParams, \
|
||||
FileDescriptorArray& aFileDescriptors, \
|
||||
bool aDelayedStart, \
|
||||
bool aDelayedStart, uint32_t aMaxSize, \
|
||||
uint32_t* aSizeUsed, \
|
||||
mozilla::dom::nsIContentParent* aManager) override { \
|
||||
if (_to) { \
|
||||
_to->Serialize(aParams, aFileDescriptors, aDelayedStart, aManager); \
|
||||
_to->Serialize(aParams, aFileDescriptors, aDelayedStart, aMaxSize, \
|
||||
aSizeUsed, aManager); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
virtual void Serialize(mozilla::ipc::InputStreamParams& aParams, \
|
||||
FileDescriptorArray& aFileDescriptors, \
|
||||
bool aDelayedStart, \
|
||||
bool aDelayedStart, uint32_t aMaxSize, \
|
||||
uint32_t* aSizeUsed, \
|
||||
mozilla::ipc::PBackgroundParent* aManager) override { \
|
||||
if (_to) { \
|
||||
_to->Serialize(aParams, aFileDescriptors, aDelayedStart, aManager); \
|
||||
_to->Serialize(aParams, aFileDescriptors, aDelayedStart, aMaxSize, \
|
||||
aSizeUsed, aManager); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
|
@ -281,39 +281,49 @@ PartiallySeekableInputStream::OnInputStreamReady(nsIAsyncInputStream* aStream) {
|
||||
void PartiallySeekableInputStream::Serialize(
|
||||
mozilla::ipc::InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
|
||||
uint32_t aMaxSize, uint32_t* aSizeUsed,
|
||||
mozilla::dom::nsIContentChild* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
||||
aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
void PartiallySeekableInputStream::Serialize(
|
||||
mozilla::ipc::InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
|
||||
uint32_t aMaxSize, uint32_t* aSizeUsed,
|
||||
mozilla::ipc::PBackgroundChild* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
||||
aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
void PartiallySeekableInputStream::Serialize(
|
||||
mozilla::ipc::InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
|
||||
uint32_t aMaxSize, uint32_t* aSizeUsed,
|
||||
mozilla::dom::nsIContentParent* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
||||
aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
void PartiallySeekableInputStream::Serialize(
|
||||
mozilla::ipc::InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
|
||||
uint32_t aMaxSize, uint32_t* aSizeUsed,
|
||||
mozilla::ipc::PBackgroundParent* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
||||
aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
template <typename M>
|
||||
void PartiallySeekableInputStream::SerializeInternal(
|
||||
mozilla::ipc::InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors, bool aDelayedStart, M* aManager) {
|
||||
FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
|
||||
uint32_t aMaxSize, uint32_t* aSizeUsed, M* aManager) {
|
||||
MOZ_ASSERT(mWeakIPCSerializableInputStream);
|
||||
MOZ_DIAGNOSTIC_ASSERT(mCachedBuffer.IsEmpty());
|
||||
mozilla::ipc::InputStreamHelper::SerializeInputStream(
|
||||
mInputStream, aParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
mInputStream, aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
||||
aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
bool PartiallySeekableInputStream::Deserialize(
|
||||
|
@ -58,7 +58,8 @@ class PartiallySeekableInputStream final : public nsISeekableStream,
|
||||
template <typename M>
|
||||
void SerializeInternal(mozilla::ipc::InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart, M* aManager);
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed, M* aManager);
|
||||
|
||||
nsCOMPtr<nsIInputStream> mInputStream;
|
||||
|
||||
|
@ -591,35 +591,46 @@ nsBufferedInputStream::GetUnbufferedStream(nsISupports** aStream) {
|
||||
|
||||
void nsBufferedInputStream::Serialize(InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart,
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed,
|
||||
mozilla::dom::nsIContentChild* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
||||
aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
void nsBufferedInputStream::Serialize(InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart,
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed,
|
||||
PBackgroundChild* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
||||
aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
void nsBufferedInputStream::Serialize(
|
||||
InputStreamParams& aParams, FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart, mozilla::dom::nsIContentParent* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
bool aDelayedStart, uint32_t aMaxSize, uint32_t* aSizeUsed,
|
||||
mozilla::dom::nsIContentParent* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
||||
aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
void nsBufferedInputStream::Serialize(InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart,
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed,
|
||||
PBackgroundParent* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
||||
aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
template <typename M>
|
||||
void nsBufferedInputStream::SerializeInternal(
|
||||
InputStreamParams& aParams, FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart, M* aManager) {
|
||||
bool aDelayedStart, uint32_t aMaxSize, uint32_t* aSizeUsed, M* aManager) {
|
||||
MOZ_ASSERT(aSizeUsed);
|
||||
*aSizeUsed = 0;
|
||||
|
||||
BufferedInputStreamParams params;
|
||||
|
||||
if (mStream) {
|
||||
@ -627,8 +638,9 @@ void nsBufferedInputStream::SerializeInternal(
|
||||
MOZ_ASSERT(stream);
|
||||
|
||||
InputStreamParams wrappedParams;
|
||||
InputStreamHelper::SerializeInputStream(
|
||||
stream, wrappedParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
InputStreamHelper::SerializeInputStream(stream, wrappedParams,
|
||||
aFileDescriptors, aDelayedStart,
|
||||
aMaxSize, aSizeUsed, aManager);
|
||||
|
||||
params.optionalStream() = wrappedParams;
|
||||
} else {
|
||||
|
@ -98,7 +98,8 @@ class nsBufferedInputStream final : public nsBufferedStream,
|
||||
template <typename M>
|
||||
void SerializeInternal(mozilla::ipc::InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart, M* aManager);
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed, M* aManager);
|
||||
|
||||
NS_IMETHOD Fill() override;
|
||||
NS_IMETHOD Flush() override { return NS_OK; } // no-op for input streams
|
||||
|
@ -537,29 +537,45 @@ nsFileInputStream::Available(uint64_t* aResult) {
|
||||
|
||||
void nsFileInputStream::Serialize(InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart,
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed,
|
||||
mozilla::dom::nsIContentChild* aManager) {
|
||||
MOZ_ASSERT(aSizeUsed);
|
||||
*aSizeUsed = 0;
|
||||
|
||||
SerializeInternal(aParams, aFileDescriptors);
|
||||
}
|
||||
|
||||
void nsFileInputStream::Serialize(InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart,
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed,
|
||||
PBackgroundChild* aManager) {
|
||||
MOZ_ASSERT(aSizeUsed);
|
||||
*aSizeUsed = 0;
|
||||
|
||||
SerializeInternal(aParams, aFileDescriptors);
|
||||
}
|
||||
|
||||
void nsFileInputStream::Serialize(InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart,
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed,
|
||||
mozilla::dom::nsIContentParent* aManager) {
|
||||
MOZ_ASSERT(aSizeUsed);
|
||||
*aSizeUsed = 0;
|
||||
|
||||
SerializeInternal(aParams, aFileDescriptors);
|
||||
}
|
||||
|
||||
void nsFileInputStream::Serialize(InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart,
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed,
|
||||
PBackgroundParent* aManager) {
|
||||
MOZ_ASSERT(aSizeUsed);
|
||||
*aSizeUsed = 0;
|
||||
|
||||
SerializeInternal(aParams, aFileDescriptors);
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,8 @@ class nsMIMEInputStream : public nsIMIMEInputStream,
|
||||
template <typename M>
|
||||
void SerializeInternal(InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart, M* aManager);
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed, M* aManager);
|
||||
|
||||
struct MOZ_STACK_CLASS ReadSegmentsState {
|
||||
nsCOMPtr<nsIInputStream> mThisStream;
|
||||
@ -337,42 +338,55 @@ nsresult nsMIMEInputStreamConstructor(nsISupports* outer, REFNSIID iid,
|
||||
|
||||
void nsMIMEInputStream::Serialize(InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart,
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed,
|
||||
mozilla::dom::nsIContentChild* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
||||
aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
void nsMIMEInputStream::Serialize(InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart,
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed,
|
||||
PBackgroundChild* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
||||
aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
void nsMIMEInputStream::Serialize(InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart,
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed,
|
||||
mozilla::dom::nsIContentParent* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
||||
aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
void nsMIMEInputStream::Serialize(InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart,
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed,
|
||||
PBackgroundParent* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
||||
aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
template <typename M>
|
||||
void nsMIMEInputStream::SerializeInternal(InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart, M* aManager) {
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed, M* aManager) {
|
||||
MOZ_ASSERT(aSizeUsed);
|
||||
*aSizeUsed = 0;
|
||||
|
||||
MIMEInputStreamParams params;
|
||||
|
||||
if (mStream) {
|
||||
InputStreamParams wrappedParams;
|
||||
InputStreamHelper::SerializeInputStream(
|
||||
mStream, wrappedParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
InputStreamHelper::SerializeInputStream(mStream, wrappedParams,
|
||||
aFileDescriptors, aDelayedStart,
|
||||
aMaxSize, aSizeUsed, aManager);
|
||||
|
||||
NS_ASSERTION(wrappedParams.type() != InputStreamParams::T__None,
|
||||
"Wrapped stream failed to serialize!");
|
||||
|
@ -259,41 +259,51 @@ InputStreamLengthWrapper::OnInputStreamReady(nsIAsyncInputStream* aStream) {
|
||||
void InputStreamLengthWrapper::Serialize(
|
||||
mozilla::ipc::InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
|
||||
uint32_t aMaxSize, uint32_t* aSizeUsed,
|
||||
mozilla::dom::nsIContentChild* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
||||
aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
void InputStreamLengthWrapper::Serialize(
|
||||
mozilla::ipc::InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
|
||||
uint32_t aMaxSize, uint32_t* aSizeUsed,
|
||||
mozilla::ipc::PBackgroundChild* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
||||
aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
void InputStreamLengthWrapper::Serialize(
|
||||
mozilla::ipc::InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
|
||||
uint32_t aMaxSize, uint32_t* aSizeUsed,
|
||||
mozilla::dom::nsIContentParent* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
||||
aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
void InputStreamLengthWrapper::Serialize(
|
||||
mozilla::ipc::InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
|
||||
uint32_t aMaxSize, uint32_t* aSizeUsed,
|
||||
mozilla::ipc::PBackgroundParent* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
||||
aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
template <typename M>
|
||||
void InputStreamLengthWrapper::SerializeInternal(
|
||||
mozilla::ipc::InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors, bool aDelayedStart, M* aManager) {
|
||||
FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
|
||||
uint32_t aMaxSize, uint32_t* aSizeUsed, M* aManager) {
|
||||
MOZ_ASSERT(mInputStream);
|
||||
MOZ_ASSERT(mWeakIPCSerializableInputStream);
|
||||
|
||||
InputStreamLengthWrapperParams params;
|
||||
InputStreamHelper::SerializeInputStream(
|
||||
mInputStream, params.stream(), aFileDescriptors, aDelayedStart, aManager);
|
||||
InputStreamHelper::SerializeInputStream(mInputStream, params.stream(),
|
||||
aFileDescriptors, aDelayedStart,
|
||||
aMaxSize, aSizeUsed, aManager);
|
||||
params.length() = mLength;
|
||||
params.consumed() = mConsumed;
|
||||
|
||||
|
@ -62,7 +62,8 @@ class InputStreamLengthWrapper final : public nsIAsyncInputStream,
|
||||
template <typename M>
|
||||
void SerializeInternal(mozilla::ipc::InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart, M* aManager);
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed, M* aManager);
|
||||
|
||||
void SetSourceStream(already_AddRefed<nsIInputStream> aInputStream);
|
||||
|
||||
|
@ -319,38 +319,48 @@ NonBlockingAsyncInputStream::AsyncWait(nsIInputStreamCallback* aCallback,
|
||||
void NonBlockingAsyncInputStream::Serialize(
|
||||
mozilla::ipc::InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
|
||||
uint32_t aMaxSize, uint32_t* aSizeUsed,
|
||||
mozilla::dom::nsIContentChild* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
||||
aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
void NonBlockingAsyncInputStream::Serialize(
|
||||
mozilla::ipc::InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
|
||||
uint32_t aMaxSize, uint32_t* aSizeUsed,
|
||||
mozilla::ipc::PBackgroundChild* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
||||
aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
void NonBlockingAsyncInputStream::Serialize(
|
||||
mozilla::ipc::InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
|
||||
uint32_t aMaxSize, uint32_t* aSizeUsed,
|
||||
mozilla::dom::nsIContentParent* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
||||
aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
void NonBlockingAsyncInputStream::Serialize(
|
||||
mozilla::ipc::InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
|
||||
uint32_t aMaxSize, uint32_t* aSizeUsed,
|
||||
mozilla::ipc::PBackgroundParent* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
||||
aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
template <typename M>
|
||||
void NonBlockingAsyncInputStream::SerializeInternal(
|
||||
mozilla::ipc::InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors, bool aDelayedStart, M* aManager) {
|
||||
FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
|
||||
uint32_t aMaxSize, uint32_t* aSizeUsed, M* aManager) {
|
||||
MOZ_ASSERT(mWeakIPCSerializableInputStream);
|
||||
InputStreamHelper::SerializeInputStream(
|
||||
mInputStream, aParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
InputStreamHelper::SerializeInputStream(mInputStream, aParams,
|
||||
aFileDescriptors, aDelayedStart,
|
||||
aMaxSize, aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
bool NonBlockingAsyncInputStream::Deserialize(
|
||||
|
@ -47,7 +47,8 @@ class NonBlockingAsyncInputStream final : public nsIAsyncInputStream,
|
||||
template <typename M>
|
||||
void SerializeInternal(mozilla::ipc::InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart, M* aManager);
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed, M* aManager);
|
||||
|
||||
class AsyncWaitRunnable;
|
||||
|
||||
|
@ -422,42 +422,52 @@ SlicedInputStream::OnInputStreamReady(nsIAsyncInputStream* aStream) {
|
||||
|
||||
void SlicedInputStream::Serialize(mozilla::ipc::InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart,
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed,
|
||||
mozilla::dom::nsIContentChild* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
||||
aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
void SlicedInputStream::Serialize(mozilla::ipc::InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart,
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed,
|
||||
mozilla::ipc::PBackgroundChild* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
||||
aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
void SlicedInputStream::Serialize(mozilla::ipc::InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart,
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed,
|
||||
mozilla::dom::nsIContentParent* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
||||
aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
void SlicedInputStream::Serialize(mozilla::ipc::InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart,
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed,
|
||||
mozilla::ipc::PBackgroundParent* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
||||
aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
template <typename M>
|
||||
void SlicedInputStream::SerializeInternal(
|
||||
mozilla::ipc::InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors, bool aDelayedStart, M* aManager) {
|
||||
FileDescriptorArray& aFileDescriptors, bool aDelayedStart,
|
||||
uint32_t aMaxSize, uint32_t* aSizeUsed, M* aManager) {
|
||||
MOZ_ASSERT(mInputStream);
|
||||
MOZ_ASSERT(mWeakIPCSerializableInputStream);
|
||||
|
||||
SlicedInputStreamParams params;
|
||||
InputStreamHelper::SerializeInputStream(
|
||||
mInputStream, params.stream(), aFileDescriptors, aDelayedStart, aManager);
|
||||
InputStreamHelper::SerializeInputStream(mInputStream, params.stream(),
|
||||
aFileDescriptors, aDelayedStart,
|
||||
aMaxSize, aSizeUsed, aManager);
|
||||
params.start() = mStart;
|
||||
params.length() = mLength;
|
||||
params.curPos() = mCurPos;
|
||||
|
@ -64,7 +64,8 @@ class SlicedInputStream final : public nsIAsyncInputStream,
|
||||
template <typename M>
|
||||
void SerializeInternal(mozilla::ipc::InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart, M* aManager);
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed, M* aManager);
|
||||
|
||||
void SetSourceStream(already_AddRefed<nsIInputStream> aInputStream);
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/CheckedInt.h"
|
||||
#include "mozilla/MathAlgorithms.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "mozilla/SystemGroup.h"
|
||||
@ -112,7 +113,8 @@ class nsMultiplexInputStream final : public nsIMultiplexInputStream,
|
||||
template <typename M>
|
||||
void SerializeInternal(InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart, M* aManager);
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed, M* aManager);
|
||||
|
||||
static nsresult ReadSegCb(nsIInputStream* aIn, void* aClosure,
|
||||
const char* aFromRawSegment, uint32_t aToOffset,
|
||||
@ -990,51 +992,69 @@ nsresult nsMultiplexInputStreamConstructor(nsISupports* aOuter, REFNSIID aIID,
|
||||
|
||||
void nsMultiplexInputStream::Serialize(
|
||||
InputStreamParams& aParams, FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart, mozilla::dom::nsIContentChild* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
bool aDelayedStart, uint32_t aMaxSize, uint32_t* aSizeUsed,
|
||||
mozilla::dom::nsIContentChild* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
||||
aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
void nsMultiplexInputStream::Serialize(InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart,
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed,
|
||||
PBackgroundChild* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
||||
aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
void nsMultiplexInputStream::Serialize(
|
||||
InputStreamParams& aParams, FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart, mozilla::dom::nsIContentParent* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
bool aDelayedStart, uint32_t aMaxSize, uint32_t* aSizeUsed,
|
||||
mozilla::dom::nsIContentParent* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
||||
aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
void nsMultiplexInputStream::Serialize(InputStreamParams& aParams,
|
||||
FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart,
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed,
|
||||
PBackgroundParent* aManager) {
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aManager);
|
||||
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
||||
aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
template <typename M>
|
||||
void nsMultiplexInputStream::SerializeInternal(
|
||||
InputStreamParams& aParams, FileDescriptorArray& aFileDescriptors,
|
||||
bool aDelayedStart, M* aManager) {
|
||||
bool aDelayedStart, uint32_t aMaxSize, uint32_t* aSizeUsed, M* aManager) {
|
||||
MutexAutoLock lock(mLock);
|
||||
|
||||
MultiplexInputStreamParams params;
|
||||
|
||||
uint32_t streamCount = mStreams.Length();
|
||||
CheckedUint32 totalSizeUsed = 0;
|
||||
CheckedUint32 maxSize = aMaxSize;
|
||||
|
||||
uint32_t streamCount = mStreams.Length();
|
||||
if (streamCount) {
|
||||
InfallibleTArray<InputStreamParams>& streams = params.streams();
|
||||
|
||||
streams.SetCapacity(streamCount);
|
||||
for (uint32_t index = 0; index < streamCount; index++) {
|
||||
uint32_t sizeUsed = 0;
|
||||
InputStreamParams childStreamParams;
|
||||
InputStreamHelper::SerializeInputStream(
|
||||
mStreams[index].mStream, childStreamParams, aFileDescriptors,
|
||||
aDelayedStart, aManager);
|
||||
|
||||
aDelayedStart, maxSize.value(), &sizeUsed, aManager);
|
||||
streams.AppendElement(childStreamParams);
|
||||
|
||||
MOZ_ASSERT(maxSize.value() >= sizeUsed);
|
||||
|
||||
maxSize -= sizeUsed;
|
||||
MOZ_DIAGNOSTIC_ASSERT(maxSize.isValid());
|
||||
|
||||
totalSizeUsed += sizeUsed;
|
||||
MOZ_DIAGNOSTIC_ASSERT(totalSizeUsed.isValid());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1043,6 +1063,9 @@ void nsMultiplexInputStream::SerializeInternal(
|
||||
params.startedReadingCurrent() = mStartedReadingCurrent;
|
||||
|
||||
aParams = params;
|
||||
|
||||
MOZ_ASSERT(aSizeUsed);
|
||||
*aSizeUsed = totalSizeUsed.value();
|
||||
}
|
||||
|
||||
bool nsMultiplexInputStream::Deserialize(
|
||||
|
@ -368,7 +368,7 @@ class nsStorageInputStream final : public nsIInputStream,
|
||||
|
||||
template <typename M>
|
||||
void SerializeInternal(InputStreamParams& aParams, bool aDelayedStart,
|
||||
M* aManager);
|
||||
uint32_t aMaxSize, uint32_t* aSizeUsed, M* aManager);
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsStorageInputStream, nsIInputStream, nsISeekableStream,
|
||||
@ -552,44 +552,52 @@ nsresult nsStorageInputStream::Seek(uint32_t aPosition) {
|
||||
|
||||
void nsStorageInputStream::Serialize(InputStreamParams& aParams,
|
||||
FileDescriptorArray&, bool aDelayedStart,
|
||||
uint32_t aMaxSize, uint32_t* aSizeUsed,
|
||||
mozilla::dom::nsIContentChild* aManager) {
|
||||
SerializeInternal(aParams, aDelayedStart, aManager);
|
||||
SerializeInternal(aParams, aDelayedStart, aMaxSize, aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
void nsStorageInputStream::Serialize(InputStreamParams& aParams,
|
||||
FileDescriptorArray&, bool aDelayedStart,
|
||||
uint32_t aMaxSize, uint32_t* aSizeUsed,
|
||||
mozilla::ipc::PBackgroundChild* aManager) {
|
||||
SerializeInternal(aParams, aDelayedStart, aManager);
|
||||
SerializeInternal(aParams, aDelayedStart, aMaxSize, aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
void nsStorageInputStream::Serialize(InputStreamParams& aParams,
|
||||
FileDescriptorArray&, bool aDelayedStart,
|
||||
uint32_t aMaxSize, uint32_t* aSizeUsed,
|
||||
mozilla::dom::nsIContentParent* aManager) {
|
||||
SerializeInternal(aParams, aDelayedStart, aManager);
|
||||
SerializeInternal(aParams, aDelayedStart, aMaxSize, aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
void nsStorageInputStream::Serialize(
|
||||
InputStreamParams& aParams, FileDescriptorArray&, bool aDelayedStart,
|
||||
uint32_t aMaxSize, uint32_t* aSizeUsed,
|
||||
mozilla::ipc::PBackgroundParent* aManager) {
|
||||
SerializeInternal(aParams, aDelayedStart, aManager);
|
||||
SerializeInternal(aParams, aDelayedStart, aMaxSize, aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
template <typename M>
|
||||
void nsStorageInputStream::SerializeInternal(InputStreamParams& aParams,
|
||||
bool aDelayedStart, M* aManager) {
|
||||
bool aDelayedStart,
|
||||
uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed, M* aManager) {
|
||||
MOZ_ASSERT(aSizeUsed);
|
||||
*aSizeUsed = 0;
|
||||
|
||||
uint64_t remaining = 0;
|
||||
nsresult rv = Available(&remaining);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
|
||||
// If the string is known to be larger than 1MB, prefer sending it in chunks.
|
||||
const uint64_t kTooLargeStream = 1024 * 1024;
|
||||
|
||||
if (remaining > kTooLargeStream) {
|
||||
if (remaining >= aMaxSize) {
|
||||
InputStreamHelper::SerializeInputStreamAsPipe(this, aParams, aDelayedStart,
|
||||
aManager);
|
||||
return;
|
||||
}
|
||||
|
||||
*aSizeUsed = remaining;
|
||||
|
||||
nsCString combined;
|
||||
int64_t offset;
|
||||
rv = Tell(&offset);
|
||||
|
@ -57,7 +57,7 @@ class nsStringInputStream final : public nsIStringInputStream,
|
||||
|
||||
template <typename M>
|
||||
void SerializeInternal(InputStreamParams& aParams, bool aDelayedStart,
|
||||
M* aManager);
|
||||
uint32_t aMaxSize, uint32_t* aSizeUsed, M* aManager);
|
||||
|
||||
uint32_t Length() const { return mData.Length(); }
|
||||
|
||||
@ -317,44 +317,52 @@ nsStringInputStream::Tell(int64_t* aOutWhere) {
|
||||
|
||||
void nsStringInputStream::Serialize(InputStreamParams& aParams,
|
||||
FileDescriptorArray& /* aFDs */,
|
||||
bool aDelayedStart,
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed,
|
||||
mozilla::dom::nsIContentChild* aManager) {
|
||||
SerializeInternal(aParams, aDelayedStart, aManager);
|
||||
SerializeInternal(aParams, aDelayedStart, aMaxSize, aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
void nsStringInputStream::Serialize(InputStreamParams& aParams,
|
||||
FileDescriptorArray& /* aFDs */,
|
||||
bool aDelayedStart,
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed,
|
||||
PBackgroundChild* aManager) {
|
||||
SerializeInternal(aParams, aDelayedStart, aManager);
|
||||
SerializeInternal(aParams, aDelayedStart, aMaxSize, aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
void nsStringInputStream::Serialize(InputStreamParams& aParams,
|
||||
FileDescriptorArray& /* aFDs */,
|
||||
bool aDelayedStart,
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed,
|
||||
mozilla::dom::nsIContentParent* aManager) {
|
||||
SerializeInternal(aParams, aDelayedStart, aManager);
|
||||
SerializeInternal(aParams, aDelayedStart, aMaxSize, aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
void nsStringInputStream::Serialize(InputStreamParams& aParams,
|
||||
FileDescriptorArray& /* aFDs */,
|
||||
bool aDelayedStart,
|
||||
bool aDelayedStart, uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed,
|
||||
PBackgroundParent* aManager) {
|
||||
SerializeInternal(aParams, aDelayedStart, aManager);
|
||||
SerializeInternal(aParams, aDelayedStart, aMaxSize, aSizeUsed, aManager);
|
||||
}
|
||||
|
||||
template <typename M>
|
||||
void nsStringInputStream::SerializeInternal(InputStreamParams& aParams,
|
||||
bool aDelayedStart, M* aManager) {
|
||||
// If the string is known to be larger than 1MB, prefer sending it in chunks.
|
||||
const uint64_t kTooLargeStream = 1024 * 1024;
|
||||
bool aDelayedStart,
|
||||
uint32_t aMaxSize,
|
||||
uint32_t* aSizeUsed, M* aManager) {
|
||||
MOZ_ASSERT(aSizeUsed);
|
||||
*aSizeUsed = 0;
|
||||
|
||||
if (Length() > kTooLargeStream) {
|
||||
if (Length() >= aMaxSize) {
|
||||
InputStreamHelper::SerializeInputStreamAsPipe(this, aParams, aDelayedStart,
|
||||
aManager);
|
||||
return;
|
||||
}
|
||||
|
||||
*aSizeUsed = Length();
|
||||
|
||||
StringInputStreamParams params;
|
||||
params.data() = PromiseFlatCString(mData);
|
||||
aParams = params;
|
||||
|
@ -269,12 +269,16 @@ class QIInputStream final : public nsIInputStream,
|
||||
|
||||
// nsIIPCSerializableInputStream
|
||||
void Serialize(mozilla::ipc::InputStreamParams&, FileDescriptorArray&, bool,
|
||||
mozilla::dom::nsIContentChild*) override {}
|
||||
uint32_t, uint32_t*, mozilla::dom::nsIContentChild*) override {
|
||||
}
|
||||
void Serialize(mozilla::ipc::InputStreamParams&, FileDescriptorArray&, bool,
|
||||
uint32_t, uint32_t*,
|
||||
mozilla::ipc::PBackgroundChild*) override {}
|
||||
void Serialize(mozilla::ipc::InputStreamParams&, FileDescriptorArray&, bool,
|
||||
uint32_t, uint32_t*,
|
||||
mozilla::dom::nsIContentParent*) override {}
|
||||
void Serialize(mozilla::ipc::InputStreamParams&, FileDescriptorArray&, bool,
|
||||
uint32_t, uint32_t*,
|
||||
mozilla::ipc::PBackgroundParent*) override {}
|
||||
bool Deserialize(const mozilla::ipc::InputStreamParams&,
|
||||
const FileDescriptorArray&) override {
|
||||
|
Loading…
Reference in New Issue
Block a user