Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / chromeos / dbus / bluetooth_gatt_service_client.h
blob080ca8f4b07abdf01aec07e1d46449095c8c8879
1 // Copyright 2014 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 CHROMEOS_DBUS_BLUETOOTH_GATT_SERVICE_CLIENT_H_
6 #define CHROMEOS_DBUS_BLUETOOTH_GATT_SERVICE_CLIENT_H_
8 #include <string>
9 #include <vector>
11 #include "chromeos/chromeos_export.h"
12 #include "chromeos/dbus/dbus_client.h"
13 #include "dbus/object_path.h"
14 #include "dbus/property.h"
16 namespace chromeos {
18 // BluetoothGattServiceClient is used to communicate with remote GATT service
19 // objects exposed by the Bluetooth daemon.
20 class CHROMEOS_EXPORT BluetoothGattServiceClient : public DBusClient {
21 public:
22 // Structure of properties associated with GATT services.
23 struct Properties : public dbus::PropertySet {
24 // The 128-bit service UUID. [read-only]
25 dbus::Property<std::string> uuid;
27 // Object path of the Bluetooth device that the GATT service belongs to.
28 dbus::Property<dbus::ObjectPath> device;
30 // Whether or not this service is a primary service.
31 dbus::Property<bool> primary;
33 // Array of object paths representing the characteristics of this service.
34 // [read-only]
35 dbus::Property<std::vector<dbus::ObjectPath> > characteristics;
37 // Array of object paths representing the included services of this service.
38 // [read-only]
39 dbus::Property<std::vector<dbus::ObjectPath> > includes;
41 Properties(dbus::ObjectProxy* object_proxy,
42 const std::string& interface_name,
43 const PropertyChangedCallback& callback);
44 ~Properties() override;
47 // Interface for observing changes from a remote GATT service.
48 class Observer {
49 public:
50 virtual ~Observer() {}
52 // Called when the GATT service with object path |object_path| is added to
53 // the system.
54 virtual void GattServiceAdded(const dbus::ObjectPath& object_path) {}
56 // Called when the GATT service with object path |object_path| is removed
57 // from the system.
58 virtual void GattServiceRemoved(const dbus::ObjectPath& object_path) {}
60 // Called when the GATT service with object path |object_path| has a change
61 // in the value of the property named |property_name|.
62 virtual void GattServicePropertyChanged(const dbus::ObjectPath& object_path,
63 const std::string& property_name) {}
66 ~BluetoothGattServiceClient() override;
68 // Adds and removes observers for events on all remote GATT services. Check
69 // the |object_path| parameter of observer methods to determine which GATT
70 // service is issuing the event.
71 virtual void AddObserver(Observer* observer) = 0;
72 virtual void RemoveObserver(Observer* observer) = 0;
74 // Returns the list of GATT service object paths known to the system.
75 virtual std::vector<dbus::ObjectPath> GetServices() = 0;
77 // Obtain the properties for the GATT service with object path |object_path|.
78 // Values should be copied if needed.
79 virtual Properties* GetProperties(const dbus::ObjectPath& object_path) = 0;
81 // Creates the instance.
82 static BluetoothGattServiceClient* Create();
84 protected:
85 BluetoothGattServiceClient();
87 private:
88 DISALLOW_COPY_AND_ASSIGN(BluetoothGattServiceClient);
91 } // namespace chromeos
93 #endif // CHROMEOS_DBUS_BLUETOOTH_GATT_SERVICE_CLIENT_H_