Bug 1347402 part 1 - call DownloadSuspended() via polymorphism; r?jwwang draft
authorKaku Kuo <kaku@mozilla.com>
Wed, 15 Mar 2017 11:20:57 +0800
changeset 500352 6edf5eef27d110c00369e7da2562fd39591d7a99
parent 500240 39607304b774591fa6e32c4b06158d869483c312
child 500353 b5c8187ed786aff6c72462d665d79488c574b780
push id49701
push userbmo:kaku@mozilla.com
push dateFri, 17 Mar 2017 03:54:30 +0000
reviewersjwwang
bugs1347402
milestone55.0a1
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
dom/media/MediaDecoder.cpp
--- 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());
 }