Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Unified Diff: chrome/browser/download/download_manager.cc

Issue 6905049: Detect removed files and reflect the state in chrome://downloads and the download shelf (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Correct typo Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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));

Powered by Google App Engine
This is Rietveld 408576698