Add EmitEvent function to replace node::MakeCallback
This commit is contained in:
parent
197a9b4165
commit
78459b913b
5 changed files with 87 additions and 26 deletions
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <vector>
|
||||
|
||||
#include "atom/common/event_emitter_caller.h"
|
||||
#include "native_mate/wrappable.h"
|
||||
|
||||
namespace content {
|
||||
|
@ -41,18 +42,16 @@ class EventEmitter : public Wrappable {
|
|||
const Args&... args) {
|
||||
v8::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
|
||||
ValueArray converted = { ConvertToV8(isolate(), args)... };
|
||||
return CallEmit(isolate(), name, sender, message, converted);
|
||||
v8::Local<v8::Object> event = CreateEvent(isolate(), sender, message);
|
||||
EmitEvent(isolate(), GetWrapper(isolate()), name, event, args...);
|
||||
return event->Get(
|
||||
StringToV8(isolate(), "defaultPrevented"))->BooleanValue();
|
||||
}
|
||||
|
||||
private:
|
||||
// Lower level implementations.
|
||||
bool CallEmit(v8::Isolate* isolate,
|
||||
const base::StringPiece& name,
|
||||
content::WebContents* sender,
|
||||
IPC::Message* message,
|
||||
ValueArray args);
|
||||
v8::Local<v8::Object> CreateEvent(v8::Isolate* isolate,
|
||||
content::WebContents* sender,
|
||||
IPC::Message* message) const;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(EventEmitter);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue