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 7 #ifndef FXJS_GLOBAL_TIMER_H_ 8 #define FXJS_GLOBAL_TIMER_H_ 9 10 #include "fxjs/cjs_runtime.h" 11 12 class CJS_App; 13 14 class GlobalTimer { 15 public: 16 enum class Type : bool { 17 kRepeating = false, 18 kOneShot = true, 19 }; 20 21 GlobalTimer(CJS_App* pObj, 22 CJS_Runtime* pRuntime, 23 Type nType, 24 const WideString& script, 25 uint32_t dwElapse, 26 uint32_t dwTimeOut); 27 ~GlobalTimer(); 28 29 static void Trigger(int32_t nTimerID); 30 static void Cancel(int32_t nTimerID); 31 IsOneShot()32 bool IsOneShot() const { return m_nType == Type::kOneShot; } GetTimeOut()33 uint32_t GetTimeOut() const { return m_dwTimeOut; } GetTimerID()34 int32_t GetTimerID() const { return m_nTimerID; } GetRuntime()35 CJS_Runtime* GetRuntime() const { return m_pRuntime.Get(); } GetJScript()36 WideString GetJScript() const { return m_swJScript; } 37 38 private: 39 bool HasValidID() const; 40 41 const Type m_nType; 42 bool m_bProcessing = false; 43 const int32_t m_nTimerID; 44 const uint32_t m_dwTimeOut; 45 const WideString m_swJScript; 46 ObservedPtr<CJS_Runtime> m_pRuntime; 47 CJS_App* const m_pEmbedApp; 48 }; 49 50 #endif // FXJS_GLOBAL_TIMER_H_ 51