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 CORE_FXCRT_CFX_TIMER_H_ 8 #define CORE_FXCRT_CFX_TIMER_H_ 9 10 #include "core/fxcrt/timerhandler_iface.h" 11 #include "core/fxcrt/unowned_ptr.h" 12 13 class CFX_TimerHandler; 14 15 class CFX_Timer { 16 public: 17 class CallbackIface { 18 public: 19 virtual ~CallbackIface() = default; 20 virtual void OnTimerFired() = 0; 21 }; 22 23 CFX_Timer(TimerHandlerIface* pTimerHandler, 24 CallbackIface* pCallbackIface, 25 int32_t nInterval); 26 ~CFX_Timer(); 27 HasValidID()28 bool HasValidID() const { 29 return m_nTimerID != TimerHandlerIface::kInvalidTimerID; 30 } 31 32 private: 33 static void TimerProc(int32_t idEvent); 34 35 const int32_t m_nTimerID; 36 UnownedPtr<TimerHandlerIface> const m_pTimerHandler; 37 UnownedPtr<CallbackIface> const m_pCallbackIface; 38 }; 39 40 #endif // CORE_FXCRT_CFX_TIMER_H_ 41