Bug 1032800 - Remove public destructors of NS_*_INLINE_* refcounted classes, Remove NS_HIDDEN, Fix dangerous public destructors r=Neil
authorPhilip Chee <philip.chee@gmail.com>
Mon, 30 Jun 2014 22:30:55 +0800
changeset 16461 c4202cb87f5d9ef517065b545cbbf8c697718070
parent 16460 2252971444b03561dcf6745b5f40f247787a2fc8
child 16462 5611f67e859c09136699a0444ecceb73a8d275a3
push id10250
push userphilip.chee@gmail.com
push dateTue, 08 Jul 2014 06:12:45 +0000
treeherdercomm-central@5611f67e859c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersNeil
bugs1032800, 1015664, 1027251, 1028588, 758992
Bug 1032800 - Remove public destructors of NS_*_INLINE_* refcounted classes, Remove NS_HIDDEN, Fix dangerous public destructors r=Neil Ports relevant parts from: Bug 1015664 - Remove NS_HIDDEN usage in Gecko Bug 1027251 - Remove public destructors of NS_*_INLINE_* refcounted classes, outside of a finite explicit whitelist Bug 1028588 - Fix dangerous public destructors in miscellaneous places Bug 758992 - Make the classes which use the XPCOM nsISupports implementation macros final, to avoid the warning about deleting using a pointer to a base class with virtual functions and no virtual dtor (browser parts)
suite/feeds/src/nsFeedSniffer.h
suite/profile/migration/src/nsNetscapeProfileMigratorBase.h
suite/profile/migration/src/nsThunderbirdProfileMigrator.h
suite/profile/nsSuiteDirectoryProvider.h
suite/shell/src/nsGNOMEShellService.h
suite/shell/src/nsMacShellService.h
suite/shell/src/nsWindowsShellService.h
--- a/suite/feeds/src/nsFeedSniffer.h
+++ b/suite/feeds/src/nsFeedSniffer.h
@@ -27,14 +27,16 @@ public:
   static NS_METHOD AppendSegmentToString(nsIInputStream* inputStream,
                                          void* closure,
                                          const char* rawSegment,
                                          uint32_t toOffset,
                                          uint32_t count,
                                          uint32_t* writeCount);
 
 protected:
+  ~nsFeedSniffer() {}
+
   nsresult ConvertEncodedData(nsIRequest* request, const uint8_t* data,
                               uint32_t length);
 
 private:
   nsCString mDecodedData;
 };
--- a/suite/profile/migration/src/nsNetscapeProfileMigratorBase.h
+++ b/suite/profile/migration/src/nsNetscapeProfileMigratorBase.h
@@ -45,17 +45,16 @@ struct fileTransactionEntry {
 class nsNetscapeProfileMigratorBase : public nsISuiteProfileMigrator,
                                       public nsITimerCallback
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSITIMERCALLBACK
 
   nsNetscapeProfileMigratorBase();
-  virtual ~nsNetscapeProfileMigratorBase() { }
 
   struct PrefTransform;
   typedef nsresult(*prefConverter)(PrefTransform*, nsIPrefBranch*);
 
   struct PrefTransform {
     const char*   sourcePrefName;
     const char*   targetPrefName;
     prefConverter prefGetterFunc;
@@ -92,16 +91,17 @@ public:
   static nsresult SetBool(PrefTransform* aTransform, nsIPrefBranch* aBranch);
   static nsresult GetInt(PrefTransform* aTransform, nsIPrefBranch* aBranch);
   static nsresult SetInt(PrefTransform* aTransform, nsIPrefBranch* aBranch);
   static nsresult SetFile(PrefTransform* aTransform, nsIPrefBranch* aBranch);
   static nsresult SetImage(PrefTransform* aTransform, nsIPrefBranch* aBranch);
   static nsresult SetCookie(PrefTransform* aTransform, nsIPrefBranch* aBranch);
 
 protected:
+  virtual ~nsNetscapeProfileMigratorBase() {}
   // This function is designed to be overriden by derived classes so that
   // the required profile data for the specific application can be obtained.
   virtual nsresult FillProfileDataFromRegistry() = 0;
 
   // General Utility Methods
   nsresult GetSourceProfile(const char16_t* aProfile);
   nsresult GetProfileDataFromProfilesIni(nsIFile* aDataDir,
                                          nsIMutableArray* aProfileNames,
--- a/suite/profile/migration/src/nsThunderbirdProfileMigrator.h
+++ b/suite/profile/migration/src/nsThunderbirdProfileMigrator.h
@@ -8,40 +8,41 @@
 
 #include "nsISuiteProfileMigrator.h"
 #include "nsIFile.h"
 #include "nsIObserverService.h"
 #include "nsISupportsArray.h"
 #include "nsNetscapeProfileMigratorBase.h"
 #include "nsStringAPI.h"
 #include "nsITimer.h"
+#include "mozilla/Attributes.h"
 
 class nsIFile;
 class nsIPrefBranch;
 class nsIPrefService;
 
 #define NS_THUNDERBIRDPROFILEMIGRATOR_CID \
 { 0x6ba91adb, 0xa4ed, 0x405f, { 0xbd, 0x6c, 0xe9, 0x04, 0xa9, 0x9d, 0x9a, 0xd8 } }
 
-class nsThunderbirdProfileMigrator : public nsNetscapeProfileMigratorBase
+class nsThunderbirdProfileMigrator MOZ_FINAL : public nsNetscapeProfileMigratorBase
 {
 public:
   NS_DECL_ISUPPORTS
 
   nsThunderbirdProfileMigrator();
-  virtual ~nsThunderbirdProfileMigrator();
 
   // nsISuiteProfileMigrator methods
   NS_IMETHOD Migrate(uint16_t aItems, nsIProfileStartup *aStartup,
                      const char16_t *aProfile);
   NS_IMETHOD GetMigrateData(const char16_t *aProfile, bool aDoingStartup,
                             uint16_t *_retval);
   NS_IMETHOD GetSupportedItems(uint16_t *aSupportedItems);
 
 protected:
+  virtual ~nsThunderbirdProfileMigrator();
   nsresult FillProfileDataFromRegistry();
   nsresult CopyPreferences(bool aReplace);
   nsresult TransformPreferences(const char* aSourcePrefFileName,
                                 const char* aTargetPrefFileName);
   nsresult CopyHistory(bool aReplace);
   nsresult CopyPasswords(bool aReplace);
 };
  
--- a/suite/profile/nsSuiteDirectoryProvider.h
+++ b/suite/profile/nsSuiteDirectoryProvider.h
@@ -7,49 +7,53 @@
 
 #include "nsCOMArray.h"
 #include "nsIDirectoryService.h"
 #include "nsIFile.h"
 #include "nsISimpleEnumerator.h"
 #include "nsStringAPI.h"
 #include "nsCOMPtr.h"
 #include "nsIProperties.h"
+#include "mozilla/Attributes.h"
 
 #define NS_SUITEDIRECTORYPROVIDER_CONTRACTID "@mozilla.org/suite/directory-provider;1"
 // {9aa21826-9d1d-433d-8c10-f313b26fa9dd}
 #define NS_SUITEDIRECTORYPROVIDER_CID \
   { 0x9aa21826, 0x9d1d, 0x433d, { 0x8c, 0x10, 0xf3, 0x13, 0xb2, 0x6f, 0xa9, 0xdd } }
 
-class nsSuiteDirectoryProvider : public nsIDirectoryServiceProvider2
+class nsSuiteDirectoryProvider MOZ_FINAL : public nsIDirectoryServiceProvider2
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDIRECTORYSERVICEPROVIDER
   NS_DECL_NSIDIRECTORYSERVICEPROVIDER2
 
 private:
+  ~nsSuiteDirectoryProvider() {}
+
   void EnsureProfileFile(const nsACString& aLeafName,
 			 nsIFile* aParentDir, nsIFile* aTarget);
 
   void AppendDistroSearchDirs(nsIProperties* aDirSvc,
                               nsCOMArray<nsIFile> &array);
 
   void AppendFileKey(const char *key, nsIProperties* aDirSvc,
                      nsCOMArray<nsIFile> &array);
 
-  class AppendingEnumerator : public nsISimpleEnumerator
+  class AppendingEnumerator MOZ_FINAL : public nsISimpleEnumerator
   {
   public:
     NS_DECL_ISUPPORTS
     NS_DECL_NSISIMPLEENUMERATOR
 
     AppendingEnumerator(nsISimpleEnumerator* aBase,
                         const char* const aLeafName);
 
   private:
+    ~AppendingEnumerator() {}
     void GetNext();
 
     nsCOMPtr<nsISimpleEnumerator> mBase;
     nsDependentCString            mLeafName;
     nsCOMPtr<nsIFile>             mNext;
   };
 };
 
--- a/suite/shell/src/nsGNOMEShellService.h
+++ b/suite/shell/src/nsGNOMEShellService.h
@@ -3,31 +3,32 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsgnomeshellservice_h____
 #define nsgnomeshellservice_h____
 
 #include "nsShellService.h"
 #include "nsStringGlue.h"
+#include "mozilla/Attributes.h"
 
 #define NS_SUITEGNOMEINTEGRATION_CID \
 {0xc16cfa25, 0xa74a, 0x420b, {0xa5, 0x45, 0x4b, 0xc0, 0x6b, 0x08, 0xa8, 0x65}}
 
 struct ProtocolAssociation;
 
-class nsGNOMEShellService : public nsIShellService
+class nsGNOMEShellService MOZ_FINAL : public nsIShellService
 {
 public:
   nsGNOMEShellService() : mCheckedThisSessionClient(false) { }
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSISHELLSERVICE
 
-  nsresult Init() NS_HIDDEN;
+  nsresult Init();
 
 private:
   ~nsGNOMEShellService() {}
   bool HandlerMatchesAppName(const char* aHandler);
 
   nsCString mAppPath;
   bool mAppIsInPath;
   bool mUseLocaleFilenames;
--- a/suite/shell/src/nsMacShellService.h
+++ b/suite/shell/src/nsMacShellService.h
@@ -5,34 +5,35 @@
 
 #ifndef nsmacshellservice_h____
 #define nsmacshellservice_h____
 
 #include "nsShellService.h"
 #include "nsIWebProgressListener.h"
 #include "nsIFile.h"
 #include "nsCOMPtr.h"
+#include "mozilla/Attributes.h"
 
 #include <CoreFoundation/CoreFoundation.h>
 
 #define NS_SUITEMACINTEGRATION_CID \
 {0xac17e6f0, 0x50c9, 0x4901, {0xab, 0x08, 0xf8, 0x70, 0xbf, 0xcd, 0x12, 0xce}}
 
-class nsMacShellService : public nsIShellService,
-                          public nsIWebProgressListener
+class nsMacShellService MOZ_FINAL : public nsIShellService,
+                                    public nsIWebProgressListener
 {
 public:
   nsMacShellService() : mCheckedThisSessionClient(false) {};
-  virtual ~nsMacShellService() {};
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSISHELLSERVICE
   NS_DECL_NSIWEBPROGRESSLISTENER
 
 protected:
+  ~nsMacShellService() {}
   bool isDefaultHandlerForProtocol(CFStringRef aScheme);
 
 private:
   nsCOMPtr<nsIFile> mBackgroundFile;
   bool mCheckedThisSessionClient;
 };
 
 #endif
--- a/suite/shell/src/nsWindowsShellService.h
+++ b/suite/shell/src/nsWindowsShellService.h
@@ -2,42 +2,43 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nscore.h"
 #include "nsShellService.h"
 #include "nsStringGlue.h"
 #include "nsIWindowsShellService.h"
+#include "mozilla/Attributes.h"
 
 #include <windows.h>
 
 #define NS_SUITEWININTEGRATION_CID \
 {0x39b688ec, 0xe308, 0x49e5, {0xbe, 0x6b, 0x28, 0xdc, 0x7f, 0xcd, 0x61, 0x54}}
 
 typedef struct {
   const char* keyName;
   const char* valueName;
   const char* valueData;
 
   int32_t flags;
 } SETTING;
 
-class nsWindowsShellService : public nsIWindowsShellService
+class nsWindowsShellService MOZ_FINAL : public nsIWindowsShellService
 {
 public:
   nsWindowsShellService() : mCheckedThisSessionClient(false) {};
-  ~nsWindowsShellService() {};
-  NS_HIDDEN_(nsresult) Init();
+  nsresult Init();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSISHELLSERVICE
   NS_DECL_NSIWINDOWSSHELLSERVICE
 
 protected:
+  ~nsWindowsShellService() {}
   bool IsDefaultClientVista(uint16_t aApps, bool* aIsDefaultClient);
   bool TestForDefault(SETTING aSettings[], int32_t aSize);
 
 private:
   bool mCheckedThisSessionClient;
   nsString mAppLongPath;
   nsString mAppShortPath;
 };