Bug 1056941 - Fix dangerous destructors in Fennec code; r=blassey
authorJim Chen <nchen@mozilla.com>
Tue, 26 Aug 2014 15:07:59 -0400
changeset 201736 963b26a1a6fbd20a4048a32b714c1c942c69412a
parent 201735 7f68752ffe1e6990b04dccf1b05e87df493adbad
child 201737 5b4012ce76768c499089ea51a01d7dd6f6cba1a4
push id27380
push userkwierso@gmail.com
push dateWed, 27 Aug 2014 00:50:11 +0000
treeherdermozilla-central@83289be2cd12 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersblassey
bugs1056941
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1056941 - Fix dangerous destructors in Fennec code; r=blassey
dom/mobilemessage/src/android/MobileMessageDatabaseService.h
dom/mobilemessage/src/android/SmsService.h
dom/system/android/nsHapticFeedback.h
gfx/thebes/gfxAndroidPlatform.cpp
image/decoders/icon/android/nsIconChannel.h
mobile/android/components/build/nsShellService.h
netwerk/base/src/Tickler.cpp
netwerk/protocol/device/AndroidCaptureProvider.h
netwerk/system/android/nsAndroidNetworkLinkService.h
toolkit/system/androidproxy/nsAndroidSystemProxySettings.cpp
uriloader/exthandler/android/nsAndroidHandlerApp.h
uriloader/exthandler/android/nsMIMEInfoAndroid.h
widget/android/GfxInfo.cpp
widget/android/GfxInfo.h
widget/android/nsAndroidProtocolHandler.cpp
widget/android/nsAndroidProtocolHandler.h
widget/android/nsAppShell.cpp
widget/android/nsClipboard.h
widget/android/nsDeviceContextAndroid.h
widget/android/nsScreenManagerAndroid.h
widget/android/nsWindow.cpp
widget/android/nsWindow.h
--- a/dom/mobilemessage/src/android/MobileMessageDatabaseService.h
+++ b/dom/mobilemessage/src/android/MobileMessageDatabaseService.h
@@ -10,16 +10,19 @@
 #include "mozilla/Attributes.h"
 
 namespace mozilla {
 namespace dom {
 namespace mobilemessage {
 
 class MobileMessageDatabaseService MOZ_FINAL : public nsIMobileMessageDatabaseService
 {
+private:
+  ~MobileMessageDatabaseService() {}
+
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIMOBILEMESSAGEDATABASESERVICE
 };
 
 } // namespace mobilemessage
 } // namespace dom
 } // namespace mozilla
--- a/dom/mobilemessage/src/android/SmsService.h
+++ b/dom/mobilemessage/src/android/SmsService.h
@@ -9,16 +9,19 @@
 #include "nsISmsService.h"
 
 namespace mozilla {
 namespace dom {
 namespace mobilemessage {
 
 class SmsService MOZ_FINAL : public nsISmsService
 {
+private:
+  ~SmsService() {}
+
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSISMSSERVICE
 };
 
 } // namespace mobilemessage
 } // namespace dom
 } // namespace mozilla
--- a/dom/system/android/nsHapticFeedback.h
+++ b/dom/system/android/nsHapticFeedback.h
@@ -2,12 +2,15 @@
  * 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 "nsIHapticFeedback.h"
 
 class nsHapticFeedback MOZ_FINAL : public nsIHapticFeedback
 {
+private:
+  ~nsHapticFeedback() {}
+
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIHAPTICFEEDBACK
 };
--- a/gfx/thebes/gfxAndroidPlatform.cpp
+++ b/gfx/thebes/gfxAndroidPlatform.cpp
@@ -39,16 +39,19 @@ using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::gfx;
 
 static FT_Library gPlatformFTLibrary = nullptr;
 
 class FreetypeReporter MOZ_FINAL : public nsIMemoryReporter,
                                    public CountingAllocatorBase<FreetypeReporter>
 {
+private:
+    ~FreetypeReporter() {}
+
 public:
     NS_DECL_ISUPPORTS
 
     static void* Malloc(FT_Memory, long size)
     {
         return CountingMalloc(size);
     }
 
--- a/image/decoders/icon/android/nsIconChannel.h
+++ b/image/decoders/icon/android/nsIconChannel.h
@@ -20,25 +20,27 @@
  */
 class nsIconChannel MOZ_FINAL : public nsIChannel {
   public:
     NS_DECL_ISUPPORTS
     NS_FORWARD_NSIREQUEST(mRealChannel->)
     NS_FORWARD_NSICHANNEL(mRealChannel->)
 
     nsIconChannel() {}
-    ~nsIconChannel() {}
 
     /**
      * Called by nsIconProtocolHandler after it creates this channel.
      * Must be called before calling any other function on this object.
      * If this method fails, no other function must be called on this object.
      */
     nsresult Init(nsIURI* aURI);
+
   private:
+    ~nsIconChannel() {}
+
     /**
      * The channel to the temp icon file (e.g. to /tmp/2qy9wjqw.html).
      * Will always be non-null after a successful Init.
      */
     nsCOMPtr<nsIChannel> mRealChannel;
 };
 
 #endif
--- a/mobile/android/components/build/nsShellService.h
+++ b/mobile/android/components/build/nsShellService.h
@@ -10,21 +10,20 @@
 
 class nsShellService MOZ_FINAL : public nsIShellService
 {
 public:
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSISHELLSERVICE
 
-  nsShellService() {};
+  nsShellService() {}
 
 private:
-  ~nsShellService() {};
-
+  ~nsShellService() {}
 };
 
 #define nsShellService_CID                          \
 {0xae9ebe1c, 0x61e9, 0x45fa, {0x8f, 0x34, 0xc1, 0x07, 0x80, 0x3a, 0x5b, 0x44}}
 
 #define nsShellService_ContractID "@mozilla.org/browser/shell-service;1"
 
 #endif
--- a/netwerk/base/src/Tickler.cpp
+++ b/netwerk/base/src/Tickler.cpp
@@ -220,19 +220,19 @@ class TicklerTimer MOZ_FINAL : public ns
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSITIMERCALLBACK
 
   TicklerTimer(Tickler *aTickler)
   {
     mTickler = do_GetWeakReference(aTickler);
   }
 
-  ~TicklerTimer() {};
+private:
+  ~TicklerTimer() {}
 
-private:
   nsWeakPtr mTickler;
 };
 
 void Tickler::StartTickler()
 {
   mLock.AssertCurrentThreadOwns();
   MOZ_ASSERT(mThread == NS_GetCurrentThread());
   MOZ_ASSERT(!mActive);
--- a/netwerk/protocol/device/AndroidCaptureProvider.h
+++ b/netwerk/protocol/device/AndroidCaptureProvider.h
@@ -12,30 +12,34 @@
 #include "nsAutoPtr.h"
 #include "nsString.h"
 #include "mozilla/net/CameraStreamImpl.h"
 #include "nsIEventTarget.h"
 #include "nsDeque.h"
 #include "mozilla/ReentrantMonitor.h"
 
 class AndroidCaptureProvider MOZ_FINAL : public nsDeviceCaptureProvider {
+  private:
+    ~AndroidCaptureProvider();
+
   public:
     AndroidCaptureProvider();
-    ~AndroidCaptureProvider();
 
     NS_DECL_THREADSAFE_ISUPPORTS
 
     nsresult Init(nsACString& aContentType, nsCaptureParams* aParams, nsIInputStream** aStream);
     static AndroidCaptureProvider* sInstance;
 };
 
 class AndroidCameraInputStream MOZ_FINAL : public nsIAsyncInputStream, mozilla::net::CameraStreamImpl::FrameCallback {
+  private:
+    ~AndroidCameraInputStream();
+
   public:
     AndroidCameraInputStream();
-    ~AndroidCameraInputStream();
 
     NS_IMETHODIMP Init(nsACString& aContentType, nsCaptureParams* aParams);
 
     NS_DECL_THREADSAFE_ISUPPORTS
     NS_DECL_NSIINPUTSTREAM
     NS_DECL_NSIASYNCINPUTSTREAM
 
     void ReceiveFrame(char* frame, uint32_t length);
--- a/netwerk/system/android/nsAndroidNetworkLinkService.h
+++ b/netwerk/system/android/nsAndroidNetworkLinkService.h
@@ -11,12 +11,14 @@
 
 class nsAndroidNetworkLinkService: public nsINetworkLinkService
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSINETWORKLINKSERVICE
 
   nsAndroidNetworkLinkService();
+
+private:
   virtual ~nsAndroidNetworkLinkService();
 };
 
 #endif /* NSANDROIDNETWORKLINKSERVICE_H_ */
--- a/toolkit/system/androidproxy/nsAndroidSystemProxySettings.cpp
+++ b/toolkit/system/androidproxy/nsAndroidSystemProxySettings.cpp
@@ -21,17 +21,17 @@ class nsAndroidSystemProxySettings : pub
 public:
     NS_DECL_THREADSAFE_ISUPPORTS
     NS_DECL_NSISYSTEMPROXYSETTINGS
 
     nsAndroidSystemProxySettings() {};
     nsresult Init();
 
 private:
-    ~nsAndroidSystemProxySettings() {};
+    virtual ~nsAndroidSystemProxySettings() {}
 };
 
 NS_IMPL_ISUPPORTS(nsAndroidSystemProxySettings, nsISystemProxySettings)
 
 NS_IMETHODIMP
 nsAndroidSystemProxySettings::GetMainThreadOnly(bool *aMainThreadOnly)
 {
   *aMainThreadOnly = true;
--- a/uriloader/exthandler/android/nsAndroidHandlerApp.h
+++ b/uriloader/exthandler/android/nsAndroidHandlerApp.h
@@ -10,24 +10,24 @@
 #include "nsIExternalSharingAppService.h"
 
 class nsAndroidHandlerApp : public nsISharingHandlerApp {
 public:
     NS_DECL_ISUPPORTS
     NS_DECL_NSIHANDLERAPP
     NS_DECL_NSISHARINGHANDLERAPP
 
-    public:
     nsAndroidHandlerApp(const nsAString& aName, const nsAString& aDescription,
                         const nsAString& aPackageName, 
                         const nsAString& aClassName, 
                         const nsACString& aMimeType, const nsAString& aAction);
+
+private:
     virtual ~nsAndroidHandlerApp();
 
-private:
     nsString mName;
     nsString mDescription;
     nsString mPackageName;
     nsString mClassName;
     nsCString mMimeType;
     nsString mAction;
 };
 #endif
--- a/uriloader/exthandler/android/nsMIMEInfoAndroid.h
+++ b/uriloader/exthandler/android/nsMIMEInfoAndroid.h
@@ -25,32 +25,36 @@ public:
                     nsIHandlerInfo **info);
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIMIMEINFO
   NS_DECL_NSIHANDLERINFO
 
   nsMIMEInfoAndroid(const nsACString& aMIMEType);
 
-protected:
+private:
+  ~nsMIMEInfoAndroid() {}
+
   virtual nsresult LaunchDefaultWithFile(nsIFile* aFile);
   virtual nsresult LoadUriInternal(nsIURI *aURI);
   nsCOMPtr<nsIMutableArray> mHandlerApps;
   nsCString mType;
   nsTArray<nsCString> mExtensions;
   bool mAlwaysAsk;
   nsHandlerInfoAction mPrefAction;
   nsString mDescription;
   nsCOMPtr<nsIHandlerApp> mPrefApp;
-  
+
+public:
   class SystemChooser MOZ_FINAL : public nsIHandlerApp {
   public:
     NS_DECL_ISUPPORTS
     NS_DECL_NSIHANDLERAPP
-    SystemChooser(nsMIMEInfoAndroid* aOuter): mOuter(aOuter) {};
-    
+    SystemChooser(nsMIMEInfoAndroid* aOuter): mOuter(aOuter) {}
+
   private:
+    ~SystemChooser() {}
+
     nsMIMEInfoAndroid* mOuter;
-    
   };
 };
 
 #endif /* nsMIMEInfoAndroid_h */
--- a/widget/android/GfxInfo.cpp
+++ b/widget/android/GfxInfo.cpp
@@ -110,16 +110,20 @@ NS_IMPL_ISUPPORTS_INHERITED(GfxInfo, Gfx
 #endif
 
 GfxInfo::GfxInfo()
   : mInitialized(false)
   , mGLStrings(new GLStrings)
 {
 }
 
+GfxInfo::~GfxInfo()
+{
+}
+
 /* GetD2DEnabled and GetDwriteEnabled shouldn't be called until after gfxPlatform initialization
  * has occurred because they depend on it for information. (See bug 591561) */
 nsresult
 GfxInfo::GetD2DEnabled(bool *aEnabled)
 {
   return NS_ERROR_FAILURE;
 }
 
--- a/widget/android/GfxInfo.h
+++ b/widget/android/GfxInfo.h
@@ -19,16 +19,19 @@ namespace mozilla {
 namespace gl {
 class GLContext;
 }
 
 namespace widget {
 
 class GfxInfo : public GfxInfoBase
 {
+private:
+  ~GfxInfo();
+
 public:
   GfxInfo();
 
   // We only declare the subset of nsIGfxInfo that we actually implement. The
   // rest is brought forward from GfxInfoBase.
   NS_IMETHOD GetD2DEnabled(bool *aD2DEnabled);
   NS_IMETHOD GetDWriteEnabled(bool *aDWriteEnabled);
   NS_IMETHOD GetDWriteVersion(nsAString & aDwriteVersion);
--- a/widget/android/nsAndroidProtocolHandler.cpp
+++ b/widget/android/nsAndroidProtocolHandler.cpp
@@ -20,21 +20,25 @@ using namespace mozilla::widget::android
 class AndroidInputStream : public nsIInputStream
 {
 public:
     AndroidInputStream(jobject connection) {
         JNIEnv *env = GetJNIForThread();
         mBridgeInputStream = env->NewGlobalRef(GeckoAppShell::CreateInputStream(connection));
         mBridgeChannel = env->NewGlobalRef(AndroidBridge::ChannelCreate(mBridgeInputStream));
     }
+
+private:
     virtual ~AndroidInputStream() {
         JNIEnv *env = GetJNIForThread();
         env->DeleteGlobalRef(mBridgeInputStream);
         env->DeleteGlobalRef(mBridgeChannel);
     }
+
+public:
     NS_DECL_THREADSAFE_ISUPPORTS
     NS_DECL_NSIINPUTSTREAM
 
     private:
     jobject mBridgeInputStream;
     jobject mBridgeChannel;
 };
 
--- a/widget/android/nsAndroidProtocolHandler.h
+++ b/widget/android/nsAndroidProtocolHandler.h
@@ -24,12 +24,14 @@ class nsAndroidProtocolHandler MOZ_FINAL
 public:
     NS_DECL_THREADSAFE_ISUPPORTS
 
     // nsIProtocolHandler methods:
     NS_DECL_NSIPROTOCOLHANDLER
 
     // nsAndroidProtocolHandler methods:
     nsAndroidProtocolHandler() {}
+
+private:
     ~nsAndroidProtocolHandler() {}
 };
 
 #endif /* nsAndroidProtocolHandler_h___ */
--- a/widget/android/nsAppShell.cpp
+++ b/widget/android/nsAppShell.cpp
@@ -106,17 +106,20 @@ public:
 private:
     nsCOMPtr<nsIAndroidBrowserApp> mBrowserApp;
     nsTArray<nsIntPoint> mPoints;
     int mTabId;
     nsRefPtr<RefCountedJavaObject> mBuffer;
 };
 
 class WakeLockListener MOZ_FINAL : public nsIDOMMozWakeLockListener {
- public:
+private:
+  ~WakeLockListener() {}
+
+public:
   NS_DECL_ISUPPORTS;
 
   nsresult Callback(const nsAString& topic, const nsAString& state) {
     mozilla::widget::android::GeckoAppShell::NotifyWakeLockChanged(topic, state);
     return NS_OK;
   }
 };
 
--- a/widget/android/nsClipboard.h
+++ b/widget/android/nsClipboard.h
@@ -5,16 +5,19 @@
 
 #ifndef NS_CLIPBOARD_H
 #define NS_CLIPBOARD_H
 
 #include "nsIClipboard.h"
 
 class nsClipboard MOZ_FINAL : public nsIClipboard
 {
+private:
+  ~nsClipboard() {}
+
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSICLIPBOARD
 
   nsClipboard();
 };
 
 #endif
--- a/widget/android/nsDeviceContextAndroid.h
+++ b/widget/android/nsDeviceContextAndroid.h
@@ -2,16 +2,19 @@
 /* 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 "nsIDeviceContextSpec.h"
 #include "nsCOMPtr.h"
 
 class nsDeviceContextSpecAndroid MOZ_FINAL : public nsIDeviceContextSpec
 {
+private:
+    ~nsDeviceContextSpecAndroid() {}
+
 public:
     NS_DECL_ISUPPORTS
 
     NS_IMETHOD GetSurfaceForPrinter(gfxASurface** surface);
 
     NS_IMETHOD Init(nsIWidget* aWidget,
                     nsIPrintSettings* aPS,
                     bool aIsPrintPreview);
--- a/widget/android/nsScreenManagerAndroid.h
+++ b/widget/android/nsScreenManagerAndroid.h
@@ -25,19 +25,21 @@ public:
     NS_IMETHOD GetColorDepth(int32_t* aColorDepth);
 
 protected:
     virtual void ApplyMinimumBrightness(uint32_t aBrightness) MOZ_OVERRIDE;
 };
 
 class nsScreenManagerAndroid MOZ_FINAL : public nsIScreenManager
 {
+private:
+    ~nsScreenManagerAndroid();
+
 public:
     nsScreenManagerAndroid();
-    ~nsScreenManagerAndroid();
 
     NS_DECL_ISUPPORTS
     NS_DECL_NSISCREENMANAGER
 
 protected:
     nsCOMPtr<nsIScreen> mOneScreen;
 };
 
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -82,16 +82,20 @@ static gfxIntSize gAndroidScreenBounds;
 
 class ContentCreationNotifier;
 static StaticRefPtr<ContentCreationNotifier> gContentCreationNotifier;
 
 // A helper class to send updates when content processes
 // are created. Currently an update for the screen size is sent.
 class ContentCreationNotifier MOZ_FINAL : public nsIObserver
 {
+private:
+    ~ContentCreationNotifier() {}
+
+public:
     NS_DECL_ISUPPORTS
 
     NS_IMETHOD Observe(nsISupports* aSubject,
                        const char* aTopic,
                        const char16_t* aData)
     {
         if (!strcmp(aTopic, "ipc:content-created")) {
             nsCOMPtr<nsIObserver> cpo = do_QueryInterface(aSubject);
--- a/widget/android/nsWindow.h
+++ b/widget/android/nsWindow.h
@@ -27,21 +27,23 @@ namespace mozilla {
         class LayerManager;
         class APZCTreeManager;
     }
 }
 
 class nsWindow :
     public nsBaseWidget
 {
+private:
+    virtual ~nsWindow();
+
 public:
     using nsBaseWidget::GetLayerManager;
 
     nsWindow();
-    virtual ~nsWindow();
 
     NS_DECL_ISUPPORTS_INHERITED
 
     static void OnGlobalAndroidEvent(mozilla::AndroidGeckoEvent *ae);
     static gfxIntSize GetAndroidScreenBounds();
     static nsWindow* TopWindow();
 
     nsWindow* FindWindowForPoint(const nsIntPoint& pt);