2015-06-23 11:46:37 +00:00
|
|
|
// Copyright (c) 2015 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2015-08-07 11:34:00 +00:00
|
|
|
#include "atom/common/api/event_emitter_caller.h"
|
2015-06-23 11:46:37 +00:00
|
|
|
|
2015-08-07 11:34:00 +00:00
|
|
|
#include "atom/common/api/locker.h"
|
2015-09-07 08:29:54 +00:00
|
|
|
#include "atom/common/node_includes.h"
|
2015-08-07 07:18:33 +00:00
|
|
|
#include "base/memory/scoped_ptr.h"
|
|
|
|
#include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h"
|
|
|
|
|
2015-06-23 11:46:37 +00:00
|
|
|
namespace mate {
|
|
|
|
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
v8::Local<v8::Value> CallEmitWithArgs(v8::Isolate* isolate,
|
|
|
|
v8::Local<v8::Object> obj,
|
|
|
|
ValueVector* args) {
|
2015-08-07 07:18:33 +00:00
|
|
|
// Perform microtask checkpoint after running JavaScript.
|
2016-05-23 01:59:39 +00:00
|
|
|
std::unique_ptr<blink::WebScopedRunV8Script> script_scope(
|
2015-08-07 11:34:00 +00:00
|
|
|
Locker::IsBrowserProcess() ?
|
2015-12-07 11:56:23 +00:00
|
|
|
nullptr : new blink::WebScopedRunV8Script);
|
2015-08-07 07:18:33 +00:00
|
|
|
// Use node::MakeCallback to call the callback, and it will also run pending
|
|
|
|
// tasks in Node.js.
|
2015-07-23 05:46:34 +00:00
|
|
|
return node::MakeCallback(
|
|
|
|
isolate, obj, "emit", args->size(), &args->front());
|
2015-06-23 11:46:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
|
|
|
|
} // namespace mate
|