Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: fpdfsdk/src/fpdfxfa/fpdfxfa_util.cpp

Issue 1664543005: Kill CFX_PtryArray in CXFA_FWLAdapterTimerMgr. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Stale iterator. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/include/fpdfxfa/fpdfxfa_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/fsdk_define.h" 7 #include "fpdfsdk/include/fsdk_define.h"
8 #include "fpdfsdk/include/fsdk_mgr.h" 8 #include "fpdfsdk/include/fsdk_mgr.h"
9 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_util.h" 9 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_util.h"
10 10
11 CFX_PtrArray CXFA_FWLAdapterTimerMgr::ms_timerArray; 11 std::vector<CFWL_TimerInfo*> CXFA_FWLAdapterTimerMgr::s_TimerArray;
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 /* = TRUE */) { 16 FX_BOOL bImmediately) {
17 if (m_pEnv) { 17 if (!m_pEnv)
18 uint32_t uIDEvent = m_pEnv->FFI_SetTimer(dwElapse, TimerProc); 18 return FWL_ERR_Indefinite;
19 CFWL_TimerInfo* pInfo = new CFWL_TimerInfo;
20 pInfo->uIDEvent = uIDEvent;
21 pInfo->pTimer = pTimer;
22 ms_timerArray.Add(pInfo);
23 19
24 hTimer = (FWL_HTIMER)pInfo; 20 uint32_t uIDEvent = m_pEnv->FFI_SetTimer(dwElapse, TimerProc);
25 return FWL_ERR_Succeeded; 21 s_TimerArray.push_back(new CFWL_TimerInfo(uIDEvent, pTimer));
26 } 22 hTimer = reinterpret_cast<FWL_HTIMER>(s_TimerArray.back());
27 23 return FWL_ERR_Succeeded;
28 return FWL_ERR_Indefinite;
29 } 24 }
30 25
31 FWL_ERR CXFA_FWLAdapterTimerMgr::Stop(FWL_HTIMER hTimer) { 26 FWL_ERR CXFA_FWLAdapterTimerMgr::Stop(FWL_HTIMER hTimer) {
32 if (!hTimer) 27 if (!hTimer || !m_pEnv)
33 return FWL_ERR_Indefinite; 28 return FWL_ERR_Indefinite;
34 29
35 if (m_pEnv) { 30 CFWL_TimerInfo* pInfo = reinterpret_cast<CFWL_TimerInfo*>(hTimer);
36 CFWL_TimerInfo* pInfo = (CFWL_TimerInfo*)hTimer; 31 m_pEnv->FFI_KillTimer(pInfo->uIDEvent);
37 32 auto it = std::find(s_TimerArray.begin(), s_TimerArray.end(), pInfo);
38 m_pEnv->FFI_KillTimer(pInfo->uIDEvent); 33 if (it != s_TimerArray.end()) {
39 34 s_TimerArray.erase(it);
40 int32_t index = ms_timerArray.Find(pInfo); 35 delete pInfo;
41 if (index >= 0) {
42 ms_timerArray.RemoveAt(index);
43 delete pInfo;
44 }
45 return FWL_ERR_Succeeded;
46 } 36 }
47 37 return FWL_ERR_Succeeded;
48 return FWL_ERR_Indefinite;
49 } 38 }
50 39
51 void CXFA_FWLAdapterTimerMgr::TimerProc(int32_t idEvent) { 40 void CXFA_FWLAdapterTimerMgr::TimerProc(int32_t idEvent) {
52 CFWL_TimerInfo* pInfo = NULL; 41 for (CFWL_TimerInfo* pInfo : s_TimerArray) {
53 int32_t iCount = CXFA_FWLAdapterTimerMgr::ms_timerArray.GetSize(); 42 if (pInfo->uIDEvent == idEvent) {
54 for (int32_t i = 0; i < iCount; i++) { 43 pInfo->pTimer->Run(reinterpret_cast<FWL_HTIMER>(pInfo));
55 CFWL_TimerInfo* pTemp =
56 (CFWL_TimerInfo*)CXFA_FWLAdapterTimerMgr::ms_timerArray.GetAt(i);
57 if (pTemp->uIDEvent == idEvent) {
58 pInfo = pTemp;
59 break; 44 break;
60 } 45 }
61 } 46 }
62 if (pInfo) {
63 pInfo->pTimer->Run((FWL_HTIMER)pInfo);
64 }
65 } 47 }
OLDNEW
« no previous file with comments | « fpdfsdk/include/fpdfxfa/fpdfxfa_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698