Bug 1293577 - Part 2. Add mutex to MetadataDecodingTask to protect from decoding races. r=seth

This commit is contained in:
Andrew Osmond 2016-08-18 10:23:42 -04:00
Родитель b98f2c8525
Коммит e80df3e463
2 изменённых файлов: 7 добавлений и 1 удалений

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

@ -158,7 +158,8 @@ AnimationDecodingTask::ShouldPreferSyncRun() const
///////////////////////////////////////////////////////////////////////////////
MetadataDecodingTask::MetadataDecodingTask(NotNull<Decoder*> aDecoder)
: mDecoder(aDecoder)
: mMutex("mozilla::image::MetadataDecodingTask")
, mDecoder(aDecoder)
{
MOZ_ASSERT(mDecoder->IsMetadataDecode(),
"Use DecodingTask for non-metadata decodes");
@ -167,6 +168,8 @@ MetadataDecodingTask::MetadataDecodingTask(NotNull<Decoder*> aDecoder)
void
MetadataDecodingTask::Run()
{
MutexAutoLock lock(mMutex);
LexerResult result = mDecoder->Decode(WrapNotNull(this));
if (result.is<TerminalState>()) {

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

@ -113,6 +113,9 @@ public:
private:
virtual ~MetadataDecodingTask() { }
/// Mutex protecting access to mDecoder.
Mutex mMutex;
NotNull<RefPtr<Decoder>> mDecoder;
};