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

Side by Side Diff: fpdfsdk/javascript/global.h

Issue 2154843002: Clean up singleton implementation (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: rebase Created 4 years, 5 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 | « fpdfsdk/javascript/JS_KeyValue.cpp ('k') | fpdfsdk/javascript/global.cpp » ('j') | 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 #ifndef FPDFSDK_JAVASCRIPT_GLOBAL_H_ 7 #ifndef FPDFSDK_JAVASCRIPT_GLOBAL_H_
8 #define FPDFSDK_JAVASCRIPT_GLOBAL_H_ 8 #define FPDFSDK_JAVASCRIPT_GLOBAL_H_
9 9
10 #include <map> 10 #include <map>
11 #include <vector> 11 #include <vector>
12 12
13 #include "fpdfsdk/javascript/JS_Define.h" 13 #include "fpdfsdk/javascript/JS_Define.h"
14 #include "fpdfsdk/javascript/JS_KeyValue.h"
14 15
15 class CJS_GlobalData; 16 class CJS_GlobalData;
16 class CJS_GlobalVariableArray; 17 class CJS_GlobalVariableArray;
17 class CJS_KeyValue; 18 class CJS_KeyValue;
18 19
19 struct JSGlobalData { 20 struct JSGlobalData {
20 JSGlobalData(); 21 JSGlobalData();
21 ~JSGlobalData(); 22 ~JSGlobalData();
22 23
23 int nType; // 0:int 1:bool 2:string 3:obj 24 JS_GlobalDataType nType;
24 double dData; 25 double dData;
25 bool bData; 26 bool bData;
26 CFX_ByteString sData; 27 CFX_ByteString sData;
27 v8::Global<v8::Object> pData; 28 v8::Global<v8::Object> pData;
28 bool bPersistent; 29 bool bPersistent;
29 bool bDeleted; 30 bool bDeleted;
30 }; 31 };
31 32
32 class JSGlobalAlternate : public CJS_EmbedObj { 33 class JSGlobalAlternate : public CJS_EmbedObj {
33 public: 34 public:
(...skipping 12 matching lines...) Expand all
46 FX_BOOL DelProperty(IJS_Context* cc, 47 FX_BOOL DelProperty(IJS_Context* cc,
47 const FX_WCHAR* propname, 48 const FX_WCHAR* propname,
48 CFX_WideString& sError); 49 CFX_WideString& sError);
49 void Initial(CPDFDoc_Environment* pApp); 50 void Initial(CPDFDoc_Environment* pApp);
50 51
51 private: 52 private:
52 void UpdateGlobalPersistentVariables(); 53 void UpdateGlobalPersistentVariables();
53 void CommitGlobalPersisitentVariables(IJS_Context* cc); 54 void CommitGlobalPersisitentVariables(IJS_Context* cc);
54 void DestroyGlobalPersisitentVariables(); 55 void DestroyGlobalPersisitentVariables();
55 FX_BOOL SetGlobalVariables(const CFX_ByteString& propname, 56 FX_BOOL SetGlobalVariables(const CFX_ByteString& propname,
56 int nType, 57 JS_GlobalDataType nType,
57 double dData, 58 double dData,
58 bool bData, 59 bool bData,
59 const CFX_ByteString& sData, 60 const CFX_ByteString& sData,
60 v8::Local<v8::Object> pData, 61 v8::Local<v8::Object> pData,
61 bool bDefaultPersistent); 62 bool bDefaultPersistent);
62 void ObjectToArray(IJS_Context* cc, 63 void ObjectToArray(IJS_Context* cc,
63 v8::Local<v8::Object> pObj, 64 v8::Local<v8::Object> pObj,
64 CJS_GlobalVariableArray& array); 65 CJS_GlobalVariableArray& array);
65 void PutObjectProperty(v8::Local<v8::Object> obj, CJS_KeyValue* pData); 66 void PutObjectProperty(v8::Local<v8::Object> obj, CJS_KeyValue* pData);
66 67
67 std::map<CFX_ByteString, JSGlobalData*> m_mapGlobal; 68 std::map<CFX_ByteString, JSGlobalData*> m_mapGlobal;
68 CFX_WideString m_sFilePath; 69 CFX_WideString m_sFilePath;
69 CJS_GlobalData* m_pGlobalData; 70 CJS_GlobalData* m_pGlobalData;
70 CPDFDoc_Environment* m_pApp; 71 CPDFDoc_Environment* m_pApp;
71 }; 72 };
72 73
73 class CJS_Global : public CJS_Object { 74 class CJS_Global : public CJS_Object {
74 public: 75 public:
75 explicit CJS_Global(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {} 76 explicit CJS_Global(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
76 ~CJS_Global() override {} 77 ~CJS_Global() override {}
77 78
78 // CJS_Object 79 // CJS_Object
79 void InitInstance(IJS_Runtime* pIRuntime) override; 80 void InitInstance(IJS_Runtime* pIRuntime) override;
80 81
81 DECLARE_SPECIAL_JS_CLASS(); 82 DECLARE_SPECIAL_JS_CLASS();
82 JS_SPECIAL_STATIC_METHOD(setPersistent, JSGlobalAlternate, global); 83 JS_SPECIAL_STATIC_METHOD(setPersistent, JSGlobalAlternate, global);
83 }; 84 };
84 85
85 #endif // FPDFSDK_JAVASCRIPT_GLOBAL_H_ 86 #endif // FPDFSDK_JAVASCRIPT_GLOBAL_H_
OLDNEW
« no previous file with comments | « fpdfsdk/javascript/JS_KeyValue.cpp ('k') | fpdfsdk/javascript/global.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698