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 79d45a52fe720c16e44da13dc17c9d242f7971b8..d1912fbcb0d56b693bb1af26c3dcc6ea5b8f0bd6 100644 |
| --- a/components/arc/bluetooth/arc_bluetooth_bridge.h |
| +++ b/components/arc/bluetooth/arc_bluetooth_bridge.h |
| @@ -40,6 +40,9 @@ class ArcBluetoothBridge |
| public device::BluetoothLocalGattService::Delegate, |
| public mojom::BluetoothHost { |
| public: |
| + using GattStatusCallback = base::Callback<void(mojom::BluetoothGattStatus)>; |
| + using GattReadCallback = base::Callback<void(mojom::BluetoothGattValuePtr)>; |
| + |
| explicit ArcBluetoothBridge(ArcBridgeService* bridge_service); |
| ~ArcBluetoothBridge() override; |
| @@ -192,10 +195,10 @@ class ArcBluetoothBridge |
| void SearchService(mojom::BluetoothAddressPtr remote_addr) override; |
| int ConvertGattIdentifierToId(const std::string identifier) const; |
| - template <class T> |
| + template <class RemoteGattAttribute> |
| mojom::BluetoothGattDBElementPtr CreateGattDBElement( |
| const mojom::BluetoothGattDBAttributeType type, |
| - const T* GattObject) const; |
| + const RemoteGattAttribute* gatt_attr) const; |
| void GetGattDB(mojom::BluetoothAddressPtr remote_addr) override; |
| void ReadGattCharacteristic( |
| mojom::BluetoothAddressPtr remote_addr, |
| @@ -313,28 +316,21 @@ class ArcBluetoothBridge |
| const StopLEListenCallback& callback, |
| device::BluetoothAdvertisement::ErrorCode error_code); |
| - using GattReadCallback = base::Callback<void(mojom::BluetoothGattValuePtr)>; |
| + void OnGattOperationDone(const GattStatusCallback& callback) const; |
| + void OnGattOperationError( |
| + const GattStatusCallback& callback, |
| + device::BluetoothGattService::GattErrorCode error_code) const; |
| + |
| void OnGattReadDone(const GattReadCallback& callback, |
| const std::vector<uint8_t>& result) const; |
| void OnGattReadError( |
| const GattReadCallback& callback, |
| device::BluetoothGattService::GattErrorCode error_code) const; |
| - using GattWriteCallback = base::Callback<void(mojom::BluetoothGattStatus)>; |
| - void OnGattWriteDone(const GattWriteCallback& callback) const; |
| - void OnGattWriteError( |
| - const GattWriteCallback& callback, |
| - device::BluetoothGattService::GattErrorCode error_code) const; |
| - |
| void OnGattNotifyStartDone( |
| const RegisterForGattNotificationCallback& callback, |
| const std::string char_string_id, |
| std::unique_ptr<device::BluetoothGattNotifySession> notify_session); |
| - void OnGattNotifyStartError( |
| - const RegisterForGattNotificationCallback& callback, |
| - device::BluetoothGattService::GattErrorCode error_code) const; |
| - void OnGattNotifyStopDone( |
| - const DeregisterForGattNotificationCallback& callback) const; |
| private: |
| mojo::Array<mojom::BluetoothPropertyPtr> GetDeviceProperties( |
| @@ -349,9 +345,10 @@ class ArcBluetoothBridge |
| bool HasBluetoothInstance() const; |
| bool CheckBluetoothInstanceVersion(uint32_t version_need) const; |
| - template <class T> |
| - T* FindGattObjectFromUuid(const std::vector<T*> objs, |
| - const device::BluetoothUUID uuid) const; |
| + template <class RemoteGattAttribute> |
| + RemoteGattAttribute* FindGattAttributeFromUuid( |
| + const std::vector<RemoteGattAttribute*> gatt_attrs, |
| + const device::BluetoothUUID uuid) const; |
| device::BluetoothRemoteGattCharacteristic* FindGattCharacteristic( |
| mojom::BluetoothAddressPtr remote_addr, |
| mojom::BluetoothGattServiceIDPtr service_id, |
| @@ -366,6 +363,9 @@ class ArcBluetoothBridge |
| // Propagates the list of paired device to Android. |
| void SendCachedPairedDevices() const; |
| + template <class LocalGattAttribute> |
| + int32_t CreateGattAttributeHandle(LocalGattAttribute* gatt_attr); |
| + |
| mojo::Binding<mojom::BluetoothHost> binding_; |
| scoped_refptr<bluez::BluetoothAdapterBlueZ> bluetooth_adapter_; |
| @@ -373,6 +373,12 @@ class ArcBluetoothBridge |
| std::unique_ptr<device::BluetoothDiscoverySession> discovery_session_; |
| std::map<std::string, std::unique_ptr<device::BluetoothGattNotifySession>> |
| notification_session_; |
| + // Map from android int handle to Chrome (BlueZ) string identifier. |
| + std::map<int32_t, std::string> gatt_identifier_; |
|
Luis Héctor Chávez
2016/07/19 01:42:18
can these be std::unordered_map?
puthik_chromium
2016/07/19 22:21:30
Done.
|
| + // Store last GattCharacteristic added to each GattService for GattServer. |
| + std::map<int32_t, int32_t> last_characteristic_; |
| + // Running number for handle to give to Android side. |
|
Luis Héctor Chávez
2016/07/19 01:42:18
How about "Monotonically increasing value to use a
puthik_chromium
2016/07/19 22:21:30
Done.
|
| + int32_t gatt_server_attr_handle = 0; |
|
Luis Héctor Chávez
2016/07/19 01:42:18
gatt_server_attribute_next_handle_?
puthik_chromium
2016/07/19 22:21:30
Done.
|
| // WeakPtrFactory to use for callbacks. |
| base::WeakPtrFactory<ArcBluetoothBridge> weak_factory_; |