#include "atom/common/native_mate_converters/callback.h"
-#include "atom/browser/atom_browser_main_parts.h"
#include "content/public/browser/browser_thread.h"
using content::BrowserThread;
DeleteOnUIThread> {
public:
RefCountedGlobal(v8::Isolate* isolate, v8::Local<v8::Value> value)
- : handle_(isolate, v8::Local<T>::Cast(value)),
- weak_factory_(this) {
- // In browser process, we need to ensure the V8 handle is destroyed before
- // the JavaScript env gets destroyed.
- if (Locker::IsBrowserProcess() && atom::AtomBrowserMainParts::Get()) {
- atom::AtomBrowserMainParts::Get()->RegisterDestructionCallback(
- base::Bind(&RefCountedGlobal<T>::FreeHandle,
- weak_factory_.GetWeakPtr()));
- }
+ : handle_(isolate, v8::Local<T>::Cast(value)) {
}
bool IsAlive() const {
}
private:
- void FreeHandle() {
- handle_.Reset();
- }
-
v8::Global<T> handle_;
- base::WeakPtrFactory<RefCountedGlobal<T>> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(RefCountedGlobal);
};