Chromium Code Reviews| Index: components/arc/bluetooth/arc_bluetooth_bridge.h |
| diff --git a/components/arc/bluetooth/arc_bluetooth_bridge.h b/components/arc/bluetooth/arc_bluetooth_bridge.h |
| index e0092d15faa6d9dbe06f7b3eed17982e524ff230..cacd9684c45ff71fde026fefd41af01aeda4b9f9 100644 |
| --- a/components/arc/bluetooth/arc_bluetooth_bridge.h |
| +++ b/components/arc/bluetooth/arc_bluetooth_bridge.h |
| @@ -40,8 +40,21 @@ class ArcBluetoothBridge |
| public device::BluetoothLocalGattService::Delegate, |
| public mojom::BluetoothHost { |
| public: |
| + // Store callback functions for Gatt Server request read / write |
| + template <class T> |
|
rkc
2016/07/14 23:28:12
Use more descriptive template arguments. Here and
puthik_chromium
2016/07/15 21:49:59
Done.
|
| + struct GattServerCallbacks { |
| + GattServerCallbacks() = default; |
| + GattServerCallbacks(const T& success_callback, |
| + const ErrorCallback& error_callback) |
| + : success_callback(success_callback), error_callback(error_callback) {} |
| + T success_callback; |
| + ErrorCallback error_callback; |
| + }; |
| + |
| using GattStatusCallback = base::Callback<void(mojom::BluetoothGattStatus)>; |
| using GattReadCallback = base::Callback<void(mojom::BluetoothGattValuePtr)>; |
| + using GattServerReadCallbacks = GattServerCallbacks<ValueCallback>; |
| + using GattServerWriteCallbacks = GattServerCallbacks<base::Closure>; |
| explicit ArcBluetoothBridge(ArcBridgeService* bridge_service); |
| ~ArcBluetoothBridge() override; |
| @@ -121,6 +134,20 @@ class ArcBluetoothBridge |
| const std::vector<uint8_t>& value) override; |
| // Overridden from device::BluetoothLocalGattService::Delegate |
| + template <class T> |
| + void OnGattAttributeReadRequest(const device::BluetoothDevice* device, |
| + const T* gatt_obj, |
| + int offset, |
| + const GattServerReadCallbacks& callbacks); |
| + |
| + template <class T> |
| + void OnGattAttributeWriteRequest( |
| + const device::BluetoothDevice* device, |
| + const T* gatt_obj, |
| + const std::vector<uint8_t>& value, |
| + int offset, |
| + const GattServerWriteCallbacks& callbacks) override; |
| + |
| void OnCharacteristicReadRequest( |
| const device::BluetoothDevice* device, |
| const device::BluetoothLocalGattCharacteristic* characteristic, |
| @@ -364,6 +391,8 @@ class ArcBluetoothBridge |
| template <class T> |
| int32_t CreateGattAttributeHandle(T* gatt_obj); |
| + int32_t CreateGattReadTransaction(const GattServerReadCallbacks& callbacks); |
| + int32_t CreateGattWriteTransaction(const GattServerWriteCallbacks& callbacks); |
| mojo::Binding<mojom::BluetoothHost> binding_; |
| @@ -378,6 +407,8 @@ class ArcBluetoothBridge |
| std::map<int32_t, int32_t> last_characteristic_; |
| // Running number for handle to give to Android side. |
| int32_t gatt_server_obj_handle = 0; |
| + std::map<int32_t, GattServerReadCallbacks> gatt_server_read_callbacks_; |
| + std::map<int32_t, GattServerWriteCallbacks> gatt_server_write_callbacks_; |
| // WeakPtrFactory to use for callbacks. |
| base::WeakPtrFactory<ArcBluetoothBridge> weak_factory_; |