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/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
| 10 #include "net/url_request/url_request_context_getter.h" | 10 #include "net/url_request/url_request_context_getter.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 DCHECK(!description_service_); | 72 DCHECK(!description_service_); |
| 73 description_service_ = std::move(description_service); | 73 description_service_ = std::move(description_service); |
| 74 } | 74 } |
| 75 | 75 |
| 76 void DialMediaSinkServiceImpl::OnDialDeviceEvent( | 76 void DialMediaSinkServiceImpl::OnDialDeviceEvent( |
| 77 const DialRegistry::DeviceList& devices) { | 77 const DialRegistry::DeviceList& devices) { |
| 78 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 78 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 79 DVLOG(2) << "DialMediaSinkServiceImpl::OnDialDeviceEvent found " | 79 DVLOG(2) << "DialMediaSinkServiceImpl::OnDialDeviceEvent found " |
| 80 << devices.size() << " devices"; | 80 << devices.size() << " devices"; |
| 81 | 81 |
| 82 current_sinks_.clear(); | 82 MediaSinkServiceBase::RemoveSinks(); |
|
imcheng
2017/07/06 22:53:30
Does Cast care that sinks are being removed from D
zhaobin
2017/07/10 20:21:15
I think it is needed in current implementation bec
imcheng
2017/07/12 00:51:35
Ok, so IIUC, once the ChannelError fix is landed,
| |
| 83 current_devices_ = devices; | 83 current_devices_ = devices; |
| 84 | 84 |
| 85 GetDescriptionService()->GetDeviceDescriptions(devices, | 85 GetDescriptionService()->GetDeviceDescriptions(devices, |
| 86 request_context_.get()); | 86 request_context_.get()); |
| 87 } | 87 } |
| 88 | 88 |
| 89 void DialMediaSinkServiceImpl::OnDialError(DialRegistry::DialErrorCode type) { | 89 void DialMediaSinkServiceImpl::OnDialError(DialRegistry::DialErrorCode type) { |
| 90 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 90 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 91 DVLOG(2) << "OnDialError [DialErrorCode]: " << static_cast<int>(type); | 91 DVLOG(2) << "OnDialError [DialErrorCode]: " << static_cast<int>(type); |
| 92 } | 92 } |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 108 MediaSink::IconType::GENERIC); | 108 MediaSink::IconType::GENERIC); |
| 109 DialSinkExtraData extra_data; | 109 DialSinkExtraData extra_data; |
| 110 extra_data.app_url = description_data.app_url; | 110 extra_data.app_url = description_data.app_url; |
| 111 extra_data.model_name = description_data.model_name; | 111 extra_data.model_name = description_data.model_name; |
| 112 std::string ip_address = device_data.device_description_url().host(); | 112 std::string ip_address = device_data.device_description_url().host(); |
| 113 if (!extra_data.ip_address.AssignFromIPLiteral(ip_address)) { | 113 if (!extra_data.ip_address.AssignFromIPLiteral(ip_address)) { |
| 114 DVLOG(1) << "Invalid ip_address: " << ip_address; | 114 DVLOG(1) << "Invalid ip_address: " << ip_address; |
| 115 return; | 115 return; |
| 116 } | 116 } |
| 117 | 117 |
| 118 current_sinks_.insert(MediaSinkInternal(sink, extra_data)); | 118 MediaSinkServiceBase::AddSink(MediaSinkInternal(sink, extra_data)); |
| 119 | |
| 120 // Start fetch timer again if device description comes back after | 119 // Start fetch timer again if device description comes back after |
| 121 // |finish_timer_| fires. | 120 // |finish_timer_| fires. |
| 122 MediaSinkServiceBase::RestartTimer(); | 121 MediaSinkServiceBase::RestartTimer(); |
| 123 } | 122 } |
| 124 | 123 |
| 125 void DialMediaSinkServiceImpl::OnDeviceDescriptionError( | 124 void DialMediaSinkServiceImpl::OnDeviceDescriptionError( |
| 126 const DialDeviceData& device, | 125 const DialDeviceData& device, |
| 127 const std::string& error_message) { | 126 const std::string& error_message) { |
| 128 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 127 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 129 DVLOG(2) << "OnDescriptionFetchesError [message]: " << error_message; | 128 DVLOG(2) << "OnDescriptionFetchesError [message]: " << error_message; |
| 130 } | 129 } |
| 131 | 130 |
| 132 void DialMediaSinkServiceImpl::RecordDeviceCounts() { | 131 void DialMediaSinkServiceImpl::RecordDeviceCounts() { |
| 133 metrics_.RecordDialDeviceCounts(current_sinks_.size(), | 132 metrics_.RecordDialDeviceCounts(MediaSinkServiceBase::GetCurrentSinksSize(), |
| 134 current_devices_.size()); | 133 current_devices_.size()); |
| 135 } | 134 } |
| 136 | 135 |
| 137 } // namespace media_router | 136 } // namespace media_router |
| OLD | NEW |