Removed caps dependency from necko. Used nsCOMPtr for nsInputStreamChannel.
This commit is contained in:
Родитель
26e32dddf5
Коммит
fec02a32a9
|
@ -188,7 +188,8 @@ nsChromeProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
|
|||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
(*result)->SetPrincipal(principal);
|
||||
nsCOMPtr<nsISupports> owner = do_QueryInterface(principal);
|
||||
(*result)->SetOwner(owner);
|
||||
#ifdef DEBUG_norris
|
||||
nsXPIDLCString spec;
|
||||
uri->GetSpec(getter_Copies(spec));
|
||||
|
|
|
@ -647,6 +647,7 @@ nsDocument::nsDocument()
|
|||
mWordBreaker = nsnull;
|
||||
mModCount = 0;
|
||||
mFileSpec = nsnull;
|
||||
mPrincipal = nsnull;
|
||||
Init();/* XXX */
|
||||
}
|
||||
|
||||
|
@ -892,7 +893,10 @@ nsDocument::Reset(nsIURI *aURL)
|
|||
|
||||
#ifdef NECKO
|
||||
(void)aChannel->GetURI(&mDocumentURL);
|
||||
aChannel->GetPrincipal(&mPrincipal);
|
||||
nsCOMPtr<nsISupports> owner;
|
||||
aChannel->GetOwner(getter_AddRefs(owner));
|
||||
if (owner)
|
||||
owner->QueryInterface(nsIPrincipal::GetIID(), (void**)&mPrincipal);
|
||||
// (void)aChannel->GetLoadGroup(&mDocumentLoadGroup);
|
||||
mDocumentLoadGroup = aLoadGroup;
|
||||
NS_ADDREF(mDocumentLoadGroup);
|
||||
|
|
|
@ -1314,7 +1314,9 @@ XULDocumentImpl::PrepareToLoad( nsCOMPtr<nsIParser>* created_parser,
|
|||
|
||||
mDocumentURL = syntheticURL;
|
||||
|
||||
rv = aChannel->GetPrincipal(getter_AddRefs(mDocumentPrincipal));
|
||||
nsCOMPtr<nsISupports> owner;
|
||||
rv = aChannel->GetOwner(getter_AddRefs(owner));
|
||||
mDocumentPrincipal = do_QueryInterface(owner);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
#ifdef NECKO
|
||||
|
|
|
@ -647,6 +647,7 @@ nsDocument::nsDocument()
|
|||
mWordBreaker = nsnull;
|
||||
mModCount = 0;
|
||||
mFileSpec = nsnull;
|
||||
mPrincipal = nsnull;
|
||||
Init();/* XXX */
|
||||
}
|
||||
|
||||
|
@ -892,7 +893,10 @@ nsDocument::Reset(nsIURI *aURL)
|
|||
|
||||
#ifdef NECKO
|
||||
(void)aChannel->GetURI(&mDocumentURL);
|
||||
aChannel->GetPrincipal(&mPrincipal);
|
||||
nsCOMPtr<nsISupports> owner;
|
||||
aChannel->GetOwner(getter_AddRefs(owner));
|
||||
if (owner)
|
||||
owner->QueryInterface(nsIPrincipal::GetIID(), (void**)&mPrincipal);
|
||||
// (void)aChannel->GetLoadGroup(&mDocumentLoadGroup);
|
||||
mDocumentLoadGroup = aLoadGroup;
|
||||
NS_ADDREF(mDocumentLoadGroup);
|
||||
|
|
|
@ -24,7 +24,6 @@ interface nsIOutputStream;
|
|||
interface nsIStreamObserver;
|
||||
interface nsIStreamListener;
|
||||
interface nsILoadGroup;
|
||||
interface nsIPrincipal;
|
||||
|
||||
typedef unsigned long nsLoadFlags;
|
||||
|
||||
|
@ -118,18 +117,18 @@ interface nsIChannel : nsIRequest
|
|||
*/
|
||||
readonly attribute string ContentType;
|
||||
|
||||
/**
|
||||
* Returns the length of the data assiciated with the channel if available.
|
||||
* If the length is unknown then -1 is returned.
|
||||
*/
|
||||
readonly attribute long ContentLength;
|
||||
/**
|
||||
* Returns the length of the data assiciated with the channel if available.
|
||||
* If the length is unknown then -1 is returned.
|
||||
*/
|
||||
readonly attribute long ContentLength;
|
||||
|
||||
/**
|
||||
* Accesses the principal corresponding to the entity that is
|
||||
* responsible for this channel. Used by security code to grant
|
||||
* or diminish privileges to mobile code loaded from this channel.
|
||||
* Accesses the owner corresponding to the entity that is
|
||||
* responsible for this channel. Used by security code to grant
|
||||
* or diminish privileges to mobile code loaded from this channel.
|
||||
*/
|
||||
attribute nsIPrincipal Principal;
|
||||
attribute nsISupports Owner;
|
||||
|
||||
/**
|
||||
* Returns the load group in which the channel is a currently a member.
|
||||
|
|
|
@ -31,17 +31,14 @@ static NS_DEFINE_CID(kMIMEServiceCID, NS_MIMESERVICE_CID);
|
|||
// nsInputStreamChannel methods:
|
||||
|
||||
nsInputStreamChannel::nsInputStreamChannel()
|
||||
: mURI(nsnull), mContentType(nsnull), mInputStream(nsnull), mLoadGroup(nsnull)
|
||||
: mContentType(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsInputStreamChannel::~nsInputStreamChannel()
|
||||
{
|
||||
NS_IF_RELEASE(mURI);
|
||||
if (mContentType) nsCRT::free(mContentType);
|
||||
NS_IF_RELEASE(mInputStream);
|
||||
NS_IF_RELEASE(mLoadGroup);
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
|
@ -62,12 +59,10 @@ nsInputStreamChannel::Init(nsIURI* uri, const char* contentType,
|
|||
nsIInputStream* in)
|
||||
{
|
||||
mURI = uri;
|
||||
NS_IF_ADDREF(mURI);
|
||||
mContentType = nsCRT::strdup(contentType);
|
||||
if (mContentType == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
mInputStream = in;
|
||||
NS_IF_ADDREF(mInputStream);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -244,15 +239,17 @@ nsInputStreamChannel::GetLoadGroup(nsILoadGroup * *aLoadGroup)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInputStreamChannel::GetPrincipal(nsIPrincipal * *aPrincipal)
|
||||
nsInputStreamChannel::GetOwner(nsISupports * *aOwner)
|
||||
{
|
||||
*aPrincipal = nsnull;
|
||||
*aOwner = mOwner;
|
||||
NS_IF_ADDREF(*aOwner);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInputStreamChannel::SetPrincipal(nsIPrincipal * aPrincipal)
|
||||
nsInputStreamChannel::SetOwner(nsISupports * aOwner)
|
||||
{
|
||||
mOwner = aOwner;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "nsIInputStream.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsInputStreamChannel : public nsIChannel
|
||||
{
|
||||
|
@ -45,10 +46,11 @@ public:
|
|||
nsresult Init(nsIURI* uri, const char* contentType, nsIInputStream* in);
|
||||
|
||||
protected:
|
||||
nsIURI* mURI;
|
||||
char* mContentType;
|
||||
nsIInputStream* mInputStream;
|
||||
nsILoadGroup* mLoadGroup;
|
||||
nsCOMPtr<nsIURI> mURI;
|
||||
char* mContentType;
|
||||
nsCOMPtr<nsIInputStream> mInputStream;
|
||||
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
||||
nsCOMPtr<nsISupports> mOwner;
|
||||
};
|
||||
|
||||
#define NS_INPUTSTREAMCHANNEL_CID \
|
||||
|
|
|
@ -1749,15 +1749,18 @@ nsSocketTransport::GetLoadGroup(nsILoadGroup * *aLoadGroup)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSocketTransport::GetPrincipal(nsIPrincipal * *aPrincipal)
|
||||
nsSocketTransport::GetOwner(nsISupports * *aOwner)
|
||||
{
|
||||
*aPrincipal = nsnull;
|
||||
return NS_OK;
|
||||
*aOwner = mOwner;
|
||||
NS_IF_ADDREF(*aOwner);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSocketTransport::SetPrincipal(nsIPrincipal * aPrincipal)
|
||||
nsSocketTransport::SetOwner(nsISupports * aOwner)
|
||||
{
|
||||
return NS_OK;
|
||||
mOwner = aOwner;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -237,6 +237,7 @@ protected:
|
|||
|
||||
nsSocketTransportService* mService;
|
||||
PRUint32 mLoadAttributes;
|
||||
nsCOMPtr<nsISupports> mOwner;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "nsIEventQueueService.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "plbase64.h"
|
||||
#include "nsIEventSinkGetter.h"
|
||||
#include "nsIPipe.h"
|
||||
|
@ -374,14 +373,17 @@ nsDataChannel::GetLoadGroup(nsILoadGroup * *aLoadGroup)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDataChannel::GetPrincipal(nsIPrincipal * *aPrincipal)
|
||||
nsDataChannel::GetOwner(nsISupports * *aOwner)
|
||||
{
|
||||
*aPrincipal = nsnull;
|
||||
*aOwner = mOwner;
|
||||
NS_IF_ADDREF(*aOwner);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDataChannel::SetPrincipal(nsIPrincipal * aPrincipal)
|
||||
nsDataChannel::SetOwner(nsISupports * aOwner)
|
||||
{
|
||||
mOwner = aOwner;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@ protected:
|
|||
nsILoadGroup *mLoadGroup;
|
||||
nsCString mContentType;
|
||||
PRInt32 mContentLength;
|
||||
nsCOMPtr<nsISupports> mOwner;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
#include "nsEscape.h"
|
||||
#include "nsIMIMEService.h"
|
||||
#include "prlog.h"
|
||||
#include "nsIPrincipal.h"
|
||||
|
||||
static NS_DEFINE_CID(kMIMEServiceCID, NS_MIMESERVICE_CID);
|
||||
|
||||
|
@ -79,7 +78,7 @@ nsFileChannel::nsFileChannel()
|
|||
mBufferInputStream(nsnull), mBufferOutputStream(nsnull),
|
||||
mStatus(NS_OK), mHandler(nsnull), mSourceOffset(0),
|
||||
mLoadAttributes(LOAD_NORMAL),
|
||||
mReadFixedAmount(PR_FALSE), mLoadGroup(nsnull), mPrincipal(nsnull),
|
||||
mReadFixedAmount(PR_FALSE), mLoadGroup(nsnull),
|
||||
mRealListener(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
@ -182,7 +181,6 @@ nsFileChannel::~nsFileChannel()
|
|||
if (mMonitor)
|
||||
nsAutoMonitor::DestroyMonitor(mMonitor);
|
||||
NS_IF_RELEASE(mLoadGroup);
|
||||
NS_IF_RELEASE(mPrincipal);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -580,19 +578,17 @@ nsFileChannel::GetLoadGroup(nsILoadGroup * *aLoadGroup)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileChannel::GetPrincipal(nsIPrincipal * *aPrincipal)
|
||||
nsFileChannel::GetOwner(nsISupports * *aOwner)
|
||||
{
|
||||
*aPrincipal = mPrincipal;
|
||||
NS_IF_ADDREF(*aPrincipal);
|
||||
*aOwner = mOwner;
|
||||
NS_IF_ADDREF(*aOwner);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileChannel::SetPrincipal(nsIPrincipal * aPrincipal)
|
||||
nsFileChannel::SetOwner(nsISupports * aOwner)
|
||||
{
|
||||
NS_IF_RELEASE(mPrincipal);
|
||||
mPrincipal = aPrincipal;
|
||||
NS_IF_ADDREF(mPrincipal);
|
||||
mOwner = aOwner;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ protected:
|
|||
PRMonitor* mMonitor;
|
||||
PRUint32 mLoadAttributes;
|
||||
nsILoadGroup* mLoadGroup;
|
||||
nsIPrincipal* mPrincipal;
|
||||
nsCOMPtr<nsISupports> mOwner;
|
||||
|
||||
nsCOMPtr<nsIStreamListener> mRealListener;
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
#include "nsILoadGroup.h"
|
||||
#include "nsIFTPContext.h"
|
||||
#include "nsIMIMEService.h"
|
||||
#include "nsIPrincipal.h"
|
||||
|
||||
static NS_DEFINE_CID(kMIMEServiceCID, NS_MIMESERVICE_CID);
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
|
@ -399,15 +398,17 @@ nsFTPChannel::GetLoadGroup(nsILoadGroup * *aLoadGroup)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFTPChannel::GetPrincipal(nsIPrincipal * *aPrincipal)
|
||||
nsFTPChannel::GetOwner(nsISupports * *aOwner)
|
||||
{
|
||||
*aPrincipal = nsnull;
|
||||
*aOwner = mOwner;
|
||||
NS_IF_ADDREF(*aOwner);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFTPChannel::SetPrincipal(nsIPrincipal * aPrincipal)
|
||||
nsFTPChannel::SetOwner(nsISupports * aOwner)
|
||||
{
|
||||
mOwner = aOwner;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ protected:
|
|||
PRInt32 mAmount;
|
||||
nsILoadGroup* mLoadGroup;
|
||||
nsString2 mContentType;
|
||||
|
||||
nsCOMPtr<nsISupports> mOwner;
|
||||
};
|
||||
|
||||
#define NS_FTP_SEGMENT_SIZE (4*1024)
|
||||
|
|
|
@ -335,15 +335,17 @@ nsHTTPChannel::GetLoadGroup(nsILoadGroup * *aLoadGroup)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTTPChannel::GetPrincipal(nsIPrincipal * *aPrincipal)
|
||||
nsHTTPChannel::GetOwner(nsISupports * *aOwner)
|
||||
{
|
||||
*aPrincipal = nsnull;
|
||||
*aOwner = mOwner;
|
||||
NS_IF_ADDREF(*aOwner);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTTPChannel::SetPrincipal(nsIPrincipal * aPrincipal)
|
||||
nsHTTPChannel::SetOwner(nsISupports * aOwner)
|
||||
{
|
||||
mOwner = aOwner;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -105,13 +105,14 @@ protected:
|
|||
nsCString mContentType;
|
||||
nsCString mCharset;
|
||||
nsIInputStream* mPostStream;
|
||||
// Auth related stuff-
|
||||
/*
|
||||
If this is true then we have already tried
|
||||
prehost as a response to the server challenge.
|
||||
And so we need to throw a dialog box!
|
||||
*/
|
||||
PRBool mAuthTriedWithPrehost;
|
||||
nsCOMPtr<nsISupports> mOwner;
|
||||
// Auth related stuff-
|
||||
/*
|
||||
If this is true then we have already tried
|
||||
prehost as a response to the server challenge.
|
||||
And so we need to throw a dialog box!
|
||||
*/
|
||||
PRBool mAuthTriedWithPrehost;
|
||||
};
|
||||
|
||||
#endif /* _nsHTTPChannel_h_ */
|
||||
|
|
|
@ -188,7 +188,8 @@ nsChromeProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
|
|||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
(*result)->SetPrincipal(principal);
|
||||
nsCOMPtr<nsISupports> owner = do_QueryInterface(principal);
|
||||
(*result)->SetOwner(owner);
|
||||
#ifdef DEBUG_norris
|
||||
nsXPIDLCString spec;
|
||||
uri->GetSpec(getter_Copies(spec));
|
||||
|
|
|
@ -1314,7 +1314,9 @@ XULDocumentImpl::PrepareToLoad( nsCOMPtr<nsIParser>* created_parser,
|
|||
|
||||
mDocumentURL = syntheticURL;
|
||||
|
||||
rv = aChannel->GetPrincipal(getter_AddRefs(mDocumentPrincipal));
|
||||
nsCOMPtr<nsISupports> owner;
|
||||
rv = aChannel->GetOwner(getter_AddRefs(owner));
|
||||
mDocumentPrincipal = do_QueryInterface(owner);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
#ifdef NECKO
|
||||
|
|
Загрузка…
Ссылка в новой задаче