OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_ |
6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_ | 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "chrome/browser/profiles/profile_keyed_service.h" | 13 #include "chrome/browser/profiles/profile_keyed_service.h" |
14 | 14 |
15 class ChromeDownloadManagerDelegate; | 15 class ChromeDownloadManagerDelegate; |
16 class Profile; | 16 class Profile; |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 class DownloadManager; | 19 class DownloadManager; |
20 class DownloadManagerDelegate; | |
21 } | 20 } |
22 | 21 |
23 // Owning class for ChromeDownloadManagerDelegate. | 22 // Owning class for ChromeDownloadManagerDelegate. |
24 class DownloadService : public ProfileKeyedService { | 23 class DownloadService : public ProfileKeyedService { |
25 public: | 24 public: |
26 explicit DownloadService(Profile* profile); | 25 explicit DownloadService(Profile* profile); |
27 virtual ~DownloadService(); | 26 virtual ~DownloadService(); |
28 | 27 |
29 // Register a callback to be called whenever the DownloadManager is created. | 28 // Register a callback to be called whenever the DownloadManager is created. |
30 typedef base::Callback<void(content::DownloadManager*)> | 29 typedef base::Callback<void(content::DownloadManager*)> |
31 OnManagerCreatedCallback; | 30 OnManagerCreatedCallback; |
32 void OnManagerCreated(const OnManagerCreatedCallback& cb); | 31 void OnManagerCreated(const OnManagerCreatedCallback& cb); |
33 | 32 |
34 // Get the download manager delegate, creating it if it doesn't already exist. | 33 // Get the download manager delegate, creating it if it doesn't already exist. |
35 content::DownloadManagerDelegate* GetDownloadManagerDelegate(); | 34 ChromeDownloadManagerDelegate* GetDownloadManagerDelegate(); |
36 | 35 |
37 // Has a download manager been created? | 36 // Has a download manager been created? |
38 bool HasCreatedDownloadManager(); | 37 bool HasCreatedDownloadManager(); |
39 | 38 |
40 // Number of downloads associated with this instance of the service. | 39 // Number of downloads associated with this instance of the service. |
41 int DownloadCount() const; | 40 int DownloadCount() const; |
42 | 41 |
43 // Number of downloads associated with all profiles. | 42 // Number of downloads associated with all profiles. |
44 static int DownloadCountAllProfiles(); | 43 static int DownloadCountAllProfiles(); |
45 | 44 |
(...skipping 15 matching lines...) Expand all Loading... |
61 // the history service/DB thread and must be kept alive for those | 60 // the history service/DB thread and must be kept alive for those |
62 // callbacks. | 61 // callbacks. |
63 scoped_refptr<ChromeDownloadManagerDelegate> manager_delegate_; | 62 scoped_refptr<ChromeDownloadManagerDelegate> manager_delegate_; |
64 | 63 |
65 std::vector<OnManagerCreatedCallback> on_manager_created_callbacks_; | 64 std::vector<OnManagerCreatedCallback> on_manager_created_callbacks_; |
66 | 65 |
67 DISALLOW_COPY_AND_ASSIGN(DownloadService); | 66 DISALLOW_COPY_AND_ASSIGN(DownloadService); |
68 }; | 67 }; |
69 | 68 |
70 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_ | 69 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_ |
OLD | NEW |