Bug 1318004 - Use C++11's override and remove virtual where applicable. draft
authorSylvestre Ledru <sledru@mozilla.com>
Wed, 16 Nov 2016 17:08:26 +0100
changeset 439790 e5c5d857a0613d003ad8b42d624f943d0bfbcdd3
parent 439789 952a2eb313fa3ad6873030387ee8d0a074a095f5
child 537252 5bbd2e0cf3b14c7072706341686ea406794e08fb
push id36092
push usersledru@mozilla.com
push dateWed, 16 Nov 2016 16:14:46 +0000
bugs1318004
milestone53.0a1
Bug 1318004 - Use C++11's override and remove virtual where applicable. MozReview-Commit-ID: H9tAe0YN1tx
toolkit/components/osfile/NativeOSFileInternals.cpp
toolkit/components/telemetry/Telemetry.cpp
toolkit/components/telemetry/TelemetryScalar.cpp
toolkit/identity/IdentityCryptoService.cpp
toolkit/mozapps/update/updater/updater.cpp
--- a/toolkit/components/osfile/NativeOSFileInternals.cpp
+++ b/toolkit/components/osfile/NativeOSFileInternals.cpp
@@ -736,17 +736,17 @@ public:
                           const uint32_t aBytes,
                           nsMainThreadPtrHandle<nsINativeOSFileSuccessCallback>& aOnSuccess,
                           nsMainThreadPtrHandle<nsINativeOSFileErrorCallback>& aOnError)
     : AbstractReadEvent(aPath, aBytes,
                         aOnSuccess, aOnError)
     , mResult(new TypedArrayResult(TimeStamp::Now()))
   { }
 
-  ~DoReadToTypedArrayEvent() {
+  ~DoReadToTypedArrayEvent() override {
     // If AbstractReadEvent::Run() has bailed out, we may need to cleanup
     // mResult, which is main-thread only data
     if (!mResult) {
       return;
     }
     NS_ReleaseOnMainThread(mResult.forget());
   }
 
@@ -773,17 +773,17 @@ public:
                       const uint32_t aBytes,
                       nsMainThreadPtrHandle<nsINativeOSFileSuccessCallback>& aOnSuccess,
                       nsMainThreadPtrHandle<nsINativeOSFileErrorCallback>& aOnError)
     : AbstractReadEvent(aPath, aBytes, aOnSuccess, aOnError)
     , mEncoding(aEncoding)
     , mResult(new StringResult(TimeStamp::Now()))
   { }
 
-  ~DoReadToStringEvent() {
+  ~DoReadToStringEvent() override {
     // If AbstraactReadEvent::Run() has bailed out, we may need to cleanup
     // mResult, which is main-thread only data
     if (!mResult) {
       return;
     }
     NS_ReleaseOnMainThread(mResult.forget());
   }
 
--- a/toolkit/components/telemetry/Telemetry.cpp
+++ b/toolkit/components/telemetry/Telemetry.cpp
@@ -421,17 +421,17 @@ class TelemetryIOInterposeObserver : pub
 
 public:
   explicit TelemetryIOInterposeObserver(nsIFile* aXreDir);
 
   /**
    * An implementation of Observe that records statistics of all
    * file IO operations.
    */
-  void Observe(Observation& aOb);
+  void Observe(Observation& aOb) override;
 
   /**
    * Reflect recorded file IO statistics into Javascript
    */
   bool ReflectIntoJS(JSContext *cx, JS::Handle<JSObject*> rootObj);
 
   /**
    * Adds a path for inclusion in main thread I/O report.
--- a/toolkit/components/telemetry/TelemetryScalar.cpp
+++ b/toolkit/components/telemetry/TelemetryScalar.cpp
@@ -190,17 +190,17 @@ ScalarBase::HandleUnsupported() const
  * The implementation for the unsigned int scalar type.
  */
 class ScalarUnsigned : public ScalarBase
 {
 public:
   using ScalarBase::SetValue;
 
   ScalarUnsigned() : mStorage(0) {};
-  ~ScalarUnsigned() = default;;
+  ~ScalarUnsigned() override = default;;
 
   ScalarResult SetValue(nsIVariant* aValue) final;
   void SetValue(uint32_t aValue) final;
   ScalarResult AddValue(nsIVariant* aValue) final;
   void AddValue(uint32_t aValue) final;
   ScalarResult SetMaximum(nsIVariant* aValue) final;
   void SetMaximum(uint32_t aValue) final;
   nsresult GetValue(nsCOMPtr<nsIVariant>& aResult) const final;
@@ -330,17 +330,17 @@ ScalarUnsigned::CheckInput(nsIVariant* a
  * The implementation for the string scalar type.
  */
 class ScalarString : public ScalarBase
 {
 public:
   using ScalarBase::SetValue;
 
   ScalarString() : mStorage(EmptyString()) {};
-  ~ScalarString() = default;;
+  ~ScalarString() override = default;;
 
   ScalarResult SetValue(nsIVariant* aValue) final;
   ScalarResult SetValue(const nsAString& aValue) final;
   nsresult GetValue(nsCOMPtr<nsIVariant>& aResult) const final;
   size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const final;
 
 private:
   nsString mStorage;
@@ -411,17 +411,17 @@ ScalarString::SizeOfIncludingThis(mozill
  * The implementation for the boolean scalar type.
  */
 class ScalarBoolean : public ScalarBase
 {
 public:
   using ScalarBase::SetValue;
 
   ScalarBoolean() : mStorage(false) {};
-  ~ScalarBoolean() = default;;
+  ~ScalarBoolean() override = default;;
 
   ScalarResult SetValue(nsIVariant* aValue) final;
   void SetValue(bool aValue) final;
   nsresult GetValue(nsCOMPtr<nsIVariant>& aResult) const final;
   size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const final;
 
 private:
   bool mStorage;
--- a/toolkit/identity/IdentityCryptoService.cpp
+++ b/toolkit/identity/IdentityCryptoService.cpp
@@ -51,17 +51,17 @@ class KeyPair : public nsIIdentityKeyPai
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIIDENTITYKEYPAIR
 
   KeyPair(SECKEYPrivateKey* aPrivateKey, SECKEYPublicKey* aPublicKey);
 
 private:
-  ~KeyPair()
+  ~KeyPair() override
   {
     nsNSSShutDownPreventionLock locker;
     if (isAlreadyShutDown()) {
       return;
     }
     destructorSafeDestroyNSSReference();
     shutdown(ShutdownCalledFrom::Object);
   }
@@ -91,27 +91,27 @@ NS_IMPL_ISUPPORTS(KeyPair, nsIIdentityKe
 class KeyGenRunnable : public Runnable, public nsNSSShutDownObject
 {
 public:
   NS_DECL_NSIRUNNABLE
 
   KeyGenRunnable(KeyType keyType, nsIIdentityKeyGenCallback * aCallback);
 
 private:
-  ~KeyGenRunnable()
+  ~KeyGenRunnable() override
   {
     nsNSSShutDownPreventionLock locker;
     if (isAlreadyShutDown()) {
       return;
     }
     destructorSafeDestroyNSSReference();
     shutdown(ShutdownCalledFrom::Object);
   }
 
-  virtual void virtualDestroyNSSReference() override
+  void virtualDestroyNSSReference() override
   {
     destructorSafeDestroyNSSReference();
   }
 
   void destructorSafeDestroyNSSReference()
   {
   }
 
@@ -128,17 +128,17 @@ class SignRunnable : public Runnable, pu
 {
 public:
   NS_DECL_NSIRUNNABLE
 
   SignRunnable(const nsACString & textToSign, SECKEYPrivateKey * privateKey,
                nsIIdentitySignCallback * aCallback);
 
 private:
-  ~SignRunnable()
+  ~SignRunnable() override
   {
     nsNSSShutDownPreventionLock locker;
     if (isAlreadyShutDown()) {
       return;
     }
     destructorSafeDestroyNSSReference();
     shutdown(ShutdownCalledFrom::Object);
   }
--- a/toolkit/mozapps/update/updater/updater.cpp
+++ b/toolkit/mozapps/update/updater/updater.cpp
@@ -1110,20 +1110,20 @@ private:
   friend class ActionList;
 };
 
 class RemoveFile : public Action
 {
 public:
   RemoveFile() : mSkip(0) { }
 
-  int Parse(NS_tchar *line);
-  int Prepare();
-  int Execute();
-  void Finish(int status);
+  int Parse(NS_tchar *line) override;
+  int Prepare() override;
+  int Execute() override;
+  void Finish(int status) override;
 
 private:
   mozilla::UniquePtr<NS_tchar[]> mFile;
   mozilla::UniquePtr<NS_tchar[]> mRelPath;
   int mSkip;
 };
 
 int
@@ -1241,20 +1241,20 @@ RemoveFile::Finish(int status)
   }
 }
 
 class RemoveDir : public Action
 {
 public:
   RemoveDir() : mSkip(0) { }
 
-  virtual int Parse(NS_tchar *line);
-  virtual int Prepare(); // check that the source dir exists
-  virtual int Execute();
-  virtual void Finish(int status);
+  int Parse(NS_tchar *line) override;
+  int Prepare() override; // check that the source dir exists
+  int Execute() override;
+  void Finish(int status) override;
 
 private:
   mozilla::UniquePtr<NS_tchar[]> mDir;
   mozilla::UniquePtr<NS_tchar[]> mRelPath;
   int mSkip;
 };
 
 int
@@ -1358,20 +1358,20 @@ RemoveDir::Finish(int status)
   }
 }
 
 class AddFile : public Action
 {
 public:
   AddFile() : mAdded(false) { }
 
-  virtual int Parse(NS_tchar *line);
-  virtual int Prepare();
-  virtual int Execute();
-  virtual void Finish(int status);
+  int Parse(NS_tchar *line) override;
+  int Prepare() override;
+  int Execute() override;
+  void Finish(int status) override;
 
 private:
   mozilla::UniquePtr<NS_tchar[]> mFile;
   mozilla::UniquePtr<NS_tchar[]> mRelPath;
   bool mAdded;
 };
 
 int
@@ -1461,22 +1461,22 @@ AddFile::Finish(int status)
   }
 }
 
 class PatchFile : public Action
 {
 public:
   PatchFile() : mPatchFile(nullptr), mPatchIndex(-1), buf(nullptr) { }
 
-  virtual ~PatchFile();
-
-  virtual int Parse(NS_tchar *line);
-  virtual int Prepare(); // should check for patch file and for checksum here
-  virtual int Execute();
-  virtual void Finish(int status);
+  ~PatchFile() override;
+
+  int Parse(NS_tchar *line) override;
+  int Prepare() override; // should check for patch file and for checksum here
+  int Execute() override;
+  void Finish(int status) override;
 
 private:
   int LoadSourceFile(FILE* ofile);
 
   static int sPatchIndex;
 
   const NS_tchar *mPatchFile;
   mozilla::UniquePtr<NS_tchar[]> mFile;
@@ -1782,20 +1782,20 @@ PatchFile::Finish(int status)
   if (!sStagedUpdate) {
     backup_finish(mFile.get(), mFileRelPath.get(), status);
   }
 }
 
 class AddIfFile : public AddFile
 {
 public:
-  virtual int Parse(NS_tchar *line);
-  virtual int Prepare();
-  virtual int Execute();
-  virtual void Finish(int status);
+  int Parse(NS_tchar *line) override;
+  int Prepare() override;
+  int Execute() override;
+  void Finish(int status) override;
 
 protected:
   mozilla::UniquePtr<NS_tchar[]> mTestFile;
 };
 
 int
 AddIfFile::Parse(NS_tchar *line)
 {
@@ -1843,20 +1843,20 @@ AddIfFile::Finish(int status)
     return;
 
   AddFile::Finish(status);
 }
 
 class AddIfNotFile : public AddFile
 {
 public:
-  virtual int Parse(NS_tchar *line);
-  virtual int Prepare();
-  virtual int Execute();
-  virtual void Finish(int status);
+  int Parse(NS_tchar *line) override;
+  int Prepare() override;
+  int Execute() override;
+  void Finish(int status) override;
 
 protected:
   mozilla::UniquePtr<NS_tchar[]> mTestFile;
 };
 
 int
 AddIfNotFile::Parse(NS_tchar *line)
 {
@@ -1904,20 +1904,20 @@ AddIfNotFile::Finish(int status)
     return;
 
   AddFile::Finish(status);
 }
 
 class PatchIfFile : public PatchFile
 {
 public:
-  virtual int Parse(NS_tchar *line);
-  virtual int Prepare(); // should check for patch file and for checksum here
-  virtual int Execute();
-  virtual void Finish(int status);
+  int Parse(NS_tchar *line) override;
+  int Prepare() override; // should check for patch file and for checksum here
+  int Execute() override;
+  void Finish(int status) override;
 
 private:
   mozilla::UniquePtr<NS_tchar[]> mTestFile;
 };
 
 int
 PatchIfFile::Parse(NS_tchar *line)
 {