Bug 1022421 - Cache value of FaviconHelper::GetICOCacheSecondsTimeout() in AsyncDeleteAllFaviconsFromDisk so that we don't use pref service off main thread. r=jimm

This commit is contained in:
Chris Pearce 2014-06-11 10:53:17 +12:00
parent 6d1e1dbad7
commit 35a88afc17
2 changed files with 5 additions and 3 deletions

View File

@ -962,6 +962,9 @@ AsyncDeleteAllFaviconsFromDisk::
AsyncDeleteAllFaviconsFromDisk(bool aIgnoreRecent)
: mIgnoreRecent(aIgnoreRecent)
{
// We can't call FaviconHelper::GetICOCacheSecondsTimeout() on non-main
// threads, as it reads a pref, so cache its value here.
mIcoNoDeleteSeconds = FaviconHelper::GetICOCacheSecondsTimeout() + 600;
}
NS_IMETHODIMP AsyncDeleteAllFaviconsFromDisk::Run()
@ -1008,11 +1011,9 @@ NS_IMETHODIMP AsyncDeleteAllFaviconsFromDisk::Run()
// If the icon is older than the regeneration time (+ 10 min to be
// safe), then it's old and we can get rid of it.
// This code is only hit directly after a regeneration.
int32_t icoNoDeleteSeconds =
FaviconHelper::GetICOCacheSecondsTimeout() + 600;
int64_t nowTime = PR_Now() / int64_t(PR_USEC_PER_SEC);
if (NS_FAILED(rv) ||
(nowTime - fileModTime) < icoNoDeleteSeconds) {
(nowTime - fileModTime) < mIcoNoDeleteSeconds) {
continue;
}
}

View File

@ -414,6 +414,7 @@ public:
AsyncDeleteAllFaviconsFromDisk(bool aIgnoreRecent = false);
virtual ~AsyncDeleteAllFaviconsFromDisk();
private:
int32_t mIcoNoDeleteSeconds;
bool mIgnoreRecent;
};