| 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 FXJSE_SCOPE_INLINE_H_ | |
| 8 #define FXJSE_SCOPE_INLINE_H_ | |
| 9 | |
| 10 #include "fxjse/context.h" | |
| 11 #include "fxjse/runtime.h" | |
| 12 | |
| 13 class CFXJSE_ScopeUtil_IsolateHandle { | |
| 14 public: | |
| 15 explicit CFXJSE_ScopeUtil_IsolateHandle(v8::Isolate* pIsolate) | |
| 16 : m_isolate(pIsolate), m_iscope(pIsolate), m_hscope(pIsolate) {} | |
| 17 v8::Isolate* GetIsolate() { return m_isolate; } | |
| 18 | |
| 19 private: | |
| 20 CFXJSE_ScopeUtil_IsolateHandle(const CFXJSE_ScopeUtil_IsolateHandle&) = | |
| 21 delete; | |
| 22 void operator=(const CFXJSE_ScopeUtil_IsolateHandle&) = delete; | |
| 23 void* operator new(size_t size) = delete; | |
| 24 void operator delete(void*, size_t) = delete; | |
| 25 | |
| 26 v8::Isolate* m_isolate; | |
| 27 v8::Isolate::Scope m_iscope; | |
| 28 v8::HandleScope m_hscope; | |
| 29 }; | |
| 30 | |
| 31 class CFXJSE_ScopeUtil_IsolateHandleRootContext { | |
| 32 public: | |
| 33 explicit CFXJSE_ScopeUtil_IsolateHandleRootContext(v8::Isolate* pIsolate) | |
| 34 : m_parent(pIsolate), | |
| 35 m_cscope(v8::Local<v8::Context>::New( | |
| 36 pIsolate, | |
| 37 CFXJSE_RuntimeData::Get(pIsolate)->m_hRootContext)) {} | |
| 38 | |
| 39 private: | |
| 40 CFXJSE_ScopeUtil_IsolateHandleRootContext( | |
| 41 const CFXJSE_ScopeUtil_IsolateHandleRootContext&) = delete; | |
| 42 void operator=(const CFXJSE_ScopeUtil_IsolateHandleRootContext&) = delete; | |
| 43 void* operator new(size_t size) = delete; | |
| 44 void operator delete(void*, size_t) = delete; | |
| 45 | |
| 46 CFXJSE_ScopeUtil_IsolateHandle m_parent; | |
| 47 v8::Context::Scope m_cscope; | |
| 48 }; | |
| 49 | |
| 50 class CFXJSE_ScopeUtil_IsolateHandleContext { | |
| 51 public: | |
| 52 explicit CFXJSE_ScopeUtil_IsolateHandleContext(CFXJSE_Context* pContext) | |
| 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 | |
| 63 private: | |
| 64 CFXJSE_ScopeUtil_IsolateHandleContext( | |
| 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 | |
| 70 CFXJSE_Context* m_context; | |
| 71 CFXJSE_ScopeUtil_IsolateHandle m_parent; | |
| 72 v8::Context::Scope m_cscope; | |
| 73 }; | |
| 74 | |
| 75 #endif // FXJSE_SCOPE_INLINE_H_ | |
| OLD | NEW |