Bug 1347402 part 1 - call DownloadSuspended() via polymorphism; r?jwwang
Instead of calling DownloadSuspended() via a pointer to a HTMLMediaElement,
we should call DownloadSuspended() via a pointer to a MediaDecoderOwner.
MozReview-Commit-ID: BvExQuchsWb
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -247,20 +247,20 @@ MediaDecoder::ResourceCallback::NotifyDa
{
RefPtr<ResourceCallback> self = this;
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction([=] () {
if (!self->mDecoder) {
return;
}
self->mDecoder->NotifyDownloadEnded(aStatus);
if (NS_SUCCEEDED(aStatus)) {
- HTMLMediaElement* element = self->GetMediaOwner()->GetMediaElement();
- if (element) {
- element->DownloadSuspended();
- }
+ MediaDecoderOwner* owner = self->GetMediaOwner();
+ MOZ_ASSERT(owner);
+ owner->DownloadSuspended();
+
// NotifySuspendedStatusChanged will tell the element that download
// has been suspended "by the cache", which is true since we never
// download anything. The element can then transition to HAVE_ENOUGH_DATA.
self->mDecoder->NotifySuspendedStatusChanged();
}
});
mAbstractMainThread->Dispatch(r.forget());
}