Bug 1034907 - Remove dangerous public destructor of TimeRanges. r=smaug

This commit is contained in:
Michael Pruett 2014-07-12 20:26:21 -05:00
parent 06db3abb67
commit 73b88d19fd
3 changed files with 13 additions and 19 deletions

View File

@ -1430,13 +1430,13 @@ HTMLMediaElement::Seek(double aTime,
}
// Clamp the seek target to inside the seekable ranges.
dom::TimeRanges seekable;
if (NS_FAILED(mDecoder->GetSeekable(&seekable))) {
nsRefPtr<dom::TimeRanges> seekable = new dom::TimeRanges();
if (NS_FAILED(mDecoder->GetSeekable(seekable))) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
uint32_t length = 0;
seekable.GetLength(&length);
seekable->GetLength(&length);
if (!length) {
return;
}
@ -1448,7 +1448,7 @@ HTMLMediaElement::Seek(double aTime,
// http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#seeking
int32_t range = 0;
bool isInRange = false;
if (NS_FAILED(IsInRanges(seekable, aTime, isInRange, range))) {
if (NS_FAILED(IsInRanges(*seekable, aTime, isInRange, range))) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
@ -1458,11 +1458,11 @@ HTMLMediaElement::Seek(double aTime,
// for |range| is -1.
if (uint32_t(range + 1) < length) {
double leftBound, rightBound;
if (NS_FAILED(seekable.End(range, &leftBound))) {
if (NS_FAILED(seekable->End(range, &leftBound))) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
if (NS_FAILED(seekable.Start(range + 1, &rightBound))) {
if (NS_FAILED(seekable->Start(range + 1, &rightBound))) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
@ -1477,7 +1477,7 @@ HTMLMediaElement::Seek(double aTime,
} else {
// Seek target is after the end last range in seekable data.
// Clamp the seek target to the end of the last seekable range.
if (NS_FAILED(seekable.End(length - 1, &aTime))) {
if (NS_FAILED(seekable->End(length - 1, &aTime))) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
@ -1485,7 +1485,7 @@ HTMLMediaElement::Seek(double aTime,
} else {
// aTime is before the first range in |seekable|, the closest point we can
// seek to is the start of the first range.
seekable.Start(0, &aTime);
seekable->Start(0, &aTime);
}
}

View File

@ -21,12 +21,6 @@ class TimeRanges;
}
template<>
struct HasDangerousPublicDestructor<dom::TimeRanges>
{
static const bool value = true;
};
namespace dom {
// Implements media TimeRanges:
@ -38,7 +32,6 @@ public:
NS_DECL_NSIDOMTIMERANGES
TimeRanges();
~TimeRanges();
void Add(double aStart, double aEnd);
@ -63,6 +56,7 @@ public:
virtual double End(uint32_t aIndex, ErrorResult& aRv);
private:
~TimeRanges();
// Comparator which orders TimeRanges by start time. Used by Normalize().
struct TimeRange

View File

@ -1429,15 +1429,15 @@ void MediaDecoderStateMachine::NotifyDataArrived(const char* aBuffer,
// faster than played, mEndTime won't reflect the end of playable data
// since we haven't played the frame at the end of buffered data. So update
// mEndTime here as new data is downloaded to prevent such a lag.
dom::TimeRanges buffered;
nsRefPtr<dom::TimeRanges> buffered = new dom::TimeRanges();
if (mDecoder->IsInfinite() &&
NS_SUCCEEDED(mDecoder->GetBuffered(&buffered)))
NS_SUCCEEDED(mDecoder->GetBuffered(buffered)))
{
uint32_t length = 0;
buffered.GetLength(&length);
buffered->GetLength(&length);
if (length) {
double end = 0;
buffered.End(length - 1, &end);
buffered->End(length - 1, &end);
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
mEndTime = std::max<int64_t>(mEndTime, end * USECS_PER_S);
}