| 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 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 const std::string& domain, | 432 const std::string& domain, |
| 433 const MediaSinkSearchResponseCallback& sink_callback) { | 433 const MediaSinkSearchResponseCallback& sink_callback) { |
| 434 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 434 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 435 | 435 |
| 436 SetWakeReason(MediaRouteProviderWakeReason::SEARCH_SINKS); | 436 SetWakeReason(MediaRouteProviderWakeReason::SEARCH_SINKS); |
| 437 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoSearchSinks, | 437 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoSearchSinks, |
| 438 base::Unretained(this), sink_id, source_id, | 438 base::Unretained(this), sink_id, source_id, |
| 439 search_input, domain, sink_callback)); | 439 search_input, domain, sink_callback)); |
| 440 } | 440 } |
| 441 | 441 |
| 442 void MediaRouterMojoImpl::OnSinksDiscovered( |
| 443 std::unique_ptr<MediaSinkList> sinks) { |
| 444 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 445 |
| 446 SetWakeReason(MediaRouteProviderWakeReason::ON_SINKS_DISCOVERED); |
| 447 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoOnSinksDiscovered, |
| 448 base::Unretained(this), base::Passed(&sinks))); |
| 449 } |
| 450 |
| 442 bool MediaRouterMojoImpl::RegisterMediaSinksObserver( | 451 bool MediaRouterMojoImpl::RegisterMediaSinksObserver( |
| 443 MediaSinksObserver* observer) { | 452 MediaSinksObserver* observer) { |
| 444 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 453 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 445 | 454 |
| 446 // Create an observer list for the media source and add |observer| | 455 // Create an observer list for the media source and add |observer| |
| 447 // to it. Fail if |observer| is already registered. | 456 // to it. Fail if |observer| is already registered. |
| 448 const std::string& source_id = observer->source().id(); | 457 const std::string& source_id = observer->source().id(); |
| 449 std::unique_ptr<MediaSinksQuery>& sinks_query = sinks_queries_[source_id]; | 458 std::unique_ptr<MediaSinksQuery>& sinks_query = sinks_queries_[source_id]; |
| 450 bool new_query = false; | 459 bool new_query = false; |
| 451 if (!sinks_query) { | 460 if (!sinks_query) { |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 const std::string& domain, | 713 const std::string& domain, |
| 705 const MediaSinkSearchResponseCallback& sink_callback) { | 714 const MediaSinkSearchResponseCallback& sink_callback) { |
| 706 DVLOG_WITH_INSTANCE(1) << "SearchSinks"; | 715 DVLOG_WITH_INSTANCE(1) << "SearchSinks"; |
| 707 auto sink_search_criteria = mojom::SinkSearchCriteria::New(); | 716 auto sink_search_criteria = mojom::SinkSearchCriteria::New(); |
| 708 sink_search_criteria->input = search_input; | 717 sink_search_criteria->input = search_input; |
| 709 sink_search_criteria->domain = domain; | 718 sink_search_criteria->domain = domain; |
| 710 media_route_provider_->SearchSinks( | 719 media_route_provider_->SearchSinks( |
| 711 sink_id, source_id, std::move(sink_search_criteria), sink_callback); | 720 sink_id, source_id, std::move(sink_search_criteria), sink_callback); |
| 712 } | 721 } |
| 713 | 722 |
| 723 void MediaRouterMojoImpl::DoOnSinksDiscovered( |
| 724 std::unique_ptr<MediaSinkList> sinks) { |
| 725 DVLOG_WITH_INSTANCE(1) << "DoOnSinksDiscovered"; |
| 726 media_route_provider_->OnSinksDiscovered(std::move(*sinks)); |
| 727 } |
| 728 |
| 714 void MediaRouterMojoImpl::OnRouteMessagesReceived( | 729 void MediaRouterMojoImpl::OnRouteMessagesReceived( |
| 715 const std::string& route_id, | 730 const std::string& route_id, |
| 716 const std::vector<RouteMessage>& messages) { | 731 const std::vector<RouteMessage>& messages) { |
| 717 DVLOG_WITH_INSTANCE(1) << "OnRouteMessagesReceived"; | 732 DVLOG_WITH_INSTANCE(1) << "OnRouteMessagesReceived"; |
| 718 | 733 |
| 719 if (messages.empty()) | 734 if (messages.empty()) |
| 720 return; | 735 return; |
| 721 | 736 |
| 722 auto it = message_observers_.find(route_id); | 737 auto it = message_observers_.find(route_id); |
| 723 if (it == message_observers_.end()) { | 738 if (it == message_observers_.end()) { |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 987 base::Unretained(this), source_id)); | 1002 base::Unretained(this), source_id)); |
| 988 } | 1003 } |
| 989 | 1004 |
| 990 void MediaRouterMojoImpl::DoUpdateMediaSinks( | 1005 void MediaRouterMojoImpl::DoUpdateMediaSinks( |
| 991 const MediaSource::Id& source_id) { | 1006 const MediaSource::Id& source_id) { |
| 992 DVLOG_WITH_INSTANCE(1) << "DoUpdateMediaSinks" << source_id; | 1007 DVLOG_WITH_INSTANCE(1) << "DoUpdateMediaSinks" << source_id; |
| 993 media_route_provider_->UpdateMediaSinks(source_id); | 1008 media_route_provider_->UpdateMediaSinks(source_id); |
| 994 } | 1009 } |
| 995 | 1010 |
| 996 } // namespace media_router | 1011 } // namespace media_router |
| OLD | NEW |