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

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

Issue 214523003: Before deleting a profile, cancel all in-progress downloads (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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
« no previous file with comments | « chrome/browser/download/download_service.h ('k') | chrome/browser/profiles/profile_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/download_service.cc
diff --git a/chrome/browser/download/download_service.cc b/chrome/browser/download/download_service.cc
index 13503dc43f2a79aac29a515affd2b74f96ff723e..fd87ca02aa2bef88feb72aa3adc2e8247f60a1d4 100644
--- a/chrome/browser/download/download_service.cc
+++ b/chrome/browser/download/download_service.cc
@@ -95,6 +95,22 @@ int DownloadService::NonMaliciousDownloadCount() const {
NonMaliciousInProgressCount();
}
+void DownloadService::CancelDownloads() {
+ if (!download_manager_created_)
+ return;
+
+ DownloadManager* download_manager =
+ BrowserContext::GetDownloadManager(profile_);
+ DownloadManager::DownloadVector downloads;
+ download_manager->GetAllDownloads(&downloads);
+ for (DownloadManager::DownloadVector::iterator it = downloads.begin();
+ it != downloads.end();
+ ++it) {
+ if ((*it)->GetState() == content::DownloadItem::IN_PROGRESS)
+ (*it)->Cancel(false);
+ }
+}
+
// static
int DownloadService::NonMaliciousDownloadCountAllProfiles() {
std::vector<Profile*> profiles(
@@ -120,17 +136,9 @@ void DownloadService::CancelAllDownloads() {
for (std::vector<Profile*>::iterator it = profiles.begin();
it < profiles.end();
++it) {
- content::DownloadManager* download_manager =
- content::BrowserContext::GetDownloadManager(*it);
- content::DownloadManager::DownloadVector downloads;
- download_manager->GetAllDownloads(&downloads);
- for (content::DownloadManager::DownloadVector::iterator it =
- downloads.begin();
- it != downloads.end();
- ++it) {
- if ((*it)->GetState() == content::DownloadItem::IN_PROGRESS)
- (*it)->Cancel(false);
- }
+ DownloadService* service =
+ DownloadServiceFactory::GetForBrowserContext(*it);
+ service->CancelDownloads();
}
}
« no previous file with comments | « chrome/browser/download/download_service.h ('k') | chrome/browser/profiles/profile_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698