Dan Sinclair | c085835 | 2017-10-30 17:49:52 +0000 | [diff] [blame] | 1 | // Copyright 2017 PDFium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
Dan Sinclair | e0345a4 | 2017-10-30 20:20:42 +0000 | [diff] [blame] | 7 | #ifndef FXJS_GLOBAL_TIMER_H_ |
| 8 | #define FXJS_GLOBAL_TIMER_H_ |
Dan Sinclair | c085835 | 2017-10-30 17:49:52 +0000 | [diff] [blame] | 9 | |
Lei Zhang | 4c1ced5 | 2018-10-18 21:58:21 +0000 | [diff] [blame] | 10 | #include "fpdfsdk/cpdfsdk_formfillenvironment.h" |
| 11 | #include "fxjs/cjs_runtime.h" |
| 12 | |
| 13 | class CJS_App; |
Dan Sinclair | c085835 | 2017-10-30 17:49:52 +0000 | [diff] [blame] | 14 | |
| 15 | class GlobalTimer { |
| 16 | public: |
Lei Zhang | de72ac4 | 2019-01-10 19:40:20 +0000 | [diff] [blame] | 17 | enum class Type : bool { |
| 18 | kRepeating = false, |
| 19 | kOneShot = true, |
| 20 | }; |
| 21 | |
Dan Sinclair | f743552 | 2018-02-05 22:27:22 +0000 | [diff] [blame] | 22 | GlobalTimer(CJS_App* pObj, |
Dan Sinclair | c085835 | 2017-10-30 17:49:52 +0000 | [diff] [blame] | 23 | CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 24 | CJS_Runtime* pRuntime, |
Lei Zhang | de72ac4 | 2019-01-10 19:40:20 +0000 | [diff] [blame] | 25 | Type nType, |
Dan Sinclair | c085835 | 2017-10-30 17:49:52 +0000 | [diff] [blame] | 26 | const WideString& script, |
| 27 | uint32_t dwElapse, |
| 28 | uint32_t dwTimeOut); |
| 29 | ~GlobalTimer(); |
| 30 | |
Lei Zhang | 5b166c0 | 2019-01-10 19:31:19 +0000 | [diff] [blame] | 31 | static void Trigger(int32_t nTimerID); |
| 32 | static void Cancel(int32_t nTimerID); |
Dan Sinclair | c085835 | 2017-10-30 17:49:52 +0000 | [diff] [blame] | 33 | |
Lei Zhang | de72ac4 | 2019-01-10 19:40:20 +0000 | [diff] [blame] | 34 | bool IsOneShot() const { return m_nType == Type::kOneShot; } |
Dan Sinclair | c085835 | 2017-10-30 17:49:52 +0000 | [diff] [blame] | 35 | uint32_t GetTimeOut() const { return m_dwTimeOut; } |
Lei Zhang | 5b166c0 | 2019-01-10 19:31:19 +0000 | [diff] [blame] | 36 | int32_t GetTimerID() const { return m_nTimerID; } |
Dan Sinclair | c085835 | 2017-10-30 17:49:52 +0000 | [diff] [blame] | 37 | CJS_Runtime* GetRuntime() const { return m_pRuntime.Get(); } |
| 38 | WideString GetJScript() const { return m_swJScript; } |
| 39 | |
| 40 | private: |
Lei Zhang | cb13a08 | 2019-01-10 19:34:49 +0000 | [diff] [blame] | 41 | bool HasValidID() const; |
| 42 | |
Lei Zhang | 5b166c0 | 2019-01-10 19:31:19 +0000 | [diff] [blame] | 43 | const int32_t m_nTimerID; |
Dan Sinclair | f743552 | 2018-02-05 22:27:22 +0000 | [diff] [blame] | 44 | CJS_App* const m_pEmbedApp; |
Lei Zhang | e3f18b2 | 2019-01-09 22:10:25 +0000 | [diff] [blame] | 45 | bool m_bProcessing = false; |
Dan Sinclair | c085835 | 2017-10-30 17:49:52 +0000 | [diff] [blame] | 46 | |
| 47 | // data |
Lei Zhang | de72ac4 | 2019-01-10 19:40:20 +0000 | [diff] [blame] | 48 | const Type m_nType; |
Dan Sinclair | c085835 | 2017-10-30 17:49:52 +0000 | [diff] [blame] | 49 | const uint32_t m_dwTimeOut; |
| 50 | const WideString m_swJScript; |
| 51 | CJS_Runtime::ObservedPtr m_pRuntime; |
| 52 | CPDFSDK_FormFillEnvironment::ObservedPtr m_pFormFillEnv; |
| 53 | }; |
| 54 | |
Dan Sinclair | e0345a4 | 2017-10-30 20:20:42 +0000 | [diff] [blame] | 55 | #endif // FXJS_GLOBAL_TIMER_H_ |