Bug 984786 part 5: Give NS_INLINE_DECL_*REFCOUNTING classes private/protected destructor & MOZ_FINAL annotation where appropriate, in /content/media. r=kinetik

This commit is contained in:
Daniel Holbert 2014-04-02 09:21:11 -07:00
parent d7bc9bd2fc
commit 00dc4bbe3f
7 changed files with 47 additions and 18 deletions

View File

@ -85,7 +85,7 @@ public:
// Represents a change yet to be made to a block in the file. The change // Represents a change yet to be made to a block in the file. The change
// is either a write (and the data to be written is stored in this struct) // is either a write (and the data to be written is stored in this struct)
// or a move (and the index of the source block is stored instead). // or a move (and the index of the source block is stored instead).
struct BlockChange { struct BlockChange MOZ_FINAL {
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BlockChange) NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BlockChange)
@ -113,6 +113,12 @@ public:
return mSourceBlockIndex == -1 && return mSourceBlockIndex == -1 &&
mData.get() != nullptr; mData.get() != nullptr;
} }
private:
// Private destructor, to discourage deletion outside of Release():
~BlockChange()
{
}
}; };
class Int32Queue : private nsDeque { class Int32Queue : private nsDeque {

View File

@ -89,9 +89,11 @@ class MediaStreamGraph;
* attached to a stream that has already finished, we'll call NotifyFinished. * attached to a stream that has already finished, we'll call NotifyFinished.
*/ */
class MediaStreamListener { class MediaStreamListener {
public: protected:
// Protected destructor, to discourage deletion outside of Release():
virtual ~MediaStreamListener() {} virtual ~MediaStreamListener() {}
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaStreamListener) NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaStreamListener)
enum Consumption { enum Consumption {
@ -291,6 +293,9 @@ public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaStream) NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaStream)
MediaStream(DOMMediaStream* aWrapper); MediaStream(DOMMediaStream* aWrapper);
protected:
// Protected destructor, to discourage deletion outside of Release():
virtual ~MediaStream() virtual ~MediaStream()
{ {
MOZ_COUNT_DTOR(MediaStream); MOZ_COUNT_DTOR(MediaStream);
@ -299,6 +304,7 @@ public:
"All main thread listeners should have been removed"); "All main thread listeners should have been removed");
} }
public:
/** /**
* Returns the graph that owns this stream. * Returns the graph that owns this stream.
*/ */
@ -810,7 +816,8 @@ protected:
* the Destroy message is processed on the graph manager thread we disconnect * the Destroy message is processed on the graph manager thread we disconnect
* the port and drop the graph's reference, destroying the object. * the port and drop the graph's reference, destroying the object.
*/ */
class MediaInputPort { class MediaInputPort MOZ_FINAL {
private:
// Do not call this constructor directly. Instead call aDest->AllocateInputPort. // Do not call this constructor directly. Instead call aDest->AllocateInputPort.
MediaInputPort(MediaStream* aSource, ProcessedMediaStream* aDest, MediaInputPort(MediaStream* aSource, ProcessedMediaStream* aDest,
uint32_t aFlags, uint16_t aInputNumber, uint32_t aFlags, uint16_t aInputNumber,
@ -825,6 +832,12 @@ class MediaInputPort {
MOZ_COUNT_CTOR(MediaInputPort); MOZ_COUNT_CTOR(MediaInputPort);
} }
// Private destructor, to discourage deletion outside of Release():
~MediaInputPort()
{
MOZ_COUNT_DTOR(MediaInputPort);
}
public: public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaInputPort) NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaInputPort)
@ -841,10 +854,6 @@ public:
// stream. // stream.
FLAG_BLOCK_OUTPUT = 0x02 FLAG_BLOCK_OUTPUT = 0x02
}; };
~MediaInputPort()
{
MOZ_COUNT_DTOR(MediaInputPort);
}
// Called on graph manager thread // Called on graph manager thread
// Do not call these from outside MediaStreamGraph.cpp! // Do not call these from outside MediaStreamGraph.cpp!
@ -886,7 +895,7 @@ public:
*/ */
void SetGraphImpl(MediaStreamGraphImpl* aGraph); void SetGraphImpl(MediaStreamGraphImpl* aGraph);
protected: private:
friend class MediaStreamGraphImpl; friend class MediaStreamGraphImpl;
friend class MediaStream; friend class MediaStream;
friend class ProcessedMediaStream; friend class ProcessedMediaStream;

View File

@ -19,6 +19,9 @@ namespace mozilla {
class ThreadSharedObject { class ThreadSharedObject {
public: public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ThreadSharedObject) NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ThreadSharedObject)
protected:
// Protected destructor, to discourage deletion outside of Release():
virtual ~ThreadSharedObject() {} virtual ~ThreadSharedObject() {}
}; };

View File

@ -38,7 +38,7 @@ private:
}; };
// Represent one encoded frame // Represent one encoded frame
class EncodedFrame class EncodedFrame MOZ_FINAL
{ {
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(EncodedFrame) NS_INLINE_DECL_THREADSAFE_REFCOUNTING(EncodedFrame)
public: public:
@ -90,6 +90,11 @@ public:
FrameType GetFrameType() const { return mFrameType; } FrameType GetFrameType() const { return mFrameType; }
void SetFrameType(FrameType aFrameType) { mFrameType = aFrameType; } void SetFrameType(FrameType aFrameType) { mFrameType = aFrameType; }
private: private:
// Private destructor, to discourage deletion outside of Release():
~EncodedFrame()
{
}
// Encoded data // Encoded data
nsTArray<uint8_t> mFrameData; nsTArray<uint8_t> mFrameData;
uint64_t mTimeStamp; uint64_t mTimeStamp;

View File

@ -24,9 +24,12 @@ public:
METADATA_AMR, METADATA_AMR,
METADATA_UNKNOWN // Metadata Kind not set METADATA_UNKNOWN // Metadata Kind not set
}; };
virtual ~TrackMetadataBase() {}
// Return the specific metadata kind // Return the specific metadata kind
virtual MetadataKind GetKind() const = 0; virtual MetadataKind GetKind() const = 0;
protected:
// Protected destructor, to discourage deletion outside of Release():
virtual ~TrackMetadataBase() {}
}; };
// The base class for audio metadata. // The base class for audio metadata.

View File

@ -182,7 +182,7 @@ private:
uint32_t mSkipBytes; uint32_t mSkipBytes;
}; };
class WebMBufferedState class WebMBufferedState MOZ_FINAL
{ {
NS_INLINE_DECL_REFCOUNTING(WebMBufferedState) NS_INLINE_DECL_REFCOUNTING(WebMBufferedState)
@ -191,15 +191,16 @@ public:
MOZ_COUNT_CTOR(WebMBufferedState); MOZ_COUNT_CTOR(WebMBufferedState);
} }
~WebMBufferedState() {
MOZ_COUNT_DTOR(WebMBufferedState);
}
void NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset); void NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset);
bool CalculateBufferedForRange(int64_t aStartOffset, int64_t aEndOffset, bool CalculateBufferedForRange(int64_t aStartOffset, int64_t aEndOffset,
uint64_t* aStartTime, uint64_t* aEndTime); uint64_t* aStartTime, uint64_t* aEndTime);
private: private:
// Private destructor, to discourage deletion outside of Release():
~WebMBufferedState() {
MOZ_COUNT_DTOR(WebMBufferedState);
}
// Synchronizes access to the mTimeMapping array. // Synchronizes access to the mTimeMapping array.
ReentrantMonitor mReentrantMonitor; ReentrantMonitor mReentrantMonitor;

View File

@ -67,8 +67,12 @@ namespace dom {
// VoiceData // VoiceData
class VoiceData class VoiceData MOZ_FINAL
{ {
private:
// Private destructor, to discourage deletion outside of Release():
~VoiceData() {}
public: public:
VoiceData(nsISpeechService* aService, const nsAString& aUri, VoiceData(nsISpeechService* aService, const nsAString& aUri,
const nsAString& aName, const nsAString& aLang, bool aIsLocal) const nsAString& aName, const nsAString& aLang, bool aIsLocal)
@ -78,8 +82,6 @@ public:
, mLang(aLang) , mLang(aLang)
, mIsLocal(aIsLocal) {} , mIsLocal(aIsLocal) {}
~VoiceData() {}
NS_INLINE_DECL_REFCOUNTING(VoiceData) NS_INLINE_DECL_REFCOUNTING(VoiceData)
nsCOMPtr<nsISpeechService> mService; nsCOMPtr<nsISpeechService> mService;