Bug 1132172 - Don't access CacheEntry::mFrecency on non-cache threads. r=michal

This commit is contained in:
Honza Bambas 2015-03-25 14:55:00 -04:00
parent cb52dfe127
commit e660be665f
2 changed files with 4 additions and 6 deletions

View File

@ -1594,7 +1594,7 @@ void CacheEntry::BackgroundOp(uint32_t aOperations, bool aForceAsync)
// Because CacheFile::Set*() are not thread-safe to use (uses WeakReference that
// is not thread-safe) we must post to the main thread...
nsRefPtr<nsRunnableMethod<CacheEntry> > event =
NS_NewRunnableMethod(this, &CacheEntry::StoreFrecency);
NS_NewRunnableMethodWithArg<double>(this, &CacheEntry::StoreFrecency, mFrecency);
NS_DispatchToMainThread(event);
}
@ -1618,14 +1618,12 @@ void CacheEntry::BackgroundOp(uint32_t aOperations, bool aForceAsync)
}
}
void CacheEntry::StoreFrecency()
void CacheEntry::StoreFrecency(double aFrecency)
{
// No need for thread safety over mFrecency, it will be rewriten
// correctly on following invocation if broken by concurrency.
MOZ_ASSERT(NS_IsMainThread());
if (NS_SUCCEEDED(mFileStatus)) {
mFile->SetFrecency(FRECENCY2INT(mFrecency));
mFile->SetFrecency(FRECENCY2INT(aFrecency));
}
}

View File

@ -248,7 +248,7 @@ private:
// When executed on the management thread directly, the operation(s)
// is (are) executed immediately.
void BackgroundOp(uint32_t aOperation, bool aForceAsync = false);
void StoreFrecency();
void StoreFrecency(double aFrecency);
// Called only from DoomAlreadyRemoved()
void DoomFile();