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 |
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/issues_observer.h" | 20 #include "chrome/browser/media/router/issues_observer.h" |
20 #include "chrome/browser/media/router/media_router_factory.h" | 21 #include "chrome/browser/media/router/media_router_factory.h" |
21 #include "chrome/browser/media/router/media_router_feature.h" | 22 #include "chrome/browser/media/router/media_router_feature.h" |
22 #include "chrome/browser/media/router/media_routes_observer.h" | 23 #include "chrome/browser/media/router/media_routes_observer.h" |
23 #include "chrome/browser/media/router/media_sinks_observer.h" | 24 #include "chrome/browser/media/router/media_sinks_observer.h" |
24 #include "chrome/browser/media/router/mojo/media_route_controller.h" | 25 #include "chrome/browser/media/router/mojo/media_route_controller.h" |
25 #include "chrome/browser/media/router/mojo/media_route_provider_util_win.h" | 26 #include "chrome/browser/media/router/mojo/media_route_provider_util_win.h" |
26 #include "chrome/browser/media/router/mojo/media_router_mojo_metrics.h" | 27 #include "chrome/browser/media/router/mojo/media_router_mojo_metrics.h" |
27 #include "chrome/browser/media/router/route_message_observer.h" | 28 #include "chrome/browser/media/router/route_message_observer.h" |
28 #include "chrome/browser/profiles/profile.h" | 29 #include "chrome/browser/profiles/profile.h" |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
428 base::Unretained(this), route_id, | 429 base::Unretained(this), route_id, |
429 std::move(mojo_media_controller_request), | 430 std::move(mojo_media_controller_request), |
430 route_controller->BindObserverPtr())); | 431 route_controller->BindObserverPtr())); |
431 route_controllers_.emplace(route_id, route_controller.get()); | 432 route_controllers_.emplace(route_id, route_controller.get()); |
432 return route_controller; | 433 return route_controller; |
433 } | 434 } |
434 | 435 |
435 void MediaRouterMojoImpl::ProvideSinks(const std::string& provider_name, | 436 void MediaRouterMojoImpl::ProvideSinks(const std::string& provider_name, |
436 std::vector<MediaSinkInternal> sinks) { | 437 std::vector<MediaSinkInternal> sinks) { |
437 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 438 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
438 DVLOG_WITH_INSTANCE(1) << "OnDialMediaSinkDiscovered found " << sinks.size() | 439 DVLOG_WITH_INSTANCE(1) << "Provider [" << provider_name << "] fould " |
mark a. foltz
2017/06/28 07:44:52
Typo in found
zhaobin
2017/07/05 18:01:37
Done.
| |
439 << " devices..."; | 440 << sinks.size() << " devices..."; |
440 | 441 |
441 SetWakeReason(MediaRouteProviderWakeReason::PROVIDE_SINKS); | 442 SetWakeReason(MediaRouteProviderWakeReason::PROVIDE_SINKS); |
442 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoProvideSinks, | 443 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoProvideSinks, |
443 base::Unretained(this), provider_name, | 444 base::Unretained(this), provider_name, |
444 std::move(sinks))); | 445 std::move(sinks))); |
445 } | 446 } |
446 | 447 |
447 bool MediaRouterMojoImpl::RegisterMediaSinksObserver( | 448 bool MediaRouterMojoImpl::RegisterMediaSinksObserver( |
448 MediaSinksObserver* observer) { | 449 MediaSinksObserver* observer) { |
449 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 450 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1008 // The MRPM extension already turns on mDNS discovery for platforms other than | 1009 // The MRPM extension already turns on mDNS discovery for platforms other than |
1009 // Windows. It only relies on this signalling from MR on Windows to avoid | 1010 // Windows. It only relies on this signalling from MR on Windows to avoid |
1010 // triggering a firewall prompt out of the context of MR from the user's | 1011 // triggering a firewall prompt out of the context of MR from the user's |
1011 // perspective. This particular call reminds the extension to enable mDNS | 1012 // perspective. This particular call reminds the extension to enable mDNS |
1012 // discovery when it wakes up, has been upgraded, etc. | 1013 // discovery when it wakes up, has been upgraded, etc. |
1013 if (should_enable_mdns_discovery_) { | 1014 if (should_enable_mdns_discovery_) { |
1014 DoEnsureMdnsDiscoveryEnabled(); | 1015 DoEnsureMdnsDiscoveryEnabled(); |
1015 } | 1016 } |
1016 #endif | 1017 #endif |
1017 | 1018 |
1018 if (media_router::DialLocalDiscoveryEnabled()) | 1019 StartDiscovery(); |
1019 StartDiscovery(); | |
1020 } | 1020 } |
1021 | 1021 |
1022 void MediaRouterMojoImpl::EventPageWakeComplete(bool success) { | 1022 void MediaRouterMojoImpl::EventPageWakeComplete(bool success) { |
1023 if (success) { | 1023 if (success) { |
1024 MediaRouterMojoMetrics::RecordMediaRouteProviderWakeReason( | 1024 MediaRouterMojoMetrics::RecordMediaRouteProviderWakeReason( |
1025 current_wake_reason_); | 1025 current_wake_reason_); |
1026 ClearWakeReason(); | 1026 ClearWakeReason(); |
1027 MediaRouterMojoMetrics::RecordMediaRouteProviderWakeup( | 1027 MediaRouterMojoMetrics::RecordMediaRouteProviderWakeup( |
1028 MediaRouteProviderWakeup::SUCCESS); | 1028 MediaRouteProviderWakeup::SUCCESS); |
1029 return; | 1029 return; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1079 bool firewall_can_use_local_ports) { | 1079 bool firewall_can_use_local_ports) { |
1080 if (firewall_can_use_local_ports) | 1080 if (firewall_can_use_local_ports) |
1081 EnsureMdnsDiscoveryEnabled(); | 1081 EnsureMdnsDiscoveryEnabled(); |
1082 } | 1082 } |
1083 #endif | 1083 #endif |
1084 | 1084 |
1085 void MediaRouterMojoImpl::StartDiscovery() { | 1085 void MediaRouterMojoImpl::StartDiscovery() { |
1086 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 1086 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
1087 DVLOG_WITH_INSTANCE(1) << "StartDiscovery"; | 1087 DVLOG_WITH_INSTANCE(1) << "StartDiscovery"; |
1088 | 1088 |
1089 if (!dial_media_sink_service_proxy_) { | 1089 if (media_router::DialLocalDiscoveryEnabled()) { |
1090 dial_media_sink_service_proxy_ = new DialMediaSinkServiceProxy( | 1090 if (!dial_media_sink_service_proxy_) { |
1091 base::Bind(&MediaRouterMojoImpl::ProvideSinks, | 1091 dial_media_sink_service_proxy_ = new DialMediaSinkServiceProxy( |
1092 weak_factory_.GetWeakPtr(), "dial"), | 1092 base::Bind(&MediaRouterMojoImpl::ProvideSinks, |
1093 context_); | 1093 weak_factory_.GetWeakPtr(), "dial"), |
1094 context_); | |
1095 } | |
1096 dial_media_sink_service_proxy_->Start(); | |
1094 } | 1097 } |
1095 | 1098 |
1096 dial_media_sink_service_proxy_->Start(); | 1099 if (media_router::CastDiscoveryEnabled()) { |
1100 if (!cast_media_sink_service_) { | |
1101 cast_media_sink_service_ = new CastMediaSinkService( | |
1102 base::Bind(&MediaRouterMojoImpl::ProvideSinks, | |
1103 weak_factory_.GetWeakPtr(), "cast"), | |
1104 context_); | |
1105 } | |
1106 cast_media_sink_service_->Start(); | |
1107 } | |
1097 } | 1108 } |
1098 | 1109 |
1099 void MediaRouterMojoImpl::UpdateMediaSinks( | 1110 void MediaRouterMojoImpl::UpdateMediaSinks( |
1100 const MediaSource::Id& source_id) { | 1111 const MediaSource::Id& source_id) { |
1101 SetWakeReason(MediaRouteProviderWakeReason::UPDATE_MEDIA_SINKS); | 1112 SetWakeReason(MediaRouteProviderWakeReason::UPDATE_MEDIA_SINKS); |
1102 RunOrDefer(base::BindOnce(&MediaRouterMojoImpl::DoUpdateMediaSinks, | 1113 RunOrDefer(base::BindOnce(&MediaRouterMojoImpl::DoUpdateMediaSinks, |
1103 base::Unretained(this), source_id)); | 1114 base::Unretained(this), source_id)); |
1104 } | 1115 } |
1105 | 1116 |
1106 void MediaRouterMojoImpl::DoUpdateMediaSinks( | 1117 void MediaRouterMojoImpl::DoUpdateMediaSinks( |
(...skipping 17 matching lines...) Expand all Loading... | |
1124 | 1135 |
1125 void MediaRouterMojoImpl::OnMediaControllerCreated( | 1136 void MediaRouterMojoImpl::OnMediaControllerCreated( |
1126 const MediaRoute::Id& route_id, | 1137 const MediaRoute::Id& route_id, |
1127 bool success) { | 1138 bool success) { |
1128 DVLOG_WITH_INSTANCE(1) << "OnMediaControllerCreated: " << route_id | 1139 DVLOG_WITH_INSTANCE(1) << "OnMediaControllerCreated: " << route_id |
1129 << (success ? " was successful." : " failed."); | 1140 << (success ? " was successful." : " failed."); |
1130 MediaRouterMojoMetrics::RecordMediaRouteControllerCreationResult(success); | 1141 MediaRouterMojoMetrics::RecordMediaRouteControllerCreationResult(success); |
1131 } | 1142 } |
1132 | 1143 |
1133 } // namespace media_router | 1144 } // namespace media_router |
OLD | NEW |