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

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

Issue 1415573014: Reland "Add Linux support for the Bluetooth API" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: build fix. Created 5 years, 1 month 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 2014 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_REMOTE_GATT_CHARACTERISTIC_CHROMEOS_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_BLUEZ_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_CHROMEOS_H_ 6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_BLUEZ_H_
7 7
8 #include <map> 8 #include <map>
9 #include <queue> 9 #include <queue>
10 #include <string> 10 #include <string>
11 #include <utility> 11 #include <utility>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/macros.h"
14 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
15 #include "dbus/object_path.h" 16 #include "dbus/object_path.h"
16 #include "device/bluetooth/bluetooth_gatt_characteristic.h" 17 #include "device/bluetooth/bluetooth_gatt_characteristic.h"
17 #include "device/bluetooth/bluetooth_uuid.h" 18 #include "device/bluetooth/bluetooth_uuid.h"
18 #include "device/bluetooth/dbus/bluetooth_gatt_descriptor_client.h" 19 #include "device/bluetooth/dbus/bluetooth_gatt_descriptor_client.h"
19 20
20 namespace device { 21 namespace device {
21 22
22 class BluetoothGattDescriptor; 23 class BluetoothGattDescriptor;
23 class BluetoothGattService; 24 class BluetoothGattService;
24 25
25 } // namespace device 26 } // namespace device
26 27
27 namespace chromeos { 28 namespace bluez {
28 29
29 class BluetoothRemoteGattDescriptorChromeOS; 30 class BluetoothRemoteGattDescriptorBlueZ;
30 class BluetoothRemoteGattServiceChromeOS; 31 class BluetoothRemoteGattServiceBlueZ;
31 32
32 // The BluetoothRemoteGattCharacteristicChromeOS class implements 33 // The BluetoothRemoteGattCharacteristicBlueZ class implements
33 // BluetoothGattCharacteristic for remote GATT characteristics on the Chrome OS 34 // BluetoothGattCharacteristic for remote GATT characteristics on the Chrome OS
ortuno 2015/11/06 18:15:41 Leftover "Chrome OS" reference.
rkc 2015/11/25 00:48:16 Done.
34 // platform. 35 // platform.
35 class BluetoothRemoteGattCharacteristicChromeOS 36 class BluetoothRemoteGattCharacteristicBlueZ
36 : public device::BluetoothGattCharacteristic, 37 : public device::BluetoothGattCharacteristic,
37 public bluez::BluetoothGattDescriptorClient::Observer { 38 public bluez::BluetoothGattDescriptorClient::Observer {
38 public: 39 public:
39 // device::BluetoothGattCharacteristic overrides. 40 // device::BluetoothGattCharacteristic overrides.
40 std::string GetIdentifier() const override; 41 std::string GetIdentifier() const override;
41 device::BluetoothUUID GetUUID() const override; 42 device::BluetoothUUID GetUUID() const override;
42 bool IsLocal() const override; 43 bool IsLocal() const override;
43 const std::vector<uint8>& GetValue() const override; 44 const std::vector<uint8>& GetValue() const override;
44 device::BluetoothGattService* GetService() const override; 45 device::BluetoothGattService* GetService() const override;
45 Properties GetProperties() const override; 46 Properties GetProperties() const override;
(...skipping 15 matching lines...) Expand all
61 // Removes one value update session and invokes |callback| on completion. This 62 // Removes one value update session and invokes |callback| on completion. This
62 // decrements the session reference count by 1 and if the number reaches 0, 63 // decrements the session reference count by 1 and if the number reaches 0,
63 // makes a call to the subsystem to stop notifications from this 64 // makes a call to the subsystem to stop notifications from this
64 // characteristic. 65 // characteristic.
65 void RemoveNotifySession(const base::Closure& callback); 66 void RemoveNotifySession(const base::Closure& callback);
66 67
67 // Object path of the underlying D-Bus characteristic. 68 // Object path of the underlying D-Bus characteristic.
68 const dbus::ObjectPath& object_path() const { return object_path_; } 69 const dbus::ObjectPath& object_path() const { return object_path_; }
69 70
70 private: 71 private:
71 friend class BluetoothRemoteGattServiceChromeOS; 72 friend class BluetoothRemoteGattServiceBlueZ;
72 73
73 typedef std::pair<NotifySessionCallback, ErrorCallback> 74 typedef std::pair<NotifySessionCallback, ErrorCallback>
74 PendingStartNotifyCall; 75 PendingStartNotifyCall;
75 76
76 BluetoothRemoteGattCharacteristicChromeOS( 77 BluetoothRemoteGattCharacteristicBlueZ(
77 BluetoothRemoteGattServiceChromeOS* service, 78 BluetoothRemoteGattServiceBlueZ* service,
78 const dbus::ObjectPath& object_path); 79 const dbus::ObjectPath& object_path);
79 ~BluetoothRemoteGattCharacteristicChromeOS() override; 80 ~BluetoothRemoteGattCharacteristicBlueZ() override;
80 81
81 // bluez::BluetoothGattDescriptorClient::Observer overrides. 82 // bluez::BluetoothGattDescriptorClient::Observer overrides.
82 void GattDescriptorAdded(const dbus::ObjectPath& object_path) override; 83 void GattDescriptorAdded(const dbus::ObjectPath& object_path) override;
83 void GattDescriptorRemoved(const dbus::ObjectPath& object_path) override; 84 void GattDescriptorRemoved(const dbus::ObjectPath& object_path) override;
84 void GattDescriptorPropertyChanged(const dbus::ObjectPath& object_path, 85 void GattDescriptorPropertyChanged(const dbus::ObjectPath& object_path,
85 const std::string& property_name) override; 86 const std::string& property_name) override;
86 87
87 // Called by dbus:: on unsuccessful completion of a request to read or write 88 // Called by dbus:: on unsuccessful completion of a request to read or write
88 // the characteristic value. 89 // the characteristic value.
89 void OnError(const ErrorCallback& error_callback, 90 void OnError(const ErrorCallback& error_callback,
(...skipping 20 matching lines...) Expand all
110 const std::string& error_name, 111 const std::string& error_name,
111 const std::string& error_message); 112 const std::string& error_message);
112 113
113 // Calls StartNotifySession for each queued request. 114 // Calls StartNotifySession for each queued request.
114 void ProcessStartNotifyQueue(); 115 void ProcessStartNotifyQueue();
115 116
116 // Object path of the D-Bus characteristic object. 117 // Object path of the D-Bus characteristic object.
117 dbus::ObjectPath object_path_; 118 dbus::ObjectPath object_path_;
118 119
119 // The GATT service this GATT characteristic belongs to. 120 // The GATT service this GATT characteristic belongs to.
120 BluetoothRemoteGattServiceChromeOS* service_; 121 BluetoothRemoteGattServiceBlueZ* service_;
121 122
122 // The total number of currently active value update sessions. 123 // The total number of currently active value update sessions.
123 size_t num_notify_sessions_; 124 size_t num_notify_sessions_;
124 125
125 // Calls to StartNotifySession that are pending. This can happen during the 126 // Calls to StartNotifySession that are pending. This can happen during the
126 // first remote call to start notifications. 127 // first remote call to start notifications.
127 std::queue<PendingStartNotifyCall> pending_start_notify_calls_; 128 std::queue<PendingStartNotifyCall> pending_start_notify_calls_;
128 129
129 // True, if a Start or Stop notify call to bluetoothd is currently pending. 130 // True, if a Start or Stop notify call to bluetoothd is currently pending.
130 bool notify_call_pending_; 131 bool notify_call_pending_;
131 132
132 // Mapping from GATT descriptor object paths to descriptor objects owned by 133 // Mapping from GATT descriptor object paths to descriptor objects owned by
133 // this characteristic. Since the Chrome OS implementation uses object paths 134 // this characteristic. Since the Chrome OS implementation uses object paths
ortuno 2015/11/06 18:15:42 Leftover "Chrome OS" reference.
rkc 2015/11/25 00:48:16 Done.
134 // as unique identifiers, we also use this mapping to return descriptors by 135 // as unique identifiers, we also use this mapping to return descriptors by
135 // identifier. 136 // identifier.
136 typedef std::map<dbus::ObjectPath, BluetoothRemoteGattDescriptorChromeOS*> 137 typedef std::map<dbus::ObjectPath, BluetoothRemoteGattDescriptorBlueZ*>
137 DescriptorMap; 138 DescriptorMap;
138 DescriptorMap descriptors_; 139 DescriptorMap descriptors_;
139 140
140 // Note: This should remain the last member so it'll be destroyed and 141 // Note: This should remain the last member so it'll be destroyed and
141 // invalidate its weak pointers before any other members are destroyed. 142 // invalidate its weak pointers before any other members are destroyed.
142 base::WeakPtrFactory<BluetoothRemoteGattCharacteristicChromeOS> 143 base::WeakPtrFactory<BluetoothRemoteGattCharacteristicBlueZ>
143 weak_ptr_factory_; 144 weak_ptr_factory_;
144 145
145 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicChromeOS); 146 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicBlueZ);
146 }; 147 };
147 148
148 } // namespace chromeos 149 } // namespace bluez
149 150
150 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_CHROMEOS_H_ 151 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_BLUEZ_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698