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 "fpdfsdk/javascript/JS_Object.h" | 7 #include "fpdfsdk/javascript/JS_Object.h" |
8 | 8 |
9 #include "fpdfsdk/include/fsdk_mgr.h" | 9 #include "fpdfsdk/include/fsdk_mgr.h" |
10 #include "fpdfsdk/javascript/JS_Define.h" | 10 #include "fpdfsdk/javascript/JS_Define.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 uint32_t dwTimeOut) | 100 uint32_t dwTimeOut) |
101 : m_nTimerID(0), | 101 : m_nTimerID(0), |
102 m_pEmbedObj(pObj), | 102 m_pEmbedObj(pObj), |
103 m_bProcessing(false), | 103 m_bProcessing(false), |
104 m_bValid(true), | 104 m_bValid(true), |
105 m_nType(nType), | 105 m_nType(nType), |
106 m_dwTimeOut(dwTimeOut), | 106 m_dwTimeOut(dwTimeOut), |
107 m_swJScript(script), | 107 m_swJScript(script), |
108 m_pRuntime(pRuntime), | 108 m_pRuntime(pRuntime), |
109 m_pApp(pApp) { | 109 m_pApp(pApp) { |
110 IFX_SystemHandler* pHandler = m_pApp->GetSysHandler(); | 110 CFX_SystemHandler* pHandler = m_pApp->GetSysHandler(); |
111 m_nTimerID = pHandler->SetTimer(dwElapse, TimerProc); | 111 m_nTimerID = pHandler->SetTimer(dwElapse, TimerProc); |
112 (*GetGlobalTimerMap())[m_nTimerID] = this; | 112 (*GetGlobalTimerMap())[m_nTimerID] = this; |
113 m_pRuntime->AddObserver(this); | 113 m_pRuntime->AddObserver(this); |
114 } | 114 } |
115 | 115 |
116 CJS_Timer::~CJS_Timer() { | 116 CJS_Timer::~CJS_Timer() { |
117 CJS_Runtime* pRuntime = GetRuntime(); | 117 CJS_Runtime* pRuntime = GetRuntime(); |
118 if (pRuntime) | 118 if (pRuntime) |
119 pRuntime->RemoveObserver(this); | 119 pRuntime->RemoveObserver(this); |
120 KillJSTimer(); | 120 KillJSTimer(); |
121 } | 121 } |
122 | 122 |
123 void CJS_Timer::KillJSTimer() { | 123 void CJS_Timer::KillJSTimer() { |
124 if (m_nTimerID) { | 124 if (m_nTimerID) { |
125 if (m_bValid) { | 125 if (m_bValid) { |
126 IFX_SystemHandler* pHandler = m_pApp->GetSysHandler(); | 126 CFX_SystemHandler* pHandler = m_pApp->GetSysHandler(); |
127 pHandler->KillTimer(m_nTimerID); | 127 pHandler->KillTimer(m_nTimerID); |
128 } | 128 } |
129 GetGlobalTimerMap()->erase(m_nTimerID); | 129 GetGlobalTimerMap()->erase(m_nTimerID); |
130 m_nTimerID = 0; | 130 m_nTimerID = 0; |
131 } | 131 } |
132 } | 132 } |
133 | 133 |
134 // static | 134 // static |
135 void CJS_Timer::TimerProc(int idEvent) { | 135 void CJS_Timer::TimerProc(int idEvent) { |
136 const auto it = GetGlobalTimerMap()->find(idEvent); | 136 const auto it = GetGlobalTimerMap()->find(idEvent); |
(...skipping 11 matching lines...) Expand all Loading... |
148 // static | 148 // static |
149 CJS_Timer::TimerMap* CJS_Timer::GetGlobalTimerMap() { | 149 CJS_Timer::TimerMap* CJS_Timer::GetGlobalTimerMap() { |
150 // Leak the timer array at shutdown. | 150 // Leak the timer array at shutdown. |
151 static auto* s_TimerMap = new TimerMap; | 151 static auto* s_TimerMap = new TimerMap; |
152 return s_TimerMap; | 152 return s_TimerMap; |
153 } | 153 } |
154 | 154 |
155 void CJS_Timer::OnDestroyed() { | 155 void CJS_Timer::OnDestroyed() { |
156 m_bValid = false; | 156 m_bValid = false; |
157 } | 157 } |
OLD | NEW |