Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / chrome / browser / download / download_status_updater.h
blob1dfd4ba7266fca0d9015db05cced0d436a3dfd80
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_STATUS_UPDATER_H_
6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_STATUS_UPDATER_H_
8 #include <set>
10 #include "base/basictypes.h"
11 #include "chrome/browser/download/all_download_item_notifier.h"
12 #include "content/public/browser/download_item.h"
13 #include "content/public/browser/download_manager.h"
15 // Keeps track of download progress for the entire browser.
16 class DownloadStatusUpdater
17 : public AllDownloadItemNotifier::Observer {
18 public:
19 DownloadStatusUpdater();
20 ~DownloadStatusUpdater() override;
22 // Fills in |*download_count| with the number of currently active downloads.
23 // If we know the final size of all downloads, this routine returns true
24 // with |*progress| set to the percentage complete of all in-progress
25 // downloads. Otherwise, it returns false.
26 bool GetProgress(float* progress, int* download_count) const;
28 // Add the specified DownloadManager to the list of managers for which
29 // this object reports status.
30 // The manager must not have previously been added to this updater.
31 // The updater will automatically disassociate itself from the
32 // manager when the manager is shutdown.
33 void AddManager(content::DownloadManager* manager);
35 // AllDownloadItemNotifier::Observer
36 void OnDownloadCreated(content::DownloadManager* manager,
37 content::DownloadItem* item) override;
38 void OnDownloadUpdated(content::DownloadManager* manager,
39 content::DownloadItem* item) override;
41 protected:
42 // Platform-specific function to update the platform UI for download progress.
43 // |download| is the download item that changed. Implementations should not
44 // hold the value of |download| as it is not guaranteed to remain valid.
45 // Virtual to be overridable for testing.
46 virtual void UpdateAppIconDownloadProgress(content::DownloadItem* download);
48 private:
49 std::vector<AllDownloadItemNotifier*> notifiers_;
51 DISALLOW_COPY_AND_ASSIGN(DownloadStatusUpdater);
54 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_STATUS_UPDATER_H_