Bug 1416643. P2 - always access mDidNotifyDataEnded within the lock. r=bechen,gerald

MozReview-Commit-ID: 3us659lCEZE

--HG--
extra : rebase_source : 9deace7a2e83ae42132f593bb7c638c5e2977638
This commit is contained in:
JW Wang 2017-11-15 15:24:26 +08:00
Родитель b88c401e49
Коммит ecbca6c33e
2 изменённых файлов: 4 добавлений и 5 удалений

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

@ -481,7 +481,6 @@ MediaCacheStream::MediaCacheStream(ChannelMediaResource* aClient,
bool aIsPrivateBrowsing)
: mMediaCache(nullptr)
, mClient(aClient)
, mDidNotifyDataEnded(false)
, mIsTransportSeekable(false)
, mCacheSuspended(false)
, mChannelEnded(false)
@ -2704,6 +2703,8 @@ MediaCacheStream::InitAsClone(MediaCacheStream* aOriginal)
MOZ_ASSERT(!mMediaCache, "Has been initialized.");
MOZ_ASSERT(aOriginal->mMediaCache, "Don't clone an uninitialized stream.");
ReentrantMonitorAutoEnter mon(aOriginal->mMediaCache->GetReentrantMonitor());
if (aOriginal->mDidNotifyDataEnded &&
NS_FAILED(aOriginal->mNotifyDataEndedStatus)) {
// Streams that ended abnormally are ineligible for cloning.
@ -2719,8 +2720,6 @@ MediaCacheStream::InitAsClone(MediaCacheStream* aOriginal)
mResourceID = aOriginal->mResourceID;
// Grab cache blocks from aOriginal as readahead blocks for our stream
ReentrantMonitorAutoEnter mon(mMediaCache->GetReentrantMonitor());
mPrincipal = aOriginal->mPrincipal;
mStreamLength = aOriginal->mStreamLength;
mIsTransportSeekable = aOriginal->mIsTransportSeekable;

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

@ -453,8 +453,6 @@ private:
// These fields are main-thread-only.
nsCOMPtr<nsIPrincipal> mPrincipal;
// True if CacheClientNotifyDataEnded has been called for this stream.
bool mDidNotifyDataEnded;
// The following fields must be written holding the cache's monitor and
// only on the main thread, thus can be read either on the main thread
@ -503,6 +501,8 @@ private:
// The number of times this stream has been Pinned without a
// corresponding Unpin
uint32_t mPinCount;
// True if CacheClientNotifyDataEnded has been called for this stream.
bool mDidNotifyDataEnded = false;
// The status used when we did CacheClientNotifyDataEnded. Only valid
// when mDidNotifyDataEnded is true.
nsresult mNotifyDataEndedStatus;