Follow-up for bug 608142: disallow sending between main and non-main thread only (r=orange). a=beta7+

This commit is contained in:
Andreas Gal 2010-10-30 08:39:53 -07:00
parent 94cd8b8073
commit ca7f2d3b0b
2 changed files with 4 additions and 3 deletions

View File

@ -3071,7 +3071,7 @@ private:
nsXPCWrappedJS* mRoot;
nsXPCWrappedJS* mNext;
nsISupports* mOuter; // only set in root
nsCOMPtr<nsIThread> mThread;
bool mMainThread;
};
/***************************************************************************/

View File

@ -436,7 +436,7 @@ nsXPCWrappedJS::nsXPCWrappedJS(XPCCallContext& ccx,
mRoot(root ? root : this),
mNext(nsnull),
mOuter(root ? nsnull : aOuter),
mThread(do_GetCurrentThread())
mMainThread(NS_IsMainThread())
{
#ifdef DEBUG_stats_jband
static int count = 0;
@ -571,8 +571,9 @@ nsXPCWrappedJS::CallMethod(PRUint16 methodIndex,
{
if(!IsValid())
return NS_ERROR_UNEXPECTED;
if (NS_GetCurrentThread() != mThread)
if (NS_IsMainThread() != mMainThread) {
return NS_ERROR_NOT_SAME_THREAD;
}
return GetClass()->CallMethod(this, methodIndex, info, params);
}