Chromium Code Reviews| 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..974d57fed6be0cb08e4c356710ba7c4d8b4c824b 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(¬ifiers_); |
| } |
| 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) { |
|
sky
2016/10/28 13:33:59
auto*
Avi (use Gerrit)
2016/10/28 14:04:10
Done.
|
| + 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,12 +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) { |
|
sky
2016/10/28 13:33:59
no {} and auto*
Avi (use Gerrit)
2016/10/28 14:04:10
Done.
|
| + OnDownloadCreated(manager, item); |
| } |
| } |