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 #include <algorithm> | 5 #include <algorithm> |
6 #include <string> | 6 #include <string> |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 if (!provider->AreItemsAvailable()) | 138 if (!provider->AreItemsAvailable()) |
139 continue; | 139 continue; |
140 | 140 |
141 OfflineItemList provider_items = provider->GetAllItems(); | 141 OfflineItemList provider_items = provider->GetAllItems(); |
142 items.insert(items.end(), provider_items.begin(), provider_items.end()); | 142 items.insert(items.end(), provider_items.begin(), provider_items.end()); |
143 } | 143 } |
144 | 144 |
145 return items; | 145 return items; |
146 } | 146 } |
147 | 147 |
| 148 void OfflineContentAggregator::GetVisualsForItem( |
| 149 const ContentId& id, |
| 150 const VisualsCallback& callback) { |
| 151 auto it = providers_.find(id.name_space); |
| 152 |
| 153 if (it == providers_.end()) { |
| 154 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 155 FROM_HERE, base::Bind(callback, id, nullptr)); |
| 156 return; |
| 157 } |
| 158 |
| 159 it->second->GetVisualsForItem(id, callback); |
| 160 } |
| 161 |
148 void OfflineContentAggregator::AddObserver( | 162 void OfflineContentAggregator::AddObserver( |
149 OfflineContentProvider::Observer* observer) { | 163 OfflineContentProvider::Observer* observer) { |
150 DCHECK(observer); | 164 DCHECK(observer); |
151 if (observers_.HasObserver(observer)) | 165 if (observers_.HasObserver(observer)) |
152 return; | 166 return; |
153 | 167 |
154 observers_.AddObserver(observer); | 168 observers_.AddObserver(observer); |
155 | 169 |
156 if (sent_on_items_available_) { | 170 if (sent_on_items_available_) { |
157 base::ThreadTaskRunnerHandle::Get()->PostTask( | 171 base::ThreadTaskRunnerHandle::Get()->PostTask( |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 | 268 |
255 void OfflineContentAggregator::RunIfReady(OfflineContentProvider* provider, | 269 void OfflineContentAggregator::RunIfReady(OfflineContentProvider* provider, |
256 const base::Closure& action) { | 270 const base::Closure& action) { |
257 if (provider->AreItemsAvailable()) | 271 if (provider->AreItemsAvailable()) |
258 action.Run(); | 272 action.Run(); |
259 else | 273 else |
260 pending_actions_[provider].push_back(action); | 274 pending_actions_[provider].push_back(action); |
261 } | 275 } |
262 | 276 |
263 } // namespace offline_items_collection | 277 } // namespace offline_items_collection |
OLD | NEW |