mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-23 02:47:07 +00:00
Bug 80589. Ensure that NS_NewLocalStore() will not return success unless it actually returns a component. r=alecf, sr=hyatt, a=asa.
This commit is contained in:
parent
8865fc53de
commit
832694b375
@ -245,24 +245,8 @@ NS_NewLocalStore(nsISupports* aOuter, REFNSIID aIID, void** aResult)
|
||||
nsresult rv;
|
||||
rv = impl->Init();
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// We need to read this synchronously.
|
||||
rv = impl->Refresh(PR_TRUE);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = impl->QueryInterface(aIID, aResult);
|
||||
}
|
||||
else {
|
||||
#ifdef DEBUG
|
||||
printf("\n\nRDF: NS_NewLocalStore::Refresh() failed.\n\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
// Register as an observer of profile changes
|
||||
NS_WITH_SERVICE(nsIObserverService, svc, NS_OBSERVERSERVICE_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && svc) {
|
||||
svc->AddObserver(impl, NS_LITERAL_STRING("profile-before-change").get());
|
||||
svc->AddObserver(impl, NS_LITERAL_STRING("profile-do-change").get());
|
||||
}
|
||||
// Set up the result pointer
|
||||
rv = impl->QueryInterface(aIID, aResult);
|
||||
}
|
||||
|
||||
NS_RELEASE(impl);
|
||||
@ -407,6 +391,10 @@ static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
rv = remote->Init((const char*) nsFileURL(spec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Read the datasource synchronously.
|
||||
rv = remote->Refresh(PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// register this as a named data source with the RDF service
|
||||
nsCOMPtr<nsIRDFService> rdf = do_GetService(kRDFServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
@ -419,6 +407,15 @@ static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to register local store");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Register as an observer of profile changes
|
||||
nsCOMPtr<nsIObserverService> obs =
|
||||
do_GetService(NS_OBSERVERSERVICE_CONTRACTID);
|
||||
|
||||
if (obs) {
|
||||
obs->AddObserver(this, NS_LITERAL_STRING("profile-before-change").get());
|
||||
obs->AddObserver(this, NS_LITERAL_STRING("profile-do-change").get());
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user