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

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

Issue 2457923002: Remove stl_util's deletion function use and ScopedVector from chrome/browser/download/. (Closed)
Patch Set: sky Created 4 years, 2 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_status_updater.cc
diff --git a/chrome/browser/download/download_status_updater.cc b/chrome/browser/download/download_status_updater.cc
index 221fb7fcc70e6416d7acaae03e8c085424217528..f6e285e11693db7386b433f9d6e76d36ad4cd9f9 100644
--- a/chrome/browser/download/download_status_updater.cc
+++ b/chrome/browser/download/download_status_updater.cc
@@ -10,7 +10,7 @@
#include "base/logging.h"
#include "base/macros.h"
-#include "base/stl_util.h"
+#include "base/memory/ptr_util.h"
#include "build/build_config.h"
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
@@ -56,7 +56,6 @@ DownloadStatusUpdater::DownloadStatusUpdater() {
}
DownloadStatusUpdater::~DownloadStatusUpdater() {
- base::STLDeleteElements(&notifiers_);
}
bool DownloadStatusUpdater::GetProgress(float* progress,
@@ -67,21 +66,19 @@ bool DownloadStatusUpdater::GetProgress(float* progress,
int64_t received_bytes = 0;
int64_t total_bytes = 0;
- for (std::vector<AllDownloadItemNotifier*>::const_iterator it =
- notifiers_.begin(); it != notifiers_.end(); ++it) {
- if ((*it)->GetManager()) {
+ for (const auto& notifier : notifiers_) {
+ if (notifier->GetManager()) {
content::DownloadManager::DownloadVector items;
- (*it)->GetManager()->GetAllDownloads(&items);
- for (content::DownloadManager::DownloadVector::const_iterator it =
- items.begin(); it != items.end(); ++it) {
- if ((*it)->GetState() == content::DownloadItem::IN_PROGRESS) {
+ notifier->GetManager()->GetAllDownloads(&items);
+ for (auto* item : items) {
+ if (item->GetState() == content::DownloadItem::IN_PROGRESS) {
++*download_count;
- if ((*it)->GetTotalBytes() <= 0) {
+ if (item->GetTotalBytes() <= 0) {
// There may or may not be more data coming down this pipe.
progress_certain = false;
} else {
- received_bytes += (*it)->GetReceivedBytes();
- total_bytes += (*it)->GetTotalBytes();
+ received_bytes += item->GetReceivedBytes();
+ total_bytes += item->GetTotalBytes();
}
}
}
@@ -94,13 +91,12 @@ bool DownloadStatusUpdater::GetProgress(float* progress,
}
void DownloadStatusUpdater::AddManager(content::DownloadManager* manager) {
- notifiers_.push_back(new AllDownloadItemNotifier(manager, this));
+ notifiers_.push_back(
+ base::MakeUnique<AllDownloadItemNotifier>(manager, this));
content::DownloadManager::DownloadVector items;
manager->GetAllDownloads(&items);
- for (content::DownloadManager::DownloadVector::const_iterator
- it = items.begin(); it != items.end(); ++it) {
- OnDownloadCreated(manager, *it);
- }
+ for (auto* item : items)
+ OnDownloadCreated(manager, item);
}
void DownloadStatusUpdater::OnDownloadCreated(
« no previous file with comments | « chrome/browser/download/download_status_updater.h ('k') | chrome/browser/download/download_status_updater_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698