chore: remove native_mate (Part 3) (#20131)

* use gin converter in atom_api_menu

* please only put necessary includes in header

Having include in header means they have dependency relationship,
putting arbitrary includes really really really really really makes
refacoring much harder.

* remove some simple uses of callback_converter_deprecated.h

* use gin callback converter in file_dialog code

* use gin in ErrorThrower

* use gin in atom_bundle_mover

* fix mistake in node stream

* deprecate native_mate version of event_emitter_caller

* use gin in node_bindings

* remove usages of native_mate event_emitter_caller.h except for EventEmitter

* fix compilation on Windows

* gin::Arguments behaves differently on GetNext

* just use StringToV8
This commit is contained in:
Cheng Zhao 2019-09-06 14:52:54 +09:00 committed by GitHub
parent 7be1905023
commit 2c23e44ed9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
61 changed files with 515 additions and 323 deletions

View file

@ -11,16 +11,14 @@
#include "base/environment.h"
#include "base/macros.h"
#include "base/threading/thread_restrictions.h"
#include "electron/shell/common/api/event_emitter_caller.h"
#include "electron/shell/common/node_includes.h"
#include "electron/shell/common/options_switches.h"
#include "electron/shell/renderer/atom_render_frame_observer.h"
#include "electron/shell/renderer/renderer_client_base.h"
#include "mojo/public/cpp/system/platform_handle.h"
#include "native_mate/dictionary.h"
#include "shell/common/atom_constants.h"
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
#include "shell/common/heap_snapshot.h"
#include "shell/common/native_mate_converters/value_converter.h"
#include "shell/common/node_includes.h"
#include "shell/common/options_switches.h"
#include "shell/renderer/atom_render_frame_observer.h"
#include "shell/renderer/renderer_client_base.h"
#include "third_party/blink/public/web/blink.h"
#include "third_party/blink/public/web/web_local_frame.h"
@ -33,8 +31,7 @@ const char kIpcKey[] = "ipcNative";
// Gets the private object under kIpcKey
v8::Local<v8::Object> GetIpcObject(v8::Local<v8::Context> context) {
auto* isolate = context->GetIsolate();
auto binding_key =
mate::ConvertToV8(isolate, kIpcKey)->ToString(context).ToLocalChecked();
auto binding_key = gin::StringToV8(isolate, kIpcKey);
auto private_binding_key = v8::Private::ForApi(isolate, binding_key);
auto global_object = context->Global();
auto value =
@ -64,7 +61,7 @@ void InvokeIpcCallback(v8::Local<v8::Context> context,
callback_scope.reset(new node::CallbackScope(isolate, ipcNative, {0, 0}));
}
auto callback_key = mate::ConvertToV8(isolate, callback_name)
auto callback_key = gin::ConvertToV8(isolate, callback_name)
->ToString(context)
.ToLocalChecked();
auto callback_value = ipcNative->Get(context, callback_key).ToLocalChecked();
@ -86,8 +83,8 @@ void EmitIPCEvent(v8::Local<v8::Context> context,
v8::MicrotasksScope::kRunMicrotasks);
std::vector<v8::Local<v8::Value>> argv = {
mate::ConvertToV8(isolate, internal), mate::ConvertToV8(isolate, channel),
mate::ConvertToV8(isolate, args), mate::ConvertToV8(isolate, sender_id)};
gin::ConvertToV8(isolate, internal), gin::ConvertToV8(isolate, channel),
gin::ConvertToV8(isolate, args), gin::ConvertToV8(isolate, sender_id)};
InvokeIpcCallback(context, "onMessage", argv);
}