| 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 <memory> | 10 #include <memory> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <unordered_map> | 12 #include <unordered_map> |
| 13 #include <unordered_set> |
| 13 #include <vector> | 14 #include <vector> |
| 14 | 15 |
| 15 #include "base/callback.h" | 16 #include "base/callback.h" |
| 16 #include "components/arc/arc_bridge_service.h" | 17 #include "components/arc/arc_bridge_service.h" |
| 17 #include "components/arc/arc_service.h" | 18 #include "components/arc/arc_service.h" |
| 18 #include "components/arc/common/bluetooth.mojom.h" | 19 #include "components/arc/common/bluetooth.mojom.h" |
| 19 #include "components/arc/instance_holder.h" | 20 #include "components/arc/instance_holder.h" |
| 20 #include "device/bluetooth/bluetooth_adapter.h" | 21 #include "device/bluetooth/bluetooth_adapter.h" |
| 21 #include "device/bluetooth/bluetooth_adapter_factory.h" | 22 #include "device/bluetooth/bluetooth_adapter_factory.h" |
| 22 #include "device/bluetooth/bluetooth_device.h" | 23 #include "device/bluetooth/bluetooth_device.h" |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 // Delete a local service. | 260 // Delete a local service. |
| 260 void DeleteService(int32_t service_handle, | 261 void DeleteService(int32_t service_handle, |
| 261 const DeleteServiceCallback& callback) override; | 262 const DeleteServiceCallback& callback) override; |
| 262 // Send value indication to a remote device. | 263 // Send value indication to a remote device. |
| 263 void SendIndication(int32_t attribute_handle, | 264 void SendIndication(int32_t attribute_handle, |
| 264 mojom::BluetoothAddressPtr address, | 265 mojom::BluetoothAddressPtr address, |
| 265 bool confirm, | 266 bool confirm, |
| 266 mojo::Array<uint8_t> value, | 267 mojo::Array<uint8_t> value, |
| 267 const SendIndicationCallback& callback) override; | 268 const SendIndicationCallback& callback) override; |
| 268 | 269 |
| 270 // Bluetooth Mojo host interface - Bluetooth SDP functions |
| 271 void GetSdpRecords(mojom::BluetoothAddressPtr remote_addr, |
| 272 mojom::BluetoothUUIDPtr target_uuid) override; |
| 273 void CreateSdpRecord(mojom::BluetoothSdpRecordPtr record_mojo, |
| 274 const CreateSdpRecordCallback& callback) override; |
| 275 void RemoveSdpRecord(uint32_t service_handle, |
| 276 const RemoveSdpRecordCallback& callback) override; |
| 277 |
| 269 // Chrome observer callbacks | 278 // Chrome observer callbacks |
| 270 void OnPoweredOn( | 279 void OnPoweredOn( |
| 271 const base::Callback<void(mojom::BluetoothAdapterState)>& callback) const; | 280 const base::Callback<void(mojom::BluetoothAdapterState)>& callback) const; |
| 272 void OnPoweredOff( | 281 void OnPoweredOff( |
| 273 const base::Callback<void(mojom::BluetoothAdapterState)>& callback) const; | 282 const base::Callback<void(mojom::BluetoothAdapterState)>& callback) const; |
| 274 void OnPoweredError( | 283 void OnPoweredError( |
| 275 const base::Callback<void(mojom::BluetoothAdapterState)>& callback) const; | 284 const base::Callback<void(mojom::BluetoothAdapterState)>& callback) const; |
| 276 void OnDiscoveryStarted( | 285 void OnDiscoveryStarted( |
| 277 std::unique_ptr<device::BluetoothDiscoverySession> session); | 286 std::unique_ptr<device::BluetoothDiscoverySession> session); |
| 278 void OnDiscoveryStopped(); | 287 void OnDiscoveryStopped(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 | 362 |
| 354 // Common code for OnCharacteristicWriteRequest and OnDescriptorWriteRequest | 363 // Common code for OnCharacteristicWriteRequest and OnDescriptorWriteRequest |
| 355 template <class LocalGattAttribute> | 364 template <class LocalGattAttribute> |
| 356 void OnGattAttributeWriteRequest(const device::BluetoothDevice* device, | 365 void OnGattAttributeWriteRequest(const device::BluetoothDevice* device, |
| 357 const LocalGattAttribute* attribute, | 366 const LocalGattAttribute* attribute, |
| 358 const std::vector<uint8_t>& value, | 367 const std::vector<uint8_t>& value, |
| 359 int offset, | 368 int offset, |
| 360 const base::Closure& success_callback, | 369 const base::Closure& success_callback, |
| 361 const ErrorCallback& error_callback); | 370 const ErrorCallback& error_callback); |
| 362 | 371 |
| 372 void OnGetServiceRecordsDone( |
| 373 mojom::BluetoothAddressPtr remote_addr, |
| 374 mojom::BluetoothUUIDPtr target_uuid, |
| 375 const std::vector<bluez::BluetoothServiceRecordBlueZ>& records_bluez); |
| 376 void OnGetServiceRecordsError( |
| 377 mojom::BluetoothAddressPtr remote_addr, |
| 378 mojom::BluetoothUUIDPtr target_uuid, |
| 379 bluez::BluetoothServiceRecordBlueZ::ErrorCode error_code); |
| 380 |
| 363 bool CalledOnValidThread(); | 381 bool CalledOnValidThread(); |
| 364 | 382 |
| 365 mojo::Binding<mojom::BluetoothHost> binding_; | 383 mojo::Binding<mojom::BluetoothHost> binding_; |
| 366 | 384 |
| 367 scoped_refptr<bluez::BluetoothAdapterBlueZ> bluetooth_adapter_; | 385 scoped_refptr<bluez::BluetoothAdapterBlueZ> bluetooth_adapter_; |
| 368 scoped_refptr<device::BluetoothAdvertisement> advertisment_; | 386 scoped_refptr<device::BluetoothAdvertisement> advertisment_; |
| 369 std::unique_ptr<device::BluetoothDiscoverySession> discovery_session_; | 387 std::unique_ptr<device::BluetoothDiscoverySession> discovery_session_; |
| 370 std::unordered_map<std::string, | 388 std::unordered_map<std::string, |
| 371 std::unique_ptr<device::BluetoothGattNotifySession>> | 389 std::unique_ptr<device::BluetoothGattNotifySession>> |
| 372 notification_session_; | 390 notification_session_; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 385 | 403 |
| 386 // WeakPtrFactory to use for callbacks. | 404 // WeakPtrFactory to use for callbacks. |
| 387 base::WeakPtrFactory<ArcBluetoothBridge> weak_factory_; | 405 base::WeakPtrFactory<ArcBluetoothBridge> weak_factory_; |
| 388 | 406 |
| 389 DISALLOW_COPY_AND_ASSIGN(ArcBluetoothBridge); | 407 DISALLOW_COPY_AND_ASSIGN(ArcBluetoothBridge); |
| 390 }; | 408 }; |
| 391 | 409 |
| 392 } // namespace arc | 410 } // namespace arc |
| 393 | 411 |
| 394 #endif // COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ | 412 #endif // COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ |
| OLD | NEW |