Chromium Code Reviews| Index: chrome/browser/download/download_service.cc |
| diff --git a/chrome/browser/download/download_service.cc b/chrome/browser/download/download_service.cc |
| index 659af4f50ad20a15bf2dea19607037eeb26bc615..74f06c3f21c9334994b78fc582b5c2c22dc267a0 100644 |
| --- a/chrome/browser/download/download_service.cc |
| +++ b/chrome/browser/download/download_service.cc |
| @@ -6,7 +6,9 @@ |
| #include "chrome/browser/browser_process.h" |
| #include "chrome/browser/download/chrome_download_manager_delegate.h" |
| +#include "chrome/browser/download/download_service_factory.h" |
| #include "chrome/browser/profiles/profile.h" |
| +#include "chrome/browser/profiles/profile_manager.h" |
| #include "content/browser/download/download_manager.h" |
| DownloadService::DownloadService(Profile* profile) |
| @@ -34,6 +36,30 @@ bool DownloadService::HasCreatedDownloadManager() { |
| return download_manager_created_; |
| } |
| +int DownloadService::DownloadCount() { |
| + if (!download_manager_created_) |
| + return 0; |
| + |
| + return manager_->in_progress_count(); |
|
achuithb
2011/10/14 19:22:10
nit: this is fine, but have you considered
return
Randy Smith (Not in Mondays)
2011/10/14 19:30:47
Done.
|
| +} |
| + |
| +// static |
| +int DownloadService::TotalDownloadCount() { |
| + std::vector<Profile*> profiles( |
| + g_browser_process->profile_manager()->GetLoadedProfiles()); |
| + |
| + int count = 0; |
| + for (std::vector<Profile*>::iterator it = profiles.begin(); |
| + it < profiles.end(); ++it) { |
| + count += DownloadServiceFactory::GetForProfile(*it)->DownloadCount(); |
| + if ((*it)->HasOffTheRecordProfile()) |
| + count += DownloadServiceFactory::GetForProfile( |
| + (*it)->GetOffTheRecordProfile())->DownloadCount(); |
| + } |
| + |
| + return count; |
| +} |
| + |
| void DownloadService::SetDownloadManagerDelegateForTesting( |
| ChromeDownloadManagerDelegate* new_delegate) { |
| // Guarantee everything is properly initialized. |