OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 explicit DownloadService(Profile* profile); | 22 explicit DownloadService(Profile* profile); |
23 virtual ~DownloadService(); | 23 virtual ~DownloadService(); |
24 | 24 |
25 // Get the download manager. Creates the download manager if | 25 // Get the download manager. Creates the download manager if |
26 // it does not already exist. | 26 // it does not already exist. |
27 DownloadManager* GetDownloadManager(); | 27 DownloadManager* GetDownloadManager(); |
28 | 28 |
29 // Has a download manager been created? (By calling above function.) | 29 // Has a download manager been created? (By calling above function.) |
30 bool HasCreatedDownloadManager(); | 30 bool HasCreatedDownloadManager(); |
31 | 31 |
| 32 // Number of downloads associated with this instance of the service. |
| 33 int DownloadCount() const; |
| 34 |
| 35 // Number of downloads associated with all profiles. |
| 36 static int DownloadCountAllProfiles(); |
| 37 |
32 // Sets the DownloadManagerDelegate associated with this object and | 38 // Sets the DownloadManagerDelegate associated with this object and |
33 // its DownloadManager. Takes ownership of |delegate|, and destroys | 39 // its DownloadManager. Takes ownership of |delegate|, and destroys |
34 // the previous delegate. For testing. | 40 // the previous delegate. For testing. |
35 void SetDownloadManagerDelegateForTesting( | 41 void SetDownloadManagerDelegateForTesting( |
36 ChromeDownloadManagerDelegate* delegate); | 42 ChromeDownloadManagerDelegate* delegate); |
37 | 43 |
38 // Will be called to release references on other services as part | 44 // Will be called to release references on other services as part |
39 // of Profile shutdown. | 45 // of Profile shutdown. |
40 virtual void Shutdown() OVERRIDE; | 46 virtual void Shutdown() OVERRIDE; |
41 | 47 |
42 private: | 48 private: |
43 bool download_manager_created_; | 49 bool download_manager_created_; |
44 Profile* profile_; | 50 Profile* profile_; |
45 | 51 |
46 // Both of these objects are owned by this class. | 52 // Both of these objects are owned by this class. |
47 // DownloadManager is RefCountedThreadSafe because of references | 53 // DownloadManager is RefCountedThreadSafe because of references |
48 // from DownloadFile objects on the FILE thread, and may need to be | 54 // from DownloadFile objects on the FILE thread, and may need to be |
49 // kept alive until those objects are deleted. | 55 // kept alive until those objects are deleted. |
50 // ChromeDownloadManagerDelegate may be the target of callbacks from | 56 // ChromeDownloadManagerDelegate may be the target of callbacks from |
51 // the history service/DB thread and must be kept alive for those | 57 // the history service/DB thread and must be kept alive for those |
52 // callbacks. | 58 // callbacks. |
53 scoped_refptr<DownloadManager> manager_; | 59 scoped_refptr<DownloadManager> manager_; |
54 scoped_refptr<ChromeDownloadManagerDelegate> manager_delegate_; | 60 scoped_refptr<ChromeDownloadManagerDelegate> manager_delegate_; |
55 | 61 |
56 DISALLOW_COPY_AND_ASSIGN(DownloadService); | 62 DISALLOW_COPY_AND_ASSIGN(DownloadService); |
57 }; | 63 }; |
58 | 64 |
59 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_ | 65 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SERVICE_H_ |
OLD | NEW |