Bug 1388612. P1 - remove MediaResource::EnsureCacheUpToDate().
This is a workaround to fix
bug 687972. It should be OK now to remove
it since we have fix
bug 1108960 where MediaCache failed to run the
update loop to update the suspend status of the stream.
MozReview-Commit-ID: MbInehhScs
--- a/dom/media/MediaCache.cpp
+++ b/dom/media/MediaCache.cpp
@@ -2120,24 +2120,16 @@ MediaCacheStream::Close()
CloseInternal(mon);
// Queue an Update since we may have created more free space. Don't do
// it from CloseInternal since that gets called by Update() itself
// sometimes, and we try to not to queue updates from Update().
mMediaCache->QueueUpdate();
}
void
-MediaCacheStream::EnsureCacheUpdate()
-{
- if (mHasHadUpdate)
- return;
- mMediaCache->Update();
-}
-
-void
MediaCacheStream::CloseInternal(ReentrantMonitorAutoEnter& aReentrantMonitor)
{
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
if (mClosed)
return;
mClosed = true;
// Closing a stream will change the return value of
--- a/dom/media/MediaCache.h
+++ b/dom/media/MediaCache.h
@@ -227,21 +227,16 @@ public:
bool IsAvailableForSharing() const
{
return !mClosed && !mIsPrivateBrowsing &&
(!mDidNotifyDataEnded || NS_SUCCEEDED(mNotifyDataEndedStatus));
}
// Get the principal for this stream. Anything accessing the contents of
// this stream must have a principal that subsumes this principal.
nsIPrincipal* GetCurrentPrincipal() { return mPrincipal; }
- // Ensure a global media cache update has run with this stream present.
- // This ensures the cache has had a chance to suspend or unsuspend this stream.
- // Called only on main thread. This can change the state of streams, fire
- // notifications, etc.
- void EnsureCacheUpdate();
// These callbacks are called on the main thread by the client
// when data has been received via the channel.
// Tells the cache what the server said the data length is going to be.
// The actual data length may be greater (we receive more data than
// specified) or smaller (the stream ends before we reach the given
// length), because servers can lie. The server's reported data length
// *and* the actual data length can even vary over time because a
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -809,19 +809,16 @@ MediaDecoder::FirstFrameLoaded(nsAutoPtr
"mPlayState=%s",
aInfo->mAudio.mChannels, aInfo->mAudio.mRate, aInfo->HasAudio(),
aInfo->HasVideo(), PlayStateStr());
mInfo = aInfo.forget();
Invalidate();
- // This can run cache callbacks.
- GetResource()->EnsureCacheUpToDate();
-
// The element can run javascript via events
// before reaching here, so only change the
// state if we're still set to the original
// loading state.
if (mPlayState == PLAY_STATE_LOADING) {
ChangeState(mNextState);
}
--- a/dom/media/MediaResource.cpp
+++ b/dom/media/MediaResource.cpp
@@ -970,22 +970,16 @@ ChannelMediaResource::GetCachedDataEnd(i
}
bool
ChannelMediaResource::IsDataCachedToEndOfResource(int64_t aOffset)
{
return mCacheStream.IsDataCachedToEndOfStream(aOffset);
}
-void
-ChannelMediaResource::EnsureCacheUpToDate()
-{
- mCacheStream.EnsureCacheUpdate();
-}
-
bool
ChannelMediaResource::IsSuspendedByCache()
{
return mCacheStream.AreAllStreamsForResourceSuspended();
}
bool
ChannelMediaResource::IsSuspended()
--- a/dom/media/MediaResource.h
+++ b/dom/media/MediaResource.h
@@ -187,19 +187,16 @@ public:
return bytes.forget();
}
// Report the current offset in bytes from the start of the stream.
// This is used to approximate where we currently are in the playback of a
// media.
// A call to ReadAt will update this position.
virtual int64_t Tell() = 0;
- // Ensures that the value returned by IsSuspendedByCache below is up to date
- // (i.e. the cache has examined this stream at least once).
- virtual void EnsureCacheUpToDate() {}
// These can be called on any thread.
// Cached blocks associated with this stream will not be evicted
// while the stream is pinned.
virtual void Pin() = 0;
virtual void Unpin() = 0;
// Get the length of the stream in bytes. Returns -1 if not known.
// This can change over time; after a seek operation, a misbehaving
@@ -503,17 +500,16 @@ public:
void Resume() override;
already_AddRefed<nsIPrincipal> GetCurrentPrincipal() override;
// Return true if the stream has been closed.
bool IsClosed() const { return mCacheStream.IsClosed(); }
bool CanClone() override;
already_AddRefed<BaseMediaResource> CloneData(
MediaResourceCallback* aDecoder) override;
nsresult ReadFromCache(char* aBuffer, int64_t aOffset, uint32_t aCount) override;
- void EnsureCacheUpToDate() override;
// Other thread
void SetReadMode(MediaCacheStream::ReadMode aMode) override;
void SetPlaybackRate(uint32_t aBytesPerSecond) override;
nsresult ReadAt(int64_t offset, char* aBuffer,
uint32_t aCount, uint32_t* aBytes) override;
// Data stored in IO&lock-encumbered MediaCacheStream, caching recommended.
bool ShouldCacheReads() override { return true; }