Bug 860085 - Use an AutoPushJSContext in XPCCallContext instead of doing it manually. r=gabor

This commit is contained in:
Bobby Holley 2013-07-03 11:05:18 -06:00
Родитель ed5a9e1467
Коммит e11487b445
3 изменённых файлов: 3 добавлений и 31 удалений

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

@ -26,12 +26,11 @@ XPCCallContext::XPCCallContext(XPCContext::LangType callerLanguage,
unsigned argc /* = NO_ARGS */,
jsval *argv /* = nullptr */,
jsval *rval /* = nullptr */)
: mAr(cx),
: mPusher(cx),
mState(INIT_FAILED),
mXPC(nsXPConnect::XPConnect()),
mXPCContext(nullptr),
mJSContext(cx),
mContextPopRequired(false),
mCallerLanguage(callerLanguage),
mFlattenedJSObject(cx),
mWrapper(nullptr),
@ -44,17 +43,6 @@ XPCCallContext::XPCCallContext(XPCContext::LangType callerLanguage,
if (!mXPC)
return;
XPCJSContextStack* stack = XPCJSRuntime::Get()->GetJSContextStack();
JSContext *topJSContext = stack->Peek();
if (topJSContext != mJSContext) {
if (!stack->Push(mJSContext)) {
NS_ERROR("bad!");
return;
}
mContextPopRequired = true;
}
mXPCContext = XPCContext::GetXPCContext(mJSContext);
mPrevCallerLanguage = mXPCContext->SetCallingLangType(mCallerLanguage);
@ -266,15 +254,6 @@ XPCCallContext::~XPCCallContext()
shouldReleaseXPC = mPrevCallContext == nullptr;
}
if (mContextPopRequired) {
XPCJSContextStack* stack = XPCJSRuntime::Get()->GetJSContextStack();
NS_ASSERTION(stack, "bad!");
if (stack) {
DebugOnly<JSContext*> poppedCX = stack->Pop();
NS_ASSERTION(poppedCX == mJSContext, "bad pop");
}
}
if (shouldReleaseXPC && mXPC)
NS_RELEASE(mXPC);
}

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

@ -61,13 +61,6 @@ XPCCallContext::GetJSContext() const
return mJSContext;
}
inline JSBool
XPCCallContext::GetContextPopRequired() const
{
CHECK_STATE(HAVE_CONTEXT);
return mContextPopRequired;
}
inline XPCContext::LangType
XPCCallContext::GetCallerLanguage() const
{

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

@ -169,6 +169,7 @@
#include "SandboxPrivate.h"
#include "BackstagePass.h"
#include "nsCxPusher.h"
#ifdef XP_WIN
// Nasty MS defines
@ -1149,14 +1150,13 @@ inline void CHECK_STATE(int s) const {NS_ASSERTION(mState >= s, "bad state");}
private:
mozilla::Maybe<AutoJSContextDestroyer> mCxDestroyer;
JSAutoRequest mAr;
mozilla::AutoPushJSContext mPusher;
State mState;
nsXPConnect* mXPC;
XPCContext* mXPCContext;
JSContext* mJSContext;
JSBool mContextPopRequired;
XPCContext::LangType mCallerLanguage;