132013 - remove from list should be batched. r=hewitt sr=ben

This commit is contained in:
blakeross%telocity.com 2002-05-06 01:14:27 +00:00
Родитель c0b6f6c850
Коммит 347da180eb
4 изменённых файлов: 38 добавлений и 3 удалений

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

@ -144,7 +144,19 @@ interface nsIDownloadManager : nsISupports {
* third party managers to let us know when they've closed.
*/
void onClose();
void onClose();
/**
* Indicate that a batch update (e.g. mass removal) is about to start.
*/
void startBatchUpdate();
/**
* Indicate that a batch update is ending.
*/
void endBatchUpdate();
};

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

@ -199,8 +199,12 @@ var downloadViewController = {
break;
case "cmd_remove":
selectedItems = getSelectedItems();
for (i = 0; i < selectedItems.length; i++)
gDownloadManager.startBatchUpdate();
for (i = 0; i < selectedItems.length; i++) {
if (i == selectedItems.length - 1)
gDownloadManager.endBatchUpdate();
gDownloadManager.removeDownload(selectedItems[i].id);
}
window.updateCommands("tree-select");
break;
case "cmd_selectAll":

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

@ -84,7 +84,8 @@ nsIRDFService* gRDFService;
NS_IMPL_ISUPPORTS3(nsDownloadManager, nsIDownloadManager, nsIDOMEventListener, nsIObserver)
nsDownloadManager::nsDownloadManager() : mCurrDownloads(nsnull)
nsDownloadManager::nsDownloadManager() : mCurrDownloads(nsnull),
mBatches(0)
{
NS_INIT_ISUPPORTS();
}
@ -627,10 +628,27 @@ nsDownloadManager::RemoveDownload(const char* aPath)
rv = downloads->RemoveElementAt(itemIndex, PR_TRUE, getter_AddRefs(node));
if (NS_FAILED(rv)) return rv;
// if a mass removal is being done, we don't want to flush every time
if (mBatches) return rv;
nsCOMPtr<nsIRDFRemoteDataSource> remote = do_QueryInterface(mDataSource);
return remote->Flush();
}
NS_IMETHODIMP
nsDownloadManager::StartBatchUpdate()
{
++mBatches;
return NS_OK;
}
NS_IMETHODIMP
nsDownloadManager::EndBatchUpdate()
{
--mBatches;
return NS_OK;
}
NS_IMETHODIMP
nsDownloadManager::Open(nsIDOMWindow* aParent)
{

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

@ -93,6 +93,7 @@ private:
nsCOMPtr<nsIDownloadProgressListener> mListener;
nsCOMPtr<nsIRDFContainerUtils> mRDFContainerUtils;
nsCOMPtr<nsIStringBundle> mBundle;
PRInt32 mBatches;
nsHashtable* mCurrDownloads;
friend class nsDownload;