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

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

Issue 3029025: Download code cleanup: (Closed)
Patch Set: rebase'n'final 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_file.cc ('k') | chrome/browser/download/download_item.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/download_file_manager.cc
diff --git a/chrome/browser/download/download_file_manager.cc b/chrome/browser/download/download_file_manager.cc
index d9ba1f28ef046ba3d2738a47dd1feff34071590a..c2cd5d00ec9cbfa24e4413ff011775fa44a93f18 100644
--- a/chrome/browser/download/download_file_manager.cc
+++ b/chrome/browser/download/download_file_manager.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/download/download_file_manager.h"
#include "base/file_util.h"
+#include "base/stl_util-inl.h"
#include "base/task.h"
#include "base/utf_string_conversions.h"
#include "build/build_config.h"
@@ -58,15 +59,7 @@ void DownloadFileManager::Shutdown() {
// Cease download thread operations.
void DownloadFileManager::OnShutdown() {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE));
- // Delete any partial downloads during shutdown.
- for (DownloadFileMap::iterator it = downloads_.begin();
- it != downloads_.end(); ++it) {
- DownloadFile* download = it->second;
- if (download->in_progress())
- download->Cancel();
- delete download;
- }
- downloads_.clear();
+ STLDeleteValues(&downloads_);
}
// Notifications sent from the download thread and run on the UI thread.
@@ -446,11 +439,11 @@ void DownloadFileManager::OnFinalDownloadName(int id,
bool need_delete_crdownload,
DownloadManager* manager) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE));
- DownloadFileMap::iterator it = downloads_.find(id);
- if (it == downloads_.end())
+
+ DownloadFile* download = GetDownloadFile(id);
+ if (!download)
return;
- DownloadFile* download = it->second;
if (download->Rename(full_path, true)) {
#if defined(OS_MACOSX)
// Done here because we only want to do this once; see
@@ -474,7 +467,7 @@ void DownloadFileManager::OnFinalDownloadName(int id,
// If the download has completed before we got this final name, we remove it
// from our in progress map.
if (!download->in_progress()) {
- downloads_.erase(it);
+ downloads_.erase(id);
delete download;
}
@@ -489,11 +482,11 @@ void DownloadFileManager::OnFinalDownloadName(int id,
// on the FILE thread.
void DownloadFileManager::CancelDownloadOnRename(int id) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE));
- DownloadFileMap::iterator it = downloads_.find(id);
- if (it == downloads_.end())
+
+ DownloadFile* download = GetDownloadFile(id);
+ if (!download)
return;
- DownloadFile* download = it->second;
DownloadManagerMap::iterator dmit = managers_.find(download->id());
if (dmit != managers_.end()) {
DownloadManager* dlm = dmit->second;
« no previous file with comments | « chrome/browser/download/download_file.cc ('k') | chrome/browser/download/download_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698