Index: chrome/browser/download/download_manager.cc |
diff --git a/chrome/browser/download/download_manager.cc b/chrome/browser/download/download_manager.cc |
index 6ef4a2b1e812ba36598d087e77f7925cacde2c3a..43adf177628bf1bb24608fb06f163a00ecbc8742 100644 |
--- a/chrome/browser/download/download_manager.cc |
+++ b/chrome/browser/download/download_manager.cc |
@@ -265,6 +265,44 @@ void DownloadManager::StartDownload(DownloadCreateInfo* info) { |
info, NewCallback(this, &DownloadManager::CheckDownloadUrlDone)); |
} |
+void DownloadManager::CheckForFilesRemoval() { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ for (DownloadMap::iterator it = history_downloads_.begin(); |
+ it != history_downloads_.end(); ++it) { |
+ DownloadItem* download_item = it->second; |
+ if (download_item->IsComplete() && download_item->file_exists()) { |
+ BrowserThread::PostTask( |
+ BrowserThread::FILE, FROM_HERE, |
+ NewRunnableMethod(this, |
+ &DownloadManager::CheckForFilesRemovalOnFileThread, |
+ it->first, download_item->GetTargetFilePath())); |
+ } |
+ } |
+} |
+ |
+void DownloadManager::CheckForFilesRemovalOnFileThread( |
+ int64 db_handle, const FilePath& path) { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
+ bool file_exists = file_util::PathExists(path); |
+ BrowserThread::PostTask( |
+ BrowserThread::UI, FROM_HERE, |
+ NewRunnableMethod(this, |
+ &DownloadManager::OnFilesRemovalDetected, |
+ db_handle, file_exists)); |
+} |
+ |
+void DownloadManager::OnFilesRemovalDetected( |
Randy Smith (Not in Mondays)
2011/05/12 20:21:17
Given that we're doing single file checks now, we
haraken1
2011/05/13 14:08:17
Done.
|
+ int64 db_handle, bool file_exists) { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ if (!file_exists) { |
Randy Smith (Not in Mondays)
2011/05/12 20:21:17
Given that this function doesn't do anything if fi
haraken1
2011/05/13 14:08:17
Done.
|
+ DownloadMap::iterator it = history_downloads_.find(db_handle); |
+ if (it != history_downloads_.end()) { |
+ DownloadItem* download_item = it->second; |
+ download_item->OnDownloadedFileRemoved(); |
+ } |
+ } |
+} |
+ |
void DownloadManager::CheckDownloadUrlDone(DownloadCreateInfo* info, |
bool is_dangerous_url) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |