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

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: resolve code review comments from Derek and Mark Created 3 years, 9 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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 const std::string& domain, 383 const std::string& domain,
384 const MediaSinkSearchResponseCallback& sink_callback) { 384 const MediaSinkSearchResponseCallback& sink_callback) {
385 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 385 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
386 386
387 SetWakeReason(MediaRouteProviderWakeReason::SEARCH_SINKS); 387 SetWakeReason(MediaRouteProviderWakeReason::SEARCH_SINKS);
388 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoSearchSinks, 388 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoSearchSinks,
389 base::Unretained(this), sink_id, source_id, 389 base::Unretained(this), sink_id, source_id,
390 search_input, domain, sink_callback)); 390 search_input, domain, sink_callback));
391 } 391 }
392 392
393 void MediaRouterMojoImpl::ProvideSinks(
394 const std::string& provider_name,
395 const std::vector<MediaSinkInternal>& sinks) {
396 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
397
398 SetWakeReason(MediaRouteProviderWakeReason::PROVIDE_SINKS);
399 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoProvideSinks,
400 base::Unretained(this), provider_name, sinks));
401 }
402
393 bool MediaRouterMojoImpl::RegisterMediaSinksObserver( 403 bool MediaRouterMojoImpl::RegisterMediaSinksObserver(
394 MediaSinksObserver* observer) { 404 MediaSinksObserver* observer) {
395 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 405 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
396 406
397 // Create an observer list for the media source and add |observer| 407 // Create an observer list for the media source and add |observer|
398 // to it. Fail if |observer| is already registered. 408 // to it. Fail if |observer| is already registered.
399 const std::string& source_id = observer->source().id(); 409 const std::string& source_id = observer->source().id();
400 std::unique_ptr<MediaSinksQuery>& sinks_query = sinks_queries_[source_id]; 410 std::unique_ptr<MediaSinksQuery>& sinks_query = sinks_queries_[source_id];
401 bool new_query = false; 411 bool new_query = false;
402 if (!sinks_query) { 412 if (!sinks_query) {
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 const std::string& domain, 665 const std::string& domain,
656 const MediaSinkSearchResponseCallback& sink_callback) { 666 const MediaSinkSearchResponseCallback& sink_callback) {
657 DVLOG_WITH_INSTANCE(1) << "SearchSinks"; 667 DVLOG_WITH_INSTANCE(1) << "SearchSinks";
658 auto sink_search_criteria = mojom::SinkSearchCriteria::New(); 668 auto sink_search_criteria = mojom::SinkSearchCriteria::New();
659 sink_search_criteria->input = search_input; 669 sink_search_criteria->input = search_input;
660 sink_search_criteria->domain = domain; 670 sink_search_criteria->domain = domain;
661 media_route_provider_->SearchSinks( 671 media_route_provider_->SearchSinks(
662 sink_id, source_id, std::move(sink_search_criteria), sink_callback); 672 sink_id, source_id, std::move(sink_search_criteria), sink_callback);
663 } 673 }
664 674
675 void MediaRouterMojoImpl::DoProvideSinks(
676 const std::string& provider_name,
677 const std::vector<MediaSinkInternal>& sinks) {
678 DVLOG_WITH_INSTANCE(1) << "DoProvideSinks";
679 media_route_provider_->ProvideSinks(provider_name, sinks);
680 }
681
665 void MediaRouterMojoImpl::OnRouteMessagesReceived( 682 void MediaRouterMojoImpl::OnRouteMessagesReceived(
666 const std::string& route_id, 683 const std::string& route_id,
667 const std::vector<RouteMessage>& messages) { 684 const std::vector<RouteMessage>& messages) {
668 DVLOG_WITH_INSTANCE(1) << "OnRouteMessagesReceived"; 685 DVLOG_WITH_INSTANCE(1) << "OnRouteMessagesReceived";
669 686
670 if (messages.empty()) 687 if (messages.empty())
671 return; 688 return;
672 689
673 auto it = message_observers_.find(route_id); 690 auto it = message_observers_.find(route_id);
674 if (it == message_observers_.end()) { 691 if (it == message_observers_.end()) {
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 base::Unretained(this), source_id)); 951 base::Unretained(this), source_id));
935 } 952 }
936 953
937 void MediaRouterMojoImpl::DoUpdateMediaSinks( 954 void MediaRouterMojoImpl::DoUpdateMediaSinks(
938 const MediaSource::Id& source_id) { 955 const MediaSource::Id& source_id) {
939 DVLOG_WITH_INSTANCE(1) << "DoUpdateMediaSinks" << source_id; 956 DVLOG_WITH_INSTANCE(1) << "DoUpdateMediaSinks" << source_id;
940 media_route_provider_->UpdateMediaSinks(source_id); 957 media_route_provider_->UpdateMediaSinks(source_id);
941 } 958 }
942 959
943 } // namespace media_router 960 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698