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

Side by Side Diff: components/arc/bluetooth/arc_bluetooth_bridge.h

Issue 2104023002: arc: bluetooth: Add Gatt server mojo API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 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 2016 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 COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ 5 #ifndef COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_
6 #define COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ 6 #define COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <memory> 11 #include <memory>
12 #include <string> 12 #include <string>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/callback.h" 15 #include "base/callback.h"
16 #include "components/arc/arc_bridge_service.h" 16 #include "components/arc/arc_bridge_service.h"
17 #include "components/arc/arc_service.h" 17 #include "components/arc/arc_service.h"
18 #include "components/arc/common/bluetooth.mojom.h" 18 #include "components/arc/common/bluetooth.mojom.h"
19 #include "components/arc/instance_holder.h" 19 #include "components/arc/instance_holder.h"
20 #include "device/bluetooth/bluetooth_adapter.h" 20 #include "device/bluetooth/bluetooth_adapter.h"
21 #include "device/bluetooth/bluetooth_adapter_factory.h" 21 #include "device/bluetooth/bluetooth_adapter_factory.h"
22 #include "device/bluetooth/bluetooth_device.h" 22 #include "device/bluetooth/bluetooth_device.h"
23 #include "device/bluetooth/bluetooth_discovery_session.h" 23 #include "device/bluetooth/bluetooth_discovery_session.h"
24 #include "device/bluetooth/bluetooth_local_gatt_service.h"
24 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h" 25 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h"
25 #include "device/bluetooth/bluetooth_remote_gatt_descriptor.h" 26 #include "device/bluetooth/bluetooth_remote_gatt_descriptor.h"
26 #include "device/bluetooth/bluetooth_remote_gatt_service.h" 27 #include "device/bluetooth/bluetooth_remote_gatt_service.h"
27 #include "device/bluetooth/bluez/bluetooth_adapter_bluez.h" 28 #include "device/bluetooth/bluez/bluetooth_adapter_bluez.h"
28 #include "mojo/public/cpp/bindings/binding.h" 29 #include "mojo/public/cpp/bindings/binding.h"
29 30
30 namespace arc { 31 namespace arc {
31 32
32 class ArcBridgeService; 33 class ArcBridgeService;
33 34
34 class ArcBluetoothBridge 35 class ArcBluetoothBridge
35 : public ArcService, 36 : public ArcService,
36 public InstanceHolder<mojom::BluetoothInstance>::Observer, 37 public InstanceHolder<mojom::BluetoothInstance>::Observer,
37 public device::BluetoothAdapter::Observer, 38 public device::BluetoothAdapter::Observer,
38 public device::BluetoothAdapterFactory::AdapterCallback, 39 public device::BluetoothAdapterFactory::AdapterCallback,
40 public device::BluetoothLocalGattService::Delegate,
39 public mojom::BluetoothHost { 41 public mojom::BluetoothHost {
40 public: 42 public:
41 explicit ArcBluetoothBridge(ArcBridgeService* bridge_service); 43 explicit ArcBluetoothBridge(ArcBridgeService* bridge_service);
42 ~ArcBluetoothBridge() override; 44 ~ArcBluetoothBridge() override;
43 45
44 // Overridden from 46 // Overridden from
45 // InstanceHolder<mojom::BluetoothInstance>::Observer: 47 // InstanceHolder<mojom::BluetoothInstance>::Observer:
46 void OnInstanceReady() override; 48 void OnInstanceReady() override;
47 49
48 void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter); 50 void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 void GattCharacteristicValueChanged( 110 void GattCharacteristicValueChanged(
109 device::BluetoothAdapter* adapter, 111 device::BluetoothAdapter* adapter,
110 device::BluetoothRemoteGattCharacteristic* characteristic, 112 device::BluetoothRemoteGattCharacteristic* characteristic,
111 const std::vector<uint8_t>& value) override; 113 const std::vector<uint8_t>& value) override;
112 114
113 void GattDescriptorValueChanged( 115 void GattDescriptorValueChanged(
114 device::BluetoothAdapter* adapter, 116 device::BluetoothAdapter* adapter,
115 device::BluetoothRemoteGattDescriptor* descriptor, 117 device::BluetoothRemoteGattDescriptor* descriptor,
116 const std::vector<uint8_t>& value) override; 118 const std::vector<uint8_t>& value) override;
117 119
120 // Overridden from device::BluetoothLocalGattService::Delegate
121 void OnCharacteristicReadRequest(
122 const device::BluetoothDevice* device,
123 const device::BluetoothLocalGattCharacteristic* characteristic,
124 int offset,
125 const ValueCallback& callback,
126 const ErrorCallback& error_callback) override;
127
128 void OnCharacteristicWriteRequest(
129 const device::BluetoothDevice* device,
130 const device::BluetoothLocalGattCharacteristic* characteristic,
131 const std::vector<uint8_t>& value,
132 int offset,
133 const base::Closure& callback,
134 const ErrorCallback& error_callback) override;
135
136 void OnDescriptorReadRequest(
137 const device::BluetoothDevice* device,
138 const device::BluetoothLocalGattDescriptor* descriptor,
139 int offset,
140 const ValueCallback& callback,
141 const ErrorCallback& error_callback) override;
142
143 void OnDescriptorWriteRequest(
144 const device::BluetoothDevice* device,
145 const device::BluetoothLocalGattDescriptor* descriptor,
146 const std::vector<uint8_t>& value,
147 int offset,
148 const base::Closure& callback,
149 const ErrorCallback& error_callback) override;
150
151 void OnNotificationsStart(
152 const device::BluetoothDevice* device,
153 const device::BluetoothLocalGattCharacteristic* characteristic) override;
154
155 void OnNotificationsStop(
156 const device::BluetoothDevice* device,
157 const device::BluetoothLocalGattCharacteristic* characteristic) override;
158
118 // Bluetooth Mojo host interface 159 // Bluetooth Mojo host interface
119 void EnableAdapter(const EnableAdapterCallback& callback) override; 160 void EnableAdapter(const EnableAdapterCallback& callback) override;
120 void DisableAdapter(const DisableAdapterCallback& callback) override; 161 void DisableAdapter(const DisableAdapterCallback& callback) override;
121 162
122 void GetAdapterProperty(mojom::BluetoothPropertyType type) override; 163 void GetAdapterProperty(mojom::BluetoothPropertyType type) override;
123 void SetAdapterProperty(mojom::BluetoothPropertyPtr property) override; 164 void SetAdapterProperty(mojom::BluetoothPropertyPtr property) override;
124 165
125 void GetRemoteDeviceProperty(mojom::BluetoothAddressPtr remote_addr, 166 void GetRemoteDeviceProperty(mojom::BluetoothAddressPtr remote_addr,
126 mojom::BluetoothPropertyType type) override; 167 mojom::BluetoothPropertyType type) override;
127 void SetRemoteDeviceProperty(mojom::BluetoothAddressPtr remote_addr, 168 void SetRemoteDeviceProperty(mojom::BluetoothAddressPtr remote_addr,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 mojom::BluetoothGattIDPtr char_id, 226 mojom::BluetoothGattIDPtr char_id,
186 const RegisterForGattNotificationCallback& callback) override; 227 const RegisterForGattNotificationCallback& callback) override;
187 void DeregisterForGattNotification( 228 void DeregisterForGattNotification(
188 mojom::BluetoothAddressPtr remote_addr, 229 mojom::BluetoothAddressPtr remote_addr,
189 mojom::BluetoothGattServiceIDPtr service_id, 230 mojom::BluetoothGattServiceIDPtr service_id,
190 mojom::BluetoothGattIDPtr char_id, 231 mojom::BluetoothGattIDPtr char_id,
191 const DeregisterForGattNotificationCallback& callback) override; 232 const DeregisterForGattNotificationCallback& callback) override;
192 void ReadRemoteRssi(mojom::BluetoothAddressPtr remote_addr, 233 void ReadRemoteRssi(mojom::BluetoothAddressPtr remote_addr,
193 const ReadRemoteRssiCallback& callback) override; 234 const ReadRemoteRssiCallback& callback) override;
194 235
236 // Bluetooth Mojo host interface - Bluetooth Gatt Server functions
237 // Create a new service. Chrome will create an integer service handle based on
238 // that BlueZ identifier that will pass back to Android in the callback.
239 // num_handles: number of handle for characteristic / descriptor that will be
240 // created in this service
241 void AddService(mojom::BluetoothGattServiceIDPtr service_id,
242 int32_t num_handles,
243 const AddServiceCallback& callback) override;
244 // Add a characteristic to a service and pass the characteristic handle back.
245 void AddCharacteristic(int32_t service_handle,
246 mojom::BluetoothUUIDPtr uuid,
247 int32_t properties,
248 int32_t permissions,
249 const AddCharacteristicCallback& callback) override;
250 // Add a descriptor to a given service and pass the descriptor handle back.
251 void AddDescriptor(int32_t service_handle,
252 mojom::BluetoothUUIDPtr uuid,
253 int32_t permissions,
254 const AddDescriptorCallback& callback) override;
255 // Starts a local service
256 void StartService(int32_t service_handle,
257 const StartServiceCallback& callback) override;
258 // Stops a local service
259 void StopService(int32_t service_handle,
260 const StopServiceCallback& callback) override;
261 // Delete a local service
262 void DeleteService(int32_t service_handle,
263 const DeleteServiceCallback& callback) override;
264 // Send value indication to a remote device
265 void SendIndication(int32_t attribute_handle,
266 mojom::BluetoothAddressPtr address,
267 bool confirm,
268 mojo::Array<uint8_t> value,
269 const SendIndicationCallback& callback) override;
270 // Send a response to a read/write operation
palmer 2016/07/16 00:21:04 It's much better for comments to be complete, punc
puthik_chromium 2016/07/18 21:27:39 The comment is copy from Android code. https://sou
Luis Héctor Chávez 2016/07/19 01:26:02 You can still improve the comments. Also, it would
puthik_chromium 2016/07/19 22:21:22 Link added
271 void SendResponse(int32_t trans_id,
272 int32_t status,
273 mojo::Array<uint8_t> value,
274 const SendResponseCallback& callback) override;
275
195 // Chrome observer callbacks 276 // Chrome observer callbacks
196 void OnPoweredOn( 277 void OnPoweredOn(
197 const base::Callback<void(mojom::BluetoothAdapterState)>& callback) const; 278 const base::Callback<void(mojom::BluetoothAdapterState)>& callback) const;
198 void OnPoweredOff( 279 void OnPoweredOff(
199 const base::Callback<void(mojom::BluetoothAdapterState)>& callback) const; 280 const base::Callback<void(mojom::BluetoothAdapterState)>& callback) const;
200 void OnPoweredError( 281 void OnPoweredError(
201 const base::Callback<void(mojom::BluetoothAdapterState)>& callback) const; 282 const base::Callback<void(mojom::BluetoothAdapterState)>& callback) const;
202 void OnDiscoveryStarted( 283 void OnDiscoveryStarted(
203 std::unique_ptr<device::BluetoothDiscoverySession> session); 284 std::unique_ptr<device::BluetoothDiscoverySession> session);
204 void OnDiscoveryStopped(); 285 void OnDiscoveryStopped();
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 376
296 // WeakPtrFactory to use for callbacks. 377 // WeakPtrFactory to use for callbacks.
297 base::WeakPtrFactory<ArcBluetoothBridge> weak_factory_; 378 base::WeakPtrFactory<ArcBluetoothBridge> weak_factory_;
298 379
299 DISALLOW_COPY_AND_ASSIGN(ArcBluetoothBridge); 380 DISALLOW_COPY_AND_ASSIGN(ArcBluetoothBridge);
300 }; 381 };
301 382
302 } // namespace arc 383 } // namespace arc
303 384
304 #endif // COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ 385 #endif // COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_
OLDNEW
« no previous file with comments | « no previous file | components/arc/bluetooth/arc_bluetooth_bridge.cc » ('j') | components/arc/bluetooth/arc_bluetooth_bridge.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698