Pepper: Fix crash on allocation failure.
[chromium-blink-merge.git] / chromeos / dbus / bluetooth_gatt_descriptor_client.h
blob3a7a26f57b2b773c69c9519b1836a98460dbb361
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_DESCRIPTOR_CLIENT_H_
6 #define CHROMEOS_DBUS_BLUETOOTH_GATT_DESCRIPTOR_CLIENT_H_
8 #include <string>
10 #include "base/basictypes.h"
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 // BluetoothGattDescriptorClient is used to communicate with remote GATT
19 // characteristic descriptor objects exposed by the Bluetooth daemon.
20 class CHROMEOS_EXPORT BluetoothGattDescriptorClient : public DBusClient {
21 public:
22 // Structure of properties associated with GATT descriptors.
23 struct Properties : public dbus::PropertySet {
24 // The 128-bit characteristic descriptor UUID. [read-only]
25 dbus::Property<std::string> uuid;
27 // Object path of the GATT characteristic the descriptor belongs to.
28 // [read-only]
29 dbus::Property<dbus::ObjectPath> characteristic;
31 // Raw characteristic descriptor value read from the remote Bluetooth
32 // device. Setting the value sends a write request to the remote device.
33 // [read-write]
34 dbus::Property<std::vector<uint8> > value;
36 Properties(dbus::ObjectProxy* object_proxy,
37 const std::string& interface_name,
38 const PropertyChangedCallback& callback);
39 virtual ~Properties();
42 // Interface for observing changes from a remote GATT characteristic
43 // descriptor.
44 class Observer {
45 public:
46 virtual ~Observer() {}
48 // Called when the GATT descriptor with object path |object_path| is added
49 // to the system.
50 virtual void GattDescriptorAdded(const dbus::ObjectPath& object_path) {}
52 // Called when the GATT descriptor with object path |object_path| is removed
53 // from the system.
54 virtual void GattDescriptorRemoved(const dbus::ObjectPath& object_path) {}
56 // Called when the GATT descriptor with object path |object_path| has a
57 // change in the value of the property named |property_name|.
58 virtual void GattDescriptorPropertyChanged(
59 const dbus::ObjectPath& object_path,
60 const std::string& property_name) {}
63 virtual ~BluetoothGattDescriptorClient();
65 // Adds and removes observers for events on all remote GATT descriptors. Check
66 // the |object_path| parameter of observer methods to determine which GATT
67 // descriptor is issuing the event.
68 virtual void AddObserver(Observer* observer) = 0;
69 virtual void RemoveObserver(Observer* observer) = 0;
71 // Returns the list of GATT descriptor object paths known to the system.
72 virtual std::vector<dbus::ObjectPath> GetDescriptors() = 0;
74 // Obtain the properties for the GATT descriptor with object path
75 // |object_path|. Values should be copied if needed.
76 virtual Properties* GetProperties(const dbus::ObjectPath& object_path) = 0;
78 // Creates the instance.
79 static BluetoothGattDescriptorClient* Create();
81 protected:
82 BluetoothGattDescriptorClient();
84 private:
85 DISALLOW_COPY_AND_ASSIGN(BluetoothGattDescriptorClient);
88 } // namespace chromeos
90 #endif // CHROMEOS_DBUS_BLUETOOTH_GATT_DESCRIPTOR_CLIENT_H_