From d5f726188761cd00cb3d16921093a859bda39a71 Mon Sep 17 00:00:00 2001 From: tsepez Date: Wed, 1 Jun 2016 14:01:31 -0700 Subject: Track shared isolates better in FXJSE. Fix the asymmetry between creating only some isolates and releasing all of them, even the shared ones, by being more careful not to trash those we didn't create. Review-Url: https://codereview.chromium.org/2025193002 --- xfa/fxjse/runtime.h | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'xfa/fxjse/runtime.h') diff --git a/xfa/fxjse/runtime.h b/xfa/fxjse/runtime.h index 1240089be4..b57efe1df7 100644 --- a/xfa/fxjse/runtime.h +++ b/xfa/fxjse/runtime.h @@ -15,39 +15,32 @@ class CFXJSE_RuntimeList; class CFXJSE_RuntimeData { - protected: - CFXJSE_RuntimeData(v8::Isolate* pIsolate) : m_pIsolate(pIsolate) {} - public: - static CFXJSE_RuntimeData* Create(v8::Isolate* pIsolate); static CFXJSE_RuntimeData* Get(v8::Isolate* pIsolate); - public: v8::Isolate* m_pIsolate; v8::Global m_hRootContextGlobalTemplate; v8::Global m_hRootContext; - public: - static CFXJSE_RuntimeList* g_RuntimeList; - protected: + static CFXJSE_RuntimeData* Create(v8::Isolate* pIsolate); + CFXJSE_RuntimeData(v8::Isolate* pIsolate) : m_pIsolate(pIsolate) {} CFXJSE_RuntimeData(); CFXJSE_RuntimeData(const CFXJSE_RuntimeData&); CFXJSE_RuntimeData& operator=(const CFXJSE_RuntimeData&); }; -class CFXJSE_RuntimeList { +class CFXJSE_IsolateTracker { public: - typedef void (*RuntimeDisposeCallback)(v8::Isolate*); + typedef void (*DisposeCallback)(v8::Isolate*, bool bOwnedIsolate); + static CFXJSE_IsolateTracker* g_pInstance; - public: - void AppendRuntime(v8::Isolate* pIsolate); - void RemoveRuntime(v8::Isolate* pIsolate, - RuntimeDisposeCallback lpfnDisposeCallback); - void RemoveAllRuntimes(RuntimeDisposeCallback lpfnDisposeCallback); + void Append(v8::Isolate* pIsolate); + void Remove(v8::Isolate* pIsolate, DisposeCallback lpfnDisposeCallback); + void RemoveAll(DisposeCallback lpfnDisposeCallback); protected: - std::vector m_RuntimeList; + std::vector m_OwnedIsolates; }; #endif // XFA_FXJSE_RUNTIME_H_ -- cgit v1.2.3