blob: ec8806b9a113dbba8af1658990a93c2398ba6e66 [file] [log] [blame]
Dan Sinclairc0858352017-10-30 17:49:52 +00001// 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 Sinclaire0345a42017-10-30 20:20:42 +00007#ifndef FXJS_GLOBAL_TIMER_H_
8#define FXJS_GLOBAL_TIMER_H_
Dan Sinclairc0858352017-10-30 17:49:52 +00009
10#include <map>
11
Dan Sinclaire0345a42017-10-30 20:20:42 +000012#include "fxjs/cjs_app.h"
Dan Sinclairc0858352017-10-30 17:49:52 +000013
14class GlobalTimer {
15 public:
16 GlobalTimer(app* pObj,
17 CPDFSDK_FormFillEnvironment* pFormFillEnv,
18 CJS_Runtime* pRuntime,
19 int nType,
20 const WideString& script,
21 uint32_t dwElapse,
22 uint32_t dwTimeOut);
23 ~GlobalTimer();
24
25 static void Trigger(int nTimerID);
26 static void Cancel(int nTimerID);
27
28 bool IsOneShot() const { return m_nType == 1; }
29 uint32_t GetTimeOut() const { return m_dwTimeOut; }
30 int GetTimerID() const { return m_nTimerID; }
31 CJS_Runtime* GetRuntime() const { return m_pRuntime.Get(); }
32 WideString GetJScript() const { return m_swJScript; }
33
34 private:
35 using TimerMap = std::map<uint32_t, GlobalTimer*>;
36 static TimerMap* GetGlobalTimerMap();
37
38 uint32_t m_nTimerID;
39 app* const m_pEmbedObj;
40 bool m_bProcessing;
41
42 // data
43 const int m_nType; // 0:Interval; 1:TimeOut
44 const uint32_t m_dwTimeOut;
45 const WideString m_swJScript;
46 CJS_Runtime::ObservedPtr m_pRuntime;
47 CPDFSDK_FormFillEnvironment::ObservedPtr m_pFormFillEnv;
48};
49
Dan Sinclaire0345a42017-10-30 20:20:42 +000050#endif // FXJS_GLOBAL_TIMER_H_