| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | |
| 6 | |
| 7 #ifndef XFA_FXJSE_SCOPE_INLINE_H_ | |
| 8 #define XFA_FXJSE_SCOPE_INLINE_H_ | |
| 9 | |
| 10 #include "xfa/fxjse/context.h" | |
| 11 #include "xfa/fxjse/runtime.h" | |
| 12 | |
| 13 class CFXJSE_ScopeUtil_IsolateHandle { | |
| 14 public: | |
| 15 explicit CFXJSE_ScopeUtil_IsolateHandle(v8::Isolate* pIsolate) | |
| 16 : m_isolate(pIsolate), | |
| 17 m_iscope(pIsolate), | |
| 18 m_hscope(pIsolate) {} | |
| 19 v8::Isolate* GetIsolate() { return m_isolate; } | |
| 20 | |
| 21 private: | |
| 22 CFXJSE_ScopeUtil_IsolateHandle(const CFXJSE_ScopeUtil_IsolateHandle&) = | |
| 23 delete; | |
| 24 void operator=(const CFXJSE_ScopeUtil_IsolateHandle&) = delete; | |
| 25 void* operator new(size_t size) = delete; | |
| 26 void operator delete(void*, size_t) = delete; | |
| 27 | |
| 28 v8::Isolate* m_isolate; | |
| 29 v8::Isolate::Scope m_iscope; | |
| 30 v8::HandleScope m_hscope; | |
| 31 }; | |
| 32 | |
| 33 class CFXJSE_ScopeUtil_IsolateHandleRootContext { | |
| 34 public: | |
| 35 explicit CFXJSE_ScopeUtil_IsolateHandleRootContext(v8::Isolate* pIsolate) | |
| 36 : m_parent(pIsolate), | |
| 37 m_cscope(v8::Local<v8::Context>::New( | |
| 38 pIsolate, | |
| 39 CFXJSE_RuntimeData::Get(pIsolate)->m_hRootContext)) {} | |
| 40 | |
| 41 private: | |
| 42 CFXJSE_ScopeUtil_IsolateHandleRootContext( | |
| 43 const CFXJSE_ScopeUtil_IsolateHandleRootContext&) = delete; | |
| 44 void operator=(const CFXJSE_ScopeUtil_IsolateHandleRootContext&) = delete; | |
| 45 void* operator new(size_t size) = delete; | |
| 46 void operator delete(void*, size_t) = delete; | |
| 47 | |
| 48 CFXJSE_ScopeUtil_IsolateHandle m_parent; | |
| 49 v8::Context::Scope m_cscope; | |
| 50 }; | |
| 51 | |
| 52 class CFXJSE_ScopeUtil_IsolateHandleContext { | |
| 53 public: | |
| 54 explicit CFXJSE_ScopeUtil_IsolateHandleContext(CFXJSE_Context* pContext) | |
| 55 : m_context(pContext), | |
| 56 m_parent(pContext->m_pIsolate), | |
| 57 m_cscope(v8::Local<v8::Context>::New(pContext->m_pIsolate, | |
| 58 pContext->m_hContext)) {} | |
| 59 v8::Isolate* GetIsolate() { return m_context->m_pIsolate; } | |
| 60 v8::Local<v8::Context> GetLocalContext() { | |
| 61 return v8::Local<v8::Context>::New(m_context->m_pIsolate, | |
| 62 m_context->m_hContext); | |
| 63 } | |
| 64 | |
| 65 private: | |
| 66 CFXJSE_ScopeUtil_IsolateHandleContext( | |
| 67 const CFXJSE_ScopeUtil_IsolateHandleContext&) = delete; | |
| 68 void operator=(const CFXJSE_ScopeUtil_IsolateHandleContext&) = delete; | |
| 69 void* operator new(size_t size) = delete; | |
| 70 void operator delete(void*, size_t) = delete; | |
| 71 | |
| 72 CFXJSE_Context* m_context; | |
| 73 CFXJSE_ScopeUtil_IsolateHandle m_parent; | |
| 74 v8::Context::Scope m_cscope; | |
| 75 }; | |
| 76 | |
| 77 #endif // XFA_FXJSE_SCOPE_INLINE_H_ | |
| OLD | NEW |