event_emitter_caller.cc 963 B

12345678910111213141516171819202122232425262728
  1. // Copyright (c) 2015 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #include "atom/common/api/event_emitter_caller.h"
  5. #include "atom/common/api/locker.h"
  6. #include "atom/common/node_includes.h"
  7. namespace mate {
  8. namespace internal {
  9. v8::Local<v8::Value> CallMethodWithArgs(v8::Isolate* isolate,
  10. v8::Local<v8::Object> obj,
  11. const char* method,
  12. ValueVector* args) {
  13. // Perform microtask checkpoint after running JavaScript.
  14. v8::MicrotasksScope script_scope(isolate,
  15. v8::MicrotasksScope::kRunMicrotasks);
  16. // Use node::MakeCallback to call the callback, and it will also run pending
  17. // tasks in Node.js.
  18. return node::MakeCallback(isolate, obj, method, args->size(), &args->front());
  19. }
  20. } // namespace internal
  21. } // namespace mate