Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "device/bluetooth/bluetooth_adapter.h" | 19 #include "device/bluetooth/bluetooth_adapter.h" |
| 20 #include "device/bluetooth/bluetooth_adapter_factory.h" | 20 #include "device/bluetooth/bluetooth_adapter_factory.h" |
| 21 #include "device/bluetooth/bluetooth_device.h" | 21 #include "device/bluetooth/bluetooth_device.h" |
| 22 #include "device/bluetooth/bluetooth_discovery_session.h" | 22 #include "device/bluetooth/bluetooth_discovery_session.h" |
| 23 #include "device/bluetooth/bluetooth_local_gatt_characteristic.h" | |
|
rkc
2016/07/01 21:28:27
Forward declare the class and keep the header incl
puthik_chromium
2016/07/14 19:01:32
Done.
| |
| 24 #include "device/bluetooth/bluetooth_local_gatt_descriptor.h" | |
| 25 #include "device/bluetooth/bluetooth_local_gatt_service.h" | |
| 23 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h" | 26 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h" |
| 24 #include "device/bluetooth/bluetooth_remote_gatt_descriptor.h" | 27 #include "device/bluetooth/bluetooth_remote_gatt_descriptor.h" |
| 25 #include "device/bluetooth/bluetooth_remote_gatt_service.h" | 28 #include "device/bluetooth/bluetooth_remote_gatt_service.h" |
| 26 #include "device/bluetooth/bluez/bluetooth_adapter_bluez.h" | 29 #include "device/bluetooth/bluez/bluetooth_adapter_bluez.h" |
| 27 #include "mojo/public/cpp/bindings/binding.h" | 30 #include "mojo/public/cpp/bindings/binding.h" |
| 28 | 31 |
| 29 namespace arc { | 32 namespace arc { |
| 30 | 33 |
| 31 class ArcBridgeService; | 34 class ArcBridgeService; |
| 32 | 35 |
| 33 class ArcBluetoothBridge | 36 class ArcBluetoothBridge |
| 34 : public ArcService, | 37 : public ArcService, |
| 35 public ArcBridgeService::Observer, | 38 public ArcBridgeService::Observer, |
| 36 public device::BluetoothAdapter::Observer, | 39 public device::BluetoothAdapter::Observer, |
| 37 public device::BluetoothAdapterFactory::AdapterCallback, | 40 public device::BluetoothAdapterFactory::AdapterCallback, |
| 41 public device::BluetoothLocalGattService::Delegate, | |
| 38 public mojom::BluetoothHost { | 42 public mojom::BluetoothHost { |
| 39 public: | 43 public: |
| 40 explicit ArcBluetoothBridge(ArcBridgeService* bridge_service); | 44 explicit ArcBluetoothBridge(ArcBridgeService* bridge_service); |
| 41 ~ArcBluetoothBridge() override; | 45 ~ArcBluetoothBridge() override; |
| 42 | 46 |
| 43 // Overridden from ArcBridgeService::Observer: | 47 // Overridden from ArcBridgeService::Observer: |
| 44 void OnBluetoothInstanceReady() override; | 48 void OnBluetoothInstanceReady() override; |
| 45 | 49 |
| 46 void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter); | 50 void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter); |
| 47 | 51 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 void GattCharacteristicValueChanged( | 110 void GattCharacteristicValueChanged( |
| 107 device::BluetoothAdapter* adapter, | 111 device::BluetoothAdapter* adapter, |
| 108 device::BluetoothRemoteGattCharacteristic* characteristic, | 112 device::BluetoothRemoteGattCharacteristic* characteristic, |
| 109 const std::vector<uint8_t>& value) override; | 113 const std::vector<uint8_t>& value) override; |
| 110 | 114 |
| 111 void GattDescriptorValueChanged( | 115 void GattDescriptorValueChanged( |
| 112 device::BluetoothAdapter* adapter, | 116 device::BluetoothAdapter* adapter, |
| 113 device::BluetoothRemoteGattDescriptor* descriptor, | 117 device::BluetoothRemoteGattDescriptor* descriptor, |
| 114 const std::vector<uint8_t>& value) override; | 118 const std::vector<uint8_t>& value) override; |
| 115 | 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 | |
| 116 // Bluetooth Mojo host interface | 159 // Bluetooth Mojo host interface |
| 117 void EnableAdapter(const EnableAdapterCallback& callback) override; | 160 void EnableAdapter(const EnableAdapterCallback& callback) override; |
| 118 void DisableAdapter(const DisableAdapterCallback& callback) override; | 161 void DisableAdapter(const DisableAdapterCallback& callback) override; |
| 119 | 162 |
| 120 void GetAdapterProperty(mojom::BluetoothPropertyType type) override; | 163 void GetAdapterProperty(mojom::BluetoothPropertyType type) override; |
| 121 void SetAdapterProperty(mojom::BluetoothPropertyPtr property) override; | 164 void SetAdapterProperty(mojom::BluetoothPropertyPtr property) override; |
| 122 | 165 |
| 123 void GetRemoteDeviceProperty(mojom::BluetoothAddressPtr remote_addr, | 166 void GetRemoteDeviceProperty(mojom::BluetoothAddressPtr remote_addr, |
| 124 mojom::BluetoothPropertyType type) override; | 167 mojom::BluetoothPropertyType type) override; |
| 125 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 Loading... | |
| 183 mojom::BluetoothGattIDPtr char_id, | 226 mojom::BluetoothGattIDPtr char_id, |
| 184 const RegisterForGattNotificationCallback& callback) override; | 227 const RegisterForGattNotificationCallback& callback) override; |
| 185 void DeregisterForGattNotification( | 228 void DeregisterForGattNotification( |
| 186 mojom::BluetoothAddressPtr remote_addr, | 229 mojom::BluetoothAddressPtr remote_addr, |
| 187 mojom::BluetoothGattServiceIDPtr service_id, | 230 mojom::BluetoothGattServiceIDPtr service_id, |
| 188 mojom::BluetoothGattIDPtr char_id, | 231 mojom::BluetoothGattIDPtr char_id, |
| 189 const DeregisterForGattNotificationCallback& callback) override; | 232 const DeregisterForGattNotificationCallback& callback) override; |
| 190 void ReadRemoteRssi(mojom::BluetoothAddressPtr remote_addr, | 233 void ReadRemoteRssi(mojom::BluetoothAddressPtr remote_addr, |
| 191 const ReadRemoteRssiCallback& callback) override; | 234 const ReadRemoteRssiCallback& callback) override; |
| 192 | 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 device::BluetoothTransport device_type, | |
|
rkc
2016/07/01 21:28:27
The transport doesn't make sense for starting a se
puthik_chromium
2016/07/14 19:01:31
I agree that it does not make sense. Removed.
| |
| 258 const StartServiceCallback& callback) override; | |
| 259 // Stops a local service | |
| 260 void StopService(int32_t service_handle, | |
| 261 const StopServiceCallback& callback) override; | |
| 262 // Delete a local service | |
| 263 void DeleteService(int32_t service_handle, | |
| 264 const DeleteServiceCallback& callback) override; | |
| 265 // Send value indication to a remote device | |
| 266 void SendIndication(int32_t attribute_handle, | |
| 267 mojom::BluetoothAddressPtr address, | |
| 268 bool confirm, | |
| 269 mojo::Array<uint8_t> value, | |
| 270 const SendIndicationCallback& callback) override; | |
| 271 // Send a response to a read/write operation | |
| 272 void SendResponse(int32_t trans_id, | |
| 273 int32_t status, | |
| 274 mojo::Array<uint8_t> value, | |
| 275 const SendResponseCallback& callback) override; | |
| 276 | |
| 193 // Chrome observer callbacks | 277 // Chrome observer callbacks |
| 194 void OnPoweredOn( | 278 void OnPoweredOn( |
| 195 const base::Callback<void(mojom::BluetoothAdapterState)>& callback) const; | 279 const base::Callback<void(mojom::BluetoothAdapterState)>& callback) const; |
| 196 void OnPoweredOff( | 280 void OnPoweredOff( |
| 197 const base::Callback<void(mojom::BluetoothAdapterState)>& callback) const; | 281 const base::Callback<void(mojom::BluetoothAdapterState)>& callback) const; |
| 198 void OnPoweredError( | 282 void OnPoweredError( |
| 199 const base::Callback<void(mojom::BluetoothAdapterState)>& callback) const; | 283 const base::Callback<void(mojom::BluetoothAdapterState)>& callback) const; |
| 200 void OnDiscoveryStarted( | 284 void OnDiscoveryStarted( |
| 201 std::unique_ptr<device::BluetoothDiscoverySession> session); | 285 std::unique_ptr<device::BluetoothDiscoverySession> session); |
| 202 void OnDiscoveryStopped(); | 286 void OnDiscoveryStopped(); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 293 | 377 |
| 294 // WeakPtrFactory to use for callbacks. | 378 // WeakPtrFactory to use for callbacks. |
| 295 base::WeakPtrFactory<ArcBluetoothBridge> weak_factory_; | 379 base::WeakPtrFactory<ArcBluetoothBridge> weak_factory_; |
| 296 | 380 |
| 297 DISALLOW_COPY_AND_ASSIGN(ArcBluetoothBridge); | 381 DISALLOW_COPY_AND_ASSIGN(ArcBluetoothBridge); |
| 298 }; | 382 }; |
| 299 | 383 |
| 300 } // namespace arc | 384 } // namespace arc |
| 301 | 385 |
| 302 #endif // COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ | 386 #endif // COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ |
| OLD | NEW |