Bug 1028146 - Remove dangerous public destructor of MediaChannelStatistics. r=cpearce

This commit is contained in:
Matthew Gregan 2014-06-22 16:43:00 +12:00
parent 8bbe3536e3
commit 5c98e287b8
3 changed files with 7 additions and 11 deletions

View File

@ -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<double>(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;
}

View File

@ -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<MediaChannelStatistics> mPlaybackStatistics;
// True when our media stream has been pinned. We pin the stream
// while seeking.

View File

@ -38,12 +38,6 @@ namespace mozilla {
class MediaDecoder;
class MediaChannelStatistics;
template<>
struct HasDangerousPublicDestructor<MediaChannelStatistics>
{
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<double>(mAccumulatedBytes)/seconds;
}
private:
~MediaChannelStatistics() {}
int64_t mAccumulatedBytes;
TimeDuration mAccumulatedTime;
TimeStamp mLastStartTime;