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 GURL& url, | |
37 const std::string& registration_id, | |
38 const std::string& title, | |
39 int64_t total_download_size) override; | |
35 | 40 |
36 // components::offline_items_collection::OfflineContentProvider overrides. | 41 // components::offline_items_collection::OfflineContentProvider overrides. |
37 bool AreItemsAvailable() override; | 42 bool AreItemsAvailable() override; |
38 void OpenItem(const offline_items_collection::ContentId& content_id) override; | 43 void OpenItem(const offline_items_collection::ContentId& content_id) override; |
39 void RemoveItem( | 44 void RemoveItem( |
40 const offline_items_collection::ContentId& content_id) override; | 45 const offline_items_collection::ContentId& content_id) override; |
41 void CancelDownload( | 46 void CancelDownload( |
42 const offline_items_collection::ContentId& content_id) override; | 47 const offline_items_collection::ContentId& content_id) override; |
43 void PauseDownload( | 48 void PauseDownload( |
44 const offline_items_collection::ContentId& content_id) override; | 49 const offline_items_collection::ContentId& content_id) override; |
45 void ResumeDownload( | 50 void ResumeDownload( |
46 const offline_items_collection::ContentId& content_id) override; | 51 const offline_items_collection::ContentId& content_id) override; |
47 const offline_items_collection::OfflineItem* GetItemById( | 52 const offline_items_collection::OfflineItem* GetItemById( |
48 const offline_items_collection::ContentId& content_id) override; | 53 const offline_items_collection::ContentId& content_id) override; |
49 offline_items_collection::OfflineContentProvider::OfflineItemList | 54 offline_items_collection::OfflineContentProvider::OfflineItemList |
50 GetAllItems() override; | 55 GetAllItems() override; |
51 void GetVisualsForItem(const offline_items_collection::ContentId& id, | 56 void GetVisualsForItem(const offline_items_collection::ContentId& id, |
52 const VisualsCallback& callback) override; | 57 const VisualsCallback& callback) override; |
53 void AddObserver(Observer* observer) override; | 58 void AddObserver(Observer* observer) override; |
54 void RemoveObserver(Observer* observer) override; | 59 void RemoveObserver(Observer* observer) override; |
55 | 60 |
56 private: | 61 private: |
57 // This object is owned by the Profile. | 62 // This object is owned by the Profile. |
58 Profile* profile_; | 63 Profile* profile_; |
59 | 64 |
60 // The |delegate| is owned externally and will remove itself prior to | 65 // The |delegate| is owned externally and will remove itself prior to |
61 // deletion. | 66 // deletion. |
62 content::BackgroundFetchClient::Delegate* delegate_; | 67 content::BackgroundFetchClient::Delegate* delegate_ = nullptr; |
Peter Beverloo
2017/04/24 14:39:15
Should probably merge this in the previous CL.
| |
63 | 68 |
64 // The name of the namespace registered with the aggregator. | 69 // The name of the namespace registered with the aggregator. |
65 std::string namespace_; | 70 std::string namespace_; |
66 | 71 |
72 // A list of all currently registered observers. | |
73 base::ObserverList<OfflineContentProvider::Observer> observers_; | |
74 | |
67 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchClientImpl); | 75 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchClientImpl); |
68 }; | 76 }; |
69 | 77 |
70 #endif // CHROME_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CLIENT_IMPL_H_ | 78 #endif // CHROME_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CLIENT_IMPL_H_ |
OLD | NEW |