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 COMPONENTS_OFFLINE_ITEMS_COLLETION_CORE_OFFLINE_CONTENT_AGGREGATOR_H_ | 5 #ifndef COMPONENTS_OFFLINE_ITEMS_COLLETION_CORE_OFFLINE_CONTENT_AGGREGATOR_H_ |
6 #define COMPONENTS_OFFLINE_ITEMS_COLLETION_CORE_OFFLINE_CONTENT_AGGREGATOR_H_ | 6 #define COMPONENTS_OFFLINE_ITEMS_COLLETION_CORE_OFFLINE_CONTENT_AGGREGATOR_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
16 #include "base/supports_user_data.h" | 16 #include "base/supports_user_data.h" |
| 17 #include "components/keyed_service/core/keyed_service.h" |
17 #include "components/offline_items_collection/core/offline_content_provider.h" | 18 #include "components/offline_items_collection/core/offline_content_provider.h" |
18 #include "url/gurl.h" | 19 #include "url/gurl.h" |
19 | 20 |
20 namespace offline_items_collection { | 21 namespace offline_items_collection { |
21 | 22 |
22 struct OfflineItem; | 23 struct OfflineItem; |
23 | 24 |
24 // An implementation of OfflineContentProvider that aggregates multiple other | 25 // An implementation of OfflineContentProvider that aggregates multiple other |
25 // providers into a single set of data. See the OfflineContentProvider header | 26 // providers into a single set of data. See the OfflineContentProvider header |
26 // for comments on expected behavior of the interface. This implementation has | 27 // for comments on expected behavior of the interface. This implementation has |
(...skipping 13 matching lines...) Expand all Loading... |
40 // actions. | 41 // actions. |
41 // | 42 // |
42 // Routing to the correct provider: | 43 // Routing to the correct provider: |
43 // - Providers must be registered with a unique namespace. The OfflineItems | 44 // - Providers must be registered with a unique namespace. The OfflineItems |
44 // created by the provider must also be tagged with the same namespace so that | 45 // created by the provider must also be tagged with the same namespace so that |
45 // actions taken on the OfflineItem can be routed to the correct internal | 46 // actions taken on the OfflineItem can be routed to the correct internal |
46 // provider. The namespace must also be consistent across startups. | 47 // provider. The namespace must also be consistent across startups. |
47 class OfflineContentAggregator : public OfflineContentProvider, | 48 class OfflineContentAggregator : public OfflineContentProvider, |
48 public OfflineContentProvider::Observer, | 49 public OfflineContentProvider::Observer, |
49 public base::SupportsUserData, | 50 public base::SupportsUserData, |
50 public base::SupportsUserData::Data { | 51 public KeyedService { |
51 public: | 52 public: |
52 OfflineContentAggregator(); | 53 OfflineContentAggregator(); |
53 ~OfflineContentAggregator() override; | 54 ~OfflineContentAggregator() override; |
54 | 55 |
55 // Registers a provider and associates it with all OfflineItems with | 56 // Registers a provider and associates it with all OfflineItems with |
56 // |name_space|. UI actions taken on OfflineItems with |name_space| will be | 57 // |name_space|. UI actions taken on OfflineItems with |name_space| will be |
57 // routed to |provider|. |provider| is expected to only expose OfflineItems | 58 // routed to |provider|. |provider| is expected to only expose OfflineItems |
58 // with |name_space| set. | 59 // with |name_space| set. |
59 void RegisterProvider(const std::string& name_space, | 60 void RegisterProvider(const std::string& name_space, |
60 OfflineContentProvider* provider); | 61 OfflineContentProvider* provider); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 bool sent_on_items_available_; | 127 bool sent_on_items_available_; |
127 | 128 |
128 base::WeakPtrFactory<OfflineContentAggregator> weak_ptr_factory_; | 129 base::WeakPtrFactory<OfflineContentAggregator> weak_ptr_factory_; |
129 | 130 |
130 DISALLOW_COPY_AND_ASSIGN(OfflineContentAggregator); | 131 DISALLOW_COPY_AND_ASSIGN(OfflineContentAggregator); |
131 }; | 132 }; |
132 | 133 |
133 } // namespace offline_items_collection | 134 } // namespace offline_items_collection |
134 | 135 |
135 #endif // COMPONENTS_OFFLINE_ITEMS_COLLETION_CORE_OFFLINE_CONTENT_AGGREGATOR_H_ | 136 #endif // COMPONENTS_OFFLINE_ITEMS_COLLETION_CORE_OFFLINE_CONTENT_AGGREGATOR_H_ |
OLD | NEW |