From: Cheng Zhao Date: Thu, 3 Dec 2015 08:33:57 +0000 (+0800) Subject: It is fine to leak a V8 handle on exit X-Git-Tag: v0.35.3~8^2~2 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=1e7c8c9fda4072d9a0672d0f9125c4edec60f272;p=electron.git It is fine to leak a V8 handle on exit --- diff --git a/atom/common/native_mate_converters/callback.cc b/atom/common/native_mate_converters/callback.cc index cd9838c1..8bf5c459 100644 --- a/atom/common/native_mate_converters/callback.cc +++ b/atom/common/native_mate_converters/callback.cc @@ -4,7 +4,6 @@ #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; @@ -78,15 +77,7 @@ class RefCountedGlobal : public base::RefCountedThreadSafe, DeleteOnUIThread> { public: RefCountedGlobal(v8::Isolate* isolate, v8::Local value) - : handle_(isolate, v8::Local::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::FreeHandle, - weak_factory_.GetWeakPtr())); - } + : handle_(isolate, v8::Local::Cast(value)) { } bool IsAlive() const { @@ -98,12 +89,7 @@ class RefCountedGlobal : public base::RefCountedThreadSafe, } private: - void FreeHandle() { - handle_.Reset(); - } - v8::Global handle_; - base::WeakPtrFactory> weak_factory_; DISALLOW_COPY_AND_ASSIGN(RefCountedGlobal); };