From d8b20376f9d709e4cd79a3d75f95a464c700c41e Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 30 Jul 2024 14:23:31 -0500 Subject: [PATCH] chore: remove unused class `electron::ObjectLifeMonitor` (#43108) chore: remove unused class `electron::ObjectLifeMonitor` (#43089) The last users were removed in June 2020 e1e73fa5f (#24115) and May 2020 9d7ba982 (#23592). Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr --- filenames.gni | 2 - shell/common/api/object_life_monitor.cc | 40 ------------------- shell/common/api/object_life_monitor.h | 35 ---------------- .../api/context_bridge/object_cache.cc | 3 +- .../api/electron_api_context_bridge.cc | 1 - 5 files changed, 2 insertions(+), 79 deletions(-) delete mode 100644 shell/common/api/object_life_monitor.cc delete mode 100644 shell/common/api/object_life_monitor.h diff --git a/filenames.gni b/filenames.gni index 896ab08aed04..f1bcd9ba050e 100644 --- a/filenames.gni +++ b/filenames.gni @@ -559,8 +559,6 @@ filenames = { "shell/common/api/electron_bindings.cc", "shell/common/api/electron_bindings.h", "shell/common/api/features.cc", - "shell/common/api/object_life_monitor.cc", - "shell/common/api/object_life_monitor.h", "shell/common/application_info.cc", "shell/common/application_info.h", "shell/common/asar/archive.cc", diff --git a/shell/common/api/object_life_monitor.cc b/shell/common/api/object_life_monitor.cc deleted file mode 100644 index a9c3bb2f910a..000000000000 --- a/shell/common/api/object_life_monitor.cc +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2013 GitHub, Inc. -// Copyright (c) 2012 Intel Corp. All rights reserved. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#include "shell/common/api/object_life_monitor.h" - -#include "base/functional/bind.h" - -namespace electron { - -ObjectLifeMonitor::ObjectLifeMonitor(v8::Isolate* isolate, - v8::Local target) - : target_(isolate, target) { - target_.SetWeak(this, OnObjectGC, v8::WeakCallbackType::kParameter); -} - -ObjectLifeMonitor::~ObjectLifeMonitor() { - if (target_.IsEmpty()) - return; - target_.ClearWeak(); - target_.Reset(); -} - -// static -void ObjectLifeMonitor::OnObjectGC( - const v8::WeakCallbackInfo& data) { - ObjectLifeMonitor* self = data.GetParameter(); - self->target_.Reset(); - self->RunDestructor(); - data.SetSecondPassCallback(Free); -} - -// static -void ObjectLifeMonitor::Free( - const v8::WeakCallbackInfo& data) { - delete data.GetParameter(); -} - -} // namespace electron diff --git a/shell/common/api/object_life_monitor.h b/shell/common/api/object_life_monitor.h deleted file mode 100644 index 8cd608f35e85..000000000000 --- a/shell/common/api/object_life_monitor.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2013 GitHub, Inc. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#ifndef ELECTRON_SHELL_COMMON_API_OBJECT_LIFE_MONITOR_H_ -#define ELECTRON_SHELL_COMMON_API_OBJECT_LIFE_MONITOR_H_ - -#include "base/memory/weak_ptr.h" -#include "v8/include/v8.h" - -namespace electron { - -class ObjectLifeMonitor { - protected: - ObjectLifeMonitor(v8::Isolate* isolate, v8::Local target); - virtual ~ObjectLifeMonitor(); - - // disable copy - ObjectLifeMonitor(const ObjectLifeMonitor&) = delete; - ObjectLifeMonitor& operator=(const ObjectLifeMonitor&) = delete; - - virtual void RunDestructor() = 0; - - private: - static void OnObjectGC(const v8::WeakCallbackInfo& data); - static void Free(const v8::WeakCallbackInfo& data); - - v8::Global target_; - - base::WeakPtrFactory weak_ptr_factory_{this}; -}; - -} // namespace electron - -#endif // ELECTRON_SHELL_COMMON_API_OBJECT_LIFE_MONITOR_H_ diff --git a/shell/renderer/api/context_bridge/object_cache.cc b/shell/renderer/api/context_bridge/object_cache.cc index 9fc359ad6cf1..55155845713d 100644 --- a/shell/renderer/api/context_bridge/object_cache.cc +++ b/shell/renderer/api/context_bridge/object_cache.cc @@ -4,7 +4,8 @@ #include "shell/renderer/api/context_bridge/object_cache.h" -#include "shell/common/api/object_life_monitor.h" +#include "v8/include/v8-local-handle.h" +#include "v8/include/v8-object.h" namespace electron::api::context_bridge { diff --git a/shell/renderer/api/electron_api_context_bridge.cc b/shell/renderer/api/electron_api_context_bridge.cc index 13250baabbac..01a687ed1596 100644 --- a/shell/renderer/api/electron_api_context_bridge.cc +++ b/shell/renderer/api/electron_api_context_bridge.cc @@ -17,7 +17,6 @@ #include "base/trace_event/trace_event.h" #include "content/public/renderer/render_frame.h" #include "content/public/renderer/render_frame_observer.h" -#include "shell/common/api/object_life_monitor.h" #include "shell/common/gin_converters/blink_converter.h" #include "shell/common/gin_converters/callback_converter.h" #include "shell/common/gin_helper/dictionary.h"