OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_BACKGROUND_FETCH_BACKGROUND_FETCH_CLIENT_IMPL_H_ | 5 #ifndef CHROME_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CLIENT_IMPL_H_ |
6 #define CHROME_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CLIENT_IMPL_H_ | 6 #define CHROME_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CLIENT_IMPL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/observer_list.h" |
11 #include "components/keyed_service/core/keyed_service.h" | 12 #include "components/keyed_service/core/keyed_service.h" |
12 #include "components/offline_items_collection/core/offline_content_provider.h" | 13 #include "components/offline_items_collection/core/offline_content_provider.h" |
13 #include "content/public/browser/background_fetch_client.h" | 14 #include "content/public/browser/background_fetch_client.h" |
14 | 15 |
15 namespace offline_items_collection { | 16 namespace offline_items_collection { |
16 struct ContentId; | 17 struct ContentId; |
17 struct OfflineItem; | 18 struct OfflineItem; |
18 } // namespace offline_items_collection | 19 } // namespace offline_items_collection |
19 | 20 |
20 class Profile; | 21 class Profile; |
21 | 22 |
22 class BackgroundFetchClientImpl | 23 class BackgroundFetchClientImpl |
23 : public content::BackgroundFetchClient, | 24 : public content::BackgroundFetchClient, |
24 public offline_items_collection::OfflineContentProvider, | 25 public offline_items_collection::OfflineContentProvider, |
25 public KeyedService { | 26 public KeyedService { |
26 public: | 27 public: |
27 explicit BackgroundFetchClientImpl(Profile* profile); | 28 explicit BackgroundFetchClientImpl(Profile* profile); |
28 ~BackgroundFetchClientImpl() override; | 29 ~BackgroundFetchClientImpl() override; |
29 | 30 |
30 // KeyedService override. | 31 // KeyedService override. |
31 void Shutdown() override; | 32 void Shutdown() override; |
32 | 33 |
33 // content::BackgroundFetchClient implementation. | 34 // content::BackgroundFetchClient implementation. |
34 void SetDelegate(content::BackgroundFetchClient::Delegate* delegate) override; | 35 void SetDelegate(content::BackgroundFetchClient::Delegate* delegate) override; |
| 36 void AddDownload(const std::string& registration_id, |
| 37 const std::string& title, |
| 38 int64_t total_download_size) override; |
35 | 39 |
36 // components::offline_items_collection::OfflineContentProvider overrides. | 40 // components::offline_items_collection::OfflineContentProvider overrides. |
37 bool AreItemsAvailable() override; | 41 bool AreItemsAvailable() override; |
38 void OpenItem(const offline_items_collection::ContentId& content_id) override; | 42 void OpenItem(const offline_items_collection::ContentId& content_id) override; |
39 void RemoveItem( | 43 void RemoveItem( |
40 const offline_items_collection::ContentId& content_id) override; | 44 const offline_items_collection::ContentId& content_id) override; |
41 void CancelDownload( | 45 void CancelDownload( |
42 const offline_items_collection::ContentId& content_id) override; | 46 const offline_items_collection::ContentId& content_id) override; |
43 void PauseDownload( | 47 void PauseDownload( |
44 const offline_items_collection::ContentId& content_id) override; | 48 const offline_items_collection::ContentId& content_id) override; |
45 void ResumeDownload( | 49 void ResumeDownload( |
46 const offline_items_collection::ContentId& content_id) override; | 50 const offline_items_collection::ContentId& content_id) override; |
47 const offline_items_collection::OfflineItem* GetItemById( | 51 const offline_items_collection::OfflineItem* GetItemById( |
48 const offline_items_collection::ContentId& content_id) override; | 52 const offline_items_collection::ContentId& content_id) override; |
49 offline_items_collection::OfflineContentProvider::OfflineItemList | 53 offline_items_collection::OfflineContentProvider::OfflineItemList |
50 GetAllItems() override; | 54 GetAllItems() override; |
51 void GetVisualsForItem(const offline_items_collection::ContentId& id, | 55 void GetVisualsForItem(const offline_items_collection::ContentId& id, |
52 const VisualsCallback& callback) override; | 56 const VisualsCallback& callback) override; |
53 void AddObserver(Observer* observer) override; | 57 void AddObserver(Observer* observer) override; |
54 void RemoveObserver(Observer* observer) override; | 58 void RemoveObserver(Observer* observer) override; |
55 | 59 |
56 private: | 60 private: |
57 // This object is owned by the Profile. | 61 // This object is owned by the Profile. |
58 Profile* profile_; | 62 Profile* profile_; |
59 | 63 |
60 // The |delegate| is owned externally and will remove itself prior to | 64 // The |delegate| is owned externally and will remove itself prior to |
61 // deletion. | 65 // deletion. |
62 content::BackgroundFetchClient::Delegate* delegate_; | 66 content::BackgroundFetchClient::Delegate* delegate_ = nullptr; |
63 | 67 |
64 // The name of the namespace registered with the aggregator. | 68 // The name of the namespace registered with the aggregator. |
65 std::string namespace_; | 69 std::string namespace_; |
66 | 70 |
| 71 // A list of all currently registered observers. |
| 72 base::ObserverList<OfflineContentProvider::Observer> observers_; |
| 73 |
67 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchClientImpl); | 74 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchClientImpl); |
68 }; | 75 }; |
69 | 76 |
70 #endif // CHROME_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CLIENT_IMPL_H_ | 77 #endif // CHROME_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CLIENT_IMPL_H_ |
OLD | NEW |