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

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

Issue 2927833002: [Media Router] Add CastMediaSinkService (Closed)
Patch Set: fix tsan and mac unit test failures Created 3 years, 5 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
« no previous file with comments | « chrome/browser/media/router/mojo/media_router_mojo_impl.h ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/guid.h" 12 #include "base/guid.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/observer_list.h" 15 #include "base/observer_list.h"
16 #include "base/stl_util.h" 16 #include "base/stl_util.h"
17 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
18 #include "chrome/browser/media/router/discovery/dial/dial_media_sink_service_pro xy.h" 18 #include "chrome/browser/media/router/discovery/dial/dial_media_sink_service_pro xy.h"
19 #include "chrome/browser/media/router/discovery/mdns/cast_media_sink_service.h"
19 #include "chrome/browser/media/router/event_page_request_manager.h" 20 #include "chrome/browser/media/router/event_page_request_manager.h"
20 #include "chrome/browser/media/router/event_page_request_manager_factory.h" 21 #include "chrome/browser/media/router/event_page_request_manager_factory.h"
21 #include "chrome/browser/media/router/issues_observer.h" 22 #include "chrome/browser/media/router/issues_observer.h"
22 #include "chrome/browser/media/router/media_router_factory.h" 23 #include "chrome/browser/media/router/media_router_factory.h"
23 #include "chrome/browser/media/router/media_router_feature.h" 24 #include "chrome/browser/media/router/media_router_feature.h"
24 #include "chrome/browser/media/router/media_routes_observer.h" 25 #include "chrome/browser/media/router/media_routes_observer.h"
25 #include "chrome/browser/media/router/media_sinks_observer.h" 26 #include "chrome/browser/media/router/media_sinks_observer.h"
26 #include "chrome/browser/media/router/mojo/media_route_controller.h" 27 #include "chrome/browser/media/router/mojo/media_route_controller.h"
27 #include "chrome/browser/media/router/mojo/media_route_provider_util_win.h" 28 #include "chrome/browser/media/router/mojo/media_route_provider_util_win.h"
28 #include "chrome/browser/media/router/mojo/media_router_mojo_metrics.h" 29 #include "chrome/browser/media/router/mojo/media_router_mojo_metrics.h"
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 std::move(mojo_media_controller_request), 423 std::move(mojo_media_controller_request),
423 route_controller->BindObserverPtr()), 424 route_controller->BindObserverPtr()),
424 MediaRouteProviderWakeReason::CREATE_MEDIA_ROUTE_CONTROLLER); 425 MediaRouteProviderWakeReason::CREATE_MEDIA_ROUTE_CONTROLLER);
425 route_controllers_.emplace(route_id, route_controller.get()); 426 route_controllers_.emplace(route_id, route_controller.get());
426 return route_controller; 427 return route_controller;
427 } 428 }
428 429
429 void MediaRouterMojoImpl::ProvideSinks(const std::string& provider_name, 430 void MediaRouterMojoImpl::ProvideSinks(const std::string& provider_name,
430 std::vector<MediaSinkInternal> sinks) { 431 std::vector<MediaSinkInternal> sinks) {
431 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 432 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
432 DVLOG_WITH_INSTANCE(1) << "OnDialMediaSinkDiscovered found " << sinks.size() 433 DVLOG_WITH_INSTANCE(1) << "Provider [" << provider_name << "] found "
433 << " devices..."; 434 << sinks.size() << " devices...";
434 435
435 event_page_request_manager_->RunOrDefer( 436 event_page_request_manager_->RunOrDefer(
436 base::Bind(&MediaRouterMojoImpl::DoProvideSinks, 437 base::Bind(&MediaRouterMojoImpl::DoProvideSinks,
437 weak_factory_.GetWeakPtr(), provider_name, std::move(sinks)), 438 weak_factory_.GetWeakPtr(), provider_name, std::move(sinks)),
438 MediaRouteProviderWakeReason::PROVIDE_SINKS); 439 MediaRouteProviderWakeReason::PROVIDE_SINKS);
439 } 440 }
440 441
441 bool MediaRouterMojoImpl::RegisterMediaSinksObserver( 442 bool MediaRouterMojoImpl::RegisterMediaSinksObserver(
442 MediaSinksObserver* observer) { 443 MediaSinksObserver* observer) {
443 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 444 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 // The MRPM extension already turns on mDNS discovery for platforms other than 935 // The MRPM extension already turns on mDNS discovery for platforms other than
935 // Windows. It only relies on this signalling from MR on Windows to avoid 936 // Windows. It only relies on this signalling from MR on Windows to avoid
936 // triggering a firewall prompt out of the context of MR from the user's 937 // triggering a firewall prompt out of the context of MR from the user's
937 // perspective. This particular call reminds the extension to enable mDNS 938 // perspective. This particular call reminds the extension to enable mDNS
938 // discovery when it wakes up, has been upgraded, etc. 939 // discovery when it wakes up, has been upgraded, etc.
939 if (should_enable_mdns_discovery_) { 940 if (should_enable_mdns_discovery_) {
940 DoEnsureMdnsDiscoveryEnabled(); 941 DoEnsureMdnsDiscoveryEnabled();
941 } 942 }
942 #endif 943 #endif
943 944
944 if (media_router::DialLocalDiscoveryEnabled()) 945 StartDiscovery();
945 StartDiscovery();
946 } 946 }
947 947
948 #if defined(OS_WIN) 948 #if defined(OS_WIN)
949 void MediaRouterMojoImpl::EnsureMdnsDiscoveryEnabled() { 949 void MediaRouterMojoImpl::EnsureMdnsDiscoveryEnabled() {
950 if (is_mdns_enabled_) 950 if (is_mdns_enabled_)
951 return; 951 return;
952 952
953 event_page_request_manager_->RunOrDefer( 953 event_page_request_manager_->RunOrDefer(
954 base::BindOnce(&MediaRouterMojoImpl::DoEnsureMdnsDiscoveryEnabled, 954 base::BindOnce(&MediaRouterMojoImpl::DoEnsureMdnsDiscoveryEnabled,
955 weak_factory_.GetWeakPtr()), 955 weak_factory_.GetWeakPtr()),
(...skipping 13 matching lines...) Expand all
969 bool firewall_can_use_local_ports) { 969 bool firewall_can_use_local_ports) {
970 if (firewall_can_use_local_ports) 970 if (firewall_can_use_local_ports)
971 EnsureMdnsDiscoveryEnabled(); 971 EnsureMdnsDiscoveryEnabled();
972 } 972 }
973 #endif 973 #endif
974 974
975 void MediaRouterMojoImpl::StartDiscovery() { 975 void MediaRouterMojoImpl::StartDiscovery() {
976 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 976 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
977 DVLOG_WITH_INSTANCE(1) << "StartDiscovery"; 977 DVLOG_WITH_INSTANCE(1) << "StartDiscovery";
978 978
979 if (!dial_media_sink_service_proxy_) { 979 if (media_router::DialLocalDiscoveryEnabled()) {
980 dial_media_sink_service_proxy_ = new DialMediaSinkServiceProxy( 980 if (!dial_media_sink_service_proxy_) {
981 base::Bind(&MediaRouterMojoImpl::ProvideSinks, 981 dial_media_sink_service_proxy_ = new DialMediaSinkServiceProxy(
982 weak_factory_.GetWeakPtr(), "dial"), 982 base::Bind(&MediaRouterMojoImpl::ProvideSinks,
983 context_); 983 weak_factory_.GetWeakPtr(), "dial"),
984 context_);
985 }
986 dial_media_sink_service_proxy_->Start();
984 } 987 }
985 988
986 dial_media_sink_service_proxy_->Start(); 989 if (media_router::CastDiscoveryEnabled()) {
990 if (!cast_media_sink_service_) {
991 cast_media_sink_service_ = new CastMediaSinkService(
992 base::Bind(&MediaRouterMojoImpl::ProvideSinks,
993 weak_factory_.GetWeakPtr(), "cast"),
994 context_);
995 }
996 cast_media_sink_service_->Start();
997 }
987 } 998 }
988 999
989 void MediaRouterMojoImpl::UpdateMediaSinks( 1000 void MediaRouterMojoImpl::UpdateMediaSinks(
990 const MediaSource::Id& source_id) { 1001 const MediaSource::Id& source_id) {
991 event_page_request_manager_->RunOrDefer( 1002 event_page_request_manager_->RunOrDefer(
992 base::BindOnce(&MediaRouterMojoImpl::DoUpdateMediaSinks, 1003 base::BindOnce(&MediaRouterMojoImpl::DoUpdateMediaSinks,
993 weak_factory_.GetWeakPtr(), source_id), 1004 weak_factory_.GetWeakPtr(), source_id),
994 MediaRouteProviderWakeReason::UPDATE_MEDIA_SINKS); 1005 MediaRouteProviderWakeReason::UPDATE_MEDIA_SINKS);
995 } 1006 }
996 1007
(...skipping 18 matching lines...) Expand all
1015 1026
1016 void MediaRouterMojoImpl::OnMediaControllerCreated( 1027 void MediaRouterMojoImpl::OnMediaControllerCreated(
1017 const MediaRoute::Id& route_id, 1028 const MediaRoute::Id& route_id,
1018 bool success) { 1029 bool success) {
1019 DVLOG_WITH_INSTANCE(1) << "OnMediaControllerCreated: " << route_id 1030 DVLOG_WITH_INSTANCE(1) << "OnMediaControllerCreated: " << route_id
1020 << (success ? " was successful." : " failed."); 1031 << (success ? " was successful." : " failed.");
1021 MediaRouterMojoMetrics::RecordMediaRouteControllerCreationResult(success); 1032 MediaRouterMojoMetrics::RecordMediaRouteControllerCreationResult(success);
1022 } 1033 }
1023 1034
1024 } // namespace media_router 1035 } // namespace media_router
OLDNEW
« no previous file with comments | « chrome/browser/media/router/mojo/media_router_mojo_impl.h ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698