OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 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 XFA_FXJSE_RUNTIME_H_ | 7 #ifndef XFA_FXJSE_RUNTIME_H_ |
8 #define XFA_FXJSE_RUNTIME_H_ | 8 #define XFA_FXJSE_RUNTIME_H_ |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "core/fxcrt/include/fx_basic.h" | 12 #include "core/fxcrt/include/fx_basic.h" |
13 #include "v8/include/v8.h" | 13 #include "v8/include/v8.h" |
14 | 14 |
15 class CFXJSE_RuntimeList; | 15 class CFXJSE_RuntimeList; |
16 | 16 |
17 class CFXJSE_RuntimeData { | 17 class CFXJSE_RuntimeData { |
18 protected: | |
19 CFXJSE_RuntimeData(v8::Isolate* pIsolate) : m_pIsolate(pIsolate) {} | |
20 | |
21 public: | 18 public: |
22 static CFXJSE_RuntimeData* Create(v8::Isolate* pIsolate); | |
23 static CFXJSE_RuntimeData* Get(v8::Isolate* pIsolate); | 19 static CFXJSE_RuntimeData* Get(v8::Isolate* pIsolate); |
24 | 20 |
25 public: | |
26 v8::Isolate* m_pIsolate; | 21 v8::Isolate* m_pIsolate; |
27 v8::Global<v8::FunctionTemplate> m_hRootContextGlobalTemplate; | 22 v8::Global<v8::FunctionTemplate> m_hRootContextGlobalTemplate; |
28 v8::Global<v8::Context> m_hRootContext; | 23 v8::Global<v8::Context> m_hRootContext; |
29 | 24 |
30 public: | |
31 static CFXJSE_RuntimeList* g_RuntimeList; | |
32 | |
33 protected: | 25 protected: |
| 26 static CFXJSE_RuntimeData* Create(v8::Isolate* pIsolate); |
| 27 CFXJSE_RuntimeData(v8::Isolate* pIsolate) : m_pIsolate(pIsolate) {} |
34 CFXJSE_RuntimeData(); | 28 CFXJSE_RuntimeData(); |
35 CFXJSE_RuntimeData(const CFXJSE_RuntimeData&); | 29 CFXJSE_RuntimeData(const CFXJSE_RuntimeData&); |
36 CFXJSE_RuntimeData& operator=(const CFXJSE_RuntimeData&); | 30 CFXJSE_RuntimeData& operator=(const CFXJSE_RuntimeData&); |
37 }; | 31 }; |
38 | 32 |
39 class CFXJSE_RuntimeList { | 33 class CFXJSE_IsolateTracker { |
40 public: | 34 public: |
41 typedef void (*RuntimeDisposeCallback)(v8::Isolate*); | 35 typedef void (*DisposeCallback)(v8::Isolate*, bool bOwnedIsolate); |
| 36 static CFXJSE_IsolateTracker* g_pInstance; |
42 | 37 |
43 public: | 38 void Append(v8::Isolate* pIsolate); |
44 void AppendRuntime(v8::Isolate* pIsolate); | 39 void Remove(v8::Isolate* pIsolate, DisposeCallback lpfnDisposeCallback); |
45 void RemoveRuntime(v8::Isolate* pIsolate, | 40 void RemoveAll(DisposeCallback lpfnDisposeCallback); |
46 RuntimeDisposeCallback lpfnDisposeCallback); | |
47 void RemoveAllRuntimes(RuntimeDisposeCallback lpfnDisposeCallback); | |
48 | 41 |
49 protected: | 42 protected: |
50 std::vector<v8::Isolate*> m_RuntimeList; | 43 std::vector<v8::Isolate*> m_OwnedIsolates; |
51 }; | 44 }; |
52 | 45 |
53 #endif // XFA_FXJSE_RUNTIME_H_ | 46 #endif // XFA_FXJSE_RUNTIME_H_ |
OLD | NEW |