| 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_remote_gatt_characteristic.h" | 23 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h" |
| 24 #include "device/bluetooth/bluetooth_remote_gatt_descriptor.h" | 24 #include "device/bluetooth/bluetooth_remote_gatt_descriptor.h" |
| 25 #include "device/bluetooth/bluetooth_remote_gatt_service.h" | 25 #include "device/bluetooth/bluetooth_remote_gatt_service.h" |
| 26 #include "device/bluetooth/bluez/bluetooth_adapter_bluez.h" | 26 #include "device/bluetooth/bluez/bluetooth_adapter_bluez.h" |
| 27 #include "device/bluetooth/bluez/bluetooth_service_record_bluez.h" |
| 27 #include "mojo/public/cpp/bindings/binding.h" | 28 #include "mojo/public/cpp/bindings/binding.h" |
| 28 | 29 |
| 29 namespace arc { | 30 namespace arc { |
| 30 | 31 |
| 31 class ArcBridgeService; | 32 class ArcBridgeService; |
| 32 | 33 |
| 33 class ArcBluetoothBridge | 34 class ArcBluetoothBridge |
| 34 : public ArcService, | 35 : public ArcService, |
| 35 public ArcBridgeService::Observer, | 36 public ArcBridgeService::Observer, |
| 36 public device::BluetoothAdapter::Observer, | 37 public device::BluetoothAdapter::Observer, |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 mojom::BluetoothGattIDPtr char_id, | 184 mojom::BluetoothGattIDPtr char_id, |
| 184 const RegisterForGattNotificationCallback& callback) override; | 185 const RegisterForGattNotificationCallback& callback) override; |
| 185 void DeregisterForGattNotification( | 186 void DeregisterForGattNotification( |
| 186 mojom::BluetoothAddressPtr remote_addr, | 187 mojom::BluetoothAddressPtr remote_addr, |
| 187 mojom::BluetoothGattServiceIDPtr service_id, | 188 mojom::BluetoothGattServiceIDPtr service_id, |
| 188 mojom::BluetoothGattIDPtr char_id, | 189 mojom::BluetoothGattIDPtr char_id, |
| 189 const DeregisterForGattNotificationCallback& callback) override; | 190 const DeregisterForGattNotificationCallback& callback) override; |
| 190 void ReadRemoteRssi(mojom::BluetoothAddressPtr remote_addr, | 191 void ReadRemoteRssi(mojom::BluetoothAddressPtr remote_addr, |
| 191 const ReadRemoteRssiCallback& callback) override; | 192 const ReadRemoteRssiCallback& callback) override; |
| 192 | 193 |
| 194 // Bluetooth Mojo host interface - Bluetooth SDP functions |
| 195 void GetSdpRecords(mojom::BluetoothAddressPtr remote_addr, |
| 196 const GetSdpRecordsCallback& callback) override; |
| 197 void CreateSdpRecord(mojom::BluetoothSdpRecordPtr record, |
| 198 const CreateSdpRecordCallback& callback) override; |
| 199 void RemoveSdpRecord(uint32_t service_handle, |
| 200 const RemoveSdpRecordCallback& callback) override; |
| 201 |
| 193 // Chrome observer callbacks | 202 // Chrome observer callbacks |
| 194 void OnPoweredOn( | 203 void OnPoweredOn( |
| 195 const base::Callback<void(mojom::BluetoothAdapterState)>& callback) const; | 204 const base::Callback<void(mojom::BluetoothAdapterState)>& callback) const; |
| 196 void OnPoweredOff( | 205 void OnPoweredOff( |
| 197 const base::Callback<void(mojom::BluetoothAdapterState)>& callback) const; | 206 const base::Callback<void(mojom::BluetoothAdapterState)>& callback) const; |
| 198 void OnPoweredError( | 207 void OnPoweredError( |
| 199 const base::Callback<void(mojom::BluetoothAdapterState)>& callback) const; | 208 const base::Callback<void(mojom::BluetoothAdapterState)>& callback) const; |
| 200 void OnDiscoveryStarted( | 209 void OnDiscoveryStarted( |
| 201 std::unique_ptr<device::BluetoothDiscoverySession> session); | 210 std::unique_ptr<device::BluetoothDiscoverySession> session); |
| 202 void OnDiscoveryStopped(); | 211 void OnDiscoveryStopped(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 void OnGattNotifyStartDone( | 255 void OnGattNotifyStartDone( |
| 247 const RegisterForGattNotificationCallback& callback, | 256 const RegisterForGattNotificationCallback& callback, |
| 248 const std::string char_string_id, | 257 const std::string char_string_id, |
| 249 std::unique_ptr<device::BluetoothGattNotifySession> notify_session); | 258 std::unique_ptr<device::BluetoothGattNotifySession> notify_session); |
| 250 void OnGattNotifyStartError( | 259 void OnGattNotifyStartError( |
| 251 const RegisterForGattNotificationCallback& callback, | 260 const RegisterForGattNotificationCallback& callback, |
| 252 device::BluetoothGattService::GattErrorCode error_code) const; | 261 device::BluetoothGattService::GattErrorCode error_code) const; |
| 253 void OnGattNotifyStopDone( | 262 void OnGattNotifyStopDone( |
| 254 const DeregisterForGattNotificationCallback& callback) const; | 263 const DeregisterForGattNotificationCallback& callback) const; |
| 255 | 264 |
| 265 void OnGetServiceRecordsDone( |
| 266 const GetSdpRecordsCallback& callback, |
| 267 const std::vector<bluez::BluetoothServiceRecordBlueZ>& records) const; |
| 268 void OnGetServiceRecordsError( |
| 269 const GetSdpRecordsCallback& callback, |
| 270 bluez::BluetoothServiceRecordBlueZ::ErrorCode error_code) const; |
| 271 void OnCreateSdpRecordDone(const CreateSdpRecordCallback& callback, |
| 272 uint32_t service_handle) const; |
| 273 void OnCreateSdpRecordError( |
| 274 const CreateSdpRecordCallback& callback, |
| 275 bluez::BluetoothServiceRecordBlueZ::ErrorCode error_code) const; |
| 276 void OnRemoveSdpRecordDone(const RemoveSdpRecordCallback& callback) const; |
| 277 void OnRemoveSdpRecordError( |
| 278 const RemoveSdpRecordCallback& callback, |
| 279 bluez::BluetoothServiceRecordBlueZ::ErrorCode error_code) const; |
| 280 |
| 256 private: | 281 private: |
| 257 mojo::Array<mojom::BluetoothPropertyPtr> GetDeviceProperties( | 282 mojo::Array<mojom::BluetoothPropertyPtr> GetDeviceProperties( |
| 258 mojom::BluetoothPropertyType type, | 283 mojom::BluetoothPropertyType type, |
| 259 device::BluetoothDevice* device) const; | 284 device::BluetoothDevice* device) const; |
| 260 mojo::Array<mojom::BluetoothPropertyPtr> GetAdapterProperties( | 285 mojo::Array<mojom::BluetoothPropertyPtr> GetAdapterProperties( |
| 261 mojom::BluetoothPropertyType type) const; | 286 mojom::BluetoothPropertyType type) const; |
| 262 mojo::Array<mojom::BluetoothAdvertisingDataPtr> GetAdvertisingData( | 287 mojo::Array<mojom::BluetoothAdvertisingDataPtr> GetAdvertisingData( |
| 263 device::BluetoothDevice* device) const; | 288 device::BluetoothDevice* device) const; |
| 264 | 289 |
| 265 void SendCachedDevicesFound() const; | 290 void SendCachedDevicesFound() const; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 293 | 318 |
| 294 // WeakPtrFactory to use for callbacks. | 319 // WeakPtrFactory to use for callbacks. |
| 295 base::WeakPtrFactory<ArcBluetoothBridge> weak_factory_; | 320 base::WeakPtrFactory<ArcBluetoothBridge> weak_factory_; |
| 296 | 321 |
| 297 DISALLOW_COPY_AND_ASSIGN(ArcBluetoothBridge); | 322 DISALLOW_COPY_AND_ASSIGN(ArcBluetoothBridge); |
| 298 }; | 323 }; |
| 299 | 324 |
| 300 } // namespace arc | 325 } // namespace arc |
| 301 | 326 |
| 302 #endif // COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ | 327 #endif // COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ |
| OLD | NEW |