зеркало из https://github.com/mozilla/pjs.git
Landing changes to support chrome URLs in netlib. Approved by dp.
This commit is contained in:
Родитель
6bee6e43ee
Коммит
b99466aa41
|
@ -148,6 +148,7 @@ LINCS=$(LINCS) -I. \
|
||||||
-I$(PUBLIC)\sockstub \
|
-I$(PUBLIC)\sockstub \
|
||||||
-I$(PUBLIC)\remoturl \
|
-I$(PUBLIC)\remoturl \
|
||||||
-I$(PUBLIC)\netlib \
|
-I$(PUBLIC)\netlib \
|
||||||
|
-I$(PUBLIC)\chrome \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
# clobber and clobber_all will remove the following garbage:
|
# clobber and clobber_all will remove the following garbage:
|
||||||
|
|
|
@ -108,6 +108,8 @@ NS_InitializeHttpURLFactory(nsINetService* inet)
|
||||||
if (rv != NS_OK) goto done;
|
if (rv != NS_OK) goto done;
|
||||||
inet->RegisterProtocol(*new nsString("resource"), urlf, NULL);
|
inet->RegisterProtocol(*new nsString("resource"), urlf, NULL);
|
||||||
if (rv != NS_OK) goto done;
|
if (rv != NS_OK) goto done;
|
||||||
|
inet->RegisterProtocol(*new nsString("chrome"), urlf, NULL);
|
||||||
|
if (rv != NS_OK) goto done;
|
||||||
inet->RegisterProtocol(*new nsString("file"), urlf, NULL);
|
inet->RegisterProtocol(*new nsString("file"), urlf, NULL);
|
||||||
if (rv != NS_OK) goto done;
|
if (rv != NS_OK) goto done;
|
||||||
inet->RegisterProtocol(*new nsString("javascript"), urlf, NULL);
|
inet->RegisterProtocol(*new nsString("javascript"), urlf, NULL);
|
||||||
|
|
|
@ -51,6 +51,8 @@ extern "C" {
|
||||||
#include "nsCRT.h"
|
#include "nsCRT.h"
|
||||||
#include "nsSocketTransport.h"
|
#include "nsSocketTransport.h"
|
||||||
|
|
||||||
|
#include "nsIChromeRegistry.h"
|
||||||
|
|
||||||
#ifdef XP_PC
|
#ifdef XP_PC
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
static HINSTANCE g_hInst = NULL;
|
static HINSTANCE g_hInst = NULL;
|
||||||
|
@ -103,6 +105,7 @@ nsresult PerformNastyWindowsAsyncDNSHack(URL_Struct* URL_s, nsIURL* aURL);
|
||||||
#endif /* XP_WIN && !NETLIB_THREAD */
|
#endif /* XP_WIN && !NETLIB_THREAD */
|
||||||
|
|
||||||
char *mangleResourceIntoFileURL(const char* aResourceFileName);
|
char *mangleResourceIntoFileURL(const char* aResourceFileName);
|
||||||
|
|
||||||
extern nsIStreamListener* ns_NewStreamListenerProxy(nsIStreamListener* aListener, PLEventQueue* aEventQ);
|
extern nsIStreamListener* ns_NewStreamListenerProxy(nsIStreamListener* aListener, PLEventQueue* aEventQ);
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -126,6 +129,11 @@ static NS_DEFINE_IID(kINetlibURLIID, NS_INETLIBURL_IID);
|
||||||
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||||
static NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID);
|
static NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID);
|
||||||
|
|
||||||
|
// Chrome registry service for handling of chrome URLs
|
||||||
|
static NS_DEFINE_IID(kChromeRegistryCID, NS_CHROMEREGISTRY_CID);
|
||||||
|
static NS_DEFINE_IID(kIChromeRegistryIID, NS_ICHROMEREGISTRY_IID);
|
||||||
|
nsIChromeRegistry* nsNetlibService::gChromeRegistry = nsnull;
|
||||||
|
int nsNetlibService::gRefCnt = 0;
|
||||||
|
|
||||||
nsNetlibService::nsNetlibService()
|
nsNetlibService::nsNetlibService()
|
||||||
{
|
{
|
||||||
|
@ -209,6 +217,20 @@ nsNetlibService::nsNetlibService()
|
||||||
|
|
||||||
mProtocols = new nsHashtable();
|
mProtocols = new nsHashtable();
|
||||||
PR_ASSERT(mProtocols);
|
PR_ASSERT(mProtocols);
|
||||||
|
|
||||||
|
// Create the chrome registry. If it fails, that's ok.
|
||||||
|
gRefCnt++;
|
||||||
|
|
||||||
|
if (gRefCnt == 1)
|
||||||
|
{
|
||||||
|
gChromeRegistry = nsnull;
|
||||||
|
if (NS_FAILED(nsServiceManager::GetService(kChromeRegistryCID,
|
||||||
|
kIChromeRegistryIID,
|
||||||
|
(nsISupports **)&gChromeRegistry))) {
|
||||||
|
gChromeRegistry = nsnull;
|
||||||
|
}
|
||||||
|
else gChromeRegistry->Init(); // Load the chrome registry
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -220,6 +242,13 @@ nsNetlibService::~nsNetlibService()
|
||||||
{
|
{
|
||||||
TRACEMSG(("nsNetlibService is being destroyed...\n"));
|
TRACEMSG(("nsNetlibService is being destroyed...\n"));
|
||||||
|
|
||||||
|
gRefCnt--;
|
||||||
|
if (gRefCnt == 0)
|
||||||
|
{
|
||||||
|
NS_IF_RELEASE(gChromeRegistry);
|
||||||
|
gChromeRegistry = nsnull;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (NULL != m_stubContext) {
|
if (NULL != m_stubContext) {
|
||||||
free_stub_context((MWContext *)m_stubContext);
|
free_stub_context((MWContext *)m_stubContext);
|
||||||
|
@ -363,6 +392,20 @@ nsresult nsNetlibService::OpenStream(nsIURL *aUrl,
|
||||||
const char* protocol;
|
const char* protocol;
|
||||||
result = aUrl->GetProtocol(&protocol);
|
result = aUrl->GetProtocol(&protocol);
|
||||||
NS_ASSERTION(result == NS_OK, "deal with this");
|
NS_ASSERTION(result == NS_OK, "deal with this");
|
||||||
|
|
||||||
|
// Deal with chrome URLS
|
||||||
|
if ((PL_strcmp(protocol, "chrome") == 0) &&
|
||||||
|
gChromeRegistry != nsnull) {
|
||||||
|
|
||||||
|
if (NS_FAILED(result = gChromeRegistry->ConvertChromeURL(aUrl))) {
|
||||||
|
NS_ERROR("Unable to convert chrome URL.");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = aUrl->GetProtocol(&protocol);
|
||||||
|
NS_ASSERTION(result == NS_OK, "deal with this");
|
||||||
|
}
|
||||||
|
|
||||||
if (PL_strcmp(protocol, "resource") == 0) {
|
if (PL_strcmp(protocol, "resource") == 0) {
|
||||||
char* fileName;
|
char* fileName;
|
||||||
const char* file;
|
const char* file;
|
||||||
|
@ -504,6 +547,20 @@ nsresult nsNetlibService::OpenBlockingStream(nsIURL *aUrl,
|
||||||
const char* protocol;
|
const char* protocol;
|
||||||
result = aUrl->GetProtocol(&protocol);
|
result = aUrl->GetProtocol(&protocol);
|
||||||
NS_ASSERTION(result == NS_OK, "deal with this");
|
NS_ASSERTION(result == NS_OK, "deal with this");
|
||||||
|
|
||||||
|
// Deal with chrome URLS
|
||||||
|
if ((PL_strcmp(protocol, "chrome") == 0) &&
|
||||||
|
gChromeRegistry != nsnull) {
|
||||||
|
|
||||||
|
if (NS_FAILED(result = gChromeRegistry->ConvertChromeURL(aUrl))) {
|
||||||
|
NS_ERROR("Unable to convert chrome URL.");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = aUrl->GetProtocol(&protocol);
|
||||||
|
NS_ASSERTION(result == NS_OK, "deal with this");
|
||||||
|
}
|
||||||
|
|
||||||
if (PL_strcmp(protocol, "resource") == 0) {
|
if (PL_strcmp(protocol, "resource") == 0) {
|
||||||
char* fileName;
|
char* fileName;
|
||||||
const char* file;
|
const char* file;
|
||||||
|
|
|
@ -31,6 +31,9 @@
|
||||||
|
|
||||||
class nsITimer;
|
class nsITimer;
|
||||||
|
|
||||||
|
// The chrome registry interface
|
||||||
|
class nsIChromeRegistry;
|
||||||
|
|
||||||
class nsNetlibService : public nsINetService {
|
class nsNetlibService : public nsINetService {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -116,6 +119,10 @@ protected:
|
||||||
static void NetlibThreadMain(void *aParam);
|
static void NetlibThreadMain(void *aParam);
|
||||||
#endif /* NETLIB_THREAD */
|
#endif /* NETLIB_THREAD */
|
||||||
|
|
||||||
|
// Chrome Registry static variables
|
||||||
|
static nsIChromeRegistry* gChromeRegistry;
|
||||||
|
static int gRefCnt;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SetupURLStruct(nsIURL *aURL, URL_Struct *aURL_s);
|
void SetupURLStruct(nsIURL *aURL, URL_Struct *aURL_s);
|
||||||
/* XXX: This is temporary until bamwrap.cpp is removed... */
|
/* XXX: This is temporary until bamwrap.cpp is removed... */
|
||||||
|
|
Загрузка…
Ссылка в новой задаче