From 35a88afc177269ec4caab9b18e1df87c63c5c4dd Mon Sep 17 00:00:00 2001 From: Chris Pearce Date: Wed, 11 Jun 2014 10:53:17 +1200 Subject: [PATCH] Bug 1022421 - Cache value of FaviconHelper::GetICOCacheSecondsTimeout() in AsyncDeleteAllFaviconsFromDisk so that we don't use pref service off main thread. r=jimm --- widget/windows/WinUtils.cpp | 7 ++++--- widget/windows/WinUtils.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/widget/windows/WinUtils.cpp b/widget/windows/WinUtils.cpp index baf4e5cfb93..303db41a342 100644 --- a/widget/windows/WinUtils.cpp +++ b/widget/windows/WinUtils.cpp @@ -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; } } diff --git a/widget/windows/WinUtils.h b/widget/windows/WinUtils.h index 337029aa49f..be2bbaa0e9a 100644 --- a/widget/windows/WinUtils.h +++ b/widget/windows/WinUtils.h @@ -414,6 +414,7 @@ public: AsyncDeleteAllFaviconsFromDisk(bool aIgnoreRecent = false); virtual ~AsyncDeleteAllFaviconsFromDisk(); private: + int32_t mIcoNoDeleteSeconds; bool mIgnoreRecent; };