OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_service.h" | 5 #include "chrome/browser/download/download_core_service.h" |
6 | 6 |
7 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
8 #include "chrome/browser/download/download_service_factory.h" | 8 #include "chrome/browser/download/download_core_service_factory.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/profiles/profile_manager.h" | 10 #include "chrome/browser/profiles/profile_manager.h" |
11 | 11 |
12 DownloadService::DownloadService() { | 12 DownloadCoreService::DownloadCoreService() = default; |
13 } | |
14 | 13 |
15 DownloadService::~DownloadService() {} | 14 DownloadCoreService::~DownloadCoreService() = default; |
16 | 15 |
17 // static | 16 // static |
18 int DownloadService::NonMaliciousDownloadCountAllProfiles() { | 17 int DownloadCoreService::NonMaliciousDownloadCountAllProfiles() { |
19 std::vector<Profile*> profiles( | 18 std::vector<Profile*> profiles( |
20 g_browser_process->profile_manager()->GetLoadedProfiles()); | 19 g_browser_process->profile_manager()->GetLoadedProfiles()); |
21 | 20 |
22 int count = 0; | 21 int count = 0; |
23 for (std::vector<Profile*>::iterator it = profiles.begin(); | 22 for (std::vector<Profile*>::iterator it = profiles.begin(); |
24 it < profiles.end(); ++it) { | 23 it < profiles.end(); ++it) { |
25 count += DownloadServiceFactory::GetForBrowserContext(*it)-> | 24 count += DownloadCoreServiceFactory::GetForBrowserContext(*it) |
26 NonMaliciousDownloadCount(); | 25 ->NonMaliciousDownloadCount(); |
27 if ((*it)->HasOffTheRecordProfile()) | 26 if ((*it)->HasOffTheRecordProfile()) |
28 count += DownloadServiceFactory::GetForBrowserContext( | 27 count += DownloadCoreServiceFactory::GetForBrowserContext( |
29 (*it)->GetOffTheRecordProfile())->NonMaliciousDownloadCount(); | 28 (*it)->GetOffTheRecordProfile()) |
| 29 ->NonMaliciousDownloadCount(); |
30 } | 30 } |
31 | 31 |
32 return count; | 32 return count; |
33 } | 33 } |
34 | 34 |
35 // static | 35 // static |
36 void DownloadService::CancelAllDownloads() { | 36 void DownloadCoreService::CancelAllDownloads() { |
37 std::vector<Profile*> profiles( | 37 std::vector<Profile*> profiles( |
38 g_browser_process->profile_manager()->GetLoadedProfiles()); | 38 g_browser_process->profile_manager()->GetLoadedProfiles()); |
39 for (std::vector<Profile*>::iterator it = profiles.begin(); | 39 for (std::vector<Profile*>::iterator it = profiles.begin(); |
40 it < profiles.end(); | 40 it < profiles.end(); ++it) { |
41 ++it) { | 41 DownloadCoreService* service = |
42 DownloadService* service = | 42 DownloadCoreServiceFactory::GetForBrowserContext(*it); |
43 DownloadServiceFactory::GetForBrowserContext(*it); | |
44 service->CancelDownloads(); | 43 service->CancelDownloads(); |
45 } | 44 } |
46 } | 45 } |
47 | |
OLD | NEW |