зеркало из https://github.com/mozilla/gecko-dev.git
Bug 724423 - Fix jump list favicon cleanup. r=jimm
This commit is contained in:
Родитель
ee01a4734c
Коммит
8ca20ca187
|
@ -126,6 +126,9 @@ NS_IMETHODIMP JumpListBuilder::InitListBuild(nsIMutableArray *removedItems, bool
|
|||
|
||||
IObjectArray *objArray;
|
||||
|
||||
// The returned objArray of removed items are for manually removed items.
|
||||
// This does not return items which are removed because they were previously
|
||||
// part of the jump list but are no longer part of the jump list.
|
||||
if (SUCCEEDED(mJumpListMgr->BeginList(&mMaxItems, IID_PPV_ARGS(&objArray)))) {
|
||||
if (objArray) {
|
||||
TransferIObjectArrayToIMutableArray(objArray, removedItems);
|
||||
|
@ -379,6 +382,12 @@ NS_IMETHODIMP JumpListBuilder::AddListToBuild(int16_t aCatType, nsIArray *items,
|
|||
hr = mJumpListMgr->AppendCategory(reinterpret_cast<const wchar_t*>(catName.BeginReading()), pArray);
|
||||
if (SUCCEEDED(hr))
|
||||
*_retval = true;
|
||||
|
||||
// Get rid of the old icons
|
||||
nsCOMPtr<nsIRunnable> event =
|
||||
new mozilla::widget::AsyncDeleteAllFaviconsFromDisk(true);
|
||||
mIOThread->Dispatch(event, NS_DISPATCH_NORMAL);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -958,7 +958,9 @@ AsyncDeleteIconFromDisk::~AsyncDeleteIconFromDisk()
|
|||
{
|
||||
}
|
||||
|
||||
AsyncDeleteAllFaviconsFromDisk::AsyncDeleteAllFaviconsFromDisk()
|
||||
AsyncDeleteAllFaviconsFromDisk::
|
||||
AsyncDeleteAllFaviconsFromDisk(bool aIgnoreRecent)
|
||||
: mIgnoreRecent(aIgnoreRecent)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -997,6 +999,24 @@ NS_IMETHODIMP AsyncDeleteAllFaviconsFromDisk::Run()
|
|||
if (NS_FAILED(currFile->Exists(&exists)) || !exists)
|
||||
continue;
|
||||
|
||||
if (mIgnoreRecent) {
|
||||
// Check to make sure the icon wasn't just recently created.
|
||||
// If it was created recently, don't delete it yet.
|
||||
int64_t fileModTime = 0;
|
||||
rv = currFile->GetLastModifiedTime(&fileModTime);
|
||||
fileModTime /= PR_MSEC_PER_SEC;
|
||||
// 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) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// We found an ICO file that exists, so we should remove it
|
||||
currFile->Remove(false);
|
||||
}
|
||||
|
|
|
@ -411,8 +411,10 @@ public:
|
|||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSIRUNNABLE
|
||||
|
||||
AsyncDeleteAllFaviconsFromDisk();
|
||||
AsyncDeleteAllFaviconsFromDisk(bool aIgnoreRecent = false);
|
||||
virtual ~AsyncDeleteAllFaviconsFromDisk();
|
||||
private:
|
||||
bool mIgnoreRecent;
|
||||
};
|
||||
|
||||
class FaviconHelper
|
||||
|
|
Загрузка…
Ссылка в новой задаче