зеркало из https://github.com/mozilla/pjs.git
386376 get services lazily in order to avoid recursive getService calls
r=bsmedberg
This commit is contained in:
Родитель
4c4b9931ca
Коммит
1a21866674
|
@ -102,7 +102,7 @@ public:
|
|||
PRUint32 flags);
|
||||
|
||||
// Gets the array of registered content sniffers
|
||||
const nsCOMArray<nsIContentSniffer>& GetContentSniffers() const {
|
||||
const nsCOMArray<nsIContentSniffer>& GetContentSniffers() {
|
||||
return mContentSniffers.GetEntries();
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,13 @@ class nsCategoryCache : protected nsCategoryListener {
|
|||
explicit nsCategoryCache(const char* aCategory);
|
||||
~nsCategoryCache() { if (mObserver) mObserver->ListenerDied(); }
|
||||
|
||||
const nsCOMArray<T>& GetEntries() const { return mEntries; }
|
||||
const nsCOMArray<T>& GetEntries() {
|
||||
// Lazy initialization, so that services in this category can't
|
||||
// cause reentrant getService (bug 386376)
|
||||
if (!mObserver)
|
||||
mObserver = new nsCategoryObserver(mCategoryName.get(), this);
|
||||
return mEntries;
|
||||
}
|
||||
protected:
|
||||
virtual void EntryAdded(const nsCString& aValue);
|
||||
virtual void EntryRemoved(const nsCString& aValue);
|
||||
|
@ -102,6 +108,7 @@ class nsCategoryCache : protected nsCategoryListener {
|
|||
// Not to be implemented
|
||||
nsCategoryCache(const nsCategoryCache<T>&);
|
||||
|
||||
nsCString mCategoryName;
|
||||
nsCOMArray<T> mEntries;
|
||||
nsRefPtr<nsCategoryObserver> mObserver;
|
||||
};
|
||||
|
@ -111,8 +118,8 @@ class nsCategoryCache : protected nsCategoryListener {
|
|||
|
||||
template<class T>
|
||||
nsCategoryCache<T>::nsCategoryCache(const char* aCategory)
|
||||
: mCategoryName(aCategory)
|
||||
{
|
||||
mObserver = new nsCategoryObserver(aCategory, this);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
|
|
Загрузка…
Ссылка в новой задаче