Bug 584551 - Do things that require entering a request on the old compartment before entering a request on the new one. r=igor a=blocking-beta3

--HG--
extra : rebase_source : 6480bb872de3268230813d2bddda27a4d552daba
This commit is contained in:
Blake Kaplan 2010-08-05 12:38:07 -07:00
parent c9dbd837ab
commit a79111f6e6

View File

@ -146,14 +146,6 @@ XPCCallContext::Init(XPCContext::LangType callerLanguage,
return;
}
// Get into the request as early as we can to avoid problems with scanning
// callcontexts on other threads from within the gc callbacks.
NS_ASSERTION(!callBeginRequest || mCallerLanguage == NATIVE_CALLER,
"Don't call JS_BeginRequest unless the caller is native.");
if(callBeginRequest)
JS_BeginRequest(mJSContext);
if(topJSContext != mJSContext)
{
if(NS_FAILED(stack->Push(mJSContext)))
@ -164,6 +156,14 @@ XPCCallContext::Init(XPCContext::LangType callerLanguage,
mContextPopRequired = JS_TRUE;
}
// Get into the request as early as we can to avoid problems with scanning
// callcontexts on other threads from within the gc callbacks.
NS_ASSERTION(!callBeginRequest || mCallerLanguage == NATIVE_CALLER,
"Don't call JS_BeginRequest unless the caller is native.");
if(callBeginRequest)
JS_BeginRequest(mJSContext);
mXPCContext = XPCContext::GetXPCContext(mJSContext);
mPrevCallerLanguage = mXPCContext->SetCallingLangType(mCallerLanguage);
@ -386,6 +386,10 @@ XPCCallContext::~XPCCallContext()
shouldReleaseXPC = mPrevCallContext == nsnull;
}
// NB: Needs to happen before the context stack pop.
if(mJSContext && mCallerLanguage == NATIVE_CALLER)
JS_EndRequest(mJSContext);
if(mContextPopRequired)
{
XPCJSContextStack* stack = mThreadData->GetJSContextStack();
@ -404,9 +408,6 @@ XPCCallContext::~XPCCallContext()
if(mJSContext)
{
if(mCallerLanguage == NATIVE_CALLER)
JS_EndRequest(mJSContext);
if(mDestroyJSContextInDestructor)
{
#ifdef DEBUG_xpc_hacker