OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/media/router/mojo/media_router_mojo_impl.h" | 5 #include "chrome/browser/media/router/mojo/media_router_mojo_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 194 |
195 auto* sinks_query = it->second; | 195 auto* sinks_query = it->second; |
196 sinks_query->has_cached_result = true; | 196 sinks_query->has_cached_result = true; |
197 sinks_query->origins.swap(origin_list); | 197 sinks_query->origins.swap(origin_list); |
198 sinks_query->cached_sink_list.swap(sink_list); | 198 sinks_query->cached_sink_list.swap(sink_list); |
199 | 199 |
200 if (!sinks_query->observers.might_have_observers()) { | 200 if (!sinks_query->observers.might_have_observers()) { |
201 DVLOG_WITH_INSTANCE(1) | 201 DVLOG_WITH_INSTANCE(1) |
202 << "Received sink list without any active observers: " << media_source; | 202 << "Received sink list without any active observers: " << media_source; |
203 } else { | 203 } else { |
204 FOR_EACH_OBSERVER( | 204 for (auto& observer : sinks_query->observers) { |
205 MediaSinksObserver, sinks_query->observers, | 205 observer.OnSinksUpdated(sinks_query->cached_sink_list, |
206 OnSinksUpdated(sinks_query->cached_sink_list, sinks_query->origins)); | 206 sinks_query->origins); |
| 207 } |
207 } | 208 } |
208 } | 209 } |
209 | 210 |
210 void MediaRouterMojoImpl::OnRoutesUpdated( | 211 void MediaRouterMojoImpl::OnRoutesUpdated( |
211 std::vector<mojom::MediaRoutePtr> routes, | 212 std::vector<mojom::MediaRoutePtr> routes, |
212 const std::string& media_source, | 213 const std::string& media_source, |
213 const std::vector<std::string>& joinable_route_ids) { | 214 const std::vector<std::string>& joinable_route_ids) { |
214 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 215 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
215 | 216 |
216 DVLOG_WITH_INSTANCE(1) << "OnRoutesUpdated"; | 217 DVLOG_WITH_INSTANCE(1) << "OnRoutesUpdated"; |
217 auto it = routes_queries_.find(media_source); | 218 auto it = routes_queries_.find(media_source); |
218 if (it == routes_queries_.end() || | 219 if (it == routes_queries_.end() || |
219 !(it->second->observers.might_have_observers())) { | 220 !(it->second->observers.might_have_observers())) { |
220 DVLOG_WITH_INSTANCE(1) | 221 DVLOG_WITH_INSTANCE(1) |
221 << "Received route list without any active observers: " << media_source; | 222 << "Received route list without any active observers: " << media_source; |
222 return; | 223 return; |
223 } | 224 } |
224 | 225 |
225 std::vector<MediaRoute> routes_converted; | 226 std::vector<MediaRoute> routes_converted; |
226 routes_converted.reserve(routes.size()); | 227 routes_converted.reserve(routes.size()); |
227 for (size_t i = 0; i < routes.size(); ++i) | 228 for (size_t i = 0; i < routes.size(); ++i) |
228 routes_converted.push_back(routes[i].To<MediaRoute>()); | 229 routes_converted.push_back(routes[i].To<MediaRoute>()); |
229 | 230 |
230 FOR_EACH_OBSERVER( | 231 for (auto& observer : it->second->observers) |
231 MediaRoutesObserver, it->second->observers, | 232 observer.OnRoutesUpdated(routes_converted, joinable_route_ids); |
232 OnRoutesUpdated(routes_converted, joinable_route_ids)); | |
233 } | 233 } |
234 | 234 |
235 void MediaRouterMojoImpl::RouteResponseReceived( | 235 void MediaRouterMojoImpl::RouteResponseReceived( |
236 const std::string& presentation_id, | 236 const std::string& presentation_id, |
237 bool incognito, | 237 bool incognito, |
238 const std::vector<MediaRouteResponseCallback>& callbacks, | 238 const std::vector<MediaRouteResponseCallback>& callbacks, |
239 mojom::MediaRoutePtr media_route, | 239 mojom::MediaRoutePtr media_route, |
240 const base::Optional<std::string>& error_text, | 240 const base::Optional<std::string>& error_text, |
241 mojom::RouteRequestResultCode result_code) { | 241 mojom::RouteRequestResultCode result_code) { |
242 std::unique_ptr<RouteRequestResult> result; | 242 std::unique_ptr<RouteRequestResult> result; |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 DVLOG_WITH_INSTANCE(1) << "OnRouteMessagesReceived"; | 703 DVLOG_WITH_INSTANCE(1) << "OnRouteMessagesReceived"; |
704 | 704 |
705 if (messages.empty()) | 705 if (messages.empty()) |
706 return; | 706 return; |
707 | 707 |
708 auto* observer_list = message_observers_.get(route_id); | 708 auto* observer_list = message_observers_.get(route_id); |
709 if (!observer_list) { | 709 if (!observer_list) { |
710 return; | 710 return; |
711 } | 711 } |
712 | 712 |
713 FOR_EACH_OBSERVER(RouteMessageObserver, *observer_list, | 713 for (auto& observer : *observer_list) |
714 OnMessagesReceived(messages)); | 714 observer.OnMessagesReceived(messages); |
715 } | 715 } |
716 | 716 |
717 void MediaRouterMojoImpl::OnSinkAvailabilityUpdated( | 717 void MediaRouterMojoImpl::OnSinkAvailabilityUpdated( |
718 SinkAvailability availability) { | 718 SinkAvailability availability) { |
719 if (availability_ == availability) | 719 if (availability_ == availability) |
720 return; | 720 return; |
721 | 721 |
722 availability_ = availability; | 722 availability_ = availability; |
723 if (availability_ == mojom::MediaRouter::SinkAvailability::UNAVAILABLE) { | 723 if (availability_ == mojom::MediaRouter::SinkAvailability::UNAVAILABLE) { |
724 // Sinks are no longer available. MRPM has already removed all sink queries. | 724 // Sinks are no longer available. MRPM has already removed all sink queries. |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
972 base::Unretained(this), source_id)); | 972 base::Unretained(this), source_id)); |
973 } | 973 } |
974 | 974 |
975 void MediaRouterMojoImpl::DoUpdateMediaSinks( | 975 void MediaRouterMojoImpl::DoUpdateMediaSinks( |
976 const MediaSource::Id& source_id) { | 976 const MediaSource::Id& source_id) { |
977 DVLOG_WITH_INSTANCE(1) << "DoUpdateMediaSinks" << source_id; | 977 DVLOG_WITH_INSTANCE(1) << "DoUpdateMediaSinks" << source_id; |
978 media_route_provider_->UpdateMediaSinks(source_id); | 978 media_route_provider_->UpdateMediaSinks(source_id); |
979 } | 979 } |
980 | 980 |
981 } // namespace media_router | 981 } // namespace media_router |
OLD | NEW |