bug 877850 - fix static constructors in xpcom/ r=jlebar

This commit is contained in:
Trevor Saunders 2013-05-30 17:20:02 -04:00
parent 7492ddf9dc
commit 0230640bc6
6 changed files with 5 additions and 20 deletions

View File

@ -29,11 +29,9 @@ public:
NS_IMETHOD GetNext(nsAString& aResult);
static EmptyEnumeratorImpl* GetInstance() {
return const_cast<EmptyEnumeratorImpl*>(&kInstance);
static const EmptyEnumeratorImpl kInstance;
return const_cast<EmptyEnumeratorImpl*>(&kInstance);
}
private:
static const EmptyEnumeratorImpl kInstance;
};
// nsISupports interface
@ -78,8 +76,6 @@ NS_IMETHODIMP EmptyEnumeratorImpl::GetNext(nsAString& aResult)
return NS_ERROR_UNEXPECTED;
}
const EmptyEnumeratorImpl EmptyEnumeratorImpl::kInstance;
nsresult
NS_NewEmptyEnumerator(nsISimpleEnumerator** aResult)
{

View File

@ -429,8 +429,6 @@ nsSimpleUnicharStreamFactory::CreateInstanceFromUTF8Stream(nsIInputStream* aStre
nsSimpleUnicharStreamFactory*
nsSimpleUnicharStreamFactory::GetInstance()
{
static const nsSimpleUnicharStreamFactory kInstance;
return const_cast<nsSimpleUnicharStreamFactory*>(&kInstance);
}
const nsSimpleUnicharStreamFactory
nsSimpleUnicharStreamFactory::kInstance;

View File

@ -24,9 +24,6 @@ public:
NS_DECL_NSISIMPLEUNICHARSTREAMFACTORY
static nsSimpleUnicharStreamFactory* GetInstance();
private:
static const nsSimpleUnicharStreamFactory kInstance;
};
#endif // nsUnicharInputStream_h__

View File

@ -85,8 +85,6 @@ public:
nsThreadClassInfo() {}
};
static nsThreadClassInfo sThreadClassInfo;
NS_IMETHODIMP_(nsrefcnt) nsThreadClassInfo::AddRef() { return 2; }
NS_IMETHODIMP_(nsrefcnt) nsThreadClassInfo::Release() { return 1; }
NS_IMPL_QUERY_INTERFACE1(nsThreadClassInfo, nsIClassInfo)
@ -156,6 +154,7 @@ NS_INTERFACE_MAP_BEGIN(nsThread)
NS_INTERFACE_MAP_ENTRY(nsISupportsPriority)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIThread)
if (aIID.Equals(NS_GET_IID(nsIClassInfo))) {
static nsThreadClassInfo sThreadClassInfo;
foundInterface = static_cast<nsIClassInfo*>(&sThreadClassInfo);
} else
NS_INTERFACE_MAP_END

View File

@ -39,10 +39,6 @@ AppendAndRemoveThread(PRThread *key, nsRefPtr<nsThread> &thread, void *arg)
return PL_DHASH_REMOVE;
}
//-----------------------------------------------------------------------------
nsThreadManager nsThreadManager::sInstance;
// statically allocated instance
NS_IMETHODIMP_(nsrefcnt) nsThreadManager::AddRef() { return 2; }
NS_IMETHODIMP_(nsrefcnt) nsThreadManager::Release() { return 1; }

View File

@ -21,6 +21,7 @@ public:
NS_DECL_NSITHREADMANAGER
static nsThreadManager *get() {
static nsThreadManager sInstance;
return &sInstance;
}
@ -60,8 +61,6 @@ private:
, mHighestNumberOfThreads(1) {
}
static nsThreadManager sInstance;
nsRefPtrHashtable<nsPtrHashKey<PRThread>, nsThread> mThreadsByPRThread;
unsigned mCurThreadIndex; // thread-local-storage index
nsRefPtr<nsThread> mMainThread;