Home | History | Annotate | Download | only in local_discovery
      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_LOCAL_DISCOVERY_PRIVET_DEVICE_LISTER_IMPL_H_
      6 #define CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_DEVICE_LISTER_IMPL_H_
      7 
      8 #include <map>
      9 #include <string>
     10 
     11 #include "base/callback.h"
     12 #include "base/memory/linked_ptr.h"
     13 #include "base/memory/scoped_ptr.h"
     14 #include "chrome/browser/local_discovery/privet_device_lister.h"
     15 #include "chrome/common/local_discovery/service_discovery_client.h"
     16 
     17 namespace local_discovery {
     18 
     19 class PrivetDeviceListerImpl : public PrivetDeviceLister {
     20  public:
     21   PrivetDeviceListerImpl(
     22       ServiceDiscoveryClient* service_discovery_client,
     23       PrivetDeviceLister::Delegate* delegate,
     24       std::string subtype);
     25 
     26   PrivetDeviceListerImpl(
     27       ServiceDiscoveryClient* service_discovery_client,
     28       PrivetDeviceLister::Delegate* delegate);
     29 
     30   virtual ~PrivetDeviceListerImpl();
     31 
     32   virtual void Start() OVERRIDE;
     33 
     34   virtual void DiscoverNewDevices(bool force_update) OVERRIDE;
     35 
     36  private:
     37   typedef std::map<std::string, linked_ptr<ServiceResolver> >
     38      ServiceResolverMap;
     39 
     40   void OnServiceUpdated(ServiceWatcher::UpdateType update,
     41                         const std::string& service_name);
     42 
     43   void OnResolveComplete(
     44       bool added,
     45       ServiceResolver::RequestStatus status,
     46       const ServiceDescription& description);
     47 
     48   void FillDeviceDescription(const ServiceDescription& service_description,
     49                              DeviceDescription* device_description);
     50 
     51   DeviceDescription::ConnectionState ConnectionStateFromString(
     52       const std::string& str);
     53 
     54   PrivetDeviceLister::Delegate* delegate_;
     55 
     56   ServiceDiscoveryClient* service_discovery_client_;
     57   scoped_ptr<ServiceWatcher> service_watcher_;
     58   ServiceResolverMap resolvers_;
     59   std::string service_type_;
     60 };
     61 
     62 }  // namespace local_discovery
     63 
     64 #endif  // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_DEVICE_LISTER_IMPL_H_
     65