chore: remove unused class electron::ObjectLifeMonitor (#43109)

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 <charles@charleskerr.com>
This commit is contained in:
trop[bot] 2024-07-30 13:27:12 -05:00 committed by GitHub
parent 35b73514b7
commit b1921b362e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 2 additions and 79 deletions

View file

@ -553,8 +553,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",

View file

@ -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<v8::Object> 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<ObjectLifeMonitor>& data) {
ObjectLifeMonitor* self = data.GetParameter();
self->target_.Reset();
self->RunDestructor();
data.SetSecondPassCallback(Free);
}
// static
void ObjectLifeMonitor::Free(
const v8::WeakCallbackInfo<ObjectLifeMonitor>& data) {
delete data.GetParameter();
}
} // namespace electron

View file

@ -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<v8::Object> 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<ObjectLifeMonitor>& data);
static void Free(const v8::WeakCallbackInfo<ObjectLifeMonitor>& data);
v8::Global<v8::Object> target_;
base::WeakPtrFactory<ObjectLifeMonitor> weak_ptr_factory_{this};
};
} // namespace electron
#endif // ELECTRON_SHELL_COMMON_API_OBJECT_LIFE_MONITOR_H_

View file

@ -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 {

View file

@ -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"