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

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: merge with https://codereview.chromium.org/2675033002/ Created 3 years, 10 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 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 const std::string& domain, 382 const std::string& domain,
383 const MediaSinkSearchResponseCallback& sink_callback) { 383 const MediaSinkSearchResponseCallback& sink_callback) {
384 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 384 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
385 385
386 SetWakeReason(MediaRouteProviderWakeReason::SEARCH_SINKS); 386 SetWakeReason(MediaRouteProviderWakeReason::SEARCH_SINKS);
387 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoSearchSinks, 387 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoSearchSinks,
388 base::Unretained(this), sink_id, source_id, 388 base::Unretained(this), sink_id, source_id,
389 search_input, domain, sink_callback)); 389 search_input, domain, sink_callback));
390 } 390 }
391 391
392 void MediaRouterMojoImpl::ProvideSinks(const std::string& provider_name,
393 const MediaSinkList& sinks) {
394 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
395
396 SetWakeReason(MediaRouteProviderWakeReason::PROVIDE_SINKS);
397 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoProvideSinks,
398 base::Unretained(this), provider_name,
399 base::ConstRef(sinks)));
mark a. foltz 2017/03/01 06:31:43 base::Passed?
imcheng 2017/03/01 23:28:36 or just |sinks|? I assume that the reference is to
zhaobin 2017/03/02 20:24:04 Done.
400 }
401
392 bool MediaRouterMojoImpl::RegisterMediaSinksObserver( 402 bool MediaRouterMojoImpl::RegisterMediaSinksObserver(
393 MediaSinksObserver* observer) { 403 MediaSinksObserver* observer) {
394 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 404 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
395 405
396 // Create an observer list for the media source and add |observer| 406 // Create an observer list for the media source and add |observer|
397 // to it. Fail if |observer| is already registered. 407 // to it. Fail if |observer| is already registered.
398 const std::string& source_id = observer->source().id(); 408 const std::string& source_id = observer->source().id();
399 std::unique_ptr<MediaSinksQuery>& sinks_query = sinks_queries_[source_id]; 409 std::unique_ptr<MediaSinksQuery>& sinks_query = sinks_queries_[source_id];
400 bool new_query = false; 410 bool new_query = false;
401 if (!sinks_query) { 411 if (!sinks_query) {
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 const std::string& domain, 664 const std::string& domain,
655 const MediaSinkSearchResponseCallback& sink_callback) { 665 const MediaSinkSearchResponseCallback& sink_callback) {
656 DVLOG_WITH_INSTANCE(1) << "SearchSinks"; 666 DVLOG_WITH_INSTANCE(1) << "SearchSinks";
657 auto sink_search_criteria = mojom::SinkSearchCriteria::New(); 667 auto sink_search_criteria = mojom::SinkSearchCriteria::New();
658 sink_search_criteria->input = search_input; 668 sink_search_criteria->input = search_input;
659 sink_search_criteria->domain = domain; 669 sink_search_criteria->domain = domain;
660 media_route_provider_->SearchSinks( 670 media_route_provider_->SearchSinks(
661 sink_id, source_id, std::move(sink_search_criteria), sink_callback); 671 sink_id, source_id, std::move(sink_search_criteria), sink_callback);
662 } 672 }
663 673
674 void MediaRouterMojoImpl::DoProvideSinks(const std::string& provider_name,
675 const MediaSinkList& sinks) {
676 DVLOG_WITH_INSTANCE(1) << "DoProvideSinks";
677 media_route_provider_->ProvideSinks(provider_name, sinks);
678 }
679
664 void MediaRouterMojoImpl::OnRouteMessagesReceived( 680 void MediaRouterMojoImpl::OnRouteMessagesReceived(
665 const std::string& route_id, 681 const std::string& route_id,
666 const std::vector<RouteMessage>& messages) { 682 const std::vector<RouteMessage>& messages) {
667 DVLOG_WITH_INSTANCE(1) << "OnRouteMessagesReceived"; 683 DVLOG_WITH_INSTANCE(1) << "OnRouteMessagesReceived";
668 684
669 if (messages.empty()) 685 if (messages.empty())
670 return; 686 return;
671 687
672 auto it = message_observers_.find(route_id); 688 auto it = message_observers_.find(route_id);
673 if (it == message_observers_.end()) { 689 if (it == message_observers_.end()) {
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 base::Unretained(this), source_id)); 949 base::Unretained(this), source_id));
934 } 950 }
935 951
936 void MediaRouterMojoImpl::DoUpdateMediaSinks( 952 void MediaRouterMojoImpl::DoUpdateMediaSinks(
937 const MediaSource::Id& source_id) { 953 const MediaSource::Id& source_id) {
938 DVLOG_WITH_INSTANCE(1) << "DoUpdateMediaSinks" << source_id; 954 DVLOG_WITH_INSTANCE(1) << "DoUpdateMediaSinks" << source_id;
939 media_route_provider_->UpdateMediaSinks(source_id); 955 media_route_provider_->UpdateMediaSinks(source_id);
940 } 956 }
941 957
942 } // namespace media_router 958 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698