diff options
Diffstat (limited to 'chrome/browser/download/download_service.cc')
-rw-r--r-- | chrome/browser/download/download_service.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/chrome/browser/download/download_service.cc b/chrome/browser/download/download_service.cc index 659af4f..6b5fcb2 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,27 @@ bool DownloadService::HasCreatedDownloadManager() { return download_manager_created_; } +int DownloadService::DownloadCount() const { + return download_manager_created_ ? manager_->in_progress_count() : 0; +} + +// static +int DownloadService::DownloadCountAllProfiles() { + 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. |