bug 283489 r=darin sr=bz

- Make the HTTP, FTP and file channels implement nsIPropertyBag2 and associated
  interfaces (by inheriting from nsHashPropertyBag)
- Use that interface to expose a "content-length" property giving the length of
  the data as a 64-bit value on the FTP and HTTP channels
- change docshell and xpinstall to use nsIPropertyBag2 instead of nsIProperties
  to read/write the referrer property


git-svn-id: svn://10.0.0.236/trunk@171661 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
cbiesinger%web.de
2005-04-05 17:40:32 +00:00
parent ee23eccf53
commit 5d85d7ccaa
58 changed files with 364 additions and 105 deletions

View File

@@ -46,3 +46,4 @@ DIRS = public src
include $(topsrcdir)/config/rules.mk
DEFINES += -DIMPL_NS_NET

View File

@@ -54,3 +54,4 @@ EXPORTS = ftpCore.h
include $(topsrcdir)/config/rules.mk
DEFINES += -DIMPL_NS_NET

View File

@@ -68,6 +68,8 @@ MODULE_OPTIMIZE_FLAGS=-O -g
endif
endif
LOCAL_INCLUDES=-I$(topsrcdir)/xpcom/ds
# we don't want the shared lib, but we want to force the creation of a
# static lib.
FORCE_STATIC_LIB = 1
@@ -82,3 +84,4 @@ endif
endif
endif # WINNT
DEFINES += -DIMPL_NS_NET

View File

@@ -100,8 +100,8 @@ nsFTPChannel::~nsFTPChannel()
NS_IF_RELEASE(mFTPState);
}
NS_IMPL_ADDREF(nsFTPChannel)
NS_IMPL_RELEASE(nsFTPChannel)
NS_IMPL_ADDREF_INHERITED(nsFTPChannel, nsHashPropertyBag)
NS_IMPL_RELEASE_INHERITED(nsFTPChannel, nsHashPropertyBag)
NS_INTERFACE_MAP_BEGIN(nsFTPChannel)
NS_INTERFACE_MAP_ENTRY(nsIChannel)
@@ -114,22 +114,14 @@ NS_INTERFACE_MAP_BEGIN(nsFTPChannel)
NS_INTERFACE_MAP_ENTRY(nsIStreamListener)
NS_INTERFACE_MAP_ENTRY(nsIRequestObserver)
NS_INTERFACE_MAP_ENTRY(nsICacheListener)
if (aIID.Equals(NS_GET_IID(nsIProperties))) {
if (!mProperties) {
mProperties =
do_CreateInstance(NS_PROPERTIES_CONTRACTID, (nsIChannel *) this);
NS_ENSURE_STATE(mProperties);
}
return mProperties->QueryInterface(aIID, aInstancePtr);
}
else
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIChannel)
NS_INTERFACE_MAP_END
NS_INTERFACE_MAP_END_INHERITING(nsHashPropertyBag)
nsresult
nsFTPChannel::Init(nsIURI* uri, nsIProxyInfo* proxyInfo, nsICacheSession* session)
{
nsresult rv = NS_OK;
nsresult rv = nsHashPropertyBag::Init();
if (NS_FAILED(rv))
return rv;
// setup channel state
mURL = uri;

View File

@@ -59,6 +59,7 @@
#include "nsIUploadChannel.h"
#include "nsIProxyInfo.h"
#include "nsIResumableChannel.h"
#include "nsHashPropertyBag.h"
#include "nsICacheService.h"
#include "nsICacheEntryDescriptor.h"
@@ -73,7 +74,8 @@
#define FTP_CACHE_CONTROL_CONNECTION 1
class nsFTPChannel : public nsIFTPChannel,
class nsFTPChannel : public nsHashPropertyBag,
public nsIFTPChannel,
public nsIUploadChannel,
public nsIInterfaceRequestor,
public nsIProgressEventSink,
@@ -82,7 +84,7 @@ class nsFTPChannel : public nsIFTPChannel,
public nsIResumableChannel
{
public:
NS_DECL_ISUPPORTS
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIREQUEST
NS_DECL_NSICHANNEL
NS_DECL_NSIUPLOADCHANNEL
@@ -139,8 +141,7 @@ protected:
PRPackedBool mCanceled;
nsCOMPtr<nsIIOService> mIOService;
nsCOMPtr<nsISupports> mProperties;
nsCOMPtr<nsICacheSession> mCacheSession;
nsCOMPtr<nsICacheEntryDescriptor> mCacheEntry;
nsCOMPtr<nsIProxyInfo> mProxyInfo;

View File

@@ -71,6 +71,7 @@
#include "nsMimeTypes.h"
#include "nsIStringBundle.h"
#include "nsEventQueueUtils.h"
#include "nsChannelProperties.h"
#include "nsICacheEntryDescriptor.h"
#include "nsICacheListener.h"
@@ -471,10 +472,8 @@ nsFtpState::OnDataAvailable(nsIRequest *request,
return NS_OK; /*** should this be an error?? */
if (!mReceivedControlData) {
nsCOMPtr<nsIProgressEventSink> sink(do_QueryInterface(mChannel));
if (sink)
// parameter can be null cause the channel fills them in.
sink->OnStatus(nsnull, nsnull,
// parameter can be null cause the channel fills them in.
mChannel->OnStatus(nsnull, nsnull,
NS_NET_STATUS_BEGIN_FTP_TRANSACTION, nsnull);
mReceivedControlData = PR_TRUE;
@@ -625,8 +624,7 @@ nsFtpState::EstablishControlConnection()
nsFtpControlConnection* connection;
(void) gFtpHandler->RemoveConnection(mURL, &connection);
nsCOMPtr<nsIProgressEventSink> psink(do_QueryInterface(mChannel));
nsRefPtr<TransportEventForwarder> fwd(new TransportEventForwarder(psink));
nsRefPtr<TransportEventForwarder> fwd(new TransportEventForwarder(mChannel));
if (connection) {
mControlConnection = connection;
if (mControlConnection->IsAlive())
@@ -1398,6 +1396,10 @@ nsFtpState::R_size() {
LL_L2UI(size32, mFileSize);
if (NS_FAILED(mChannel->SetContentLength(size32))) return FTP_ERROR;
// Set the 64-bit length too
mChannel->SetPropertyAsUint64(NS_CHANNEL_PROP_CONTENT_LENGTH,
mFileSize);
mDRequestForwarder->SetFileSize(mFileSize);
}
@@ -2161,7 +2163,7 @@ nsFtpState::CanReadEntry()
}
nsresult
nsFtpState::Init(nsIFTPChannel* aChannel,
nsFtpState::Init(nsFTPChannel* aChannel,
nsIPrompt* aPrompter,
nsIAuthPrompt* aAuthPrompter,
nsIFTPEventSink* sink,
@@ -2191,7 +2193,7 @@ nsFtpState::Init(nsIFTPChannel* aChannel,
// parameter validation
NS_ASSERTION(aChannel, "FTP: needs a channel");
mChannel = aChannel; // a straight com ptr to the channel
mChannel = aChannel; // a straight ref ptr to the channel
nsresult rv = aChannel->GetURI(getter_AddRefs(mURL));
if (NS_FAILED(rv))
@@ -2420,11 +2422,10 @@ nsFtpState::StopProcessing()
{
// The forwarding object was never created which means that we never sent our notifications.
nsCOMPtr<nsIRequestObserver> asyncObserver = do_QueryInterface(mChannel);
nsCOMPtr<nsIRequestObserver> arg = do_QueryInterface(mChannel);
nsCOMPtr<nsIRequestObserver> asyncObserver;
NS_NewRequestObserverProxy(getter_AddRefs(asyncObserver),
arg,
mChannel,
NS_CURRENT_EVENTQ);
if(asyncObserver) {
(void) asyncObserver->OnStartRequest(this, nsnull);
@@ -2439,9 +2440,7 @@ nsFtpState::StopProcessing()
KillControlConnection();
nsCOMPtr<nsIProgressEventSink> sink(do_QueryInterface(mChannel));
if (sink)
sink->OnStatus(nsnull, nsnull, NS_NET_STATUS_END_FTP_TRANSACTION, nsnull);
mChannel->OnStatus(nsnull, nsnull, NS_NET_STATUS_END_FTP_TRANSACTION, nsnull);
// Release the Observers
mWriteStream = 0; // should this call close before setting to null?
@@ -2463,7 +2462,6 @@ nsFtpState::BuildStreamConverter(nsIStreamListener** convertStreamListener)
// unconverted data of fromType, and the final listener in the chain (in this case
// the mListener).
nsCOMPtr<nsIStreamListener> converterListener;
nsCOMPtr<nsIStreamListener> listener = do_QueryInterface(mChannel);
nsCOMPtr<nsIStreamConverterService> scs =
do_GetService(kStreamConverterServiceCID, &rv);
@@ -2473,7 +2471,7 @@ nsFtpState::BuildStreamConverter(nsIStreamListener** convertStreamListener)
rv = scs->AsyncConvertData("text/ftp-dir",
APPLICATION_HTTP_INDEX_FORMAT,
listener,
mChannel,
mURL,
getter_AddRefs(converterListener));
if (NS_FAILED(rv)) {

View File

@@ -56,6 +56,7 @@
#include "nsIInputStream.h"
#include "nsIOutputStream.h"
#include "nsAutoLock.h"
#include "nsAutoPtr.h"
#include "nsIEventQueueService.h"
#include "nsIPrompt.h"
#include "nsIAuthPrompt.h"
@@ -104,6 +105,7 @@ typedef enum _FTP_STATE {
typedef enum _FTP_ACTION {GET, PUT} FTP_ACTION;
class DataRequestForwarder;
class nsFTPChannel;
class nsFtpState : public nsIStreamListener,
public nsIRequest {
@@ -116,7 +118,7 @@ public:
nsFtpState();
virtual ~nsFtpState();
nsresult Init(nsIFTPChannel *aChannel,
nsresult Init(nsFTPChannel *aChannel,
nsIPrompt *aPrompter,
nsIAuthPrompt *aAuthPrompter,
nsIFTPEventSink *sink,
@@ -197,7 +199,7 @@ private:
nsCString mModTime;
// ****** consumer vars
nsCOMPtr<nsIFTPChannel> mChannel; // our owning FTP channel we pass through our events
nsRefPtr<nsFTPChannel> mChannel; // our owning FTP channel we pass through our events
nsCOMPtr<nsIProxyInfo> mProxyInfo;
// ****** connection cache vars