Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: chrome/browser/media/router/mojo/media_router_mojo_impl.cc

Issue 2679893002: [Media Router] Add ProvideSinks() Mojo API (Closed)
Patch Set: fix android compile error Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 const std::string& domain, 391 const std::string& domain,
392 const MediaSinkSearchResponseCallback& sink_callback) { 392 const MediaSinkSearchResponseCallback& sink_callback) {
393 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 393 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
394 394
395 SetWakeReason(MediaRouteProviderWakeReason::SEARCH_SINKS); 395 SetWakeReason(MediaRouteProviderWakeReason::SEARCH_SINKS);
396 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoSearchSinks, 396 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoSearchSinks,
397 base::Unretained(this), sink_id, source_id, 397 base::Unretained(this), sink_id, source_id,
398 search_input, domain, sink_callback)); 398 search_input, domain, sink_callback));
399 } 399 }
400 400
401 void MediaRouterMojoImpl::ProvideSinks(
402 const std::string& provider_name,
403 const std::vector<MediaSinkInternal>& sinks) {
404 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
405
406 SetWakeReason(MediaRouteProviderWakeReason::PROVIDE_SINKS);
407 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoProvideSinks,
408 base::Unretained(this), provider_name, sinks));
409 }
410
401 bool MediaRouterMojoImpl::RegisterMediaSinksObserver( 411 bool MediaRouterMojoImpl::RegisterMediaSinksObserver(
402 MediaSinksObserver* observer) { 412 MediaSinksObserver* observer) {
403 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 413 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
404 414
405 // Create an observer list for the media source and add |observer| 415 // Create an observer list for the media source and add |observer|
406 // to it. Fail if |observer| is already registered. 416 // to it. Fail if |observer| is already registered.
407 const std::string& source_id = observer->source().id(); 417 const std::string& source_id = observer->source().id();
408 std::unique_ptr<MediaSinksQuery>& sinks_query = sinks_queries_[source_id]; 418 std::unique_ptr<MediaSinksQuery>& sinks_query = sinks_queries_[source_id];
409 bool is_new_query = false; 419 bool is_new_query = false;
410 if (!sinks_query) { 420 if (!sinks_query) {
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 const std::string& domain, 705 const std::string& domain,
696 const MediaSinkSearchResponseCallback& sink_callback) { 706 const MediaSinkSearchResponseCallback& sink_callback) {
697 DVLOG_WITH_INSTANCE(1) << "SearchSinks"; 707 DVLOG_WITH_INSTANCE(1) << "SearchSinks";
698 auto sink_search_criteria = mojom::SinkSearchCriteria::New(); 708 auto sink_search_criteria = mojom::SinkSearchCriteria::New();
699 sink_search_criteria->input = search_input; 709 sink_search_criteria->input = search_input;
700 sink_search_criteria->domain = domain; 710 sink_search_criteria->domain = domain;
701 media_route_provider_->SearchSinks( 711 media_route_provider_->SearchSinks(
702 sink_id, source_id, std::move(sink_search_criteria), sink_callback); 712 sink_id, source_id, std::move(sink_search_criteria), sink_callback);
703 } 713 }
704 714
715 void MediaRouterMojoImpl::DoProvideSinks(
716 const std::string& provider_name,
717 const std::vector<MediaSinkInternal>& sinks) {
718 DVLOG_WITH_INSTANCE(1) << "DoProvideSinks";
719 media_route_provider_->ProvideSinks(provider_name, sinks);
720 }
721
705 void MediaRouterMojoImpl::OnRouteMessagesReceived( 722 void MediaRouterMojoImpl::OnRouteMessagesReceived(
706 const std::string& route_id, 723 const std::string& route_id,
707 const std::vector<RouteMessage>& messages) { 724 const std::vector<RouteMessage>& messages) {
708 DVLOG_WITH_INSTANCE(1) << "OnRouteMessagesReceived"; 725 DVLOG_WITH_INSTANCE(1) << "OnRouteMessagesReceived";
709 726
710 if (messages.empty()) 727 if (messages.empty())
711 return; 728 return;
712 729
713 auto it = message_observers_.find(route_id); 730 auto it = message_observers_.find(route_id);
714 if (it == message_observers_.end()) { 731 if (it == message_observers_.end()) {
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 base::Unretained(this), source_id)); 990 base::Unretained(this), source_id));
974 } 991 }
975 992
976 void MediaRouterMojoImpl::DoUpdateMediaSinks( 993 void MediaRouterMojoImpl::DoUpdateMediaSinks(
977 const MediaSource::Id& source_id) { 994 const MediaSource::Id& source_id) {
978 DVLOG_WITH_INSTANCE(1) << "DoUpdateMediaSinks" << source_id; 995 DVLOG_WITH_INSTANCE(1) << "DoUpdateMediaSinks" << source_id;
979 media_route_provider_->UpdateMediaSinks(source_id); 996 media_route_provider_->UpdateMediaSinks(source_id);
980 } 997 }
981 998
982 } // namespace media_router 999 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698