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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
108 CFX_SystemHandler* pHandler = m_pApp->GetSysHandler(); | 108 CFX_SystemHandler* pHandler = m_pApp->GetSysHandler(); |
109 pHandler->KillTimer(m_nTimerID); | 109 pHandler->KillTimer(m_nTimerID); |
110 } | 110 } |
111 GetGlobalTimerMap()->erase(m_nTimerID); | 111 GetGlobalTimerMap()->erase(m_nTimerID); |
112 m_nTimerID = 0; | 112 m_nTimerID = 0; |
113 } | 113 } |
114 } | 114 } |
115 | 115 |
116 // static | 116 // static |
117 void CJS_Timer::TimerProc(int idEvent) { | 117 void CJS_Timer::TimerProc(int idEvent) { |
118 const auto it = GetGlobalTimerMap()->find(idEvent); | 118 auto it = GetGlobalTimerMap()->find(idEvent); |
119 if (it != GetGlobalTimerMap()->end()) { | 119 if (it == GetGlobalTimerMap()->end()) |
120 CJS_Timer* pTimer = it->second; | 120 return; |
121 if (!pTimer->m_bProcessing) { | 121 |
122 CFX_AutoRestorer<bool> scoped_processing(&pTimer->m_bProcessing); | 122 CJS_Timer* pTimer = it->second; |
123 pTimer->m_bProcessing = true; | 123 if (pTimer->m_bProcessing) |
124 if (pTimer->m_pEmbedObj) | 124 return; |
125 pTimer->m_pEmbedObj->TimerProc(pTimer); | 125 |
126 } | 126 pTimer->m_bProcessing = true; |
127 } | 127 if (pTimer->m_pEmbedObj) |
128 pTimer->m_pEmbedObj->TimerProc(pTimer); | |
129 | |
130 // Timer proc may have destroyed timer, find it again. | |
Lei Zhang
2016/08/04 19:02:40
Is it possible for a new timer with the same |idEv
Tom Sepez
2016/08/04 19:12:40
It's up to the embedder, and doesn't happen AFAICT
| |
131 it = GetGlobalTimerMap()->find(idEvent); | |
132 if (it == GetGlobalTimerMap()->end()) | |
133 return; | |
134 | |
135 pTimer->m_bProcessing = false; | |
128 } | 136 } |
129 | 137 |
130 // static | 138 // static |
131 CJS_Timer::TimerMap* CJS_Timer::GetGlobalTimerMap() { | 139 CJS_Timer::TimerMap* CJS_Timer::GetGlobalTimerMap() { |
132 // Leak the timer array at shutdown. | 140 // Leak the timer array at shutdown. |
133 static auto* s_TimerMap = new TimerMap; | 141 static auto* s_TimerMap = new TimerMap; |
134 return s_TimerMap; | 142 return s_TimerMap; |
135 } | 143 } |
136 | 144 |
137 void CJS_Timer::OnDestroyed() { | 145 void CJS_Timer::OnDestroyed() { |
138 m_bValid = false; | 146 m_bValid = false; |
139 } | 147 } |
OLD | NEW |