diff --git a/filenames.gni b/filenames.gni index b8daa9a9197..d637df042d1 100644 --- a/filenames.gni +++ b/filenames.gni @@ -562,8 +562,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 a9c3bb2f910..00000000000 --- 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 9ef0dcf2b41..00000000000 --- a/shell/common/api/object_life_monitor.h +++ /dev/null @@ -1,37 +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-object.h" -#include "v8/include/v8-persistent-handle.h" -#include "v8/include/v8-weak-callback-info.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 9fc359ad6cf..55155845713 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 5058a4dea24..384eb4b3360 100644 --- a/shell/renderer/api/electron_api_context_bridge.cc +++ b/shell/renderer/api/electron_api_context_bridge.cc @@ -16,7 +16,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"