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 CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_STATUS_UPDATER_H_ | 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_STATUS_UPDATER_H_ |
6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_STATUS_UPDATER_H_ | 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_STATUS_UPDATER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "content/common/content_export.h" |
13 | 14 |
14 class DownloadStatusUpdaterDelegate; | 15 class DownloadStatusUpdaterDelegate; |
15 | 16 |
16 // Keeps track of download progress for the entire browser. | 17 // Keeps track of download progress for the entire browser. |
17 class DownloadStatusUpdater | 18 class CONTENT_EXPORT DownloadStatusUpdater |
18 : public base::SupportsWeakPtr<DownloadStatusUpdater> { | 19 : public base::SupportsWeakPtr<DownloadStatusUpdater> { |
19 public: | 20 public: |
20 DownloadStatusUpdater(); | 21 DownloadStatusUpdater(); |
21 ~DownloadStatusUpdater(); | 22 ~DownloadStatusUpdater(); |
22 | 23 |
23 void AddDelegate(DownloadStatusUpdaterDelegate* delegate); | 24 void AddDelegate(DownloadStatusUpdaterDelegate* delegate); |
24 void RemoveDelegate(DownloadStatusUpdaterDelegate* delegate); | 25 void RemoveDelegate(DownloadStatusUpdaterDelegate* delegate); |
25 | 26 |
26 // If the progress is known (i.e. we know the final size of all downloads), | 27 // If the progress is known (i.e. we know the final size of all downloads), |
27 // returns true and puts a percentage (in range [0-1]) in |progress|. Also | 28 // returns true and puts a percentage (in range [0-1]) in |progress|. Also |
28 // returns the number of current downloads in |download_count|. | 29 // returns the number of current downloads in |download_count|. |
29 bool GetProgress(float* progress, int* download_count); | 30 bool GetProgress(float* progress, int* download_count); |
30 | 31 |
31 private: | 32 private: |
32 // Returns the number of downloads that are in progress. | 33 // Returns the number of downloads that are in progress. |
33 int64 GetInProgressDownloadCount(); | 34 int64 GetInProgressDownloadCount(); |
34 | 35 |
35 typedef std::set<DownloadStatusUpdaterDelegate*> DelegateSet; | 36 typedef std::set<DownloadStatusUpdaterDelegate*> DelegateSet; |
36 DelegateSet delegates_; | 37 DelegateSet delegates_; |
37 | 38 |
38 DISALLOW_COPY_AND_ASSIGN(DownloadStatusUpdater); | 39 DISALLOW_COPY_AND_ASSIGN(DownloadStatusUpdater); |
39 }; | 40 }; |
40 | 41 |
41 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_STATUS_UPDATER_H_ | 42 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_STATUS_UPDATER_H_ |
OLD | NEW |