From e372b0a90fc8c21d6dd588c244c9b0de19abc091 Mon Sep 17 00:00:00 2001 From: Honza Bambas Date: Fri, 4 Aug 2017 04:38:00 +0200 Subject: [PATCH] Bug 1377206 - Explicitly disable throttling of media HTTP responses, r=cpearce --HG-- extra : rebase_source : 01f913c44c7ce02bedd733faaf11262353f3461d --- dom/html/HTMLMediaElement.cpp | 19 ++++++++++++------- dom/media/MediaResource.cpp | 8 ++++++++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp index 86f0787ac284..2b68118db772 100644 --- a/dom/html/HTMLMediaElement.cpp +++ b/dom/html/HTMLMediaElement.cpp @@ -1196,14 +1196,19 @@ public: return; } - nsCOMPtr cos; - if (aElement->mUseUrgentStartForChannel && - (cos = do_QueryInterface(channel))) { - cos->AddClassFlags(nsIClassOfService::UrgentStart); + nsCOMPtr cos(do_QueryInterface(channel)); + if (cos) { + if (aElement->mUseUrgentStartForChannel) { + cos->AddClassFlags(nsIClassOfService::UrgentStart); - // Reset the flag to avoid loading again without initiated by user - // interaction. - aElement->mUseUrgentStartForChannel = false; + // Reset the flag to avoid loading again without initiated by user + // interaction. + aElement->mUseUrgentStartForChannel = false; + } + + // Unconditionally disable throttling since we want the media to fluently + // play even when we switch the tab to background. + cos->AddClassFlags(nsIClassOfService::DontThrottle); } // The listener holds a strong reference to us. This creates a diff --git a/dom/media/MediaResource.cpp b/dom/media/MediaResource.cpp index 9c5a5e5c4423..691fabcb41d8 100644 --- a/dom/media/MediaResource.cpp +++ b/dom/media/MediaResource.cpp @@ -14,6 +14,7 @@ #include "nsDebug.h" #include "nsNetUtil.h" #include "nsThreadUtils.h" +#include "nsIClassOfService.h" #include "nsIFile.h" #include "nsIFileChannel.h" #include "nsIFileStreams.h" @@ -847,6 +848,13 @@ ChannelMediaResource::RecreateChannel() loadFlags); NS_ENSURE_SUCCESS(rv, rv); + nsCOMPtr cos(do_QueryInterface(mChannel)); + if (cos) { + // Unconditionally disable throttling since we want the media to fluently + // play even when we switch the tab to background. + cos->AddClassFlags(nsIClassOfService::DontThrottle); + } + mSuspendAgent.NotifyChannelOpened(mChannel); // Tell the cache to reset the download status when the channel is reopened.