зеркало из https://github.com/mozilla/gecko-dev.git
96117 - Cache Observer service. r=dp, sr=waterson
This commit is contained in:
Родитель
a765b24b69
Коммит
28d9dc0a0d
|
@ -27,9 +27,10 @@
|
|||
#include "nsIParserNode.h"
|
||||
#include "nsParserNode.h"
|
||||
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
nsIObserverService *CObserverService::gObserverService = NULL;
|
||||
|
||||
MOZ_DECL_CTOR_COUNTER(nsEntryStack)
|
||||
MOZ_DECL_CTOR_COUNTER(nsDTDContext)
|
||||
MOZ_DECL_CTOR_COUNTER(nsTokenAllocator)
|
||||
|
@ -1595,6 +1596,23 @@ nsresult nsObserverTopic::Notify(eHTMLTags aTag,nsIParserNode& aNode,void* aUniq
|
|||
observers by topic. Up till now, they've all just be thrown into the same
|
||||
observer list, which was wrong. This fixes bug #28825.
|
||||
******************************************************************************/
|
||||
nsresult
|
||||
CObserverService::InitGlobals() {
|
||||
if (!gObserverService) {
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIObserverService> obs(do_GetService(NS_OBSERVERSERVICE_CONTRACTID,&rv));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
gObserverService = obs.get();
|
||||
NS_IF_ADDREF(gObserverService);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
CObserverService::ReleaseGlobals() {
|
||||
NS_IF_RELEASE(gObserverService);
|
||||
}
|
||||
|
||||
CObserverService::CObserverService() : mTopics(0) {
|
||||
|
||||
|
@ -1653,13 +1671,9 @@ nsObserverTopic* CObserverService::CreateTopic(const nsString& aTopic) {
|
|||
|
||||
void CObserverService::RegisterObservers(const nsString& aTopic) {
|
||||
nsresult result = NS_OK;
|
||||
nsIObserverService* theObserverService = nsnull;
|
||||
result = nsServiceManager::GetService(NS_OBSERVERSERVICE_CONTRACTID, NS_GET_IID(nsIObserverService),
|
||||
(nsISupports**) &theObserverService, nsnull);
|
||||
if(result == NS_OK){
|
||||
if (gObserverService) {
|
||||
nsIEnumerator* theEnum = nsnull;
|
||||
result = theObserverService->EnumerateObserverList(aTopic.get(), &theEnum);
|
||||
nsServiceManager::ReleaseService(NS_OBSERVERSERVICE_CONTRACTID, theObserverService);
|
||||
result = gObserverService->EnumerateObserverList(aTopic.get(), &theEnum);
|
||||
|
||||
if(result == NS_OK) {
|
||||
nsCOMPtr<nsIElementObserver> theElementObserver;
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "nsIParserNode.h"
|
||||
#include "nsFixedSizeAllocator.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsIObserverService.h"
|
||||
|
||||
#define IF_HOLD(_ptr) \
|
||||
PR_BEGIN_MACRO \
|
||||
|
@ -553,10 +554,16 @@ public:
|
|||
nsObserverTopic* GetTopic(const nsString& aTopic);
|
||||
nsObserverTopic* CreateTopic(const nsString& aTopic);
|
||||
|
||||
// Do allocation and release of gObserverService
|
||||
// These are called from the module init and shutdown
|
||||
static nsresult InitGlobals();
|
||||
static void ReleaseGlobals();
|
||||
|
||||
protected:
|
||||
void RegisterObservers(const nsString& aTopic);
|
||||
void UnregisterObservers(const nsString& aTopic);
|
||||
nsDeque mTopics; //each topic holds a list of observers per tag.
|
||||
static nsIObserverService *gObserverService;
|
||||
};
|
||||
|
||||
/*********************************************************************************************/
|
||||
|
|
|
@ -187,6 +187,7 @@ Initialize(nsIModule* aSelf)
|
|||
nsHTMLEntities::AddRefTable();
|
||||
InitializeElementTable();
|
||||
CNewlineToken::AllocNewline();
|
||||
CObserverService::InitGlobals();
|
||||
gInitialized = PR_TRUE;
|
||||
}
|
||||
return NS_OK;
|
||||
|
@ -202,6 +203,7 @@ Shutdown(nsIModule* aSelf)
|
|||
nsParser::FreeSharedObjects();
|
||||
DeleteElementTable();
|
||||
CNewlineToken::FreeNewline();
|
||||
CObserverService::ReleaseGlobals();
|
||||
gInitialized = PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,9 +27,10 @@
|
|||
#include "nsIParserNode.h"
|
||||
#include "nsParserNode.h"
|
||||
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
nsIObserverService *CObserverService::gObserverService = NULL;
|
||||
|
||||
MOZ_DECL_CTOR_COUNTER(nsEntryStack)
|
||||
MOZ_DECL_CTOR_COUNTER(nsDTDContext)
|
||||
MOZ_DECL_CTOR_COUNTER(nsTokenAllocator)
|
||||
|
@ -1595,6 +1596,23 @@ nsresult nsObserverTopic::Notify(eHTMLTags aTag,nsIParserNode& aNode,void* aUniq
|
|||
observers by topic. Up till now, they've all just be thrown into the same
|
||||
observer list, which was wrong. This fixes bug #28825.
|
||||
******************************************************************************/
|
||||
nsresult
|
||||
CObserverService::InitGlobals() {
|
||||
if (!gObserverService) {
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIObserverService> obs(do_GetService(NS_OBSERVERSERVICE_CONTRACTID,&rv));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
gObserverService = obs.get();
|
||||
NS_IF_ADDREF(gObserverService);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
CObserverService::ReleaseGlobals() {
|
||||
NS_IF_RELEASE(gObserverService);
|
||||
}
|
||||
|
||||
CObserverService::CObserverService() : mTopics(0) {
|
||||
|
||||
|
@ -1653,13 +1671,9 @@ nsObserverTopic* CObserverService::CreateTopic(const nsString& aTopic) {
|
|||
|
||||
void CObserverService::RegisterObservers(const nsString& aTopic) {
|
||||
nsresult result = NS_OK;
|
||||
nsIObserverService* theObserverService = nsnull;
|
||||
result = nsServiceManager::GetService(NS_OBSERVERSERVICE_CONTRACTID, NS_GET_IID(nsIObserverService),
|
||||
(nsISupports**) &theObserverService, nsnull);
|
||||
if(result == NS_OK){
|
||||
if (gObserverService) {
|
||||
nsIEnumerator* theEnum = nsnull;
|
||||
result = theObserverService->EnumerateObserverList(aTopic.get(), &theEnum);
|
||||
nsServiceManager::ReleaseService(NS_OBSERVERSERVICE_CONTRACTID, theObserverService);
|
||||
result = gObserverService->EnumerateObserverList(aTopic.get(), &theEnum);
|
||||
|
||||
if(result == NS_OK) {
|
||||
nsCOMPtr<nsIElementObserver> theElementObserver;
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "nsIParserNode.h"
|
||||
#include "nsFixedSizeAllocator.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsIObserverService.h"
|
||||
|
||||
#define IF_HOLD(_ptr) \
|
||||
PR_BEGIN_MACRO \
|
||||
|
@ -553,10 +554,16 @@ public:
|
|||
nsObserverTopic* GetTopic(const nsString& aTopic);
|
||||
nsObserverTopic* CreateTopic(const nsString& aTopic);
|
||||
|
||||
// Do allocation and release of gObserverService
|
||||
// These are called from the module init and shutdown
|
||||
static nsresult InitGlobals();
|
||||
static void ReleaseGlobals();
|
||||
|
||||
protected:
|
||||
void RegisterObservers(const nsString& aTopic);
|
||||
void UnregisterObservers(const nsString& aTopic);
|
||||
nsDeque mTopics; //each topic holds a list of observers per tag.
|
||||
static nsIObserverService *gObserverService;
|
||||
};
|
||||
|
||||
/*********************************************************************************************/
|
||||
|
|
|
@ -187,6 +187,7 @@ Initialize(nsIModule* aSelf)
|
|||
nsHTMLEntities::AddRefTable();
|
||||
InitializeElementTable();
|
||||
CNewlineToken::AllocNewline();
|
||||
CObserverService::InitGlobals();
|
||||
gInitialized = PR_TRUE;
|
||||
}
|
||||
return NS_OK;
|
||||
|
@ -202,6 +203,7 @@ Shutdown(nsIModule* aSelf)
|
|||
nsParser::FreeSharedObjects();
|
||||
DeleteElementTable();
|
||||
CNewlineToken::FreeNewline();
|
||||
CObserverService::ReleaseGlobals();
|
||||
gInitialized = PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче