From 741b9ebc715614ebbfabe722ee85187ccbee0c7d Mon Sep 17 00:00:00 2001 From: "warren%netscape.com" Date: Thu, 24 Jun 1999 22:58:42 +0000 Subject: [PATCH] Added nsILoadGroup. Changed load attribute strategy to flags. git-svn-id: svn://10.0.0.236/trunk@36753 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/netwerk/base/public/makefile.win | 1 + mozilla/netwerk/base/public/nsIChannel.idl | 18 +- mozilla/netwerk/base/public/nsIIOService.idl | 9 + mozilla/netwerk/base/public/nsILoadGroup.idl | 79 +++++++ mozilla/netwerk/base/src/Makefile.in | 1 + mozilla/netwerk/base/src/makefile.win | 1 + mozilla/netwerk/base/src/nsIOService.cpp | 34 +-- mozilla/netwerk/base/src/nsIOService.h | 1 + mozilla/netwerk/base/src/nsLoadGroup.cpp | 197 ++++++++++++++++++ mozilla/netwerk/base/src/nsLoadGroup.h | 88 ++++++++ .../netwerk/base/src/nsSocketTransport.cpp | 9 +- mozilla/netwerk/base/src/nsSocketTransport.h | 6 +- mozilla/netwerk/base/src/nsStandardUrl.h | 11 +- mozilla/netwerk/build/nsNetFactory.cpp | 5 + .../protocol/file/src/nsFileChannel.cpp | 11 +- .../netwerk/protocol/file/src/nsFileChannel.h | 6 +- .../netwerk/protocol/ftp/src/nsFTPChannel.cpp | 12 +- .../netwerk/protocol/ftp/src/nsFTPChannel.h | 6 +- .../protocol/http/public/nsIHTTPChannel.idl | 10 +- .../protocol/http/src/nsHTTPChannel.cpp | 39 +--- .../netwerk/protocol/http/src/nsHTTPChannel.h | 12 +- 21 files changed, 450 insertions(+), 106 deletions(-) create mode 100644 mozilla/netwerk/base/public/nsILoadGroup.idl create mode 100644 mozilla/netwerk/base/src/nsLoadGroup.cpp create mode 100644 mozilla/netwerk/base/src/nsLoadGroup.h diff --git a/mozilla/netwerk/base/public/makefile.win b/mozilla/netwerk/base/public/makefile.win index 7bc5d3ecfac..c7fd6e7834d 100644 --- a/mozilla/netwerk/base/public/makefile.win +++ b/mozilla/netwerk/base/public/makefile.win @@ -48,6 +48,7 @@ XPIDLSRCS = \ .\nsINetModRegEntry.idl \ .\nsINetModuleMgr.idl \ .\nsINetNotify.idl \ + .\nsILoadGroup.idl \ $(NULL) include <$(DEPTH)/config/rules.mak> diff --git a/mozilla/netwerk/base/public/nsIChannel.idl b/mozilla/netwerk/base/public/nsIChannel.idl index 0207cf48e8d..b2e2601fea9 100644 --- a/mozilla/netwerk/base/public/nsIChannel.idl +++ b/mozilla/netwerk/base/public/nsIChannel.idl @@ -88,10 +88,22 @@ interface nsIChannel : nsIRequest in nsIStreamObserver observer); /** - * Setting this attribute causes the loading process to not deliver status - * notifications to the program performing the load. + * Load attribute flags. These may be or'd together. + * + * Note that more will follow for each protocol's implementation of a channel, + * although channel writers have to be careful to not let the flag bits + * overlap. Otherwise, users won't be able to create a single flag word + * of load attributes that applies to a number of different channel types. */ - attribute boolean LoadQuiet; + const unsigned long LOAD_NORMAL = 0; /* no special load attributes -- use defaults */ + const unsigned long LOAD_QUIET = 1 << 0; /* don't deliver status notifications to the nsIProgressEventSink */ + + /** + * Accesses the load attributes for the channel. E.g. setting the load + * attributes with the LOAD_QUIET bit set causes the loading process to + * not deliver status notifications to the program performing the load. + */ + attribute unsigned long LoadAttributes; /** * Returns the content MIME type of the channel if available. Note that the diff --git a/mozilla/netwerk/base/public/nsIIOService.idl b/mozilla/netwerk/base/public/nsIIOService.idl index 14b06e1e87e..a6ebfb16a20 100644 --- a/mozilla/netwerk/base/public/nsIIOService.idl +++ b/mozilla/netwerk/base/public/nsIIOService.idl @@ -28,6 +28,7 @@ interface nsIEventQueue; interface nsIBufferInputStream; interface nsIBufferOutputStream; interface nsIFileChannel; +interface nsILoadGroup; [scriptable, uuid(01f0a170-1881-11d3-9337-00104ba0fd40)] interface nsIIOService : nsISupports @@ -130,6 +131,14 @@ interface nsIIOService : nsISupports * then uses it to construct a file channel from a native path string. */ nsIFileChannel NewChannelFromNativePath(in string nativePath); + + /** + * Returns a new load group. Load groups can be used to manage collections + * of channels so that they can be reloaded or canceled en mass. Note that + * their use is not required by other parts of the system, they are primarily + * a convenience for the caller. + */ + nsILoadGroup NewLoadGroup(); }; %{C++ diff --git a/mozilla/netwerk/base/public/nsILoadGroup.idl b/mozilla/netwerk/base/public/nsILoadGroup.idl new file mode 100644 index 00000000000..3bdc75b1b9b --- /dev/null +++ b/mozilla/netwerk/base/public/nsILoadGroup.idl @@ -0,0 +1,79 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#include "nsIRequest.idl" + +interface nsIChannel; +interface nsISimpleEnumerator; + +[scriptable, uuid(19845248-29ab-11d3-8cce-0060b0fc14a3)] +interface nsILoadGroup : nsIRequest +{ + /** + * Accesses the default load attributes for the group, returned as + * a flag word. Setting the default load attributes will cause them + * to be applied to each new channel inserted into the group. + */ + attribute unsigned long DefaultLoadAttributes; + + /** + * Adds a new channel to the group. This will cause the default load + * attributes to be applied to that channel. + */ + void AddChannel(in nsIChannel channel); + + /** + * Removes a channel from the group. + */ + void RemoveChannel(in nsIChannel channel); + + /** + * Returns the channels contained directly in this group. + * Enumerator element type: nsIChannel. + */ + readonly attribute nsISimpleEnumerator Channels; + + /** + * Adds a new sub-group to the group. + */ + void AddSubGroup(in nsILoadGroup group); + + /** + * Removes a sub-group from the group. + */ + void RemoveSubGroup(in nsILoadGroup group); + + /** + * Returns the sub-groups of a group. + * Enumerator element type: nsILoadGroup. + */ + readonly attribute nsISimpleEnumerator SubGroups; + +}; + +%{C++ + +#define NS_LOADGROUP_CID \ +{ /* e1c61582-2a84-11d3-8cce-0060b0fc14a3 */ \ + 0xe1c61582, \ + 0x2a84, \ + 0x11d3, \ + {0x8c, 0xce, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \ +} \ + +%} diff --git a/mozilla/netwerk/base/src/Makefile.in b/mozilla/netwerk/base/src/Makefile.in index e036534d2a0..b18eea4127f 100644 --- a/mozilla/netwerk/base/src/Makefile.in +++ b/mozilla/netwerk/base/src/Makefile.in @@ -34,6 +34,7 @@ CPPSRCS = \ nsStandardUrl.cpp \ nsNetModuleMgr.cpp \ nsNetModRegEntry.cpp \ + nsLoadGroup.cpp \ $(NULL) include $(topsrcdir)/config/config.mk diff --git a/mozilla/netwerk/base/src/makefile.win b/mozilla/netwerk/base/src/makefile.win index 75afd52edf3..8645515c175 100644 --- a/mozilla/netwerk/base/src/makefile.win +++ b/mozilla/netwerk/base/src/makefile.win @@ -36,6 +36,7 @@ CPP_OBJS = \ .\$(OBJDIR)\nsStandardUrl.obj \ .\$(OBJDIR)\nsNetModuleMgr.obj \ .\$(OBJDIR)\nsNetModRegEntry.obj \ + .\$(OBJDIR)\nsLoadGroup.obj \ $(NULL) INCS = $(INCS) \ diff --git a/mozilla/netwerk/base/src/nsIOService.cpp b/mozilla/netwerk/base/src/nsIOService.cpp index 554a01a5ceb..a76f79a8aa9 100644 --- a/mozilla/netwerk/base/src/nsIOService.cpp +++ b/mozilla/netwerk/base/src/nsIOService.cpp @@ -30,6 +30,7 @@ #include "prmem.h" // for PR_Malloc #include // for isalpha #include "nsIFileProtocolHandler.h" // for NewChannelFromNativePath +#include "nsLoadGroup.h" static NS_DEFINE_CID(kFileTransportService, NS_FILETRANSPORTSERVICE_CID); static NS_DEFINE_CID(kEventQueueService, NS_EVENTQUEUESERVICE_CID); @@ -324,36 +325,13 @@ nsIOService::NewChannelFromNativePath(const char *nativePath, nsIFileChannel **r return NS_OK; } -//////////////////////////////////////////////////////////////////////////////// -// HELPER ROUTINES -//////////////////////////////////////////////////////////////////////////////// -#if 0 -static NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID); -static NS_DEFINE_IID(kINetServiceIID, NS_INETSERVICE_IID); - -nsresult NS_NewURI(nsIURI** aInstancePtrResult, - const char *aSpec, - nsIURI* aBaseURI) +NS_IMETHODIMP +nsIOService::NewLoadGroup(nsILoadGroup **result) { - NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); - if (nsnull == aInstancePtrResult) { - return NS_ERROR_NULL_POINTER; - } - - nsINetService *inet = nsnull; - nsresult rv = nsServiceManager::GetService(kNetServiceCID, - kINetServiceIID, - (nsISupports **)&inet); - if (NS_FAILED(rv)) return rv; - - rv = inet->NewURI(aSpec, aInstancePtrResult, aBaseURI); - - if (NS_FAILED(rv)) return rv; - - nsServiceManager::ReleaseService(kNetServiceCID, inet); - return rv; + return nsLoadGroup::Create(nsnull, nsILoadGroup::GetIID(), + (void**)result); } -#endif + //////////////////////////////////////////////////////////////////////////////// diff --git a/mozilla/netwerk/base/src/nsIOService.h b/mozilla/netwerk/base/src/nsIOService.h index 68ebe8c46e8..9ca1857ef55 100644 --- a/mozilla/netwerk/base/src/nsIOService.h +++ b/mozilla/netwerk/base/src/nsIOService.h @@ -52,6 +52,7 @@ public: NS_IMETHOD NewAsyncStreamListener(nsIStreamListener *receiver, nsIEventQueue *eventQueue, nsIStreamListener **_retval); NS_IMETHOD NewSyncStreamListener(nsIBufferInputStream **inStream, nsIBufferOutputStream **outStream, nsIStreamListener **_retval); NS_IMETHOD NewChannelFromNativePath(const char *nativePath, nsIFileChannel **_retval); + NS_IMETHOD NewLoadGroup(nsILoadGroup **result); // nsIOService methods: nsIOService(); diff --git a/mozilla/netwerk/base/src/nsLoadGroup.cpp b/mozilla/netwerk/base/src/nsLoadGroup.cpp new file mode 100644 index 00000000000..388b99b5936 --- /dev/null +++ b/mozilla/netwerk/base/src/nsLoadGroup.cpp @@ -0,0 +1,197 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#include "nsLoadGroup.h" +#include "nsIIOService.h" +#include "nsIChannel.h" +#include "nsIServiceManager.h" +#include "nsISupportsArray.h" +#include "nsEnumeratorUtils.h" + +static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); + +//////////////////////////////////////////////////////////////////////////////// + +nsLoadGroup::nsLoadGroup(nsISupports* outer) + : mChannels(nsnull), mSubGroups(nsnull), + mDefaultLoadAttributes(nsIChannel::LOAD_NORMAL) +{ + NS_INIT_AGGREGATED(outer); +} + +nsLoadGroup::~nsLoadGroup() +{ + NS_IF_RELEASE(mChannels); + NS_IF_RELEASE(mSubGroups); +} + +NS_METHOD +nsLoadGroup::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult) +{ + nsLoadGroup* group = new nsLoadGroup(aOuter); + if (group == nsnull) + return NS_ERROR_OUT_OF_MEMORY; + NS_ADDREF(group); + nsresult rv = group->QueryInterface(aIID, aResult); + NS_RELEASE(group); + return rv; +} + +NS_IMPL_AGGREGATED(nsLoadGroup); + +NS_IMETHODIMP +nsLoadGroup::AggregatedQueryInterface(const nsIID& aIID, void** aInstancePtr) +{ + NS_ASSERTION(aInstancePtr, "no instance pointer"); + if (aIID.Equals(nsILoadGroup::GetIID()) || + aIID.Equals(nsIRequest::GetIID()) || + aIID.Equals(nsISupports::GetIID())) { + *aInstancePtr = NS_STATIC_CAST(nsILoadGroup*, this); + NS_ADDREF_THIS(); + return NS_OK; + } + return NS_NOINTERFACE; +} + +//////////////////////////////////////////////////////////////////////////////// +// nsIRequest methods: + +nsresult +nsLoadGroup::Iterate(IterateFun fun) +{ + nsresult rv; + PRUint32 i; + PRUint32 count; + rv = mChannels->Count(&count); + if (NS_FAILED(rv)) return rv; + for (i = 0; i < count; i++) { + nsIRequest* req = NS_STATIC_CAST(nsIRequest*, mChannels->ElementAt(i)); + if (req == nsnull) + return NS_ERROR_FAILURE; + rv = fun(req); + NS_RELEASE(req); + if (NS_FAILED(rv)) return rv; + } + + rv = mSubGroups->Count(&count); + if (NS_FAILED(rv)) return rv; + for (i = 0; i < count; i++) { + nsIRequest* req = NS_STATIC_CAST(nsIRequest*, mSubGroups->ElementAt(i)); + if (req == nsnull) + return NS_ERROR_FAILURE; + rv = fun(req); + NS_RELEASE(req); + if (NS_FAILED(rv)) return rv; + } + return NS_OK; +} + +static nsresult +CancelFun(nsIRequest* req) +{ + return req->Cancel(); +} + +NS_IMETHODIMP +nsLoadGroup::Cancel() +{ + return Iterate(CancelFun); +} + +static nsresult +SuspendFun(nsIRequest* req) +{ + return req->Suspend(); +} + +NS_IMETHODIMP +nsLoadGroup::Suspend() +{ + return Iterate(SuspendFun); +} + +static nsresult +ResumeFun(nsIRequest* req) +{ + return req->Resume(); +} + +NS_IMETHODIMP +nsLoadGroup::Resume() +{ + return Iterate(ResumeFun); +} + +//////////////////////////////////////////////////////////////////////////////// +// nsILoadGroup methods: + +NS_IMETHODIMP +nsLoadGroup::GetDefaultLoadAttributes(PRUint32 *aDefaultLoadAttributes) +{ + *aDefaultLoadAttributes = mDefaultLoadAttributes; + return NS_OK; +} + +NS_IMETHODIMP +nsLoadGroup::SetDefaultLoadAttributes(PRUint32 aDefaultLoadAttributes) +{ + mDefaultLoadAttributes = aDefaultLoadAttributes; + return NS_OK; +} + +NS_IMETHODIMP +nsLoadGroup::AddChannel(nsIChannel *channel) +{ + nsresult rv = mChannels->AppendElement(channel); + if (NS_FAILED(rv)) return rv; + + rv = channel->SetLoadAttributes(mDefaultLoadAttributes); + return NS_OK; +} + +NS_IMETHODIMP +nsLoadGroup::RemoveChannel(nsIChannel *channel) +{ + return mChannels->RemoveElement(channel); +} + +NS_IMETHODIMP +nsLoadGroup::GetChannels(nsISimpleEnumerator * *aChannels) +{ + return NS_NewArrayEnumerator(aChannels, mChannels); +} + +NS_IMETHODIMP +nsLoadGroup::AddSubGroup(nsILoadGroup *group) +{ + return mSubGroups->AppendElement(group); +} + +NS_IMETHODIMP +nsLoadGroup::RemoveSubGroup(nsILoadGroup *group) +{ + return mSubGroups->RemoveElement(group); +} + +NS_IMETHODIMP +nsLoadGroup::GetSubGroups(nsISimpleEnumerator * *aSubGroups) +{ + return NS_NewArrayEnumerator(aSubGroups, mSubGroups); +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/mozilla/netwerk/base/src/nsLoadGroup.h b/mozilla/netwerk/base/src/nsLoadGroup.h new file mode 100644 index 00000000000..eb8f671922e --- /dev/null +++ b/mozilla/netwerk/base/src/nsLoadGroup.h @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsLoadGroup_h__ +#define nsLoadGroup_h__ + +#include "nsILoadGroup.h" +#include "nsAgg.h" + +class nsISupportsArray; + +class nsLoadGroup : public nsILoadGroup +{ +public: + NS_DECL_AGGREGATED + + //////////////////////////////////////////////////////////////////////////// + // nsIRequest methods: + + /* void Cancel (); */ + NS_IMETHOD Cancel(); + + /* void Suspend (); */ + NS_IMETHOD Suspend(); + + /* void Resume (); */ + NS_IMETHOD Resume(); + + //////////////////////////////////////////////////////////////////////////// + // nsILoadGroup methods: + + /* attribute unsigned long DefaultLoadAttributes; */ + NS_IMETHOD GetDefaultLoadAttributes(PRUint32 *aDefaultLoadAttributes); + NS_IMETHOD SetDefaultLoadAttributes(PRUint32 aDefaultLoadAttributes); + + /* void AddChannel (in nsIChannel channel); */ + NS_IMETHOD AddChannel(nsIChannel *channel); + + /* void RemoveChannel (in nsIChannel channel); */ + NS_IMETHOD RemoveChannel(nsIChannel *channel); + + /* readonly attribute nsISimpleEnumerator Channels; */ + NS_IMETHOD GetChannels(nsISimpleEnumerator * *aChannels); + + /* void AddSubGroup (in nsILoadGroup group); */ + NS_IMETHOD AddSubGroup(nsILoadGroup *group); + + /* void RemoveSubGroup (in nsILoadGroup group); */ + NS_IMETHOD RemoveSubGroup(nsILoadGroup *group); + + /* readonly attribute nsISimpleEnumerator SubGroups; */ + NS_IMETHOD GetSubGroups(nsISimpleEnumerator * *aSubGroups); + + //////////////////////////////////////////////////////////////////////////// + // nsLoadGroup methods: + + nsLoadGroup(nsISupports* outer); + virtual ~nsLoadGroup(); + + static NS_METHOD + Create(nsISupports *aOuter, REFNSIID aIID, void **aResult); + +protected: + typedef nsresult (*IterateFun)(nsIRequest* request); + nsresult Iterate(IterateFun fun); + +protected: + PRUint32 mDefaultLoadAttributes; + nsISupportsArray* mChannels; + nsISupportsArray* mSubGroups; +}; + +#endif // nsLoadGroup_h__ diff --git a/mozilla/netwerk/base/src/nsSocketTransport.cpp b/mozilla/netwerk/base/src/nsSocketTransport.cpp index f378acfb863..6d3c821ed0e 100644 --- a/mozilla/netwerk/base/src/nsSocketTransport.cpp +++ b/mozilla/netwerk/base/src/nsSocketTransport.cpp @@ -147,6 +147,7 @@ nsSocketTransport::nsSocketTransport() mWriteCount = 0; mSourceOffset = 0; mService = nsnull; + mLoadAttributes = LOAD_NORMAL; // // Set up Internet defaults... @@ -1241,16 +1242,16 @@ nsSocketTransport::OpenOutputStream(PRUint32 startPosition, nsIOutputStream* *re } NS_IMETHODIMP -nsSocketTransport::GetLoadQuiet(PRBool *aLoadQuiet) +nsSocketTransport::GetLoadAttributes(PRUint32 *aLoadAttributes) { - *aLoadQuiet = mLoadQuiet; + *aLoadAttributes = mLoadAttributes; return NS_OK; } NS_IMETHODIMP -nsSocketTransport::SetLoadQuiet(PRBool aLoadQuiet) +nsSocketTransport::SetLoadAttributes(PRUint32 aLoadAttributes) { - mLoadQuiet = aLoadQuiet; + mLoadAttributes = aLoadAttributes; return NS_OK; } diff --git a/mozilla/netwerk/base/src/nsSocketTransport.h b/mozilla/netwerk/base/src/nsSocketTransport.h index ba2339dfada..072911b4cbf 100644 --- a/mozilla/netwerk/base/src/nsSocketTransport.h +++ b/mozilla/netwerk/base/src/nsSocketTransport.h @@ -91,8 +91,8 @@ public: nsISupports *ctxt, nsIEventQueue *eventQueue, nsIStreamObserver *observer); - NS_IMETHOD GetLoadQuiet(PRBool *aLoadQuiet); - NS_IMETHOD SetLoadQuiet(PRBool aLoadQuiet); + NS_IMETHOD GetLoadAttributes(PRUint32 *aLoadAttributes); + NS_IMETHOD SetLoadAttributes(PRUint32 aLoadAttributes); NS_IMETHOD GetContentType(char * *aContentType); // nsIBufferObserver methods: @@ -153,7 +153,7 @@ protected: PRUint32 mSourceOffset; nsSocketTransportService* mService; - PRBool mLoadQuiet; + PRUint32 mLoadAttributes; }; diff --git a/mozilla/netwerk/base/src/nsStandardUrl.h b/mozilla/netwerk/base/src/nsStandardUrl.h index 4e3fa23b559..4fc0c8dfaf9 100644 --- a/mozilla/netwerk/base/src/nsStandardUrl.h +++ b/mozilla/netwerk/base/src/nsStandardUrl.h @@ -22,13 +22,12 @@ #include "nsIURL.h" #include "nsAgg.h" -// XXX regenerate: #define NS_THIS_STANDARDURL_IMPLEMENTATION_CID \ -{ /* 905ed480-f11f-11d2-9322-000000000000 */ \ - 0x905ed480, \ - 0xf11f, \ - 0x11d2, \ - {0x93, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} \ +{ /* e3939dc8-29ab-11d3-8cce-0060b0fc14a3 */ \ + 0xe3939dc8, \ + 0x29ab, \ + 0x11d3, \ + {0x8c, 0xce, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \ } class nsStandardURL : public nsIURI diff --git a/mozilla/netwerk/build/nsNetFactory.cpp b/mozilla/netwerk/build/nsNetFactory.cpp index 84e349cb321..eb01b6c7cd5 100644 --- a/mozilla/netwerk/build/nsNetFactory.cpp +++ b/mozilla/netwerk/build/nsNetFactory.cpp @@ -26,6 +26,7 @@ #include "nscore.h" #include "nsStandardUrl.h" #include "nsDnsService.h" +#include "nsLoadGroup.h" static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); @@ -34,6 +35,7 @@ static NS_DEFINE_CID(kStandardURLCID, NS_STANDARDURL_CID); static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID); static NS_DEFINE_CID(kExternalModuleManagerCID, NS_NETMODULEMGR_CID); static NS_DEFINE_CID(kDNSServiceCID, NS_DNSSERVICE_CID); +static NS_DEFINE_CID(kLoadGroupCID, NS_LOADGROUP_CID); //////////////////////////////////////////////////////////////////////////////// @@ -72,6 +74,9 @@ NSGetFactory(nsISupports* aServMgr, else if (aClass.Equals(kDNSServiceCID)) { rv = NS_NewGenericFactory(&fact, nsDNSService::Create); } + else if (aClass.Equals(kLoadGroupCID)) { + rv = NS_NewGenericFactory(&fact, nsLoadGroup::Create); + } else { rv = NS_ERROR_FAILURE; } diff --git a/mozilla/netwerk/protocol/file/src/nsFileChannel.cpp b/mozilla/netwerk/protocol/file/src/nsFileChannel.cpp index 777d2b3c58d..6c6876759d4 100644 --- a/mozilla/netwerk/protocol/file/src/nsFileChannel.cpp +++ b/mozilla/netwerk/protocol/file/src/nsFileChannel.cpp @@ -45,7 +45,8 @@ nsFileChannel::nsFileChannel() mContext(nsnull), mState(QUIESCENT), mSuspended(PR_FALSE), mFileStream(nsnull), mBufferInputStream(nsnull), mBufferOutputStream(nsnull), - mStatus(NS_OK), mHandler(nsnull), mSourceOffset(0) + mStatus(NS_OK), mHandler(nsnull), mSourceOffset(0), + mLoadAttributes(LOAD_NORMAL) { NS_INIT_REFCNT(); } @@ -418,16 +419,16 @@ nsFileChannel::AsyncWrite(nsIInputStream *fromStream, } NS_IMETHODIMP -nsFileChannel::GetLoadQuiet(PRBool *aLoadQuiet) +nsFileChannel::GetLoadAttributes(PRUint32 *aLoadAttributes) { - *aLoadQuiet = mLoadQuiet; + *aLoadAttributes = mLoadAttributes; return NS_OK; } NS_IMETHODIMP -nsFileChannel::SetLoadQuiet(PRBool aLoadQuiet) +nsFileChannel::SetLoadAttributes(PRUint32 aLoadAttributes) { - mLoadQuiet = aLoadQuiet; + mLoadAttributes = aLoadAttributes; return NS_OK; } diff --git a/mozilla/netwerk/protocol/file/src/nsFileChannel.h b/mozilla/netwerk/protocol/file/src/nsFileChannel.h index 11e6394078b..2a2e94dcd02 100644 --- a/mozilla/netwerk/protocol/file/src/nsFileChannel.h +++ b/mozilla/netwerk/protocol/file/src/nsFileChannel.h @@ -68,8 +68,8 @@ public: NS_IMETHOD AsyncWrite(nsIInputStream *fromStream, PRUint32 startPosition, PRInt32 writeCount, nsISupports *ctxt, nsIEventQueue *eventQueue, nsIStreamObserver *observer); /* attribute boolean LoadQuiet; */ - NS_IMETHOD GetLoadQuiet(PRBool *aLoadQuiet); - NS_IMETHOD SetLoadQuiet(PRBool aLoadQuiet); + NS_IMETHOD GetLoadAttributes(PRUint32 *aLoadAttributes); + NS_IMETHOD SetLoadAttributes(PRUint32 aLoadAttributes); /* readonly attribute string ContentType; */ NS_IMETHOD GetContentType(char * *aContentType); @@ -181,7 +181,7 @@ protected: PRInt32 mAmount; PRLock* mLock; - PRBool mLoadQuiet; + PRUint32 mLoadAttributes; }; #define NS_FILE_TRANSPORT_SEGMENT_SIZE (4*1024) diff --git a/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.cpp b/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.cpp index 0c425b2bada..1aaa7e68f9b 100644 --- a/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.cpp +++ b/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.cpp @@ -41,7 +41,9 @@ static NS_DEFINE_CID(kEventQueueService, NS_EVENTQUEUESERVICE_CID); // Client initiation is the most command case and is attempted first. nsFTPChannel::nsFTPChannel() - : mUrl(nsnull), mConnected(PR_FALSE), mListener(nsnull) { + : mUrl(nsnull), mConnected(PR_FALSE), mListener(nsnull), + mLoadAttributes(LOAD_NORMAL) +{ nsresult rv; @@ -187,16 +189,16 @@ nsFTPChannel::AsyncWrite(nsIInputStream *fromStream, } NS_IMETHODIMP -nsFTPChannel::GetLoadQuiet(PRBool *aLoadQuiet) +nsFTPChannel::GetLoadAttributes(PRUint32 *aLoadAttributes) { - *aLoadQuiet = mLoadQuiet; + *aLoadAttributes = mLoadAttributes; return NS_OK; } NS_IMETHODIMP -nsFTPChannel::SetLoadQuiet(PRBool aLoadQuiet) +nsFTPChannel::SetLoadAttributes(PRUint32 aLoadAttributes) { - mLoadQuiet = aLoadQuiet; + mLoadAttributes = aLoadAttributes; return NS_OK; } diff --git a/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.h b/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.h index 1cff37045b1..f63c9f02513 100644 --- a/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.h +++ b/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.h @@ -55,8 +55,8 @@ public: nsISupports *ctxt, nsIEventQueue *eventQueue, nsIStreamObserver *observer); - NS_IMETHOD GetLoadQuiet(PRBool *aLoadQuiet); - NS_IMETHOD SetLoadQuiet(PRBool aLoadQuiet); + NS_IMETHOD GetLoadAttributes(PRUint32 *aLoadAttributes); + NS_IMETHOD SetLoadAttributes(PRUint32 aLoadAttributes); NS_IMETHOD GetContentType(char * *aContentType); // nsIFTPChannel methods: @@ -98,7 +98,7 @@ protected: PRBool mConnected; nsIStreamListener* mListener; - PRBool mLoadQuiet; + PRUint32 mLoadAttributes; }; #endif /* nsFTPChannel_h___ */ diff --git a/mozilla/netwerk/protocol/http/public/nsIHTTPChannel.idl b/mozilla/netwerk/protocol/http/public/nsIHTTPChannel.idl index 888f1c47fa9..d52398fe426 100644 --- a/mozilla/netwerk/protocol/http/public/nsIHTTPChannel.idl +++ b/mozilla/netwerk/protocol/http/public/nsIHTTPChannel.idl @@ -24,6 +24,12 @@ interface nsIStreamListener; [scriptable, uuid(35c00430-1938-11d3-933a-000064657374)] interface nsIHTTPChannel : nsIChannel { + /** + * More load attributes for http. + */ + const unsigned long BYPASS_CACHE = 1 << 1; + const unsigned long BYPASS_PROXY = 1 << 2; + /* Request functions- These functions set/get parameters on the outbound request and may only @@ -49,10 +55,6 @@ interface nsIHTTPChannel : nsIChannel readonly attribute nsIHTTPEventSink EventSink; readonly attribute nsIStreamListener ResponseDataListener; - - attribute boolean BypassCache; - - attribute boolean BypassProxy; }; diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPChannel.cpp b/mozilla/netwerk/protocol/http/src/nsHTTPChannel.cpp index 306b53045c6..42f6aeceb29 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPChannel.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHTTPChannel.cpp @@ -52,7 +52,8 @@ nsHTTPChannel::nsHTTPChannel(nsIURI* i_URL, m_pEventSink(dont_QueryInterface(i_HTTPEventSink)), m_pResponse(nsnull), m_pEventQ(dont_QueryInterface(i_EQ)), - m_pResponseDataListener(nsnull) + m_pResponseDataListener(nsnull), + mLoadAttributes(LOAD_NORMAL) { NS_INIT_REFCNT(); } @@ -216,16 +217,16 @@ nsHTTPChannel::AsyncWrite(nsIInputStream *fromStream, } NS_IMETHODIMP -nsHTTPChannel::GetLoadQuiet(PRBool *aLoadQuiet) +nsHTTPChannel::GetLoadAttributes(PRUint32 *aLoadAttributes) { - *aLoadQuiet = mLoadQuiet; + *aLoadAttributes = mLoadAttributes; return NS_OK; } NS_IMETHODIMP -nsHTTPChannel::SetLoadQuiet(PRBool aLoadQuiet) +nsHTTPChannel::SetLoadAttributes(PRUint32 aLoadAttributes) { - mLoadQuiet = aLoadQuiet; + mLoadAttributes = aLoadAttributes; return NS_OK; } @@ -329,34 +330,6 @@ nsHTTPChannel::GetResponseDataListener(nsIStreamListener* *aListener) return rv; } -NS_IMETHODIMP -nsHTTPChannel::GetBypassCache(PRBool *aBypassCache) -{ - *aBypassCache = mBypassCache; - return NS_OK; -} - -NS_IMETHODIMP -nsHTTPChannel::SetBypassCache(PRBool aBypassCache) -{ - mBypassCache = aBypassCache; - return NS_OK; -} - -NS_IMETHODIMP -nsHTTPChannel::GetBypassProxy(PRBool *aBypassProxy) -{ - *aBypassProxy = mBypassProxy; - return NS_OK; -} - -NS_IMETHODIMP -nsHTTPChannel::SetBypassProxy(PRBool aBypassProxy) -{ - mBypassProxy = aBypassProxy; - return NS_OK; -} - static NS_DEFINE_IID(kProxyObjectManagerIID, NS_IPROXYEVENT_MANAGER_IID); static NS_DEFINE_CID(kEventQueueService, NS_EVENTQUEUESERVICE_CID); static NS_DEFINE_CID(kNetModuleMgrCID, NS_NETMODULEMGR_CID); diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPChannel.h b/mozilla/netwerk/protocol/http/src/nsHTTPChannel.h index dd77c708f96..78ef6c365ad 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPChannel.h +++ b/mozilla/netwerk/protocol/http/src/nsHTTPChannel.h @@ -74,8 +74,8 @@ public: nsISupports *ctxt, nsIEventQueue *eventQueue, nsIStreamObserver *observer); - NS_IMETHOD GetLoadQuiet(PRBool *aLoadQuiet); - NS_IMETHOD SetLoadQuiet(PRBool aLoadQuiet); + NS_IMETHOD GetLoadAttributes(PRUint32 *aLoadAttributes); + NS_IMETHOD SetLoadAttributes(PRUint32 aLoadAttributes); NS_IMETHOD GetContentType(char * *aContentType); NS_IMETHOD Open(); @@ -88,10 +88,6 @@ public: NS_IMETHOD GetResponseString(char * *aResponseString); NS_IMETHOD GetEventSink(nsIHTTPEventSink* *eventSink); NS_IMETHOD GetResponseDataListener(nsIStreamListener* *aListener); - NS_IMETHOD GetBypassCache(PRBool *aBypassCache); - NS_IMETHOD SetBypassCache(PRBool aBypassCache); - NS_IMETHOD GetBypassProxy(PRBool *aBypassProxy); - NS_IMETHOD SetBypassProxy(PRBool aBypassProxy); // nsHTTPChannel methods: nsresult Init(); @@ -108,9 +104,7 @@ protected: nsHTTPRequest* m_pRequest; nsHTTPResponse* m_pResponse; nsIStreamListener* m_pResponseDataListener; - PRBool mLoadQuiet; - PRBool mBypassCache; - PRBool mBypassProxy; + PRUint32 mLoadAttributes; }; #endif /* _nsHTTPChannel_h_ */