| 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/devtools/device/cast_device_provider.h" | 5 #include "chrome/browser/devtools/device/cast_device_provider.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> |
| 10 #include <vector> | 11 #include <vector> |
| 11 | 12 |
| 12 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 13 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/string_split.h" | 15 #include "base/strings/string_split.h" |
| 15 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
| 16 #include "chrome/browser/local_discovery/service_discovery_shared_client.h" | 17 #include "chrome/browser/local_discovery/service_discovery_shared_client.h" |
| 17 #include "net/base/host_port_pair.h" | 18 #include "net/base/host_port_pair.h" |
| 18 #include "net/base/ip_address.h" | 19 #include "net/base/ip_address.h" |
| 19 | 20 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 void StartDiscovery() { | 98 void StartDiscovery() { |
| 98 // This must be called on the UI thread; ServiceDiscoverySharedClient and | 99 // This must be called on the UI thread; ServiceDiscoverySharedClient and |
| 99 // ServiceDiscoveryDeviceLister are thread protected. | 100 // ServiceDiscoveryDeviceLister are thread protected. |
| 100 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 101 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 101 if (device_lister_) | 102 if (device_lister_) |
| 102 return; | 103 return; |
| 103 service_discovery_client_ = ServiceDiscoverySharedClient::GetInstance(); | 104 service_discovery_client_ = ServiceDiscoverySharedClient::GetInstance(); |
| 104 device_lister_.reset(new ServiceDiscoveryDeviceLister( | 105 device_lister_.reset(new ServiceDiscoveryDeviceLister( |
| 105 this, service_discovery_client_.get(), kCastServiceType)); | 106 this, service_discovery_client_.get(), kCastServiceType)); |
| 106 device_lister_->Start(); | 107 device_lister_->Start(); |
| 107 device_lister_->DiscoverNewDevices(true); | 108 device_lister_->DiscoverNewDevices(); |
| 108 } | 109 } |
| 109 | 110 |
| 110 // ServiceDiscoveryDeviceLister::Delegate implementation: | 111 // ServiceDiscoveryDeviceLister::Delegate implementation: |
| 111 void OnDeviceChanged(bool added, | 112 void OnDeviceChanged(bool added, |
| 112 const ServiceDescription& service_description) override { | 113 const ServiceDescription& service_description) override { |
| 113 runner_->PostTask(FROM_HERE, | 114 runner_->PostTask(FROM_HERE, |
| 114 base::BindOnce(&CastDeviceProvider::OnDeviceChanged, | 115 base::BindOnce(&CastDeviceProvider::OnDeviceChanged, |
| 115 provider_, added, service_description)); | 116 provider_, added, service_description)); |
| 116 } | 117 } |
| 117 | 118 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 const std::string& hostname = it->second; | 198 const std::string& hostname = it->second; |
| 198 device_info_map_.erase(hostname); | 199 device_info_map_.erase(hostname); |
| 199 service_hostname_map_.erase(it); | 200 service_hostname_map_.erase(it); |
| 200 } | 201 } |
| 201 | 202 |
| 202 void CastDeviceProvider::OnDeviceCacheFlushed() { | 203 void CastDeviceProvider::OnDeviceCacheFlushed() { |
| 203 VLOG(1) << "Device cache flushed"; | 204 VLOG(1) << "Device cache flushed"; |
| 204 service_hostname_map_.clear(); | 205 service_hostname_map_.clear(); |
| 205 device_info_map_.clear(); | 206 device_info_map_.clear(); |
| 206 } | 207 } |
| OLD | NEW |