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

Side by Side Diff: device/bluetooth/bluetooth_gatt_service_bluez.h

Issue 1872943002: Add support for local services/characteristics/descriptors. (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
(Empty)
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.
4
5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_GATT_SERVICE_BLUEZ_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_GATT_SERVICE_BLUEZ_H_
7
8 #include <stdint.h>
9
10 #include <map>
11 #include <string>
12 #include <vector>
13
14 #include "base/macros.h"
15 #include "base/memory/ref_counted.h"
16 #include "base/memory/weak_ptr.h"
17 #include "base/observer_list.h"
18 #include "dbus/object_path.h"
19 #include "device/bluetooth/bluetooth_gatt_service.h"
20 #include "device/bluetooth/bluetooth_uuid.h"
21 #include "device/bluetooth/dbus/bluetooth_gatt_characteristic_client.h"
22 #include "device/bluetooth/dbus/bluetooth_gatt_service_client.h"
23
24 namespace device {
25
26 class BluetoothAdapter;
27 class BluetoothGattCharacteristic;
28
29 } // namespace device
30
31 namespace bluez {
32
33 class BluetoothAdapterBlueZ;
34 class BluetoothDeviceBlueZ;
35 class BluetoothGattCharacteristicBlueZ;
36 class BluetoothGattDescriptorBlueZ;
37
38 // The BluetoothGattServiceBlueZ class implements BluetootGattService
39 // for GATT services on platforms that use BlueZ.
40 class BluetoothGattServiceBlueZ : public device::BluetoothGattService {
41 public:
42 // device::BluetoothGattService overrides.
43 std::string GetIdentifier() const override;
44 device::BluetoothUUID GetUUID() const override;
45 bool IsPrimary() const override;
46 device::BluetoothDevice* GetDevice() const override;
47 std::vector<device::BluetoothGattCharacteristic*> GetCharacteristics()
48 const override;
49 std::vector<device::BluetoothGattService*> GetIncludedServices()
50 const override;
51 device::BluetoothGattCharacteristic* GetCharacteristic(
52 const std::string& identifier) const override;
53
54 // Object path of the underlying service.
55 const dbus::ObjectPath& object_path() const { return object_path_; }
56
57 // Parses a named D-Bus error into a service error code.
58 static device::BluetoothGattService::GattErrorCode DBusErrorToServiceError(
59 const std::string error_name);
60
61 // Returns the adapter associated with this service.
62 BluetoothAdapterBlueZ* GetAdapter() const;
63
64 protected:
65 BluetoothGattServiceBlueZ(BluetoothAdapterBlueZ* adapter,
66 BluetoothDeviceBlueZ* device,
67 const dbus::ObjectPath& object_path);
68 ~BluetoothGattServiceBlueZ() override;
69
70 private:
71 friend class BluetoothDeviceBlueZ;
72
73 typedef std::map<dbus::ObjectPath, BluetoothGattCharacteristicBlueZ*>
74 CharacteristicMap;
75
76 // Object path of the GATT service.
77 dbus::ObjectPath object_path_;
78
79 // The adapter associated with this service. It's ok to store a raw pointer
80 // here since |adapter_| indirectly owns this instance.
81 BluetoothAdapterBlueZ* adapter_;
82
83 // The device this GATT service belongs to. It's ok to store a raw pointer
84 // here since |device_| owns this instance.
85 BluetoothDeviceBlueZ* device_;
86
87 // Mapping from GATT characteristic object paths to characteristic objects.
88 // owned by this service. Since the BlueZ implementation uses object
89 // paths as unique identifiers, we also use this mapping to return
90 // characteristics by identifier.
91 CharacteristicMap characteristics_;
92
93 DISALLOW_COPY_AND_ASSIGN(BluetoothGattServiceBlueZ);
94 };
95
96 } // namespace bluez
97
98 #endif // DEVICE_BLUETOOTH_BLUETOOTH_GATT_SERVICE_BLUEZ_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698