зеркало из https://github.com/mozilla/gecko-dev.git
Added GetLoadGroup/SetLoadGroup to nsIChannel so that redirects can discover the group.
This commit is contained in:
Родитель
e317552c69
Коммит
07b963204e
|
@ -23,6 +23,7 @@ interface nsIInputStream;
|
|||
interface nsIOutputStream;
|
||||
interface nsIStreamObserver;
|
||||
interface nsIStreamListener;
|
||||
interface nsILoadGroup;
|
||||
|
||||
typedef unsigned long nsLoadFlags;
|
||||
|
||||
|
@ -116,5 +117,10 @@ interface nsIChannel : nsIRequest
|
|||
*/
|
||||
readonly attribute string ContentType;
|
||||
|
||||
/**
|
||||
* Returns the load group in which the channel is a currently a member.
|
||||
*/
|
||||
attribute nsILoadGroup LoadGroup;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -19,21 +19,19 @@
|
|||
#include "nsInputStreamChannel.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsInputStreamChannel methods:
|
||||
|
||||
nsInputStreamChannel::nsInputStreamChannel()
|
||||
: mURI(nsnull), mContentType(nsnull), mInputStream(nsnull)
|
||||
: mContentType(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsInputStreamChannel::~nsInputStreamChannel() {
|
||||
NS_IF_RELEASE(mURI);
|
||||
nsInputStreamChannel::~nsInputStreamChannel()
|
||||
{
|
||||
if (mContentType) nsCRT::free(mContentType);
|
||||
NS_IF_RELEASE(mInputStream);
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
|
@ -53,13 +51,11 @@ nsresult
|
|||
nsInputStreamChannel::Init(nsIURI* uri, const char* contentType,
|
||||
nsIInputStream* in)
|
||||
{
|
||||
mURI = uri;
|
||||
NS_IF_ADDREF(mURI);
|
||||
mURI = uri; // addrefs
|
||||
mContentType = nsCRT::strdup(contentType);
|
||||
if (mContentType == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
mInputStream = in;
|
||||
NS_IF_ADDREF(mInputStream);
|
||||
mInputStream = in; // addrefs
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -100,7 +96,7 @@ NS_IMETHODIMP
|
|||
nsInputStreamChannel::GetURI(nsIURI * *aURI)
|
||||
{
|
||||
*aURI = mURI;
|
||||
NS_IF_ADDREF(mURI);
|
||||
NS_IF_ADDREF(*aURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -111,7 +107,7 @@ nsInputStreamChannel::OpenInputStream(PRUint32 startPosition, PRInt32 readCount,
|
|||
// if we had seekable streams, we could seek here:
|
||||
NS_ASSERTION(startPosition == 0, "Can't seek in nsInputStreamChannel");
|
||||
*result = mInputStream;
|
||||
NS_ADDREF(mInputStream);
|
||||
NS_ADDREF(*result);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -186,4 +182,19 @@ nsInputStreamChannel::GetContentType(char * *aContentType)
|
|||
return *aContentType ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInputStreamChannel::GetLoadGroup(nsILoadGroup * *aLoadGroup)
|
||||
{
|
||||
*aLoadGroup = mLoadGroup;
|
||||
NS_IF_ADDREF(*aLoadGroup);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInputStreamChannel::SetLoadGroup(nsILoadGroup * aLoadGroup)
|
||||
{
|
||||
mLoadGroup = aLoadGroup; // releases and addrefs
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "nsIInputStream.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsInputStreamChannel : public nsIChannel
|
||||
{
|
||||
|
@ -48,6 +49,8 @@ public:
|
|||
NS_IMETHOD GetLoadAttributes(nsLoadFlags *aLoadAttributes);
|
||||
NS_IMETHOD SetLoadAttributes(nsLoadFlags aLoadAttributes);
|
||||
NS_IMETHOD GetContentType(char * *aContentType);
|
||||
NS_IMETHOD GetLoadGroup(nsILoadGroup * *aLoadGroup);
|
||||
NS_IMETHOD SetLoadGroup(nsILoadGroup * aLoadGroup);
|
||||
|
||||
// nsInputStreamChannel methods:
|
||||
nsInputStreamChannel();
|
||||
|
@ -59,9 +62,10 @@ public:
|
|||
nsresult Init(nsIURI* uri, const char* contentType, nsIInputStream* in);
|
||||
|
||||
protected:
|
||||
nsIURI* mURI;
|
||||
char* mContentType;
|
||||
nsIInputStream* mInputStream;
|
||||
nsCOMPtr<nsIURI> mURI;
|
||||
char* mContentType;
|
||||
nsCOMPtr<nsIInputStream> mInputStream;
|
||||
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
||||
};
|
||||
|
||||
#define NS_INPUTSTREAMCHANNEL_CID \
|
||||
|
|
|
@ -1478,3 +1478,16 @@ nsSocketTransport::GetContentType(char * *aContentType)
|
|||
return NS_ERROR_FAILURE; // XXX doesn't make sense for transports
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSocketTransport::GetLoadGroup(nsILoadGroup * *aLoadGroup)
|
||||
{
|
||||
NS_ASSERTION(0, "transports shouldn't end up in groups");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSocketTransport::SetLoadGroup(nsILoadGroup * aLoadGroup)
|
||||
{
|
||||
NS_ASSERTION(0, "transports shouldn't end up in groups");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
|
|
@ -128,6 +128,8 @@ public:
|
|||
NS_IMETHOD GetLoadAttributes(PRUint32 *aLoadAttributes);
|
||||
NS_IMETHOD SetLoadAttributes(PRUint32 aLoadAttributes);
|
||||
NS_IMETHOD GetContentType(char * *aContentType);
|
||||
NS_IMETHOD GetLoadGroup(nsILoadGroup * *aLoadGroup);
|
||||
NS_IMETHOD SetLoadGroup(nsILoadGroup * aLoadGroup);
|
||||
|
||||
// nsIBufferObserver methods:
|
||||
NS_IMETHOD OnFull (nsIBuffer* aBuffer);
|
||||
|
|
|
@ -645,6 +645,21 @@ nsFileChannel::GetContentType(char * *aContentType)
|
|||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileChannel::GetLoadGroup(nsILoadGroup * *aLoadGroup)
|
||||
{
|
||||
*aLoadGroup = mLoadGroup;
|
||||
NS_IF_ADDREF(*aLoadGroup);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileChannel::SetLoadGroup(nsILoadGroup * aLoadGroup)
|
||||
{
|
||||
mLoadGroup = aLoadGroup; // releases and addrefs
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIRunnable methods:
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -98,6 +98,9 @@ public:
|
|||
/* readonly attribute string ContentType; */
|
||||
NS_IMETHOD GetContentType(char * *aContentType);
|
||||
|
||||
NS_IMETHOD GetLoadGroup(nsILoadGroup * *aLoadGroup);
|
||||
NS_IMETHOD SetLoadGroup(nsILoadGroup * aLoadGroup);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// from nsIFileChannel:
|
||||
|
||||
|
@ -216,6 +219,7 @@ protected:
|
|||
|
||||
PRMonitor* mMonitor;
|
||||
PRUint32 mLoadAttributes;
|
||||
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
||||
|
||||
#ifdef STREAM_CONVERTER_HACK
|
||||
nsCOMPtr<nsIStreamConverter2> mStreamConverter;
|
||||
|
|
|
@ -218,6 +218,21 @@ nsFTPChannel::GetContentType(char* *contentType) {
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFTPChannel::GetLoadGroup(nsILoadGroup * *aLoadGroup)
|
||||
{
|
||||
*aLoadGroup = mLoadGroup;
|
||||
NS_IF_ADDREF(*aLoadGroup);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFTPChannel::SetLoadGroup(nsILoadGroup * aLoadGroup)
|
||||
{
|
||||
mLoadGroup = aLoadGroup; // releases and addrefs
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIFTPChannel methods:
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "nsIURI.h"
|
||||
#include "nsString2.h"
|
||||
#include "nsIEventQueue.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsIEventSinkGetter;
|
||||
class nsIProgressEventSink;
|
||||
|
@ -58,6 +59,8 @@ public:
|
|||
NS_IMETHOD GetLoadAttributes(PRUint32 *aLoadAttributes);
|
||||
NS_IMETHOD SetLoadAttributes(PRUint32 aLoadAttributes);
|
||||
NS_IMETHOD GetContentType(char * *aContentType);
|
||||
NS_IMETHOD GetLoadGroup(nsILoadGroup * *aLoadGroup);
|
||||
NS_IMETHOD SetLoadGroup(nsILoadGroup * aLoadGroup);
|
||||
|
||||
// nsIFTPChannel methods:
|
||||
NS_IMETHOD Get(void);
|
||||
|
@ -95,6 +98,7 @@ protected:
|
|||
PRBool mConnected;
|
||||
nsIStreamListener* mListener;
|
||||
PRUint32 mLoadAttributes;
|
||||
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
||||
};
|
||||
|
||||
#endif /* nsFTPChannel_h___ */
|
||||
|
|
|
@ -282,6 +282,21 @@ nsHTTPChannel::GetContentType(char * *aContentType)
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTTPChannel::GetLoadGroup(nsILoadGroup * *aLoadGroup)
|
||||
{
|
||||
*aLoadGroup = mLoadGroup;
|
||||
NS_IF_ADDREF(*aLoadGroup);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTTPChannel::SetLoadGroup(nsILoadGroup * aLoadGroup)
|
||||
{
|
||||
mLoadGroup = aLoadGroup; // releases and addrefs
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIHTTPChannel methods:
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "nsIEventQueue.h"
|
||||
#include "nsIHttpEventSink.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsHTTPRequest;
|
||||
class nsHTTPResponse;
|
||||
|
@ -76,6 +77,8 @@ public:
|
|||
NS_IMETHOD GetLoadAttributes(PRUint32 *aLoadAttributes);
|
||||
NS_IMETHOD SetLoadAttributes(PRUint32 aLoadAttributes);
|
||||
NS_IMETHOD GetContentType(char * *aContentType);
|
||||
NS_IMETHOD GetLoadGroup(nsILoadGroup * *aLoadGroup);
|
||||
NS_IMETHOD SetLoadGroup(nsILoadGroup * aLoadGroup);
|
||||
|
||||
// nsIHTTPChannel methods:
|
||||
NS_IMETHOD GetRequestHeader(const char *headerName, char **_retval);
|
||||
|
@ -106,6 +109,7 @@ protected:
|
|||
PRUint32 mLoadAttributes;
|
||||
|
||||
nsCOMPtr<nsISupports> mResponseContext;
|
||||
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
||||
};
|
||||
|
||||
#endif /* _nsHTTPChannel_h_ */
|
||||
|
|
|
@ -744,8 +744,18 @@ nsresult nsHTTPResponseListener::ProcessRedirection(PRInt32 aStatusCode)
|
|||
nsIChannel* channel;
|
||||
rv = serv->NewChannelFromURI("load", newURL, nsnull, &channel);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = channel->AsyncRead(0, -1, m_ResponseContext, m_pConsumer);
|
||||
NS_RELEASE(channel);
|
||||
nsCOMPtr<nsILoadGroup> group;
|
||||
rv = m_pConnection->GetLoadGroup(getter_AddRefs(group));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Add the new channel first. That way we don't run the risk
|
||||
// of emptying the group and firing off the OnEndDocumentLoad
|
||||
// notification.
|
||||
(void)group->AddChannel(channel, m_ResponseContext);
|
||||
(void)group->RemoveChannel(m_pConnection, m_ResponseContext,
|
||||
aStatusCode, nsnull); // XXX error message
|
||||
}
|
||||
rv = channel->AsyncRead(0, -1, m_ResponseContext, m_pConsumer);
|
||||
NS_RELEASE(channel);
|
||||
}
|
||||
#endif
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче