mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 860085 - Use an AutoPushJSContext in XPCCallContext instead of doing it manually. r=gabor
This commit is contained in:
parent
31b32c4e26
commit
5ba2509426
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user