| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #ifndef FXJSE_SCOPE_INLINE_H_ | 7 #ifndef FXJS_CFXJSE_ISOLATETRACKER_H_ |
| 8 #define FXJSE_SCOPE_INLINE_H_ | 8 #define FXJS_CFXJSE_ISOLATETRACKER_H_ |
| 9 | 9 |
| 10 #include "fxjse/context.h" | 10 #include <vector> |
| 11 #include "fxjse/runtime.h" | 11 |
| 12 #include "v8/include/v8.h" |
| 13 |
| 14 #include "fxjs/cfxjse_runtimedata.h" |
| 12 | 15 |
| 13 class CFXJSE_ScopeUtil_IsolateHandle { | 16 class CFXJSE_ScopeUtil_IsolateHandle { |
| 14 public: | 17 public: |
| 15 explicit CFXJSE_ScopeUtil_IsolateHandle(v8::Isolate* pIsolate) | 18 explicit CFXJSE_ScopeUtil_IsolateHandle(v8::Isolate* pIsolate) |
| 16 : m_isolate(pIsolate), m_iscope(pIsolate), m_hscope(pIsolate) {} | 19 : m_isolate(pIsolate), m_iscope(pIsolate), m_hscope(pIsolate) {} |
| 17 v8::Isolate* GetIsolate() { return m_isolate; } | 20 v8::Isolate* GetIsolate() { return m_isolate; } |
| 18 | 21 |
| 19 private: | 22 private: |
| 20 CFXJSE_ScopeUtil_IsolateHandle(const CFXJSE_ScopeUtil_IsolateHandle&) = | 23 CFXJSE_ScopeUtil_IsolateHandle(const CFXJSE_ScopeUtil_IsolateHandle&) = |
| 21 delete; | 24 delete; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 40 CFXJSE_ScopeUtil_IsolateHandleRootContext( | 43 CFXJSE_ScopeUtil_IsolateHandleRootContext( |
| 41 const CFXJSE_ScopeUtil_IsolateHandleRootContext&) = delete; | 44 const CFXJSE_ScopeUtil_IsolateHandleRootContext&) = delete; |
| 42 void operator=(const CFXJSE_ScopeUtil_IsolateHandleRootContext&) = delete; | 45 void operator=(const CFXJSE_ScopeUtil_IsolateHandleRootContext&) = delete; |
| 43 void* operator new(size_t size) = delete; | 46 void* operator new(size_t size) = delete; |
| 44 void operator delete(void*, size_t) = delete; | 47 void operator delete(void*, size_t) = delete; |
| 45 | 48 |
| 46 CFXJSE_ScopeUtil_IsolateHandle m_parent; | 49 CFXJSE_ScopeUtil_IsolateHandle m_parent; |
| 47 v8::Context::Scope m_cscope; | 50 v8::Context::Scope m_cscope; |
| 48 }; | 51 }; |
| 49 | 52 |
| 50 class CFXJSE_ScopeUtil_IsolateHandleContext { | 53 class CFXJSE_IsolateTracker { |
| 51 public: | 54 public: |
| 52 explicit CFXJSE_ScopeUtil_IsolateHandleContext(CFXJSE_Context* pContext) | 55 typedef void (*DisposeCallback)(v8::Isolate*, bool bOwnedIsolate); |
| 53 : m_context(pContext), | |
| 54 m_parent(pContext->m_pIsolate), | |
| 55 m_cscope(v8::Local<v8::Context>::New(pContext->m_pIsolate, | |
| 56 pContext->m_hContext)) {} | |
| 57 v8::Isolate* GetIsolate() { return m_context->m_pIsolate; } | |
| 58 v8::Local<v8::Context> GetLocalContext() { | |
| 59 return v8::Local<v8::Context>::New(m_context->m_pIsolate, | |
| 60 m_context->m_hContext); | |
| 61 } | |
| 62 | 56 |
| 63 private: | 57 CFXJSE_IsolateTracker(); |
| 64 CFXJSE_ScopeUtil_IsolateHandleContext( | 58 ~CFXJSE_IsolateTracker(); |
| 65 const CFXJSE_ScopeUtil_IsolateHandleContext&) = delete; | |
| 66 void operator=(const CFXJSE_ScopeUtil_IsolateHandleContext&) = delete; | |
| 67 void* operator new(size_t size) = delete; | |
| 68 void operator delete(void*, size_t) = delete; | |
| 69 | 59 |
| 70 CFXJSE_Context* m_context; | 60 void Append(v8::Isolate* pIsolate); |
| 71 CFXJSE_ScopeUtil_IsolateHandle m_parent; | 61 void Remove(v8::Isolate* pIsolate, DisposeCallback lpfnDisposeCallback); |
| 72 v8::Context::Scope m_cscope; | 62 void RemoveAll(DisposeCallback lpfnDisposeCallback); |
| 63 |
| 64 static CFXJSE_IsolateTracker* g_pInstance; |
| 65 |
| 66 protected: |
| 67 std::vector<v8::Isolate*> m_OwnedIsolates; |
| 73 }; | 68 }; |
| 74 | 69 |
| 75 #endif // FXJSE_SCOPE_INLINE_H_ | 70 #endif // FXJS_CFXJSE_ISOLATETRACKER_H_ |
| OLD | NEW |