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

Side by Side Diff: fpdfsdk/javascript/JS_Object.h

Issue 2221513002: Remove another potential stale CJS_Timer usage (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: rework, weak refs, single deletion path Created 4 years, 4 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 | « no previous file | fpdfsdk/javascript/JS_Object.cpp » ('j') | fpdfsdk/javascript/JS_Object.cpp » ('J')
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 #ifndef FPDFSDK_JAVASCRIPT_JS_OBJECT_H_ 7 #ifndef FPDFSDK_JAVASCRIPT_JS_OBJECT_H_
8 #define FPDFSDK_JAVASCRIPT_JS_OBJECT_H_ 8 #define FPDFSDK_JAVASCRIPT_JS_OBJECT_H_
9 9
10 #include <map> 10 #include <map>
11 #include <memory> 11 #include <memory>
12 12
13 #include "fpdfsdk/include/fsdk_define.h" 13 #include "fpdfsdk/include/fsdk_define.h"
14 #include "fpdfsdk/javascript/cjs_runtime.h" 14 #include "fpdfsdk/javascript/cjs_runtime.h"
15 #include "fxjs/include/fxjs_v8.h" 15 #include "fxjs/include/fxjs_v8.h"
16 16
17 class CJS_Context; 17 class CJS_Context;
18 class CJS_Object; 18 class CJS_Object;
19 class CJS_Timer; 19 class CJS_Timer;
20 class CPDFDoc_Environment; 20 class CPDFDoc_Environment;
21
21 class CJS_EmbedObj { 22 class CJS_EmbedObj {
22 public: 23 public:
23 explicit CJS_EmbedObj(CJS_Object* pJSObject); 24 explicit CJS_EmbedObj(CJS_Object* pJSObject);
24 virtual ~CJS_EmbedObj(); 25 virtual ~CJS_EmbedObj();
25 26
26 virtual void TimerProc(CJS_Timer* pTimer) {} 27 virtual void TimerProc(CJS_Timer* pTimer) {}
28 virtual void CancelProc(CJS_Timer* pTimer) {}
27 29
28 CJS_Object* GetJSObject() const { return m_pJSObject; } 30 CJS_Object* GetJSObject() const { return m_pJSObject; }
29 31
30 int MsgBox(CPDFDoc_Environment* pApp, 32 int MsgBox(CPDFDoc_Environment* pApp,
31 const FX_WCHAR* swMsg, 33 const FX_WCHAR* swMsg,
32 const FX_WCHAR* swTitle, 34 const FX_WCHAR* swTitle,
33 FX_UINT nType, 35 FX_UINT nType,
34 FX_UINT nIcon); 36 FX_UINT nIcon);
35 void Alert(CJS_Context* pContext, const FX_WCHAR* swMsg); 37 void Alert(CJS_Context* pContext, const FX_WCHAR* swMsg);
36 38
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 public: 71 public:
70 CJS_Timer(CJS_EmbedObj* pObj, 72 CJS_Timer(CJS_EmbedObj* pObj,
71 CPDFDoc_Environment* pApp, 73 CPDFDoc_Environment* pApp,
72 CJS_Runtime* pRuntime, 74 CJS_Runtime* pRuntime,
73 int nType, 75 int nType,
74 const CFX_WideString& script, 76 const CFX_WideString& script,
75 uint32_t dwElapse, 77 uint32_t dwElapse,
76 uint32_t dwTimeOut); 78 uint32_t dwTimeOut);
77 ~CJS_Timer() override; 79 ~CJS_Timer() override;
78 80
79 void KillJSTimer(); 81 static void Trigger(int nTimerID);
82 static void Cancel(int nTimerID);
80 83
81 int GetType() const { return m_nType; } 84 bool IsOneTime() const { return m_nType == 1; }
Lei Zhang 2016/08/05 22:29:55 Maybe IsOneShot() ?
Tom Sepez 2016/08/05 23:11:42 Done.
82 uint32_t GetTimeOut() const { return m_dwTimeOut; } 85 uint32_t GetTimeOut() const { return m_dwTimeOut; }
86 int GetTimerID() const { return m_nTimerID; }
83 CJS_Runtime* GetRuntime() const { return m_bValid ? m_pRuntime : nullptr; } 87 CJS_Runtime* GetRuntime() const { return m_bValid ? m_pRuntime : nullptr; }
84 CFX_WideString GetJScript() const { return m_swJScript; } 88 CFX_WideString GetJScript() const { return m_swJScript; }
85 89
86 static void TimerProc(int idEvent);
87
88 private: 90 private:
89 using TimerMap = std::map<FX_UINT, CJS_Timer*>; 91 using TimerMap = std::map<FX_UINT, CJS_Timer*>;
90 static TimerMap* GetGlobalTimerMap(); 92 static TimerMap* GetGlobalTimerMap();
91 93
92 // CJS_Runtime::Observer 94 // CJS_Runtime::Observer
93 void OnDestroyed() override; 95 void OnDestroyed() override;
94 96
95 uint32_t m_nTimerID; 97 uint32_t m_nTimerID;
96 CJS_EmbedObj* const m_pEmbedObj; 98 CJS_EmbedObj* const m_pEmbedObj;
97 bool m_bProcessing; 99 bool m_bProcessing;
98 bool m_bValid; 100 bool m_bValid;
99 101
100 // data 102 // data
101 const int m_nType; // 0:Interval; 1:TimeOut 103 const int m_nType; // 0:Interval; 1:TimeOut
102 const uint32_t m_dwTimeOut; 104 const uint32_t m_dwTimeOut;
103 const CFX_WideString m_swJScript; 105 const CFX_WideString m_swJScript;
104 CJS_Runtime* const m_pRuntime; 106 CJS_Runtime* const m_pRuntime;
105 CPDFDoc_Environment* const m_pApp; 107 CPDFDoc_Environment* const m_pApp;
106 }; 108 };
107 109
108 #endif // FPDFSDK_JAVASCRIPT_JS_OBJECT_H_ 110 #endif // FPDFSDK_JAVASCRIPT_JS_OBJECT_H_
OLDNEW
« no previous file with comments | « no previous file | fpdfsdk/javascript/JS_Object.cpp » ('j') | fpdfsdk/javascript/JS_Object.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698