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.
5 #ifndef CHROME_BROWSER_LOCAL_DISCOVERY_SERVICE_DISCOVERY_DEVICE_LISTER_H_
6 #define CHROME_BROWSER_LOCAL_DISCOVERY_SERVICE_DISCOVERY_DEVICE_LISTER_H_
11 #include "base/memory/linked_ptr.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
14 #include "chrome/common/local_discovery/service_discovery_client.h"
16 namespace local_discovery {
18 class ServiceDiscoveryDeviceLister {
22 virtual void OnDeviceChanged(
24 const ServiceDescription& service_description) = 0;
25 virtual void OnDeviceRemoved(const std::string& service_name) = 0;
26 virtual void OnDeviceCacheFlushed() = 0;
29 ServiceDiscoveryDeviceLister(Delegate* delegate,
30 ServiceDiscoveryClient* service_discovery_client,
31 const std::string& service_type);
32 virtual ~ServiceDiscoveryDeviceLister();
35 void DiscoverNewDevices(bool force_update);
37 std::string service_type() { return service_type_; }
40 typedef std::map<std::string, linked_ptr<ServiceResolver> >
43 void OnServiceUpdated(ServiceWatcher::UpdateType update,
44 const std::string& service_name);
46 void OnResolveComplete(
48 std::string service_name,
49 ServiceResolver::RequestStatus status,
50 const ServiceDescription& description);
52 // Create or recreate the service watcher
53 void CreateServiceWatcher();
55 Delegate* const delegate_;
56 ServiceDiscoveryClient* const service_discovery_client_;
57 const std::string service_type_;
59 scoped_ptr<ServiceWatcher> service_watcher_;
60 ServiceResolverMap resolvers_;
62 base::WeakPtrFactory<ServiceDiscoveryDeviceLister> weak_factory_;
64 DISALLOW_COPY_AND_ASSIGN(ServiceDiscoveryDeviceLister);
67 } // namespace local_discovery
69 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_SERVICE_DISCOVERY_DEVICE_LISTER_H_