зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1426578. P4 - offload InitAsClone() to another thread. r=bechen,gerald
MozReview-Commit-ID: H8bQRmkJ8jU --HG-- extra : rebase_source : a6fd3ec4d48974a36c0eec24503d10258ed5f5d4 extra : source : 2ffac43de24706551d3e183072d4e53c137ecb5f
This commit is contained in:
Родитель
e43ca27ba0
Коммит
ea7483e4ce
|
@ -1804,8 +1804,6 @@ MediaCache::OpenStream(AutoLock& aLock,
|
|||
MediaCacheStream* aStream,
|
||||
bool aIsClone)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
|
||||
|
||||
LOG("Stream %p opened", aStream);
|
||||
mStreams.AppendElement(aStream);
|
||||
|
||||
|
@ -2890,6 +2888,19 @@ MediaCacheStream::InitAsClone(MediaCacheStream* aOriginal)
|
|||
mCacheSuspended = true;
|
||||
mChannelEnded = true;
|
||||
|
||||
OwnerThread()->Dispatch(
|
||||
NS_NewRunnableFunction("MediaCacheStream::InitAsClone", [
|
||||
this,
|
||||
aOriginal,
|
||||
r1 = RefPtr<ChannelMediaResource>(mClient),
|
||||
r2 = RefPtr<ChannelMediaResource>(aOriginal->mClient)
|
||||
]() { InitAsCloneInternal(aOriginal); }));
|
||||
}
|
||||
|
||||
void
|
||||
MediaCacheStream::InitAsCloneInternal(MediaCacheStream* aOriginal)
|
||||
{
|
||||
MOZ_ASSERT(OwnerThread()->IsOnCurrentThread());
|
||||
AutoLock lock(aOriginal->mMediaCache->Monitor());
|
||||
|
||||
mResourceID = aOriginal->mResourceID;
|
||||
|
@ -2927,6 +2938,9 @@ MediaCacheStream::InitAsClone(MediaCacheStream* aOriginal)
|
|||
BLOCK_SIZE);
|
||||
|
||||
mMediaCache->OpenStream(lock, this, true /* aIsClone */);
|
||||
|
||||
// Wake up the reader which is waiting for the cloned data.
|
||||
lock.NotifyAll();
|
||||
}
|
||||
|
||||
nsIEventTarget*
|
||||
|
|
|
@ -466,6 +466,7 @@ private:
|
|||
void UpdateDownloadStatistics(AutoLock&);
|
||||
|
||||
void CloseInternal(AutoLock&);
|
||||
void InitAsCloneInternal(MediaCacheStream* aOriginal);
|
||||
|
||||
// Instance of MediaCache to use with this MediaCacheStream.
|
||||
RefPtr<MediaCache> mMediaCache;
|
||||
|
|
Загрузка…
Ссылка в новой задаче