| 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 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 DCHECK(event_page_tracker_); | 74 DCHECK(event_page_tracker_); |
| 75 #if defined(OS_WIN) | 75 #if defined(OS_WIN) |
| 76 CanFirewallUseLocalPorts( | 76 CanFirewallUseLocalPorts( |
| 77 base::Bind(&MediaRouterMojoImpl::OnFirewallCheckComplete, | 77 base::Bind(&MediaRouterMojoImpl::OnFirewallCheckComplete, |
| 78 weak_factory_.GetWeakPtr())); | 78 weak_factory_.GetWeakPtr())); |
| 79 #endif | 79 #endif |
| 80 } | 80 } |
| 81 | 81 |
| 82 MediaRouterMojoImpl::~MediaRouterMojoImpl() { | 82 MediaRouterMojoImpl::~MediaRouterMojoImpl() { |
| 83 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 83 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 84 if (dial_media_sink_service_proxy_) | 84 if (!dial_media_sink_service_proxy_) |
| 85 dial_media_sink_service_proxy_->Stop(); | 85 return; |
| 86 dial_media_sink_service_proxy_->Stop(); |
| 87 |
| 88 if (!cast_media_sink_service_) |
| 89 return; |
| 90 dial_media_sink_service_proxy_->RemoveObserver( |
| 91 cast_media_sink_service_.get()); |
| 86 } | 92 } |
| 87 | 93 |
| 88 // static | 94 // static |
| 89 void MediaRouterMojoImpl::BindToRequest( | 95 void MediaRouterMojoImpl::BindToRequest( |
| 90 const extensions::Extension* extension, | 96 const extensions::Extension* extension, |
| 91 content::BrowserContext* context, | 97 content::BrowserContext* context, |
| 92 const service_manager::BindSourceInfo& source_info, | 98 const service_manager::BindSourceInfo& source_info, |
| 93 mojom::MediaRouterRequest request) { | 99 mojom::MediaRouterRequest request) { |
| 94 MediaRouterMojoImpl* impl = static_cast<MediaRouterMojoImpl*>( | 100 MediaRouterMojoImpl* impl = static_cast<MediaRouterMojoImpl*>( |
| 95 MediaRouterFactory::GetApiForBrowserContext(context)); | 101 MediaRouterFactory::GetApiForBrowserContext(context)); |
| (...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1079 bool firewall_can_use_local_ports) { | 1085 bool firewall_can_use_local_ports) { |
| 1080 if (firewall_can_use_local_ports) | 1086 if (firewall_can_use_local_ports) |
| 1081 EnsureMdnsDiscoveryEnabled(); | 1087 EnsureMdnsDiscoveryEnabled(); |
| 1082 } | 1088 } |
| 1083 #endif | 1089 #endif |
| 1084 | 1090 |
| 1085 void MediaRouterMojoImpl::StartDiscovery() { | 1091 void MediaRouterMojoImpl::StartDiscovery() { |
| 1086 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 1092 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 1087 DVLOG_WITH_INSTANCE(1) << "StartDiscovery"; | 1093 DVLOG_WITH_INSTANCE(1) << "StartDiscovery"; |
| 1088 | 1094 |
| 1089 if (media_router::DialLocalDiscoveryEnabled()) { | |
| 1090 if (!dial_media_sink_service_proxy_) { | |
| 1091 dial_media_sink_service_proxy_ = new DialMediaSinkServiceProxy( | |
| 1092 base::Bind(&MediaRouterMojoImpl::ProvideSinks, | |
| 1093 weak_factory_.GetWeakPtr(), "dial"), | |
| 1094 context_); | |
| 1095 } | |
| 1096 dial_media_sink_service_proxy_->Start(); | |
| 1097 } | |
| 1098 | |
| 1099 if (media_router::CastDiscoveryEnabled()) { | 1095 if (media_router::CastDiscoveryEnabled()) { |
| 1100 if (!cast_media_sink_service_) { | 1096 if (!cast_media_sink_service_) { |
| 1101 cast_media_sink_service_ = new CastMediaSinkService( | 1097 cast_media_sink_service_ = new CastMediaSinkService( |
| 1102 base::Bind(&MediaRouterMojoImpl::ProvideSinks, | 1098 base::Bind(&MediaRouterMojoImpl::ProvideSinks, |
| 1103 weak_factory_.GetWeakPtr(), "cast"), | 1099 weak_factory_.GetWeakPtr(), "cast"), |
| 1104 context_); | 1100 context_); |
| 1105 } | 1101 } |
| 1106 cast_media_sink_service_->Start(); | 1102 cast_media_sink_service_->Start(); |
| 1107 } | 1103 } |
| 1104 |
| 1105 if (media_router::DialLocalDiscoveryEnabled()) { |
| 1106 if (!dial_media_sink_service_proxy_) { |
| 1107 dial_media_sink_service_proxy_ = new DialMediaSinkServiceProxy( |
| 1108 base::Bind(&MediaRouterMojoImpl::ProvideSinks, |
| 1109 weak_factory_.GetWeakPtr(), "dial"), |
| 1110 context_); |
| 1111 // Add observer for dual discovery. |
| 1112 if (cast_media_sink_service_) { |
| 1113 dial_media_sink_service_proxy_->AddObserver( |
| 1114 cast_media_sink_service_.get()); |
| 1115 } |
| 1116 } |
| 1117 dial_media_sink_service_proxy_->Start(); |
| 1118 } |
| 1108 } | 1119 } |
| 1109 | 1120 |
| 1110 void MediaRouterMojoImpl::UpdateMediaSinks( | 1121 void MediaRouterMojoImpl::UpdateMediaSinks( |
| 1111 const MediaSource::Id& source_id) { | 1122 const MediaSource::Id& source_id) { |
| 1112 SetWakeReason(MediaRouteProviderWakeReason::UPDATE_MEDIA_SINKS); | 1123 SetWakeReason(MediaRouteProviderWakeReason::UPDATE_MEDIA_SINKS); |
| 1113 RunOrDefer(base::BindOnce(&MediaRouterMojoImpl::DoUpdateMediaSinks, | 1124 RunOrDefer(base::BindOnce(&MediaRouterMojoImpl::DoUpdateMediaSinks, |
| 1114 base::Unretained(this), source_id)); | 1125 base::Unretained(this), source_id)); |
| 1115 } | 1126 } |
| 1116 | 1127 |
| 1117 void MediaRouterMojoImpl::DoUpdateMediaSinks( | 1128 void MediaRouterMojoImpl::DoUpdateMediaSinks( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1135 | 1146 |
| 1136 void MediaRouterMojoImpl::OnMediaControllerCreated( | 1147 void MediaRouterMojoImpl::OnMediaControllerCreated( |
| 1137 const MediaRoute::Id& route_id, | 1148 const MediaRoute::Id& route_id, |
| 1138 bool success) { | 1149 bool success) { |
| 1139 DVLOG_WITH_INSTANCE(1) << "OnMediaControllerCreated: " << route_id | 1150 DVLOG_WITH_INSTANCE(1) << "OnMediaControllerCreated: " << route_id |
| 1140 << (success ? " was successful." : " failed."); | 1151 << (success ? " was successful." : " failed."); |
| 1141 MediaRouterMojoMetrics::RecordMediaRouteControllerCreationResult(success); | 1152 MediaRouterMojoMetrics::RecordMediaRouteControllerCreationResult(success); |
| 1142 } | 1153 } |
| 1143 | 1154 |
| 1144 } // namespace media_router | 1155 } // namespace media_router |
| OLD | NEW |