| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/download/download_status_updater.h" | 5 #include "chrome/browser/download/download_status_updater.h" |
| 6 | 6 |
| 7 #include <stdint.h> |
| 8 |
| 7 #include <vector> | 9 #include <vector> |
| 8 | 10 |
| 9 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/macros.h" |
| 10 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
| 14 #include "build/build_config.h" |
| 11 | 15 |
| 12 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 16 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 13 #include "ui/views/linux_ui/linux_ui.h" | 17 #include "ui/views/linux_ui/linux_ui.h" |
| 14 #endif | 18 #endif |
| 15 | 19 |
| 16 namespace { | 20 namespace { |
| 17 | 21 |
| 18 // DownloadStatusUpdater::UpdateAppIconDownloadProgress() expects to only be | 22 // DownloadStatusUpdater::UpdateAppIconDownloadProgress() expects to only be |
| 19 // called once when a DownloadItem completes, then not again (except perhaps | 23 // called once when a DownloadItem completes, then not again (except perhaps |
| 20 // until it is resumed). The existence of WasInProgressData is effectively a | 24 // until it is resumed). The existence of WasInProgressData is effectively a |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 57 |
| 54 DownloadStatusUpdater::~DownloadStatusUpdater() { | 58 DownloadStatusUpdater::~DownloadStatusUpdater() { |
| 55 STLDeleteElements(¬ifiers_); | 59 STLDeleteElements(¬ifiers_); |
| 56 } | 60 } |
| 57 | 61 |
| 58 bool DownloadStatusUpdater::GetProgress(float* progress, | 62 bool DownloadStatusUpdater::GetProgress(float* progress, |
| 59 int* download_count) const { | 63 int* download_count) const { |
| 60 *progress = 0; | 64 *progress = 0; |
| 61 *download_count = 0; | 65 *download_count = 0; |
| 62 bool progress_certain = true; | 66 bool progress_certain = true; |
| 63 int64 received_bytes = 0; | 67 int64_t received_bytes = 0; |
| 64 int64 total_bytes = 0; | 68 int64_t total_bytes = 0; |
| 65 | 69 |
| 66 for (std::vector<AllDownloadItemNotifier*>::const_iterator it = | 70 for (std::vector<AllDownloadItemNotifier*>::const_iterator it = |
| 67 notifiers_.begin(); it != notifiers_.end(); ++it) { | 71 notifiers_.begin(); it != notifiers_.end(); ++it) { |
| 68 if ((*it)->GetManager()) { | 72 if ((*it)->GetManager()) { |
| 69 content::DownloadManager::DownloadVector items; | 73 content::DownloadManager::DownloadVector items; |
| 70 (*it)->GetManager()->GetAllDownloads(&items); | 74 (*it)->GetManager()->GetAllDownloads(&items); |
| 71 for (content::DownloadManager::DownloadVector::const_iterator it = | 75 for (content::DownloadManager::DownloadVector::const_iterator it = |
| 72 items.begin(); it != items.end(); ++it) { | 76 items.begin(); it != items.end(); ++it) { |
| 73 if ((*it)->GetState() == content::DownloadItem::IN_PROGRESS) { | 77 if ((*it)->GetState() == content::DownloadItem::IN_PROGRESS) { |
| 74 ++*download_count; | 78 ++*download_count; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 float progress = 0; | 146 float progress = 0; |
| 143 int download_count = 0; | 147 int download_count = 0; |
| 144 GetProgress(&progress, &download_count); | 148 GetProgress(&progress, &download_count); |
| 145 linux_ui->SetDownloadCount(download_count); | 149 linux_ui->SetDownloadCount(download_count); |
| 146 linux_ui->SetProgressFraction(progress); | 150 linux_ui->SetProgressFraction(progress); |
| 147 } | 151 } |
| 148 #endif | 152 #endif |
| 149 // TODO(avi): Implement for Android? | 153 // TODO(avi): Implement for Android? |
| 150 } | 154 } |
| 151 #endif | 155 #endif |
| OLD | NEW |