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