mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 782649 - 'Remove old IPC::InputStream'. r=cjones+khuey.
This commit is contained in:
parent
fe9cb94d87
commit
3e66942f49
@ -2,6 +2,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/. */
|
||||
|
||||
include "IPC/IPCMessageUtils.h";
|
||||
|
||||
using mozilla::void_t;
|
||||
|
||||
namespace mozilla {
|
||||
namespace ipc {
|
||||
|
||||
@ -37,8 +41,32 @@ union InputStreamParams
|
||||
StringInputStreamParams;
|
||||
FileInputStreamParams;
|
||||
PartialFileInputStreamParams;
|
||||
BufferedInputStreamParams;
|
||||
MIMEInputStreamParams;
|
||||
MultiplexInputStreamParams;
|
||||
};
|
||||
|
||||
union OptionalInputStreamParams
|
||||
{
|
||||
void_t;
|
||||
InputStreamParams;
|
||||
};
|
||||
|
||||
struct BufferedInputStreamParams
|
||||
{
|
||||
OptionalInputStreamParams optionalStream;
|
||||
uint32_t bufferSize;
|
||||
};
|
||||
|
||||
struct MIMEInputStreamParams
|
||||
{
|
||||
OptionalInputStreamParams optionalStream;
|
||||
nsCString headers;
|
||||
nsCString contentLength;
|
||||
bool startedReading;
|
||||
bool addContentLength;
|
||||
};
|
||||
|
||||
|
||||
} // namespace ipc
|
||||
} // namespace mozilla
|
||||
|
@ -22,6 +22,7 @@ namespace {
|
||||
NS_DEFINE_CID(kStringInputStreamCID, NS_STRINGINPUTSTREAM_CID);
|
||||
NS_DEFINE_CID(kFileInputStreamCID, NS_LOCALFILEINPUTSTREAM_CID);
|
||||
NS_DEFINE_CID(kPartialFileInputStreamCID, NS_PARTIALLOCALFILEINPUTSTREAM_CID);
|
||||
NS_DEFINE_CID(kBufferedInputStreamCID, NS_BUFFEREDINPUTSTREAM_CID);
|
||||
NS_DEFINE_CID(kMultiplexInputStreamCID, NS_MULTIPLEXINPUTSTREAM_CID);
|
||||
|
||||
} // anonymous namespace
|
||||
@ -29,6 +30,42 @@ NS_DEFINE_CID(kMultiplexInputStreamCID, NS_MULTIPLEXINPUTSTREAM_CID);
|
||||
namespace mozilla {
|
||||
namespace ipc {
|
||||
|
||||
void
|
||||
SerializeInputStream(nsIInputStream* aInputStream,
|
||||
InputStreamParams& aParams)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aInputStream);
|
||||
|
||||
nsCOMPtr<nsIIPCSerializableInputStream> serializable =
|
||||
do_QueryInterface(aInputStream);
|
||||
if (!serializable) {
|
||||
NS_WARNING("Input stream is not serializable!");
|
||||
return;
|
||||
}
|
||||
|
||||
serializable->Serialize(aParams);
|
||||
|
||||
NS_WARN_IF_FALSE(aParams.type() != InputStreamParams::T__None,
|
||||
"Serialize failed!");
|
||||
}
|
||||
|
||||
void
|
||||
SerializeInputStream(nsIInputStream* aInputStream,
|
||||
OptionalInputStreamParams& aParams)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (aInputStream) {
|
||||
InputStreamParams params;
|
||||
SerializeInputStream(aInputStream, params);
|
||||
aParams = params;
|
||||
}
|
||||
else {
|
||||
aParams = mozilla::void_t();
|
||||
}
|
||||
}
|
||||
|
||||
already_AddRefed<nsIInputStream>
|
||||
DeserializeInputStream(const InputStreamParams& aParams)
|
||||
{
|
||||
@ -37,10 +74,6 @@ DeserializeInputStream(const InputStreamParams& aParams)
|
||||
nsCOMPtr<nsIIPCSerializableInputStream> serializable;
|
||||
|
||||
switch (aParams.type()) {
|
||||
case InputStreamParams::T__None:
|
||||
NS_WARNING("This union has no type!");
|
||||
return nullptr;
|
||||
|
||||
case InputStreamParams::TStringInputStreamParams:
|
||||
serializable = do_CreateInstance(kStringInputStreamCID);
|
||||
break;
|
||||
@ -53,19 +86,23 @@ DeserializeInputStream(const InputStreamParams& aParams)
|
||||
serializable = do_CreateInstance(kPartialFileInputStreamCID);
|
||||
break;
|
||||
|
||||
case InputStreamParams::TBufferedInputStreamParams:
|
||||
serializable = do_CreateInstance(kBufferedInputStreamCID);
|
||||
break;
|
||||
|
||||
case InputStreamParams::TMultiplexInputStreamParams:
|
||||
serializable = do_CreateInstance(kMultiplexInputStreamCID);
|
||||
break;
|
||||
|
||||
default:
|
||||
NS_WARNING("Unknown params!");
|
||||
MOZ_ASSERT(false, "Unknown params!");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(serializable);
|
||||
|
||||
if (!serializable->Deserialize(aParams)) {
|
||||
NS_WARNING("Deserialize failed!");
|
||||
MOZ_ASSERT(false, "Deserialize failed!");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -75,5 +112,28 @@ DeserializeInputStream(const InputStreamParams& aParams)
|
||||
return stream.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIInputStream>
|
||||
DeserializeInputStream(const OptionalInputStreamParams& aParams)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
nsCOMPtr<nsIInputStream> stream;
|
||||
|
||||
switch (aParams.type()) {
|
||||
case OptionalInputStreamParams::Tvoid_t:
|
||||
// Leave stream null.
|
||||
break;
|
||||
|
||||
case OptionalInputStreamParams::TInputStreamParams:
|
||||
stream = DeserializeInputStream(aParams.get_InputStreamParams());
|
||||
break;
|
||||
|
||||
default:
|
||||
MOZ_ASSERT(false, "Unknown params!");
|
||||
}
|
||||
|
||||
return stream.forget();
|
||||
}
|
||||
|
||||
} // namespace ipc
|
||||
} // namespace mozilla
|
||||
|
@ -12,9 +12,20 @@
|
||||
namespace mozilla {
|
||||
namespace ipc {
|
||||
|
||||
void
|
||||
SerializeInputStream(nsIInputStream* aInputStream,
|
||||
InputStreamParams& aParams);
|
||||
|
||||
void
|
||||
SerializeInputStream(nsIInputStream* aInputStream,
|
||||
OptionalInputStreamParams& aParams);
|
||||
|
||||
already_AddRefed<nsIInputStream>
|
||||
DeserializeInputStream(const InputStreamParams& aParams);
|
||||
|
||||
already_AddRefed<nsIInputStream>
|
||||
DeserializeInputStream(const OptionalInputStreamParams& aParams);
|
||||
|
||||
} // namespace ipc
|
||||
} // namespace mozilla
|
||||
|
||||
|
@ -1294,10 +1294,11 @@ with some new IPDL/C++ nodes that are tuned for C++ codegen."""
|
||||
self.protocolName = None
|
||||
|
||||
def visitTranslationUnit(self, tu):
|
||||
if not isinstance(tu, TranslationUnit) and tu not in self.visitedTus:
|
||||
if tu not in self.visitedTus:
|
||||
self.visitedTus.add(tu)
|
||||
ipdl.ast.Visitor.visitTranslationUnit(self, tu)
|
||||
TranslationUnit.upgrade(tu)
|
||||
if not isinstance(tu, TranslationUnit):
|
||||
TranslationUnit.upgrade(tu)
|
||||
self.typedefs[:] = sorted(list(self.typedefSet))
|
||||
|
||||
def visitInclude(self, inc):
|
||||
@ -1317,20 +1318,23 @@ with some new IPDL/C++ nodes that are tuned for C++ codegen."""
|
||||
using.decl.shortname))
|
||||
|
||||
def visitStructDecl(self, sd):
|
||||
sd.decl.special = 0
|
||||
newfields = [ ]
|
||||
for f in sd.fields:
|
||||
ftype = f.decl.type
|
||||
if _hasVisibleActor(ftype):
|
||||
sd.decl.special = 1
|
||||
# if ftype has a visible actor, we need both
|
||||
# |ActorParent| and |ActorChild| fields
|
||||
newfields.append(_StructField(ftype, f.name, sd, side='parent'))
|
||||
newfields.append(_StructField(ftype, f.name, sd, side='child'))
|
||||
else:
|
||||
newfields.append(_StructField(ftype, f.name, sd))
|
||||
sd.fields = newfields
|
||||
StructDecl.upgrade(sd)
|
||||
if not isinstance(sd, StructDecl):
|
||||
sd.decl.special = 0
|
||||
newfields = [ ]
|
||||
for f in sd.fields:
|
||||
ftype = f.decl.type
|
||||
if _hasVisibleActor(ftype):
|
||||
sd.decl.special = 1
|
||||
# if ftype has a visible actor, we need both
|
||||
# |ActorParent| and |ActorChild| fields
|
||||
newfields.append(_StructField(ftype, f.name, sd,
|
||||
side='parent'))
|
||||
newfields.append(_StructField(ftype, f.name, sd,
|
||||
side='child'))
|
||||
else:
|
||||
newfields.append(_StructField(ftype, f.name, sd))
|
||||
sd.fields = newfields
|
||||
StructDecl.upgrade(sd)
|
||||
|
||||
if sd.decl.fullname is not None:
|
||||
self.typedefSet.add(Typedef(Type(sd.fqClassName()), sd.name))
|
||||
|
@ -4,7 +4,6 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "IPC/IPCMessageUtils.h"
|
||||
#include "mozilla/net/NeckoMessageUtils.h"
|
||||
|
||||
#include "nsAlgorithm.h"
|
||||
#include "nsBufferedStreams.h"
|
||||
@ -12,6 +11,8 @@
|
||||
#include "nsCRT.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsIClassInfoImpl.h"
|
||||
#include "mozilla/ipc/InputStreamUtils.h"
|
||||
#include "mozilla/ipc/IPCSerializableParams.h"
|
||||
|
||||
#ifdef DEBUG_brendan
|
||||
# define METERING
|
||||
@ -38,6 +39,8 @@ static struct {
|
||||
# define METER(x) /* nothing */
|
||||
#endif
|
||||
|
||||
using namespace mozilla::ipc;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsBufferedStream
|
||||
|
||||
@ -252,16 +255,15 @@ NS_INTERFACE_MAP_BEGIN(nsBufferedInputStream)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIInputStream)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIBufferedInputStream)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIStreamBufferAccess)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIIPCSerializableObsolete)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIIPCSerializableInputStream)
|
||||
NS_IMPL_QUERY_CLASSINFO(nsBufferedInputStream)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsBufferedStream)
|
||||
|
||||
NS_IMPL_CI_INTERFACE_GETTER5(nsBufferedInputStream,
|
||||
NS_IMPL_CI_INTERFACE_GETTER4(nsBufferedInputStream,
|
||||
nsIInputStream,
|
||||
nsIBufferedInputStream,
|
||||
nsISeekableStream,
|
||||
nsIStreamBufferAccess,
|
||||
nsIIPCSerializableObsolete)
|
||||
nsIStreamBufferAccess)
|
||||
|
||||
nsresult
|
||||
nsBufferedInputStream::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
@ -484,34 +486,62 @@ nsBufferedInputStream::GetUnbufferedStream(nsISupports* *aStream)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
nsBufferedInputStream::Read(const IPC::Message *aMsg, void **aIter)
|
||||
void
|
||||
nsBufferedInputStream::Serialize(InputStreamParams& aParams)
|
||||
{
|
||||
using IPC::ReadParam;
|
||||
BufferedInputStreamParams params;
|
||||
|
||||
uint32_t bufferSize;
|
||||
IPC::InputStream inputStream;
|
||||
if (!ReadParam(aMsg, aIter, &bufferSize) ||
|
||||
!ReadParam(aMsg, aIter, &inputStream))
|
||||
return false;
|
||||
if (mStream) {
|
||||
nsCOMPtr<nsIIPCSerializableInputStream> stream =
|
||||
do_QueryInterface(mStream);
|
||||
NS_ASSERTION(stream, "Wrapped stream is not serializable!");
|
||||
|
||||
nsCOMPtr<nsIInputStream> stream(inputStream);
|
||||
nsresult rv = Init(stream, bufferSize);
|
||||
if (NS_FAILED(rv))
|
||||
return false;
|
||||
InputStreamParams wrappedParams;
|
||||
stream->Serialize(wrappedParams);
|
||||
|
||||
return true;
|
||||
NS_ASSERTION(wrappedParams.type() != InputStreamParams::T__None,
|
||||
"Wrapped stream failed to serialize!");
|
||||
|
||||
params.optionalStream() = wrappedParams;
|
||||
}
|
||||
else {
|
||||
params.optionalStream() = mozilla::void_t();
|
||||
}
|
||||
|
||||
params.bufferSize() = mBufferSize;
|
||||
|
||||
aParams = params;
|
||||
}
|
||||
|
||||
void
|
||||
nsBufferedInputStream::Write(IPC::Message *aMsg)
|
||||
bool
|
||||
nsBufferedInputStream::Deserialize(const InputStreamParams& aParams)
|
||||
{
|
||||
using IPC::WriteParam;
|
||||
if (aParams.type() != InputStreamParams::TBufferedInputStreamParams) {
|
||||
NS_ERROR("Received unknown parameters from the other process!");
|
||||
return false;
|
||||
}
|
||||
|
||||
WriteParam(aMsg, mBufferSize);
|
||||
const BufferedInputStreamParams& params =
|
||||
aParams.get_BufferedInputStreamParams();
|
||||
const OptionalInputStreamParams& wrappedParams = params.optionalStream();
|
||||
|
||||
IPC::InputStream inputStream(Source());
|
||||
WriteParam(aMsg, inputStream);
|
||||
nsCOMPtr<nsIInputStream> stream;
|
||||
if (wrappedParams.type() == OptionalInputStreamParams::TInputStreamParams) {
|
||||
stream = DeserializeInputStream(wrappedParams.get_InputStreamParams());
|
||||
if (!stream) {
|
||||
NS_WARNING("Failed to deserialize wrapped stream!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
NS_ASSERTION(wrappedParams.type() == OptionalInputStreamParams::Tvoid_t,
|
||||
"Unknown type for OptionalInputStreamParams!");
|
||||
}
|
||||
|
||||
nsresult rv = Init(stream, params.bufferSize());
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -787,4 +817,4 @@ nsBufferedOutputStream::GetUnbufferedStream(nsISupports* *aStream)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
@ -13,7 +13,7 @@
|
||||
#include "nsISeekableStream.h"
|
||||
#include "nsIStreamBufferAccess.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIIPCSerializableObsolete.h"
|
||||
#include "nsIIPCSerializableInputStream.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -60,14 +60,14 @@ protected:
|
||||
class nsBufferedInputStream : public nsBufferedStream,
|
||||
public nsIBufferedInputStream,
|
||||
public nsIStreamBufferAccess,
|
||||
public nsIIPCSerializableObsolete
|
||||
public nsIIPCSerializableInputStream
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIINPUTSTREAM
|
||||
NS_DECL_NSIBUFFEREDINPUTSTREAM
|
||||
NS_DECL_NSISTREAMBUFFERACCESS
|
||||
NS_DECL_NSIIPCSERIALIZABLEOBSOLETE
|
||||
NS_DECL_NSIIPCSERIALIZABLEINPUTSTREAM
|
||||
|
||||
nsBufferedInputStream() : nsBufferedStream() {}
|
||||
virtual ~nsBufferedInputStream() {}
|
||||
|
@ -9,7 +9,6 @@
|
||||
*/
|
||||
|
||||
#include "IPC/IPCMessageUtils.h"
|
||||
#include "mozilla/net/NeckoMessageUtils.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
@ -19,12 +18,16 @@
|
||||
#include "nsIStringStream.h"
|
||||
#include "nsString.h"
|
||||
#include "nsMIMEInputStream.h"
|
||||
#include "nsIIPCSerializableObsolete.h"
|
||||
#include "nsIClassInfoImpl.h"
|
||||
#include "nsIIPCSerializableInputStream.h"
|
||||
#include "mozilla/ipc/InputStreamUtils.h"
|
||||
#include "mozilla/ipc/IPCSerializableParams.h"
|
||||
|
||||
using namespace mozilla::ipc;
|
||||
|
||||
class nsMIMEInputStream : public nsIMIMEInputStream,
|
||||
public nsISeekableStream,
|
||||
public nsIIPCSerializableObsolete
|
||||
public nsIIPCSerializableInputStream
|
||||
{
|
||||
public:
|
||||
nsMIMEInputStream();
|
||||
@ -34,8 +37,8 @@ public:
|
||||
NS_DECL_NSIINPUTSTREAM
|
||||
NS_DECL_NSIMIMEINPUTSTREAM
|
||||
NS_DECL_NSISEEKABLESTREAM
|
||||
NS_DECL_NSIIPCSERIALIZABLEOBSOLETE
|
||||
|
||||
NS_DECL_NSIIPCSERIALIZABLEINPUTSTREAM
|
||||
|
||||
NS_METHOD Init();
|
||||
|
||||
private:
|
||||
@ -73,12 +76,11 @@ NS_IMPL_QUERY_INTERFACE4_CI(nsMIMEInputStream,
|
||||
nsIMIMEInputStream,
|
||||
nsIInputStream,
|
||||
nsISeekableStream,
|
||||
nsIIPCSerializableObsolete)
|
||||
NS_IMPL_CI_INTERFACE_GETTER4(nsMIMEInputStream,
|
||||
nsIIPCSerializableInputStream)
|
||||
NS_IMPL_CI_INTERFACE_GETTER3(nsMIMEInputStream,
|
||||
nsIMIMEInputStream,
|
||||
nsIInputStream,
|
||||
nsISeekableStream,
|
||||
nsIIPCSerializableObsolete)
|
||||
nsISeekableStream)
|
||||
|
||||
nsMIMEInputStream::nsMIMEInputStream() : mAddContentLength(false),
|
||||
mStartedReading(false)
|
||||
@ -293,51 +295,79 @@ nsMIMEInputStreamConstructor(nsISupports *outer, REFNSIID iid, void **result)
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool
|
||||
nsMIMEInputStream::Read(const IPC::Message *aMsg, void **aIter)
|
||||
void
|
||||
nsMIMEInputStream::Serialize(InputStreamParams& aParams)
|
||||
{
|
||||
using IPC::ReadParam;
|
||||
MIMEInputStreamParams params;
|
||||
|
||||
if (!ReadParam(aMsg, aIter, &mHeaders) ||
|
||||
!ReadParam(aMsg, aIter, &mContentLength) ||
|
||||
!ReadParam(aMsg, aIter, &mStartedReading))
|
||||
if (mData) {
|
||||
nsCOMPtr<nsIIPCSerializableInputStream> stream =
|
||||
do_QueryInterface(mData);
|
||||
NS_ASSERTION(stream, "Wrapped stream is not serializable!");
|
||||
|
||||
InputStreamParams wrappedParams;
|
||||
stream->Serialize(wrappedParams);
|
||||
|
||||
NS_ASSERTION(wrappedParams.type() != InputStreamParams::T__None,
|
||||
"Wrapped stream failed to serialize!");
|
||||
|
||||
params.optionalStream() = wrappedParams;
|
||||
}
|
||||
else {
|
||||
params.optionalStream() = mozilla::void_t();
|
||||
}
|
||||
|
||||
params.headers() = mHeaders;
|
||||
params.contentLength() = mContentLength;
|
||||
params.startedReading() = mStartedReading;
|
||||
params.addContentLength() = mAddContentLength;
|
||||
|
||||
aParams = params;
|
||||
}
|
||||
|
||||
bool
|
||||
nsMIMEInputStream::Deserialize(const InputStreamParams& aParams)
|
||||
{
|
||||
if (aParams.type() != InputStreamParams::TMIMEInputStreamParams) {
|
||||
NS_ERROR("Received unknown parameters from the other process!");
|
||||
return false;
|
||||
}
|
||||
|
||||
const MIMEInputStreamParams& params =
|
||||
aParams.get_MIMEInputStreamParams();
|
||||
const OptionalInputStreamParams& wrappedParams = params.optionalStream();
|
||||
|
||||
mHeaders = params.headers();
|
||||
mContentLength = params.contentLength();
|
||||
mStartedReading = params.startedReading();
|
||||
|
||||
// nsMIMEInputStream::Init() already appended mHeaderStream & mCLStream
|
||||
mHeaderStream->ShareData(mHeaders.get(),
|
||||
mStartedReading? mHeaders.Length() : 0);
|
||||
mStartedReading ? mHeaders.Length() : 0);
|
||||
mCLStream->ShareData(mContentLength.get(),
|
||||
mStartedReading? mContentLength.Length() : 0);
|
||||
mStartedReading ? mContentLength.Length() : 0);
|
||||
|
||||
IPC::InputStream inputStream;
|
||||
if (!ReadParam(aMsg, aIter, &inputStream))
|
||||
return false;
|
||||
|
||||
nsCOMPtr<nsIInputStream> stream(inputStream);
|
||||
mData = stream;
|
||||
if (stream) {
|
||||
nsresult rv = mStream->AppendStream(mData);
|
||||
if (NS_FAILED(rv))
|
||||
nsCOMPtr<nsIInputStream> stream;
|
||||
if (wrappedParams.type() == OptionalInputStreamParams::TInputStreamParams) {
|
||||
stream = DeserializeInputStream(wrappedParams.get_InputStreamParams());
|
||||
if (!stream) {
|
||||
NS_WARNING("Failed to deserialize wrapped stream!");
|
||||
return false;
|
||||
}
|
||||
|
||||
mData = stream;
|
||||
|
||||
if (NS_FAILED(mStream->AppendStream(mData))) {
|
||||
NS_WARNING("Failed to append stream!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
NS_ASSERTION(wrappedParams.type() == OptionalInputStreamParams::Tvoid_t,
|
||||
"Unknown type for OptionalInputStreamParams!");
|
||||
}
|
||||
|
||||
if (!ReadParam(aMsg, aIter, &mAddContentLength))
|
||||
return false;
|
||||
mAddContentLength = params.addContentLength();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
nsMIMEInputStream::Write(IPC::Message *aMsg)
|
||||
{
|
||||
using IPC::WriteParam;
|
||||
|
||||
WriteParam(aMsg, mHeaders);
|
||||
WriteParam(aMsg, mContentLength);
|
||||
WriteParam(aMsg, mStartedReading);
|
||||
|
||||
IPC::InputStream inputStream(mData);
|
||||
WriteParam(aMsg, inputStream);
|
||||
|
||||
WriteParam(aMsg, mAddContentLength);
|
||||
}
|
||||
|
@ -143,118 +143,6 @@ struct ParamTraits<URI>
|
||||
}
|
||||
};
|
||||
|
||||
class InputStream {
|
||||
public:
|
||||
InputStream() : mStream(nullptr) {}
|
||||
InputStream(nsIInputStream* aStream) : mStream(aStream) {}
|
||||
operator nsIInputStream*() const { return mStream.get(); }
|
||||
|
||||
friend struct ParamTraits<InputStream>;
|
||||
|
||||
private:
|
||||
// Unimplemented
|
||||
InputStream& operator=(InputStream&);
|
||||
|
||||
nsCOMPtr<nsIInputStream> mStream;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct ParamTraits<InputStream>
|
||||
{
|
||||
typedef InputStream paramType;
|
||||
|
||||
static void Write(Message* aMsg, const paramType& aParam)
|
||||
{
|
||||
bool isNull = !aParam.mStream;
|
||||
aMsg->WriteBool(isNull);
|
||||
|
||||
if (isNull)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIIPCSerializableObsolete> serializable =
|
||||
do_QueryInterface(aParam.mStream);
|
||||
bool isSerializable = !!serializable;
|
||||
WriteParam(aMsg, isSerializable);
|
||||
|
||||
if (!serializable) {
|
||||
NS_WARNING("nsIInputStream implementation doesn't support "
|
||||
"nsIIPCSerializableObsolete; falling back to copying data");
|
||||
|
||||
nsCString streamString;
|
||||
uint64_t bytes;
|
||||
|
||||
nsresult rv = aParam.mStream->Available(&bytes);
|
||||
if (NS_SUCCEEDED(rv) && bytes > 0) {
|
||||
// Also, on 64-bit system, for an interoperability for 32-bit process
|
||||
// and 64-bit process, we shouldn't handle over 4GB message.
|
||||
NS_ABORT_IF_FALSE(bytes < PR_UINT32_MAX, "nsIInputStream has over 4GB data");
|
||||
mozilla::DebugOnly<nsresult> rv =
|
||||
NS_ReadInputStreamToString(aParam.mStream, streamString, (uint32_t)bytes);
|
||||
NS_ABORT_IF_FALSE(NS_SUCCEEDED(rv), "Can't read input stream into a string!");
|
||||
}
|
||||
|
||||
WriteParam(aMsg, streamString);
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIClassInfo> classInfo = do_QueryInterface(aParam.mStream);
|
||||
NS_ASSERTION(classInfo, "Must QI to nsIClassInfo for this to work!");
|
||||
|
||||
char cidStr[NSID_LENGTH];
|
||||
nsCID cid;
|
||||
mozilla::DebugOnly<nsresult> rv = classInfo->GetClassIDNoAlloc(&cid);
|
||||
NS_ABORT_IF_FALSE(NS_SUCCEEDED(rv), "All IPDL streams must report a valid class ID");
|
||||
|
||||
cid.ToProvidedString(cidStr);
|
||||
WriteParam(aMsg, nsCAutoString(cidStr));
|
||||
serializable->Write(aMsg);
|
||||
}
|
||||
|
||||
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
|
||||
{
|
||||
bool isNull;
|
||||
if (!ReadParam(aMsg, aIter, &isNull))
|
||||
return false;
|
||||
|
||||
if (isNull) {
|
||||
aResult->mStream = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isSerializable;
|
||||
if (!ReadParam(aMsg, aIter, &isSerializable))
|
||||
return false;
|
||||
|
||||
nsCOMPtr<nsIInputStream> stream;
|
||||
if (!isSerializable) {
|
||||
nsCString streamString;
|
||||
if (!ReadParam(aMsg, aIter, &streamString))
|
||||
return false;
|
||||
|
||||
nsresult rv = NS_NewCStringInputStream(getter_AddRefs(stream), streamString);
|
||||
if (NS_FAILED(rv))
|
||||
return false;
|
||||
} else {
|
||||
nsCAutoString cidStr;
|
||||
nsCID cid;
|
||||
if (!ReadParam(aMsg, aIter, &cidStr) ||
|
||||
!cid.Parse(cidStr.get()))
|
||||
return false;
|
||||
|
||||
stream = do_CreateInstance(cid);
|
||||
if (!stream)
|
||||
return false;
|
||||
nsCOMPtr<nsIIPCSerializableObsolete> serializable =
|
||||
do_QueryInterface(stream);
|
||||
if (!serializable || !serializable->Read(aMsg, aIter))
|
||||
return false;
|
||||
}
|
||||
|
||||
stream.swap(aResult->mStream);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
// nsIPermissionManager utilities
|
||||
|
||||
struct Permission
|
||||
@ -365,4 +253,4 @@ struct ParamTraits<PRNetAddr>
|
||||
|
||||
}
|
||||
|
||||
#endif // mozilla_net_NeckoMessageUtils_h
|
||||
#endif // mozilla_net_NeckoMessageUtils_h
|
@ -16,6 +16,9 @@
|
||||
#include "nsILoadContext.h"
|
||||
#include "nsCDefaultURIFixup.h"
|
||||
#include "base/compiler_specific.h"
|
||||
#include "mozilla/ipc/InputStreamUtils.h"
|
||||
|
||||
using namespace mozilla::ipc;
|
||||
|
||||
#undef LOG
|
||||
#define LOG(args) PR_LOG(gFTPLog, PR_LOG_DEBUG, args)
|
||||
@ -160,8 +163,11 @@ FTPChannelChild::AsyncOpen(::nsIStreamListener* listener, nsISupports* aContext)
|
||||
if (mLoadGroup)
|
||||
mLoadGroup->AddRequest(this, nullptr);
|
||||
|
||||
SendAsyncOpen(nsBaseChannel::URI(), mStartPos, mEntityID,
|
||||
IPC::InputStream(mUploadStream), IPC::SerializedLoadContext(this));
|
||||
OptionalInputStreamParams uploadStream;
|
||||
SerializeInputStream(mUploadStream, uploadStream);
|
||||
|
||||
SendAsyncOpen(nsBaseChannel::URI(), mStartPos, mEntityID, uploadStream,
|
||||
IPC::SerializedLoadContext(this));
|
||||
|
||||
// The socket transport layer in the chrome process now has a logical ref to
|
||||
// us until OnStopRequest is called.
|
||||
|
@ -12,6 +12,9 @@
|
||||
#include "nsIRedirectChannelRegistrar.h"
|
||||
#include "nsFtpProtocolHandler.h"
|
||||
#include "mozilla/LoadContext.h"
|
||||
#include "mozilla/ipc/InputStreamUtils.h"
|
||||
|
||||
using namespace mozilla::ipc;
|
||||
|
||||
#undef LOG
|
||||
#define LOG(args) PR_LOG(gFTPLog, PR_LOG_DEBUG, args)
|
||||
@ -58,7 +61,7 @@ bool
|
||||
FTPChannelParent::RecvAsyncOpen(const IPC::URI& aURI,
|
||||
const uint64_t& aStartPos,
|
||||
const nsCString& aEntityID,
|
||||
const IPC::InputStream& aUploadStream,
|
||||
const OptionalInputStreamParams& aUploadStream,
|
||||
const IPC::SerializedLoadContext& loadContext)
|
||||
{
|
||||
nsCOMPtr<nsIURI> uri(aURI);
|
||||
@ -82,7 +85,7 @@ FTPChannelParent::RecvAsyncOpen(const IPC::URI& aURI,
|
||||
|
||||
mChannel = static_cast<nsFtpChannel*>(chan.get());
|
||||
|
||||
nsCOMPtr<nsIInputStream> upload(aUploadStream);
|
||||
nsCOMPtr<nsIInputStream> upload = DeserializeInputStream(aUploadStream);
|
||||
if (upload) {
|
||||
// contentType and contentLength are ignored
|
||||
rv = mChannel->SetUploadStream(upload, EmptyCString(), 0);
|
||||
|
@ -37,7 +37,7 @@ protected:
|
||||
virtual bool RecvAsyncOpen(const IPC::URI& uri,
|
||||
const uint64_t& startPos,
|
||||
const nsCString& entityID,
|
||||
const IPC::InputStream& uploadStream,
|
||||
const OptionalInputStreamParams& uploadStream,
|
||||
const IPC::SerializedLoadContext& loadContext) MOZ_OVERRIDE;
|
||||
virtual bool RecvConnectChannel(const uint32_t& channelId) MOZ_OVERRIDE;
|
||||
virtual bool RecvCancel(const nsresult& status) MOZ_OVERRIDE;
|
||||
|
@ -8,9 +8,9 @@
|
||||
include protocol PNecko;
|
||||
|
||||
include "mozilla/net/NeckoMessageUtils.h";
|
||||
include IPCSerializableParams;
|
||||
|
||||
using IPC::URI;
|
||||
using IPC::InputStream;
|
||||
using IPC::SerializedLoadContext;
|
||||
using PRTime;
|
||||
|
||||
@ -27,7 +27,7 @@ parent:
|
||||
AsyncOpen(URI uri,
|
||||
uint64_t startPos,
|
||||
nsCString entityID,
|
||||
InputStream uploadStream,
|
||||
OptionalInputStreamParams uploadStream,
|
||||
SerializedLoadContext loadContext);
|
||||
|
||||
ConnectChannel(uint32_t channelId);
|
||||
|
@ -16,6 +16,9 @@
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsSerializationHelper.h"
|
||||
#include "base/compiler_specific.h"
|
||||
#include "mozilla/ipc/InputStreamUtils.h"
|
||||
|
||||
using namespace mozilla::ipc;
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
@ -1034,12 +1037,14 @@ HttpChannelChild::AsyncOpen(nsIStreamListener *listener, nsISupports *aContext)
|
||||
|
||||
gNeckoChild->SendPHttpChannelConstructor(this, tabChild);
|
||||
|
||||
OptionalInputStreamParams uploadStream;
|
||||
SerializeInputStream(mUploadStream, uploadStream);
|
||||
|
||||
SendAsyncOpen(IPC::URI(mURI), IPC::URI(mOriginalURI),
|
||||
IPC::URI(mDocumentURI), IPC::URI(mReferrer), mLoadFlags,
|
||||
mClientSetRequestHeaders, mRequestHead.Method(),
|
||||
IPC::InputStream(mUploadStream), mUploadStreamHasHeaders,
|
||||
mPriority, mRedirectionLimit, mAllowPipelining,
|
||||
mForceAllowThirdPartyCookie, mSendResumeAt,
|
||||
mClientSetRequestHeaders, mRequestHead.Method(), uploadStream,
|
||||
mUploadStreamHasHeaders, mPriority, mRedirectionLimit,
|
||||
mAllowPipelining, mForceAllowThirdPartyCookie, mSendResumeAt,
|
||||
mStartPos, mEntityID, mChooseApplicationCache,
|
||||
appCacheClientId, mAllowSpdy, IPC::SerializedLoadContext(this));
|
||||
|
||||
|
@ -24,6 +24,9 @@
|
||||
#include "nsIRedirectChannelRegistrar.h"
|
||||
#include "mozilla/LoadContext.h"
|
||||
#include "prinit.h"
|
||||
#include "mozilla/ipc/InputStreamUtils.h"
|
||||
|
||||
using namespace mozilla::ipc;
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
@ -108,7 +111,7 @@ HttpChannelParent::RecvAsyncOpen(const IPC::URI& aURI,
|
||||
const uint32_t& loadFlags,
|
||||
const RequestHeaderTuples& requestHeaders,
|
||||
const nsHttpAtom& requestMethod,
|
||||
const IPC::InputStream& uploadStream,
|
||||
const OptionalInputStreamParams& uploadStream,
|
||||
const bool& uploadStreamHasHeaders,
|
||||
const uint16_t& priority,
|
||||
const uint8_t& redirectionLimit,
|
||||
@ -172,7 +175,7 @@ HttpChannelParent::RecvAsyncOpen(const IPC::URI& aURI,
|
||||
|
||||
httpChan->SetRequestMethod(nsDependentCString(requestMethod.get()));
|
||||
|
||||
nsCOMPtr<nsIInputStream> stream(uploadStream);
|
||||
nsCOMPtr<nsIInputStream> stream = DeserializeInputStream(uploadStream);
|
||||
if (stream) {
|
||||
httpChan->InternalSetUploadStream(stream);
|
||||
httpChan->SetUploadStreamHasHeaders(uploadStreamHasHeaders);
|
||||
|
@ -52,7 +52,7 @@ protected:
|
||||
const uint32_t& loadFlags,
|
||||
const RequestHeaderTuples& requestHeaders,
|
||||
const nsHttpAtom& requestMethod,
|
||||
const IPC::InputStream& uploadStream,
|
||||
const OptionalInputStreamParams& uploadStream,
|
||||
const bool& uploadStreamHasHeaders,
|
||||
const uint16_t& priority,
|
||||
const uint8_t& redirectionLimit,
|
||||
|
@ -11,12 +11,13 @@ include "mozilla/net/PHttpChannelParams.h";
|
||||
include "mozilla/net/NeckoMessageUtils.h";
|
||||
include "prio.h";
|
||||
|
||||
include IPCSerializableParams;
|
||||
|
||||
using RequestHeaderTuples;
|
||||
using nsHttpHeaderArray;
|
||||
using nsHttpResponseHead;
|
||||
using nsHttpAtom;
|
||||
using IPC::URI;
|
||||
using IPC::InputStream;
|
||||
using IPC::SerializedLoadContext;
|
||||
using PRNetAddr;
|
||||
|
||||
@ -39,7 +40,7 @@ parent:
|
||||
uint32_t loadFlags,
|
||||
RequestHeaderTuples requestHeaders,
|
||||
nsHttpAtom requestMethod,
|
||||
InputStream uploadStream,
|
||||
OptionalInputStreamParams uploadStream,
|
||||
bool uploadStreamHasHeaders,
|
||||
uint16_t priority,
|
||||
uint8_t redirectionLimit,
|
||||
|
@ -9,9 +9,9 @@ include protocol PNecko;
|
||||
include protocol PBrowser;
|
||||
|
||||
include "mozilla/net/NeckoMessageUtils.h";
|
||||
include IPCSerializableParams;
|
||||
|
||||
using IPC::URI;
|
||||
using IPC::InputStream;
|
||||
using IPC::SerializedLoadContext;
|
||||
|
||||
namespace mozilla {
|
||||
@ -31,7 +31,7 @@ parent:
|
||||
Close(uint16_t code, nsCString reason);
|
||||
SendMsg(nsCString aMsg);
|
||||
SendBinaryMsg(nsCString aMsg);
|
||||
SendBinaryStream(InputStream aStream, uint32_t aLength);
|
||||
SendBinaryStream(InputStreamParams aStream, uint32_t aLength);
|
||||
|
||||
DeleteSelf();
|
||||
|
||||
|
@ -11,6 +11,9 @@
|
||||
#include "nsITabChild.h"
|
||||
#include "nsILoadContext.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "mozilla/ipc/InputStreamUtils.h"
|
||||
|
||||
using namespace mozilla::ipc;
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
@ -381,7 +384,10 @@ WebSocketChannelChild::SendBinaryStream(nsIInputStream *aStream,
|
||||
{
|
||||
LOG(("WebSocketChannelChild::SendBinaryStream() %p\n", this));
|
||||
|
||||
if (!mIPCOpen || !SendSendBinaryStream(IPC::InputStream(aStream), aLength))
|
||||
OptionalInputStreamParams stream;
|
||||
SerializeInputStream(aStream, stream);
|
||||
|
||||
if (!mIPCOpen || !SendSendBinaryStream(stream, aLength))
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -8,6 +8,9 @@
|
||||
#include "WebSocketChannelParent.h"
|
||||
#include "nsIAuthPromptProvider.h"
|
||||
#include "mozilla/LoadContext.h"
|
||||
#include "mozilla/ipc/InputStreamUtils.h"
|
||||
|
||||
using namespace mozilla::ipc;
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
@ -114,12 +117,16 @@ WebSocketChannelParent::RecvSendBinaryMsg(const nsCString& aMsg)
|
||||
}
|
||||
|
||||
bool
|
||||
WebSocketChannelParent::RecvSendBinaryStream(const InputStream& aStream,
|
||||
WebSocketChannelParent::RecvSendBinaryStream(const InputStreamParams& aStream,
|
||||
const uint32_t& aLength)
|
||||
{
|
||||
LOG(("WebSocketChannelParent::RecvSendBinaryStream() %p\n", this));
|
||||
if (mChannel) {
|
||||
nsresult rv = mChannel->SendBinaryStream(aStream, aLength);
|
||||
nsCOMPtr<nsIInputStream> stream = DeserializeInputStream(aStream);
|
||||
if (!stream) {
|
||||
return false;
|
||||
}
|
||||
nsresult rv = mChannel->SendBinaryStream(stream, aLength);
|
||||
NS_ENSURE_SUCCESS(rv, true);
|
||||
}
|
||||
return true;
|
||||
|
@ -39,7 +39,7 @@ class WebSocketChannelParent : public PWebSocketParent,
|
||||
bool RecvClose(const uint16_t & code, const nsCString & reason);
|
||||
bool RecvSendMsg(const nsCString& aMsg);
|
||||
bool RecvSendBinaryMsg(const nsCString& aMsg);
|
||||
bool RecvSendBinaryStream(const InputStream& aStream,
|
||||
bool RecvSendBinaryStream(const InputStreamParams& aStream,
|
||||
const uint32_t& aLength);
|
||||
bool RecvDeleteSelf();
|
||||
|
||||
|
@ -9,7 +9,6 @@
|
||||
*/
|
||||
|
||||
#include "IPC/IPCMessageUtils.h"
|
||||
#include "mozilla/net/NeckoMessageUtils.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
|
||||
#include "nsMultiplexInputStream.h"
|
||||
@ -27,7 +26,6 @@ using namespace mozilla::ipc;
|
||||
|
||||
class nsMultiplexInputStream MOZ_FINAL : public nsIMultiplexInputStream,
|
||||
public nsISeekableStream,
|
||||
public nsIIPCSerializableObsolete,
|
||||
public nsIIPCSerializableInputStream
|
||||
{
|
||||
public:
|
||||
@ -37,7 +35,6 @@ public:
|
||||
NS_DECL_NSIINPUTSTREAM
|
||||
NS_DECL_NSIMULTIPLEXINPUTSTREAM
|
||||
NS_DECL_NSISEEKABLESTREAM
|
||||
NS_DECL_NSIIPCSERIALIZABLEOBSOLETE
|
||||
NS_DECL_NSIIPCSERIALIZABLEINPUTSTREAM
|
||||
|
||||
private:
|
||||
@ -67,11 +64,10 @@ NS_IMPL_THREADSAFE_RELEASE(nsMultiplexInputStream)
|
||||
NS_IMPL_CLASSINFO(nsMultiplexInputStream, NULL, nsIClassInfo::THREADSAFE,
|
||||
NS_MULTIPLEXINPUTSTREAM_CID)
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE5_CI(nsMultiplexInputStream,
|
||||
NS_IMPL_QUERY_INTERFACE4_CI(nsMultiplexInputStream,
|
||||
nsIMultiplexInputStream,
|
||||
nsIInputStream,
|
||||
nsISeekableStream,
|
||||
nsIIPCSerializableObsolete,
|
||||
nsIIPCSerializableInputStream)
|
||||
NS_IMPL_CI_INTERFACE_GETTER3(nsMultiplexInputStream,
|
||||
nsIMultiplexInputStream,
|
||||
@ -596,52 +592,6 @@ nsMultiplexInputStreamConstructor(nsISupports *outer,
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool
|
||||
nsMultiplexInputStream::Read(const IPC::Message *aMsg, void **aIter)
|
||||
{
|
||||
using IPC::ReadParam;
|
||||
|
||||
uint32_t count;
|
||||
if (!ReadParam(aMsg, aIter, &count))
|
||||
return false;
|
||||
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
IPC::InputStream inputStream;
|
||||
if (!ReadParam(aMsg, aIter, &inputStream))
|
||||
return false;
|
||||
|
||||
nsCOMPtr<nsIInputStream> stream(inputStream);
|
||||
nsresult rv = AppendStream(stream);
|
||||
if (NS_FAILED(rv))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ReadParam(aMsg, aIter, &mCurrentStream) ||
|
||||
!ReadParam(aMsg, aIter, &mStartedReadingCurrent) ||
|
||||
!ReadParam(aMsg, aIter, &mStatus))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
nsMultiplexInputStream::Write(IPC::Message *aMsg)
|
||||
{
|
||||
using IPC::WriteParam;
|
||||
|
||||
uint32_t count = mStreams.Length();
|
||||
WriteParam(aMsg, count);
|
||||
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
IPC::InputStream inputStream(mStreams[i]);
|
||||
WriteParam(aMsg, inputStream);
|
||||
}
|
||||
|
||||
WriteParam(aMsg, mCurrentStream);
|
||||
WriteParam(aMsg, mStartedReadingCurrent);
|
||||
WriteParam(aMsg, mStatus);
|
||||
}
|
||||
|
||||
void
|
||||
nsMultiplexInputStream::Serialize(InputStreamParams& aParams)
|
||||
{
|
||||
@ -712,4 +662,4 @@ nsMultiplexInputStream::Deserialize(const InputStreamParams& aParams)
|
||||
mStartedReadingCurrent = params.startedReadingCurrent();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user