Bounce input stream and FTP patches for Windows test failure. a=bustage

This commit is contained in:
Dan Witte 2010-10-19 19:46:54 -07:00
parent 6fbce6a4ea
commit 6b7bdc50fe
27 changed files with 168 additions and 587 deletions

View File

@ -64,7 +64,6 @@ IPDLDIRS = \
js/jetpack \
layout/ipc \
netwerk/ipc \
netwerk/protocol/ftp \
netwerk/protocol/http \
netwerk/protocol/wyciwyg \
netwerk/cookie \

View File

@ -281,24 +281,22 @@ private:
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__

View File

@ -35,16 +35,9 @@
*
* ***** 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
@ -253,26 +246,11 @@ nsBufferedStream::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)
@ -488,42 +466,6 @@ nsBufferedInputStream::GetUnbufferedStream(nsISupports* *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

View File

@ -46,8 +46,6 @@
#include "nsIStreamBufferAccess.h"
#include "nsCOMPtr.h"
#include "nsInt64.h"
#include "nsIIPCSerializable.h"
////////////////////////////////////////////////////////////////////////////////
class nsBufferedStream : public nsISeekableStream
@ -91,15 +89,13 @@ protected:
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() {}

View File

@ -35,10 +35,6 @@
*
* ***** 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)
@ -63,7 +59,7 @@
#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
@ -177,27 +173,11 @@ nsFileStream::SetEOF()
////////////////////////////////////////////////////////////////////////////////
// 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)
@ -245,9 +225,9 @@ nsFileInputStream::Open(nsIFile* aFile, PRInt32 aIOFlags, PRInt32 aPerm)
// 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;
}
}
@ -263,9 +243,12 @@ nsFileInputStream::Init(nsIFile* aFile, PRInt32 aIOFlags, PRInt32 aPerm,
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);
}
@ -277,12 +260,14 @@ nsFileInputStream::Close()
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;
}
@ -378,54 +363,6 @@ nsFileInputStream::Seek(PRInt32 aWhence, PRInt64 aOffset)
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

View File

@ -48,7 +48,6 @@
#include "nsCOMPtr.h"
#include "prlog.h"
#include "prio.h"
#include "nsIIPCSerializable.h"
template<class CharType> class nsLineBuffer;
@ -77,15 +76,13 @@ protected:
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);
@ -107,15 +104,18 @@ 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;
/**

View File

@ -41,11 +41,6 @@
* 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"
@ -53,13 +48,9 @@
#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();
@ -69,7 +60,6 @@ public:
NS_DECL_NSIINPUTSTREAM
NS_DECL_NSIMIMEINPUTSTREAM
NS_DECL_NSISEEKABLESTREAM
NS_DECL_NSIIPCSERIALIZABLE
NS_METHOD Init();
@ -98,22 +88,10 @@ private:
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)
@ -327,58 +305,3 @@ nsMIMEInputStreamConstructor(nsISupports *outer, REFNSIID iid, void **result)
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
}

View File

@ -45,7 +45,6 @@
#include "mozilla/net/HttpChannelChild.h"
#include "mozilla/net/CookieServiceChild.h"
#include "mozilla/net/WyciwygChannelChild.h"
#include "mozilla/net/FTPChannelChild.h"
namespace mozilla {
namespace net {
@ -113,24 +112,6 @@ NeckoChild::DeallocPHttpChannel(PHttpChannelChild* channel)
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()
{

View File

@ -65,8 +65,6 @@ protected:
virtual bool DeallocPCookieService(PCookieServiceChild*);
virtual PWyciwygChannelChild* AllocPWyciwygChannel();
virtual bool DeallocPWyciwygChannel(PWyciwygChannelChild*);
virtual PFTPChannelChild* AllocPFTPChannel();
virtual bool DeallocPFTPChannel(PFTPChannelChild*);
};
/**

View File

@ -73,20 +73,12 @@
#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 {

View File

@ -46,7 +46,6 @@
#include "nsIClassInfo.h"
#include "nsComponentManagerUtils.h"
#include "nsNetUtil.h"
#include "nsStringStream.h"
namespace IPC {
@ -175,109 +174,6 @@ struct ParamTraits<URI>
}
};
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

View File

@ -43,7 +43,6 @@
#include "mozilla/net/HttpChannelParent.h"
#include "mozilla/net/CookieServiceParent.h"
#include "mozilla/net/WyciwygChannelParent.h"
#include "mozilla/net/FTPChannelParent.h"
#include "nsHTMLDNSPrefetch.h"
@ -75,22 +74,6 @@ NeckoParent::DeallocPHttpChannel(PHttpChannelParent* channel)
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()
{

View File

@ -62,8 +62,6 @@ protected:
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);
};

View File

@ -43,7 +43,6 @@ include protocol PHttpChannel;
include protocol PCookieService;
include protocol PBrowser;
include protocol PWyciwygChannel;
include protocol PFTPChannel;
namespace mozilla {
namespace net {
@ -56,14 +55,12 @@ sync protocol PNecko
manages PHttpChannel;
manages PCookieService;
manages PWyciwygChannel;
manages PFTPChannel;
parent:
__delete__();
PCookieService();
PWyciwygChannel();
PFTPChannel();
HTMLDNSPrefetch(nsString hostname, PRUint16 flags);

View File

@ -56,15 +56,6 @@ 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 \
@ -72,13 +63,6 @@ CPPSRCS = \
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
@ -91,8 +75,6 @@ LOCAL_INCLUDES = \
-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)

View File

@ -62,7 +62,6 @@
#include "nsIProxiedChannel.h"
#include "nsIResumableChannel.h"
#include "nsHashPropertyBag.h"
#include "nsFtpProtocolHandler.h"
class nsFtpChannel : public nsBaseChannel,
public nsIFTPChannel,

View File

@ -49,12 +49,6 @@
* 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"
@ -87,7 +81,6 @@ using namespace mozilla::net;
//
PRLogModuleInfo* gFTPLog = nsnull;
#endif
#undef LOG
#define LOG(args) PR_LOG(gFTPLog, PR_LOG_DEBUG, args)
//-----------------------------------------------------------------------------
@ -135,11 +128,6 @@ NS_IMPL_THREADSAFE_ISUPPORTS4(nsFtpProtocolHandler,
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);
@ -253,20 +241,18 @@ 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;
}

View File

@ -123,8 +123,4 @@ private:
extern nsFtpProtocolHandler *gFtpHandler;
#ifdef PR_LOGGING
extern PRLogModuleInfo* gFTPLog;
#endif
#endif // !nsFtpProtocolHandler_h__

View File

@ -60,9 +60,31 @@
#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.

View File

@ -820,6 +820,29 @@ HttpChannelChild::AsyncOpen(nsIStreamListener *listener, nsISupports *aContext)
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;
@ -876,10 +899,9 @@ HttpChannelChild::AsyncOpen(nsIStreamListener *listener, nsISupports *aContext)
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;

View File

@ -102,8 +102,8 @@ HttpChannelParent::RecvAsyncOpen(const IPC::URI& aURI,
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,
@ -158,10 +158,16 @@ HttpChannelParent::RecvAsyncOpen(const IPC::URI& aURI,
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)

View File

@ -88,8 +88,8 @@ protected:
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,

View File

@ -48,7 +48,6 @@ using RequestHeaderTuples;
using nsHttpResponseHead;
using nsHttpAtom;
using IPC::URI;
using IPC::InputStream;
namespace mozilla {
namespace net {
@ -69,8 +68,8 @@ parent:
PRUint32 loadFlags,
RequestHeaderTuples requestHeaders,
nsHttpAtom requestMethod,
InputStream uploadStream,
PRBool uploadStreamHasHeaders,
nsCString uploadStreamData,
PRInt32 uploadStreamInfo,
PRUint16 priority,
PRUint8 redirectionLimit,
PRBool allowPipelining,

View File

@ -49,9 +49,8 @@
#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 {
@ -196,6 +195,56 @@ struct ParamTraits<nsHttpResponseHead>
}
};
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

View File

@ -187,7 +187,6 @@ FORCE_STATIC_LIB = 1
FORCE_USE_PIC = 1
include $(topsrcdir)/config/rules.mk
include $(topsrcdir)/ipc/chromium/chromium-config.mk
DEFINES += -D_IMPL_NS_COM
@ -197,7 +196,7 @@ DEFINES += -DHAVE_USR_LIB64_DIR
endif
endif
LOCAL_INCLUDES += -I..
LOCAL_INCLUDES = -I..
ifeq ($(MOZ_PLATFORM_MAEMO),5)
CFLAGS += $(MOZ_DBUS_CFLAGS)

View File

@ -41,23 +41,15 @@
* 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();
@ -66,7 +58,6 @@ public:
NS_DECL_NSIINPUTSTREAM
NS_DECL_NSIMULTIPLEXINPUTSTREAM
NS_DECL_NSISEEKABLESTREAM
NS_DECL_NSIIPCSERIALIZABLE
private:
~nsMultiplexInputStream() {}
@ -89,22 +80,11 @@ private:
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),
@ -428,55 +408,3 @@ nsMultiplexInputStreamConstructor(nsISupports *outer,
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
}

View File

@ -52,10 +52,6 @@
* Based on original code from nsIStringStream.cpp
*/
#ifdef MOZ_IPC
#include "IPC/IPCMessageUtils.h"
#endif
#include "nsStringStream.h"
#include "nsStreamUtils.h"
#include "nsReadableUtils.h"
@ -66,7 +62,6 @@
#include "prerror.h"
#include "plstr.h"
#include "nsIClassInfoImpl.h"
#include "nsIIPCSerializable.h"
//-----------------------------------------------------------------------------
// nsIStringInputStream implementation
@ -75,7 +70,6 @@
class nsStringInputStream : public nsIStringInputStream
, public nsISeekableStream
, public nsISupportsCString
, public nsIIPCSerializable
{
public:
NS_DECL_ISUPPORTS
@ -84,7 +78,6 @@ public:
NS_DECL_NSISEEKABLESTREAM
NS_DECL_NSISUPPORTSPRIMITIVE
NS_DECL_NSISUPPORTSCSTRING
NS_DECL_NSIIPCSERIALIZABLE
nsStringInputStream()
: mData(nsnull)
@ -128,18 +121,16 @@ 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
@ -358,44 +349,6 @@ 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,