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
parent b98f2c8525
commit e80df3e463
2 changed files with 7 additions and 1 deletions

View File

@ -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>()) {

View File

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