Chromium Code Reviews| Index: chrome/browser/extensions/api/mdns/dns_sd_registry.cc |
| diff --git a/chrome/browser/extensions/api/mdns/dns_sd_registry.cc b/chrome/browser/extensions/api/mdns/dns_sd_registry.cc |
| index 78a68954a22f523615d43ccb7c17cf39ca30d5f0..ffba78f102053edd6cdc9e752e60df3b8f674510 100644 |
| --- a/chrome/browser/extensions/api/mdns/dns_sd_registry.cc |
| +++ b/chrome/browser/extensions/api/mdns/dns_sd_registry.cc |
| @@ -54,16 +54,26 @@ bool DnsSdRegistry::ServiceTypeData::UpdateService( |
| // Set to true when a service is updated in or added to the registry. |
| bool updated_or_added = added; |
| if (it != service_list_.end()) { |
|
Vitaly Buka (NO REVIEWS)
2014/01/15 22:11:42
How about just one log statement:
VLOG(1) << "Upd
imcheng
2014/01/15 22:51:37
Done.
|
| + VLOG(1) << "Found service in cache: " << service.service_name; |
| // If added == true, but we still found the service in our cache, then just |
| // update the existing entry, but this should not happen! |
| DCHECK(!added); |
| if (*it != service) { |
| + VLOG(1) << "Service in cache was different, updating: " |
| + << service.service_name; |
| *it = service; |
| updated_or_added = true; |
| } |
| } else if (added) { |
| + VLOG(1) << "Service not found in cache, adding: " << service.service_name; |
| service_list_.push_back(service); |
| + } else { |
| + VLOG(1) << "Service not found in cache but claims added == false, " |
| + << "this should not happen?: " << service.service_name; |
| } |
| + |
| + VLOG(1) << "Updated or added service: " << service.service_name << "? : " |
| + << updated_or_added; |
| return updated_or_added; |
| }; |
| @@ -120,15 +130,20 @@ DnsSdDeviceLister* DnsSdRegistry::CreateDnsSdDeviceLister( |
| } |
| void DnsSdRegistry::RegisterDnsSdListener(std::string service_type) { |
| + VLOG(1) << "Registering listener of service type: " << service_type; |
|
Vitaly Buka (NO REVIEWS)
2014/01/15 22:11:42
Just one line in begining with input service_type
imcheng
2014/01/15 22:51:37
Done.
|
| if (service_type.empty()) |
| return; |
| if (IsRegistered(service_type)) { |
| + VLOG(1) << "Service type " << service_type |
| + << " was already registered; adding " |
| + << "listener and dispatching event"; |
| service_data_map_[service_type]->ListenerAdded(); |
| DispatchApiEvent(service_type); |
| return; |
| } |
| + VLOG(1) << "Creating DnsSdDeviceLister and discovering and dispatching event"; |
| scoped_ptr<DnsSdDeviceLister> dns_sd_device_lister(CreateDnsSdDeviceLister( |
| this, service_type, service_discovery_client_)); |
| dns_sd_device_lister->Discover(false); |
| @@ -139,6 +154,7 @@ void DnsSdRegistry::RegisterDnsSdListener(std::string service_type) { |
| } |
| void DnsSdRegistry::UnregisterDnsSdListener(std::string service_type) { |
| + VLOG(1) << "Unregistering listener of service type: " << service_type; |
| DnsSdRegistry::DnsSdServiceTypeDataMap::iterator it = |
| service_data_map_.find(service_type); |
| if (it == service_data_map_.end()) |
| @@ -151,11 +167,17 @@ void DnsSdRegistry::UnregisterDnsSdListener(std::string service_type) { |
| void DnsSdRegistry::ServiceChanged(const std::string& service_type, |
| bool added, |
| const DnsSdService& service) { |
| - if (!IsRegistered(service_type)) |
| + if (!IsRegistered(service_type)) { |
| + VLOG(1) << "ServiceChanged: Service type: " << service_type |
|
Vitaly Buka (NO REVIEWS)
2014/01/15 22:11:42
same
imcheng
2014/01/15 22:51:37
Done.
|
| + << " not registered; ignoring"; |
| return; |
| + } |
| - VLOG(1) << "Service changed: " << service.service_name; |
| + VLOG(1) << "Service changed: " << service.service_name |
| + << ", added? " << added; |
| if (service_data_map_[service_type]->UpdateService(added, service)) { |
| + VLOG(1) << "Updated service and dispatching event for service type: " |
| + << service_type; |
| DispatchApiEvent(service_type); |
| } else { |
| VLOG(1) << "Failed to find existing service to update: " |
| @@ -165,11 +187,16 @@ void DnsSdRegistry::ServiceChanged(const std::string& service_type, |
| void DnsSdRegistry::ServiceRemoved(const std::string& service_type, |
| const std::string& service_name) { |
| - if (!IsRegistered(service_type)) |
| + if (!IsRegistered(service_type)) { |
| + VLOG(1) << "ServiceRemoved: Service type: " << service_type |
| + << " not registered; ignoring"; |
|
Vitaly Buka (NO REVIEWS)
2014/01/15 22:11:42
same
imcheng
2014/01/15 22:51:37
Done.
|
| return; |
| + } |
| VLOG(1) << "Removing service: " << service_name; |
| if (service_data_map_[service_type]->RemoveService(service_name)) { |
| + VLOG(1) << "Removed service and dispatching event for service type: " |
| + << service_type; |
| DispatchApiEvent(service_type); |
| } else { |
| VLOG(1) << "Failed to remove service: " << service_name; |
| @@ -177,16 +204,27 @@ void DnsSdRegistry::ServiceRemoved(const std::string& service_type, |
| } |
| void DnsSdRegistry::ServicesFlushed(const std::string& service_type) { |
| - if (!IsRegistered(service_type)) |
| + if (!IsRegistered(service_type)) { |
| + VLOG(1) << "ServicesFlushed: Service type: " << service_type |
|
Vitaly Buka (NO REVIEWS)
2014/01/15 22:11:42
same
imcheng
2014/01/15 22:51:37
Done.
|
| + << " not registered; ignoring"; |
| return; |
| + } |
| - if (service_data_map_[service_type]->ClearServices()) |
| + VLOG(1) << "Flushing Service type: " << service_type; |
| + if (service_data_map_[service_type]->ClearServices()) { |
| + VLOG(1) << "Cleared services and dispatching event for service type: " |
| + << service_type; |
| DispatchApiEvent(service_type); |
| + } else { |
| + VLOG(1) << "Failed to clear services for service type: " << service_type; |
| + } |
| } |
| void DnsSdRegistry::DispatchApiEvent(const std::string& service_type) { |
| // TODO(justinlin): Make this MaybeDispatchApiEvent instead and dispatch if a |
| // dirty bit is set. |
| + VLOG(1) << "Calling observers OnDnsSdEvent with service type: " |
| + << service_type; |
| FOR_EACH_OBSERVER(DnsSdObserver, observers_, OnDnsSdEvent( |
| service_type, service_data_map_[service_type]->GetServiceList())); |
| } |