Bug 758481 - When seeking in an unbuffered range after having ended a media, networkState is NETWORK_IDLE r=chris.double
authorChris Double <chris.double@double.co.nz>
Thu, 31 May 2012 14:30:23 +1200
changeset 99394 28fe5eec1ca3b7ffc5ba1b4be231f4928e5210e6
parent 99393 ff89c3c866e0a237122e88f8ac86f5dc77b5b250
child 99395 843c0d2aafaf992f0544b9eb762dd108b9d75fae
push id1116
push userlsblakk@mozilla.com
push dateMon, 16 Jul 2012 19:38:18 +0000
treeherdermozilla-beta@95f959a8b4dc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschris
bugs758481
milestone15.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 758481 - When seeking in an unbuffered range after having ended a media, networkState is NETWORK_IDLE r=chris.double
content/html/content/public/nsHTMLMediaElement.h
content/html/content/src/nsHTMLMediaElement.cpp
content/media/MediaResource.cpp
--- a/content/html/content/public/nsHTMLMediaElement.h
+++ b/content/html/content/public/nsHTMLMediaElement.h
@@ -148,17 +148,21 @@ public:
   // Called by the media stream, on the main thread, when the download
   // has been suspended by the cache or because the element itself
   // asked the decoder to suspend the download.
   void DownloadSuspended();
 
   // Called by the media stream, on the main thread, when the download
   // has been resumed by the cache or because the element itself
   // asked the decoder to resumed the download.
-  void DownloadResumed();
+  // If aForceNetworkLoading is True, ignore the fact that the download has
+  // previously finished. We are downloading the middle of the media after
+  // having downloaded the end, we need to notify the element a download in
+  // ongoing.
+  void DownloadResumed(bool aForceNetworkLoading = false);
 
   // Called by the media decoder to indicate that the download has stalled
   // (no data has arrived for a while).
   void DownloadStalled();
 
   // Called by the media decoder to indicate whether the media cache has
   // suspended the channel.
   void NotifySuspendedByCache(bool aIsSuspended);
--- a/content/html/content/src/nsHTMLMediaElement.cpp
+++ b/content/html/content/src/nsHTMLMediaElement.cpp
@@ -2774,19 +2774,19 @@ void nsHTMLMediaElement::DownloadSuspend
   DispatchAsyncEvent(NS_LITERAL_STRING("progress"));
   if (mBegun) {
     mNetworkState = nsIDOMHTMLMediaElement::NETWORK_IDLE;
     AddRemoveSelfReference();
     DispatchAsyncEvent(NS_LITERAL_STRING("suspend"));
   }
 }
 
-void nsHTMLMediaElement::DownloadResumed()
+void nsHTMLMediaElement::DownloadResumed(bool aForceNetworkLoading)
 {
-  if (mBegun) {
+  if (mBegun || aForceNetworkLoading) {
     mNetworkState = nsIDOMHTMLMediaElement::NETWORK_LOADING;
     AddRemoveSelfReference();
   }
 }
 
 void nsHTMLMediaElement::DownloadStalled()
 {
   if (mNetworkState == nsIDOMHTMLMediaElement::NETWORK_LOADING) {
--- a/content/media/MediaResource.cpp
+++ b/content/media/MediaResource.cpp
@@ -446,16 +446,18 @@ nsresult ChannelMediaResource::OpenChann
                                   nsIScriptSecurityManager::STANDARD);
       NS_ENSURE_SUCCESS(rv, rv);
     }
 
     SetupChannelHeaders();
 
     nsresult rv = mChannel->AsyncOpen(listener, nsnull);
     NS_ENSURE_SUCCESS(rv, rv);
+    // Tell the media element that we are fetching data from a channel.
+    element->DownloadResumed(true);
   }
 
   return NS_OK;
 }
 
 void ChannelMediaResource::SetupChannelHeaders()
 {
   // Always use a byte range request even if we're reading from the start