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..0a49ecb1883c30c10bdc818c13098826814c3679 100644 |
--- a/chrome/browser/download/download_manager.cc |
+++ b/chrome/browser/download/download_manager.cc |
@@ -265,6 +265,54 @@ void DownloadManager::StartDownload(DownloadCreateInfo* info) { |
info, NewCallback(this, &DownloadManager::CheckDownloadUrlDone)); |
} |
+void DownloadManager::CheckExistingPaths() { |
+ PathVector existing_paths; |
+ for (DownloadMap::iterator it = history_downloads_.begin(); |
+ it != history_downloads_.end(); ++it) { |
+ DownloadItem* download_item = it->second; |
+ if (download_item->IsComplete() && download_item->is_path_exists()) { |
+ existing_paths.push_back(std::pair<int64, FilePath>( |
+ it->first, download_item->GetTargetFilePath())); |
+ } |
+ } |
+ |
+ BrowserThread::PostTask( |
+ BrowserThread::FILE, FROM_HERE, |
+ NewRunnableMethod(this, |
+ &DownloadManager::CheckExistingPathsOnFileThread, |
+ existing_paths)); |
+} |
+ |
+void DownloadManager::CheckExistingPathsOnFileThread( |
+ PathVector existing_paths) { |
+ PathVector removed_paths; |
+ for (PathVector::iterator it = existing_paths.begin(); |
+ it != existing_paths.end(); ++it) { |
+ if (!file_util::PathExists(it->second)) { |
+ removed_paths.push_back(std::pair<int64, FilePath>( |
+ it->first, it->second)); |
+ } |
+ } |
+ |
+ BrowserThread::PostTask( |
+ BrowserThread::UI, FROM_HERE, |
+ NewRunnableMethod(this, |
+ &DownloadManager::OnExistingPathsAvailable, |
+ removed_paths)); |
+} |
+ |
+void DownloadManager::OnExistingPathsAvailable(PathVector removed_paths) { |
+ for (PathVector::iterator it = removed_paths.begin(); |
+ it != removed_paths.end(); ++it) { |
+ DownloadMap::iterator map_it = history_downloads_.find(it->first); |
+ if (map_it != history_downloads_.end()) { |
+ DownloadItem* download_item = map_it->second; |
+ download_item->set_is_path_exists(false); |
+ download_item->UpdateObservers(); |
+ } |
+ } |
+} |
+ |
void DownloadManager::CheckDownloadUrlDone(DownloadCreateInfo* info, |
bool is_dangerous_url) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |