| 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/include/fpdfxfa/fpdfxfa_util.h" |   7 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_util.h" | 
|   8 #include "fpdfsdk/include/fsdk_define.h" |   8 #include "fpdfsdk/include/fsdk_define.h" | 
|   9 #include "fpdfsdk/include/fsdk_mgr.h" |   9 #include "fpdfsdk/include/fsdk_mgr.h" | 
|  10  |  10  | 
|  11 std::vector<CFWL_TimerInfo*> CXFA_FWLAdapterTimerMgr::s_TimerArray; |  11 std::vector<CFWL_TimerInfo*>* CXFA_FWLAdapterTimerMgr::s_TimerArray = nullptr; | 
|  12  |  12  | 
|  13 FWL_ERR CXFA_FWLAdapterTimerMgr::Start(IFWL_Timer* pTimer, |  13 FWL_ERR CXFA_FWLAdapterTimerMgr::Start(IFWL_Timer* pTimer, | 
|  14                                        FX_DWORD dwElapse, |  14                                        FX_DWORD dwElapse, | 
|  15                                        FWL_HTIMER& hTimer, |  15                                        FWL_HTIMER& hTimer, | 
|  16                                        FX_BOOL bImmediately) { |  16                                        FX_BOOL bImmediately) { | 
|  17   if (!m_pEnv) |  17   if (!m_pEnv) | 
|  18     return FWL_ERR_Indefinite; |  18     return FWL_ERR_Indefinite; | 
|  19  |  19  | 
|  20   uint32_t uIDEvent = m_pEnv->FFI_SetTimer(dwElapse, TimerProc); |  20   uint32_t uIDEvent = m_pEnv->FFI_SetTimer(dwElapse, TimerProc); | 
|  21   s_TimerArray.push_back(new CFWL_TimerInfo(uIDEvent, pTimer)); |  21   if (!s_TimerArray) | 
|  22   hTimer = reinterpret_cast<FWL_HTIMER>(s_TimerArray.back()); |  22     s_TimerArray = new std::vector<CFWL_TimerInfo*>; | 
 |  23   s_TimerArray->push_back(new CFWL_TimerInfo(uIDEvent, pTimer)); | 
 |  24   hTimer = reinterpret_cast<FWL_HTIMER>(s_TimerArray->back()); | 
|  23   return FWL_ERR_Succeeded; |  25   return FWL_ERR_Succeeded; | 
|  24 } |  26 } | 
|  25  |  27  | 
|  26 FWL_ERR CXFA_FWLAdapterTimerMgr::Stop(FWL_HTIMER hTimer) { |  28 FWL_ERR CXFA_FWLAdapterTimerMgr::Stop(FWL_HTIMER hTimer) { | 
|  27   if (!hTimer || !m_pEnv) |  29   if (!hTimer || !m_pEnv) | 
|  28     return FWL_ERR_Indefinite; |  30     return FWL_ERR_Indefinite; | 
|  29  |  31  | 
|  30   CFWL_TimerInfo* pInfo = reinterpret_cast<CFWL_TimerInfo*>(hTimer); |  32   CFWL_TimerInfo* pInfo = reinterpret_cast<CFWL_TimerInfo*>(hTimer); | 
|  31   m_pEnv->FFI_KillTimer(pInfo->uIDEvent); |  33   m_pEnv->FFI_KillTimer(pInfo->uIDEvent); | 
|  32   auto it = std::find(s_TimerArray.begin(), s_TimerArray.end(), pInfo); |  34   if (s_TimerArray) { | 
|  33   if (it != s_TimerArray.end()) { |  35     auto it = std::find(s_TimerArray->begin(), s_TimerArray->end(), pInfo); | 
|  34     s_TimerArray.erase(it); |  36     if (it != s_TimerArray->end()) { | 
|  35     delete pInfo; |  37       s_TimerArray->erase(it); | 
 |  38       delete pInfo; | 
 |  39     } | 
|  36   } |  40   } | 
|  37   return FWL_ERR_Succeeded; |  41   return FWL_ERR_Succeeded; | 
|  38 } |  42 } | 
|  39  |  43  | 
 |  44 // static | 
|  40 void CXFA_FWLAdapterTimerMgr::TimerProc(int32_t idEvent) { |  45 void CXFA_FWLAdapterTimerMgr::TimerProc(int32_t idEvent) { | 
|  41   for (CFWL_TimerInfo* pInfo : s_TimerArray) { |  46   if (!s_TimerArray) | 
 |  47     return; | 
 |  48  | 
 |  49   for (CFWL_TimerInfo* pInfo : *s_TimerArray) { | 
|  42     if (pInfo->uIDEvent == idEvent) { |  50     if (pInfo->uIDEvent == idEvent) { | 
|  43       pInfo->pTimer->Run(reinterpret_cast<FWL_HTIMER>(pInfo)); |  51       pInfo->pTimer->Run(reinterpret_cast<FWL_HTIMER>(pInfo)); | 
|  44       break; |  52       break; | 
|  45     } |  53     } | 
|  46   } |  54   } | 
|  47 } |  55 } | 
| OLD | NEW |