Backed out 2 changesets (bug 1422657) for browser chrome failures on browser_cache.js r=backout on a CLOSED TREE

Backed out changeset 7267883c2b72 (bug 1422657)
Backed out changeset 9c77dddb2fac (bug 1422657)
This commit is contained in:
Narcis Beleuzu 2017-12-06 00:40:16 +02:00
Родитель dfd58840d1
Коммит bc723a6e7e
8 изменённых файлов: 87 добавлений и 2 удалений

Просмотреть файл

@ -159,4 +159,13 @@ BaseMediaResource::ModifyLoadFlags(nsLoadFlags aFlags)
}
}
void
BaseMediaResource::DispatchBytesConsumed(int64_t aNumBytes, int64_t aOffset)
{
if (aNumBytes <= 0) {
return;
}
mCallback->NotifyBytesConsumed(aNumBytes, aOffset);
}
} // namespace mozilla

Просмотреть файл

@ -129,6 +129,10 @@ protected:
// then the request is added back to the load group.
void ModifyLoadFlags(nsLoadFlags aFlags);
// Dispatches an event to call MediaDecoder::NotifyBytesConsumed(aNumBytes, aOffset)
// on the main thread. This is called automatically after every read.
void DispatchBytesConsumed(int64_t aNumBytes, int64_t aOffset);
RefPtr<MediaResourceCallback> mCallback;
// Channel used to download the media data. Must be accessed

Просмотреть файл

@ -131,11 +131,30 @@ ChannelMediaDecoder::ResourceCallback::NotifySuspendedStatusChanged(
}
}
void
ChannelMediaDecoder::ResourceCallback::NotifyBytesConsumed(int64_t aBytes,
int64_t aOffset)
{
RefPtr<ResourceCallback> self = this;
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction(
"ChannelMediaDecoder::ResourceCallback::NotifyBytesConsumed",
[=]() {
if (self->mDecoder) {
self->mDecoder->NotifyBytesConsumed(aBytes, aOffset);
}
});
mAbstractMainThread->Dispatch(r.forget());
}
ChannelMediaDecoder::ChannelMediaDecoder(MediaDecoderInit& aInit)
: MediaDecoder(aInit)
, mResourceCallback(new ResourceCallback(aInit.mOwner->AbstractMainThread()))
, mWatchManager(this, aInit.mOwner->AbstractMainThread())
{
mResourceCallback->Connect(this);
// mIgnoreProgressData
mWatchManager.Watch(mLogicallySeeking, &ChannelMediaDecoder::SeekingChanged);
}
/* static */
@ -202,6 +221,7 @@ MediaDecoderStateMachine* ChannelMediaDecoder::CreateStateMachine()
void
ChannelMediaDecoder::Shutdown()
{
mWatchManager.Shutdown();
mResourceCallback->Disconnect();
MediaDecoder::Shutdown();
@ -288,6 +308,30 @@ ChannelMediaDecoder::NotifyDownloadEnded(nsresult aStatus)
}
}
void
ChannelMediaDecoder::NotifyBytesConsumed(int64_t aBytes, int64_t aOffset)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
AbstractThread::AutoEnter context(AbstractMainThread());
if (mIgnoreProgressData) {
return;
}
MOZ_ASSERT(GetStateMachine());
mDecoderPosition = aOffset + aBytes;
}
void
ChannelMediaDecoder::SeekingChanged()
{
// Stop updating the bytes downloaded for progress notifications when
// seeking to prevent wild changes to the progress notification.
MOZ_ASSERT(NS_IsMainThread());
mIgnoreProgressData = mLogicallySeeking;
}
bool
ChannelMediaDecoder::CanPlayThroughImpl()
{
@ -400,7 +444,7 @@ ChannelMediaDecoder::GetStatistics(const PlaybackRateInfo& aInfo)
MediaStatistics result;
result.mDownloadRate =
mResource->GetDownloadRate(&result.mDownloadRateReliable);
result.mDownloadPosition = mResource->GetCachedDataEnd(mPlaybackPosition);
result.mDownloadPosition = mResource->GetCachedDataEnd(mDecoderPosition);
result.mTotalBytes = mResource->GetLength();
result.mPlaybackRate = aInfo.mRate;
result.mPlaybackRateReliable = aInfo.mReliable;

Просмотреть файл

@ -44,6 +44,7 @@ class ChannelMediaDecoder : public MediaDecoder
void NotifyDataEnded(nsresult aStatus) override;
void NotifyPrincipalChanged() override;
void NotifySuspendedStatusChanged(bool aSuspendedByCache) override;
void NotifyBytesConsumed(int64_t aBytes, int64_t aOffset) override;
static void TimerCallback(nsITimer* aTimer, void* aClosure);
@ -114,6 +115,8 @@ private:
// by the MediaResource read functions.
void NotifyBytesConsumed(int64_t aBytes, int64_t aOffset);
void SeekingChanged();
bool CanPlayThroughImpl() override final;
bool IsLiveStream() override final;
@ -138,6 +141,14 @@ private:
bool ShouldThrottleDownload(const MediaStatistics& aStats);
WatchManager<ChannelMediaDecoder> mWatchManager;
// True when seeking or otherwise moving the play position around in
// such a manner that progress event data is inaccurate. This is set
// during seek and duration operations to prevent the progress indicator
// from jumping around. Read/Write on the main thread only.
bool mIgnoreProgressData = false;
// Data needed to estimate playback data rate. The timeline used for
// this estimate is "decode time" (where the "current time" is the
// time of the last decoded video frame).

Просмотреть файл

@ -621,7 +621,12 @@ nsresult ChannelMediaResource::ReadAt(int64_t aOffset,
uint32_t* aBytes)
{
NS_ASSERTION(!NS_IsMainThread(), "Don't call on main thread");
return mCacheStream.ReadAt(aOffset, aBuffer, aCount, aBytes);
nsresult rv = mCacheStream.ReadAt(aOffset, aBuffer, aCount, aBytes);
if (NS_SUCCEEDED(rv)) {
DispatchBytesConsumed(*aBytes, aOffset);
}
return rv;
}
void

Просмотреть файл

@ -171,6 +171,9 @@ FileMediaResource::ReadAt(int64_t aOffset, char* aBuffer, uint32_t aCount,
if (NS_FAILED(rv)) return rv;
rv = UnsafeRead(aBuffer, aCount, aBytes);
}
if (NS_SUCCEEDED(rv)) {
DispatchBytesConsumed(*aBytes, aOffset);
}
return rv;
}

Просмотреть файл

@ -648,6 +648,12 @@ protected:
// background.
bool mIsBackgroundVideoDecodingAllowed;
// Current decoding position in the stream. This is where the decoder
// is up to consuming the stream. This is not adjusted during decoder
// seek operations, but it's updated at the end when we start playing
// back again.
int64_t mDecoderPosition = 0;
public:
AbstractCanonical<double>* CanonicalVolume() { return &mVolume; }
AbstractCanonical<bool>* CanonicalPreservesPitch()

Просмотреть файл

@ -53,6 +53,9 @@ public:
// Notify that the "cache suspended" status of MediaResource changes.
virtual void NotifySuspendedStatusChanged(bool aSuspendedByCache) {}
// Notify the number of bytes read from the resource.
virtual void NotifyBytesConsumed(int64_t aBytes, int64_t aOffset) {}
protected:
virtual ~MediaResourceCallback() {}
};