Bug 877261 - Fold XPCCallContext::Init into XPCCallContext::XPCCallContext. r=Ms2ger

The large block is a simple move.
This commit is contained in:
Bobby Holley 2013-06-04 21:11:21 -07:00
Родитель a3d8f01f4d
Коммит 88a9016df8
2 изменённых файлов: 21 добавлений и 43 удалений

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

@ -16,6 +16,8 @@ using namespace mozilla;
using namespace xpc;
using namespace JS;
#define IS_TEAROFF_CLASS(clazz) ((clazz) == &XPC_WN_Tearoff_JSClass)
XPCCallContext::XPCCallContext(XPCContext::LangType callerLanguage,
JSContext* cx /* = GetDefaultJSContext() */,
HandleObject obj /* = nullptr */,
@ -37,42 +39,9 @@ XPCCallContext::XPCCallContext(XPCContext::LangType callerLanguage,
mName(cx)
{
MOZ_ASSERT(cx);
Init(callerLanguage, callerLanguage == NATIVE_CALLER, obj, funobj, name,
argc, argv, rval);
}
bool callBeginRequest = callerLanguage == NATIVE_CALLER;
#define IS_TEAROFF_CLASS(clazz) ((clazz) == &XPC_WN_Tearoff_JSClass)
// static
JSContext *
XPCCallContext::GetDefaultJSContext()
{
// This is slightly questionable. If called without an explicit
// JSContext (generally a call to a wrappedJS) we will use the JSContext
// on the top of the JSContext stack - if there is one - *before*
// falling back on the safe JSContext.
// This is good AND bad because it makes calls from JS -> native -> JS
// have JS stack 'continuity' for purposes of stack traces etc.
// Note: this *is* what the pre-XPCCallContext xpconnect did too.
XPCJSContextStack* stack = XPCJSRuntime::Get()->GetJSContextStack();
JSContext *topJSContext = stack->Peek();
return topJSContext ? topJSContext : stack->GetSafeJSContext();
}
void
XPCCallContext::Init(XPCContext::LangType callerLanguage,
JSBool callBeginRequest,
HandleObject obj,
HandleObject funobj,
HandleId name,
unsigned argc,
jsval *argv,
jsval *rval)
{
NS_ASSERTION(mJSContext, "No JSContext supplied to XPCCallContext");
if (!mXPC)
return;
@ -160,6 +129,24 @@ XPCCallContext::Init(XPCContext::LangType callerLanguage,
CHECK_STATE(HAVE_OBJECT);
}
// static
JSContext *
XPCCallContext::GetDefaultJSContext()
{
// This is slightly questionable. If called without an explicit
// JSContext (generally a call to a wrappedJS) we will use the JSContext
// on the top of the JSContext stack - if there is one - *before*
// falling back on the safe JSContext.
// This is good AND bad because it makes calls from JS -> native -> JS
// have JS stack 'continuity' for purposes of stack traces etc.
// Note: this *is* what the pre-XPCCallContext xpconnect did too.
XPCJSContextStack* stack = XPCJSRuntime::Get()->GetJSContextStack();
JSContext *topJSContext = stack->Peek();
return topJSContext ? topJSContext : stack->GetSafeJSContext();
}
void
XPCCallContext::SetName(jsid name)
{

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

@ -1173,15 +1173,6 @@ private:
XPCCallContext(const XPCCallContext& r); // not implemented
XPCCallContext& operator= (const XPCCallContext& r); // not implemented
void Init(XPCContext::LangType callerLanguage,
JSBool callBeginRequest,
JS::HandleObject obj,
JS::HandleObject funobj,
JS::HandleId name,
unsigned argc,
jsval *argv,
jsval *rval);
XPCWrappedNative* UnwrapThisIfAllowed(JS::HandleObject obj, JS::HandleObject fun,
unsigned argc);