chore: remove native_mate (Part 12) (#20869)
* refactor: move mate::Event to gin * refactor: move mate::Locker to gin * refactor: convert contextBridge to gin * refactor: convert contentTracing to gin * refactor: remove callback converter of native_mate * refactor: remove file_dialog_converter and native_window_converter from native_mate * refactor: convert webFrame to gin * refactor: move blink_converter to gin * refactor: remove net_converter from native_mate * refactor: remove event_emitter_caller_deprecated * refactor: remove gurl_converter from native_mate * refactor: remove file_path and string16_converter from native_mate * refactor: remove image_converter from native_mate * refactor: move value_converter to gin
This commit is contained in:
parent
6781d5e3c8
commit
3ae3233e65
96 changed files with 622 additions and 1711 deletions
|
@ -18,16 +18,14 @@
|
|||
#include "base/threading/thread_restrictions.h"
|
||||
#include "chrome/common/chrome_version.h"
|
||||
#include "electron/electron_version.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "services/resource_coordinator/public/cpp/memory_instrumentation/global_memory_dump.h"
|
||||
#include "services/resource_coordinator/public/cpp/memory_instrumentation/memory_instrumentation.h"
|
||||
#include "shell/browser/browser.h"
|
||||
#include "shell/common/api/locker.h"
|
||||
#include "shell/common/application_info.h"
|
||||
#include "shell/common/gin_converters/file_path_converter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/gin_helper/locker.h"
|
||||
#include "shell/common/heap_snapshot.h"
|
||||
#include "shell/common/native_mate_converters/file_path_converter.h"
|
||||
#include "shell/common/native_mate_converters/string16_converter.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
#include "shell/common/promise_util.h"
|
||||
#include "third_party/blink/renderer/platform/heap/process_heap.h" // nogncheck
|
||||
|
@ -57,7 +55,7 @@ ElectronBindings::~ElectronBindings() {
|
|||
|
||||
// static
|
||||
void ElectronBindings::BindProcess(v8::Isolate* isolate,
|
||||
mate::Dictionary* process,
|
||||
gin_helper::Dictionary* process,
|
||||
base::ProcessMetrics* metrics) {
|
||||
// These bindings are shared between sandboxed & unsandboxed renderers
|
||||
process->SetMethod("crash", &Crash);
|
||||
|
@ -89,7 +87,7 @@ void ElectronBindings::BindTo(v8::Isolate* isolate,
|
|||
v8::Local<v8::Object> process) {
|
||||
isolate->SetFatalErrorHandler(FatalErrorCallback);
|
||||
|
||||
mate::Dictionary dict(isolate, process);
|
||||
gin_helper::Dictionary dict(isolate, process);
|
||||
BindProcess(isolate, &dict, metrics_.get());
|
||||
|
||||
dict.SetMethod("takeHeapSnapshot", &TakeHeapSnapshot);
|
||||
|
@ -100,7 +98,7 @@ void ElectronBindings::BindTo(v8::Isolate* isolate,
|
|||
base::BindRepeating(&ElectronBindings::ActivateUVLoop,
|
||||
base::Unretained(this)));
|
||||
|
||||
mate::Dictionary versions;
|
||||
gin_helper::Dictionary versions;
|
||||
if (dict.Get("versions", &versions)) {
|
||||
versions.SetReadOnly(ELECTRON_PROJECT_NAME, ELECTRON_VERSION_STRING);
|
||||
versions.SetReadOnly("chrome", CHROME_VERSION_STRING);
|
||||
|
@ -131,7 +129,7 @@ void ElectronBindings::OnCallNextTick(uv_async_t* handle) {
|
|||
self->pending_next_ticks_.begin();
|
||||
it != self->pending_next_ticks_.end(); ++it) {
|
||||
node::Environment* env = *it;
|
||||
mate::Locker locker(env->isolate());
|
||||
gin_helper::Locker locker(env->isolate());
|
||||
v8::Context::Scope context_scope(env->context());
|
||||
node::InternalCallbackScope scope(
|
||||
env, v8::Local<v8::Object>(), {0, 0},
|
||||
|
@ -201,7 +199,7 @@ v8::Local<v8::Value> ElectronBindings::GetCreationTime(v8::Isolate* isolate) {
|
|||
// static
|
||||
v8::Local<v8::Value> ElectronBindings::GetSystemMemoryInfo(
|
||||
v8::Isolate* isolate,
|
||||
mate::Arguments* args) {
|
||||
gin_helper::Arguments* args) {
|
||||
base::SystemMemoryInfoKB mem_info;
|
||||
if (!base::GetSystemMemoryInfo(&mem_info)) {
|
||||
args->ThrowError("Unable to retrieve system memory information");
|
||||
|
@ -233,10 +231,10 @@ v8::Local<v8::Value> ElectronBindings::GetSystemMemoryInfo(
|
|||
// static
|
||||
v8::Local<v8::Promise> ElectronBindings::GetProcessMemoryInfo(
|
||||
v8::Isolate* isolate) {
|
||||
util::Promise<mate::Dictionary> promise(isolate);
|
||||
util::Promise<gin_helper::Dictionary> promise(isolate);
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
|
||||
if (mate::Locker::IsBrowserProcess() && !Browser::Get()->is_ready()) {
|
||||
if (gin_helper::Locker::IsBrowserProcess() && !Browser::Get()->is_ready()) {
|
||||
promise.RejectWithErrorMessage(
|
||||
"Memory Info is available only after app ready");
|
||||
return handle;
|
||||
|
@ -267,11 +265,11 @@ v8::Local<v8::Value> ElectronBindings::GetBlinkMemoryInfo(
|
|||
// static
|
||||
void ElectronBindings::DidReceiveMemoryDump(
|
||||
v8::Global<v8::Context> context,
|
||||
util::Promise<mate::Dictionary> promise,
|
||||
util::Promise<gin_helper::Dictionary> promise,
|
||||
bool success,
|
||||
std::unique_ptr<memory_instrumentation::GlobalMemoryDump> global_dump) {
|
||||
v8::Isolate* isolate = promise.isolate();
|
||||
mate::Locker locker(isolate);
|
||||
gin_helper::Locker locker(isolate);
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
v8::MicrotasksScope script_scope(isolate,
|
||||
v8::MicrotasksScope::kRunMicrotasks);
|
||||
|
@ -287,14 +285,14 @@ void ElectronBindings::DidReceiveMemoryDump(
|
|||
for (const memory_instrumentation::GlobalMemoryDump::ProcessDump& dump :
|
||||
global_dump->process_dumps()) {
|
||||
if (base::GetCurrentProcId() == dump.pid()) {
|
||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
const auto& osdump = dump.os_dump();
|
||||
#if defined(OS_LINUX) || defined(OS_WIN)
|
||||
dict.Set("residentSet", osdump.resident_set_kb);
|
||||
#endif
|
||||
dict.Set("private", osdump.private_footprint_kb);
|
||||
dict.Set("shared", osdump.shared_footprint_kb);
|
||||
promise.Resolve(dict);
|
||||
promise.ResolveWithGin(dict);
|
||||
resolved = true;
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue