Use RDF/XML datasource directly, rather than loading through RDF service. The separates this from whatever policy RDF service ends up needing to use for RDF/XML. Chrome registry _must_ be loaded synchronously no matter what.

This commit is contained in:
waterson%netscape.com 1999-06-15 00:42:45 +00:00
Родитель c9a8c48435
Коммит 3dfae0dd79
2 изменённых файлов: 34 добавлений и 8 удалений

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

@ -20,6 +20,7 @@
#include "nsFileSpec.h" #include "nsFileSpec.h"
#include "nsSpecialSystemDirectory.h" #include "nsSpecialSystemDirectory.h"
#include "nsIChromeRegistry.h" #include "nsIChromeRegistry.h"
#include "nsIRDFXMLDataSource.h"
#include "nsIRDFObserver.h" #include "nsIRDFObserver.h"
#include "nsCRT.h" #include "nsCRT.h"
#include "rdf.h" #include "rdf.h"
@ -37,9 +38,9 @@ static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID);
static NS_DEFINE_IID(kIRDFLiteralIID, NS_IRDFLITERAL_IID); static NS_DEFINE_IID(kIRDFLiteralIID, NS_IRDFLITERAL_IID);
static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID); static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
static NS_DEFINE_IID(kIRDFDataSourceIID, NS_IRDFDATASOURCE_IID); static NS_DEFINE_IID(kIRDFDataSourceIID, NS_IRDFDATASOURCE_IID);
static NS_DEFINE_CID(kRDFXMLDataSourceCID, NS_RDFXMLDATASOURCE_CID);
static NS_DEFINE_IID(kIRDFIntIID, NS_IRDFINT_IID); static NS_DEFINE_IID(kIRDFIntIID, NS_IRDFINT_IID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static NS_DEFINE_CID(kRDFXMLDataSourceCID, NS_RDFXMLDATASOURCE_CID);
#define CHROME_NAMESPACE_URI "http://chrome.mozilla.org/rdf#" #define CHROME_NAMESPACE_URI "http://chrome.mozilla.org/rdf#"
DEFINE_RDF_VOCAB(CHROME_NAMESPACE_URI, CHROME, chrome); DEFINE_RDF_VOCAB(CHROME_NAMESPACE_URI, CHROME, chrome);
@ -492,6 +493,12 @@ nsChromeRegistry::Init(const char* uri)
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource"); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource");
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = nsComponentManager::CreateInstance(kRDFXMLDataSourceCID,
nsnull,
nsIRDFXMLDataSource::GetIID(),
(void**) &mInner);
if (NS_FAILED(rv)) return rv;
// Retrieve the mInner data source. // Retrieve the mInner data source.
nsSpecialSystemDirectory chromeFile(nsSpecialSystemDirectory::OS_CurrentProcessDirectory); nsSpecialSystemDirectory chromeFile(nsSpecialSystemDirectory::OS_CurrentProcessDirectory);
chromeFile += "chrome"; chromeFile += "chrome";
@ -500,9 +507,15 @@ nsChromeRegistry::Init(const char* uri)
nsFileURL chromeURL(chromeFile); nsFileURL chromeURL(chromeFile);
const char* innerURI = chromeURL.GetAsString(); const char* innerURI = chromeURL.GetAsString();
// Try to create the new data source. rv = mInner->Init(innerURI);
if (NS_FAILED(rv = gRDFService->GetDataSource(innerURI, &mInner))) if (NS_FAILED(rv)) return rv;
return rv;
nsCOMPtr<nsIRDFXMLDataSource> xmlds = do_QueryInterface(mInner);
if (! xmlds)
return NS_ERROR_FAILURE;
// We need to read this synchronously.
rv = xmlds->Open(PR_TRUE);
} }
return rv; return rv;

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

@ -20,6 +20,7 @@
#include "nsFileSpec.h" #include "nsFileSpec.h"
#include "nsSpecialSystemDirectory.h" #include "nsSpecialSystemDirectory.h"
#include "nsIChromeRegistry.h" #include "nsIChromeRegistry.h"
#include "nsIRDFXMLDataSource.h"
#include "nsIRDFObserver.h" #include "nsIRDFObserver.h"
#include "nsCRT.h" #include "nsCRT.h"
#include "rdf.h" #include "rdf.h"
@ -37,9 +38,9 @@ static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID);
static NS_DEFINE_IID(kIRDFLiteralIID, NS_IRDFLITERAL_IID); static NS_DEFINE_IID(kIRDFLiteralIID, NS_IRDFLITERAL_IID);
static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID); static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
static NS_DEFINE_IID(kIRDFDataSourceIID, NS_IRDFDATASOURCE_IID); static NS_DEFINE_IID(kIRDFDataSourceIID, NS_IRDFDATASOURCE_IID);
static NS_DEFINE_CID(kRDFXMLDataSourceCID, NS_RDFXMLDATASOURCE_CID);
static NS_DEFINE_IID(kIRDFIntIID, NS_IRDFINT_IID); static NS_DEFINE_IID(kIRDFIntIID, NS_IRDFINT_IID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static NS_DEFINE_CID(kRDFXMLDataSourceCID, NS_RDFXMLDATASOURCE_CID);
#define CHROME_NAMESPACE_URI "http://chrome.mozilla.org/rdf#" #define CHROME_NAMESPACE_URI "http://chrome.mozilla.org/rdf#"
DEFINE_RDF_VOCAB(CHROME_NAMESPACE_URI, CHROME, chrome); DEFINE_RDF_VOCAB(CHROME_NAMESPACE_URI, CHROME, chrome);
@ -492,6 +493,12 @@ nsChromeRegistry::Init(const char* uri)
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource"); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource");
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = nsComponentManager::CreateInstance(kRDFXMLDataSourceCID,
nsnull,
nsIRDFXMLDataSource::GetIID(),
(void**) &mInner);
if (NS_FAILED(rv)) return rv;
// Retrieve the mInner data source. // Retrieve the mInner data source.
nsSpecialSystemDirectory chromeFile(nsSpecialSystemDirectory::OS_CurrentProcessDirectory); nsSpecialSystemDirectory chromeFile(nsSpecialSystemDirectory::OS_CurrentProcessDirectory);
chromeFile += "chrome"; chromeFile += "chrome";
@ -500,9 +507,15 @@ nsChromeRegistry::Init(const char* uri)
nsFileURL chromeURL(chromeFile); nsFileURL chromeURL(chromeFile);
const char* innerURI = chromeURL.GetAsString(); const char* innerURI = chromeURL.GetAsString();
// Try to create the new data source. rv = mInner->Init(innerURI);
if (NS_FAILED(rv = gRDFService->GetDataSource(innerURI, &mInner))) if (NS_FAILED(rv)) return rv;
return rv;
nsCOMPtr<nsIRDFXMLDataSource> xmlds = do_QueryInterface(mInner);
if (! xmlds)
return NS_ERROR_FAILURE;
// We need to read this synchronously.
rv = xmlds->Open(PR_TRUE);
} }
return rv; return rv;