Bug 564553 - e10s HTTP: Serialize nsInputStreams to support large file uploads. Part 1: serialize them. r=dwitte, a=blocking-fennec2.0b2+
This commit is contained in:
@@ -52,6 +52,10 @@
|
||||
* Based on original code from nsIStringStream.cpp
|
||||
*/
|
||||
|
||||
#ifdef MOZ_IPC
|
||||
#include "IPC/IPCMessageUtils.h"
|
||||
#endif
|
||||
|
||||
#include "nsStringStream.h"
|
||||
#include "nsStreamUtils.h"
|
||||
#include "nsReadableUtils.h"
|
||||
@@ -62,6 +66,7 @@
|
||||
#include "prerror.h"
|
||||
#include "plstr.h"
|
||||
#include "nsIClassInfoImpl.h"
|
||||
#include "nsIIPCSerializable.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// nsIStringInputStream implementation
|
||||
@@ -70,6 +75,7 @@
|
||||
class nsStringInputStream : public nsIStringInputStream
|
||||
, public nsISeekableStream
|
||||
, public nsISupportsCString
|
||||
, public nsIIPCSerializable
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
@@ -78,6 +84,7 @@ public:
|
||||
NS_DECL_NSISEEKABLESTREAM
|
||||
NS_DECL_NSISUPPORTSPRIMITIVE
|
||||
NS_DECL_NSISUPPORTSCSTRING
|
||||
NS_DECL_NSIIPCSERIALIZABLE
|
||||
|
||||
nsStringInputStream()
|
||||
: mData(nsnull)
|
||||
@@ -121,16 +128,18 @@ NS_IMPL_THREADSAFE_RELEASE(nsStringInputStream)
|
||||
|
||||
NS_IMPL_CLASSINFO(nsStringInputStream, NULL, nsIClassInfo::THREADSAFE,
|
||||
NS_STRINGINPUTSTREAM_CID)
|
||||
NS_IMPL_QUERY_INTERFACE4_CI(nsStringInputStream,
|
||||
NS_IMPL_QUERY_INTERFACE5_CI(nsStringInputStream,
|
||||
nsIStringInputStream,
|
||||
nsIInputStream,
|
||||
nsISupportsCString,
|
||||
nsISeekableStream)
|
||||
NS_IMPL_CI_INTERFACE_GETTER4(nsStringInputStream,
|
||||
nsISeekableStream,
|
||||
nsIIPCSerializable)
|
||||
NS_IMPL_CI_INTERFACE_GETTER5(nsStringInputStream,
|
||||
nsIStringInputStream,
|
||||
nsIInputStream,
|
||||
nsISupportsCString,
|
||||
nsISeekableStream)
|
||||
nsISeekableStream,
|
||||
nsIIPCSerializable)
|
||||
|
||||
/////////
|
||||
// nsISupportsCString implementation
|
||||
@@ -349,6 +358,44 @@ nsStringInputStream::SetEOF()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/////////
|
||||
// nsIIPCSerializable implementation
|
||||
/////////
|
||||
|
||||
PRBool
|
||||
nsStringInputStream::Read(const IPC::Message *aMsg, void **aIter)
|
||||
{
|
||||
#ifdef MOZ_IPC
|
||||
using IPC::ReadParam;
|
||||
|
||||
nsCAutoString value;
|
||||
|
||||
if (!ReadParam(aMsg, aIter, &value))
|
||||
return PR_FALSE;
|
||||
|
||||
nsresult rv = SetData(value.get(), value.Length());
|
||||
if (NS_FAILED(rv))
|
||||
return PR_FALSE;
|
||||
|
||||
return PR_TRUE;
|
||||
#else
|
||||
return PR_FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
nsStringInputStream::Write(IPC::Message *aMsg)
|
||||
{
|
||||
#ifdef MOZ_IPC
|
||||
using IPC::WriteParam;
|
||||
|
||||
nsCAutoString value;
|
||||
GetData(value);
|
||||
|
||||
WriteParam(aMsg, value);
|
||||
#endif
|
||||
}
|
||||
|
||||
NS_COM nsresult
|
||||
NS_NewByteInputStream(nsIInputStream** aStreamResult,
|
||||
const char* aStringToRead, PRInt32 aLength,
|
||||
|
||||
Reference in New Issue
Block a user