Bug 1056941 - Fix dangerous destructors in Fennec code; r=blassey

This commit is contained in:
Jim Chen
2014-08-26 15:07:59 -04:00
parent 2fe5eb0c13
commit ba12eedda5
22 changed files with 72 additions and 19 deletions

View File

@@ -15,6 +15,9 @@ namespace mobilemessage {
class MobileMessageDatabaseService MOZ_FINAL : public nsIMobileMessageDatabaseService class MobileMessageDatabaseService MOZ_FINAL : public nsIMobileMessageDatabaseService
{ {
private:
~MobileMessageDatabaseService() {}
public: public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSIMOBILEMESSAGEDATABASESERVICE NS_DECL_NSIMOBILEMESSAGEDATABASESERVICE

View File

@@ -14,6 +14,9 @@ namespace mobilemessage {
class SmsService MOZ_FINAL : public nsISmsService class SmsService MOZ_FINAL : public nsISmsService
{ {
private:
~SmsService() {}
public: public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSISMSSERVICE NS_DECL_NSISMSSERVICE

View File

@@ -7,6 +7,9 @@
class nsHapticFeedback MOZ_FINAL : public nsIHapticFeedback class nsHapticFeedback MOZ_FINAL : public nsIHapticFeedback
{ {
private:
~nsHapticFeedback() {}
public: public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSIHAPTICFEEDBACK NS_DECL_NSIHAPTICFEEDBACK

View File

@@ -44,6 +44,9 @@ static FT_Library gPlatformFTLibrary = nullptr;
class FreetypeReporter MOZ_FINAL : public nsIMemoryReporter, class FreetypeReporter MOZ_FINAL : public nsIMemoryReporter,
public CountingAllocatorBase<FreetypeReporter> public CountingAllocatorBase<FreetypeReporter>
{ {
private:
~FreetypeReporter() {}
public: public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS

View File

@@ -25,7 +25,6 @@ class nsIconChannel MOZ_FINAL : public nsIChannel {
NS_FORWARD_NSICHANNEL(mRealChannel->) NS_FORWARD_NSICHANNEL(mRealChannel->)
nsIconChannel() {} nsIconChannel() {}
~nsIconChannel() {}
/** /**
* Called by nsIconProtocolHandler after it creates this channel. * Called by nsIconProtocolHandler after it creates this channel.
@@ -33,7 +32,10 @@ class nsIconChannel MOZ_FINAL : public nsIChannel {
* If this method fails, no other function must be called on this object. * If this method fails, no other function must be called on this object.
*/ */
nsresult Init(nsIURI* aURI); nsresult Init(nsIURI* aURI);
private: private:
~nsIconChannel() {}
/** /**
* The channel to the temp icon file (e.g. to /tmp/2qy9wjqw.html). * The channel to the temp icon file (e.g. to /tmp/2qy9wjqw.html).
* Will always be non-null after a successful Init. * Will always be non-null after a successful Init.

View File

@@ -15,11 +15,10 @@ public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSISHELLSERVICE NS_DECL_NSISHELLSERVICE
nsShellService() {}; nsShellService() {}
private: private:
~nsShellService() {}; ~nsShellService() {}
}; };
#define nsShellService_CID \ #define nsShellService_CID \

View File

@@ -225,9 +225,9 @@ class TicklerTimer MOZ_FINAL : public nsITimerCallback
mTickler = do_GetWeakReference(aTickler); mTickler = do_GetWeakReference(aTickler);
} }
~TicklerTimer() {};
private: private:
~TicklerTimer() {}
nsWeakPtr mTickler; nsWeakPtr mTickler;
}; };

View File

@@ -17,9 +17,11 @@
#include "mozilla/ReentrantMonitor.h" #include "mozilla/ReentrantMonitor.h"
class AndroidCaptureProvider MOZ_FINAL : public nsDeviceCaptureProvider { class AndroidCaptureProvider MOZ_FINAL : public nsDeviceCaptureProvider {
private:
~AndroidCaptureProvider();
public: public:
AndroidCaptureProvider(); AndroidCaptureProvider();
~AndroidCaptureProvider();
NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_THREADSAFE_ISUPPORTS
@@ -28,9 +30,11 @@ class AndroidCaptureProvider MOZ_FINAL : public nsDeviceCaptureProvider {
}; };
class AndroidCameraInputStream MOZ_FINAL : public nsIAsyncInputStream, mozilla::net::CameraStreamImpl::FrameCallback { class AndroidCameraInputStream MOZ_FINAL : public nsIAsyncInputStream, mozilla::net::CameraStreamImpl::FrameCallback {
private:
~AndroidCameraInputStream();
public: public:
AndroidCameraInputStream(); AndroidCameraInputStream();
~AndroidCameraInputStream();
NS_IMETHODIMP Init(nsACString& aContentType, nsCaptureParams* aParams); NS_IMETHODIMP Init(nsACString& aContentType, nsCaptureParams* aParams);

View File

@@ -16,6 +16,8 @@ public:
NS_DECL_NSINETWORKLINKSERVICE NS_DECL_NSINETWORKLINKSERVICE
nsAndroidNetworkLinkService(); nsAndroidNetworkLinkService();
private:
virtual ~nsAndroidNetworkLinkService(); virtual ~nsAndroidNetworkLinkService();
}; };

View File

@@ -26,7 +26,7 @@ public:
nsresult Init(); nsresult Init();
private: private:
~nsAndroidSystemProxySettings() {}; virtual ~nsAndroidSystemProxySettings() {}
}; };
NS_IMPL_ISUPPORTS(nsAndroidSystemProxySettings, nsISystemProxySettings) NS_IMPL_ISUPPORTS(nsAndroidSystemProxySettings, nsISystemProxySettings)

View File

@@ -15,14 +15,14 @@ public:
NS_DECL_NSIHANDLERAPP NS_DECL_NSIHANDLERAPP
NS_DECL_NSISHARINGHANDLERAPP NS_DECL_NSISHARINGHANDLERAPP
public:
nsAndroidHandlerApp(const nsAString& aName, const nsAString& aDescription, nsAndroidHandlerApp(const nsAString& aName, const nsAString& aDescription,
const nsAString& aPackageName, const nsAString& aPackageName,
const nsAString& aClassName, const nsAString& aClassName,
const nsACString& aMimeType, const nsAString& aAction); const nsACString& aMimeType, const nsAString& aAction);
virtual ~nsAndroidHandlerApp();
private: private:
virtual ~nsAndroidHandlerApp();
nsString mName; nsString mName;
nsString mDescription; nsString mDescription;
nsString mPackageName; nsString mPackageName;

View File

@@ -30,7 +30,9 @@ public:
nsMIMEInfoAndroid(const nsACString& aMIMEType); nsMIMEInfoAndroid(const nsACString& aMIMEType);
protected: private:
~nsMIMEInfoAndroid() {}
virtual nsresult LaunchDefaultWithFile(nsIFile* aFile); virtual nsresult LaunchDefaultWithFile(nsIFile* aFile);
virtual nsresult LoadUriInternal(nsIURI *aURI); virtual nsresult LoadUriInternal(nsIURI *aURI);
nsCOMPtr<nsIMutableArray> mHandlerApps; nsCOMPtr<nsIMutableArray> mHandlerApps;
@@ -40,16 +42,18 @@ protected:
nsHandlerInfoAction mPrefAction; nsHandlerInfoAction mPrefAction;
nsString mDescription; nsString mDescription;
nsCOMPtr<nsIHandlerApp> mPrefApp; nsCOMPtr<nsIHandlerApp> mPrefApp;
public:
class SystemChooser MOZ_FINAL : public nsIHandlerApp { class SystemChooser MOZ_FINAL : public nsIHandlerApp {
public: public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSIHANDLERAPP NS_DECL_NSIHANDLERAPP
SystemChooser(nsMIMEInfoAndroid* aOuter): mOuter(aOuter) {}; SystemChooser(nsMIMEInfoAndroid* aOuter): mOuter(aOuter) {}
private: private:
~SystemChooser() {}
nsMIMEInfoAndroid* mOuter; nsMIMEInfoAndroid* mOuter;
}; };
}; };

View File

@@ -115,6 +115,10 @@ GfxInfo::GfxInfo()
{ {
} }
GfxInfo::~GfxInfo()
{
}
/* GetD2DEnabled and GetDwriteEnabled shouldn't be called until after gfxPlatform initialization /* GetD2DEnabled and GetDwriteEnabled shouldn't be called until after gfxPlatform initialization
* has occurred because they depend on it for information. (See bug 591561) */ * has occurred because they depend on it for information. (See bug 591561) */
nsresult nsresult

View File

@@ -24,6 +24,9 @@ namespace widget {
class GfxInfo : public GfxInfoBase class GfxInfo : public GfxInfoBase
{ {
private:
~GfxInfo();
public: public:
GfxInfo(); GfxInfo();

View File

@@ -25,11 +25,15 @@ public:
mBridgeInputStream = env->NewGlobalRef(GeckoAppShell::CreateInputStream(connection)); mBridgeInputStream = env->NewGlobalRef(GeckoAppShell::CreateInputStream(connection));
mBridgeChannel = env->NewGlobalRef(AndroidBridge::ChannelCreate(mBridgeInputStream)); mBridgeChannel = env->NewGlobalRef(AndroidBridge::ChannelCreate(mBridgeInputStream));
} }
private:
virtual ~AndroidInputStream() { virtual ~AndroidInputStream() {
JNIEnv *env = GetJNIForThread(); JNIEnv *env = GetJNIForThread();
env->DeleteGlobalRef(mBridgeInputStream); env->DeleteGlobalRef(mBridgeInputStream);
env->DeleteGlobalRef(mBridgeChannel); env->DeleteGlobalRef(mBridgeChannel);
} }
public:
NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIINPUTSTREAM NS_DECL_NSIINPUTSTREAM

View File

@@ -29,6 +29,8 @@ public:
// nsAndroidProtocolHandler methods: // nsAndroidProtocolHandler methods:
nsAndroidProtocolHandler() {} nsAndroidProtocolHandler() {}
private:
~nsAndroidProtocolHandler() {} ~nsAndroidProtocolHandler() {}
}; };

View File

@@ -111,7 +111,10 @@ private:
}; };
class WakeLockListener MOZ_FINAL : public nsIDOMMozWakeLockListener { class WakeLockListener MOZ_FINAL : public nsIDOMMozWakeLockListener {
public: private:
~WakeLockListener() {}
public:
NS_DECL_ISUPPORTS; NS_DECL_ISUPPORTS;
nsresult Callback(const nsAString& topic, const nsAString& state) { nsresult Callback(const nsAString& topic, const nsAString& state) {

View File

@@ -10,6 +10,9 @@
class nsClipboard MOZ_FINAL : public nsIClipboard class nsClipboard MOZ_FINAL : public nsIClipboard
{ {
private:
~nsClipboard() {}
public: public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSICLIPBOARD NS_DECL_NSICLIPBOARD

View File

@@ -7,6 +7,9 @@
class nsDeviceContextSpecAndroid MOZ_FINAL : public nsIDeviceContextSpec class nsDeviceContextSpecAndroid MOZ_FINAL : public nsIDeviceContextSpec
{ {
private:
~nsDeviceContextSpecAndroid() {}
public: public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS

View File

@@ -30,9 +30,11 @@ protected:
class nsScreenManagerAndroid MOZ_FINAL : public nsIScreenManager class nsScreenManagerAndroid MOZ_FINAL : public nsIScreenManager
{ {
private:
~nsScreenManagerAndroid();
public: public:
nsScreenManagerAndroid(); nsScreenManagerAndroid();
~nsScreenManagerAndroid();
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSISCREENMANAGER NS_DECL_NSISCREENMANAGER

View File

@@ -87,6 +87,10 @@ static StaticRefPtr<ContentCreationNotifier> gContentCreationNotifier;
// are created. Currently an update for the screen size is sent. // are created. Currently an update for the screen size is sent.
class ContentCreationNotifier MOZ_FINAL : public nsIObserver class ContentCreationNotifier MOZ_FINAL : public nsIObserver
{ {
private:
~ContentCreationNotifier() {}
public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_IMETHOD Observe(nsISupports* aSubject, NS_IMETHOD Observe(nsISupports* aSubject,

View File

@@ -32,11 +32,13 @@ namespace mozilla {
class nsWindow : class nsWindow :
public nsBaseWidget public nsBaseWidget
{ {
private:
virtual ~nsWindow();
public: public:
using nsBaseWidget::GetLayerManager; using nsBaseWidget::GetLayerManager;
nsWindow(); nsWindow();
virtual ~nsWindow();
NS_DECL_ISUPPORTS_INHERITED NS_DECL_ISUPPORTS_INHERITED