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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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) | 120 CJS_GlobalData::CJS_GlobalData(CPDFDoc_Environment* pApp) : m_RefCount(0) { |
Lei Zhang
2015/10/14 21:02:27
Why bother even passing in |pApp| then?
| |
121 : m_pApp(pApp), m_RefCount(0) { | |
122 m_sFilePath += SDK_JS_GLOBALDATA_FILENAME; | 121 m_sFilePath += SDK_JS_GLOBALDATA_FILENAME; |
123 LoadGlobalPersistentVariables(); | 122 LoadGlobalPersistentVariables(); |
124 } | 123 } |
125 | 124 |
126 CJS_GlobalData::~CJS_GlobalData() { | 125 CJS_GlobalData::~CJS_GlobalData() { |
127 SaveGlobalPersisitentVariables(); | 126 SaveGlobalPersisitentVariables(); |
128 for (int i = 0, sz = m_arrayGlobalData.GetSize(); i < sz; i++) | 127 for (int i = 0, sz = m_arrayGlobalData.GetSize(); i < sz; i++) |
129 delete m_arrayGlobalData.GetAt(i); | 128 delete m_arrayGlobalData.GetAt(i); |
130 | 129 |
131 m_arrayGlobalData.RemoveAll(); | 130 m_arrayGlobalData.RemoveAll(); |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
490 case JS_GLOBALDATA_TYPE_NULL: { | 489 case JS_GLOBALDATA_TYPE_NULL: { |
491 FX_DWORD dwNameLen = (FX_DWORD)name.GetLength(); | 490 FX_DWORD dwNameLen = (FX_DWORD)name.GetLength(); |
492 sData.AppendBlock(&dwNameLen, sizeof(FX_DWORD)); | 491 sData.AppendBlock(&dwNameLen, sizeof(FX_DWORD)); |
493 sData.AppendString(name); | 492 sData.AppendString(name); |
494 sData.AppendBlock(&wType, sizeof(FX_DWORD)); | 493 sData.AppendBlock(&wType, sizeof(FX_DWORD)); |
495 } break; | 494 } break; |
496 default: | 495 default: |
497 break; | 496 break; |
498 } | 497 } |
499 } | 498 } |
OLD | NEW |