99163 - removing nsObserverService.h includes. Also fixing 106090, extra methods on nsObserverService. r=shaver@mozilla.org, sr=jband@netscape.com

git-svn-id: svn://10.0.0.236/trunk@105973 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
dougt%netscape.com
2001-10-22 22:01:27 +00:00
parent 1403ab79f6
commit fa2d0b7e98
69 changed files with 115 additions and 182 deletions

View File

@@ -37,6 +37,7 @@
* ***** END LICENSE BLOCK ***** */
#define NS_IMPL_IDS
#include "prlog.h"
#include "prlock.h"
#include "nsIFactory.h"
#include "nsIServiceManager.h"
@@ -51,9 +52,19 @@
static NS_DEFINE_CID(kObserverServiceCID, NS_OBSERVERSERVICE_CID);
////////////////////////////////////////////////////////////////////////////////
static nsObserverService* gObserverService = nsnull; // The one-and-only ObserverService
#if defined(PR_LOGGING)
// Log module for nsObserverService logging...
//
// To enable logging (see prlog.h for full details):
//
// set NSPR_LOG_MODULES=ObserverService:5
// set NSPR_LOG_FILE=nspr.log
//
// this enables PR_LOG_DEBUG level information and places all output in
// the file nspr.log
PRLogModuleInfo* observerServiceLog = nsnull;
#endif /* PR_LOGGING */
////////////////////////////////////////////////////////////////////////////////
// nsObserverService Implementation
@@ -61,11 +72,6 @@ static nsObserverService* gObserverService = nsnull; // The one-and-only Observe
NS_IMPL_THREADSAFE_ISUPPORTS1(nsObserverService, nsIObserverService)
NS_COM nsresult NS_NewObserverService(nsIObserverService** anObserverService)
{
return nsObserverService::GetObserverService(anObserverService);
}
nsObserverService::nsObserverService()
: mObserverTopicTable(nsnull)
{
@@ -77,12 +83,16 @@ nsObserverService::~nsObserverService(void)
{
if(mObserverTopicTable)
delete mObserverTopicTable;
gObserverService = nsnull;
}
NS_METHOD
nsObserverService::Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr)
{
#if defined(PR_LOGGING)
if (!observerServiceLog)
observerServiceLog = PR_NewLogModule("ObserverService");
#endif
nsresult rv;
nsObserverService* os = new nsObserverService();
if (os == nsnull)
@@ -93,20 +103,6 @@ nsObserverService::Create(nsISupports* outer, const nsIID& aIID, void* *aInstanc
return rv;
}
nsresult nsObserverService::GetObserverService(nsIObserverService** anObserverService)
{
if (! gObserverService) {
nsObserverService* it = new nsObserverService();
if (! it)
return NS_ERROR_OUT_OF_MEMORY;
gObserverService = it;
}
NS_ADDREF(gObserverService);
*anObserverService = gObserverService;
return NS_OK;
}
static PRBool PR_CALLBACK
ReleaseObserverList(nsHashKey *aKey, void *aData, void* closure)
{
@@ -223,6 +219,9 @@ NS_IMETHODIMP nsObserverService::NotifyObservers( nsISupports *aSubject,
if ( observer )
observer->Observe( aSubject, aTopic, someData );
PR_LOG(observerServiceLog, PR_LOG_DEBUG, ("Notification - %s\n", aTopic ? aTopic : "undefined"));
}
#endif
}