зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1416643
. P1 - remove checks for mDidNotifyDataEnded/mNotifyDataEndedStatus from IsAvailableForSharing(). r=bechen,gerald
We will need to modify these members off the main thead while IsAvailableForSharing() is a main thread only function. InitAsClone() will return an error if the original stream ends abnormally. MozReview-Commit-ID: 1qRyboca2YZ --HG-- extra : rebase_source : 4617a911a1de052833bd0085b883a8ae4d639c7d
This commit is contained in:
Родитель
ef3b43fb44
Коммит
b88c401e49
|
@ -610,7 +610,11 @@ ChannelMediaResource::CloneData(MediaResourceCallback* aCallback)
|
|||
// which will recreate the channel. This way, if all of the media data
|
||||
// is already in the cache we don't create an unnecessary HTTP channel
|
||||
// and perform a useless HTTP transaction.
|
||||
resource->mCacheStream.InitAsClone(&mCacheStream);
|
||||
nsresult rv = resource->mCacheStream.InitAsClone(&mCacheStream);
|
||||
if (NS_FAILED(rv)) {
|
||||
resource->Close();
|
||||
return nullptr;
|
||||
}
|
||||
// mSuspendAgent.Suspend() accesses mCacheStream which is not ready
|
||||
// until InitAsClone() is done.
|
||||
resource->mSuspendAgent.Suspend();
|
||||
|
|
|
@ -2697,13 +2697,19 @@ MediaCacheStream::Init(int64_t aContentLength)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsresult
|
||||
MediaCacheStream::InitAsClone(MediaCacheStream* aOriginal)
|
||||
{
|
||||
MOZ_ASSERT(aOriginal->IsAvailableForSharing());
|
||||
MOZ_ASSERT(!mMediaCache, "Has been initialized.");
|
||||
MOZ_ASSERT(aOriginal->mMediaCache, "Don't clone an uninitialized stream.");
|
||||
|
||||
if (aOriginal->mDidNotifyDataEnded &&
|
||||
NS_FAILED(aOriginal->mNotifyDataEndedStatus)) {
|
||||
// Streams that ended abnormally are ineligible for cloning.
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// This needs to be done before OpenStream() to avoid data race.
|
||||
mClientSuspended = true;
|
||||
|
||||
|
@ -2744,6 +2750,8 @@ MediaCacheStream::InitAsClone(MediaCacheStream* aOriginal)
|
|||
}
|
||||
|
||||
mMediaCache->OpenStream(this, true /* aIsClone */);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIEventTarget*
|
||||
|
|
|
@ -210,7 +210,7 @@ public:
|
|||
// as the aOriginal stream.
|
||||
// Exactly one of InitAsClone or Init must be called before any other method
|
||||
// on this class.
|
||||
void InitAsClone(MediaCacheStream* aOriginal);
|
||||
nsresult InitAsClone(MediaCacheStream* aOriginal);
|
||||
|
||||
nsIEventTarget* OwnerThread() const;
|
||||
|
||||
|
@ -223,11 +223,7 @@ public:
|
|||
bool IsClosed() const { return mClosed; }
|
||||
// Returns true when this stream is can be shared by a new resource load.
|
||||
// Called on the main thread only.
|
||||
bool IsAvailableForSharing() const
|
||||
{
|
||||
return !mClosed && !mIsPrivateBrowsing &&
|
||||
(!mDidNotifyDataEnded || NS_SUCCEEDED(mNotifyDataEndedStatus));
|
||||
}
|
||||
bool IsAvailableForSharing() const { return !mClosed && !mIsPrivateBrowsing; }
|
||||
// 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; }
|
||||
|
|
Загрузка…
Ссылка в новой задаче