Bug 1257030 - Add support for supplying preexisting stack instead of capturing one for use as the async parent stack of CallbackObject. r=bz,tromey

This commit is contained in:
Till Schneidereit 2016-03-17 18:07:43 +01:00
Родитель 9bd7b90e07
Коммит 6602beaac6
4 изменённых файлов: 49 добавлений и 11 удалений

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

@ -32,6 +32,14 @@ public:
{
}
// See CallbackObject for an explanation of the arguments.
explicit CallbackFunction(JS::Handle<JSObject*> aCallable,
JS::Handle<JSObject*> aAsyncStack,
nsIGlobalObject* aIncumbentGlobal)
: CallbackObject(aCallable, aAsyncStack, aIncumbentGlobal)
{
}
JS::Handle<JSObject*> Callable() const
{
return Callback();

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

@ -31,6 +31,14 @@ public:
{
}
// See CallbackObject for an explanation of the arguments.
explicit CallbackInterface(JS::Handle<JSObject*> aCallback,
JS::Handle<JSObject*> aAsyncStack,
nsIGlobalObject* aIncumbentGlobal)
: CallbackObject(aCallback, aAsyncStack, aIncumbentGlobal)
{
}
protected:
bool GetCallableProperty(JSContext* cx, JS::Handle<jsid> aPropId,
JS::MutableHandle<JS::Value> aCallable);

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

@ -67,6 +67,16 @@ public:
}
}
// Instead of capturing the current stack to use as an async parent when the
// callback is invoked, the caller can use this overload to pass in a stack
// for that purpose.
explicit CallbackObject(JS::Handle<JSObject*> aCallback,
JS::Handle<JSObject*> aAsyncStack,
nsIGlobalObject *aIncumbentGlobal)
{
Init(aCallback, aAsyncStack, aIncumbentGlobal);
}
JS::Handle<JSObject*> Callback() const
{
JS::ExposeObjectToActiveJS(mCallback);

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

@ -14687,17 +14687,29 @@ class CGCallback(CGClass):
# Not much we can assert about it, other than not being null, and
# CallbackObject does that already.
body = ""
return [ClassConstructor(
[Argument("JSContext*", "aCx"),
Argument("JS::Handle<JSObject*>", "aCallback"),
Argument("nsIGlobalObject*", "aIncumbentGlobal")],
bodyInHeader=True,
visibility="public",
explicit=True,
baseConstructors=[
"%s(aCx, aCallback, aIncumbentGlobal)" % self.baseName,
],
body=body)]
return [
ClassConstructor(
[Argument("JSContext*", "aCx"),
Argument("JS::Handle<JSObject*>", "aCallback"),
Argument("nsIGlobalObject*", "aIncumbentGlobal")],
bodyInHeader=True,
visibility="public",
explicit=True,
baseConstructors=[
"%s(aCx, aCallback, aIncumbentGlobal)" % self.baseName,
],
body=body),
ClassConstructor(
[Argument("JS::Handle<JSObject*>", "aCallback"),
Argument("JS::Handle<JSObject*>", "aAsyncStack"),
Argument("nsIGlobalObject*", "aIncumbentGlobal")],
bodyInHeader=True,
visibility="public",
explicit=True,
baseConstructors=[
"%s(aCallback, aAsyncStack, aIncumbentGlobal)" % self.baseName,
],
body=body)]
def getMethodImpls(self, method):
assert method.needThisHandling