Bounce input stream and FTP patches for Windows test failure. a=bustage
authorDan Witte <dwitte@mozilla.com>
Tue, 19 Oct 2010 19:46:54 -0700
changeset 56161 227b2a6ecdde3d377b7082b16533812814118ea0
parent 56160 d6c5a710d01c5c2765d2a3b4da9d3640e6f034af
child 56162 8012dab3b01ce8cbbb5749c9afd807f3904974c9
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersbustage
milestone2.0b8pre
Bounce input stream and FTP patches for Windows test failure. a=bustage
ipc/ipdl/Makefile.in
netwerk/base/src/nsBaseChannel.h
netwerk/base/src/nsBufferedStreams.cpp
netwerk/base/src/nsBufferedStreams.h
netwerk/base/src/nsFileStreams.cpp
netwerk/base/src/nsFileStreams.h
netwerk/base/src/nsMIMEInputStream.cpp
netwerk/ipc/NeckoChild.cpp
netwerk/ipc/NeckoChild.h
netwerk/ipc/NeckoCommon.h
netwerk/ipc/NeckoMessageUtils.h
netwerk/ipc/NeckoParent.cpp
netwerk/ipc/NeckoParent.h
netwerk/ipc/PNecko.ipdl
netwerk/protocol/ftp/Makefile.in
netwerk/protocol/ftp/nsFTPChannel.h
netwerk/protocol/ftp/nsFtpProtocolHandler.cpp
netwerk/protocol/ftp/nsFtpProtocolHandler.h
netwerk/protocol/http/HttpBaseChannel.h
netwerk/protocol/http/HttpChannelChild.cpp
netwerk/protocol/http/HttpChannelParent.cpp
netwerk/protocol/http/HttpChannelParent.h
netwerk/protocol/http/PHttpChannel.ipdl
netwerk/protocol/http/PHttpChannelParams.h
xpcom/io/Makefile.in
xpcom/io/nsMultiplexInputStream.cpp
xpcom/io/nsStringStream.cpp
--- a/ipc/ipdl/Makefile.in
+++ b/ipc/ipdl/Makefile.in
@@ -59,17 +59,16 @@ IPDLDIRS =  \
   dom/ipc  \
   gfx/layers/ipc \
   ipc/ipdl/test/cxx  \
   ipc/testshell  \
   js/ipc  \
   js/jetpack \
   layout/ipc \
   netwerk/ipc  \
-  netwerk/protocol/ftp \
   netwerk/protocol/http  \
   netwerk/protocol/wyciwyg \
   netwerk/cookie  \
   $(NULL)
 ##-----------------------------------------------------------------------------
 
 ifdef MOZ_IPDL_TESTS
 DIRS += test
--- a/netwerk/base/src/nsBaseChannel.h
+++ b/netwerk/base/src/nsBaseChannel.h
@@ -276,29 +276,27 @@ private:
   };
   friend class RedirectRunnable;
 
   nsRefPtr<nsInputStreamPump>         mPump;
   nsCOMPtr<nsIInterfaceRequestor>     mCallbacks;
   nsCOMPtr<nsIProgressEventSink>      mProgressSink;
   nsCOMPtr<nsIURI>                    mOriginalURI;
   nsCOMPtr<nsIURI>                    mURI;
+  nsCOMPtr<nsILoadGroup>              mLoadGroup;
   nsCOMPtr<nsISupports>               mOwner;
   nsCOMPtr<nsISupports>               mSecurityInfo;
+  nsCOMPtr<nsIStreamListener>         mListener;
+  nsCOMPtr<nsISupports>               mListenerContext;
   nsCOMPtr<nsIChannel>                mRedirectChannel;
   nsCString                           mContentType;
   nsCString                           mContentCharset;
   PRUint32                            mLoadFlags;
+  nsresult                            mStatus;
   PRPackedBool                        mQueriedProgressSink;
   PRPackedBool                        mSynthProgressEvents;
   PRPackedBool                        mWasOpened;
   PRPackedBool                        mWaitingOnAsyncRedirect;
   PRPackedBool                        mOpenRedirectChannel;
   PRUint32                            mRedirectFlags;
-
-protected:
-  nsCOMPtr<nsILoadGroup>              mLoadGroup;
-  nsCOMPtr<nsIStreamListener>         mListener;
-  nsCOMPtr<nsISupports>               mListenerContext;
-  nsresult                            mStatus;
 };
 
 #endif // !nsBaseChannel_h__
--- a/netwerk/base/src/nsBufferedStreams.cpp
+++ b/netwerk/base/src/nsBufferedStreams.cpp
@@ -30,26 +30,19 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#ifdef MOZ_IPC
-#include "IPC/IPCMessageUtils.h"
-#include "mozilla/net/NeckoMessageUtils.h"
-#endif
-
 #include "nsBufferedStreams.h"
 #include "nsStreamUtils.h"
 #include "nsCRT.h"
-#include "nsNetCID.h"
-#include "nsIClassInfoImpl.h"
 
 #ifdef DEBUG_brendan
 # define METERING
 #endif
 
 #ifdef METERING
 # include <stdio.h>
 # define METER(x)       x
@@ -248,36 +241,21 @@ nsBufferedStream::SetEOF()
     if (NS_FAILED(rv)) return rv;
 
     return ras->SetEOF();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsBufferedInputStream
 
-NS_IMPL_ADDREF_INHERITED(nsBufferedInputStream, nsBufferedStream)
-NS_IMPL_RELEASE_INHERITED(nsBufferedInputStream, nsBufferedStream)
-
-NS_IMPL_CLASSINFO(nsBufferedInputStream, NULL, nsIClassInfo::THREADSAFE,
-                  NS_BUFFEREDINPUTSTREAM_CID)
-
-NS_INTERFACE_MAP_BEGIN(nsBufferedInputStream)
-    NS_INTERFACE_MAP_ENTRY(nsIInputStream)
-    NS_INTERFACE_MAP_ENTRY(nsIBufferedInputStream)
-    NS_INTERFACE_MAP_ENTRY(nsIStreamBufferAccess)
-    NS_INTERFACE_MAP_ENTRY(nsIIPCSerializable)
-    NS_IMPL_QUERY_CLASSINFO(nsBufferedInputStream)
-NS_INTERFACE_MAP_END_INHERITING(nsBufferedStream)
-
-NS_IMPL_CI_INTERFACE_GETTER5(nsBufferedInputStream,
+NS_IMPL_ISUPPORTS_INHERITED3(nsBufferedInputStream, 
+                             nsBufferedStream,
                              nsIInputStream,
                              nsIBufferedInputStream,
-                             nsISeekableStream,
-                             nsIStreamBufferAccess,
-                             nsIIPCSerializable)
+                             nsIStreamBufferAccess)
 
 nsresult
 nsBufferedInputStream::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
 {
     NS_ENSURE_NO_AGGREGATION(aOuter);
 
     nsBufferedInputStream* stream = new nsBufferedInputStream();
     if (stream == nsnull)
@@ -483,52 +461,16 @@ nsBufferedInputStream::GetUnbufferedStre
     mBufferStartOffset += mCursor;
     mFillPoint = mCursor = 0;
 
     *aStream = mStream;
     NS_IF_ADDREF(*aStream);
     return NS_OK;
 }
 
-PRBool
-nsBufferedInputStream::Read(const IPC::Message *aMsg, void **aIter)
-{
-#ifdef MOZ_IPC
-    using IPC::ReadParam;
-
-    PRUint32 bufferSize;
-    IPC::InputStream inputStream;
-    if (!ReadParam(aMsg, aIter, &bufferSize) ||
-        !ReadParam(aMsg, aIter, &inputStream))
-        return PR_FALSE;
-
-    nsCOMPtr<nsIInputStream> stream(inputStream);
-    nsresult rv = Init(stream, bufferSize);
-    if (NS_FAILED(rv))
-        return PR_FALSE;
-
-    return PR_TRUE;
-#else
-    return PR_FALSE;
-#endif
-}
-
-void
-nsBufferedInputStream::Write(IPC::Message *aMsg)
-{
-#ifdef MOZ_IPC
-    using IPC::WriteParam;
-
-    WriteParam(aMsg, mBufferSize);
-
-    IPC::InputStream inputStream(Source());
-    WriteParam(aMsg, inputStream);
-#endif
-}
-
 ////////////////////////////////////////////////////////////////////////////////
 // nsBufferedOutputStream
 
 NS_IMPL_ADDREF_INHERITED(nsBufferedOutputStream, nsBufferedStream)
 NS_IMPL_RELEASE_INHERITED(nsBufferedOutputStream, nsBufferedStream)
 // This QI uses NS_INTERFACE_MAP_ENTRY_CONDITIONAL to check for
 // non-nullness of mSafeStream.
 NS_INTERFACE_MAP_BEGIN(nsBufferedOutputStream)
--- a/netwerk/base/src/nsBufferedStreams.h
+++ b/netwerk/base/src/nsBufferedStreams.h
@@ -41,18 +41,16 @@
 #include "nsIBufferedStreams.h"
 #include "nsIInputStream.h"
 #include "nsIOutputStream.h"
 #include "nsISafeOutputStream.h"
 #include "nsISeekableStream.h"
 #include "nsIStreamBufferAccess.h"
 #include "nsCOMPtr.h"
 #include "nsInt64.h"
-#include "nsIIPCSerializable.h"
-
 ////////////////////////////////////////////////////////////////////////////////
 
 class nsBufferedStream : public nsISeekableStream
 {
 public:
     NS_DECL_ISUPPORTS
     NS_DECL_NSISEEKABLESTREAM
 
@@ -86,25 +84,23 @@ protected:
     PRPackedBool                mBufferDisabled;
     PRUint8                     mGetBufferCount;
 };
 
 ////////////////////////////////////////////////////////////////////////////////
 
 class nsBufferedInputStream : public nsBufferedStream,
                               public nsIBufferedInputStream,
-                              public nsIStreamBufferAccess,
-                              public nsIIPCSerializable
+                              public nsIStreamBufferAccess
 {
 public:
     NS_DECL_ISUPPORTS_INHERITED
     NS_DECL_NSIINPUTSTREAM
     NS_DECL_NSIBUFFEREDINPUTSTREAM
     NS_DECL_NSISTREAMBUFFERACCESS
-    NS_DECL_NSIIPCSERIALIZABLE
 
     nsBufferedInputStream() : nsBufferedStream() {}
     virtual ~nsBufferedInputStream() {}
 
     static nsresult
     Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
 
     nsIInputStream* Source() { 
--- a/netwerk/base/src/nsFileStreams.cpp
+++ b/netwerk/base/src/nsFileStreams.cpp
@@ -30,20 +30,16 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#ifdef MOZ_IPC
-#include "IPC/IPCMessageUtils.h"
-#endif
-
 #if defined(XP_UNIX) || defined(XP_BEOS)
 #include <unistd.h>
 #elif defined(XP_WIN)
 #include <windows.h>
 #elif defined(XP_OS2)
 #define INCL_DOSERRORS
 #include <os2.h>
 #else
@@ -58,17 +54,17 @@
 #include "prerror.h"
 #include "nsCRT.h"
 #include "nsInt64.h"
 #include "nsIFile.h"
 #include "nsDirectoryIndexStream.h"
 #include "nsMimeTypes.h"
 #include "nsReadLine.h"
 #include "nsNetUtil.h"
-#include "nsIClassInfoImpl.h"
+//#include "nsFileTransportService.h"
 
 #define NS_NO_INPUT_BUFFERING 1 // see http://bugzilla.mozilla.org/show_bug.cgi?id=41067
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsFileStream
 
 nsFileStream::nsFileStream()
     : mFD(nsnull)
@@ -172,37 +168,21 @@ nsFileStream::SetEOF()
 #endif
 
     return NS_OK;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsFileInputStream
 
-NS_IMPL_ADDREF_INHERITED(nsFileInputStream, nsFileStream)
-NS_IMPL_RELEASE_INHERITED(nsFileInputStream, nsFileStream)
-
-NS_IMPL_CLASSINFO(nsFileInputStream, NULL, nsIClassInfo::THREADSAFE,
-                  NS_LOCALFILEINPUTSTREAM_CID)
-
-NS_INTERFACE_MAP_BEGIN(nsFileInputStream)
-    NS_INTERFACE_MAP_ENTRY(nsFileStream)
-    NS_INTERFACE_MAP_ENTRY(nsIInputStream)
-    NS_INTERFACE_MAP_ENTRY(nsIFileInputStream)
-    NS_INTERFACE_MAP_ENTRY(nsILineInputStream)
-    NS_INTERFACE_MAP_ENTRY(nsIIPCSerializable)
-    NS_IMPL_QUERY_CLASSINFO(nsFileInputStream)
-NS_INTERFACE_MAP_END_INHERITING(nsFileStream)
-
-NS_IMPL_CI_INTERFACE_GETTER5(nsFileInputStream,
+NS_IMPL_ISUPPORTS_INHERITED3(nsFileInputStream,
+                             nsFileStream,
                              nsIInputStream,
                              nsIFileInputStream,
-                             nsISeekableStream,
-                             nsILineInputStream,
-                             nsIIPCSerializable)
+                             nsILineInputStream)
 
 nsresult
 nsFileInputStream::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
 {
     NS_ENSURE_NO_AGGREGATION(aOuter);
 
     nsFileInputStream* stream = new nsFileInputStream();
     if (stream == nsnull)
@@ -240,54 +220,59 @@ nsFileInputStream::Open(nsIFile* aFile, 
 
     if (mBehaviorFlags & DELETE_ON_CLOSE) {
         // POSIX compatible filesystems allow a file to be unlinked while a
         // file descriptor is still referencing the file.  since we've already
         // opened the file descriptor, we'll try to remove the file.  if that
         // fails, then we'll just remember the nsIFile and remove it after we
         // close the file descriptor.
         rv = aFile->Remove(PR_FALSE);
-        if (NS_SUCCEEDED(rv)) {
-          // No need to remove it later. Clear the flag.
-          mBehaviorFlags &= ~DELETE_ON_CLOSE;
+        if (NS_FAILED(rv) && !(mBehaviorFlags & REOPEN_ON_REWIND)) {
+            // If REOPEN_ON_REWIND is not happenin', we haven't saved the file yet
+            mFile = aFile;
         }
     }
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsFileInputStream::Init(nsIFile* aFile, PRInt32 aIOFlags, PRInt32 aPerm,
                         PRInt32 aBehaviorFlags)
 {
     NS_ENSURE_TRUE(!mFD, NS_ERROR_ALREADY_INITIALIZED);
     NS_ENSURE_TRUE(!mParent, NS_ERROR_ALREADY_INITIALIZED);
 
     mBehaviorFlags = aBehaviorFlags;
 
-    mFile = aFile;
-    mIOFlags = aIOFlags;
-    mPerm = aPerm;
+    // If the file will be reopened on rewind, save the info to open the file
+    if (mBehaviorFlags & REOPEN_ON_REWIND) {
+        mFile = aFile;
+        mIOFlags = aIOFlags;
+        mPerm = aPerm;
+    }
 
     return Open(aFile, aIOFlags, aPerm);
 }
 
 NS_IMETHODIMP
 nsFileInputStream::Close()
 {
     // null out mLineBuffer in case Close() is called again after failing
     PR_FREEIF(mLineBuffer);
     nsresult rv = nsFileStream::Close();
     if (NS_FAILED(rv)) return rv;
-
-    if (mBehaviorFlags & DELETE_ON_CLOSE) {
+    if (mFile && (mBehaviorFlags & DELETE_ON_CLOSE)) {
         rv = mFile->Remove(PR_FALSE);
         NS_ASSERTION(NS_SUCCEEDED(rv), "failed to delete file");
+        // If we don't need to save the file for reopening, free it up
+        if (!(mBehaviorFlags & REOPEN_ON_REWIND)) {
+          mFile = nsnull;
+        }
     }
-
     return rv;
 }
 
 NS_IMETHODIMP
 nsFileInputStream::Available(PRUint32* aResult)
 {
     if (!mFD) {
         return NS_BASE_STREAM_CLOSED;
@@ -373,64 +358,16 @@ nsFileInputStream::Seek(PRInt32 aWhence,
         } else {
             return NS_BASE_STREAM_CLOSED;
         }
     }
 
     return nsFileStream::Seek(aWhence, aOffset);
 }
 
-PRBool
-nsFileInputStream::Read(const IPC::Message *aMsg, void **aIter)
-{
-#ifdef MOZ_IPC
-    using IPC::ReadParam;
-
-    nsCString path;
-    PRBool followLinks;
-    PRInt32 flags;
-    if (!ReadParam(aMsg, aIter, &path) ||
-        !ReadParam(aMsg, aIter, &followLinks) ||
-        !ReadParam(aMsg, aIter, &flags))
-        return PR_FALSE;
-
-    nsCOMPtr<nsILocalFile> file;
-    nsresult rv = NS_NewNativeLocalFile(path, followLinks, getter_AddRefs(file));
-    if (NS_FAILED(rv))
-        return PR_FALSE;
-
-    // IO flags = -1 means readonly, and
-    // permissions are unimportant since we're reading
-    rv = Init(file, -1, -1, flags);
-    if (NS_FAILED(rv))
-        return PR_FALSE;
-
-    return PR_TRUE;
-#else
-    return PR_FALSE;
-#endif
-}
-
-void
-nsFileInputStream::Write(IPC::Message *aMsg)
-{
-#ifdef MOZ_IPC
-    using IPC::WriteParam;
-
-    nsCString path;
-    mFile->GetNativePath(path);
-    WriteParam(aMsg, path);
-    nsCOMPtr<nsILocalFile> localFile = do_QueryInterface(mFile);
-    PRBool followLinks;
-    localFile->GetFollowLinks(&followLinks);
-    WriteParam(aMsg, followLinks);
-    WriteParam(aMsg, mBehaviorFlags);
-#endif
-}
-
 ////////////////////////////////////////////////////////////////////////////////
 // nsPartialFileInputStream
 
 // Don't forward to nsFileInputStream as we don't want to QI to
 // nsIFileInputStream
 NS_IMPL_ISUPPORTS_INHERITED3(nsPartialFileInputStream,
                              nsFileStream,
                              nsIInputStream,
--- a/netwerk/base/src/nsFileStreams.h
+++ b/netwerk/base/src/nsFileStreams.h
@@ -43,17 +43,16 @@
 #include "nsIInputStream.h"
 #include "nsIOutputStream.h"
 #include "nsISafeOutputStream.h"
 #include "nsISeekableStream.h"
 #include "nsILineInputStream.h"
 #include "nsCOMPtr.h"
 #include "prlog.h"
 #include "prio.h"
-#include "nsIIPCSerializable.h"
 
 template<class CharType> class nsLineBuffer;
 
 ////////////////////////////////////////////////////////////////////////////////
 
 class nsFileStream : public nsISeekableStream
 {
 public:
@@ -72,25 +71,23 @@ protected:
                                    // which ensures mFD remains valid.
     PRBool                mCloseFD;
 };
 
 ////////////////////////////////////////////////////////////////////////////////
 
 class nsFileInputStream : public nsFileStream,
                           public nsIFileInputStream,
-                          public nsILineInputStream,
-                          public nsIIPCSerializable
+                          public nsILineInputStream
 {
 public:
     NS_DECL_ISUPPORTS_INHERITED
     NS_DECL_NSIINPUTSTREAM
     NS_DECL_NSIFILEINPUTSTREAM
     NS_DECL_NSILINEINPUTSTREAM
-    NS_DECL_NSIIPCSERIALIZABLE
     
     // Overrided from nsFileStream
     NS_IMETHOD Seek(PRInt32 aWhence, PRInt64 aOffset);
 
     nsFileInputStream() : nsFileStream() 
     {
         mLineBuffer = nsnull;
         mBehaviorFlags = 0;
@@ -102,25 +99,28 @@ public:
 
     static nsresult
     Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
 
 protected:
     nsLineBuffer<char> *mLineBuffer;
 
     /**
-     * The file being opened.
+     * The file being opened.  Only stored when DELETE_ON_CLOSE or
+     * REOPEN_ON_REWIND are true.
      */
     nsCOMPtr<nsIFile> mFile;
     /**
      * The IO flags passed to Init() for the file open.
+     * Only set for REOPEN_ON_REWIND.
      */
     PRInt32 mIOFlags;
     /**
      * The permissions passed to Init() for the file open.
+     * Only set for REOPEN_ON_REWIND.
      */
     PRInt32 mPerm;
     /**
      * Flags describing our behavior.  See the IDL file for possible values.
      */
     PRInt32 mBehaviorFlags;
 
 protected:
--- a/netwerk/base/src/nsMIMEInputStream.cpp
+++ b/netwerk/base/src/nsMIMEInputStream.cpp
@@ -36,45 +36,35 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 /**
  * The MIME stream separates headers and a datastream. It also allows
  * automatic creation of the content-length header.
  */
 
-#ifdef MOZ_IPC
-#include "IPC/IPCMessageUtils.h"
-#include "mozilla/net/NeckoMessageUtils.h"
-#endif
-
 #include "nsCOMPtr.h"
 #include "nsComponentManagerUtils.h"
 #include "nsIMultiplexInputStream.h"
 #include "nsIMIMEInputStream.h"
 #include "nsISeekableStream.h"
 #include "nsIStringStream.h"
 #include "nsString.h"
-#include "nsMIMEInputStream.h"
-#include "nsIIPCSerializable.h"
-#include "nsIClassInfoImpl.h"
 
 class nsMIMEInputStream : public nsIMIMEInputStream,
-                          public nsISeekableStream,
-                          public nsIIPCSerializable
+                          public nsISeekableStream
 {
 public:
     nsMIMEInputStream();
     virtual ~nsMIMEInputStream();
 
     NS_DECL_ISUPPORTS
     NS_DECL_NSIINPUTSTREAM
     NS_DECL_NSIMIMEINPUTSTREAM
     NS_DECL_NSISEEKABLESTREAM
-    NS_DECL_NSIIPCSERIALIZABLE
     
     NS_METHOD Init();
 
 private:
 
     void InitStreams();
 
     struct ReadSegmentsState {
@@ -93,32 +83,20 @@ private:
     nsCOMPtr<nsIStringInputStream> mCLStream;
     
     nsCOMPtr<nsIInputStream> mData;
     nsCOMPtr<nsIMultiplexInputStream> mStream;
     PRPackedBool mAddContentLength;
     PRPackedBool mStartedReading;
 };
 
-NS_IMPL_THREADSAFE_ADDREF(nsMIMEInputStream)
-NS_IMPL_THREADSAFE_RELEASE(nsMIMEInputStream)
-
-NS_IMPL_CLASSINFO(nsMIMEInputStream, NULL, nsIClassInfo::THREADSAFE,
-                  NS_MIMEINPUTSTREAM_CID)
-
-NS_IMPL_QUERY_INTERFACE4_CI(nsMIMEInputStream,
-                            nsIMIMEInputStream,
-                            nsIInputStream,
-                            nsISeekableStream,
-                            nsIIPCSerializable)
-NS_IMPL_CI_INTERFACE_GETTER4(nsMIMEInputStream,
-                             nsIMIMEInputStream,
-                             nsIInputStream,
-                             nsISeekableStream,
-                             nsIIPCSerializable)
+NS_IMPL_THREADSAFE_ISUPPORTS3(nsMIMEInputStream,
+                              nsIMIMEInputStream,
+                              nsIInputStream,
+                              nsISeekableStream)
 
 nsMIMEInputStream::nsMIMEInputStream() : mAddContentLength(PR_FALSE),
                                          mStartedReading(PR_FALSE)
 {
 }
 
 nsMIMEInputStream::~nsMIMEInputStream()
 {
@@ -322,63 +300,8 @@ nsMIMEInputStreamConstructor(nsISupports
         return rv;
     }
 
     rv = inst->QueryInterface(iid, result);
     NS_RELEASE(inst);
 
     return rv;
 }
-
-PRBool
-nsMIMEInputStream::Read(const IPC::Message *aMsg, void **aIter)
-{
-#ifdef MOZ_IPC
-    using IPC::ReadParam;
-
-    if (!ReadParam(aMsg, aIter, &mHeaders) ||
-        !ReadParam(aMsg, aIter, &mContentLength) ||
-        !ReadParam(aMsg, aIter, &mStartedReading))
-        return PR_FALSE;
-
-    // nsMIMEInputStream::Init() already appended mHeaderStream & mCLStream
-    mHeaderStream->ShareData(mHeaders.get(),
-                             mStartedReading? mHeaders.Length() : 0);
-    mCLStream->ShareData(mContentLength.get(),
-                         mStartedReading? mContentLength.Length() : 0);
-
-    IPC::InputStream inputStream;
-    if (!ReadParam(aMsg, aIter, &inputStream))
-        return PR_FALSE;
-
-    nsCOMPtr<nsIInputStream> stream(inputStream);
-    mData = stream;
-    if (stream) {
-        nsresult rv = mStream->AppendStream(mData);
-        if (NS_FAILED(rv))
-            return PR_FALSE;
-    }
-
-    if (!ReadParam(aMsg, aIter, &mAddContentLength))
-        return PR_FALSE;
-
-    return PR_TRUE;
-#else
-    return PR_FALSE;
-#endif
-}
-
-void
-nsMIMEInputStream::Write(IPC::Message *aMsg)
-{
-#ifdef MOZ_IPC
-    using IPC::WriteParam;
-
-    WriteParam(aMsg, mHeaders);
-    WriteParam(aMsg, mContentLength);
-    WriteParam(aMsg, mStartedReading);
-
-    IPC::InputStream inputStream(mData);
-    WriteParam(aMsg, inputStream);
-
-    WriteParam(aMsg, mAddContentLength);
-#endif
-}
--- a/netwerk/ipc/NeckoChild.cpp
+++ b/netwerk/ipc/NeckoChild.cpp
@@ -40,17 +40,16 @@
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsHttp.h"
 #include "mozilla/net/NeckoChild.h"
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/net/HttpChannelChild.h"
 #include "mozilla/net/CookieServiceChild.h"
 #include "mozilla/net/WyciwygChannelChild.h"
-#include "mozilla/net/FTPChannelChild.h"
 
 namespace mozilla {
 namespace net {
 
 PNeckoChild *gNeckoChild = nsnull;
 
 // C++ file contents
 NeckoChild::NeckoChild()
@@ -108,34 +107,16 @@ NeckoChild::DeallocPHttpChannel(PHttpCha
 {
   NS_ABORT_IF_FALSE(IsNeckoChild(), "DeallocPHttpChannel called by non-child!");
 
   HttpChannelChild* child = static_cast<HttpChannelChild*>(channel);
   child->ReleaseIPDLReference();
   return true;
 }
 
-PFTPChannelChild*
-NeckoChild::AllocPFTPChannel()
-{
-  // We don't allocate here: see FTPChannelChild::AsyncOpen()
-  NS_RUNTIMEABORT("AllocPFTPChannel should not be called");
-  return nsnull;
-}
-
-bool
-NeckoChild::DeallocPFTPChannel(PFTPChannelChild* channel)
-{
-  NS_ABORT_IF_FALSE(IsNeckoChild(), "DeallocPFTPChannel called by non-child!");
-
-  FTPChannelChild* child = static_cast<FTPChannelChild*>(channel);
-  child->ReleaseIPDLReference();
-  return true;
-}
-
 PCookieServiceChild* 
 NeckoChild::AllocPCookieService()
 {
   // We don't allocate here: see nsCookieService::GetSingleton()
   NS_NOTREACHED("AllocPCookieService should not be called");
   return nsnull;
 }
 
--- a/netwerk/ipc/NeckoChild.h
+++ b/netwerk/ipc/NeckoChild.h
@@ -60,18 +60,16 @@ public:
 
 protected:
   virtual PHttpChannelChild* AllocPHttpChannel(PBrowserChild* iframeEmbedding);
   virtual bool DeallocPHttpChannel(PHttpChannelChild*);
   virtual PCookieServiceChild* AllocPCookieService();
   virtual bool DeallocPCookieService(PCookieServiceChild*);
   virtual PWyciwygChannelChild* AllocPWyciwygChannel();
   virtual bool DeallocPWyciwygChannel(PWyciwygChannelChild*);
-  virtual PFTPChannelChild* AllocPFTPChannel();
-  virtual bool DeallocPFTPChannel(PFTPChannelChild*);
 };
 
 /**
  * Reference to the PNecko Child protocol.
  * Null if this is not a content process.
  */
 extern PNeckoChild *gNeckoChild;
 
--- a/netwerk/ipc/NeckoCommon.h
+++ b/netwerk/ipc/NeckoCommon.h
@@ -68,30 +68,22 @@
       msg.Append(" (set NECKO_ERRORS_ARE_FATAL=1 in your environment to "      \
                       "convert this warning into a fatal error.)");            \
       NS_WARNING(msg.get());                                                   \
     }                                                                          \
   } while (0)
 
 #define DROP_DEAD()                                                            \
   do {                                                                         \
-    nsPrintfCString msg(1000,"NECKO ERROR: '%s' UNIMPLEMENTED",                \
+    nsPrintfCString msg(1000,"FATAL NECKO ERROR: '%s' UNIMPLEMENTED",          \
                         __FUNCTION__);                                         \
     NECKO_MAYBE_ABORT(msg);                                                    \
     return NS_ERROR_NOT_IMPLEMENTED;                                           \
   } while (0)
 
-#define ENSURE_CALLED_BEFORE_ASYNC_OPEN()                                      \
-  if (mIsPending || mWasOpened) {                                              \
-    nsPrintfCString msg(1000, "'%s' called after AsyncOpen: %s +%d",           \
-                        __FUNCTION__, __FILE__, __LINE__);                     \
-    NECKO_MAYBE_ABORT(msg);                                                    \
-  }                                                                            \
-  NS_ENSURE_TRUE(!mIsPending, NS_ERROR_IN_PROGRESS);                           \
-  NS_ENSURE_TRUE(!mWasOpened, NS_ERROR_ALREADY_OPENED);
 
 namespace mozilla {
 namespace net {
 
 inline bool 
 IsNeckoChild() 
 {
   static bool didCheck = false;
--- a/netwerk/ipc/NeckoMessageUtils.h
+++ b/netwerk/ipc/NeckoMessageUtils.h
@@ -41,17 +41,16 @@
 
 #include "IPC/IPCMessageUtils.h"
 #include "nsStringGlue.h"
 #include "nsIURI.h"
 #include "nsIIPCSerializable.h"
 #include "nsIClassInfo.h"
 #include "nsComponentManagerUtils.h"
 #include "nsNetUtil.h"
-#include "nsStringStream.h"
 
 namespace IPC {
 
 // Since IPDL doesn't have any knowledge of pointers, there's no easy way to
 // pass around nsIURI pointers.  This is a very thin wrapper that IPDL can
 // easily work with, allowing for conversion to and from an nsIURI pointer.
 
 class URI {
@@ -170,119 +169,16 @@ struct ParamTraits<URI>
       aLog->append(StringPrintf(L"[%s]", spec.get()));
     }
     else {
       aLog->append(L"[]");
     }
   }
 };
 
-class InputStream {
- public:
-  InputStream() : mStream(nsnull) {}
-  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<nsIIPCSerializable> serializable = do_QueryInterface(aParam.mStream);
-    bool isSerializable = !!serializable;
-    WriteParam(aMsg, isSerializable);
-
-    if (!serializable) {
-      NS_WARNING("nsIInputStream implementation doesn't support nsIIPCSerializable; falling back to copying data");
-
-      nsCString streamString;
-      PRUint32 bytes;
-
-      aParam.mStream->Available(&bytes);
-      if (bytes > 0) {
-        nsresult rv = NS_ReadInputStreamToString(aParam.mStream, streamString, 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);
-    char cidStr[NSID_LENGTH];
-    nsCID cid;
-    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 = nsnull;
-      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<nsIIPCSerializable> serializable = do_QueryInterface(stream);
-      if (!serializable || !serializable->Read(aMsg, aIter))
-        return false;
-    }
-
-    stream.swap(aResult->mStream);
-    return true;
-  }
-};
-
 // nsIPermissionManager utilities
 
 struct Permission
 {
   nsCString host, type;
   PRUint32 capability, expireType;
   PRInt64 expireTime;
 
--- a/netwerk/ipc/NeckoParent.cpp
+++ b/netwerk/ipc/NeckoParent.cpp
@@ -38,17 +38,16 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsHttp.h"
 #include "mozilla/net/NeckoParent.h"
 #include "mozilla/net/HttpChannelParent.h"
 #include "mozilla/net/CookieServiceParent.h"
 #include "mozilla/net/WyciwygChannelParent.h"
-#include "mozilla/net/FTPChannelParent.h"
 
 #include "nsHTMLDNSPrefetch.h"
 
 namespace mozilla {
 namespace net {
 
 // C++ file contents
 NeckoParent::NeckoParent()
@@ -70,32 +69,16 @@ NeckoParent::AllocPHttpChannel(PBrowserP
 bool 
 NeckoParent::DeallocPHttpChannel(PHttpChannelParent* channel)
 {
   HttpChannelParent *p = static_cast<HttpChannelParent *>(channel);
   p->Release();
   return true;
 }
 
-PFTPChannelParent*
-NeckoParent::AllocPFTPChannel()
-{
-  FTPChannelParent *p = new FTPChannelParent();
-  p->AddRef();
-  return p;
-}
-
-bool
-NeckoParent::DeallocPFTPChannel(PFTPChannelParent* channel)
-{
-  FTPChannelParent *p = static_cast<FTPChannelParent *>(channel);
-  p->Release();
-  return true;
-}
-
 PCookieServiceParent* 
 NeckoParent::AllocPCookieService()
 {
   return new CookieServiceParent();
 }
 
 bool 
 NeckoParent::DeallocPCookieService(PCookieServiceParent* cs)
--- a/netwerk/ipc/NeckoParent.h
+++ b/netwerk/ipc/NeckoParent.h
@@ -57,18 +57,16 @@ public:
 
 protected:
   virtual PHttpChannelParent* AllocPHttpChannel(PBrowserParent* browser);
   virtual bool DeallocPHttpChannel(PHttpChannelParent*);
   virtual PCookieServiceParent* AllocPCookieService();
   virtual bool DeallocPCookieService(PCookieServiceParent*);
   virtual PWyciwygChannelParent* AllocPWyciwygChannel();
   virtual bool DeallocPWyciwygChannel(PWyciwygChannelParent*);
-  virtual PFTPChannelParent* AllocPFTPChannel();
-  virtual bool DeallocPFTPChannel(PFTPChannelParent*);
   virtual bool RecvHTMLDNSPrefetch(const nsString& hostname,
                                    const PRUint16& flags);
 };
 
 } // namespace net
 } // namespace mozilla
 
 #endif // mozilla_net_NeckoParent_h
--- a/netwerk/ipc/PNecko.ipdl
+++ b/netwerk/ipc/PNecko.ipdl
@@ -38,37 +38,34 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 include protocol PContent;
 include protocol PHttpChannel;
 include protocol PCookieService;
 include protocol PBrowser;
 include protocol PWyciwygChannel;
-include protocol PFTPChannel;
 
 namespace mozilla {
 namespace net {
 
 
 //-------------------------------------------------------------------
 sync protocol PNecko
 {
   manager PContent;
   manages PHttpChannel;
   manages PCookieService;
   manages PWyciwygChannel;
-  manages PFTPChannel;
 
 parent:
   __delete__();
 
   PCookieService();
   PWyciwygChannel();
-  PFTPChannel();
 
   HTMLDNSPrefetch(nsString hostname, PRUint16 flags);
 
 both:
   PHttpChannel(nullable PBrowser browser);
 };
 
 
--- a/netwerk/protocol/ftp/Makefile.in
+++ b/netwerk/protocol/ftp/Makefile.in
@@ -51,53 +51,35 @@ GRE_MODULE     = 1
 FORCE_STATIC_LIB = 1
 
 EXPORTS = ftpCore.h
 
 XPIDLSRCS = \
   nsIFTPChannel.idl \
   $(NULL)
 
-ifdef MOZ_IPC
-EXPORTS_NAMESPACES = mozilla/net
-
-EXPORTS_mozilla/net += \
-  FTPChannelParent.h \
-  FTPChannelChild.h  \
-  $(NULL)
-endif
-
 CPPSRCS = \
   nsFtpProtocolHandler.cpp \
   nsFTPChannel.cpp \
   nsFtpConnectionThread.cpp \
   nsFtpControlConnection.cpp \
   $(NULL)
 
-ifdef MOZ_IPC
-CPPSRCS += \
-  FTPChannelParent.cpp \
-  FTPChannelChild.cpp \
-  $(NULL)
-endif
-
 # Use -g for Irix mipspro builds as workaround for bug 92099
 ifneq (,$(filter IRIX IRIX64,$(OS_ARCH)))
 ifndef GNU_CC
 MODULE_OPTIMIZE_FLAGS=-O -g
 endif
 endif
 
 LOCAL_INCLUDES = \
   -I$(srcdir)/../../base/src \
   -I$(topsrcdir)/xpcom/ds \
   $(NULL)
 
-include $(topsrcdir)/config/config.mk
-include $(topsrcdir)/ipc/chromium/chromium-config.mk
 include $(topsrcdir)/config/rules.mk
 
 ifeq ($(OS_ARCH),WINNT)
 ifndef MOZ_DEBUG
 ifndef NO_LOGGING
 DEFINES += -DFORCE_PR_LOG
 endif
 endif
--- a/netwerk/protocol/ftp/nsFTPChannel.h
+++ b/netwerk/protocol/ftp/nsFTPChannel.h
@@ -57,17 +57,16 @@
 #include "nsIStreamListener.h"
 #include "nsAutoLock.h"
 #include "nsIFTPChannel.h"
 #include "nsIUploadChannel.h"
 #include "nsIProxyInfo.h"
 #include "nsIProxiedChannel.h"
 #include "nsIResumableChannel.h"
 #include "nsHashPropertyBag.h"
-#include "nsFtpProtocolHandler.h"
 
 class nsFtpChannel : public nsBaseChannel,
                      public nsIFTPChannel,
                      public nsIUploadChannel,
                      public nsIResumableChannel,
                      public nsIProxiedChannel
 {
 public:
--- a/netwerk/protocol/ftp/nsFtpProtocolHandler.cpp
+++ b/netwerk/protocol/ftp/nsFtpProtocolHandler.cpp
@@ -44,22 +44,16 @@
  * Modifications to Mozilla code or documentation
  * identified per MPL Section 3.3
  *
  * Date         Modified by     Description of modification
  * 03/27/2000   IBM Corp.       Added PR_CALLBACK for Optlink
  *                               use in OS2
  */
 
-#ifdef MOZ_IPC
-#include "mozilla/net/NeckoChild.h"
-#include "mozilla/net/FTPChannelChild.h"
-using namespace mozilla::net;
-#endif
-
 #include "nsFtpProtocolHandler.h"
 #include "nsFTPChannel.h"
 #include "nsIURL.h"
 #include "nsIStandardURL.h"
 #include "nsCRT.h"
 #include "nsIComponentManager.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIInterfaceRequestorUtils.h"
@@ -82,17 +76,16 @@ using namespace mozilla::net;
 //    set NSPR_LOG_MODULES=nsFtp:5
 //    set NSPR_LOG_FILE=nspr.log
 //
 // this enables PR_LOG_DEBUG level information and places all output in
 // the file nspr.log
 //
 PRLogModuleInfo* gFTPLog = nsnull;
 #endif
-#undef LOG
 #define LOG(args) PR_LOG(gFTPLog, PR_LOG_DEBUG, args)
 
 //-----------------------------------------------------------------------------
 
 #define IDLE_TIMEOUT_PREF     "network.ftp.idleConnectionTimeout"
 #define IDLE_CONNECTION_LIMIT 8 /* TODO pref me */
 
 #define QOS_DATA_PREF         "network.ftp.data.qos"
@@ -130,21 +123,16 @@ NS_IMPL_THREADSAFE_ISUPPORTS4(nsFtpProto
                               nsIProtocolHandler,
                               nsIProxiedProtocolHandler,
                               nsIObserver,
                               nsISupportsWeakReference)
 
 nsresult
 nsFtpProtocolHandler::Init()
 {
-#ifdef MOZ_IPC
-    if (IsNeckoChild())
-        NeckoChild::InitNeckoChild();
-#endif // MOZ_IPC
-
     if (mIdleTimeout == -1) {
         nsresult rv;
         nsCOMPtr<nsIPrefBranch2> branch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
         if (NS_FAILED(rv)) return rv;
 
         rv = branch->GetIntPref(IDLE_TIMEOUT_PREF, &mIdleTimeout);
         if (NS_FAILED(rv))
             mIdleTimeout = 5*60; // 5 minute default
@@ -248,30 +236,28 @@ nsFtpProtocolHandler::NewChannel(nsIURI*
     return NewProxiedChannel(url, nsnull, result);
 }
 
 NS_IMETHODIMP
 nsFtpProtocolHandler::NewProxiedChannel(nsIURI* uri, nsIProxyInfo* proxyInfo,
                                         nsIChannel* *result)
 {
     NS_ENSURE_ARG_POINTER(uri);
-    nsRefPtr<nsBaseChannel> channel;
-#ifdef MOZ_IPC
-    if (IsNeckoChild())
-        channel = new FTPChannelChild(uri);
-    else
-#endif
-        channel = new nsFtpChannel(uri, proxyInfo);
+    nsFtpChannel *channel = new nsFtpChannel(uri, proxyInfo);
+    if (!channel)
+        return NS_ERROR_OUT_OF_MEMORY;
+    NS_ADDREF(channel);
 
     nsresult rv = channel->Init();
     if (NS_FAILED(rv)) {
+        NS_RELEASE(channel);
         return rv;
     }
     
-    channel.forget(result);
+    *result = channel;
     return rv;
 }
 
 NS_IMETHODIMP 
 nsFtpProtocolHandler::AllowPort(PRInt32 port, const char *scheme, PRBool *_retval)
 {
     *_retval = (port == 21 || port == 22);
     return NS_OK;
--- a/netwerk/protocol/ftp/nsFtpProtocolHandler.h
+++ b/netwerk/protocol/ftp/nsFtpProtocolHandler.h
@@ -118,13 +118,9 @@ private:
     PRUint8 mControlQoSBits;
     PRUint8 mDataQoSBits;
 };
 
 //-----------------------------------------------------------------------------
 
 extern nsFtpProtocolHandler *gFtpHandler;
 
-#ifdef PR_LOGGING
-extern PRLogModuleInfo* gFTPLog;
-#endif
-
 #endif // !nsFtpProtocolHandler_h__
--- a/netwerk/protocol/http/HttpBaseChannel.h
+++ b/netwerk/protocol/http/HttpBaseChannel.h
@@ -55,19 +55,41 @@
 #include "nsIUploadChannel2.h"
 #include "nsIProgressEventSink.h"
 #include "nsIURI.h"
 #include "nsIStringEnumerator.h"
 #include "nsISupportsPriority.h"
 #include "nsIApplicationCache.h"
 #include "nsIResumableChannel.h"
 
+#define DIE_WITH_ASYNC_OPEN_MSG()                                              \
+  do {                                                                         \
+    fprintf(stderr,                                                            \
+            "*&*&*&*&*&*&*&**&*&&*& FATAL ERROR: '%s' "                        \
+            "called after AsyncOpen: %s +%d",                                  \
+            __FUNCTION__, __FILE__, __LINE__);                                 \
+    NS_ABORT();                                                                \
+    return NS_ERROR_NOT_IMPLEMENTED;                                           \
+  } while (0)
+
+#define ENSURE_CALLED_BEFORE_ASYNC_OPEN()                                      \
+  if (mIsPending)                                                              \
+    DIE_WITH_ASYNC_OPEN_MSG();                                                 \
+  if (mWasOpened)                                                              \
+    DIE_WITH_ASYNC_OPEN_MSG();                                                 \
+  NS_ENSURE_TRUE(!mIsPending, NS_ERROR_IN_PROGRESS);                           \
+  NS_ENSURE_TRUE(!mWasOpened, NS_ERROR_ALREADY_OPENED);
+
 namespace mozilla {
 namespace net {
 
+typedef enum { eUploadStream_null = -1,
+               eUploadStream_hasNoHeaders = 0,
+               eUploadStream_hasHeaders = 1 } UploadStreamInfoType;
+
 /*
  * This class is a partial implementation of nsIHttpChannel.  It contains code
  * shared by nsHttpChannel and HttpChannelChild. 
  * - Note that this class has nothing to do with nsBaseChannel, which is an
  *   earlier effort at a base class for channels that somehow never made it all
  *   the way to the HTTP channel.
  */
 class HttpBaseChannel : public nsHashPropertyBag
--- a/netwerk/protocol/http/HttpChannelChild.cpp
+++ b/netwerk/protocol/http/HttpChannelChild.cpp
@@ -815,16 +815,39 @@ HttpChannelChild::AsyncOpen(nsIStreamLis
 
   // Port checked in parent, but duplicate here so we can return with error
   // immediately
   nsresult rv;
   rv = NS_CheckPortSafety(mURI);
   if (NS_FAILED(rv))
     return rv;
 
+  // Prepare uploadStream for POST data
+  nsCAutoString uploadStreamData;
+  PRInt32 uploadStreamInfo;
+
+  if (mUploadStream) {
+    // Read entire POST stream into string:
+    // This is a temporary measure until bug 564553 is implemented:  we're doing
+    // a blocking read of a potentially arbitrarily large stream, so this isn't
+    // performant/safe for large file uploads.
+    PRUint32 bytes;
+    mUploadStream->Available(&bytes);
+    if (bytes > 0) {
+      rv = NS_ReadInputStreamToString(mUploadStream, uploadStreamData, bytes);
+      if (NS_FAILED(rv))
+        return rv;
+    }
+
+    uploadStreamInfo = mUploadStreamHasHeaders ? 
+      eUploadStream_hasHeaders : eUploadStream_hasNoHeaders;
+  } else {
+    uploadStreamInfo = eUploadStream_null;
+  }
+
   const char *cookieHeader = mRequestHead.PeekHeader(nsHttp::Cookie);
   if (cookieHeader) {
     mUserSetCookieHeader = cookieHeader;
   }
 
   AddCookiesToRequest();
 
   //
@@ -871,20 +894,19 @@ HttpChannelChild::AsyncOpen(nsIStreamLis
   // The socket transport in the chrome process now holds a logical ref to us
   // until OnStopRequest, or we do a redirect, or we hit an IPDL error.
   AddIPDLReference();
 
   gNeckoChild->SendPHttpChannelConstructor(this, tabChild);
 
   SendAsyncOpen(IPC::URI(mURI), IPC::URI(mOriginalURI),
                 IPC::URI(mDocumentURI), IPC::URI(mReferrer), mLoadFlags,
-                mRequestHeaders, mRequestHead.Method(),
-                IPC::InputStream(mUploadStream), mUploadStreamHasHeaders,
-                mPriority, mRedirectionLimit, mAllowPipelining,
-                mForceAllowThirdPartyCookie, mSendResumeAt,
+                mRequestHeaders, mRequestHead.Method(), uploadStreamData,
+                uploadStreamInfo, mPriority, mRedirectionLimit,
+                mAllowPipelining, mForceAllowThirdPartyCookie, mSendResumeAt,
                 mStartPos, mEntityID);
 
   return NS_OK;
 }
 
 //-----------------------------------------------------------------------------
 // HttpChannelChild::nsIHttpChannel
 //-----------------------------------------------------------------------------
--- a/netwerk/protocol/http/HttpChannelParent.cpp
+++ b/netwerk/protocol/http/HttpChannelParent.cpp
@@ -97,18 +97,18 @@ NS_IMPL_ISUPPORTS1(HttpChannelParent,
 bool 
 HttpChannelParent::RecvAsyncOpen(const IPC::URI&            aURI,
                                  const IPC::URI&            aOriginalURI,
                                  const IPC::URI&            aDocURI,
                                  const IPC::URI&            aReferrerURI,
                                  const PRUint32&            loadFlags,
                                  const RequestHeaderTuples& requestHeaders,
                                  const nsHttpAtom&          requestMethod,
-                                 const IPC::InputStream&    uploadStream,
-                                 const PRBool&              uploadStreamHasHeaders,
+                                 const nsCString&           uploadStreamData,
+                                 const PRInt32&             uploadStreamInfo,
                                  const PRUint16&            priority,
                                  const PRUint8&             redirectionLimit,
                                  const PRBool&              allowPipelining,
                                  const PRBool&              forceAllowThirdPartyCookie,
                                  const bool&                doResumeAt,
                                  const PRUint64&            startPos,
                                  const nsCString&           entityID)
 {
@@ -153,20 +153,26 @@ HttpChannelParent::RecvAsyncOpen(const I
   }
 
   mChannelListener = new HttpChannelParentListener(this);
 
   httpChan->SetNotificationCallbacks(mChannelListener);
 
   httpChan->SetRequestMethod(nsDependentCString(requestMethod.get()));
 
-  nsCOMPtr<nsIInputStream> stream(uploadStream);
-  if (stream) {
+  if (uploadStreamInfo != eUploadStream_null) {
+    nsCOMPtr<nsIInputStream> stream;
+    rv = NS_NewPostDataStream(getter_AddRefs(stream), false, uploadStreamData, 0);
+    if (NS_FAILED(rv))
+      return SendCancelEarly(rv);
+
     httpChan->InternalSetUploadStream(stream);
-    httpChan->SetUploadStreamHasHeaders(uploadStreamHasHeaders);
+    // We're casting uploadStreamInfo into PRBool here on purpose because
+    // we know possible values are either 0 or 1. See uploadStreamInfoType.
+    httpChan->SetUploadStreamHasHeaders((PRBool) uploadStreamInfo);
   }
 
   if (priority != nsISupportsPriority::PRIORITY_NORMAL)
     httpChan->SetPriority(priority);
   httpChan->SetRedirectionLimit(redirectionLimit);
   httpChan->SetAllowPipelining(allowPipelining);
   httpChan->SetForceAllowThirdPartyCookie(forceAllowThirdPartyCookie);
 
--- a/netwerk/protocol/http/HttpChannelParent.h
+++ b/netwerk/protocol/http/HttpChannelParent.h
@@ -83,18 +83,18 @@ public:
 protected:
   virtual bool RecvAsyncOpen(const IPC::URI&            uri,
                              const IPC::URI&            originalUri,
                              const IPC::URI&            docUri,
                              const IPC::URI&            referrerUri,
                              const PRUint32&            loadFlags,
                              const RequestHeaderTuples& requestHeaders,
                              const nsHttpAtom&          requestMethod,
-                             const IPC::InputStream&    uploadStream,
-                             const PRBool&              uploadStreamHasHeaders,
+                             const nsCString&           uploadStreamData,
+                             const PRInt32&             uploadStreamInfo,
                              const PRUint16&            priority,
                              const PRUint8&             redirectionLimit,
                              const PRBool&              allowPipelining,
                              const PRBool&              forceAllowThirdPartyCookie,
                              const bool&                doResumeAt,
                              const PRUint64&            startPos,
                              const nsCString&           entityID);
 
--- a/netwerk/protocol/http/PHttpChannel.ipdl
+++ b/netwerk/protocol/http/PHttpChannel.ipdl
@@ -43,17 +43,16 @@ include protocol PNecko;
 
 include "mozilla/net/PHttpChannelParams.h";
 include "mozilla/net/NeckoMessageUtils.h";
 
 using RequestHeaderTuples;
 using nsHttpResponseHead;
 using nsHttpAtom;
 using IPC::URI;
-using IPC::InputStream;
 
 namespace mozilla {
 namespace net {
 
 //-------------------------------------------------------------------
 protocol PHttpChannel
 {
   manager PNecko;
@@ -64,18 +63,18 @@ parent:
             // set originalURI != uri (about:credits?); also not clear if
             // chrome channel would ever need to know.  Get rid of next arg?
             URI                 original,
             URI                 doc,
             URI                 referrer,
             PRUint32            loadFlags,
             RequestHeaderTuples requestHeaders,
             nsHttpAtom          requestMethod,
-            InputStream         uploadStream,
-            PRBool              uploadStreamHasHeaders,
+            nsCString           uploadStreamData,
+            PRInt32             uploadStreamInfo,
             PRUint16            priority,
             PRUint8             redirectionLimit,
             PRBool              allowPipelining,
             PRBool              forceAllowThirdPartyCookie,
             bool                resumeAt,
             PRUint64            startPos,
             nsCString           entityID);
 
--- a/netwerk/protocol/http/PHttpChannelParams.h
+++ b/netwerk/protocol/http/PHttpChannelParams.h
@@ -44,19 +44,18 @@
 #define ALLOW_LATE_NSHTTP_H_INCLUDE 1
 #include "base/basictypes.h"
 
 #include "IPC/IPCMessageUtils.h"
 #include "nsHttp.h"
 #include "nsHttpHeaderArray.h"
 #include "nsHttpResponseHead.h"
 
-#include "nsIIPCSerializable.h"
-#include "nsIClassInfo.h"
-#include "nsNetUtil.h"
+#include "nsIStringStream.h"
+#include "nsISupportsPrimitives.h"
 
 namespace mozilla {
 namespace net {
 
 struct RequestHeaderTuple {
   nsCString mHeader;
   nsCString mValue;
   PRBool    mMerge;
@@ -191,11 +190,61 @@ struct ParamTraits<nsHttpResponseHead>
         !ReadParam(aMsg, aIter, &(aResult->mCacheControlNoCache)) ||
         !ReadParam(aMsg, aIter, &(aResult->mPragmaNoCache)))
       return false;
 
     return true;
   }
 };
 
+template<>
+struct ParamTraits<nsIStringInputStream*>
+{
+  typedef nsIStringInputStream* paramType;
+
+  static void Write(Message* aMsg, const paramType& aParam)
+  {
+    nsCAutoString value;
+    nsCOMPtr<nsISupportsCString> cstr(do_QueryInterface(aParam));
+
+    if (cstr) {
+      cstr->GetData(value);
+    } else {
+      PRUint32 length;
+      aParam->Available(&length);
+      value.SetLength(length);
+      NS_ASSERTION(value.Length() == length, "SetLength failed");
+      char *c = value.BeginWriting();
+      PRUint32 bytesRead;
+#ifdef DEBUG
+      nsresult rv = 
+#endif
+      aParam->Read(c, length, &bytesRead);
+      NS_ASSERTION(NS_SUCCEEDED(rv) && bytesRead == length, "Read failed");
+    }
+
+    WriteParam(aMsg, value);
+  }
+
+  static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
+  {
+    nsCAutoString value;
+    if (!ReadParam(aMsg, aIter, &value))
+      return false;
+
+    nsresult rv;
+
+    nsCOMPtr<nsIStringInputStream> stream
+      (do_CreateInstance("@mozilla.org/io/string-input-stream;1", &rv));
+    if (NS_FAILED(rv))
+      return false;
+
+    rv = stream->SetData(value.get(), value.Length());
+    if (NS_FAILED(rv))
+      return false;
+
+    stream.forget(aResult);
+    return true;
+  }
+};
 } // namespace IPC
 
 #endif // mozilla_net_PHttpChannelParams_h
--- a/xpcom/io/Makefile.in
+++ b/xpcom/io/Makefile.in
@@ -182,27 +182,26 @@ EXPORTS		:= $(addprefix $(srcdir)/, $(EX
 
 # we don't want the shared lib, but we want to force the creation of a static lib.
 FORCE_STATIC_LIB = 1
 
 # Force use of PIC
 FORCE_USE_PIC	= 1
 
 include $(topsrcdir)/config/rules.mk
-include $(topsrcdir)/ipc/chromium/chromium-config.mk
 
 DEFINES		+= -D_IMPL_NS_COM
 
 ifeq ($(OS_ARCH),Linux)
 ifneq (,$(findstring lib64,$(libdir)))
 DEFINES     += -DHAVE_USR_LIB64_DIR
 endif
 endif
 
-LOCAL_INCLUDES	+= -I..
+LOCAL_INCLUDES	= -I..
 
 ifeq ($(MOZ_PLATFORM_MAEMO),5)
 CFLAGS          += $(MOZ_DBUS_CFLAGS)
 CXXFLAGS        += $(MOZ_DBUS_CFLAGS)
 endif
 
 ifdef MOZ_PLATFORM_MAEMO
 CFLAGS          += $(MOZ_PLATFORM_MAEMO_CFLAGS)
--- a/xpcom/io/nsMultiplexInputStream.cpp
+++ b/xpcom/io/nsMultiplexInputStream.cpp
@@ -36,42 +36,33 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 /**
  * The multiplex stream concatenates a list of input streams into a single
  * stream.
  */
 
-#ifdef MOZ_IPC
-#include "IPC/IPCMessageUtils.h"
-#include "mozilla/net/NeckoMessageUtils.h"
-#endif
-
 #include "nsMultiplexInputStream.h"
 #include "nsIMultiplexInputStream.h"
 #include "nsISeekableStream.h"
 #include "nsCOMPtr.h"
 #include "nsCOMArray.h"
 #include "nsInt64.h"
-#include "nsIIPCSerializable.h"
-#include "nsIClassInfoImpl.h"
 
 class nsMultiplexInputStream : public nsIMultiplexInputStream,
-                               public nsISeekableStream,
-                               public nsIIPCSerializable
+                               public nsISeekableStream
 {
 public:
     nsMultiplexInputStream();
 
     NS_DECL_ISUPPORTS
     NS_DECL_NSIINPUTSTREAM
     NS_DECL_NSIMULTIPLEXINPUTSTREAM
     NS_DECL_NSISEEKABLESTREAM
-    NS_DECL_NSIIPCSERIALIZABLE
 
 private:
     ~nsMultiplexInputStream() {}
 
     struct ReadSegmentsState {
         nsIInputStream* mThisStream;
         PRUint32 mOffset;
         nsWriteSegmentFun mWriter;
@@ -84,32 +75,21 @@ private:
                                PRUint32 aCount, PRUint32 *aWriteCount);
     
     nsCOMArray<nsIInputStream> mStreams;
     PRUint32 mCurrentStream;
     PRBool mStartedReadingCurrent;
     nsresult mStatus;
 };
 
-NS_IMPL_THREADSAFE_ADDREF(nsMultiplexInputStream)
-NS_IMPL_THREADSAFE_RELEASE(nsMultiplexInputStream)
 
-NS_IMPL_CLASSINFO(nsMultiplexInputStream, NULL, nsIClassInfo::THREADSAFE,
-                  NS_MULTIPLEXINPUTSTREAM_CID)
-
-NS_IMPL_QUERY_INTERFACE4_CI(nsMultiplexInputStream,
-                            nsIMultiplexInputStream,
-                            nsIInputStream,
-                            nsISeekableStream,
-                            nsIIPCSerializable)
-NS_IMPL_CI_INTERFACE_GETTER4(nsMultiplexInputStream,
-                             nsIMultiplexInputStream,
-                             nsIInputStream,
-                             nsISeekableStream,
-                             nsIIPCSerializable)
+NS_IMPL_THREADSAFE_ISUPPORTS3(nsMultiplexInputStream,
+                              nsIMultiplexInputStream,
+                              nsIInputStream,
+                              nsISeekableStream)
 
 nsMultiplexInputStream::nsMultiplexInputStream()
     : mCurrentStream(0),
       mStartedReadingCurrent(PR_FALSE),
       mStatus(NS_OK)
 {
 }
 
@@ -423,60 +403,8 @@ nsMultiplexInputStreamConstructor(nsISup
         return NS_ERROR_OUT_OF_MEMORY;
 
     NS_ADDREF(inst);
     nsresult rv = inst->QueryInterface(iid, result);
     NS_RELEASE(inst);
 
     return rv;
 }
-
-PRBool
-nsMultiplexInputStream::Read(const IPC::Message *aMsg, void **aIter)
-{
-#ifdef MOZ_IPC
-    using IPC::ReadParam;
-
-    PRUint32 count;
-    if (!ReadParam(aMsg, aIter, &count))
-        return PR_FALSE;
-
-    for (PRUint32 i = 0; i < count; i++) {
-        IPC::InputStream inputStream;
-        if (!ReadParam(aMsg, aIter, &inputStream))
-            return PR_FALSE;
-
-        nsCOMPtr<nsIInputStream> stream(inputStream);
-        nsresult rv = AppendStream(stream);
-        if (NS_FAILED(rv))
-            return PR_FALSE;
-    }
-
-    if (!ReadParam(aMsg, aIter, &mCurrentStream) ||
-        !ReadParam(aMsg, aIter, &mStartedReadingCurrent) ||
-        !ReadParam(aMsg, aIter, &mStatus))
-        return PR_FALSE;
-
-    return PR_TRUE;
-#else
-    return PR_FALSE;
-#endif
-}
-
-void
-nsMultiplexInputStream::Write(IPC::Message *aMsg)
-{
-#ifdef MOZ_IPC
-    using IPC::WriteParam;
-
-    PRUint32 count = mStreams.Count();
-    WriteParam(aMsg, count);
-
-    for (PRUint32 i = 0; i < count; i++) {
-        IPC::InputStream inputStream(mStreams.ObjectAt(i));
-        WriteParam(aMsg, inputStream);
-    }
-
-    WriteParam(aMsg, mCurrentStream);
-    WriteParam(aMsg, mStartedReadingCurrent);
-    WriteParam(aMsg, mStatus);
-#endif
-}
--- a/xpcom/io/nsStringStream.cpp
+++ b/xpcom/io/nsStringStream.cpp
@@ -47,49 +47,42 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 /**
  * Based on original code from nsIStringStream.cpp
  */
 
-#ifdef MOZ_IPC
-#include "IPC/IPCMessageUtils.h"
-#endif
-
 #include "nsStringStream.h"
 #include "nsStreamUtils.h"
 #include "nsReadableUtils.h"
 #include "nsISeekableStream.h"
 #include "nsISupportsPrimitives.h"
 #include "nsInt64.h"
 #include "nsCRT.h"
 #include "prerror.h"
 #include "plstr.h"
 #include "nsIClassInfoImpl.h"
-#include "nsIIPCSerializable.h"
 
 //-----------------------------------------------------------------------------
 // nsIStringInputStream implementation
 //-----------------------------------------------------------------------------
 
 class nsStringInputStream : public nsIStringInputStream
                           , public nsISeekableStream
                           , public nsISupportsCString
-                          , public nsIIPCSerializable
 {
 public:
     NS_DECL_ISUPPORTS
     NS_DECL_NSIINPUTSTREAM
     NS_DECL_NSISTRINGINPUTSTREAM
     NS_DECL_NSISEEKABLESTREAM
     NS_DECL_NSISUPPORTSPRIMITIVE
     NS_DECL_NSISUPPORTSCSTRING
-    NS_DECL_NSIIPCSERIALIZABLE
 
     nsStringInputStream()
         : mData(nsnull)
         , mOffset(0)
         , mLength(0)
         , mOwned(PR_FALSE)
     {}
 
@@ -123,28 +116,26 @@ private:
 
 // This class needs to support threadsafe refcounting since people often
 // allocate a string stream, and then read it from a background thread.
 NS_IMPL_THREADSAFE_ADDREF(nsStringInputStream)
 NS_IMPL_THREADSAFE_RELEASE(nsStringInputStream)
 
 NS_IMPL_CLASSINFO(nsStringInputStream, NULL, nsIClassInfo::THREADSAFE,
                   NS_STRINGINPUTSTREAM_CID)
-NS_IMPL_QUERY_INTERFACE5_CI(nsStringInputStream,
+NS_IMPL_QUERY_INTERFACE4_CI(nsStringInputStream,
                             nsIStringInputStream,
                             nsIInputStream,
                             nsISupportsCString,
-                            nsISeekableStream,
-                            nsIIPCSerializable)
-NS_IMPL_CI_INTERFACE_GETTER5(nsStringInputStream,
+                            nsISeekableStream)
+NS_IMPL_CI_INTERFACE_GETTER4(nsStringInputStream,
                              nsIStringInputStream,
                              nsIInputStream,
                              nsISupportsCString,
-                             nsISeekableStream,
-                             nsIIPCSerializable)
+                             nsISeekableStream)
 
 /////////
 // nsISupportsCString implementation
 /////////
 
 NS_IMETHODIMP
 nsStringInputStream::GetType(PRUint16 *type)
 {
@@ -353,54 +344,16 @@ nsStringInputStream::SetEOF()
 {
     if (!mData)
         return NS_BASE_STREAM_CLOSED;
 
     mLength = mOffset;
     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,
                       nsAssignmentType aAssignment)
 {
     NS_PRECONDITION(aStreamResult, "null out ptr");
 
     nsStringInputStream* stream = new nsStringInputStream();