mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
bug #14889 Lazy loading wallet dll r=morse,gagan sr=jband a=asa
This commit is contained in:
parent
6835cdd75e
commit
786ae7cdf5
@ -423,5 +423,18 @@ NS_ShutdownXPCOM(nsIServiceManager* servMgr);
|
|||||||
|
|
||||||
#define NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID "xpcom-autoregistration"
|
#define NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID "xpcom-autoregistration"
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Convenience functions
|
||||||
|
//
|
||||||
|
// CreateServicesFromCategory()
|
||||||
|
//
|
||||||
|
// Given a category, this convenience functions enumerates the category and
|
||||||
|
// creates a service of every CID or ContractID registered under the category.
|
||||||
|
// If observerTopic is non null and the service implements nsIObserver,
|
||||||
|
// this will attempt to notify the observer with this observerTopic string
|
||||||
|
// and origin as parameter.
|
||||||
|
//
|
||||||
|
extern NS_COM nsresult
|
||||||
|
NS_CreateServicesFromCategory(const char* category, nsISupports *origin, const PRUnichar *observerTopic);
|
||||||
|
|
||||||
#endif /* nsIServiceManager_h___ */
|
#endif /* nsIServiceManager_h___ */
|
||||||
|
@ -29,6 +29,8 @@
|
|||||||
#include "prcmon.h"
|
#include "prcmon.h"
|
||||||
#include "prthread.h" /* XXX: only used for the NSPR initialization hack (rick) */
|
#include "prthread.h" /* XXX: only used for the NSPR initialization hack (rick) */
|
||||||
#include "nsAutoLock.h"
|
#include "nsAutoLock.h"
|
||||||
|
#include "nsISupportsPrimitives.h"
|
||||||
|
#include "nsIObserver.h"
|
||||||
|
|
||||||
nsIServiceManager* gServiceManager = NULL;
|
nsIServiceManager* gServiceManager = NULL;
|
||||||
PRBool gShuttingDown = PR_FALSE;
|
PRBool gShuttingDown = PR_FALSE;
|
||||||
@ -303,9 +305,7 @@ nsServiceManagerImpl::GetService(const nsCID& aClass, const nsIID& aIID,
|
|||||||
// occurs in the list
|
// occurs in the list
|
||||||
if (gShuttingDown) {
|
if (gShuttingDown) {
|
||||||
// When processing shutdown, dont process new GetService() requests
|
// When processing shutdown, dont process new GetService() requests
|
||||||
#ifdef DEBUG_dp
|
NS_WARNING("Creating new service on shutdown. Denied.");
|
||||||
NS_WARN_IF_FALSE(PR_FALSE, "Creating new service on shutdown. Denied.");
|
|
||||||
#endif /* DEBUG_dp */
|
|
||||||
return NS_ERROR_UNEXPECTED;
|
return NS_ERROR_UNEXPECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -639,3 +639,67 @@ nsServiceManager::UnregisterService(const char* aContractID)
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/*
|
||||||
|
* CreateServicesFromCategory()
|
||||||
|
*
|
||||||
|
* Given a category, this convenience functions enumerates the category and
|
||||||
|
* creates a service of every CID or ContractID registered under the category.
|
||||||
|
* If observerTopic is non null and the service implements nsIObserver,
|
||||||
|
* this will attempt to notify the observer with the origin, observerTopic string
|
||||||
|
* as parameter.
|
||||||
|
*/
|
||||||
|
nsresult
|
||||||
|
NS_CreateServicesFromCategory(const char *category,
|
||||||
|
nsISupports *origin,
|
||||||
|
const PRUnichar *observerTopic)
|
||||||
|
{
|
||||||
|
nsresult rv = NS_OK;
|
||||||
|
|
||||||
|
int nFailed = 0;
|
||||||
|
nsCOMPtr<nsICategoryManager> categoryManager =
|
||||||
|
do_GetService("@mozilla.org/categorymanager;1", &rv);
|
||||||
|
if (!categoryManager) return rv;
|
||||||
|
|
||||||
|
nsCOMPtr<nsISimpleEnumerator> enumerator;
|
||||||
|
rv = categoryManager->EnumerateCategory(category,
|
||||||
|
getter_AddRefs(enumerator));
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
nsCOMPtr<nsISupports> entry;
|
||||||
|
while (NS_SUCCEEDED(enumerator->GetNext(getter_AddRefs(entry)))) {
|
||||||
|
// From here on just skip any error we get.
|
||||||
|
nsCOMPtr<nsISupportsString> catEntry = do_QueryInterface(entry, &rv);
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
nFailed++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
nsXPIDLCString entryString;
|
||||||
|
rv = catEntry->GetData(getter_Copies(entryString));
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
nFailed++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
nsXPIDLCString contractID;
|
||||||
|
rv = categoryManager->GetCategoryEntry(category,(const char *)entryString, getter_Copies(contractID));
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
nFailed++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsCOMPtr<nsISupports> instance = do_GetService(contractID, &rv);
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
nFailed++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (observerTopic) {
|
||||||
|
// try an observer, if it implements it.
|
||||||
|
nsCOMPtr<nsIObserver> observer = do_QueryInterface(instance, &rv);
|
||||||
|
if (NS_SUCCEEDED(rv) && observer)
|
||||||
|
observer->Observe(origin, observerTopic, NS_LITERAL_STRING("").get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (nFailed ? NS_ERROR_FAILURE : NS_OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user