Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(540)

Side by Side Diff: fxjs/include/fxjs_v8.h

Issue 2354923003: Fix leaks related to the usage of JSE runtime data (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fxjs/fxjs_v8.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // FXJS_V8 is a layer that makes it easier to define native objects in V8, but 7 // FXJS_V8 is a layer that makes it easier to define native objects in V8, but
8 // has no knowledge of PDF-specific native objects. It could in theory be used 8 // has no knowledge of PDF-specific native objects. It could in theory be used
9 // to implement other sets of native objects. 9 // to implement other sets of native objects.
10 10
11 // PDFium code should include this file rather than including V8 headers 11 // PDFium code should include this file rather than including V8 headers
12 // directly. 12 // directly.
13 13
14 #ifndef FXJS_INCLUDE_FXJS_V8_H_ 14 #ifndef FXJS_INCLUDE_FXJS_V8_H_
15 #define FXJS_INCLUDE_FXJS_V8_H_ 15 #define FXJS_INCLUDE_FXJS_V8_H_
16 16
17 #include <v8-util.h> 17 #include <v8-util.h>
18 #include <v8.h> 18 #include <v8.h>
19 19
20 #include <map> 20 #include <map>
21 #include <memory>
21 #include <vector> 22 #include <vector>
22 23
23 #include "core/fxcrt/include/fx_string.h" 24 #include "core/fxcrt/include/fx_string.h"
25 #ifdef PDF_ENABLE_XFA
26 // Header for CFXJSE_RuntimeData. FXJS_V8 doesn't interpret this class,
27 // it is just passed along to XFA.
28 #include "fxjs/cfxjse_runtimedata.h"
29 #endif // PDF_ENABLE_XFA
24 30
25 class CFXJS_Engine; 31 class CFXJS_Engine;
26 class CFXJS_ObjDefinition; 32 class CFXJS_ObjDefinition;
27 33
28 // FXJS_V8 places no restrictions on this class; it merely passes it 34 // FXJS_V8 places no restrictions on this class; it merely passes it
29 // on to caller-provided methods. 35 // on to caller-provided methods.
30 class IJS_Context; // A description of the event that caused JS execution. 36 class IJS_Context; // A description of the event that caused JS execution.
31 37
32 #ifdef PDF_ENABLE_XFA
33 // FXJS_V8 places no interpreation on this calass; it merely passes it
34 // along to XFA.
35 class CFXJSE_RuntimeData;
36 #endif // PDF_ENABLE_XFA
37
38 enum FXJSOBJTYPE { 38 enum FXJSOBJTYPE {
39 FXJSOBJTYPE_DYNAMIC = 0, // Created by native method and returned to JS. 39 FXJSOBJTYPE_DYNAMIC = 0, // Created by native method and returned to JS.
40 FXJSOBJTYPE_STATIC, // Created by init and hung off of global object. 40 FXJSOBJTYPE_STATIC, // Created by init and hung off of global object.
41 FXJSOBJTYPE_GLOBAL, // The global object itself (may only appear once). 41 FXJSOBJTYPE_GLOBAL, // The global object itself (may only appear once).
42 }; 42 };
43 43
44 struct FXJSErr { 44 struct FXJSErr {
45 const wchar_t* message; 45 const wchar_t* message;
46 const wchar_t* srcline; 46 const wchar_t* srcline;
47 unsigned linnum; 47 unsigned linnum;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 if (!m_pDynamicObjsMap) 104 if (!m_pDynamicObjsMap)
105 m_pDynamicObjsMap = new V8TemplateMap(pIsolate); 105 m_pDynamicObjsMap = new V8TemplateMap(pIsolate);
106 } 106 }
107 void ReleaseDynamicObjsMap() { 107 void ReleaseDynamicObjsMap() {
108 delete m_pDynamicObjsMap; 108 delete m_pDynamicObjsMap;
109 m_pDynamicObjsMap = nullptr; 109 m_pDynamicObjsMap = nullptr;
110 } 110 }
111 111
112 std::vector<CFXJS_ObjDefinition*> m_ObjectDefnArray; 112 std::vector<CFXJS_ObjDefinition*> m_ObjectDefnArray;
113 #ifdef PDF_ENABLE_XFA 113 #ifdef PDF_ENABLE_XFA
114 CFXJSE_RuntimeData* m_pFXJSERuntimeData; 114 std::unique_ptr<CFXJSE_RuntimeData> m_pFXJSERuntimeData;
115 #endif // PDF_ENABLE_XFA 115 #endif // PDF_ENABLE_XFA
116 V8TemplateMap* m_pDynamicObjsMap; 116 V8TemplateMap* m_pDynamicObjsMap;
117 117
118 protected: 118 protected:
119 FXJS_PerIsolateData(); 119 FXJS_PerIsolateData();
120 }; 120 };
121 121
122 class FXJS_ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { 122 class FXJS_ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
123 void* Allocate(size_t length) override; 123 void* Allocate(size_t length) override;
124 void* AllocateUninitialized(size_t length) override; 124 void* AllocateUninitialized(size_t length) override;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 void Error(const CFX_WideString& message); 259 void Error(const CFX_WideString& message);
260 260
261 private: 261 private:
262 v8::Isolate* m_isolate; 262 v8::Isolate* m_isolate;
263 v8::Global<v8::Context> m_V8PersistentContext; 263 v8::Global<v8::Context> m_V8PersistentContext;
264 std::vector<v8::Global<v8::Object>*> m_StaticObjects; 264 std::vector<v8::Global<v8::Object>*> m_StaticObjects;
265 std::map<CFX_WideString, v8::Global<v8::Array>> m_ConstArrays; 265 std::map<CFX_WideString, v8::Global<v8::Array>> m_ConstArrays;
266 }; 266 };
267 267
268 #endif // FXJS_INCLUDE_FXJS_V8_H_ 268 #endif // FXJS_INCLUDE_FXJS_V8_H_
OLDNEW
« no previous file with comments | « fxjs/fxjs_v8.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698