Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/discovery/dial/dial_media_sink_service_imp l.h" | 5 #include "chrome/browser/media/router/discovery/dial/dial_media_sink_service_imp l.h" |
| 6 | 6 |
| 7 #include "chrome/browser/media/router/discovery/dial/dial_device_data.h" | 7 #include "chrome/browser/media/router/discovery/dial/dial_device_data.h" |
| 8 #include "chrome/browser/media/router/discovery/mdns/cast_media_sink_service.h" | |
| 8 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 9 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| 10 #include "net/url_request/url_request_context_getter.h" | 11 #include "net/url_request/url_request_context_getter.h" |
| 11 | 12 |
| 12 using content::BrowserThread; | 13 using content::BrowserThread; |
| 13 | 14 |
| 14 namespace media_router { | 15 namespace media_router { |
| 15 | 16 |
| 16 DialMediaSinkServiceImpl::DialMediaSinkServiceImpl( | 17 DialMediaSinkServiceImpl::DialMediaSinkServiceImpl( |
| 17 const OnSinksDiscoveredCallback& callback, | 18 const OnSinksDiscoveredCallback& callback, |
| 19 scoped_refptr<CastMediaSinkService> cast_media_sink_service, | |
| 18 net::URLRequestContextGetter* request_context) | 20 net::URLRequestContextGetter* request_context) |
| 19 : MediaSinkServiceBase(callback), request_context_(request_context) { | 21 : MediaSinkServiceBase(callback), |
| 22 cast_media_sink_service_(cast_media_sink_service), | |
| 23 request_context_(request_context) { | |
| 20 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 24 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 21 DCHECK(request_context_); | 25 DCHECK(request_context_); |
| 22 } | 26 } |
| 23 | 27 |
| 24 DialMediaSinkServiceImpl::~DialMediaSinkServiceImpl() { | 28 DialMediaSinkServiceImpl::~DialMediaSinkServiceImpl() { |
| 25 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 29 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 26 Stop(); | 30 Stop(); |
| 27 } | 31 } |
| 28 | 32 |
| 29 void DialMediaSinkServiceImpl::Start() { | 33 void DialMediaSinkServiceImpl::Start() { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 } | 78 } |
| 75 | 79 |
| 76 void DialMediaSinkServiceImpl::OnDialDeviceEvent( | 80 void DialMediaSinkServiceImpl::OnDialDeviceEvent( |
| 77 const DialRegistry::DeviceList& devices) { | 81 const DialRegistry::DeviceList& devices) { |
| 78 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 82 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 79 DVLOG(2) << "DialMediaSinkServiceImpl::OnDialDeviceEvent found " | 83 DVLOG(2) << "DialMediaSinkServiceImpl::OnDialDeviceEvent found " |
| 80 << devices.size() << " devices"; | 84 << devices.size() << " devices"; |
| 81 | 85 |
| 82 current_sinks_.clear(); | 86 current_sinks_.clear(); |
| 83 current_devices_ = devices; | 87 current_devices_ = devices; |
| 88 if (cast_media_sink_service_) | |
| 89 cast_media_sink_service_->OnDialSinksRemoved(); | |
|
mark a. foltz
2017/07/11 23:52:50
It looks like the DMSS doesn't need to take a depe
| |
| 84 | 90 |
| 85 GetDescriptionService()->GetDeviceDescriptions(devices, | 91 GetDescriptionService()->GetDeviceDescriptions(devices, |
| 86 request_context_.get()); | 92 request_context_.get()); |
| 87 } | 93 } |
| 88 | 94 |
| 89 void DialMediaSinkServiceImpl::OnDialError(DialRegistry::DialErrorCode type) { | 95 void DialMediaSinkServiceImpl::OnDialError(DialRegistry::DialErrorCode type) { |
| 90 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 96 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 91 DVLOG(2) << "OnDialError [DialErrorCode]: " << static_cast<int>(type); | 97 DVLOG(2) << "OnDialError [DialErrorCode]: " << static_cast<int>(type); |
| 92 } | 98 } |
| 93 | 99 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 108 MediaSink::IconType::GENERIC); | 114 MediaSink::IconType::GENERIC); |
| 109 DialSinkExtraData extra_data; | 115 DialSinkExtraData extra_data; |
| 110 extra_data.app_url = description_data.app_url; | 116 extra_data.app_url = description_data.app_url; |
| 111 extra_data.model_name = description_data.model_name; | 117 extra_data.model_name = description_data.model_name; |
| 112 std::string ip_address = device_data.device_description_url().host(); | 118 std::string ip_address = device_data.device_description_url().host(); |
| 113 if (!extra_data.ip_address.AssignFromIPLiteral(ip_address)) { | 119 if (!extra_data.ip_address.AssignFromIPLiteral(ip_address)) { |
| 114 DVLOG(1) << "Invalid ip_address: " << ip_address; | 120 DVLOG(1) << "Invalid ip_address: " << ip_address; |
| 115 return; | 121 return; |
| 116 } | 122 } |
| 117 | 123 |
| 118 current_sinks_.insert(MediaSinkInternal(sink, extra_data)); | 124 MediaSinkInternal dial_sink(sink, extra_data); |
| 125 current_sinks_.insert(dial_sink); | |
| 126 if (cast_media_sink_service_) | |
| 127 cast_media_sink_service_->OnDialSinkAdded(dial_sink); | |
| 119 | 128 |
| 120 // Start fetch timer again if device description comes back after | 129 // Start fetch timer again if device description comes back after |
| 121 // |finish_timer_| fires. | 130 // |finish_timer_| fires. |
| 122 MediaSinkServiceBase::RestartTimer(); | 131 MediaSinkServiceBase::RestartTimer(); |
| 123 } | 132 } |
| 124 | 133 |
| 125 void DialMediaSinkServiceImpl::OnDeviceDescriptionError( | 134 void DialMediaSinkServiceImpl::OnDeviceDescriptionError( |
| 126 const DialDeviceData& device, | 135 const DialDeviceData& device, |
| 127 const std::string& error_message) { | 136 const std::string& error_message) { |
| 128 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 137 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 129 DVLOG(2) << "OnDescriptionFetchesError [message]: " << error_message; | 138 DVLOG(2) << "OnDescriptionFetchesError [message]: " << error_message; |
| 130 } | 139 } |
| 131 | 140 |
| 132 void DialMediaSinkServiceImpl::RecordDeviceCounts() { | 141 void DialMediaSinkServiceImpl::RecordDeviceCounts() { |
| 133 metrics_.RecordDialDeviceCounts(current_sinks_.size(), | 142 metrics_.RecordDialDeviceCounts(current_sinks_.size(), |
| 134 current_devices_.size()); | 143 current_devices_.size()); |
| 135 } | 144 } |
| 136 | 145 |
| 137 } // namespace media_router | 146 } // namespace media_router |
| OLD | NEW |