Chromium Code Reviews| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 95 0xd0, 0xdf, 0x8c, 0xfa, 0x2a, 0xa9, 0x49, 0xfd, 0x97, 0x1c, 0x0e, 0x22, | 95 0xd0, 0xdf, 0x8c, 0xfa, 0x2a, 0xa9, 0x49, 0xfd, 0x97, 0x1c, 0x0e, 0x22, |
| 96 0x13, 0x28, 0x7c, 0xaf, 0xc4, 0xfc, 0x9c, 0x12, 0x65, 0x8c, 0x4e, 0x5b, | 96 0x13, 0x28, 0x7c, 0xaf, 0xc4, 0xfc, 0x9c, 0x12, 0x65, 0x8c, 0x4e, 0x5b, |
| 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) { |
|
Lei Zhang
2015/10/14 21:18:41
And in turn, |pApp| isn't needed here.
| |
| 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) | 120 CJS_GlobalData::CJS_GlobalData() : m_RefCount(0) { |
| 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 |