- 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
This commit is contained in:
cbiesinger%web.de 2005-04-05 17:40:32 +00:00
Родитель 4b42fa49f2
Коммит 44625301dd
58 изменённых файлов: 364 добавлений и 105 удалений

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

@ -484,6 +484,7 @@ DEFINES += \
-D_IMPL_NS_GFX \
-D_IMPL_NS_WIDGET \
-DIMPL_XULAPI \
-DIMPL_NS_NET \
$(NULL)
ifndef MOZ_NATIVE_ZLIB

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

@ -83,6 +83,7 @@
#include "nsISeekableStream.h"
#include "nsAutoPtr.h"
#include "nsIPrefService.h"
#include "nsIWritablePropertyBag2.h"
// we want to explore making the document own the load group
// so we can associate the document URI with the load group.
@ -5762,12 +5763,13 @@ nsDocShell::DoURILoad(nsIURI * aURI,
}
}
nsCOMPtr<nsIProperties> props(do_QueryInterface(channel));
nsCOMPtr<nsIWritablePropertyBag2> props(do_QueryInterface(channel));
if (props)
{
// save true referrer for those who need it (e.g. xpinstall whitelisting)
// Currently only http and ftp channels support this.
props->Set("docshell.internalReferrer", aReferrerURI);
props->SetPropertyAsInterface(NS_LITERAL_STRING("docshell.internalReferrer"),
aReferrerURI);
}
//

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

@ -66,3 +66,5 @@ endif
EXPORTS = necko-config.h
include $(topsrcdir)/config/rules.mk
DEFINES += -DIMPL_NS_NET

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

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

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

@ -118,6 +118,8 @@ EXPORTS = \
netCore.h \
nsNetError.h \
nsNetUtil.h \
nsNetStrings.h \
nsChannelProperties.h \
nsURIHashKey.h \
nsReadLine.h \
nsCPasswordManager.h \
@ -128,3 +130,4 @@ PREF_JS_EXPORTS = $(srcdir)/security-prefs.js
include $(topsrcdir)/config/rules.mk
DEFINES += -DIMPL_NS_NET

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

@ -0,0 +1,68 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org networking code.
*
* The Initial Developer of the Original Code is
* Christian Biesinger <cbiesinger@web.de>.
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* 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 ***** */
#ifndef nsChannelProperties_h__
#define nsChannelProperties_h__
#include "nsLiteralString.h"
#ifdef IMPL_NS_NET
#include "nsNetStrings.h"
#endif
/**
* @file
* This file contains constants for properties channels can expose.
* They can be accessed by using QueryInterface to access the nsIPropertyBag
* or nsIPropertyBag2 interface on a channel and reading the value.
*/
/**
* Content-Length of a channel. Used instead of the nsIChannel.contentLength
* property.
* Not available before onStartRequest has been called.
* Type: PRUint64
*/
#define NS_CHANNEL_PROP_CONTENT_LENGTH_STR "content-length"
#ifdef IMPL_NS_NET
#define NS_CHANNEL_PROP_CONTENT_LENGTH gNetStrings->kContentLength
#else
#define NS_CHANNEL_PROP_CONTENT_LENGTH \
NS_LITERAL_STRING(NS_CHANNEL_PROP_CONTENT_LENGTH_STR)
#endif
#endif

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

@ -146,6 +146,9 @@ interface nsIChannel : nsIRequest
/**
* The length of the data associated with the channel if available. A value
* of -1 indicates that the content length is unknown.
*
* Callers should prefer getting the "content-length" property
* using nsIPropertyBag2 as 64-bit value, if available.
*/
attribute long contentLength;

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

@ -0,0 +1,57 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org networking code.
*
* The Initial Developer of the Original Code is
* Christian Biesinger <cbiesinger@web.de>.
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* 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 ***** */
#ifndef nsNetStrings_h__
#define nsNetStrings_h__
#include "nsLiteralString.h"
/**
* Class on which wide strings are available, to avoid constructing strings
* wherever these strings are used.
*/
class nsNetStrings {
public:
nsNetStrings();
/** "content-length" */
const nsLiteralString kContentLength;
};
extern NS_HIDDEN_(nsNetStrings*) gNetStrings;
#endif

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

@ -87,6 +87,7 @@ CPPSRCS = \
nsURIChecker.cpp \
nsURLHelper.cpp \
nsURLParsers.cpp \
nsNetStrings.cpp \
$(NULL)
ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
@ -119,3 +120,4 @@ FORCE_STATIC_LIB = 1
include $(topsrcdir)/config/rules.mk
DEFINES += -DIMPL_NS_NET

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

@ -0,0 +1,46 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org networking code.
*
* The Initial Developer of the Original Code is
* Christian Biesinger <cbiesinger@web.de>.
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* 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 ***** */
#include "nsNetStrings.h"
#include "nsChannelProperties.h"
NS_HIDDEN_(nsNetStrings*) gNetStrings;
nsNetStrings::nsNetStrings()
: NS_LITERAL_STRING_INIT(kContentLength, NS_CHANNEL_PROP_CONTENT_LENGTH_STR)
{}

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

@ -138,3 +138,5 @@ OS_LIBS += -lwsock32
endif
OS_LIBS += $(call EXPAND_LIBNAME,ole32 shell32)
endif
DEFINES += -DIMPL_NS_NET

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

@ -57,6 +57,7 @@
#include "nsCacheService.h"
#include "nsIOThreadPool.h"
#include "nsMimeTypes.h"
#include "nsNetStrings.h"
#include "nsNetCID.h"
@ -575,8 +576,16 @@ CreateNewNSTXTToHTMLConvFactory(nsISupports *aOuter, REFNSIID aIID, void **aResu
///////////////////////////////////////////////////////////////////////////////
// Module implementation for the net library
// Necko module shutdown hook
static void PR_CALLBACK nsNeckoShutdown(nsIModule *neckoModule)
// Net module startup hook
PR_STATIC_CALLBACK(nsresult) nsNetStartup(nsIModule *neckoModule)
{
gNetStrings = new nsNetStrings();
return gNetStrings ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
// Net module shutdown hook
static void PR_CALLBACK nsNetShutdown(nsIModule *neckoModule)
{
// Release the url parser that the stdurl is holding.
nsStandardURL::ShutdownGlobalObjects();
@ -586,6 +595,10 @@ static void PR_CALLBACK nsNeckoShutdown(nsIModule *neckoModule)
// Release global state used by the URL helper module.
net_ShutdownURLHelper();
// Release necko strings
delete gNetStrings;
gNetStrings = nsnull;
}
static const nsModuleComponentInfo gNetModuleInfo[] = {
@ -1044,5 +1057,6 @@ static const nsModuleComponentInfo gNetModuleInfo[] = {
};
NS_IMPL_NSGETMODULE_WITH_DTOR(necko_core_and_primary_protocols, gNetModuleInfo,
nsNeckoShutdown)
NS_IMPL_NSGETMODULE_WITH_CTOR_DTOR(necko_core_and_primary_protocols,
gNetModuleInfo,
nsNetStartup, nsNetShutdown)

1
netwerk/cache/Makefile.in поставляемый
Просмотреть файл

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

1
netwerk/cache/public/Makefile.in поставляемый
Просмотреть файл

@ -57,3 +57,4 @@ XPIDLSRCS = \
include $(topsrcdir)/config/rules.mk
DEFINES += -DIMPL_NS_NET

1
netwerk/cache/src/Makefile.in поставляемый
Просмотреть файл

@ -92,3 +92,4 @@ include $(topsrcdir)/config/config.mk
include $(topsrcdir)/config/rules.mk
DEFINES += -DIMPL_NS_NET

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

@ -50,3 +50,5 @@ DIRS += src
endif
include $(topsrcdir)/config/rules.mk
DEFINES += -DIMPL_NS_NET

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

@ -60,3 +60,5 @@ XPIDLSRCS = \
$(NULL)
include $(topsrcdir)/config/rules.mk
DEFINES += -DIMPL_NS_NET

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

@ -58,3 +58,5 @@ CPPSRCS = \
$(NULL)
include $(topsrcdir)/config/rules.mk
DEFINES += -DIMPL_NS_NET

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

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

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

@ -56,3 +56,5 @@ XPIDLSRCS = \
$(NULL)
include $(topsrcdir)/config/rules.mk
DEFINES += -DIMPL_NS_NET

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

@ -68,3 +68,5 @@ CSRCS = race.c \
FORCE_STATIC_LIB = 1
include $(topsrcdir)/config/rules.mk
DEFINES += -DIMPL_NS_NET

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

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

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

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

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

@ -61,3 +61,4 @@ FORCE_STATIC_LIB = 1
include $(topsrcdir)/config/rules.mk
DEFINES += -DIMPL_NS_NET

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

@ -54,3 +54,5 @@ DIRS = about \
$(NULL)
include $(topsrcdir)/config/rules.mk
DEFINES += -DIMPL_NS_NET

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

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

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

@ -50,3 +50,4 @@ XPIDLSRCS = nsIAboutModule.idl
include $(topsrcdir)/config/rules.mk
DEFINES += -DIMPL_NS_NET

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

@ -68,3 +68,5 @@ CPPSRCS = \
FORCE_STATIC_LIB = 1
include $(topsrcdir)/config/rules.mk
DEFINES += -DIMPL_NS_NET

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

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

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

@ -53,3 +53,4 @@ XPIDLSRCS = \
include $(topsrcdir)/config/rules.mk
DEFINES += -DIMPL_NS_NET

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

@ -65,6 +65,8 @@ FORCE_STATIC_LIB = 1
LOCAL_INCLUDES = \
-I$(srcdir)/../../../base/src \
-I$(topsrcdir)/xpcom/ds \
$(NULL)
include $(topsrcdir)/config/rules.mk
DEFINES += -DIMPL_NS_NET

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

@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim:set ts=4 sw=4 sts=4 et cin: */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -68,7 +69,9 @@ nsFileChannel::nsFileChannel()
nsresult
nsFileChannel::Init(nsIURI *uri)
{
nsresult rv;
nsresult rv = nsHashPropertyBag::Init();
if (NS_FAILED(rv))
return rv;
mURL = do_QueryInterface(uri, &rv);
return rv;
}
@ -124,15 +127,17 @@ nsFileChannel::EnsureStream()
// nsISupports
//-----------------------------------------------------------------------------
// XXX this only needs to be threadsafe because of bug 101252
NS_IMPL_THREADSAFE_ISUPPORTS7(nsFileChannel,
nsIRequest,
nsIChannel,
nsIStreamListener,
nsIRequestObserver,
nsIUploadChannel,
nsIFileChannel,
nsITransportEventSink)
NS_IMPL_ADDREF_INHERITED(nsFileChannel, nsHashPropertyBag)
NS_IMPL_RELEASE_INHERITED(nsFileChannel, nsHashPropertyBag)
NS_INTERFACE_MAP_BEGIN(nsFileChannel)
NS_INTERFACE_MAP_ENTRY(nsIRequest)
NS_INTERFACE_MAP_ENTRY(nsIChannel)
NS_INTERFACE_MAP_ENTRY(nsIStreamListener)
NS_INTERFACE_MAP_ENTRY(nsIRequestObserver)
NS_INTERFACE_MAP_ENTRY(nsIUploadChannel)
NS_INTERFACE_MAP_ENTRY(nsIFileChannel)
NS_INTERFACE_MAP_ENTRY(nsITransportEventSink)
NS_INTERFACE_MAP_END_INHERITING(nsHashPropertyBag)
//-----------------------------------------------------------------------------
// nsIRequest

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

@ -50,14 +50,16 @@
#include "nsITransport.h"
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsHashPropertyBag.h"
class nsFileChannel : public nsIFileChannel
class nsFileChannel : public nsHashPropertyBag
, public nsIFileChannel
, public nsIUploadChannel
, public nsIStreamListener
, public nsITransportEventSink
{
public:
NS_DECL_ISUPPORTS
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIREQUEST
NS_DECL_NSICHANNEL
NS_DECL_NSIFILECHANNEL

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -61,3 +61,5 @@ XPIDLSRCS = \
$(NULL)
include $(topsrcdir)/config/rules.mk
DEFINES += -DIMPL_NS_NET

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

@ -79,10 +79,12 @@ CPPSRCS = \
nsHttpPipeline.cpp \
$(NULL)
LOCAL_INCLUDES=-I$(srcdir)/../../../base/src
LOCAL_INCLUDES=-I$(srcdir)/../../../base/src -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
include $(topsrcdir)/config/rules.mk
DEFINES += -DIMPL_NS_NET

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

@ -70,6 +70,8 @@
#include "nsICookieService.h"
#include "nsIResumableChannel.h"
#include "nsInt64.h"
#include "nsIVariant.h"
#include "nsChannelProperties.h"
static NS_DEFINE_CID(kStreamListenerTeeCID, NS_STREAMLISTENERTEE_CID);
@ -152,12 +154,14 @@ nsHttpChannel::Init(nsIURI *uri,
PRUint8 caps,
nsProxyInfo *proxyInfo)
{
nsresult rv;
LOG(("nsHttpChannel::Init [this=%x]\n", this));
NS_PRECONDITION(uri, "null uri");
nsresult rv = nsHashPropertyBag::Init();
if (NS_FAILED(rv))
return rv;
mURI = uri;
mOriginalURI = uri;
mDocumentURI = nsnull;
@ -681,6 +685,10 @@ nsHttpChannel::CallOnStartRequest()
if (mResponseHead && mResponseHead->ContentCharset().IsEmpty())
mResponseHead->SetContentCharset(mContentCharsetHint);
if (mResponseHead)
SetPropertyAsInt64(NS_CHANNEL_PROP_CONTENT_LENGTH,
mResponseHead->ContentLength());
LOG((" calling mListener->OnStartRequest\n"));
nsresult rv = mListener->OnStartRequest(this, mListenerContext);
@ -1762,6 +1770,15 @@ nsHttpChannel::InstallCacheListener(PRUint32 offset)
// nsHttpChannel <redirect>
//-----------------------------------------------------------------------------
PR_STATIC_CALLBACK(PLDHashOperator)
CopyProperties(const nsAString& aKey, nsIVariant *aData, void *aClosure)
{
nsIWritablePropertyBag* bag = NS_STATIC_CAST(nsIWritablePropertyBag*,
aClosure);
bag->SetProperty(aKey, aData);
return PL_DHASH_NEXT;
}
nsresult
nsHttpChannel::SetupReplacementChannel(nsIURI *newURI,
nsIChannel *newChannel,
@ -1846,24 +1863,9 @@ nsHttpChannel::SetupReplacementChannel(nsIURI *newURI,
}
// transfer any properties
if (mProperties) {
nsCOMPtr<nsIProperties> oldProps = do_QueryInterface(mProperties);
nsCOMPtr<nsIProperties> newProps = do_QueryInterface(newChannel);
if (newProps) {
PRUint32 count;
char **keys;
if (NS_SUCCEEDED(oldProps->GetKeys(&count, &keys))) {
nsCOMPtr<nsISupports> val;
for (PRUint32 i=0; i<count; ++i) {
oldProps->Get(keys[i],
NS_GET_IID(nsISupports),
getter_AddRefs(val));
newProps->Set(keys[i], val);
}
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, keys);
}
}
}
nsCOMPtr<nsIWritablePropertyBag> bag(do_QueryInterface(newChannel));
if (bag)
mPropertyHash.EnumerateRead(CopyProperties, bag.get());
return NS_OK;
}
@ -2806,8 +2808,8 @@ nsHttpChannel::GetCurrentPath(nsACString &path)
// nsHttpChannel::nsISupports
//-----------------------------------------------------------------------------
NS_IMPL_THREADSAFE_ADDREF(nsHttpChannel)
NS_IMPL_THREADSAFE_RELEASE(nsHttpChannel)
NS_IMPL_ADDREF_INHERITED(nsHttpChannel, nsHashPropertyBag)
NS_IMPL_RELEASE_INHERITED(nsHttpChannel, nsHashPropertyBag)
NS_INTERFACE_MAP_BEGIN(nsHttpChannel)
NS_INTERFACE_MAP_ENTRY(nsIRequest)
@ -2823,17 +2825,7 @@ NS_INTERFACE_MAP_BEGIN(nsHttpChannel)
NS_INTERFACE_MAP_ENTRY(nsIResumableChannel)
NS_INTERFACE_MAP_ENTRY(nsITransportEventSink)
NS_INTERFACE_MAP_ENTRY(nsISupportsPriority)
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)
//-----------------------------------------------------------------------------
// nsHttpChannel::nsIRequest

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

@ -47,6 +47,8 @@
#include "nsCOMPtr.h"
#include "nsInt64.h"
#include "nsHashPropertyBag.h"
#include "nsIHttpChannel.h"
#include "nsIHttpChannelInternal.h"
#include "nsIHttpHeaderVisitor.h"
@ -83,7 +85,8 @@ class nsProxyInfo;
// nsHttpChannel
//-----------------------------------------------------------------------------
class nsHttpChannel : public nsIHttpChannel
class nsHttpChannel : public nsHashPropertyBag
, public nsIHttpChannel
, public nsIHttpChannelInternal
, public nsIStreamListener
, public nsICachingChannel
@ -95,7 +98,7 @@ class nsHttpChannel : public nsIHttpChannel
, public nsISupportsPriority
{
public:
NS_DECL_ISUPPORTS
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIREQUEST
NS_DECL_NSICHANNEL
NS_DECL_NSIHTTPCHANNEL
@ -231,8 +234,6 @@ private:
nsCString mContentTypeHint;
nsCString mContentCharsetHint;
nsCOMPtr<nsISupports> mProperties;
// cache specific data
nsCOMPtr<nsICacheEntryDescriptor> mCacheEntry;
nsCOMPtr<nsIInputStreamPump> mCachePump;

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

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

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

@ -52,3 +52,4 @@ XPIDLSRCS = \
include $(topsrcdir)/config/rules.mk
DEFINES += -DIMPL_NS_NET

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

@ -67,3 +67,4 @@ LOCAL_INCLUDES = \
include $(topsrcdir)/config/rules.mk
DEFINES += -DIMPL_NS_NET

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

@ -44,3 +44,4 @@ include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
DEFINES += -DIMPL_NS_NET

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

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

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

@ -72,3 +72,4 @@ FORCE_STATIC_LIB = 1
include $(topsrcdir)/config/rules.mk
DEFINES += -DIMPL_NS_NET

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

@ -50,3 +50,4 @@ endif
include $(topsrcdir)/config/rules.mk
DEFINES += -DIMPL_NS_NET

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

@ -107,3 +107,4 @@ ifeq ($(OS_ARCH),WINNT)
DEFINES += -DZLIB_DLL
endif
DEFINES += -DIMPL_NS_NET

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

@ -63,3 +63,4 @@ endif
include $(topsrcdir)/config/rules.mk
DEFINES += -DIMPL_NS_NET

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

@ -66,3 +66,5 @@ endif
FORCE_STATIC_LIB = 1
include $(topsrcdir)/config/rules.mk
DEFINES += -DIMPL_NS_NET

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

@ -73,3 +73,4 @@ DEFINES += -DNGPREFS
endif
endif # WINNT
DEFINES += -DIMPL_NS_NET

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

@ -77,6 +77,9 @@
#include "nsIAuthPrompt.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "nsIPropertyBag2.h"
#include "nsIWritablePropertyBag2.h"
#include "nsChannelProperties.h"
#include "nsISimpleEnumerator.h"
#include "nsXPIDLString.h"
@ -393,10 +396,12 @@ InputTestConsumer::OnStartRequest(nsIRequest *request, nsISupports* context)
LOG(("\tChannel Owner: %x\n", owner.get()));
}
nsCOMPtr<nsIProperties> props = do_QueryInterface(request);
nsCOMPtr<nsIPropertyBag2> props = do_QueryInterface(request);
if (props) {
nsCOMPtr<nsIURI> foo;
props->Get("test.foo", NS_GET_IID(nsIURI), getter_AddRefs(foo));
props->GetPropertyAsInterface(NS_LITERAL_STRING("test.foo"),
NS_GET_IID(nsIURI),
getter_AddRefs(foo));
if (foo) {
nsCAutoString spec;
foo->GetSpec(spec);
@ -404,6 +409,15 @@ InputTestConsumer::OnStartRequest(nsIRequest *request, nsISupports* context)
}
}
nsCOMPtr<nsIPropertyBag2> propbag = do_QueryInterface(request);
if (propbag) {
PRInt64 len;
nsresult rv = propbag->GetPropertyAsInt64(NS_CHANNEL_PROP_CONTENT_LENGTH,
&len);
if (NS_SUCCEEDED(rv))
LOG(("\t64-bit length: %lli\n", len));
}
nsCOMPtr<nsIHttpChannelInternal> httpChannelInt(do_QueryInterface(request));
if (httpChannelInt) {
PRUint32 majorVer, minorVer;
@ -626,9 +640,11 @@ nsresult StartLoadingURL(const char* aUrlString)
return rv;
}
nsCOMPtr<nsIProperties> props = do_QueryInterface(pChannel);
nsCOMPtr<nsIWritablePropertyBag2> props = do_QueryInterface(pChannel);
if (props) {
if (NS_SUCCEEDED(props->Set("test.foo", pURL)))
rv = props->SetPropertyAsInterface(NS_LITERAL_STRING("test.foo"),
pURL);
if (NS_SUCCEEDED(rv))
LOG(("set prop 'test.foo'\n"));
}

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

@ -58,6 +58,7 @@
#include "nsIDocument.h"
#include "nsIPrincipal.h"
#include "nsIObserverService.h"
#include "nsIPropertyBag2.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
@ -149,10 +150,10 @@ nsInstallTrigger::HandleContent(const char * aContentType,
// Save the referrer if any, for permission checks
static const char kReferrerProperty[] = "docshell.internalReferrer";
NS_NAMED_LITERAL_STRING(referrerProperty, "docshell.internalReferrer");
PRBool useReferrer = PR_FALSE;
nsCOMPtr<nsIURI> referringURI;
nsCOMPtr<nsIProperties> channelprops(do_QueryInterface(channel));
nsCOMPtr<nsIPropertyBag2> channelprops(do_QueryInterface(channel));
if (channelprops)
{
@ -160,18 +161,17 @@ nsInstallTrigger::HandleContent(const char * aContentType,
// channels support our internal-referrer property).
//
// It's possible docshell explicitly set a null referrer in the case
// of typed, pasted, or bookmarked URLs and the like. In this null
// referrer case we get NS_ERROR_NO_INTERFACE rather than the usual
// NS_ERROR_FAILURE that indicates the property was not set at all.
// of typed, pasted, or bookmarked URLs and the like. In such a case
// we get a success return value with null pointer.
//
// A null referrer is automatically whitelisted as an explicit user
// action (though they'll still get the confirmation dialog). For a
// missing referrer we go to our fall-back plan of using the XPI
// location for whitelisting purposes.
rv = channelprops->Get(kReferrerProperty,
NS_GET_IID(nsIURI),
getter_AddRefs(referringURI));
if (NS_SUCCEEDED(rv) || rv == NS_ERROR_NO_INTERFACE)
rv = channelprops->GetPropertyAsInterface(referrerProperty,
NS_GET_IID(nsIURI),
getter_AddRefs(referringURI));
if (NS_SUCCEEDED(rv))
useReferrer = PR_TRUE;
}