diff --git a/netwerk/protocol/http/src/nsHttpHandler.cpp b/netwerk/protocol/http/src/nsHttpHandler.cpp index 3331c39b3642..c148bc1854a6 100644 --- a/netwerk/protocol/http/src/nsHttpHandler.cpp +++ b/netwerk/protocol/http/src/nsHttpHandler.cpp @@ -228,7 +228,9 @@ nsHttpHandler::Init() // Startup the http category // Bring alive the objects in the http-protocol-startup category - CreateServicesFromCategory(NS_HTTP_STARTUP_CATEGORY); + NS_CreateServicesFromCategory(NS_HTTP_STARTUP_CATEGORY, + NS_STATIC_CAST(nsISupports*,NS_STATIC_CAST(void*,this)), + NS_HTTP_STARTUP_TOPIC); nsCOMPtr observerSvc = do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv); @@ -1265,67 +1267,6 @@ nsHttpHandler::PrefsCallback(const char *pref, void *self) return 0; } -/* - * CreateServicesFromCategory() - * - * Given a category, this convenience functions enumerates the category and - * creates a service of every CID or ContractID registered under the category - * - * @category: Input category - * @return: returns error if any CID or ContractID registered failed to create. - */ -nsresult -nsHttpHandler::CreateServicesFromCategory(const char *category) -{ - nsresult rv = NS_OK; - - int nFailed = 0; - nsCOMPtr categoryManager = - do_GetService("@mozilla.org/categorymanager;1", &rv); - if (!categoryManager) return rv; - - nsCOMPtr enumerator; - rv = categoryManager->EnumerateCategory(category, - getter_AddRefs(enumerator)); - if (NS_FAILED(rv)) return rv; - - nsCOMPtr entry; - while (NS_SUCCEEDED(enumerator->GetNext(getter_AddRefs(entry)))) { - // From here on just skip any error we get. - nsCOMPtr 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; - } - - LOG(("nsHttpHandler: instantiating [%s]\n", (const char *)contractID)); - - nsCOMPtr instance = do_GetService(contractID, &rv); - if (NS_FAILED(rv)) - nFailed++; - - // try an observer, if it implements it. - nsCOMPtr observer = do_QueryInterface(instance, &rv); - if (NS_SUCCEEDED(rv) && observer) - observer->Observe(NS_STATIC_CAST(nsISupports*,NS_STATIC_CAST(void*,this)), - NS_HTTP_STARTUP_TOPIC, - NS_LITERAL_STRING("").get()); - } - return (nFailed ? NS_ERROR_FAILURE : NS_OK); -} - /** * Allocates a C string into that contains a ISO 639 language list * notated with HTTP "q" values for output with a HTTP Accept-Language diff --git a/netwerk/protocol/http/src/nsHttpHandler.h b/netwerk/protocol/http/src/nsHttpHandler.h index 4e5c819aa0a1..4e4ba191c04b 100644 --- a/netwerk/protocol/http/src/nsHttpHandler.h +++ b/netwerk/protocol/http/src/nsHttpHandler.h @@ -187,8 +187,6 @@ private: static PRInt32 PR_CALLBACK PrefsCallback(const char *, void *); - nsresult CreateServicesFromCategory(const char *category); - private: static nsHttpHandler *mGlobalInstance;