electron/shell/common/api/object_life_monitor.h

35 lines
903 B
C
Raw Normal View History

// Copyright (c) 2013 GitHub, Inc.
2014-04-25 09:49:37 +00:00
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
2019-06-19 20:56:58 +00:00
#ifndef SHELL_COMMON_API_OBJECT_LIFE_MONITOR_H_
#define SHELL_COMMON_API_OBJECT_LIFE_MONITOR_H_
2016-03-08 04:38:49 +00:00
#include "base/macros.h"
2015-08-27 08:41:51 +00:00
#include "base/memory/weak_ptr.h"
#include "v8/include/v8.h"
namespace atom {
class ObjectLifeMonitor {
protected:
ObjectLifeMonitor(v8::Isolate* isolate, v8::Local<v8::Object> target);
virtual ~ObjectLifeMonitor();
virtual void RunDestructor() = 0;
private:
2015-08-27 08:41:51 +00:00
static void OnObjectGC(const v8::WeakCallbackInfo<ObjectLifeMonitor>& data);
static void Free(const v8::WeakCallbackInfo<ObjectLifeMonitor>& data);
2015-08-27 08:41:51 +00:00
v8::Global<v8::Object> target_;
base::WeakPtrFactory<ObjectLifeMonitor> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(ObjectLifeMonitor);
};
} // namespace atom
2019-06-19 20:56:58 +00:00
#endif // SHELL_COMMON_API_OBJECT_LIFE_MONITOR_H_