From f6e8a42c48b16f04675a507f2bee26020466c380 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 12 Sep 2023 18:53:20 -0500 Subject: [PATCH] refactor: remove unused fields, methods in gin_helper::Locker (#39803) * refactor: remove unused field gin_helper::Locker::g_is_browser_process refactor: remove unused field gin_helper::Locker::g_is_renderer_process refactor: make field const gin_helper::Locker::locker_ * refactor: remove unused declaration gin_helper::Locker::new() refactor: remove unused declaration gin_helper::Locker::delete() * refactor: make field const electron::JavascriptEnvironment::locker_ * refactor: remove unused #include gin_helper/locker.h --- shell/browser/javascript_environment.h | 2 +- shell/common/gin_helper/event_emitter_caller.cc | 1 - shell/common/gin_helper/locker.cc | 7 +++---- shell/common/gin_helper/locker.h | 8 +------- shell/common/node_bindings.cc | 1 - 5 files changed, 5 insertions(+), 14 deletions(-) diff --git a/shell/browser/javascript_environment.h b/shell/browser/javascript_environment.h index 937b0f976415..adb7be448cee 100644 --- a/shell/browser/javascript_environment.h +++ b/shell/browser/javascript_environment.h @@ -49,7 +49,7 @@ class JavascriptEnvironment { const raw_ptr isolate_; // depends-on: isolate_ - v8::Locker locker_; + const v8::Locker locker_; std::unique_ptr microtasks_runner_; }; diff --git a/shell/common/gin_helper/event_emitter_caller.cc b/shell/common/gin_helper/event_emitter_caller.cc index 41b0c7b35575..468f0d854f01 100644 --- a/shell/common/gin_helper/event_emitter_caller.cc +++ b/shell/common/gin_helper/event_emitter_caller.cc @@ -4,7 +4,6 @@ #include "shell/common/gin_helper/event_emitter_caller.h" -#include "shell/common/gin_helper/locker.h" #include "shell/common/gin_helper/microtasks_scope.h" #include "shell/common/node_includes.h" diff --git a/shell/common/gin_helper/locker.cc b/shell/common/gin_helper/locker.cc index 84740204ebb2..27b9f0306b21 100644 --- a/shell/common/gin_helper/locker.cc +++ b/shell/common/gin_helper/locker.cc @@ -8,10 +8,9 @@ namespace gin_helper { -Locker::Locker(v8::Isolate* isolate) { - if (electron::IsBrowserProcess()) - locker_ = std::make_unique(isolate); -} +Locker::Locker(v8::Isolate* isolate) + : locker_{electron::IsBrowserProcess() ? new v8::Locker{isolate} + : nullptr} {} Locker::~Locker() = default; diff --git a/shell/common/gin_helper/locker.h b/shell/common/gin_helper/locker.h index 9ce78d701e42..dc142aded3bc 100644 --- a/shell/common/gin_helper/locker.h +++ b/shell/common/gin_helper/locker.h @@ -22,13 +22,7 @@ class Locker { Locker& operator=(const Locker&) = delete; private: - void* operator new(size_t size); - void operator delete(void*, size_t); - - std::unique_ptr locker_; - - static bool g_is_browser_process; - static bool g_is_renderer_process; + const std::unique_ptr locker_; }; } // namespace gin_helper diff --git a/shell/common/node_bindings.cc b/shell/common/node_bindings.cc index 9a6092364eb6..8c6c1fb3c689 100644 --- a/shell/common/node_bindings.cc +++ b/shell/common/node_bindings.cc @@ -31,7 +31,6 @@ #include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/event.h" #include "shell/common/gin_helper/event_emitter_caller.h" -#include "shell/common/gin_helper/locker.h" #include "shell/common/gin_helper/microtasks_scope.h" #include "shell/common/mac/main_application_bundle.h" #include "shell/common/world_ids.h"