| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/extensions/api/mdns/dns_sd_registry.h" | 5 #include "chrome/browser/extensions/api/mdns/dns_sd_registry.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "chrome/browser/extensions/api/mdns/dns_sd_device_lister.h" | 8 #include "chrome/browser/extensions/api/mdns/dns_sd_device_lister.h" |
| 9 #include "chrome/browser/local_discovery/service_discovery_shared_client.h" | 9 #include "chrome/browser/local_discovery/service_discovery_shared_client.h" |
| 10 | 10 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 if (service_type.empty()) | 133 if (service_type.empty()) |
| 134 return; | 134 return; |
| 135 | 135 |
| 136 if (IsRegistered(service_type)) { | 136 if (IsRegistered(service_type)) { |
| 137 service_data_map_[service_type]->ListenerAdded(); | 137 service_data_map_[service_type]->ListenerAdded(); |
| 138 DispatchApiEvent(service_type); | 138 DispatchApiEvent(service_type); |
| 139 return; | 139 return; |
| 140 } | 140 } |
| 141 | 141 |
| 142 scoped_ptr<DnsSdDeviceLister> dns_sd_device_lister(CreateDnsSdDeviceLister( | 142 scoped_ptr<DnsSdDeviceLister> dns_sd_device_lister(CreateDnsSdDeviceLister( |
| 143 this, service_type, service_discovery_client_)); | 143 this, service_type, service_discovery_client_.get())); |
| 144 dns_sd_device_lister->Discover(false); | 144 dns_sd_device_lister->Discover(false); |
| 145 linked_ptr<ServiceTypeData> service_type_data( | 145 linked_ptr<ServiceTypeData> service_type_data( |
| 146 new ServiceTypeData(dns_sd_device_lister.Pass())); | 146 new ServiceTypeData(dns_sd_device_lister.Pass())); |
| 147 service_data_map_[service_type] = service_type_data; | 147 service_data_map_[service_type] = service_type_data; |
| 148 DispatchApiEvent(service_type); | 148 DispatchApiEvent(service_type); |
| 149 } | 149 } |
| 150 | 150 |
| 151 void DnsSdRegistry::UnregisterDnsSdListener(std::string service_type) { | 151 void DnsSdRegistry::UnregisterDnsSdListener(std::string service_type) { |
| 152 VLOG(1) << "UnregisterDnsSdListener: " << service_type; | 152 VLOG(1) << "UnregisterDnsSdListener: " << service_type; |
| 153 DnsSdRegistry::DnsSdServiceTypeDataMap::iterator it = | 153 DnsSdRegistry::DnsSdServiceTypeDataMap::iterator it = |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 VLOG(1) << "DispatchApiEvent: service_type: " << service_type; | 216 VLOG(1) << "DispatchApiEvent: service_type: " << service_type; |
| 217 FOR_EACH_OBSERVER(DnsSdObserver, observers_, OnDnsSdEvent( | 217 FOR_EACH_OBSERVER(DnsSdObserver, observers_, OnDnsSdEvent( |
| 218 service_type, service_data_map_[service_type]->GetServiceList())); | 218 service_type, service_data_map_[service_type]->GetServiceList())); |
| 219 } | 219 } |
| 220 | 220 |
| 221 bool DnsSdRegistry::IsRegistered(const std::string& service_type) { | 221 bool DnsSdRegistry::IsRegistered(const std::string& service_type) { |
| 222 return service_data_map_.find(service_type) != service_data_map_.end(); | 222 return service_data_map_.find(service_type) != service_data_map_.end(); |
| 223 } | 223 } |
| 224 | 224 |
| 225 } // namespace extensions | 225 } // namespace extensions |
| OLD | NEW |