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_H_
      6 #define CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_DEVICE_LISTER_H_
      7 
      8 #include <string>
      9 
     10 #include "base/callback.h"
     11 #include "base/time/time.h"
     12 #include "net/base/host_port_pair.h"
     13 #include "net/base/net_util.h"
     14 
     15 namespace local_discovery {
     16 
     17 struct DeviceDescription {
     18   enum ConnectionState {
     19     ONLINE,
     20     OFFLINE,
     21     CONNECTING,
     22     NOT_CONFIGURED,
     23     UNKNOWN
     24   };
     25 
     26   DeviceDescription();
     27   ~DeviceDescription();
     28 
     29   // Display attributes
     30   std::string name;
     31   std::string description;
     32 
     33   // Functional attributes
     34   std::string url;
     35   std::string id;
     36   std::string type;
     37   ConnectionState connection_state;
     38 
     39   // Attributes related to local HTTP
     40   net::HostPortPair address;
     41   net::IPAddressNumber ip_address;
     42   base::Time last_seen;
     43 };
     44 
     45 class PrivetDeviceLister {
     46  public:
     47   class Delegate {
     48    public:
     49     virtual void DeviceChanged(bool added,
     50                                const std::string& name,
     51                                const DeviceDescription& description) = 0;
     52     virtual void DeviceRemoved(const std::string& name) = 0;
     53   };
     54 
     55 
     56   virtual ~PrivetDeviceLister() {}
     57 
     58   // Start the PrivetServiceLister.
     59   virtual void Start() = 0;
     60 
     61   virtual void DiscoverNewDevices(bool force_update) = 0;
     62 };
     63 
     64 }  // namespace local_discovery
     65 
     66 #endif  // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_DEVICE_LISTER_H_
     67