diff --git a/mozilla/config/config.mk b/mozilla/config/config.mk index e0522b1b5ca..99a009aaf0c 100644 --- a/mozilla/config/config.mk +++ b/mozilla/config/config.mk @@ -484,6 +484,7 @@ DEFINES += \ -D_IMPL_NS_GFX \ -D_IMPL_NS_WIDGET \ -DIMPL_XULAPI \ + -DIMPL_NS_NET \ $(NULL) ifndef MOZ_NATIVE_ZLIB diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index fadb5531f90..93fd560c36c 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -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 props(do_QueryInterface(channel)); + nsCOMPtr 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); } // diff --git a/mozilla/netwerk/Makefile.in b/mozilla/netwerk/Makefile.in index 32fd1d28e9f..9d4646ec99d 100644 --- a/mozilla/netwerk/Makefile.in +++ b/mozilla/netwerk/Makefile.in @@ -66,3 +66,5 @@ endif EXPORTS = necko-config.h include $(topsrcdir)/config/rules.mk + +DEFINES += -DIMPL_NS_NET diff --git a/mozilla/netwerk/base/Makefile.in b/mozilla/netwerk/base/Makefile.in index 94ab7ccbbb6..7cb9e164e6b 100644 --- a/mozilla/netwerk/base/Makefile.in +++ b/mozilla/netwerk/base/Makefile.in @@ -46,3 +46,4 @@ DIRS = public src include $(topsrcdir)/config/rules.mk +DEFINES += -DIMPL_NS_NET diff --git a/mozilla/netwerk/base/public/Makefile.in b/mozilla/netwerk/base/public/Makefile.in index 2e74d675450..cabdbae3538 100644 --- a/mozilla/netwerk/base/public/Makefile.in +++ b/mozilla/netwerk/base/public/Makefile.in @@ -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 diff --git a/mozilla/netwerk/base/public/nsChannelProperties.h b/mozilla/netwerk/base/public/nsChannelProperties.h new file mode 100644 index 00000000000..48d344d09c7 --- /dev/null +++ b/mozilla/netwerk/base/public/nsChannelProperties.h @@ -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 . + * 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 diff --git a/mozilla/netwerk/base/public/nsIChannel.idl b/mozilla/netwerk/base/public/nsIChannel.idl index 19f4c8af7f7..ed9e6a292b6 100644 --- a/mozilla/netwerk/base/public/nsIChannel.idl +++ b/mozilla/netwerk/base/public/nsIChannel.idl @@ -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; diff --git a/mozilla/netwerk/base/public/nsNetStrings.h b/mozilla/netwerk/base/public/nsNetStrings.h new file mode 100644 index 00000000000..603457a14d7 --- /dev/null +++ b/mozilla/netwerk/base/public/nsNetStrings.h @@ -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 . + * 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 diff --git a/mozilla/netwerk/base/src/Makefile.in b/mozilla/netwerk/base/src/Makefile.in index ced8789357f..f469b30540d 100644 --- a/mozilla/netwerk/base/src/Makefile.in +++ b/mozilla/netwerk/base/src/Makefile.in @@ -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 diff --git a/mozilla/netwerk/base/src/nsNetStrings.cpp b/mozilla/netwerk/base/src/nsNetStrings.cpp new file mode 100644 index 00000000000..b8d47d8f9fd --- /dev/null +++ b/mozilla/netwerk/base/src/nsNetStrings.cpp @@ -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 . + * 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) +{} + + diff --git a/mozilla/netwerk/build/Makefile.in b/mozilla/netwerk/build/Makefile.in index 32e58f041ff..cd0b1c43b77 100644 --- a/mozilla/netwerk/build/Makefile.in +++ b/mozilla/netwerk/build/Makefile.in @@ -138,3 +138,5 @@ OS_LIBS += -lwsock32 endif OS_LIBS += $(call EXPAND_LIBNAME,ole32 shell32) endif + +DEFINES += -DIMPL_NS_NET diff --git a/mozilla/netwerk/build/nsNetModule.cpp b/mozilla/netwerk/build/nsNetModule.cpp index a416f85042f..55b7d6f1cbb 100644 --- a/mozilla/netwerk/build/nsNetModule.cpp +++ b/mozilla/netwerk/build/nsNetModule.cpp @@ -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) diff --git a/mozilla/netwerk/cache/Makefile.in b/mozilla/netwerk/cache/Makefile.in index ef18c95ddef..db709a3a56b 100644 --- a/mozilla/netwerk/cache/Makefile.in +++ b/mozilla/netwerk/cache/Makefile.in @@ -47,3 +47,4 @@ DIRS = public src include $(topsrcdir)/config/rules.mk +DEFINES += -DIMPL_NS_NET diff --git a/mozilla/netwerk/cache/public/Makefile.in b/mozilla/netwerk/cache/public/Makefile.in index dbe801f6d48..40b70c38e5d 100644 --- a/mozilla/netwerk/cache/public/Makefile.in +++ b/mozilla/netwerk/cache/public/Makefile.in @@ -57,3 +57,4 @@ XPIDLSRCS = \ include $(topsrcdir)/config/rules.mk +DEFINES += -DIMPL_NS_NET diff --git a/mozilla/netwerk/cache/src/Makefile.in b/mozilla/netwerk/cache/src/Makefile.in index c295d328ef2..2b5a04b62ce 100644 --- a/mozilla/netwerk/cache/src/Makefile.in +++ b/mozilla/netwerk/cache/src/Makefile.in @@ -92,3 +92,4 @@ include $(topsrcdir)/config/config.mk include $(topsrcdir)/config/rules.mk +DEFINES += -DIMPL_NS_NET diff --git a/mozilla/netwerk/cookie/Makefile.in b/mozilla/netwerk/cookie/Makefile.in index fc71ae923af..45d3d014eaa 100644 --- a/mozilla/netwerk/cookie/Makefile.in +++ b/mozilla/netwerk/cookie/Makefile.in @@ -50,3 +50,5 @@ DIRS += src endif include $(topsrcdir)/config/rules.mk + +DEFINES += -DIMPL_NS_NET diff --git a/mozilla/netwerk/cookie/public/Makefile.in b/mozilla/netwerk/cookie/public/Makefile.in index c8b7ca3e1c0..3e458bcd96e 100644 --- a/mozilla/netwerk/cookie/public/Makefile.in +++ b/mozilla/netwerk/cookie/public/Makefile.in @@ -60,3 +60,5 @@ XPIDLSRCS = \ $(NULL) include $(topsrcdir)/config/rules.mk + +DEFINES += -DIMPL_NS_NET diff --git a/mozilla/netwerk/cookie/src/Makefile.in b/mozilla/netwerk/cookie/src/Makefile.in index 2bef4e0cc73..398af493d1e 100644 --- a/mozilla/netwerk/cookie/src/Makefile.in +++ b/mozilla/netwerk/cookie/src/Makefile.in @@ -58,3 +58,5 @@ CPPSRCS = \ $(NULL) include $(topsrcdir)/config/rules.mk + +DEFINES += -DIMPL_NS_NET diff --git a/mozilla/netwerk/dns/Makefile.in b/mozilla/netwerk/dns/Makefile.in index 94ab7ccbbb6..7cb9e164e6b 100644 --- a/mozilla/netwerk/dns/Makefile.in +++ b/mozilla/netwerk/dns/Makefile.in @@ -46,3 +46,4 @@ DIRS = public src include $(topsrcdir)/config/rules.mk +DEFINES += -DIMPL_NS_NET diff --git a/mozilla/netwerk/dns/public/Makefile.in b/mozilla/netwerk/dns/public/Makefile.in index 952d9cc3866..1fcde9eafa6 100644 --- a/mozilla/netwerk/dns/public/Makefile.in +++ b/mozilla/netwerk/dns/public/Makefile.in @@ -56,3 +56,5 @@ XPIDLSRCS = \ $(NULL) include $(topsrcdir)/config/rules.mk + +DEFINES += -DIMPL_NS_NET diff --git a/mozilla/netwerk/dns/src/Makefile.in b/mozilla/netwerk/dns/src/Makefile.in index 45bf63a1879..e481ab14022 100644 --- a/mozilla/netwerk/dns/src/Makefile.in +++ b/mozilla/netwerk/dns/src/Makefile.in @@ -68,3 +68,5 @@ CSRCS = race.c \ FORCE_STATIC_LIB = 1 include $(topsrcdir)/config/rules.mk + +DEFINES += -DIMPL_NS_NET diff --git a/mozilla/netwerk/mime/Makefile.in b/mozilla/netwerk/mime/Makefile.in index 34f76fdd6b5..69a202dab12 100644 --- a/mozilla/netwerk/mime/Makefile.in +++ b/mozilla/netwerk/mime/Makefile.in @@ -47,3 +47,4 @@ DIRS = public src include $(topsrcdir)/config/rules.mk +DEFINES += -DIMPL_NS_NET diff --git a/mozilla/netwerk/mime/public/Makefile.in b/mozilla/netwerk/mime/public/Makefile.in index f80b206e1b8..faa67602101 100644 --- a/mozilla/netwerk/mime/public/Makefile.in +++ b/mozilla/netwerk/mime/public/Makefile.in @@ -61,3 +61,4 @@ EXPORTS = \ include $(topsrcdir)/config/rules.mk +DEFINES += -DIMPL_NS_NET diff --git a/mozilla/netwerk/mime/src/Makefile.in b/mozilla/netwerk/mime/src/Makefile.in index 4c0842d30c2..002ce56985c 100644 --- a/mozilla/netwerk/mime/src/Makefile.in +++ b/mozilla/netwerk/mime/src/Makefile.in @@ -61,3 +61,4 @@ FORCE_STATIC_LIB = 1 include $(topsrcdir)/config/rules.mk +DEFINES += -DIMPL_NS_NET diff --git a/mozilla/netwerk/protocol/Makefile.in b/mozilla/netwerk/protocol/Makefile.in index 66ad4b5c40c..89e07984bb2 100644 --- a/mozilla/netwerk/protocol/Makefile.in +++ b/mozilla/netwerk/protocol/Makefile.in @@ -54,3 +54,5 @@ DIRS = about \ $(NULL) include $(topsrcdir)/config/rules.mk + +DEFINES += -DIMPL_NS_NET diff --git a/mozilla/netwerk/protocol/about/Makefile.in b/mozilla/netwerk/protocol/about/Makefile.in index 99899581691..ba7e16adccf 100644 --- a/mozilla/netwerk/protocol/about/Makefile.in +++ b/mozilla/netwerk/protocol/about/Makefile.in @@ -46,3 +46,4 @@ DIRS = public src include $(topsrcdir)/config/rules.mk +DEFINES += -DIMPL_NS_NET diff --git a/mozilla/netwerk/protocol/about/public/Makefile.in b/mozilla/netwerk/protocol/about/public/Makefile.in index d85ea96a50d..6f887ac3151 100644 --- a/mozilla/netwerk/protocol/about/public/Makefile.in +++ b/mozilla/netwerk/protocol/about/public/Makefile.in @@ -50,3 +50,4 @@ XPIDLSRCS = nsIAboutModule.idl include $(topsrcdir)/config/rules.mk +DEFINES += -DIMPL_NS_NET diff --git a/mozilla/netwerk/protocol/about/src/Makefile.in b/mozilla/netwerk/protocol/about/src/Makefile.in index 37e1ccea698..ea3f2876291 100644 --- a/mozilla/netwerk/protocol/about/src/Makefile.in +++ b/mozilla/netwerk/protocol/about/src/Makefile.in @@ -68,3 +68,5 @@ CPPSRCS = \ FORCE_STATIC_LIB = 1 include $(topsrcdir)/config/rules.mk + +DEFINES += -DIMPL_NS_NET diff --git a/mozilla/netwerk/protocol/file/Makefile.in b/mozilla/netwerk/protocol/file/Makefile.in index 99899581691..ba7e16adccf 100644 --- a/mozilla/netwerk/protocol/file/Makefile.in +++ b/mozilla/netwerk/protocol/file/Makefile.in @@ -46,3 +46,4 @@ DIRS = public src include $(topsrcdir)/config/rules.mk +DEFINES += -DIMPL_NS_NET diff --git a/mozilla/netwerk/protocol/file/public/Makefile.in b/mozilla/netwerk/protocol/file/public/Makefile.in index 408968b7247..fc5d916aa6d 100644 --- a/mozilla/netwerk/protocol/file/public/Makefile.in +++ b/mozilla/netwerk/protocol/file/public/Makefile.in @@ -53,3 +53,4 @@ XPIDLSRCS = \ include $(topsrcdir)/config/rules.mk +DEFINES += -DIMPL_NS_NET diff --git a/mozilla/netwerk/protocol/file/src/Makefile.in b/mozilla/netwerk/protocol/file/src/Makefile.in index ce232d7b6b4..0a492326596 100644 --- a/mozilla/netwerk/protocol/file/src/Makefile.in +++ b/mozilla/netwerk/protocol/file/src/Makefile.in @@ -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 diff --git a/mozilla/netwerk/protocol/file/src/nsFileChannel.cpp b/mozilla/netwerk/protocol/file/src/nsFileChannel.cpp index a9fb173f611..411369e7655 100644 --- a/mozilla/netwerk/protocol/file/src/nsFileChannel.cpp +++ b/mozilla/netwerk/protocol/file/src/nsFileChannel.cpp @@ -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 diff --git a/mozilla/netwerk/protocol/file/src/nsFileChannel.h b/mozilla/netwerk/protocol/file/src/nsFileChannel.h index 7a71f050042..3faec75d5b1 100644 --- a/mozilla/netwerk/protocol/file/src/nsFileChannel.h +++ b/mozilla/netwerk/protocol/file/src/nsFileChannel.h @@ -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 diff --git a/mozilla/netwerk/protocol/ftp/Makefile.in b/mozilla/netwerk/protocol/ftp/Makefile.in index 99899581691..ba7e16adccf 100644 --- a/mozilla/netwerk/protocol/ftp/Makefile.in +++ b/mozilla/netwerk/protocol/ftp/Makefile.in @@ -46,3 +46,4 @@ DIRS = public src include $(topsrcdir)/config/rules.mk +DEFINES += -DIMPL_NS_NET diff --git a/mozilla/netwerk/protocol/ftp/public/Makefile.in b/mozilla/netwerk/protocol/ftp/public/Makefile.in index 7b5565e3849..c1fdcb30d85 100644 --- a/mozilla/netwerk/protocol/ftp/public/Makefile.in +++ b/mozilla/netwerk/protocol/ftp/public/Makefile.in @@ -54,3 +54,4 @@ EXPORTS = ftpCore.h include $(topsrcdir)/config/rules.mk +DEFINES += -DIMPL_NS_NET diff --git a/mozilla/netwerk/protocol/ftp/src/Makefile.in b/mozilla/netwerk/protocol/ftp/src/Makefile.in index dc012cd4990..c62230d60b5 100644 --- a/mozilla/netwerk/protocol/ftp/src/Makefile.in +++ b/mozilla/netwerk/protocol/ftp/src/Makefile.in @@ -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 diff --git a/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.cpp b/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.cpp index 814c26bf18f..6737ad04243 100644 --- a/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.cpp +++ b/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.cpp @@ -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; diff --git a/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.h b/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.h index e4b67ad3d03..6d6de4098ac 100644 --- a/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.h +++ b/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.h @@ -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 mIOService; - nsCOMPtr mProperties; - + nsCOMPtr mCacheSession; nsCOMPtr mCacheEntry; nsCOMPtr mProxyInfo; diff --git a/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp b/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp index a8e7ddc1785..590eb75ab93 100644 --- a/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp +++ b/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp @@ -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 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 psink(do_QueryInterface(mChannel)); - nsRefPtr fwd(new TransportEventForwarder(psink)); + nsRefPtr 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 asyncObserver = do_QueryInterface(mChannel); - nsCOMPtr arg = do_QueryInterface(mChannel); + nsCOMPtr 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 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 converterListener; - nsCOMPtr listener = do_QueryInterface(mChannel); nsCOMPtr 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)) { diff --git a/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.h b/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.h index 65696a7a90c..09d11cd4ee8 100644 --- a/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.h +++ b/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.h @@ -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 mChannel; // our owning FTP channel we pass through our events + nsRefPtr mChannel; // our owning FTP channel we pass through our events nsCOMPtr mProxyInfo; // ****** connection cache vars diff --git a/mozilla/netwerk/protocol/http/Makefile.in b/mozilla/netwerk/protocol/http/Makefile.in index 99899581691..ba7e16adccf 100644 --- a/mozilla/netwerk/protocol/http/Makefile.in +++ b/mozilla/netwerk/protocol/http/Makefile.in @@ -46,3 +46,4 @@ DIRS = public src include $(topsrcdir)/config/rules.mk +DEFINES += -DIMPL_NS_NET diff --git a/mozilla/netwerk/protocol/http/public/Makefile.in b/mozilla/netwerk/protocol/http/public/Makefile.in index c23e12467fe..e24b43e9a2c 100644 --- a/mozilla/netwerk/protocol/http/public/Makefile.in +++ b/mozilla/netwerk/protocol/http/public/Makefile.in @@ -61,3 +61,5 @@ XPIDLSRCS = \ $(NULL) include $(topsrcdir)/config/rules.mk + +DEFINES += -DIMPL_NS_NET diff --git a/mozilla/netwerk/protocol/http/src/Makefile.in b/mozilla/netwerk/protocol/http/src/Makefile.in index d82c92631b2..d2069270cac 100644 --- a/mozilla/netwerk/protocol/http/src/Makefile.in +++ b/mozilla/netwerk/protocol/http/src/Makefile.in @@ -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 diff --git a/mozilla/netwerk/protocol/http/src/nsHttpChannel.cpp b/mozilla/netwerk/protocol/http/src/nsHttpChannel.cpp index c2ea101f655..3e01b1bf17f 100644 --- a/mozilla/netwerk/protocol/http/src/nsHttpChannel.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHttpChannel.cpp @@ -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 //----------------------------------------------------------------------------- +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 oldProps = do_QueryInterface(mProperties); - nsCOMPtr newProps = do_QueryInterface(newChannel); - if (newProps) { - PRUint32 count; - char **keys; - if (NS_SUCCEEDED(oldProps->GetKeys(&count, &keys))) { - nsCOMPtr val; - for (PRUint32 i=0; iGet(keys[i], - NS_GET_IID(nsISupports), - getter_AddRefs(val)); - newProps->Set(keys[i], val); - } - NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, keys); - } - } - } + nsCOMPtr 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 diff --git a/mozilla/netwerk/protocol/http/src/nsHttpChannel.h b/mozilla/netwerk/protocol/http/src/nsHttpChannel.h index bae842191c1..678ab329b6a 100644 --- a/mozilla/netwerk/protocol/http/src/nsHttpChannel.h +++ b/mozilla/netwerk/protocol/http/src/nsHttpChannel.h @@ -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 mProperties; - // cache specific data nsCOMPtr mCacheEntry; nsCOMPtr mCachePump; diff --git a/mozilla/netwerk/protocol/res/Makefile.in b/mozilla/netwerk/protocol/res/Makefile.in index 99899581691..ba7e16adccf 100644 --- a/mozilla/netwerk/protocol/res/Makefile.in +++ b/mozilla/netwerk/protocol/res/Makefile.in @@ -46,3 +46,4 @@ DIRS = public src include $(topsrcdir)/config/rules.mk +DEFINES += -DIMPL_NS_NET diff --git a/mozilla/netwerk/protocol/res/public/Makefile.in b/mozilla/netwerk/protocol/res/public/Makefile.in index 6928851c945..8064094017c 100644 --- a/mozilla/netwerk/protocol/res/public/Makefile.in +++ b/mozilla/netwerk/protocol/res/public/Makefile.in @@ -52,3 +52,4 @@ XPIDLSRCS = \ include $(topsrcdir)/config/rules.mk +DEFINES += -DIMPL_NS_NET diff --git a/mozilla/netwerk/protocol/res/src/Makefile.in b/mozilla/netwerk/protocol/res/src/Makefile.in index 6bdbff6f324..8fcb5bab311 100644 --- a/mozilla/netwerk/protocol/res/src/Makefile.in +++ b/mozilla/netwerk/protocol/res/src/Makefile.in @@ -67,3 +67,4 @@ LOCAL_INCLUDES = \ include $(topsrcdir)/config/rules.mk +DEFINES += -DIMPL_NS_NET diff --git a/mozilla/netwerk/resources/Makefile.in b/mozilla/netwerk/resources/Makefile.in index f7ddc4e1e65..cf7c1621d64 100644 --- a/mozilla/netwerk/resources/Makefile.in +++ b/mozilla/netwerk/resources/Makefile.in @@ -44,3 +44,4 @@ include $(DEPTH)/config/autoconf.mk include $(topsrcdir)/config/rules.mk +DEFINES += -DIMPL_NS_NET diff --git a/mozilla/netwerk/socket/Makefile.in b/mozilla/netwerk/socket/Makefile.in index 999e28ba599..e81c1e594ef 100755 --- a/mozilla/netwerk/socket/Makefile.in +++ b/mozilla/netwerk/socket/Makefile.in @@ -46,3 +46,4 @@ DIRS = base include $(topsrcdir)/config/rules.mk +DEFINES += -DIMPL_NS_NET diff --git a/mozilla/netwerk/socket/base/Makefile.in b/mozilla/netwerk/socket/base/Makefile.in index f88df2dc2ce..83028195607 100755 --- a/mozilla/netwerk/socket/base/Makefile.in +++ b/mozilla/netwerk/socket/base/Makefile.in @@ -72,3 +72,4 @@ FORCE_STATIC_LIB = 1 include $(topsrcdir)/config/rules.mk +DEFINES += -DIMPL_NS_NET diff --git a/mozilla/netwerk/streamconv/Makefile.in b/mozilla/netwerk/streamconv/Makefile.in index 3c05b0e5205..f652ad54cae 100644 --- a/mozilla/netwerk/streamconv/Makefile.in +++ b/mozilla/netwerk/streamconv/Makefile.in @@ -50,3 +50,4 @@ endif include $(topsrcdir)/config/rules.mk +DEFINES += -DIMPL_NS_NET diff --git a/mozilla/netwerk/streamconv/converters/Makefile.in b/mozilla/netwerk/streamconv/converters/Makefile.in index b752d322e5e..5ea82d04315 100644 --- a/mozilla/netwerk/streamconv/converters/Makefile.in +++ b/mozilla/netwerk/streamconv/converters/Makefile.in @@ -107,3 +107,4 @@ ifeq ($(OS_ARCH),WINNT) DEFINES += -DZLIB_DLL endif +DEFINES += -DIMPL_NS_NET diff --git a/mozilla/netwerk/streamconv/public/Makefile.in b/mozilla/netwerk/streamconv/public/Makefile.in index 7c2887743a0..d85f209c8c3 100644 --- a/mozilla/netwerk/streamconv/public/Makefile.in +++ b/mozilla/netwerk/streamconv/public/Makefile.in @@ -63,3 +63,4 @@ endif include $(topsrcdir)/config/rules.mk +DEFINES += -DIMPL_NS_NET diff --git a/mozilla/netwerk/streamconv/src/Makefile.in b/mozilla/netwerk/streamconv/src/Makefile.in index 8e85bf1be31..ecd642f964d 100644 --- a/mozilla/netwerk/streamconv/src/Makefile.in +++ b/mozilla/netwerk/streamconv/src/Makefile.in @@ -66,3 +66,5 @@ endif FORCE_STATIC_LIB = 1 include $(topsrcdir)/config/rules.mk + +DEFINES += -DIMPL_NS_NET diff --git a/mozilla/netwerk/streamconv/test/Makefile.in b/mozilla/netwerk/streamconv/test/Makefile.in index 68f4f7c1ee5..cd287365806 100644 --- a/mozilla/netwerk/streamconv/test/Makefile.in +++ b/mozilla/netwerk/streamconv/test/Makefile.in @@ -73,3 +73,4 @@ DEFINES += -DNGPREFS endif endif # WINNT +DEFINES += -DIMPL_NS_NET diff --git a/mozilla/netwerk/test/TestProtocols.cpp b/mozilla/netwerk/test/TestProtocols.cpp index e4631ae8e2c..27df53556c7 100644 --- a/mozilla/netwerk/test/TestProtocols.cpp +++ b/mozilla/netwerk/test/TestProtocols.cpp @@ -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 props = do_QueryInterface(request); + nsCOMPtr props = do_QueryInterface(request); if (props) { nsCOMPtr 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 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 httpChannelInt(do_QueryInterface(request)); if (httpChannelInt) { PRUint32 majorVer, minorVer; @@ -626,9 +640,11 @@ nsresult StartLoadingURL(const char* aUrlString) return rv; } - nsCOMPtr props = do_QueryInterface(pChannel); + nsCOMPtr 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")); } diff --git a/mozilla/xpinstall/src/nsInstallTrigger.cpp b/mozilla/xpinstall/src/nsInstallTrigger.cpp index 170af0f3414..fd7b7b5f10e 100644 --- a/mozilla/xpinstall/src/nsInstallTrigger.cpp +++ b/mozilla/xpinstall/src/nsInstallTrigger.cpp @@ -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 referringURI; - nsCOMPtr channelprops(do_QueryInterface(channel)); + nsCOMPtr 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; }