зеркало из https://github.com/electron/electron.git
chore: remove unused class `electron::ObjectLifeMonitor` (#43089)
* chore: remove unused electron::ObjectLifeMonitor The last users were removed in June 2020e1e73fa5f
(#24115) and May 20209d7ba982
(#23592). * fixup! chore: remove unused electron::ObjectLifeMonitor fix: oops
This commit is contained in:
Родитель
1a6e651844
Коммит
47dde3b6e2
|
@ -562,8 +562,6 @@ filenames = {
|
||||||
"shell/common/api/electron_bindings.cc",
|
"shell/common/api/electron_bindings.cc",
|
||||||
"shell/common/api/electron_bindings.h",
|
"shell/common/api/electron_bindings.h",
|
||||||
"shell/common/api/features.cc",
|
"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.cc",
|
||||||
"shell/common/application_info.h",
|
"shell/common/application_info.h",
|
||||||
"shell/common/asar/archive.cc",
|
"shell/common/asar/archive.cc",
|
||||||
|
|
|
@ -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
|
|
|
@ -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<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_
|
|
|
@ -4,7 +4,8 @@
|
||||||
|
|
||||||
#include "shell/renderer/api/context_bridge/object_cache.h"
|
#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 {
|
namespace electron::api::context_bridge {
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#include "base/trace_event/trace_event.h"
|
#include "base/trace_event/trace_event.h"
|
||||||
#include "content/public/renderer/render_frame.h"
|
#include "content/public/renderer/render_frame.h"
|
||||||
#include "content/public/renderer/render_frame_observer.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/blink_converter.h"
|
||||||
#include "shell/common/gin_converters/callback_converter.h"
|
#include "shell/common/gin_converters/callback_converter.h"
|
||||||
#include "shell/common/gin_helper/dictionary.h"
|
#include "shell/common/gin_helper/dictionary.h"
|
||||||
|
|
Загрузка…
Ссылка в новой задаче