Setup v8::MicrotasksScope for callbacks

This commit is contained in:
Cheng Zhao 2016-06-24 14:40:47 +09:00
Родитель e75f2aa087
Коммит a1efa28520
1 изменённых файлов: 4 добавлений и 0 удалений

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

@ -185,6 +185,8 @@ class Invoker<IndicesHolder<indices...>, ArgTypes...>
template <typename ReturnType>
void DispatchToCallback(base::Callback<ReturnType(ArgTypes...)> callback) {
v8::MicrotasksScope script_scope(
args_->isolate(), v8::MicrotasksScope::kRunMicrotasks);
args_->Return(callback.Run(ArgumentHolder<indices, ArgTypes>::value...));
}
@ -192,6 +194,8 @@ class Invoker<IndicesHolder<indices...>, ArgTypes...>
// expression to foo. As a result, we must specialize the case of Callbacks
// that have the void return type.
void DispatchToCallback(base::Callback<void(ArgTypes...)> callback) {
v8::MicrotasksScope script_scope(
args_->isolate(), v8::MicrotasksScope::kRunMicrotasks);
callback.Run(ArgumentHolder<indices, ArgTypes>::value...);
}