diff --git a/netwerk/base/src/nsBaseChannel.h b/netwerk/base/src/nsBaseChannel.h index 7d85e547cf23..ac94d4fc84ae 100644 --- a/netwerk/base/src/nsBaseChannel.h +++ b/netwerk/base/src/nsBaseChannel.h @@ -281,22 +281,24 @@ private: nsCOMPtr mProgressSink; nsCOMPtr mOriginalURI; nsCOMPtr mURI; - nsCOMPtr mLoadGroup; nsCOMPtr mOwner; nsCOMPtr mSecurityInfo; - nsCOMPtr mListener; - nsCOMPtr mListenerContext; nsCOMPtr mRedirectChannel; nsCString mContentType; nsCString mContentCharset; PRUint32 mLoadFlags; - nsresult mStatus; PRPackedBool mQueriedProgressSink; PRPackedBool mSynthProgressEvents; PRPackedBool mWasOpened; PRPackedBool mWaitingOnAsyncRedirect; PRPackedBool mOpenRedirectChannel; PRUint32 mRedirectFlags; + +protected: + nsCOMPtr mLoadGroup; + nsCOMPtr mListener; + nsCOMPtr mListenerContext; + nsresult mStatus; }; #endif // !nsBaseChannel_h__ diff --git a/netwerk/ipc/NeckoChild.cpp b/netwerk/ipc/NeckoChild.cpp index 8556d50703d5..3a191369af7f 100644 --- a/netwerk/ipc/NeckoChild.cpp +++ b/netwerk/ipc/NeckoChild.cpp @@ -45,6 +45,7 @@ #include "mozilla/net/HttpChannelChild.h" #include "mozilla/net/CookieServiceChild.h" #include "mozilla/net/WyciwygChannelChild.h" +#include "mozilla/net/FTPChannelChild.h" namespace mozilla { namespace net { @@ -112,6 +113,24 @@ 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(channel); + child->ReleaseIPDLReference(); + return true; +} + PCookieServiceChild* NeckoChild::AllocPCookieService() { diff --git a/netwerk/ipc/NeckoChild.h b/netwerk/ipc/NeckoChild.h index 0d88b91e5e28..9548330a1e1f 100644 --- a/netwerk/ipc/NeckoChild.h +++ b/netwerk/ipc/NeckoChild.h @@ -65,6 +65,8 @@ protected: virtual bool DeallocPCookieService(PCookieServiceChild*); virtual PWyciwygChannelChild* AllocPWyciwygChannel(); virtual bool DeallocPWyciwygChannel(PWyciwygChannelChild*); + virtual PFTPChannelChild* AllocPFTPChannel(); + virtual bool DeallocPFTPChannel(PFTPChannelChild*); }; /** diff --git a/netwerk/ipc/NeckoCommon.h b/netwerk/ipc/NeckoCommon.h index 7070454c57bc..5899e06715f4 100644 --- a/netwerk/ipc/NeckoCommon.h +++ b/netwerk/ipc/NeckoCommon.h @@ -73,12 +73,20 @@ #define DROP_DEAD() \ do { \ - nsPrintfCString msg(1000,"FATAL NECKO ERROR: '%s' UNIMPLEMENTED", \ + nsPrintfCString msg(1000,"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 { diff --git a/netwerk/ipc/NeckoParent.cpp b/netwerk/ipc/NeckoParent.cpp index d1b7d27a1fbf..22d33f43625c 100644 --- a/netwerk/ipc/NeckoParent.cpp +++ b/netwerk/ipc/NeckoParent.cpp @@ -43,6 +43,7 @@ #include "mozilla/net/HttpChannelParent.h" #include "mozilla/net/CookieServiceParent.h" #include "mozilla/net/WyciwygChannelParent.h" +#include "mozilla/net/FTPChannelParent.h" #include "nsHTMLDNSPrefetch.h" @@ -74,6 +75,22 @@ 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(channel); + p->Release(); + return true; +} + PCookieServiceParent* NeckoParent::AllocPCookieService() { diff --git a/netwerk/ipc/NeckoParent.h b/netwerk/ipc/NeckoParent.h index 98f0f122c316..94f93a132b9e 100644 --- a/netwerk/ipc/NeckoParent.h +++ b/netwerk/ipc/NeckoParent.h @@ -62,6 +62,8 @@ 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); }; diff --git a/netwerk/ipc/PNecko.ipdl b/netwerk/ipc/PNecko.ipdl index ac9010fe7fbc..cf3953dadca8 100644 --- a/netwerk/ipc/PNecko.ipdl +++ b/netwerk/ipc/PNecko.ipdl @@ -43,6 +43,7 @@ include protocol PHttpChannel; include protocol PCookieService; include protocol PBrowser; include protocol PWyciwygChannel; +include protocol PFTPChannel; namespace mozilla { namespace net { @@ -55,12 +56,14 @@ sync protocol PNecko manages PHttpChannel; manages PCookieService; manages PWyciwygChannel; + manages PFTPChannel; parent: __delete__(); PCookieService(); PWyciwygChannel(); + PFTPChannel(); HTMLDNSPrefetch(nsString hostname, PRUint16 flags); diff --git a/netwerk/protocol/ftp/Makefile.in b/netwerk/protocol/ftp/Makefile.in index 1a035973eceb..8869402f4f4b 100644 --- a/netwerk/protocol/ftp/Makefile.in +++ b/netwerk/protocol/ftp/Makefile.in @@ -56,6 +56,15 @@ 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 \ @@ -63,6 +72,13 @@ 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 @@ -75,6 +91,8 @@ 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) diff --git a/netwerk/protocol/ftp/nsFTPChannel.h b/netwerk/protocol/ftp/nsFTPChannel.h index 33235fb761b2..b30e6443c2d0 100644 --- a/netwerk/protocol/ftp/nsFTPChannel.h +++ b/netwerk/protocol/ftp/nsFTPChannel.h @@ -62,6 +62,7 @@ #include "nsIProxiedChannel.h" #include "nsIResumableChannel.h" #include "nsHashPropertyBag.h" +#include "nsFtpProtocolHandler.h" class nsFtpChannel : public nsBaseChannel, public nsIFTPChannel, diff --git a/netwerk/protocol/ftp/nsFtpProtocolHandler.cpp b/netwerk/protocol/ftp/nsFtpProtocolHandler.cpp index 9ece9c90bab6..208ee32b9c40 100644 --- a/netwerk/protocol/ftp/nsFtpProtocolHandler.cpp +++ b/netwerk/protocol/ftp/nsFtpProtocolHandler.cpp @@ -49,6 +49,12 @@ * 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" @@ -81,6 +87,7 @@ // PRLogModuleInfo* gFTPLog = nsnull; #endif +#undef LOG #define LOG(args) PR_LOG(gFTPLog, PR_LOG_DEBUG, args) //----------------------------------------------------------------------------- @@ -128,6 +135,11 @@ NS_IMPL_THREADSAFE_ISUPPORTS4(nsFtpProtocolHandler, nsresult nsFtpProtocolHandler::Init() { +#ifdef MOZ_IPC + if (IsNeckoChild()) + NeckoChild::InitNeckoChild(); +#endif // MOZ_IPC + if (mIdleTimeout == -1) { nsresult rv; nsCOMPtr branch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv); @@ -241,18 +253,20 @@ nsFtpProtocolHandler::NewProxiedChannel(nsIURI* uri, nsIProxyInfo* proxyInfo, nsIChannel* *result) { NS_ENSURE_ARG_POINTER(uri); - nsFtpChannel *channel = new nsFtpChannel(uri, proxyInfo); - if (!channel) - return NS_ERROR_OUT_OF_MEMORY; - NS_ADDREF(channel); + nsRefPtr channel; +#ifdef MOZ_IPC + if (IsNeckoChild()) + channel = new FTPChannelChild(uri); + else +#endif + channel = new nsFtpChannel(uri, proxyInfo); nsresult rv = channel->Init(); if (NS_FAILED(rv)) { - NS_RELEASE(channel); return rv; } - *result = channel; + channel.forget(result); return rv; } diff --git a/netwerk/protocol/ftp/nsFtpProtocolHandler.h b/netwerk/protocol/ftp/nsFtpProtocolHandler.h index 2d1d30d8e291..bb8abf02198e 100644 --- a/netwerk/protocol/ftp/nsFtpProtocolHandler.h +++ b/netwerk/protocol/ftp/nsFtpProtocolHandler.h @@ -123,4 +123,8 @@ private: extern nsFtpProtocolHandler *gFtpHandler; +#ifdef PR_LOGGING +extern PRLogModuleInfo* gFTPLog; +#endif + #endif // !nsFtpProtocolHandler_h__ diff --git a/netwerk/protocol/http/HttpBaseChannel.h b/netwerk/protocol/http/HttpBaseChannel.h index 42c47922196f..647462b6f9c6 100644 --- a/netwerk/protocol/http/HttpBaseChannel.h +++ b/netwerk/protocol/http/HttpBaseChannel.h @@ -60,24 +60,6 @@ #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 {