зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1426578. P2 - always access MediaCache::mStreams while the cache monitor is held. r=bechen,gerald
Note we offload MediaCache::CloseStreamsForPrivateBrowsing() to another thread so we don't need to take the cache monitor on the main thread. MozReview-Commit-ID: 9hYszHZ0OJJ --HG-- extra : rebase_source : 652b4ca783a52d28b0948e81d7b54ed79094230d extra : intermediate-source : 46316625deb99585c42026010d994fa22b5b3dca extra : source : 8c9e8ac739eb347b3b8ba24229cafcf2a3e3c4cd
This commit is contained in:
Родитель
0c88150fb7
Коммит
1aec590c73
|
@ -253,7 +253,7 @@ public:
|
|||
/**
|
||||
* An iterator that makes it easy to iterate through all streams that
|
||||
* have a given resource ID and are not closed.
|
||||
* Can be used on the main thread or while holding the media cache lock.
|
||||
* Must be used while holding the media cache lock.
|
||||
*/
|
||||
class ResourceStreamIterator
|
||||
{
|
||||
|
@ -263,6 +263,7 @@ public:
|
|||
, mResourceID(aResourceID)
|
||||
, mNext(0)
|
||||
{
|
||||
aMediaCache->mMonitor.AssertCurrentThreadIn();
|
||||
}
|
||||
MediaCacheStream* Next(AutoLock& aLock)
|
||||
{
|
||||
|
@ -443,8 +444,7 @@ protected:
|
|||
// readers that need to block will Wait() on this monitor. When new
|
||||
// data becomes available in the cache, we NotifyAll() on this monitor.
|
||||
ReentrantMonitor mMonitor;
|
||||
// This is only written while on the main thread and the monitor is held.
|
||||
// Thus, it can be safely read from the main thread or while holding the monitor.
|
||||
// This must always be accessed when the monitor is held.
|
||||
nsTArray<MediaCacheStream*> mStreams;
|
||||
// The Blocks describing the cache entries.
|
||||
nsTArray<Block> mIndex;
|
||||
|
@ -724,11 +724,16 @@ void
|
|||
MediaCache::CloseStreamsForPrivateBrowsing()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
for (MediaCacheStream* s : mStreams) {
|
||||
if (s->mIsPrivateBrowsing) {
|
||||
s->mClient->Close();
|
||||
}
|
||||
}
|
||||
sThread->Dispatch(
|
||||
NS_NewRunnableFunction("MediaCache::CloseStreamsForPrivateBrowsing",
|
||||
[self = RefPtr<MediaCache>(this)]() {
|
||||
AutoLock lock(self->mMonitor);
|
||||
for (MediaCacheStream* s : self->mStreams) {
|
||||
if (s->mIsPrivateBrowsing) {
|
||||
s->CloseInternal(lock);
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
/* static */ RefPtr<MediaCache>
|
||||
|
|
Загрузка…
Ссылка в новой задаче