[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor-browser] 29/73: Bug 1781759 factor out ChannelMediaResource::MediaElement() helper r=chunmin a=RyanVM



This is an automated email from the git hooks/post-receive script.

richard pushed a commit to branch geckoview-102.3.0esr-12.0-1
in repository tor-browser.

commit 06dd4b32f0e4432646d3d7c5ecbf9597ec3f91ec
Author: Karl Tomlinson <karlt+@xxxxxxxxx>
AuthorDate: Tue Aug 23 00:23:51 2022 +0000

    Bug 1781759 factor out ChannelMediaResource::MediaElement() helper r=chunmin a=RyanVM
    
    Differential Revision: https://phabricator.services.mozilla.com/D154039
---
 dom/media/ChannelMediaResource.cpp | 36 ++++++++++++++----------------------
 dom/media/ChannelMediaResource.h   |  2 ++
 2 files changed, 16 insertions(+), 22 deletions(-)

diff --git a/dom/media/ChannelMediaResource.cpp b/dom/media/ChannelMediaResource.cpp
index 804884b1e359e..7266998f60fc9 100644
--- a/dom/media/ChannelMediaResource.cpp
+++ b/dom/media/ChannelMediaResource.cpp
@@ -512,6 +512,15 @@ nsresult ChannelMediaResource::Open(nsIStreamListener** aStreamListener) {
   return NS_OK;
 }
 
+dom::HTMLMediaElement* ChannelMediaResource::MediaElement() const {
+  MOZ_ASSERT(NS_IsMainThread());
+  MediaDecoderOwner* owner = mCallback->GetMediaOwner();
+  MOZ_DIAGNOSTIC_ASSERT(owner);
+  dom::HTMLMediaElement* element = owner->GetMediaElement();
+  MOZ_DIAGNOSTIC_ASSERT(element);
+  return element;
+}
+
 nsresult ChannelMediaResource::OpenChannel(int64_t aOffset) {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_DIAGNOSTIC_ASSERT(!mClosed);
@@ -529,11 +538,7 @@ nsresult ChannelMediaResource::OpenChannel(int64_t aOffset) {
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Tell the media element that we are fetching data from a channel.
-  MediaDecoderOwner* owner = mCallback->GetMediaOwner();
-  MOZ_DIAGNOSTIC_ASSERT(owner);
-  dom::HTMLMediaElement* element = owner->GetMediaElement();
-  MOZ_DIAGNOSTIC_ASSERT(element);
-  element->DownloadResumed();
+  MediaElement()->DownloadResumed();
 
   return NS_OK;
 }
@@ -556,11 +561,7 @@ nsresult ChannelMediaResource::SetupChannelHeaders(int64_t aOffset) {
     NS_ENSURE_SUCCESS(rv, rv);
 
     // Send Accept header for video and audio types only (Bug 489071)
-    MediaDecoderOwner* owner = mCallback->GetMediaOwner();
-    MOZ_DIAGNOSTIC_ASSERT(owner);
-    dom::HTMLMediaElement* element = owner->GetMediaElement();
-    MOZ_DIAGNOSTIC_ASSERT(element);
-    element->SetRequestHeaders(hc);
+    MediaElement()->SetRequestHeaders(hc);
   } else {
     NS_ASSERTION(aOffset == 0, "Don't know how to seek on this channel type");
     return NS_ERROR_FAILURE;
@@ -669,10 +670,7 @@ void ChannelMediaResource::Suspend(bool aCloseImmediately) {
     return;
   }
 
-  MediaDecoderOwner* owner = mCallback->GetMediaOwner();
-  MOZ_DIAGNOSTIC_ASSERT(owner);
-  dom::HTMLMediaElement* element = owner->GetMediaElement();
-  MOZ_DIAGNOSTIC_ASSERT(element);
+  dom::HTMLMediaElement* element = MediaElement();
 
   if (mChannel && aCloseImmediately && mIsTransportSeekable) {
     CloseChannel();
@@ -691,10 +689,7 @@ void ChannelMediaResource::Resume() {
     return;
   }
 
-  MediaDecoderOwner* owner = mCallback->GetMediaOwner();
-  MOZ_DIAGNOSTIC_ASSERT(owner);
-  dom::HTMLMediaElement* element = owner->GetMediaElement();
-  MOZ_DIAGNOSTIC_ASSERT(element);
+  dom::HTMLMediaElement* element = MediaElement();
 
   if (mSuspendAgent.Resume()) {
     if (mChannel) {
@@ -712,10 +707,7 @@ nsresult ChannelMediaResource::RecreateChannel() {
   nsLoadFlags loadFlags = nsICachingChannel::LOAD_BYPASS_LOCAL_CACHE_IF_BUSY |
                           (mLoadInBackground ? nsIRequest::LOAD_BACKGROUND : 0);
 
-  MediaDecoderOwner* owner = mCallback->GetMediaOwner();
-  MOZ_DIAGNOSTIC_ASSERT(owner);
-  dom::HTMLMediaElement* element = owner->GetMediaElement();
-  MOZ_DIAGNOSTIC_ASSERT(element);
+  dom::HTMLMediaElement* element = MediaElement();
 
   nsCOMPtr<nsILoadGroup> loadGroup = element->GetDocumentLoadGroup();
   NS_ENSURE_TRUE(loadGroup, NS_ERROR_NULL_POINTER);
diff --git a/dom/media/ChannelMediaResource.h b/dom/media/ChannelMediaResource.h
index 695e490c6f7c0..892dca1de081d 100644
--- a/dom/media/ChannelMediaResource.h
+++ b/dom/media/ChannelMediaResource.h
@@ -213,6 +213,8 @@ class ChannelMediaResource
   nsresult OnChannelRedirect(nsIChannel* aOld, nsIChannel* aNew,
                              uint32_t aFlags, int64_t aOffset);
 
+  // Use only before MediaDecoder shutdown.  Main thread only.
+  dom::HTMLMediaElement* MediaElement() const;
   // Opens the channel, using an HTTP byte range request to start at aOffset
   // if possible. Main thread only.
   nsresult OpenChannel(int64_t aOffset);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits