privet_device_lister.h revision 58537e28ecd584eab876aee8be7156509866d23a
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
15namespace local_discovery {
16
17struct 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
45class 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    virtual void DeviceCacheFlushed() = 0;
54  };
55
56
57  virtual ~PrivetDeviceLister() {}
58
59  // Start the PrivetServiceLister.
60  virtual void Start() = 0;
61
62  virtual void DiscoverNewDevices(bool force_update) = 0;
63};
64
65}  // namespace local_discovery
66
67#endif  // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_DEVICE_LISTER_H_
68