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 "base/memory/scoped_ptr.h" |
13 #include "chrome/browser/profiles/profile_keyed_service.h" | 14 #include "chrome/browser/profiles/profile_keyed_service.h" |
14 | 15 |
15 class ChromeDownloadManagerDelegate; | 16 class ChromeDownloadManagerDelegate; |
| 17 class DownloadHistory; |
16 class Profile; | 18 class Profile; |
17 | 19 |
18 namespace content { | 20 namespace content { |
19 class DownloadManager; | 21 class DownloadManager; |
20 } | 22 } |
21 | 23 |
22 // Owning class for ChromeDownloadManagerDelegate. | 24 // Owning class for ChromeDownloadManagerDelegate. |
23 class DownloadService : public ProfileKeyedService { | 25 class DownloadService : public ProfileKeyedService { |
24 public: | 26 public: |
25 explicit DownloadService(Profile* profile); | 27 explicit DownloadService(Profile* profile); |
26 virtual ~DownloadService(); | 28 virtual ~DownloadService(); |
27 | 29 |
28 // Get the download manager delegate, creating it if it doesn't already exist. | 30 // Get the download manager delegate, creating it if it doesn't already exist. |
29 ChromeDownloadManagerDelegate* GetDownloadManagerDelegate(); | 31 ChromeDownloadManagerDelegate* GetDownloadManagerDelegate(); |
30 | 32 |
| 33 // Get the interface to the history system. Returns NULL if profile is |
| 34 // incognito or if the DownloadManager hasn't been created yet or if there is |
| 35 // no HistoryService for profile. |
| 36 DownloadHistory* GetDownloadHistory(); |
| 37 |
31 // Has a download manager been created? | 38 // Has a download manager been created? |
32 bool HasCreatedDownloadManager(); | 39 bool HasCreatedDownloadManager(); |
33 | 40 |
34 // Number of downloads associated with this instance of the service. | 41 // Number of downloads associated with this instance of the service. |
35 int DownloadCount() const; | 42 int DownloadCount() const; |
36 | 43 |
37 // Number of downloads associated with all profiles. | 44 // Number of downloads associated with all profiles. |
38 static int DownloadCountAllProfiles(); | 45 static int DownloadCountAllProfiles(); |
39 | 46 |
40 // Sets the DownloadManagerDelegate associated with this object and | 47 // Sets the DownloadManagerDelegate associated with this object and |
41 // its DownloadManager. Takes ownership of |delegate|, and destroys | 48 // its DownloadManager. Takes ownership of |delegate|, and destroys |
42 // the previous delegate. For testing. | 49 // the previous delegate. For testing. |
43 void SetDownloadManagerDelegateForTesting( | 50 void SetDownloadManagerDelegateForTesting( |
44 ChromeDownloadManagerDelegate* delegate); | 51 ChromeDownloadManagerDelegate* delegate); |
45 | 52 |
46 // Will be called to release references on other services as part | 53 // Will be called to release references on other services as part |
47 // of Profile shutdown. | 54 // of Profile shutdown. |
48 virtual void Shutdown() OVERRIDE; | 55 virtual void Shutdown() OVERRIDE; |
49 | 56 |
50 private: | 57 private: |
51 bool download_manager_created_; | 58 bool download_manager_created_; |
52 Profile* profile_; | 59 Profile* profile_; |
53 | 60 |
54 // ChromeDownloadManagerDelegate may be the target of callbacks from | 61 // ChromeDownloadManagerDelegate may be the target of callbacks from |
55 // the history service/DB thread and must be kept alive for those | 62 // the history service/DB thread and must be kept alive for those |
56 // callbacks. | 63 // callbacks. |
57 scoped_refptr<ChromeDownloadManagerDelegate> manager_delegate_; | 64 scoped_refptr<ChromeDownloadManagerDelegate> manager_delegate_; |
58 | 65 |
| 66 scoped_ptr<DownloadHistory> download_history_; |
| 67 |
59 DISALLOW_COPY_AND_ASSIGN(DownloadService); | 68 DISALLOW_COPY_AND_ASSIGN(DownloadService); |
60 }; | 69 }; |
61 | 70 |
62 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_ | 71 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_ |
OLD | NEW |