Skip to content

Commit

Permalink
Bug 1037691 - Fix instances where refcounted classes expose a public …
Browse files Browse the repository at this point in the history
…destructor. r=ehsan,bent,mayhemer,jrmuizel
  • Loading branch information
bgirard committed Jul 15, 2014
1 parent 2b38307 commit 1465e09
Show file tree
Hide file tree
Showing 69 changed files with 259 additions and 33 deletions.
11 changes: 10 additions & 1 deletion content/base/src/nsAttrValueInlines.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@

#include "nsAttrValue.h"

struct MiscContainer;

namespace mozilla {
template<>
struct HasDangerousPublicDestructor<MiscContainer>
{
static const bool value = true;
};
}

struct MiscContainer
{
typedef nsAttrValue::ValueType ValueType;
Expand Down Expand Up @@ -93,7 +103,6 @@ struct MiscContainer
void Evict();
};


/**
* Implementation of inline methods
*/
Expand Down
2 changes: 2 additions & 0 deletions content/base/src/nsDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1463,11 +1463,13 @@ class nsIDocument::SelectorCacheKeyDeleter MOZ_FINAL : public nsRunnable
MOZ_COUNT_CTOR(SelectorCacheKeyDeleter);
}

protected:
~SelectorCacheKeyDeleter()
{
MOZ_COUNT_DTOR(SelectorCacheKeyDeleter);
}

public:
NS_IMETHOD Run()
{
return NS_OK;
Expand Down
2 changes: 2 additions & 0 deletions content/media/AudioNodeExternalInputStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ namespace mozilla {
class AudioNodeExternalInputStream : public AudioNodeStream {
public:
AudioNodeExternalInputStream(AudioNodeEngine* aEngine, TrackRate aSampleRate);
protected:
~AudioNodeExternalInputStream();

public:
virtual void ProcessInput(GraphTime aFrom, GraphTime aTo, uint32_t aFlags) MOZ_OVERRIDE;

private:
Expand Down
3 changes: 3 additions & 0 deletions content/media/AudioNodeStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,11 @@ class AudioNodeStream : public ProcessedMediaStream {
mHasCurrentData = true;
MOZ_COUNT_CTOR(AudioNodeStream);
}

protected:
~AudioNodeStream();

public:
// Control API
/**
* Sets a parameter that's a time relative to some stream's played time.
Expand Down
2 changes: 2 additions & 0 deletions content/media/BufferMediaResource.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ class BufferMediaResource : public MediaResource
MOZ_COUNT_CTOR(BufferMediaResource);
}

protected:
virtual ~BufferMediaResource()
{
MOZ_COUNT_DTOR(BufferMediaResource);
}

private:
virtual nsresult Close() { return NS_OK; }
virtual void Suspend(bool aCloseImmediately) {}
virtual void Resume() {}
Expand Down
2 changes: 2 additions & 0 deletions content/media/FileBlockCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ class FileBlockCache : public nsRunnable {

FileBlockCache();

protected:
~FileBlockCache();

public:
// Assumes ownership of aFD.
nsresult Open(PRFileDesc* aFD);

Expand Down
4 changes: 4 additions & 0 deletions content/media/MediaDataDecodedListener.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,12 @@ class MediaDataDecodedListener : public RequestSampleCallback {
{
MOZ_COUNT_CTOR(DeliverAudioTask);
}
protected:
~DeliverAudioTask()
{
MOZ_COUNT_DTOR(DeliverAudioTask);
}
public:
NS_METHOD Run() {
mTarget->OnAudioDecoded(mSample.forget());
return NS_OK;
Expand All @@ -125,10 +127,12 @@ class MediaDataDecodedListener : public RequestSampleCallback {
{
MOZ_COUNT_CTOR(DeliverVideoTask);
}
protected:
~DeliverVideoTask()
{
MOZ_COUNT_DTOR(DeliverVideoTask);
}
public:
NS_METHOD Run() {
mTarget->OnVideoDecoded(mSample.forget());
return NS_OK;
Expand Down
2 changes: 2 additions & 0 deletions content/media/MediaResource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1639,11 +1639,13 @@ class DispatchBytesConsumedEvent : public nsRunnable {
MOZ_COUNT_CTOR(DispatchBytesConsumedEvent);
}

protected:
~DispatchBytesConsumedEvent()
{
MOZ_COUNT_DTOR(DispatchBytesConsumedEvent);
}

public:
NS_IMETHOD Run() {
mDecoder->NotifyBytesConsumed(mNumBytes, mOffset);
// Drop ref to decoder on main thread, just in case this reference
Expand Down
2 changes: 2 additions & 0 deletions content/media/mediasource/SourceBufferResource.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,10 @@ class SourceBufferResource MOZ_FINAL : public MediaResource
public:
SourceBufferResource(nsIPrincipal* aPrincipal,
const nsACString& aType);
protected:
~SourceBufferResource();

public:
virtual nsresult Close() MOZ_OVERRIDE;
virtual void Suspend(bool aCloseImmediately) MOZ_OVERRIDE {}
virtual void Resume() MOZ_OVERRIDE {}
Expand Down
3 changes: 3 additions & 0 deletions content/media/ogg/OggReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ class OggReader : public MediaDecoderReader
{
public:
OggReader(AbstractMediaDecoder* aDecoder);

protected:
~OggReader();

public:
virtual nsresult Init(MediaDecoderReader* aCloneDonor);
virtual nsresult ResetDecode();
virtual bool DecodeAudioData();
Expand Down
3 changes: 3 additions & 0 deletions content/media/raw/RawReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ class RawReader : public MediaDecoderReader
{
public:
RawReader(AbstractMediaDecoder* aDecoder);

protected:
~RawReader();

public:
virtual nsresult Init(MediaDecoderReader* aCloneDonor);
virtual nsresult ResetDecode();
virtual bool DecodeAudioData();
Expand Down
3 changes: 3 additions & 0 deletions content/media/wave/WaveReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ class WaveReader : public MediaDecoderReader
{
public:
WaveReader(AbstractMediaDecoder* aDecoder);

protected:
~WaveReader();

public:
virtual nsresult Init(MediaDecoderReader* aCloneDonor);
virtual bool DecodeAudioData();
virtual bool DecodeVideoFrame(bool &aKeyframeSkip,
Expand Down
3 changes: 3 additions & 0 deletions content/media/webm/WebMReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,11 @@ class WebMReader : public MediaDecoderReader
{
public:
WebMReader(AbstractMediaDecoder* aDecoder);

protected:
~WebMReader();

public:
virtual nsresult Init(MediaDecoderReader* aCloneDonor);
virtual nsresult ResetDecode();
virtual bool DecodeAudioData();
Expand Down
5 changes: 5 additions & 0 deletions content/xul/templates/src/nsRuleNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,13 @@ class MemoryElementSet {
public:
List() { MOZ_COUNT_CTOR(MemoryElementSet::List); }

protected:
~List() {
MOZ_COUNT_DTOR(MemoryElementSet::List);
delete mElement;
NS_IF_RELEASE(mNext); }

public:
int32_t AddRef() { return ++mRefCnt; }

int32_t Release() {
Expand Down Expand Up @@ -231,10 +233,13 @@ class nsAssignmentSet {
List(const nsAssignment &aAssignment) : mAssignment(aAssignment) {
MOZ_COUNT_CTOR(nsAssignmentSet::List); }

protected:
~List() {
MOZ_COUNT_DTOR(nsAssignmentSet::List);
NS_IF_RELEASE(mNext); }

public:

int32_t AddRef() { return ++mRefCnt; }

int32_t Release() {
Expand Down
2 changes: 2 additions & 0 deletions dom/archivereader/ArchiveEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ class ArchiveReaderEvent : public nsRunnable

ArchiveReaderEvent(ArchiveReader* aArchiveReader);

protected:
virtual ~ArchiveReaderEvent();

public:
// This must be implemented
virtual nsresult Exec() = 0;

Expand Down
1 change: 1 addition & 0 deletions dom/archivereader/ArchiveRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class ArchiveRequestEvent : public nsRunnable
MOZ_COUNT_CTOR(ArchiveRequestEvent);
}

protected:
~ArchiveRequestEvent()
{
MOZ_COUNT_DTOR(ArchiveRequestEvent);
Expand Down
2 changes: 2 additions & 0 deletions dom/archivereader/ArchiveZipEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ class ArchiveZipItem : public ArchiveItem
ArchiveZipItem(const char* aFilename,
const ZipCentral& aCentralStruct,
const nsACString& aEncoding);
protected:
virtual ~ArchiveZipItem();

public:
nsresult GetFilename(nsString& aFilename) MOZ_OVERRIDE;

// From zipItem to DOMFile:
Expand Down
2 changes: 2 additions & 0 deletions dom/asmjscache/AsmJSCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,7 @@ class SingleProcessRunnable MOZ_FINAL : public File,
MOZ_COUNT_CTOR(SingleProcessRunnable);
}

protected:
~SingleProcessRunnable()
{
MOZ_COUNT_DTOR(SingleProcessRunnable);
Expand Down Expand Up @@ -1370,6 +1371,7 @@ class ChildProcessRunnable MOZ_FINAL : public File,
MOZ_COUNT_CTOR(ChildProcessRunnable);
}

protected:
~ChildProcessRunnable()
{
MOZ_ASSERT(mState == eFinished);
Expand Down
4 changes: 3 additions & 1 deletion dom/base/nsGlobalWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7839,12 +7839,14 @@ class PostMessageEvent : public nsRunnable
{
MOZ_COUNT_CTOR(PostMessageEvent);
}


protected:
~PostMessageEvent()
{
MOZ_COUNT_DTOR(PostMessageEvent);
}

public:
JSAutoStructuredCloneBuffer& Buffer()
{
return mBuffer;
Expand Down
3 changes: 3 additions & 0 deletions dom/camera/DOMCameraControlListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,14 @@ class DOMCameraControlListener::DOMCallback : public nsRunnable
{
MOZ_COUNT_CTOR(DOMCameraControlListener::DOMCallback);
}

protected:
virtual ~DOMCallback()
{
MOZ_COUNT_DTOR(DOMCameraControlListener::DOMCallback);
}

public:
virtual void RunCallback(nsDOMCameraControl* aDOMCameraControl) = 0;

NS_IMETHOD
Expand Down
4 changes: 4 additions & 0 deletions dom/promise/Promise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ class PromiseTask MOZ_FINAL : public nsRunnable
MOZ_COUNT_CTOR(PromiseTask);
}

protected:
~PromiseTask()
{
MOZ_COUNT_DTOR(PromiseTask);
}

public:
NS_IMETHOD Run()
{
mPromise->mTaskPending = false;
Expand All @@ -70,11 +72,13 @@ class WorkerPromiseTask MOZ_FINAL : public WorkerSameThreadRunnable
MOZ_COUNT_CTOR(WorkerPromiseTask);
}

protected:
~WorkerPromiseTask()
{
MOZ_COUNT_DTOR(WorkerPromiseTask);
}

public:
bool
WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
{
Expand Down
3 changes: 3 additions & 0 deletions dom/src/storage/DOMStorageCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,11 @@ class DOMStorageCache : public DOMStorageCacheBridge
NS_IMETHOD_(void) Release(void);

DOMStorageCache(const nsACString* aScope);

protected:
virtual ~DOMStorageCache();

public:
void Init(DOMStorageManager* aManager, bool aPersistent, nsIPrincipal* aPrincipal,
const nsACString& aQuotaScope);

Expand Down
3 changes: 3 additions & 0 deletions gfx/layers/CopyableCanvasLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ class CopyableCanvasLayer : public CanvasLayer
{
public:
CopyableCanvasLayer(LayerManager* aLayerManager, void *aImplData);

protected:
virtual ~CopyableCanvasLayer();

public:
virtual void Initialize(const Data& aData);

virtual bool IsDataValid(const Data& aData);
Expand Down
3 changes: 3 additions & 0 deletions gfx/layers/basic/BasicColorLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ class BasicColorLayer : public ColorLayer, public BasicImplData {
{
MOZ_COUNT_CTOR(BasicColorLayer);
}

protected:
virtual ~BasicColorLayer()
{
MOZ_COUNT_DTOR(BasicColorLayer);
}

public:
virtual void SetVisibleRegion(const nsIntRegion& aRegion)
{
NS_ASSERTION(BasicManager()->InConstruction(),
Expand Down
3 changes: 2 additions & 1 deletion gfx/layers/basic/BasicCompositor.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ class BasicCompositor : public Compositor
public:
BasicCompositor(nsIWidget *aWidget);

protected:
virtual ~BasicCompositor();


public:
virtual bool Initialize() MOZ_OVERRIDE { return true; };

virtual void Destroy() MOZ_OVERRIDE;
Expand Down
2 changes: 2 additions & 0 deletions gfx/layers/basic/BasicContainerLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ class BasicContainerLayer : public ContainerLayer, public BasicImplData {
MOZ_COUNT_CTOR(BasicContainerLayer);
mSupportsComponentAlphaChildren = true;
}
protected:
virtual ~BasicContainerLayer();

public:
virtual void SetVisibleRegion(const nsIntRegion& aRegion)
{
NS_ASSERTION(BasicManager()->InConstruction(),
Expand Down
2 changes: 2 additions & 0 deletions gfx/layers/basic/BasicImageLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ class BasicImageLayer : public ImageLayer, public BasicImplData {
{
MOZ_COUNT_CTOR(BasicImageLayer);
}
protected:
virtual ~BasicImageLayer()
{
MOZ_COUNT_DTOR(BasicImageLayer);
}

public:
virtual void SetVisibleRegion(const nsIntRegion& aRegion)
{
NS_ASSERTION(BasicManager()->InConstruction(),
Expand Down
Loading

0 comments on commit 1465e09

Please sign in to comment.