Add CFX_SystemHandler::kInvalidTimerID.

Use it in both CPWL_Timer and GlobalTimer.

Change-Id: I67817603b25c1ba3f9da7280295af17aaa73d3d8
Reviewed-on: https://pdfium-review.googlesource.com/c/48032
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/fpdfsdk/cfx_systemhandler.h b/fpdfsdk/cfx_systemhandler.h
index 719ec34..af55187 100644
--- a/fpdfsdk/cfx_systemhandler.h
+++ b/fpdfsdk/cfx_systemhandler.h
@@ -22,6 +22,8 @@
 
 class CFX_SystemHandler {
  public:
+  static constexpr int32_t kInvalidTimerID = 0;
+
   explicit CFX_SystemHandler(CPDFSDK_FormFillEnvironment* pFormFillEnv);
   ~CFX_SystemHandler();
 
diff --git a/fpdfsdk/pwl/cpwl_timer.cpp b/fpdfsdk/pwl/cpwl_timer.cpp
index 902a144..b5436d4 100644
--- a/fpdfsdk/pwl/cpwl_timer.cpp
+++ b/fpdfsdk/pwl/cpwl_timer.cpp
@@ -8,7 +8,6 @@
 
 #include <map>
 
-#include "fpdfsdk/cfx_systemhandler.h"
 #include "fpdfsdk/pwl/cpwl_timer_handler.h"
 
 namespace {
@@ -47,7 +46,7 @@
 
   m_pSystemHandler->KillTimer(m_nTimerID);
   GetPWLTimeMap().erase(m_nTimerID);
-  m_nTimerID = kInvalidTimerID;
+  m_nTimerID = CFX_SystemHandler::kInvalidTimerID;
 }
 
 // static
diff --git a/fpdfsdk/pwl/cpwl_timer.h b/fpdfsdk/pwl/cpwl_timer.h
index 1e93333..79259fe 100644
--- a/fpdfsdk/pwl/cpwl_timer.h
+++ b/fpdfsdk/pwl/cpwl_timer.h
@@ -8,8 +8,8 @@
 #define FPDFSDK_PWL_CPWL_TIMER_H_
 
 #include "core/fxcrt/unowned_ptr.h"
+#include "fpdfsdk/cfx_systemhandler.h"
 
-class CFX_SystemHandler;
 class CPWL_TimerHandler;
 
 class CPWL_Timer {
@@ -23,11 +23,11 @@
   void KillPWLTimer();
 
  private:
-  static constexpr int32_t kInvalidTimerID = 0;
+  bool HasValidID() const {
+    return m_nTimerID != CFX_SystemHandler::kInvalidTimerID;
+  }
 
-  bool HasValidID() const { return m_nTimerID != kInvalidTimerID; }
-
-  int32_t m_nTimerID = kInvalidTimerID;
+  int32_t m_nTimerID = CFX_SystemHandler::kInvalidTimerID;
   UnownedPtr<CPWL_TimerHandler> const m_pAttached;
   UnownedPtr<CFX_SystemHandler> const m_pSystemHandler;
 };
diff --git a/fxjs/global_timer.cpp b/fxjs/global_timer.cpp
index a0fac96..16372cf 100644
--- a/fxjs/global_timer.cpp
+++ b/fxjs/global_timer.cpp
@@ -6,6 +6,7 @@
 
 #include "fxjs/global_timer.h"
 
+#include "fpdfsdk/cfx_systemhandler.h"
 #include "fxjs/cjs_app.h"
 
 GlobalTimer::GlobalTimer(CJS_App* pObj,
@@ -22,12 +23,12 @@
       m_swJScript(script),
       m_pRuntime(pRuntime),
       m_pFormFillEnv(pFormFillEnv) {
-  if (m_nTimerID)
+  if (HasValidID())
     (*GetGlobalTimerMap())[m_nTimerID] = this;
 }
 
 GlobalTimer::~GlobalTimer() {
-  if (!m_nTimerID)
+  if (!HasValidID())
     return;
 
   if (GetRuntime())
@@ -77,3 +78,7 @@
   static auto* s_TimerMap = new TimerMap;
   return s_TimerMap;
 }
+
+bool GlobalTimer::HasValidID() const {
+  return m_nTimerID != CFX_SystemHandler::kInvalidTimerID;
+}
diff --git a/fxjs/global_timer.h b/fxjs/global_timer.h
index f8971f9..463ed19 100644
--- a/fxjs/global_timer.h
+++ b/fxjs/global_timer.h
@@ -38,6 +38,8 @@
   using TimerMap = std::map<int32_t, GlobalTimer*>;
   static TimerMap* GetGlobalTimerMap();
 
+  bool HasValidID() const;
+
   const int32_t m_nTimerID;
   CJS_App* const m_pEmbedApp;
   bool m_bProcessing = false;