зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1473173 - Report MediaResource as seekable if we know we will never seek into underlying transport. r=bryce
The MediaCache reads content by block of BLOCK_SIZE bytes (currently 32kB). As such, if a content being fetched is less than BLOCK_SIZE, it will always be fully read from offset = 0. We can then seek within this buffered content regardless of the underlying HTTP connection supporting request-range or not. test_bug686942.html is ultimately testing a racy behaviour: it attempts to seek into a resource that isn't always seekable (http.js doesn't report Range -Request support for small files). The seekable range becomes then the buffered range which at the time of loadedmetadata may not be set yet. Differential Revision: https://phabricator.services.mozilla.com/D3028 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
2b60e5044b
Коммит
756a7bdfd8
|
@ -295,6 +295,9 @@ ChannelMediaResource::OnStartRequest(nsIRequest* aRequest,
|
|||
|
||||
mCacheStream.NotifyDataStarted(mLoadID, startOffset, seekable, length);
|
||||
mIsTransportSeekable = seekable;
|
||||
if (mFirstReadLength < 0) {
|
||||
mFirstReadLength = length;
|
||||
}
|
||||
|
||||
mSuspendAgent.Delegate(mChannel);
|
||||
|
||||
|
@ -317,7 +320,14 @@ bool
|
|||
ChannelMediaResource::IsTransportSeekable()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
return mIsTransportSeekable;
|
||||
// We Report the transport as seekable if we know we will never seek into
|
||||
// the underlying transport. As the MediaCache reads content by block of
|
||||
// BLOCK_SIZE bytes, so the content length is less it will always be fully
|
||||
// read from offset = 0 and we can then always successfully seek within this
|
||||
// buffered content.
|
||||
return mIsTransportSeekable ||
|
||||
(mFirstReadLength > 0 &&
|
||||
mFirstReadLength < MediaCacheStream::BLOCK_SIZE);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -255,6 +255,8 @@ protected:
|
|||
bool mClosed = false;
|
||||
// The last reported seekability state for the underlying channel
|
||||
bool mIsTransportSeekable = false;
|
||||
// Length of the content first reported.
|
||||
int64_t mFirstReadLength = -1;
|
||||
RefPtr<Listener> mListener;
|
||||
// A mono-increasing integer to uniquely identify the channel we are loading.
|
||||
uint32_t mLoadID = 0;
|
||||
|
|
Загрузка…
Ссылка в новой задаче