Bug 677079 - Part k: Expose outstandingRequests in jsfriendapi.h; r=cdleary

This commit is contained in:
Ms2ger 2012-01-15 09:13:09 +01:00
parent 3e577b6915
commit c13b7236b0
4 changed files with 13 additions and 5 deletions

View File

@ -37,7 +37,6 @@
*
* ***** END LICENSE BLOCK ***** */
#include "jscntxt.h" // outstandingRequests
#include "nsJSEnvironment.h"
#include "nsIScriptGlobalObject.h"
#include "nsIScriptObjectPrincipal.h"
@ -1127,7 +1126,7 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(nsJSContext)
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsJSContext)
NS_IMPL_CYCLE_COLLECTION_TRACE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsJSContext)
NS_ASSERTION(!tmp->mContext || tmp->mContext->outstandingRequests == 0,
NS_ASSERTION(!tmp->mContext || js::GetContextOutstandingRequests(tmp->mContext) == 0,
"Trying to unlink a context with outstanding requests.");
tmp->mIsInitialized = false;
tmp->mGCOnDestruction = false;
@ -1157,7 +1156,7 @@ nsJSContext::GetCCRefcnt()
{
nsrefcnt refcnt = mRefCnt.get();
if (NS_LIKELY(mContext))
refcnt += mContext->outstandingRequests;
refcnt += js::GetContextOutstandingRequests(mContext);
return refcnt;
}

View File

@ -527,6 +527,12 @@ GetContextThread(const JSContext *cx)
{
return cx->thread();
}
JS_FRIEND_API(unsigned)
GetContextOutstandingRequests(const JSContext *cx)
{
return cx->outstandingRequests;
}
#endif
} // namespace js

View File

@ -453,6 +453,9 @@ GetPCCountScriptContents(JSContext *cx, size_t script);
#ifdef JS_THREADSAFE
JS_FRIEND_API(JSThread *)
GetContextThread(const JSContext *cx);
JS_FRIEND_API(unsigned)
GetContextOutstandingRequests(const JSContext *cx);
#endif
class JS_FRIEND_API(AutoLockGC)

View File

@ -69,7 +69,7 @@
#include "nsWrapperCacheInlines.h"
#include "jscntxt.h" // js::ThreadData, JS_TRACER_INIT, context->stackLimit, cx->outstandingRequests,
#include "jscntxt.h" // js::ThreadData, JS_TRACER_INIT, context->stackLimit,
// cx->globalObject, sizeof(JSContext), js::CompartmentVector, cx->stack.empty()
NS_IMPL_THREADSAFE_ISUPPORTS7(nsXPConnect,
@ -970,7 +970,7 @@ nsXPConnect::Traverse(void *p, nsCycleCollectionTraversalCallback &cb)
unsigned
nsXPConnect::GetOutstandingRequests(JSContext* cx)
{
unsigned n = cx->outstandingRequests;
unsigned n = js::GetContextOutstandingRequests(cx);
XPCCallContext* context = mCycleCollectionContext;
// Ignore the contribution from the XPCCallContext we created for cycle
// collection.