Bug 1398659. P1 - tighten up the assertions in InitAsClone(). r=gerald

We also make it return void since it now always succeeds.

MozReview-Commit-ID: H1oQWoguEzF

--HG--
extra : rebase_source : b5c6714832bed6fceb80c4afcdf4a590cc7dc567
extra : intermediate-source : 01aa9da848391bbf0b39f8dca874c0234f3202fb
extra : source : af04510d8603ffe407069ef342fdb4d3bca33509
This commit is contained in:
JW Wang 2017-09-05 17:28:14 +08:00
Родитель 045157cf54
Коммит b8f562f05e
2 изменённых файлов: 7 добавлений и 13 удалений

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

@ -2561,17 +2561,13 @@ MediaCacheStream::Init(int64_t aContentLength)
return NS_OK;
}
nsresult
void
MediaCacheStream::InitAsClone(MediaCacheStream* aOriginal)
{
if (!aOriginal->IsAvailableForSharing())
return NS_ERROR_FAILURE;
MOZ_ASSERT(aOriginal->IsAvailableForSharing());
MOZ_ASSERT(!mMediaCache, "Has been initialized.");
MOZ_ASSERT(aOriginal->mMediaCache, "Don't clone an uninitialized stream.");
if (mMediaCache) {
return NS_OK;
}
NS_ASSERTION(aOriginal->mMediaCache, "Don't clone an uninitialized stream");
// Use the same MediaCache as our clone.
mMediaCache = aOriginal->mMediaCache;
@ -2609,8 +2605,6 @@ MediaCacheStream::InitAsClone(MediaCacheStream* aOriginal)
// stream offset is zero
mMediaCache->AddBlockOwnerAsReadahead(cacheBlockIndex, this, i);
}
return NS_OK;
}
nsresult MediaCacheStream::GetCachedRanges(MediaByteRangeSet& aRanges)

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

@ -205,10 +205,10 @@ public:
nsresult Init(int64_t aContentLength);
// Set up this stream with the cache, assuming it's for the same data
// as the aOriginal stream. Can fail on OOM.
// as the aOriginal stream.
// Exactly one of InitAsClone or Init must be called before any other method
// on this class. Does nothing if already initialized.
nsresult InitAsClone(MediaCacheStream* aOriginal);
// on this class.
void InitAsClone(MediaCacheStream* aOriginal);
// These are called on the main thread.
// Tell us whether the stream is seekable or not. Non-seekable streams