update_engine: Add override when possible.

Google Style Guide requires to include the "override" keyword
when overriding a method on a derived class, so the compiler will
catch errors if the method is not overriding a member of the base
class.

This patch introduces the "override" keyword when possible.

BUG=None
TEST=FEATURES=test emerge-link update_engine

Change-Id: Ie83d115c5730f3b35b3d95859a54bc1a48e0be7b
Reviewed-on: https://chromium-review.googlesource.com/228928
Tested-by: Alex Deymo <deymo@chromium.org>
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
diff --git a/update_manager/chromeos_policy.h b/update_manager/chromeos_policy.h
index 6f6fbb2..e400cdc 100644
--- a/update_manager/chromeos_policy.h
+++ b/update_manager/chromeos_policy.h
@@ -40,7 +40,7 @@
 class ChromeOSPolicy : public Policy {
  public:
   ChromeOSPolicy() {}
-  virtual ~ChromeOSPolicy() {}
+  ~ChromeOSPolicy() override {}
 
   // Policy overrides.
   EvalStatus UpdateCheckAllowed(
diff --git a/update_manager/chromeos_policy_unittest.cc b/update_manager/chromeos_policy_unittest.cc
index 77adfbe..34d8150 100644
--- a/update_manager/chromeos_policy_unittest.cc
+++ b/update_manager/chromeos_policy_unittest.cc
@@ -30,7 +30,7 @@
 
 class UmChromeOSPolicyTest : public ::testing::Test {
  protected:
-  virtual void SetUp() {
+  void SetUp() override {
     SetUpDefaultClock();
     eval_ctx_ = new EvaluationContext(&fake_clock_, TimeDelta::FromSeconds(5));
     SetUpDefaultState();
diff --git a/update_manager/default_policy.h b/update_manager/default_policy.h
index dccbc87..294afea 100644
--- a/update_manager/default_policy.h
+++ b/update_manager/default_policy.h
@@ -50,7 +50,7 @@
  public:
   explicit DefaultPolicy(chromeos_update_engine::ClockInterface* clock);
   DefaultPolicy() : DefaultPolicy(nullptr) {}
-  virtual ~DefaultPolicy() {}
+  ~DefaultPolicy() override {}
 
   // Policy overrides.
   EvalStatus UpdateCheckAllowed(
diff --git a/update_manager/device_policy_provider.h b/update_manager/device_policy_provider.h
index b0b9d36..1259610 100644
--- a/update_manager/device_policy_provider.h
+++ b/update_manager/device_policy_provider.h
@@ -20,7 +20,7 @@
 // Provides access to the current DevicePolicy.
 class DevicePolicyProvider : public Provider {
  public:
-  virtual ~DevicePolicyProvider() {}
+  ~DevicePolicyProvider() override {}
 
   // Variable stating whether the DevicePolicy was loaded.
   virtual Variable<bool>* var_device_policy_is_loaded() = 0;
diff --git a/update_manager/evaluation_context.h b/update_manager/evaluation_context.h
index e7fba00..ecb37e0 100644
--- a/update_manager/evaluation_context.h
+++ b/update_manager/evaluation_context.h
@@ -119,7 +119,7 @@
   friend class UmEvaluationContextTest;
 
   // BaseVariable::ObserverInterface override.
-  void ValueChanged(BaseVariable* var);
+  void ValueChanged(BaseVariable* var) override;
 
   // Called from the main loop when a scheduled timeout has passed.
   void OnTimeout();
diff --git a/update_manager/evaluation_context_unittest.cc b/update_manager/evaluation_context_unittest.cc
index c5cc883..b945301 100644
--- a/update_manager/evaluation_context_unittest.cc
+++ b/update_manager/evaluation_context_unittest.cc
@@ -71,7 +71,7 @@
 
 class UmEvaluationContextTest : public ::testing::Test {
  protected:
-  virtual void SetUp() {
+  void SetUp() override {
     // Apr 22, 2009 19:25:00 UTC (this is a random reference point).
     fake_clock_.SetMonotonicTime(Time::FromTimeT(1240428300));
     // Mar 2, 2006 1:23:45 UTC.
@@ -81,7 +81,7 @@
         unique_ptr<base::Callback<void(EvaluationContext*)>>(nullptr));
   }
 
-  virtual void TearDown() {
+  void TearDown() override {
     // Ensure that the evaluation context did not leak and is actually being
     // destroyed.
     if (eval_ctx_) {
diff --git a/update_manager/fake_state.h b/update_manager/fake_state.h
index 9c1ff01..b803890 100644
--- a/update_manager/fake_state.h
+++ b/update_manager/fake_state.h
@@ -31,7 +31,7 @@
   // Creates and initializes the FakeState using fake providers.
   FakeState() {}
 
-  virtual ~FakeState() {}
+  ~FakeState() override {}
 
   // Downcasted getters to access the fake instances during testing.
   FakeConfigProvider* config_provider() override {
diff --git a/update_manager/fake_variable.h b/update_manager/fake_variable.h
index 9459fac..5b9facc 100644
--- a/update_manager/fake_variable.h
+++ b/update_manager/fake_variable.h
@@ -21,7 +21,7 @@
       : Variable<T>(name, mode) {}
   FakeVariable(const std::string& name, base::TimeDelta poll_interval)
       : Variable<T>(name, poll_interval) {}
-  virtual ~FakeVariable() {}
+  ~FakeVariable() override {}
 
   // Sets the next value of this variable to the passed |p_value| pointer. Once
   // returned by GetValue(), the pointer is released and has to be set again.
diff --git a/update_manager/generic_variables.h b/update_manager/generic_variables.h
index ad9f0c1..b1b059f 100644
--- a/update_manager/generic_variables.h
+++ b/update_manager/generic_variables.h
@@ -69,8 +69,8 @@
   FRIEND_TEST(UmPollCopyVariableTest, UseCopyConstructorTest);
 
   // Variable override.
-  virtual inline const T* GetValue(base::TimeDelta /* timeout */,
-                                   std::string* errmsg) {
+  inline const T* GetValue(base::TimeDelta /* timeout */,
+                           std::string* errmsg) override {
     if (is_set_p_ && !(*is_set_p_)) {
       if (errmsg) {
         if (errmsg_.empty())
@@ -108,8 +108,8 @@
 
  protected:
   // Variable override.
-  virtual const T* GetValue(base::TimeDelta /* timeout */,
-                            std::string* /* errmsg */) {
+  const T* GetValue(base::TimeDelta /* timeout */,
+                    std::string* /* errmsg */) override {
     return new T(obj_);
   }
 
@@ -132,8 +132,8 @@
 
  protected:
   // Variable override.
-  virtual const T* GetValue(base::TimeDelta /* timeout */,
-                            std::string* /* errmsg */) {
+  const T* GetValue(base::TimeDelta /* timeout */,
+                    std::string* /* errmsg */) override {
     if (func_.is_null())
       return nullptr;
     return new T(func_.Run());
@@ -183,8 +183,8 @@
 
  protected:
   // Variable override.
-  virtual const T* GetValue(base::TimeDelta /* timeout */,
-                            std::string* errmsg) {
+  const T* GetValue(base::TimeDelta /* timeout */,
+                    std::string* errmsg) override {
     if (!has_value_) {
       if (errmsg)
         *errmsg = "No value set for " + this->GetName();
diff --git a/update_manager/generic_variables_unittest.cc b/update_manager/generic_variables_unittest.cc
index 7de6725..65f7f51 100644
--- a/update_manager/generic_variables_unittest.cc
+++ b/update_manager/generic_variables_unittest.cc
@@ -133,7 +133,7 @@
 
 class UmAsyncCopyVariableTest : public ::testing::Test {
  public:
-  void TearDown() {
+  void TearDown() override {
     // No remaining event on the main loop.
     EXPECT_EQ(0, RunGMainLoopMaxIterations(1));
   }
diff --git a/update_manager/mock_policy.h b/update_manager/mock_policy.h
index aff74f5..24a6ee8 100644
--- a/update_manager/mock_policy.h
+++ b/update_manager/mock_policy.h
@@ -42,7 +42,7 @@
   }
 
   MockPolicy() : MockPolicy(nullptr) {}
-  virtual ~MockPolicy() {}
+  ~MockPolicy() override {}
 
   // Policy overrides.
   MOCK_CONST_METHOD4(UpdateCheckAllowed,
diff --git a/update_manager/random_provider.h b/update_manager/random_provider.h
index fef5c35..7c22863 100644
--- a/update_manager/random_provider.h
+++ b/update_manager/random_provider.h
@@ -13,7 +13,7 @@
 // Provider of random values.
 class RandomProvider : public Provider {
  public:
-  virtual ~RandomProvider() {}
+  ~RandomProvider() override {}
 
   // Return a random number every time it is requested. Note that values
   // returned by the variables are cached by the EvaluationContext, so the
diff --git a/update_manager/real_config_provider_unittest.cc b/update_manager/real_config_provider_unittest.cc
index 09f9fc0..f6ddb7c 100644
--- a/update_manager/real_config_provider_unittest.cc
+++ b/update_manager/real_config_provider_unittest.cc
@@ -24,7 +24,7 @@
 
 class UmRealConfigProviderTest : public ::testing::Test {
  protected:
-  virtual void SetUp() {
+  void SetUp() override {
     ASSERT_TRUE(root_dir_.CreateUniqueTempDir());
     provider_.reset(new RealConfigProvider(&fake_hardware_));
     provider_->SetRootPrefix(root_dir_.path().value());
diff --git a/update_manager/real_device_policy_provider_unittest.cc b/update_manager/real_device_policy_provider_unittest.cc
index 0ed2615..a0a3333 100644
--- a/update_manager/real_device_policy_provider_unittest.cc
+++ b/update_manager/real_device_policy_provider_unittest.cc
@@ -29,14 +29,14 @@
 
 class UmRealDevicePolicyProviderTest : public ::testing::Test {
  protected:
-  virtual void SetUp() {
+  void SetUp() override {
     provider_.reset(new RealDevicePolicyProvider(&mock_policy_provider_));
     // By default, we have a device policy loaded. Tests can call
     // SetUpNonExistentDevicePolicy() to override this.
     SetUpExistentDevicePolicy();
   }
 
-  virtual void TearDown() {
+  void TearDown() override {
     // Check for leaked callbacks on the main loop.
     EXPECT_EQ(0, RunGMainLoopMaxIterations(100));
   }
diff --git a/update_manager/real_random_provider.cc b/update_manager/real_random_provider.cc
index 47cb31d..add26e5 100644
--- a/update_manager/real_random_provider.cc
+++ b/update_manager/real_random_provider.cc
@@ -34,7 +34,7 @@
   // policy request.
   RandomSeedVariable(const string& name, FILE* fp)
       : Variable<uint64_t>(name, kVariableModeConst), fp_(fp) {}
-  virtual ~RandomSeedVariable() {}
+  ~RandomSeedVariable() override {}
 
  protected:
   virtual const uint64_t* GetValue(base::TimeDelta /* timeout */,
diff --git a/update_manager/real_random_provider_unittest.cc b/update_manager/real_random_provider_unittest.cc
index 0deba4c..899ef6f 100644
--- a/update_manager/real_random_provider_unittest.cc
+++ b/update_manager/real_random_provider_unittest.cc
@@ -16,7 +16,7 @@
 
 class UmRealRandomProviderTest : public ::testing::Test {
  protected:
-  virtual void SetUp() {
+  void SetUp() override {
     // The provider initializes correctly.
     provider_.reset(new RealRandomProvider());
     ASSERT_NE(nullptr, provider_.get());
diff --git a/update_manager/real_shill_provider.h b/update_manager/real_shill_provider.h
index 716a7dd..1cceadf 100644
--- a/update_manager/real_shill_provider.h
+++ b/update_manager/real_shill_provider.h
@@ -29,7 +29,7 @@
   RealShillProvider(DBusWrapperInterface* dbus, ClockInterface* clock)
       : dbus_(dbus), clock_(clock) {}
 
-  virtual ~RealShillProvider();
+  ~RealShillProvider() override;
 
   // Initializes the provider and returns whether it succeeded.
   bool Init();
diff --git a/update_manager/real_shill_provider_unittest.cc b/update_manager/real_shill_provider_unittest.cc
index 641a5c3..bca45e2 100644
--- a/update_manager/real_shill_provider_unittest.cc
+++ b/update_manager/real_shill_provider_unittest.cc
@@ -63,14 +63,14 @@
 
 class UmRealShillProviderTest : public ::testing::Test {
  protected:
-  virtual void SetUp() {
+  void SetUp() override {
     // By default, initialize the provider so that it gets an initial connection
     // status from shill. This simulates the common case where shill is
     // available and responding during RealShillProvider initialization.
     Init(true);
   }
 
-  virtual void TearDown() {
+  void TearDown() override {
     Shutdown();
   }
 
diff --git a/update_manager/real_state.h b/update_manager/real_state.h
index 824656f..ac70648 100644
--- a/update_manager/real_state.h
+++ b/update_manager/real_state.h
@@ -14,7 +14,7 @@
 // State concrete implementation.
 class RealState : public State {
  public:
-  virtual ~RealState() {}
+  ~RealState() override {}
 
   RealState(ConfigProvider* config_provider,
             DevicePolicyProvider* device_policy_provider,
diff --git a/update_manager/real_system_provider_unittest.cc b/update_manager/real_system_provider_unittest.cc
index e370274..41222d9 100644
--- a/update_manager/real_system_provider_unittest.cc
+++ b/update_manager/real_system_provider_unittest.cc
@@ -18,7 +18,7 @@
 
 class UmRealSystemProviderTest : public ::testing::Test {
  protected:
-  virtual void SetUp() {
+  void SetUp() override {
     provider_.reset(new RealSystemProvider(&fake_hardware_));
     EXPECT_TRUE(provider_->Init());
   }
diff --git a/update_manager/real_time_provider_unittest.cc b/update_manager/real_time_provider_unittest.cc
index 7e27a4e..90bd3c1 100644
--- a/update_manager/real_time_provider_unittest.cc
+++ b/update_manager/real_time_provider_unittest.cc
@@ -21,7 +21,7 @@
 
 class UmRealTimeProviderTest : public ::testing::Test {
  protected:
-  virtual void SetUp() {
+  void SetUp() override {
     // The provider initializes correctly.
     provider_.reset(new RealTimeProvider(&fake_clock_));
     ASSERT_NE(nullptr, provider_.get());
diff --git a/update_manager/real_updater_provider_unittest.cc b/update_manager/real_updater_provider_unittest.cc
index e253d39..f1511dd 100644
--- a/update_manager/real_updater_provider_unittest.cc
+++ b/update_manager/real_updater_provider_unittest.cc
@@ -62,7 +62,7 @@
 
 class UmRealUpdaterProviderTest : public ::testing::Test {
  protected:
-  virtual void SetUp() {
+  void SetUp() override {
     fake_clock_ = fake_sys_state_.fake_clock();
     provider_.reset(new RealUpdaterProvider(&fake_sys_state_));
     ASSERT_NE(nullptr, provider_.get());
diff --git a/update_manager/shill_provider.h b/update_manager/shill_provider.h
index b7e47b6..89d3b97 100644
--- a/update_manager/shill_provider.h
+++ b/update_manager/shill_provider.h
@@ -31,7 +31,7 @@
 // Provider for networking related information.
 class ShillProvider : public Provider {
  public:
-  virtual ~ShillProvider() {}
+  ~ShillProvider() override {}
 
   // A variable returning whether we currently have network connectivity.
   virtual Variable<bool>* var_is_connected() = 0;
diff --git a/update_manager/system_provider.h b/update_manager/system_provider.h
index 8688b9c..ea5f79f 100644
--- a/update_manager/system_provider.h
+++ b/update_manager/system_provider.h
@@ -14,7 +14,7 @@
 // reported by crossystem, the kernel boot command line and the partition table.
 class SystemProvider : public Provider {
  public:
-  virtual ~SystemProvider() {}
+  ~SystemProvider() override {}
 
   // Returns true if the boot mode is normal or if it's unable to
   // determine the boot mode. Returns false if the boot mode is
diff --git a/update_manager/time_provider.h b/update_manager/time_provider.h
index 46fe65a..a30fdb3 100644
--- a/update_manager/time_provider.h
+++ b/update_manager/time_provider.h
@@ -15,7 +15,7 @@
 // Provider for time related information.
 class TimeProvider : public Provider {
  public:
-  virtual ~TimeProvider() {}
+  ~TimeProvider() override {}
 
   // Returns the current date. The time of day component will be zero.
   virtual Variable<base::Time>* var_curr_date() = 0;
diff --git a/update_manager/updater_provider.h b/update_manager/updater_provider.h
index 535b3e7..1ff1085 100644
--- a/update_manager/updater_provider.h
+++ b/update_manager/updater_provider.h
@@ -35,7 +35,7 @@
 // Provider for Chrome OS update related information.
 class UpdaterProvider : public Provider {
  public:
-  virtual ~UpdaterProvider() {}
+  ~UpdaterProvider() override {}
 
   // A variable returning the timestamp when the update engine was started in
   // wallclock time.
diff --git a/update_manager/variable.h b/update_manager/variable.h
index ad2eefa..c47f488 100644
--- a/update_manager/variable.h
+++ b/update_manager/variable.h
@@ -166,7 +166,7 @@
 template<typename T>
 class Variable : public BaseVariable {
  public:
-  virtual ~Variable() {}
+  ~Variable() override {}
 
  protected:
   // Only allow to get values through the EvaluationContext class and not
diff --git a/update_manager/variable_unittest.cc b/update_manager/variable_unittest.cc
index 7944c38..912d55c 100644
--- a/update_manager/variable_unittest.cc
+++ b/update_manager/variable_unittest.cc
@@ -25,7 +25,7 @@
       : Variable<T>(name, mode) {}
   DefaultVariable(const string& name, const TimeDelta& poll_interval)
       : Variable<T>(name, poll_interval) {}
-  virtual ~DefaultVariable() {}
+  ~DefaultVariable() override {}
 
  protected:
   virtual const T* GetValue(TimeDelta /* timeout */,