From 5c98e287b81da91508ed70a47bd9e8da2fe5c4f0 Mon Sep 17 00:00:00 2001 From: Matthew Gregan Date: Sun, 22 Jun 2014 16:43:00 +1200 Subject: [PATCH] Bug 1028146 - Remove dangerous public destructor of MediaChannelStatistics. r=cpearce --- content/media/MediaDecoder.cpp | 5 +++-- content/media/MediaDecoder.h | 6 +++--- content/media/MediaResource.h | 7 +------ 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/content/media/MediaDecoder.cpp b/content/media/MediaDecoder.cpp index a201ecdf362..8652b4fec3c 100644 --- a/content/media/MediaDecoder.cpp +++ b/content/media/MediaDecoder.cpp @@ -429,6 +429,7 @@ MediaDecoder::MediaDecoder() : mIgnoreProgressData(false), mInfiniteStream(false), mOwner(nullptr), + mPlaybackStatistics(new MediaChannelStatistics()), mPinnedForSeek(false), mShuttingDown(false), mPausedForPlaybackRateNull(false), @@ -940,7 +941,7 @@ double MediaDecoder::ComputePlaybackRate(bool* aReliable) *aReliable = true; return length * static_cast(USECS_PER_S) / mDuration; } - return mPlaybackStatistics.GetRateAtLastStop(aReliable); + return mPlaybackStatistics->GetRateAtLastStop(aReliable); } void MediaDecoder::UpdatePlaybackRate() @@ -1032,7 +1033,7 @@ void MediaDecoder::NotifyBytesConsumed(int64_t aBytes, int64_t aOffset) return; } if (aOffset >= mDecoderPosition) { - mPlaybackStatistics.AddBytes(aBytes); + mPlaybackStatistics->AddBytes(aBytes); } mDecoderPosition = aOffset + aBytes; } diff --git a/content/media/MediaDecoder.h b/content/media/MediaDecoder.h index e58468a8eb7..1fe7533d498 100755 --- a/content/media/MediaDecoder.h +++ b/content/media/MediaDecoder.h @@ -718,14 +718,14 @@ public: // Records activity stopping on the channel. The monitor must be held. virtual void NotifyPlaybackStarted() { GetReentrantMonitor().AssertCurrentThreadIn(); - mPlaybackStatistics.Start(); + mPlaybackStatistics->Start(); } // Used to estimate rates of data passing through the decoder's channel. // Records activity stopping on the channel. The monitor must be held. virtual void NotifyPlaybackStopped() { GetReentrantMonitor().AssertCurrentThreadIn(); - mPlaybackStatistics.Stop(); + mPlaybackStatistics->Stop(); } // The actual playback rate computation. The monitor must be held. @@ -1194,7 +1194,7 @@ protected: // Data needed to estimate playback data rate. The timeline used for // this estimate is "decode time" (where the "current time" is the // time of the last decoded video frame). - MediaChannelStatistics mPlaybackStatistics; + nsRefPtr mPlaybackStatistics; // True when our media stream has been pinned. We pin the stream // while seeking. diff --git a/content/media/MediaResource.h b/content/media/MediaResource.h index d8aeb4ebbb8..387b0aff69c 100644 --- a/content/media/MediaResource.h +++ b/content/media/MediaResource.h @@ -38,12 +38,6 @@ namespace mozilla { class MediaDecoder; class MediaChannelStatistics; -template<> -struct HasDangerousPublicDestructor -{ - static const bool value = true; -}; - /** * This class is useful for estimating rates of data passing through * some channel. The idea is that activity on the channel "starts" @@ -119,6 +113,7 @@ public: return static_cast(mAccumulatedBytes)/seconds; } private: + ~MediaChannelStatistics() {} int64_t mAccumulatedBytes; TimeDuration mAccumulatedTime; TimeStamp mLastStartTime;