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:
Jae-Seong Lee-Russo
2010-10-19 17:24:52 -07:00
parent b94b577478
commit 5952b72f45
16 changed files with 559 additions and 115 deletions

View File

@@ -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,