Bug 677079 - Part o: Expose setActivityCallback in jsfriendapi.h; r=gal

This commit is contained in:
Ms2ger 2012-01-15 09:13:10 +01:00
parent dcc2192b9e
commit 5760a0138f
4 changed files with 20 additions and 17 deletions

View File

@ -337,9 +337,6 @@ typedef struct JSPropertyTreeEntry {
js::Shape *child;
} JSPropertyTreeEntry;
typedef void
(* JSActivityCallback)(void *arg, JSBool active);
namespace js {
typedef Vector<JSCompartment *, 0, SystemAllocPolicy> CompartmentVector;
@ -378,18 +375,7 @@ struct JSRuntime
/* Compartment create/destroy callback. */
JSCompartmentCallback compartmentCallback;
/*
* Sets a callback that is run whenever the runtime goes idle - the
* last active request ceases - and begins activity - when it was
* idle and a request begins. Note: The callback is called under the
* GC lock.
*/
void setActivityCallback(JSActivityCallback cb, void *arg) {
activityCallback = cb;
activityCallbackArg = arg;
}
JSActivityCallback activityCallback;
js::ActivityCallback activityCallback;
void *activityCallbackArg;
/* Garbage collector state, used by jsgc.c. */

View File

@ -547,4 +547,10 @@ HasUnrootedGlobal(const JSContext *cx)
return cx->hasRunOption(JSOPTION_UNROOTED_GLOBAL);
}
JS_FRIEND_API(void)
SetActivityCallback(JSRuntime *rt, ActivityCallback cb, void *arg)
{
rt->activityCallback = cb;
rt->activityCallbackArg = arg;
}
} // namespace js

View File

@ -464,6 +464,18 @@ GetContextCompartment(const JSContext *cx);
JS_FRIEND_API(bool)
HasUnrootedGlobal(const JSContext *cx);
typedef void
(* ActivityCallback)(void *arg, JSBool active);
/*
* Sets a callback that is run whenever the runtime goes idle - the
* last active request ceases - and begins activity - when it was
* idle and a request begins. Note: The callback is called under the
* GC lock.
*/
JS_FRIEND_API(void)
SetActivityCallback(JSRuntime *rt, ActivityCallback cb, void *arg);
class JS_FRIEND_API(AutoLockGC)
{
public:

View File

@ -70,7 +70,6 @@ JS_LOCK_GC, JS_UNLOCK_GC
js_NextActiveContext, js::TriggerOperationCallback
mWatchdogWakeup = JS_NEW_CONDVAR(mJSRuntime->gcLock);
mJSRuntime->setActivityCallback(ActivityCallback, this);
#endif
using namespace mozilla;
@ -2001,7 +2000,7 @@ XPCJSRuntime::XPCJSRuntime(nsXPConnect* aXPConnect)
if (!mWatchdogWakeup)
NS_RUNTIMEABORT("JS_NEW_CONDVAR failed.");
mJSRuntime->setActivityCallback(ActivityCallback, this);
js::SetActivityCallback(mJSRuntime, ActivityCallback, this);
NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(XPConnectJSGCHeap));
NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(XPConnectJSSystemCompartmentCount));