зеркало из https://github.com/mozilla/gecko-dev.git
Bug 968335 - Add an API to determine if a given AutoCxPusher corresponds to the stack-top cx push. r=bz
This patch, and those following, are part of an epic quest to make this API work properly despite the fact that we don't yet have GetEntryGlobal. See the comment a few patches forward.
This commit is contained in:
Родитель
acdc754107
Коммит
4a944caaf5
|
@ -115,6 +115,7 @@ AutoCxPusher::AutoCxPusher(JSContext* cx, bool allowNull)
|
|||
if (!stack->Push(cx)) {
|
||||
MOZ_CRASH();
|
||||
}
|
||||
mStackDepthAfterPush = stack->Count();
|
||||
|
||||
#ifdef DEBUG
|
||||
mPushedContext = cx;
|
||||
|
@ -163,6 +164,14 @@ AutoCxPusher::~AutoCxPusher()
|
|||
mScx = nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
AutoCxPusher::IsStackTop()
|
||||
{
|
||||
uint32_t currentDepth = XPCJSRuntime::Get()->GetJSContextStack()->Count();
|
||||
MOZ_ASSERT(currentDepth >= mStackDepthAfterPush);
|
||||
return currentDepth == mStackDepthAfterPush;
|
||||
}
|
||||
|
||||
AutoJSContext::AutoJSContext(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_IN_IMPL)
|
||||
: mCx(nullptr)
|
||||
{
|
||||
|
|
|
@ -31,10 +31,15 @@ public:
|
|||
|
||||
nsIScriptContext* GetScriptContext() { return mScx; }
|
||||
|
||||
// Returns true if this AutoCxPusher performed the push that is currently at
|
||||
// the top of the cx stack.
|
||||
bool IsStackTop();
|
||||
|
||||
private:
|
||||
mozilla::Maybe<JSAutoRequest> mAutoRequest;
|
||||
mozilla::Maybe<JSAutoCompartment> mAutoCompartment;
|
||||
nsCOMPtr<nsIScriptContext> mScx;
|
||||
uint32_t mStackDepthAfterPush;
|
||||
#ifdef DEBUG
|
||||
JSContext* mPushedContext;
|
||||
unsigned mCompartmentDepthOnEntry;
|
||||
|
|
Загрузка…
Ссылка в новой задаче