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

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

Issue 3043048: Clean up download code: (Closed)
Patch Set: Created 10 years, 5 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
« no previous file with comments | « chrome/browser/download/download_exe.cc ('k') | chrome/browser/download/download_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/download_item.cc
diff --git a/chrome/browser/download/download_item.cc b/chrome/browser/download/download_item.cc
index 905d00f3c7e089ca4a557a64b2c167dd990ce6b6..269f0cbeba485dddb9f34bad6c8455ea2ba46098 100644
--- a/chrome/browser/download/download_item.cc
+++ b/chrome/browser/download/download_item.cc
@@ -4,8 +4,10 @@
#include "chrome/browser/download/download_item.h"
+#include "base/file_util.h"
#include "base/logging.h"
#include "base/timer.h"
+#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/download/download_history.h"
#include "chrome/browser/download/download_manager.h"
#include "chrome/browser/download/download_util.h"
@@ -17,6 +19,14 @@ namespace {
// Update frequency (milliseconds).
const int kUpdateTimeMs = 1000;
+void DeleteDownloadedFile(const FilePath& path) {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE));
+
+ // Make sure we only delete files.
+ if (!file_util::DirectoryExists(path))
+ file_util::Delete(path, false);
+}
+
} // namespace
// Constructor for reading from the history service.
@@ -229,8 +239,11 @@ void DownloadItem::Finished(int64 size) {
void DownloadItem::Remove(bool delete_on_disk) {
Cancel(true);
state_ = REMOVING;
- if (delete_on_disk)
- download_manager_->DeleteDownload(full_path_);
+ if (delete_on_disk) {
+ ChromeThread::PostTask(
+ ChromeThread::FILE, FROM_HERE,
+ NewRunnableFunction(&DeleteDownloadedFile, full_path_));
+ }
download_manager_->RemoveDownload(db_handle_);
// We have now been deleted.
}
« no previous file with comments | « chrome/browser/download/download_exe.cc ('k') | chrome/browser/download/download_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698