Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Side by Side Diff: device/bluetooth/bluez/bluetooth_gatt_descriptor_bluez.h

Issue 1898643002: Refactor device::BluetoothGattXXX classes to split into remote/local. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_GATT_DESCRIPTOR_BLUEZ_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_GATT_DESCRIPTOR_BLUEZ_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_GATT_DESCRIPTOR_BLUEZ_H_ 6 #define DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_GATT_DESCRIPTOR_BLUEZ_H_
7
8 #include <stdint.h>
9 7
10 #include <string> 8 #include <string>
11 #include <vector>
12 9
13 #include "base/macros.h" 10 #include "base/macros.h"
14 #include "base/memory/weak_ptr.h"
15 #include "dbus/object_path.h" 11 #include "dbus/object_path.h"
16 #include "device/bluetooth/bluetooth_gatt_descriptor.h" 12 #include "device/bluetooth/bluetooth_gatt_descriptor.h"
17 #include "device/bluetooth/bluetooth_uuid.h"
18
19 namespace device {
20
21 class BluetoothGattCharacteristic;
22
23 } // namespace device
24 13
25 namespace bluez { 14 namespace bluez {
26 15
27 class BluetoothGattCharacteristicBlueZ; 16 class BluetoothGattCharacteristicBlueZ;
28 17
29 // The BluetoothGattDescriptorBlueZ class implements 18 // The BluetoothGattDescriptorBlueZ class implements BluetoothGattDescriptor for
30 // BluetoothGattDescriptor for remote and local GATT characteristic descriptors 19 // GATT characteristic descriptors for platforms that use BlueZ.
31 // for platforms that use BlueZ. 20 class BluetoothGattDescriptorBlueZ
32 class BluetoothGattDescriptorBlueZ : public device::BluetoothGattDescriptor { 21 : public virtual device::BluetoothGattDescriptor {
33 public: 22 public:
34 // device::BluetoothGattDescriptor overrides. 23 // device::BluetoothGattDescriptor overrides.
35 std::string GetIdentifier() const override; 24 std::string GetIdentifier() const override;
36 device::BluetoothUUID GetUUID() const override;
37 bool IsLocal() const override;
38 const std::vector<uint8_t>& GetValue() const override;
39 device::BluetoothGattCharacteristic* GetCharacteristic() const override;
40 device::BluetoothGattCharacteristic::Permissions GetPermissions()
41 const override;
42 void ReadRemoteDescriptor(const ValueCallback& callback,
43 const ErrorCallback& error_callback) override;
44 void WriteRemoteDescriptor(const std::vector<uint8_t>& new_value,
45 const base::Closure& callback,
46 const ErrorCallback& error_callback) override;
47 25
48 // Object path of the underlying D-Bus characteristic. 26 // Object path of the underlying D-Bus characteristic.
49 const dbus::ObjectPath& object_path() const { return object_path_; } 27 const dbus::ObjectPath& object_path() const { return object_path_; }
50 28
51 private: 29 protected:
52 friend class BluetoothRemoteGattCharacteristicBlueZ; 30 explicit BluetoothGattDescriptorBlueZ(const dbus::ObjectPath& object_path);
53
54 BluetoothGattDescriptorBlueZ(BluetoothGattCharacteristicBlueZ* characteristic,
55 const dbus::ObjectPath& object_path,
56 bool is_local);
57 ~BluetoothGattDescriptorBlueZ() override; 31 ~BluetoothGattDescriptorBlueZ() override;
58 32
33 private:
59 // Called by dbus:: on unsuccessful completion of a request to read or write 34 // Called by dbus:: on unsuccessful completion of a request to read or write
60 // the descriptor value. 35 // the descriptor value.
61 void OnError(const ErrorCallback& error_callback, 36 void OnError(const ErrorCallback& error_callback,
62 const std::string& error_name, 37 const std::string& error_name,
63 const std::string& error_message); 38 const std::string& error_message);
64 39
65 // Object path of the D-Bus descriptor object. 40 // Object path of the D-Bus descriptor object.
66 dbus::ObjectPath object_path_; 41 dbus::ObjectPath object_path_;
67 42
68 // The GATT characteristic this descriptor belongs to.
69 BluetoothGattCharacteristicBlueZ* characteristic_;
70
71 // Is this a remote or local descriptor.
72 bool is_local_;
73
74 // Note: This should remain the last member so it'll be destroyed and
75 // invalidate its weak pointers before any other members are destroyed.
76 base::WeakPtrFactory<BluetoothGattDescriptorBlueZ> weak_ptr_factory_;
77
78 DISALLOW_COPY_AND_ASSIGN(BluetoothGattDescriptorBlueZ); 43 DISALLOW_COPY_AND_ASSIGN(BluetoothGattDescriptorBlueZ);
79 }; 44 };
80 45
81 } // namespace bluez 46 } // namespace bluez
82 47
83 #endif // DEVICE_BLUETOOTH_BLUETOOTH_GATT_DESCRIPTOR_BLUEZ_H_ 48 #endif // DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_GATT_DESCRIPTOR_BLUEZ_H_
OLDNEW
« no previous file with comments | « device/bluetooth/bluez/bluetooth_gatt_connection_bluez.cc ('k') | device/bluetooth/bluez/bluetooth_gatt_descriptor_bluez.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698