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 3// found in the LICENSE file. 4 5#ifndef CHROME_BROWSER_EXTENSIONS_API_MDNS_DNS_SD_DEVICE_LISTER_H_ 6#define CHROME_BROWSER_EXTENSIONS_API_MDNS_DNS_SD_DEVICE_LISTER_H_ 7 8#include <string> 9 10#include "chrome/browser/extensions/api/mdns/dns_sd_delegate.h" 11#include "chrome/browser/local_discovery/service_discovery_device_lister.h" 12 13namespace local_discovery { 14class ServiceDiscoveryClient; 15} // local_discovery 16 17namespace extensions { 18 19// Manages a watcher for a specific MDNS/DNS-SD service type and notifies 20// a delegate of changes to watched services. 21class DnsSdDeviceLister 22 : public local_discovery::ServiceDiscoveryDeviceLister::Delegate { 23 public: 24 DnsSdDeviceLister( 25 local_discovery::ServiceDiscoveryClient* service_discovery_client, 26 DnsSdDelegate* delegate, 27 const std::string& service_type); 28 virtual ~DnsSdDeviceLister(); 29 30 virtual void Discover(bool force_update); 31 32 protected: 33 virtual void OnDeviceChanged( 34 bool added, 35 const local_discovery::ServiceDescription& service_description) OVERRIDE; 36 virtual void OnDeviceRemoved(const std::string& service_name) OVERRIDE; 37 virtual void OnDeviceCacheFlushed() OVERRIDE; 38 39 private: 40 // The delegate to notify of changes to services. 41 DnsSdDelegate* const delegate_; 42 local_discovery::ServiceDiscoveryDeviceLister device_lister_; 43 bool started_; 44 45 DISALLOW_COPY_AND_ASSIGN(DnsSdDeviceLister); 46}; 47 48} // namespace extensions 49 50#endif // CHROME_BROWSER_EXTENSIONS_API_MDNS_DNS_SD_DEVICE_LISTER_H_ 51