Clean up CPWL_Timer and CPWL_TimerHandler.

Change-Id: I89c7cbf8abfc88b7f801ffbf948edee8ea06434f
Reviewed-on: https://pdfium-review.googlesource.com/c/47070
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fpdfsdk/pwl/cpwl_timer.cpp b/fpdfsdk/pwl/cpwl_timer.cpp
index 34f81fc..44fc32c 100644
--- a/fpdfsdk/pwl/cpwl_timer.cpp
+++ b/fpdfsdk/pwl/cpwl_timer.cpp
@@ -23,7 +23,7 @@
 
 CPWL_Timer::CPWL_Timer(CPWL_TimerHandler* pAttached,
                        CFX_SystemHandler* pSystemHandler)
-    : m_nTimerID(0), m_pAttached(pAttached), m_pSystemHandler(pSystemHandler) {
+    : m_pAttached(pAttached), m_pSystemHandler(pSystemHandler) {
   ASSERT(m_pAttached);
   ASSERT(m_pSystemHandler);
 }
@@ -33,21 +33,20 @@
 }
 
 int32_t CPWL_Timer::SetPWLTimer(int32_t nElapse) {
-  if (m_nTimerID != 0)
-    KillPWLTimer();
-  m_nTimerID = m_pSystemHandler->SetTimer(nElapse, TimerProc);
+  KillPWLTimer();
 
+  m_nTimerID = m_pSystemHandler->SetTimer(nElapse, TimerProc);
   GetPWLTimeMap()[m_nTimerID] = this;
   return m_nTimerID;
 }
 
 void CPWL_Timer::KillPWLTimer() {
-  if (m_nTimerID == 0)
+  if (!HasValidID())
     return;
 
   m_pSystemHandler->KillTimer(m_nTimerID);
   GetPWLTimeMap().erase(m_nTimerID);
-  m_nTimerID = 0;
+  m_nTimerID = kInvalidTimerID;
 }
 
 // static
diff --git a/fpdfsdk/pwl/cpwl_timer.h b/fpdfsdk/pwl/cpwl_timer.h
index 6e082ab..1e93333 100644
--- a/fpdfsdk/pwl/cpwl_timer.h
+++ b/fpdfsdk/pwl/cpwl_timer.h
@@ -15,7 +15,7 @@
 class CPWL_Timer {
  public:
   CPWL_Timer(CPWL_TimerHandler* pAttached, CFX_SystemHandler* pSystemHandler);
-  virtual ~CPWL_Timer();
+  ~CPWL_Timer();
 
   static void TimerProc(int32_t idEvent);
 
@@ -23,9 +23,13 @@
   void KillPWLTimer();
 
  private:
-  int32_t m_nTimerID;
-  UnownedPtr<CPWL_TimerHandler> m_pAttached;
-  UnownedPtr<CFX_SystemHandler> m_pSystemHandler;
+  static constexpr int32_t kInvalidTimerID = 0;
+
+  bool HasValidID() const { return m_nTimerID != kInvalidTimerID; }
+
+  int32_t m_nTimerID = kInvalidTimerID;
+  UnownedPtr<CPWL_TimerHandler> const m_pAttached;
+  UnownedPtr<CFX_SystemHandler> const m_pSystemHandler;
 };
 
 #endif  // FPDFSDK_PWL_CPWL_TIMER_H_
diff --git a/fpdfsdk/pwl/cpwl_timer_handler.cpp b/fpdfsdk/pwl/cpwl_timer_handler.cpp
index 33af306..d5ebc25 100644
--- a/fpdfsdk/pwl/cpwl_timer_handler.cpp
+++ b/fpdfsdk/pwl/cpwl_timer_handler.cpp
@@ -9,9 +9,9 @@
 #include "fpdfsdk/pwl/cpwl_timer.h"
 #include "third_party/base/ptr_util.h"
 
-CPWL_TimerHandler::CPWL_TimerHandler() {}
+CPWL_TimerHandler::CPWL_TimerHandler() = default;
 
-CPWL_TimerHandler::~CPWL_TimerHandler() {}
+CPWL_TimerHandler::~CPWL_TimerHandler() = default;
 
 void CPWL_TimerHandler::BeginTimer(int32_t nElapse) {
   if (!m_pTimer)