Bug 1415090. P5 - remove MediaCacheStream::NotifyChannelRecreated().
NotifyDataEnded() runs off the main thread which might set mChannelEnded
wrongly after NotifyChannelRecreated reset it on the main thread.
We should reset the flags in NotifyDataStarted() which indicate a new load has begun.
MozReview-Commit-ID: Gi6PFXwMJqc
--- a/dom/media/ChannelMediaResource.cpp
+++ b/dom/media/ChannelMediaResource.cpp
@@ -790,19 +790,16 @@ ChannelMediaResource::RecreateChannel()
nsCOMPtr<nsIClassOfService> 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);
}
- // Tell the cache to reset the download status when the channel is reopened.
- mCacheStream.NotifyChannelRecreated();
-
return rv;
}
void
ChannelMediaResource::CacheClientNotifyDataReceived()
{
SystemGroup::Dispatch(
TaskCategory::Other,
--- a/dom/media/MediaCache.cpp
+++ b/dom/media/MediaCache.cpp
@@ -1977,16 +1977,20 @@ MediaCacheStream::NotifyDataStarted(uint
mIsTransportSeekable = aSeekable;
// Queue an Update since we may change our strategy for dealing
// with this stream
mMediaCache->QueueUpdate();
// Reset mSeekTarget since the seek is completed so MediaCache::Update() will
// make decisions based on mChannelOffset instead of mSeekTarget.
mSeekTarget = -1;
+
+ // Reset these flags since a new load has begun.
+ mChannelEnded = false;
+ mDidNotifyDataEnded = false;
}
void
MediaCacheStream::UpdatePrincipal(nsIPrincipal* aPrincipal)
{
MOZ_ASSERT(NS_IsMainThread());
MediaCache::ResourceStreamIterator iter(mMediaCache, mResourceID);
while (MediaCacheStream* stream = iter.Next()) {
@@ -2187,25 +2191,16 @@ MediaCacheStream::NotifyDataEndedInterna
stream->mDidNotifyDataEnded = true;
stream->mNotifyDataEndedStatus = aStatus;
stream->mClient->CacheClientNotifyDataEnded(aStatus);
}
}
}
void
-MediaCacheStream::NotifyChannelRecreated()
-{
- NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
- ReentrantMonitorAutoEnter mon(mMediaCache->GetReentrantMonitor());
- mChannelEnded = false;
- mDidNotifyDataEnded = false;
-}
-
-void
MediaCacheStream::NotifyDataEnded(uint32_t aLoadID,
nsresult aStatus,
bool aReopenOnError)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aLoadID > 0);
RefPtr<ChannelMediaResource> client = mClient;
--- a/dom/media/MediaCache.h
+++ b/dom/media/MediaCache.h
@@ -273,20 +273,16 @@ public:
// preceding NotifyDataStarted().
void NotifyLoadID(uint32_t aLoadID);
// Notifies the cache that the channel has closed with the given status.
void NotifyDataEnded(uint32_t aLoadID,
nsresult aStatus,
bool aReopenOnError = false);
- // Notifies the stream that the channel is reopened. The stream should
- // reset variables such as |mDidNotifyDataEnded|.
- void NotifyChannelRecreated();
-
// Notifies the stream that the suspend status of the client has changed.
// Main thread only.
void NotifyClientSuspended(bool aSuspended);
// These methods can be called on any thread.
// Cached blocks associated with this stream will not be evicted
// while the stream is pinned.
void Pin();