Bug 536289 - Part 2: Make FTP work for fennec. r=jduell a=blocking-fennec

This commit is contained in:
Alon Zakai 2010-08-10 14:47:00 -04:00
Родитель 484da22282
Коммит b758507282
12 изменённых файлов: 101 добавлений и 29 удалений

Просмотреть файл

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

Просмотреть файл

@ -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<FTPChannelChild*>(channel);
child->ReleaseIPDLReference();
return true;
}
PCookieServiceChild*
NeckoChild::AllocPCookieService()
{

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -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<FTPChannelParent *>(channel);
p->Release();
return true;
}
PCookieServiceParent*
NeckoParent::AllocPCookieService()
{

Просмотреть файл

@ -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);
};

Просмотреть файл

@ -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);

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -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<nsIPrefBranch2> 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<nsBaseChannel> 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;
}

Просмотреть файл

@ -123,4 +123,8 @@ private:
extern nsFtpProtocolHandler *gFtpHandler;
#ifdef PR_LOGGING
extern PRLogModuleInfo* gFTPLog;
#endif
#endif // !nsFtpProtocolHandler_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 {