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

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

Issue 7466033: Fix warning prompting on closing a window that will cancel downloads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Last little things from Achuith and Miranda. Created 9 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_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.

Powered by Google App Engine
This is Rietveld 408576698