Chromium Code Reviews| Index: chrome/browser/download/download_manager.cc |
| diff --git a/chrome/browser/download/download_manager.cc b/chrome/browser/download/download_manager.cc |
| index fb9fb7b033c3cd2c04eb3451e860e5844c69f5a7..1de71dc74ba6e830ea622272c64469cc004c89ad 100644 |
| --- a/chrome/browser/download/download_manager.cc |
| +++ b/chrome/browser/download/download_manager.cc |
| @@ -262,6 +262,47 @@ void DownloadManager::StartDownload(DownloadCreateInfo* info) { |
| info, NewCallback(this, &DownloadManager::CheckDownloadUrlDone)); |
| } |
| +void DownloadManager::CheckForHistoryFilesRemoval() { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + for (DownloadMap::iterator it = history_downloads_.begin(); |
| + it != history_downloads_.end(); ++it) { |
| + CheckForFileRemoval(it->second); |
| + } |
| +} |
| + |
| +void DownloadManager::CheckForFileRemoval(DownloadItem* download_item) { |
|
Paweł Hajdan Jr.
2011/05/17 20:03:39
nit: Add a BrowserThread::CurrentlyOn DCHECK here
haraken1
2011/06/07 12:49:18
Done.
|
| + if (download_item->IsComplete() && |
| + !download_item->file_externally_removed()) { |
| + BrowserThread::PostTask( |
| + BrowserThread::FILE, FROM_HERE, |
| + NewRunnableMethod(this, |
| + &DownloadManager::CheckForFileRemovalOnFileThread, |
| + download_item->db_handle(), |
| + 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)); |