Bug 549388 - Don't use refcounting for nsProxyObjectManager: create it once, and destroy it at shutdown after all the clients have finished with it, r=timeless

--HG--
extra : rebase_source : d4c0486a748675e29de713a8a55ee594764c4c9b
This commit is contained in:
Benjamin Smedberg 2010-05-21 11:50:05 -04:00
Родитель fe1ee01716
Коммит 5ff9ae27f9
3 изменённых файлов: 22 добавлений и 14 удалений

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

@ -347,10 +347,6 @@ nsProxyObject::nsProxyObject(nsIEventTarget *target, PRInt32 proxyType,
NS_ASSERTION(target == canonicalTarget,
"Non-canonical nsISupports passed to nsProxyObject constructor");
#endif
nsProxyObjectManager *pom = nsProxyObjectManager::GetInstance();
NS_ASSERTION(pom, "Creating a proxy without a global proxy-object-manager.");
pom->AddRef();
}
nsProxyObject::~nsProxyObject()
@ -400,7 +396,6 @@ nsProxyObject::LockedRelease()
nsAutoUnlock unlock(pom->GetLock());
delete this;
pom->Release();
return 0;
}

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

@ -299,7 +299,7 @@ public:
private:
~nsProxyObjectManager();
static nsProxyObjectManager* mInstance;
static nsProxyObjectManager* gInstance;
nsHashtable mProxyObjectMap;
nsClassHashtable<nsIDHashKey, nsProxyEventClass> mProxyClassMap;
PRLock *mProxyCreationLock;

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

@ -96,9 +96,21 @@ protected:
// nsProxyObjectManager
/////////////////////////////////////////////////////////////////////////
nsProxyObjectManager* nsProxyObjectManager::mInstance = nsnull;
nsProxyObjectManager* nsProxyObjectManager::gInstance = nsnull;
NS_IMPL_THREADSAFE_ISUPPORTS1(nsProxyObjectManager, nsIProxyObjectManager)
NS_IMPL_QUERY_INTERFACE1(nsProxyObjectManager, nsIProxyObjectManager)
NS_IMETHODIMP_(nsrefcnt)
nsProxyObjectManager::AddRef()
{
return 2;
}
NS_IMETHODIMP_(nsrefcnt)
nsProxyObjectManager::Release()
{
return 1;
}
nsProxyObjectManager::nsProxyObjectManager()
: mProxyObjectMap(256, PR_FALSE)
@ -114,27 +126,28 @@ nsProxyObjectManager::~nsProxyObjectManager()
if (mProxyCreationLock)
PR_DestroyLock(mProxyCreationLock);
nsProxyObjectManager::mInstance = nsnull;
nsProxyObjectManager::gInstance = nsnull;
}
PRBool
nsProxyObjectManager::IsManagerShutdown()
{
return mInstance == nsnull;
return gInstance == nsnull;
}
nsProxyObjectManager *
nsProxyObjectManager::GetInstance()
{
if (!mInstance)
mInstance = new nsProxyObjectManager();
return mInstance;
if (!gInstance)
gInstance = new nsProxyObjectManager();
return gInstance;
}
void
nsProxyObjectManager::Shutdown()
{
mInstance = nsnull;
delete gInstance;
NS_ASSERTION(!gInstance, "Destructor didn't null gInstance?");
}
NS_IMETHODIMP