Bug 1028588 - Fix dangerous public destructors in image/ - r=jrmuizel

This commit is contained in:
Benoit Jacob 2014-06-23 14:49:08 -04:00
Родитель 360bdb42d9
Коммит 9a1a886bf7
21 изменённых файлов: 49 добавлений и 29 удалений

Просмотреть файл

@ -25,7 +25,6 @@ class nsIconChannel MOZ_FINAL : public nsIChannel {
NS_FORWARD_NSICHANNEL(mRealChannel->)
nsIconChannel() {}
~nsIconChannel() {}
static void Shutdown();
@ -36,6 +35,7 @@ class nsIconChannel MOZ_FINAL : public nsIChannel {
*/
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.

Просмотреть файл

@ -17,9 +17,9 @@ public:
// nsIconProtocolHandler methods:
nsIconProtocolHandler();
virtual ~nsIconProtocolHandler();
protected:
virtual ~nsIconProtocolHandler();
};
#endif /* nsIconProtocolHandler_h___ */

Просмотреть файл

@ -28,9 +28,9 @@ public:
// nsMozIconURI
nsMozIconURI();
virtual ~nsMozIconURI();
protected:
virtual ~nsMozIconURI();
nsCOMPtr<nsIURL> mIconURL; // a URL that we want the icon for
uint32_t mSize; // the # of pixels in a row that we want for this image. Typically 16, 32, 128, etc.
nsCString mContentType; // optional field explicitly specifying the content type

Просмотреть файл

@ -31,9 +31,10 @@ public:
NS_DECL_NSIASYNCINPUTSTREAM
nsBMPEncoder();
~nsBMPEncoder();
protected:
~nsBMPEncoder();
enum Version {
VERSION_3 = 3,
VERSION_5 = 5

Просмотреть файл

@ -35,7 +35,6 @@ public:
NS_DECL_NSIASYNCINPUTSTREAM
nsICOEncoder();
~nsICOEncoder();
// Obtains the width of the icon directory entry
uint32_t GetRealWidth() const
@ -50,6 +49,8 @@ public:
}
protected:
~nsICOEncoder();
nsresult ParseOptions(const nsAString& aOptions, uint32_t* bpp,
bool *usePNG);
void NotifyListener();

Просмотреть файл

@ -33,9 +33,9 @@ public:
NS_DECL_NSIASYNCINPUTSTREAM
nsPNGEncoder();
~nsPNGEncoder();
protected:
~nsPNGEncoder();
nsresult ParseOptions(const nsAString& aOptions,
bool* useTransparency,
bool* skipFirstFrame,

Просмотреть файл

@ -31,8 +31,6 @@ class ClippedImage : public ImageWrapper
public:
NS_DECL_ISUPPORTS
virtual ~ClippedImage();
virtual nsIntRect FrameRect(uint32_t aWhichFrame) MOZ_OVERRIDE;
NS_IMETHOD GetWidth(int32_t* aWidth) MOZ_OVERRIDE;
@ -58,6 +56,8 @@ public:
protected:
ClippedImage(Image* aImage, nsIntRect aClip);
virtual ~ClippedImage();
private:
mozilla::TemporaryRef<SourceSurface>
GetFrameInternal(const nsIntSize& aViewportSize,

Просмотреть файл

@ -31,8 +31,6 @@ class FrozenImage : public ImageWrapper
public:
NS_DECL_ISUPPORTS
virtual ~FrozenImage() { }
virtual nsIntRect FrameRect(uint32_t aWhichFrame) MOZ_OVERRIDE;
virtual void IncrementAnimationConsumers() MOZ_OVERRIDE;
virtual void DecrementAnimationConsumers() MOZ_OVERRIDE;
@ -60,6 +58,7 @@ public:
protected:
FrozenImage(Image* aImage) : ImageWrapper(aImage) { }
virtual ~FrozenImage() { }
private:
friend class ImageOps;

Просмотреть файл

@ -21,8 +21,6 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_IMGICONTAINER
virtual ~ImageWrapper() { }
// Inherited methods from Image.
virtual nsresult Init(const char* aMimeType, uint32_t aFlags) MOZ_OVERRIDE;
@ -71,6 +69,8 @@ protected:
NS_ABORT_IF_FALSE(aInnerImage, "Cannot wrap a null image");
}
virtual ~ImageWrapper() { }
/**
* Returns a weak reference to the inner image wrapped by this ImageWrapper.
*/

Просмотреть файл

@ -28,8 +28,6 @@ class OrientedImage : public ImageWrapper
public:
NS_DECL_ISUPPORTS
virtual ~OrientedImage() { }
virtual nsIntRect FrameRect(uint32_t aWhichFrame) MOZ_OVERRIDE;
NS_IMETHOD GetWidth(int32_t* aWidth) MOZ_OVERRIDE;
@ -56,6 +54,8 @@ protected:
, mOrientation(aOrientation)
{ }
virtual ~OrientedImage() { }
gfxMatrix OrientationMatrix(const nsIntSize& aViewportSize);
private:

Просмотреть файл

@ -143,6 +143,9 @@ class RasterImage : public ImageResource
, public imgIContainerDebug
#endif
{
// (no public constructor - use ImageFactory)
virtual ~RasterImage();
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(RasterImage)
NS_DECL_THREADSAFE_ISUPPORTS
@ -152,9 +155,6 @@ public:
NS_DECL_IMGICONTAINERDEBUG
#endif
// (no public constructor - use ImageFactory)
virtual ~RasterImage();
virtual nsresult StartAnimation();
virtual nsresult StopAnimation();
@ -454,13 +454,12 @@ private:
*/
already_AddRefed<nsIEventTarget> GetEventTarget();
virtual ~DecodePool();
private: /* statics */
static StaticRefPtr<DecodePool> sSingleton;
private: /* methods */
DecodePool();
virtual ~DecodePool();
enum DecodeType {
DECODE_TYPE_UNTIL_TIME,

Просмотреть файл

@ -41,7 +41,6 @@ class SVGDocumentWrapper MOZ_FINAL : public nsIStreamListener,
{
public:
SVGDocumentWrapper();
~SVGDocumentWrapper();
NS_DECL_ISUPPORTS
NS_DECL_NSISTREAMLISTENER
@ -146,6 +145,8 @@ public:
void FlushLayout();
private:
~SVGDocumentWrapper();
nsresult SetupViewer(nsIRequest *aRequest,
nsIContentViewer** aViewer,
nsILoadGroup** aLoadGroup);

Просмотреть файл

@ -20,13 +20,13 @@ class ScriptedNotificationObserver : public imgINotificationObserver
{
public:
ScriptedNotificationObserver(imgIScriptedNotificationObserver* aInner);
virtual ~ScriptedNotificationObserver() {}
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_IMGINOTIFICATIONOBSERVER
NS_DECL_CYCLE_COLLECTION_CLASS(ScriptedNotificationObserver)
private:
virtual ~ScriptedNotificationObserver() {}
nsCOMPtr<imgIScriptedNotificationObserver> mInner;
};

Просмотреть файл

@ -223,6 +223,7 @@ public:
os->AddObserver(mMemoryPressureObserver, "memory-pressure", false);
}
private:
virtual ~SurfaceCacheImpl()
{
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
@ -232,6 +233,7 @@ public:
UnregisterWeakMemoryReporter(this);
}
public:
void InitMemoryReporter() {
RegisterWeakMemoryReporter(this);
}
@ -417,8 +419,6 @@ private:
{
NS_DECL_ISUPPORTS
virtual ~MemoryPressureObserver() { }
NS_IMETHOD Observe(nsISupports*, const char* aTopic, const char16_t*)
{
if (sInstance && strcmp(aTopic, "memory-pressure") == 0) {
@ -426,6 +426,9 @@ private:
}
return NS_OK;
}
private:
virtual ~MemoryPressureObserver() { }
};

Просмотреть файл

@ -126,6 +126,7 @@ public:
mDocument->AddObserver(this);
}
private:
~SVGParseCompleteListener()
{
if (mDocument) {
@ -136,6 +137,7 @@ public:
}
}
public:
void EndLoad(nsIDocument* aDocument) MOZ_OVERRIDE
{
MOZ_ASSERT(aDocument == mDocument, "Got EndLoad for wrong document?");
@ -180,6 +182,7 @@ public:
mDocument->AddEventListener(NS_LITERAL_STRING("SVGError"), this, true, false);
}
private:
~SVGLoadEventListener()
{
if (mDocument) {
@ -190,6 +193,7 @@ public:
}
}
public:
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) MOZ_OVERRIDE
{
MOZ_ASSERT(mDocument, "Need an SVG document. Received multiple events?");

Просмотреть файл

@ -36,7 +36,6 @@ public:
NS_DECL_IMGICONTAINER
// (no public constructor - use ImageFactory)
virtual ~VectorImage();
// Methods inherited from Image
nsresult Init(const char* aMimeType,
@ -81,6 +80,7 @@ public:
protected:
VectorImage(imgStatusTracker* aStatusTracker = nullptr,
ImageURL* aURI = nullptr);
virtual ~VectorImage();
virtual nsresult StartAnimation();
virtual nsresult StopAnimation();

Просмотреть файл

@ -52,6 +52,8 @@ MOZ_DEFINE_MALLOC_SIZE_OF(ImagesMallocSizeOf)
class imgMemoryReporter MOZ_FINAL : public nsIMemoryReporter
{
~imgMemoryReporter() {}
public:
NS_DECL_ISUPPORTS
@ -842,6 +844,8 @@ nsresult imgLoader::CreateNewProxyForRequest(imgRequest *aRequest, nsILoadGroup
class imgCacheObserver MOZ_FINAL : public nsIObserver
{
~imgCacheObserver() {}
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER

Просмотреть файл

@ -211,6 +211,8 @@ class imgLoader : public imgILoader,
public nsSupportsWeakReference,
public nsIObserver
{
virtual ~imgLoader();
public:
typedef mozilla::image::ImageURL ImageURL;
typedef nsRefPtrHashtable<nsCStringHashKey, imgCacheEntry> imgCacheTable;
@ -225,7 +227,6 @@ public:
static imgLoader* PBSingleton();
imgLoader();
virtual ~imgLoader();
nsresult Init();
@ -399,7 +400,6 @@ class ProxyListener : public nsIStreamListener
{
public:
ProxyListener(nsIStreamListener *dest);
virtual ~ProxyListener();
/* additional members */
NS_DECL_ISUPPORTS
@ -408,6 +408,8 @@ public:
NS_DECL_NSIREQUESTOBSERVER
private:
virtual ~ProxyListener();
nsCOMPtr<nsIStreamListener> mDestListener;
};
@ -455,7 +457,6 @@ class imgCacheValidator : public nsIStreamListener,
public:
imgCacheValidator(nsProgressNotificationProxy* progress, imgLoader* loader,
imgRequest *request, void *aContext, bool forcePrincipalCheckForCacheEntry);
virtual ~imgCacheValidator();
void AddProxy(imgRequestProxy *aProxy);
@ -468,6 +469,8 @@ public:
NS_DECL_NSIASYNCVERIFYREDIRECTCALLBACK
private:
virtual ~imgCacheValidator();
nsCOMPtr<nsIStreamListener> mDestListener;
nsRefPtr<nsProgressNotificationProxy> mProgressProxy;
nsCOMPtr<nsIAsyncVerifyRedirectCallback> mRedirectCallback;

Просмотреть файл

@ -46,10 +46,11 @@ class imgRequest : public nsIStreamListener,
public nsIInterfaceRequestor,
public nsIAsyncVerifyRedirectCallback
{
virtual ~imgRequest();
public:
typedef mozilla::image::ImageURL ImageURL;
imgRequest(imgLoader* aLoader);
virtual ~imgRequest();
NS_DECL_THREADSAFE_ISUPPORTS

Просмотреть файл

@ -48,6 +48,9 @@ class imgRequestProxy : public imgIRequest,
public nsITimedChannel,
public mozilla::SupportsWeakPtr<imgRequestProxy>
{
protected:
virtual ~imgRequestProxy();
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(imgRequestProxy)
typedef mozilla::image::ImageURL ImageURL;
@ -59,7 +62,6 @@ public:
// nsITimedChannel declared below
imgRequestProxy();
virtual ~imgRequestProxy();
// Callers to Init or ChangeOwner are required to call NotifyListener after
// (although not immediately after) doing so.

Просмотреть файл

@ -21,5 +21,7 @@ public:
NS_DECL_IMGITOOLS
imgTools();
private:
virtual ~imgTools();
};