first round of checkins to fix bug 37616, Retire SetRelativePath, r=warren@netscape.com

This commit is contained in:
andreas.otte%primus-online.de 2000-05-05 23:39:25 +00:00
Родитель 31aea70ec6
Коммит e365632082
10 изменённых файлов: 112 добавлений и 99 удалений

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

@ -622,16 +622,18 @@ nsChromeProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
// URLs, so there is no "outer" given to CreateInstance // URLs, so there is no "outer" given to CreateInstance
nsIURI* url; nsIURI* url;
rv = nsComponentManager::CreateInstance(kStandardURLCID, nsnull,
NS_GET_IID(nsIURI),
(void**)&url);
if (NS_FAILED(rv)) return rv;
if (aBaseURI) { if (aBaseURI) {
rv = aBaseURI->Clone(&url); nsXPIDLCString aResolvedURI;
rv = aBaseURI->Resolve(aSpec, getter_Copies(aResolvedURI));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = url->SetRelativePath(aSpec); rv = url->SetSpec(aResolvedURI);
} }
else { else {
rv = nsComponentManager::CreateInstance(kStandardURLCID, nsnull,
NS_GET_IID(nsIURI),
(void**)&url);
if (NS_FAILED(rv)) return rv;
rv = url->SetSpec((char*)aSpec); rv = url->SetSpec((char*)aSpec);
} }

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

@ -28,6 +28,7 @@
#include "nsJARURI.h" #include "nsJARURI.h"
#include "nsIURL.h" #include "nsIURL.h"
#include "nsJARChannel.h" #include "nsJARChannel.h"
#include "nsXPIDLString.h"
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
static NS_DEFINE_CID(kJARUriCID, NS_JARURI_CID); static NS_DEFINE_CID(kJARUriCID, NS_JARURI_CID);
@ -94,16 +95,19 @@ NS_IMETHODIMP
nsJARProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI, nsJARProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
nsIURI **result) nsIURI **result)
{ {
nsresult rv; nsresult rv = NS_OK;
nsIURI* url; nsIURI* url;
if (aBaseURI) {
rv = aBaseURI->Clone(&url); rv = nsJARURI::Create(nsnull, NS_GET_IID(nsIJARURI), (void**)&url);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = url->SetRelativePath(aSpec);
} if (aBaseURI)
else { {
rv = nsJARURI::Create(nsnull, NS_GET_IID(nsIJARURI), (void**)&url); nsXPIDLCString aResolvedURI;
rv = aBaseURI->Resolve(aSpec, getter_Copies(aResolvedURI));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = url->SetSpec(aResolvedURI);
} else {
rv = url->SetSpec((char*)aSpec); rv = url->SetSpec((char*)aSpec);
} }

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

@ -95,22 +95,15 @@ nsAboutProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
{ {
nsresult rv; nsresult rv;
// about: URIs are implemented by the "Simple URI" implementation // no concept of a relative about url
NS_ASSERTION(!aBaseURI, "base url passed into about protocol handler");
nsIURI* url; nsIURI* url;
if (aBaseURI) { rv = nsComponentManager::CreateInstance(kSimpleURICID, nsnull,
rv = aBaseURI->Clone(&url); NS_GET_IID(nsIURI),
if (NS_FAILED(rv)) return rv; (void**)&url);
rv = url->SetRelativePath(aSpec); if (NS_FAILED(rv)) return rv;
} rv = url->SetSpec((char*)aSpec);
else {
rv = nsComponentManager::CreateInstance(kSimpleURICID, nsnull,
NS_GET_IID(nsIURI),
(void**)&url);
if (NS_FAILED(rv)) return rv;
rv = url->SetSpec((char*)aSpec);
}
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
NS_RELEASE(url); NS_RELEASE(url);
return rv; return rv;

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

@ -34,6 +34,7 @@
#include "nsISupportsArray.h" #include "nsISupportsArray.h"
#include "nsFileSpec.h" #include "nsFileSpec.h"
#include "nsAutoLock.h" #include "nsAutoLock.h"
#include "nsXPIDLString.h"
static NS_DEFINE_CID(kStandardURLCID, NS_STANDARDURL_CID); static NS_DEFINE_CID(kStandardURLCID, NS_STANDARDURL_CID);
static NS_DEFINE_CID(kNoAuthUrlParserCID, NS_NOAUTHORITYURLPARSER_CID); static NS_DEFINE_CID(kNoAuthUrlParserCID, NS_NOAUTHORITYURLPARSER_CID);
@ -105,26 +106,27 @@ nsFileProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
nsCOMPtr<nsIURI> url; nsCOMPtr<nsIURI> url;
nsCOMPtr<nsIURLParser> urlparser; nsCOMPtr<nsIURLParser> urlparser;
if (aBaseURI) {
rv = aBaseURI->Clone(getter_AddRefs(url)); rv = nsComponentManager::CreateInstance(kNoAuthUrlParserCID,
if (NS_FAILED(rv)) return rv;
rv = url->SetRelativePath(aSpec);
}
else {
rv = nsComponentManager::CreateInstance(kNoAuthUrlParserCID,
nsnull, NS_GET_IID(nsIURLParser), nsnull, NS_GET_IID(nsIURLParser),
getter_AddRefs(urlparser)); getter_AddRefs(urlparser));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = nsComponentManager::CreateInstance(kStandardURLCID, rv = nsComponentManager::CreateInstance(kStandardURLCID,
nsnull, NS_GET_IID(nsIURI), nsnull, NS_GET_IID(nsIURI),
getter_AddRefs(url)); getter_AddRefs(url));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = url->SetURLParser(urlparser);
if (NS_FAILED(rv)) return rv;
rv = url->SetURLParser(urlparser); if (aBaseURI)
{
nsXPIDLCString aResolvedURI;
rv = aBaseURI->Resolve(aSpec, getter_Copies(aResolvedURI));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = url->SetSpec(aResolvedURI);
} else {
rv = url->SetSpec((char*)aSpec); rv = url->SetSpec((char*)aSpec);
} }
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
*result = url.get(); *result = url.get();

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

@ -144,24 +144,24 @@ nsFtpProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
nsresult rv = NS_OK; nsresult rv = NS_OK;
nsCOMPtr<nsIURI> url; nsCOMPtr<nsIURI> url;
nsCOMPtr<nsIURLParser> urlparser; nsCOMPtr<nsIURLParser> urlparser;
if (aBaseURI) { rv = nsComponentManager::CreateInstance(kAuthUrlParserCID,
rv = aBaseURI->Clone(getter_AddRefs(url)); nsnull, NS_GET_IID(nsIURLParser),
if (NS_FAILED(rv)) return rv; getter_AddRefs(urlparser));
rv = url->SetRelativePath(aSpec); if (NS_FAILED(rv)) return rv;
} rv = nsComponentManager::CreateInstance(kStandardURLCID,
else { nsnull, NS_GET_IID(nsIURI),
rv = nsComponentManager::CreateInstance(kAuthUrlParserCID, getter_AddRefs(url));
nsnull, NS_GET_IID(nsIURLParser), if (NS_FAILED(rv)) return rv;
getter_AddRefs(urlparser)); rv = url->SetURLParser(urlparser);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = nsComponentManager::CreateInstance(kStandardURLCID,
nsnull, NS_GET_IID(nsIURI),
getter_AddRefs(url));
if (NS_FAILED(rv)) return rv;
rv = url->SetURLParser(urlparser); if (aBaseURI)
{
nsXPIDLCString aResolvedURI;
rv = aBaseURI->Resolve(aSpec, getter_Copies(aResolvedURI));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = url->SetSpec(aResolvedURI);
} else {
rv = url->SetSpec((char*)aSpec); rv = url->SetSpec((char*)aSpec);
} }
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;

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

@ -181,31 +181,30 @@ nsHTTPHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
nsIURI **result) nsIURI **result)
{ {
nsresult rv = NS_OK; nsresult rv = NS_OK;
nsCOMPtr<nsIURI> url; nsCOMPtr<nsIURI> url;
nsCOMPtr<nsIURLParser> urlparser; nsCOMPtr<nsIURLParser> urlparser;
rv = nsComponentManager::CreateInstance(kAuthUrlParserCID,
nsnull, NS_GET_IID(nsIURLParser),
getter_AddRefs(urlparser));
if (NS_FAILED(rv)) return rv;
rv = nsComponentManager::CreateInstance(kStandardUrlCID,
nsnull, NS_GET_IID(nsIURI),
getter_AddRefs(url));
if (NS_FAILED(rv)) return rv;
rv = url->SetURLParser(urlparser);
if (NS_FAILED(rv)) return rv;
if (aBaseURI) if (aBaseURI)
{ {
rv = aBaseURI->Clone(getter_AddRefs(url)); nsXPIDLCString aResolvedURI;
if (NS_FAILED(rv)) return rv; rv = aBaseURI->Resolve(aSpec, getter_Copies(aResolvedURI));
rv = url->SetRelativePath(aSpec);
}
else
{
rv = nsComponentManager::CreateInstance(kAuthUrlParserCID,
nsnull, NS_GET_IID(nsIURLParser),
getter_AddRefs(urlparser));
if (NS_FAILED(rv)) return rv;
rv = nsComponentManager::CreateInstance(kStandardUrlCID,
nsnull, NS_GET_IID(nsIURI),
getter_AddRefs(url));
if (NS_FAILED(rv)) return rv;
rv = url->SetURLParser(urlparser);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = url->SetSpec(aResolvedURI);
} else {
rv = url->SetSpec((char*)aSpec); rv = url->SetSpec((char*)aSpec);
} }
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
*result = url.get(); *result = url.get();
NS_ADDREF(*result); NS_ADDREF(*result);
return rv; return rv;

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

@ -28,6 +28,7 @@
#include "nsJARURI.h" #include "nsJARURI.h"
#include "nsIURL.h" #include "nsIURL.h"
#include "nsJARChannel.h" #include "nsJARChannel.h"
#include "nsXPIDLString.h"
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
static NS_DEFINE_CID(kJARUriCID, NS_JARURI_CID); static NS_DEFINE_CID(kJARUriCID, NS_JARURI_CID);
@ -94,16 +95,19 @@ NS_IMETHODIMP
nsJARProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI, nsJARProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
nsIURI **result) nsIURI **result)
{ {
nsresult rv; nsresult rv = NS_OK;
nsIURI* url; nsIURI* url;
if (aBaseURI) {
rv = aBaseURI->Clone(&url); rv = nsJARURI::Create(nsnull, NS_GET_IID(nsIJARURI), (void**)&url);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = url->SetRelativePath(aSpec);
} if (aBaseURI)
else { {
rv = nsJARURI::Create(nsnull, NS_GET_IID(nsIJARURI), (void**)&url); nsXPIDLCString aResolvedURI;
rv = aBaseURI->Resolve(aSpec, getter_Copies(aResolvedURI));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = url->SetSpec(aResolvedURI);
} else {
rv = url->SetSpec((char*)aSpec); rv = url->SetSpec((char*)aSpec);
} }

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

@ -151,16 +151,21 @@ nsResChannel::Substitutions::Next(nsIURI* *result)
PRBool ok = mSubstitutions->RemoveCStringAt(0); PRBool ok = mSubstitutions->RemoveCStringAt(0);
if (!ok) return NS_ERROR_FAILURE; if (!ok) return NS_ERROR_FAILURE;
char* path; char* path = nsnull;
rv = channel->mResourceURI->GetPath(&path); rv = channel->mResourceURI->GetPath(&path);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
// XXX this path[0] check is a hack -- it seems to me that GetPath // XXX this path[0] check is a hack -- it seems to me that GetPath
// shouldn't include the leading slash: // shouldn't include the leading slash:
rv = resolvedURI->SetRelativePath(path[0] == '/' ? path+1 : path); nsXPIDLCString aResolvedURI;
rv = resolvedURI->Resolve(path[0] == '/' ? path+1 : path,
getter_Copies(aResolvedURI));
nsCRT::free(path); nsCRT::free(path);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = resolvedURI->SetSpec(aResolvedURI);
if (NS_FAILED(rv)) return rv;
*result = resolvedURI; *result = resolvedURI;
NS_IF_ADDREF(*result); NS_IF_ADDREF(*result);
return NS_OK; return NS_OK;

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

@ -42,6 +42,7 @@
#include "prenv.h" #include "prenv.h"
#include "prmem.h" #include "prmem.h"
#include "prprf.h" #include "prprf.h"
#include "nsXPIDLString.h"
static NS_DEFINE_CID(kStandardURLCID, NS_STANDARDURL_CID); static NS_DEFINE_CID(kStandardURLCID, NS_STANDARDURL_CID);
@ -232,16 +233,17 @@ nsResProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
// URLs, so there is no "outer" given to CreateInstance // URLs, so there is no "outer" given to CreateInstance
nsIURI* url; nsIURI* url;
rv = nsComponentManager::CreateInstance(kStandardURLCID, nsnull,
NS_GET_IID(nsIURI),
(void**)&url);
if (NS_FAILED(rv)) return rv;
if (aBaseURI) { if (aBaseURI) {
rv = aBaseURI->Clone(&url); nsXPIDLCString aResolvedURI;
if (NS_FAILED(rv)) return rv; rv = aBaseURI->Resolve(aSpec, getter_Copies(aResolvedURI));
rv = url->SetRelativePath(aSpec);
}
else {
rv = nsComponentManager::CreateInstance(kStandardURLCID, nsnull,
NS_GET_IID(nsIURI),
(void**)&url);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = url->SetSpec(aResolvedURI);
} else {
rv = url->SetSpec((char*)aSpec); rv = url->SetSpec((char*)aSpec);
} }

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

@ -622,16 +622,18 @@ nsChromeProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
// URLs, so there is no "outer" given to CreateInstance // URLs, so there is no "outer" given to CreateInstance
nsIURI* url; nsIURI* url;
rv = nsComponentManager::CreateInstance(kStandardURLCID, nsnull,
NS_GET_IID(nsIURI),
(void**)&url);
if (NS_FAILED(rv)) return rv;
if (aBaseURI) { if (aBaseURI) {
rv = aBaseURI->Clone(&url); nsXPIDLCString aResolvedURI;
rv = aBaseURI->Resolve(aSpec, getter_Copies(aResolvedURI));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = url->SetRelativePath(aSpec); rv = url->SetSpec(aResolvedURI);
} }
else { else {
rv = nsComponentManager::CreateInstance(kStandardURLCID, nsnull,
NS_GET_IID(nsIURI),
(void**)&url);
if (NS_FAILED(rv)) return rv;
rv = url->SetSpec((char*)aSpec); rv = url->SetSpec((char*)aSpec);
} }