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

Side by Side Diff: device/bluetooth/bluetooth_remote_gatt_service_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
(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_REMOTE_GATT_SERVICE_BLUEZ_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_BLUEZ_H_
7
8 #include <stdint.h>
9 #include <string>
10 #include <vector>
11
12 #include "base/callback_forward.h"
13 #include "base/macros.h"
14 #include "base/memory/weak_ptr.h"
15 #include "dbus/object_path.h"
16 #include "device/bluetooth/bluetooth_gatt_service_bluez.h"
17 #include "device/bluetooth/bluetooth_uuid.h"
18 #include "device/bluetooth/dbus/bluetooth_gatt_characteristic_client.h"
19 #include "device/bluetooth/dbus/bluetooth_gatt_service_client.h"
20
21 namespace device {
22
23 class BluetoothAdapter;
24 class BluetoothDevice;
25 class BluetoothGattCharacteristic;
26
27 } // namespace device
28
29 namespace bluez {
30
31 class BluetoothAdapterBlueZ;
32 class BluetoothDeviceBlueZ;
33 class BluetoothRemoteGattCharacteristicBlueZ;
34 class BluetoothGattDescriptorBlueZ;
35
36 // The BluetoothRemoteGattServiceBlueZ class implements BluetootGattService
37 // for remote GATT services for platforms that use BlueZ.
38 class BluetoothRemoteGattServiceBlueZ
39 : public BluetoothGattServiceBlueZ,
40 public BluetoothGattServiceClient::Observer,
41 public BluetoothGattCharacteristicClient::Observer {
42 public:
43 // device::BluetoothGattService overrides.
44 device::BluetoothUUID GetUUID() const override;
45 bool IsLocal() const override;
46 bool IsPrimary() const override;
47 device::BluetoothDevice* GetDevice() const override;
48 bool AddCharacteristic(
49 device::BluetoothGattCharacteristic* characteristic) override;
50 bool AddIncludedService(device::BluetoothGattService* service) override;
51 void Register(const base::Closure& callback,
52 const ErrorCallback& error_callback) override;
53 void Unregister(const base::Closure& callback,
54 const ErrorCallback& error_callback) override;
55
56 // Notifies its observers that the GATT service has changed. This is mainly
57 // used by BluetoothRemoteGattCharacteristicBlueZ instances to notify
58 // service observers when characteristic descriptors get added and removed.
59 void NotifyServiceChanged();
60
61 // Notifies its observers that a descriptor |descriptor| belonging to
62 // characteristic |characteristic| has been added or removed. This is used
63 // by BluetoothRemoteGattCharacteristicBlueZ instances to notify service
64 // observers when characteristic descriptors get added and removed. If |added|
65 // is true, an "Added" event will be sent. Otherwise, a "Removed" event will
66 // be sent.
67 void NotifyDescriptorAddedOrRemoved(
68 BluetoothRemoteGattCharacteristicBlueZ* characteristic,
69 BluetoothGattDescriptorBlueZ* descriptor,
70 bool added);
71
72 // Notifies its observers that the value of a descriptor has changed. Called
73 // by BluetoothRemoteGattCharacteristicBlueZ instances to notify service
74 // observers.
75 void NotifyDescriptorValueChanged(
76 BluetoothRemoteGattCharacteristicBlueZ* characteristic,
77 BluetoothGattDescriptorBlueZ* descriptor,
78 const std::vector<uint8_t>& value);
79
80 private:
81 friend class BluetoothDeviceBlueZ;
82
83 BluetoothRemoteGattServiceBlueZ(BluetoothAdapterBlueZ* adapter,
84 BluetoothDeviceBlueZ* device,
85 const dbus::ObjectPath& object_path);
86 ~BluetoothRemoteGattServiceBlueZ() override;
87
88 // bluez::BluetoothGattServiceClient::Observer override.
89 void GattServicePropertyChanged(const dbus::ObjectPath& object_path,
90 const std::string& property_name) override;
91
92 // bluez::BluetoothGattCharacteristicClient::Observer override.
93 void GattCharacteristicAdded(const dbus::ObjectPath& object_path) override;
94 void GattCharacteristicRemoved(const dbus::ObjectPath& object_path) override;
95 void GattCharacteristicPropertyChanged(
96 const dbus::ObjectPath& object_path,
97 const std::string& property_name) override;
98
99 // The device this GATT service belongs to. It's ok to store a raw pointer
100 // here since |device_| owns this instance.
101 BluetoothDeviceBlueZ* device_;
102
103 // Indicates whether or not the characteristics of this service are known to
104 // have been discovered.
105 bool discovery_complete_;
106
107 // Note: This should remain the last member so it'll be destroyed and
108 // invalidate its weak pointers before any other members are destroyed.
109 base::WeakPtrFactory<BluetoothRemoteGattServiceBlueZ> weak_ptr_factory_;
110
111 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattServiceBlueZ);
112 };
113
114 } // namespace bluez
115
116 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_BLUEZ_H_
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_remote_gatt_service_android.cc ('k') | device/bluetooth/bluetooth_remote_gatt_service_bluez.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698