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 #include "JS_GlobalData.h" | 7 #include "JS_GlobalData.h" |
8 | 8 |
9 #include "../../../core/include/fdrm/fx_crypt.h" | 9 #include "../../../core/include/fdrm/fx_crypt.h" |
10 #include "../../include/javascript/IJavaScript.h" | 10 #include "../../include/javascript/IJavaScript.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 0x04, 0x75, 0x89, 0xc9, 0xb1, 0xed, 0x50, 0xca, 0x96, 0x6f, 0x1a, 0x7a, | 97 0x04, 0x75, 0x89, 0xc9, 0xb1, 0xed, 0x50, 0xca, 0x96, 0x6f, 0x1a, 0x7a, |
98 0xfe, 0x58, 0x5d, 0xec, 0x19, 0x4a, 0xf6, 0x35, 0x6a, 0x97, 0x14, 0x00, | 98 0xfe, 0x58, 0x5d, 0xec, 0x19, 0x4a, 0xf6, 0x35, 0x6a, 0x97, 0x14, 0x00, |
99 0x0e, 0xd0, 0x6b, 0xbb, 0xd5, 0x75, 0x55, 0x8b, 0x6e, 0x6b, 0x19, 0xa0, | 99 0x0e, 0xd0, 0x6b, 0xbb, 0xd5, 0x75, 0x55, 0x8b, 0x6e, 0x6b, 0x19, 0xa0, |
100 0xf8, 0x77, 0xd5, 0xa3}; | 100 0xf8, 0x77, 0xd5, 0xa3}; |
101 | 101 |
102 CJS_GlobalData* CJS_GlobalData::g_Instance = nullptr; | 102 CJS_GlobalData* CJS_GlobalData::g_Instance = nullptr; |
103 | 103 |
104 // static | 104 // static |
105 CJS_GlobalData* CJS_GlobalData::GetRetainedInstance(CPDFDoc_Environment* pApp) { | 105 CJS_GlobalData* CJS_GlobalData::GetRetainedInstance(CPDFDoc_Environment* pApp) { |
106 if (!g_Instance) { | 106 if (!g_Instance) { |
107 g_Instance = new CJS_GlobalData(pApp); | 107 g_Instance = new CJS_GlobalData(); |
108 } | 108 } |
109 ++g_Instance->m_RefCount; | 109 ++g_Instance->m_RefCount; |
110 return g_Instance; | 110 return g_Instance; |
111 } | 111 } |
112 | 112 |
113 void CJS_GlobalData::Release() { | 113 void CJS_GlobalData::Release() { |
114 if (!--m_RefCount) { | 114 if (!--m_RefCount) { |
115 delete g_Instance; | 115 delete g_Instance; |
116 g_Instance = nullptr; | 116 g_Instance = nullptr; |
117 } | 117 } |
118 } | 118 } |
119 | 119 |
120 CJS_GlobalData::CJS_GlobalData(CPDFDoc_Environment* pApp) : m_RefCount(0) { | 120 CJS_GlobalData::CJS_GlobalData() : m_RefCount(0) { |
121 m_sFilePath += SDK_JS_GLOBALDATA_FILENAME; | 121 m_sFilePath += SDK_JS_GLOBALDATA_FILENAME; |
122 LoadGlobalPersistentVariables(); | 122 LoadGlobalPersistentVariables(); |
123 } | 123 } |
124 | 124 |
125 CJS_GlobalData::~CJS_GlobalData() { | 125 CJS_GlobalData::~CJS_GlobalData() { |
126 SaveGlobalPersisitentVariables(); | 126 SaveGlobalPersisitentVariables(); |
127 for (int i = 0, sz = m_arrayGlobalData.GetSize(); i < sz; i++) | 127 for (int i = 0, sz = m_arrayGlobalData.GetSize(); i < sz; i++) |
128 delete m_arrayGlobalData.GetAt(i); | 128 delete m_arrayGlobalData.GetAt(i); |
129 | 129 |
130 m_arrayGlobalData.RemoveAll(); | 130 m_arrayGlobalData.RemoveAll(); |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 case JS_GLOBALDATA_TYPE_NULL: { | 489 case JS_GLOBALDATA_TYPE_NULL: { |
490 FX_DWORD dwNameLen = (FX_DWORD)name.GetLength(); | 490 FX_DWORD dwNameLen = (FX_DWORD)name.GetLength(); |
491 sData.AppendBlock(&dwNameLen, sizeof(FX_DWORD)); | 491 sData.AppendBlock(&dwNameLen, sizeof(FX_DWORD)); |
492 sData.AppendString(name); | 492 sData.AppendString(name); |
493 sData.AppendBlock(&wType, sizeof(FX_DWORD)); | 493 sData.AppendBlock(&wType, sizeof(FX_DWORD)); |
494 } break; | 494 } break; |
495 default: | 495 default: |
496 break; | 496 break; |
497 } | 497 } |
498 } | 498 } |
OLD | NEW |