Fix long lockup when hitting Cleanup button with a large number of removable downloads. (Use datasource batching)

This commit is contained in:
ben%bengoodger.com 2003-12-01 00:08:40 +00:00
Родитель 1b51f27fa6
Коммит d2e9a8cbe0
1 изменённых файлов: 9 добавлений и 0 удалений

Просмотреть файл

@ -780,7 +780,10 @@ nsDownloadManager::CleanUp()
nsCOMPtr<nsIRDFInt> intLiteral;
nsCOMPtr<nsISimpleEnumerator> downloads;
// Coalesce operations so that we don't write to disk for every removal, or
// attempt to update the UI too much.
StartBatchUpdate();
mDataSource->BeginUpdateBatch();
// 1). First, clean out the usual suspects - downloads that are
// finished, failed or canceled.
@ -804,6 +807,7 @@ nsDownloadManager::CleanUp()
}
}
mDataSource->EndUpdateBatch();
EndBatchUpdate();
return NS_OK;
@ -876,6 +880,9 @@ nsDownloadManager::ValidateDownloadsContainer()
e->HasMoreElements(&hasMore);
}
// Coalesce notifications
mDataSource->BeginUpdateBatch();
// Now Remove all the bad downloads.
PRUint32 cnt;
ary->Count(&cnt);
@ -886,6 +893,8 @@ nsDownloadManager::ValidateDownloadsContainer()
RemoveDownload(download);
}
mDataSource->EndUpdateBatch();
return NS_OK;
}