Changed NSServiceManager to nsServiceManager.

This commit is contained in:
warren%netscape.com 1998-09-01 00:17:47 +00:00
Родитель 8a20456a35
Коммит 71e9f3f5ea
4 изменённых файлов: 47 добавлений и 47 удалений

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

@ -133,7 +133,7 @@ nsServiceEntry::NotifyListeners(void)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
class nsServiceManager : public nsIServiceManager { class nsServiceManagerImpl : public nsIServiceManager {
public: public:
NS_IMETHOD NS_IMETHOD
@ -148,18 +148,18 @@ public:
NS_IMETHOD NS_IMETHOD
ShutdownService(const nsCID& aClass); ShutdownService(const nsCID& aClass);
nsServiceManager(void); nsServiceManagerImpl(void);
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
protected: protected:
virtual ~nsServiceManager(void); virtual ~nsServiceManagerImpl(void);
nsHashtable* mServices; // nsHashtable<nsServiceEntry> nsHashtable* mServices; // nsHashtable<nsServiceEntry>
}; };
nsServiceManager::nsServiceManager(void) nsServiceManagerImpl::nsServiceManagerImpl(void)
{ {
NS_INIT_REFCNT(); NS_INIT_REFCNT();
mServices = new nsHashtable(); mServices = new nsHashtable();
@ -167,7 +167,7 @@ nsServiceManager::nsServiceManager(void)
} }
static PRBool static PRBool
DeleteEntry(nsHashKey *aKey, void *aData) DeleteEntry(nsHashKey *aKey, void *aData, void* closure)
{ {
nsServiceEntry* entry = (nsServiceEntry*)aData; nsServiceEntry* entry = (nsServiceEntry*)aData;
entry->mService->Release(); entry->mService->Release();
@ -175,7 +175,7 @@ DeleteEntry(nsHashKey *aKey, void *aData)
return PR_TRUE; return PR_TRUE;
} }
nsServiceManager::~nsServiceManager(void) nsServiceManagerImpl::~nsServiceManagerImpl(void)
{ {
mServices->Enumerate(DeleteEntry); mServices->Enumerate(DeleteEntry);
delete mServices; delete mServices;
@ -184,11 +184,11 @@ nsServiceManager::~nsServiceManager(void)
static NS_DEFINE_IID(kIServiceManagerIID, NS_ISERVICEMANAGER_IID); static NS_DEFINE_IID(kIServiceManagerIID, NS_ISERVICEMANAGER_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
NS_IMPL_ADDREF(nsServiceManager); NS_IMPL_ADDREF(nsServiceManagerImpl);
NS_IMPL_RELEASE(nsServiceManager); NS_IMPL_RELEASE(nsServiceManagerImpl);
nsresult nsresult
nsServiceManager::QueryInterface(const nsIID& aIID, void* *aInstancePtr) nsServiceManagerImpl::QueryInterface(const nsIID& aIID, void* *aInstancePtr)
{ {
if (NULL == aInstancePtr) { if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
@ -204,7 +204,7 @@ nsServiceManager::QueryInterface(const nsIID& aIID, void* *aInstancePtr)
} }
nsresult nsresult
nsServiceManager::GetService(const nsCID& aClass, const nsIID& aIID, nsServiceManagerImpl::GetService(const nsCID& aClass, const nsIID& aIID,
nsISupports* *result, nsISupports* *result,
nsIShutdownListener* shutdownListener) nsIShutdownListener* shutdownListener)
{ {
@ -226,7 +226,7 @@ nsServiceManager::GetService(const nsCID& aClass, const nsIID& aIID,
} }
else { else {
nsISupports* service; nsISupports* service;
err = NSRepository::CreateInstance(aClass, NULL, aIID, (void**)&service); err = nsRepository::CreateInstance(aClass, NULL, aIID, (void**)&service);
if (err == NS_OK) { if (err == NS_OK) {
entry = new nsServiceEntry(aClass, service); entry = new nsServiceEntry(aClass, service);
if (entry == NULL) { if (entry == NULL) {
@ -252,7 +252,7 @@ nsServiceManager::GetService(const nsCID& aClass, const nsIID& aIID,
} }
nsresult nsresult
nsServiceManager::ReleaseService(const nsCID& aClass, nsISupports* service, nsServiceManagerImpl::ReleaseService(const nsCID& aClass, nsISupports* service,
nsIShutdownListener* shutdownListener) nsIShutdownListener* shutdownListener)
{ {
nsresult err = NS_OK; nsresult err = NS_OK;
@ -281,7 +281,7 @@ nsServiceManager::ReleaseService(const nsCID& aClass, nsISupports* service,
} }
nsresult nsresult
nsServiceManager::ShutdownService(const nsCID& aClass) nsServiceManagerImpl::ShutdownService(const nsCID& aClass)
{ {
nsresult err = NS_OK; nsresult err = NS_OK;
PR_CEnterMonitor(this); PR_CEnterMonitor(this);
@ -298,7 +298,7 @@ nsServiceManager::ShutdownService(const nsCID& aClass)
nsrefcnt cnt = entry->mService->Release(); nsrefcnt cnt = entry->mService->Release();
if (err == NS_OK && cnt == 0) { if (err == NS_OK && cnt == 0) {
mServices->Remove(&key); mServices->Remove(&key);
err = NSRepository::FreeLibraries(); err = nsRepository::FreeLibraries();
} }
else else
err = NS_ERROR_SERVICE_IN_USE; err = NS_ERROR_SERVICE_IN_USE;
@ -311,13 +311,13 @@ nsServiceManager::ShutdownService(const nsCID& aClass)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Global service manager interface (see nsIServiceManager.h) // Global service manager interface (see nsIServiceManager.h)
nsIServiceManager* NSServiceManager::globalServiceManager = NULL; nsIServiceManager* nsServiceManager::globalServiceManager = NULL;
nsresult nsresult
NSServiceManager::GetGlobalServiceManager(nsIServiceManager* *result) nsServiceManager::GetGlobalServiceManager(nsIServiceManager* *result)
{ {
if (globalServiceManager == NULL) { if (globalServiceManager == NULL) {
globalServiceManager = new nsServiceManager(); globalServiceManager = new nsServiceManagerImpl();
if (globalServiceManager == NULL) if (globalServiceManager == NULL)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
globalServiceManager->AddRef(); globalServiceManager->AddRef();
@ -327,7 +327,7 @@ NSServiceManager::GetGlobalServiceManager(nsIServiceManager* *result)
} }
nsresult nsresult
NSServiceManager::GetService(const nsCID& aClass, const nsIID& aIID, nsServiceManager::GetService(const nsCID& aClass, const nsIID& aIID,
nsISupports* *result, nsISupports* *result,
nsIShutdownListener* shutdownListener) nsIShutdownListener* shutdownListener)
{ {
@ -338,7 +338,7 @@ NSServiceManager::GetService(const nsCID& aClass, const nsIID& aIID,
} }
nsresult nsresult
NSServiceManager::ReleaseService(const nsCID& aClass, nsISupports* service, nsServiceManager::ReleaseService(const nsCID& aClass, nsISupports* service,
nsIShutdownListener* shutdownListener) nsIShutdownListener* shutdownListener)
{ {
nsIServiceManager* mgr; nsIServiceManager* mgr;
@ -348,7 +348,7 @@ NSServiceManager::ReleaseService(const nsCID& aClass, nsISupports* service,
} }
nsresult nsresult
NSServiceManager::ShutdownService(const nsCID& aClass) nsServiceManager::ShutdownService(const nsCID& aClass)
{ {
nsIServiceManager* mgr; nsIServiceManager* mgr;
nsresult rslt = GetGlobalServiceManager(&mgr); nsresult rslt = GetGlobalServiceManager(&mgr);

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

@ -123,7 +123,7 @@ public:
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Interface to Global Services // Interface to Global Services
class NS_COM NSServiceManager { class NS_COM nsServiceManager {
public: public:
static nsresult GetService(const nsCID& aClass, const nsIID& aIID, static nsresult GetService(const nsCID& aClass, const nsIID& aIID,
nsISupports* *result, nsISupports* *result,

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

@ -133,7 +133,7 @@ nsServiceEntry::NotifyListeners(void)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
class nsServiceManager : public nsIServiceManager { class nsServiceManagerImpl : public nsIServiceManager {
public: public:
NS_IMETHOD NS_IMETHOD
@ -148,18 +148,18 @@ public:
NS_IMETHOD NS_IMETHOD
ShutdownService(const nsCID& aClass); ShutdownService(const nsCID& aClass);
nsServiceManager(void); nsServiceManagerImpl(void);
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
protected: protected:
virtual ~nsServiceManager(void); virtual ~nsServiceManagerImpl(void);
nsHashtable* mServices; // nsHashtable<nsServiceEntry> nsHashtable* mServices; // nsHashtable<nsServiceEntry>
}; };
nsServiceManager::nsServiceManager(void) nsServiceManagerImpl::nsServiceManagerImpl(void)
{ {
NS_INIT_REFCNT(); NS_INIT_REFCNT();
mServices = new nsHashtable(); mServices = new nsHashtable();
@ -167,7 +167,7 @@ nsServiceManager::nsServiceManager(void)
} }
static PRBool static PRBool
DeleteEntry(nsHashKey *aKey, void *aData) DeleteEntry(nsHashKey *aKey, void *aData, void* closure)
{ {
nsServiceEntry* entry = (nsServiceEntry*)aData; nsServiceEntry* entry = (nsServiceEntry*)aData;
entry->mService->Release(); entry->mService->Release();
@ -175,7 +175,7 @@ DeleteEntry(nsHashKey *aKey, void *aData)
return PR_TRUE; return PR_TRUE;
} }
nsServiceManager::~nsServiceManager(void) nsServiceManagerImpl::~nsServiceManagerImpl(void)
{ {
mServices->Enumerate(DeleteEntry); mServices->Enumerate(DeleteEntry);
delete mServices; delete mServices;
@ -184,11 +184,11 @@ nsServiceManager::~nsServiceManager(void)
static NS_DEFINE_IID(kIServiceManagerIID, NS_ISERVICEMANAGER_IID); static NS_DEFINE_IID(kIServiceManagerIID, NS_ISERVICEMANAGER_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
NS_IMPL_ADDREF(nsServiceManager); NS_IMPL_ADDREF(nsServiceManagerImpl);
NS_IMPL_RELEASE(nsServiceManager); NS_IMPL_RELEASE(nsServiceManagerImpl);
nsresult nsresult
nsServiceManager::QueryInterface(const nsIID& aIID, void* *aInstancePtr) nsServiceManagerImpl::QueryInterface(const nsIID& aIID, void* *aInstancePtr)
{ {
if (NULL == aInstancePtr) { if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
@ -204,7 +204,7 @@ nsServiceManager::QueryInterface(const nsIID& aIID, void* *aInstancePtr)
} }
nsresult nsresult
nsServiceManager::GetService(const nsCID& aClass, const nsIID& aIID, nsServiceManagerImpl::GetService(const nsCID& aClass, const nsIID& aIID,
nsISupports* *result, nsISupports* *result,
nsIShutdownListener* shutdownListener) nsIShutdownListener* shutdownListener)
{ {
@ -226,7 +226,7 @@ nsServiceManager::GetService(const nsCID& aClass, const nsIID& aIID,
} }
else { else {
nsISupports* service; nsISupports* service;
err = NSRepository::CreateInstance(aClass, NULL, aIID, (void**)&service); err = nsRepository::CreateInstance(aClass, NULL, aIID, (void**)&service);
if (err == NS_OK) { if (err == NS_OK) {
entry = new nsServiceEntry(aClass, service); entry = new nsServiceEntry(aClass, service);
if (entry == NULL) { if (entry == NULL) {
@ -252,7 +252,7 @@ nsServiceManager::GetService(const nsCID& aClass, const nsIID& aIID,
} }
nsresult nsresult
nsServiceManager::ReleaseService(const nsCID& aClass, nsISupports* service, nsServiceManagerImpl::ReleaseService(const nsCID& aClass, nsISupports* service,
nsIShutdownListener* shutdownListener) nsIShutdownListener* shutdownListener)
{ {
nsresult err = NS_OK; nsresult err = NS_OK;
@ -281,7 +281,7 @@ nsServiceManager::ReleaseService(const nsCID& aClass, nsISupports* service,
} }
nsresult nsresult
nsServiceManager::ShutdownService(const nsCID& aClass) nsServiceManagerImpl::ShutdownService(const nsCID& aClass)
{ {
nsresult err = NS_OK; nsresult err = NS_OK;
PR_CEnterMonitor(this); PR_CEnterMonitor(this);
@ -298,7 +298,7 @@ nsServiceManager::ShutdownService(const nsCID& aClass)
nsrefcnt cnt = entry->mService->Release(); nsrefcnt cnt = entry->mService->Release();
if (err == NS_OK && cnt == 0) { if (err == NS_OK && cnt == 0) {
mServices->Remove(&key); mServices->Remove(&key);
err = NSRepository::FreeLibraries(); err = nsRepository::FreeLibraries();
} }
else else
err = NS_ERROR_SERVICE_IN_USE; err = NS_ERROR_SERVICE_IN_USE;
@ -311,13 +311,13 @@ nsServiceManager::ShutdownService(const nsCID& aClass)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Global service manager interface (see nsIServiceManager.h) // Global service manager interface (see nsIServiceManager.h)
nsIServiceManager* NSServiceManager::globalServiceManager = NULL; nsIServiceManager* nsServiceManager::globalServiceManager = NULL;
nsresult nsresult
NSServiceManager::GetGlobalServiceManager(nsIServiceManager* *result) nsServiceManager::GetGlobalServiceManager(nsIServiceManager* *result)
{ {
if (globalServiceManager == NULL) { if (globalServiceManager == NULL) {
globalServiceManager = new nsServiceManager(); globalServiceManager = new nsServiceManagerImpl();
if (globalServiceManager == NULL) if (globalServiceManager == NULL)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
globalServiceManager->AddRef(); globalServiceManager->AddRef();
@ -327,7 +327,7 @@ NSServiceManager::GetGlobalServiceManager(nsIServiceManager* *result)
} }
nsresult nsresult
NSServiceManager::GetService(const nsCID& aClass, const nsIID& aIID, nsServiceManager::GetService(const nsCID& aClass, const nsIID& aIID,
nsISupports* *result, nsISupports* *result,
nsIShutdownListener* shutdownListener) nsIShutdownListener* shutdownListener)
{ {
@ -338,7 +338,7 @@ NSServiceManager::GetService(const nsCID& aClass, const nsIID& aIID,
} }
nsresult nsresult
NSServiceManager::ReleaseService(const nsCID& aClass, nsISupports* service, nsServiceManager::ReleaseService(const nsCID& aClass, nsISupports* service,
nsIShutdownListener* shutdownListener) nsIShutdownListener* shutdownListener)
{ {
nsIServiceManager* mgr; nsIServiceManager* mgr;
@ -348,7 +348,7 @@ NSServiceManager::ReleaseService(const nsCID& aClass, nsISupports* service,
} }
nsresult nsresult
NSServiceManager::ShutdownService(const nsCID& aClass) nsServiceManager::ShutdownService(const nsCID& aClass)
{ {
nsIServiceManager* mgr; nsIServiceManager* mgr;
nsresult rslt = GetGlobalServiceManager(&mgr); nsresult rslt = GetGlobalServiceManager(&mgr);

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

@ -32,7 +32,7 @@ BeginTest(int testNumber, nsIShutdownListener* listener)
{ {
nsresult err; nsresult err;
NS_ASSERTION(myServ == NULL, "myServ not reset"); NS_ASSERTION(myServ == NULL, "myServ not reset");
err = NSServiceManager::GetService(kIMyServiceCID, kIMyServiceIID, err = nsServiceManager::GetService(kIMyServiceCID, kIMyServiceIID,
(nsISupports**)&myServ, listener); (nsISupports**)&myServ, listener);
return err; return err;
} }
@ -46,7 +46,7 @@ EndTest(int testNumber, nsIShutdownListener* listener)
err = myServ->Doit(); err = myServ->Doit();
if (err != NS_OK) return err; if (err != NS_OK) return err;
err = NSServiceManager::ReleaseService(kIMyServiceCID, myServ, listener); err = nsServiceManager::ReleaseService(kIMyServiceCID, myServ, listener);
if (err != NS_OK) return err; if (err != NS_OK) return err;
myServ = NULL; myServ = NULL;
} }
@ -103,7 +103,7 @@ AsyncShutdown(int testNumber)
// thread, we'd have to protect all accesses to myServ throughout this // thread, we'd have to protect all accesses to myServ throughout this
// code with a monitor. // code with a monitor.
err = NSServiceManager::ShutdownService(kIMyServiceCID); err = nsServiceManager::ShutdownService(kIMyServiceCID);
if (err == NS_ERROR_SERVICE_IN_USE) { if (err == NS_ERROR_SERVICE_IN_USE) {
printf("async shutdown -- service still in use\n"); printf("async shutdown -- service still in use\n");
return NS_OK; return NS_OK;
@ -158,7 +158,7 @@ AsyncNoShutdownTest(int testNumber)
// Create some other user of kIMyServiceCID, preventing it from // Create some other user of kIMyServiceCID, preventing it from
// really going away: // really going away:
IMyService* otherClient; IMyService* otherClient;
err = NSServiceManager::GetService(kIMyServiceCID, kIMyServiceIID, err = nsServiceManager::GetService(kIMyServiceCID, kIMyServiceIID,
(nsISupports**)&otherClient); (nsISupports**)&otherClient);
if (err != NS_OK) return err; if (err != NS_OK) return err;
@ -167,7 +167,7 @@ AsyncNoShutdownTest(int testNumber)
err = EndTest(testNumber, listener); err = EndTest(testNumber, listener);
// Finally, release the other client. // Finally, release the other client.
err = NSServiceManager::ReleaseService(kIMyServiceCID, otherClient); err = nsServiceManager::ReleaseService(kIMyServiceCID, otherClient);
if (err != NS_OK) return err; if (err != NS_OK) return err;
nsrefcnt cnt = listener->Release(); nsrefcnt cnt = listener->Release();
@ -182,7 +182,7 @@ SetupFactories(void)
{ {
nsresult err; nsresult err;
// seed the repository (hack) // seed the repository (hack)
err = NSRepository::RegisterFactory(kIMyServiceCID, "MyService.dll", err = nsRepository::RegisterFactory(kIMyServiceCID, "MyService.dll",
PR_TRUE, PR_FALSE); PR_TRUE, PR_FALSE);
NS_ASSERTION(err == NS_OK, "failed to register my factory"); NS_ASSERTION(err == NS_OK, "failed to register my factory");
} }