| Index: chrome/browser/media/router/mojo/media_router_mojo_impl.cc
|
| diff --git a/chrome/browser/media/router/mojo/media_router_mojo_impl.cc b/chrome/browser/media/router/mojo/media_router_mojo_impl.cc
|
| index 3871ccd6ecabfe972bf4add744833365ccdff41b..11592db63db81e54cd01ea2198993929e8ee12a3 100644
|
| --- a/chrome/browser/media/router/mojo/media_router_mojo_impl.cc
|
| +++ b/chrome/browser/media/router/mojo/media_router_mojo_impl.cc
|
| @@ -81,8 +81,14 @@ MediaRouterMojoImpl::MediaRouterMojoImpl(
|
|
|
| MediaRouterMojoImpl::~MediaRouterMojoImpl() {
|
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
| - if (dial_media_sink_service_proxy_)
|
| - dial_media_sink_service_proxy_->Stop();
|
| + if (!dial_media_sink_service_proxy_)
|
| + return;
|
| + dial_media_sink_service_proxy_->Stop();
|
| +
|
| + if (!cast_media_sink_service_)
|
| + return;
|
| + dial_media_sink_service_proxy_->RemoveObserver(
|
| + cast_media_sink_service_.get());
|
| }
|
|
|
| // static
|
| @@ -1086,16 +1092,6 @@ void MediaRouterMojoImpl::StartDiscovery() {
|
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
| DVLOG_WITH_INSTANCE(1) << "StartDiscovery";
|
|
|
| - if (media_router::DialLocalDiscoveryEnabled()) {
|
| - if (!dial_media_sink_service_proxy_) {
|
| - dial_media_sink_service_proxy_ = new DialMediaSinkServiceProxy(
|
| - base::Bind(&MediaRouterMojoImpl::ProvideSinks,
|
| - weak_factory_.GetWeakPtr(), "dial"),
|
| - context_);
|
| - }
|
| - dial_media_sink_service_proxy_->Start();
|
| - }
|
| -
|
| if (media_router::CastDiscoveryEnabled()) {
|
| if (!cast_media_sink_service_) {
|
| cast_media_sink_service_ = new CastMediaSinkService(
|
| @@ -1105,6 +1101,21 @@ void MediaRouterMojoImpl::StartDiscovery() {
|
| }
|
| cast_media_sink_service_->Start();
|
| }
|
| +
|
| + if (media_router::DialLocalDiscoveryEnabled()) {
|
| + if (!dial_media_sink_service_proxy_) {
|
| + dial_media_sink_service_proxy_ = new DialMediaSinkServiceProxy(
|
| + base::Bind(&MediaRouterMojoImpl::ProvideSinks,
|
| + weak_factory_.GetWeakPtr(), "dial"),
|
| + context_);
|
| + // Add observer for dual discovery.
|
| + if (cast_media_sink_service_) {
|
| + dial_media_sink_service_proxy_->AddObserver(
|
| + cast_media_sink_service_.get());
|
| + }
|
| + }
|
| + dial_media_sink_service_proxy_->Start();
|
| + }
|
| }
|
|
|
| void MediaRouterMojoImpl::UpdateMediaSinks(
|
|
|