Changed GetOwner() to read owner from underlying nsJAR rather than saving it locally. SetOwner() now does nothing. bug=7270 r=norris

This commit is contained in:
mstoltz%netscape.com 2000-02-14 01:59:09 +00:00
Родитель 8df8c26172
Коммит e526225795
4 изменённых файлов: 20 добавлений и 34 удалений

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

@ -473,7 +473,6 @@ nsJARChannel::GetContentType(char* *aContentType)
char* fileName = new char[PL_strlen(mJAREntry)+1]; char* fileName = new char[PL_strlen(mJAREntry)+1];
PL_strcpy(fileName, mJAREntry); PL_strcpy(fileName, mJAREntry);
//char* fileName = <get the relative part of the jar URL's file name>;
if (fileName != nsnull) { if (fileName != nsnull) {
PRInt32 len = nsCRT::strlen(fileName); PRInt32 len = nsCRT::strlen(fileName);
const char* ext = nsnull; const char* ext = nsnull;
@ -554,27 +553,22 @@ nsJARChannel::SetLoadGroup(nsILoadGroup* aLoadGroup)
NS_IMETHODIMP NS_IMETHODIMP
nsJARChannel::GetOwner(nsISupports* *aOwner) nsJARChannel::GetOwner(nsISupports* *aOwner)
{
if (!mOwner)
{ {
nsCOMPtr<nsIPrincipal> principal; nsCOMPtr<nsIPrincipal> principal;
nsresult rv = mJAR->GetPrincipal(mJAREntry, getter_AddRefs(principal)); nsresult rv = mJAR->GetPrincipal(mJAREntry, getter_AddRefs(principal));
if (NS_SUCCEEDED(rv) && principal) if (NS_SUCCEEDED(rv) && principal)
mOwner = do_QueryInterface(principal); rv = principal->QueryInterface(NS_GET_IID(nsISupports), (void **)aOwner);
else else
mOwner = null_nsCOMPtr(); *aOwner = nsnull;
}
*aOwner = mOwner.get();
NS_IF_ADDREF(*aOwner);
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsJARChannel::SetOwner(nsISupports* aOwner) nsJARChannel::SetOwner(nsISupports* aOwner)
{ {
mOwner = aOwner; //XXX: is this OK?
return NS_OK; return NS_ERROR_FAILURE;
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -652,7 +646,7 @@ nsJARChannel::Open(char* *contentType, PRInt32 *contentLength)
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
// If this fails, GetOwner will fail, but otherwise we can continue. // If this fails, GetOwner will fail, but otherwise we can continue.
rv = mJAR->ParseManifest(); mJAR->ParseManifest();
nsCOMPtr<nsIZipEntry> entry; nsCOMPtr<nsIZipEntry> entry;
rv = mJAR->GetEntry(mJAREntry, getter_AddRefs(entry)); rv = mJAR->GetEntry(mJAREntry, getter_AddRefs(entry));

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

@ -91,7 +91,6 @@ protected:
nsCOMPtr<nsIInterfaceRequestor> mCallbacks; nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
nsCOMPtr<nsIURI> mOriginalURI; nsCOMPtr<nsIURI> mOriginalURI;
nsLoadFlags mLoadAttributes; nsLoadFlags mLoadAttributes;
nsCOMPtr<nsISupports> mOwner;
PRUint32 mStartPosition; PRUint32 mStartPosition;
PRInt32 mReadCount; PRInt32 mReadCount;

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

@ -473,7 +473,6 @@ nsJARChannel::GetContentType(char* *aContentType)
char* fileName = new char[PL_strlen(mJAREntry)+1]; char* fileName = new char[PL_strlen(mJAREntry)+1];
PL_strcpy(fileName, mJAREntry); PL_strcpy(fileName, mJAREntry);
//char* fileName = <get the relative part of the jar URL's file name>;
if (fileName != nsnull) { if (fileName != nsnull) {
PRInt32 len = nsCRT::strlen(fileName); PRInt32 len = nsCRT::strlen(fileName);
const char* ext = nsnull; const char* ext = nsnull;
@ -554,27 +553,22 @@ nsJARChannel::SetLoadGroup(nsILoadGroup* aLoadGroup)
NS_IMETHODIMP NS_IMETHODIMP
nsJARChannel::GetOwner(nsISupports* *aOwner) nsJARChannel::GetOwner(nsISupports* *aOwner)
{
if (!mOwner)
{ {
nsCOMPtr<nsIPrincipal> principal; nsCOMPtr<nsIPrincipal> principal;
nsresult rv = mJAR->GetPrincipal(mJAREntry, getter_AddRefs(principal)); nsresult rv = mJAR->GetPrincipal(mJAREntry, getter_AddRefs(principal));
if (NS_SUCCEEDED(rv) && principal) if (NS_SUCCEEDED(rv) && principal)
mOwner = do_QueryInterface(principal); rv = principal->QueryInterface(NS_GET_IID(nsISupports), (void **)aOwner);
else else
mOwner = null_nsCOMPtr(); *aOwner = nsnull;
}
*aOwner = mOwner.get();
NS_IF_ADDREF(*aOwner);
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsJARChannel::SetOwner(nsISupports* aOwner) nsJARChannel::SetOwner(nsISupports* aOwner)
{ {
mOwner = aOwner; //XXX: is this OK?
return NS_OK; return NS_ERROR_FAILURE;
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -652,7 +646,7 @@ nsJARChannel::Open(char* *contentType, PRInt32 *contentLength)
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
// If this fails, GetOwner will fail, but otherwise we can continue. // If this fails, GetOwner will fail, but otherwise we can continue.
rv = mJAR->ParseManifest(); mJAR->ParseManifest();
nsCOMPtr<nsIZipEntry> entry; nsCOMPtr<nsIZipEntry> entry;
rv = mJAR->GetEntry(mJAREntry, getter_AddRefs(entry)); rv = mJAR->GetEntry(mJAREntry, getter_AddRefs(entry));

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

@ -91,7 +91,6 @@ protected:
nsCOMPtr<nsIInterfaceRequestor> mCallbacks; nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
nsCOMPtr<nsIURI> mOriginalURI; nsCOMPtr<nsIURI> mOriginalURI;
nsLoadFlags mLoadAttributes; nsLoadFlags mLoadAttributes;
nsCOMPtr<nsISupports> mOwner;
PRUint32 mStartPosition; PRUint32 mStartPosition;
PRInt32 mReadCount; PRInt32 mReadCount;