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..c47dacd055578477e6d120f810cb41fcd22afda3 100644 |
--- a/chrome/browser/download/download_manager.cc |
+++ b/chrome/browser/download/download_manager.cc |
@@ -265,6 +265,43 @@ 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_externally_removed()) { |
+ BrowserThread::PostTask( |
+ BrowserThread::FILE, FROM_HERE, |
+ NewRunnableMethod(this, |
+ &DownloadManager::CheckForFileRemovalOnFileThread, |
+ it->first, download_item->GetTargetFilePath())); |
+ } |
+ } |
+} |
+ |
+void DownloadManager::CheckForFileRemovalOnFileThread( |
+ int64 db_handle, const FilePath& path) { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
+ if (!file_util::PathExists(path)) { |
+ BrowserThread::PostTask( |
+ BrowserThread::UI, FROM_HERE, |
+ NewRunnableMethod(this, |
+ &DownloadManager::OnFileRemovalDetected, |
+ db_handle)); |
+ } |
+} |
+ |
+void DownloadManager::OnFileRemovalDetected(int64 db_handle) { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ 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)); |