Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1165)

Unified Diff: components/arc/bluetooth/arc_bluetooth_bridge.h

Issue 2101283003: arc: bluetooth: Implement Gatt server request to read/write (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gs2
Patch Set: Fix bug / More descriptive type name for template Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 ef53c79655033861ae7bfa231789d28f274162e2..400d0fbc199d334ede8e168433f580be3075e2ba 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 SuccessCallbackT>
+ struct GattServerCallbacks {
+ GattServerCallbacks() = default;
+ GattServerCallbacks(const SuccessCallbackT& success_callback,
+ const ErrorCallback& error_callback)
+ : success_callback(success_callback), error_callback(error_callback) {}
+ SuccessCallbackT 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 LocalGattObjectT>
+ void OnGattAttributeReadRequest(const device::BluetoothDevice* device,
+ const LocalGattObjectT* gatt_obj,
+ int offset,
+ const GattServerReadCallbacks& callbacks);
+
+ template <class LocalGattObjectT>
+ void OnGattAttributeWriteRequest(
+ const device::BluetoothDevice* device,
+ const LocalGattObjectT* gatt_obj,
+ const std::vector<uint8_t>& value,
+ int offset,
+ const GattServerWriteCallbacks& callbacks) override;
+
void OnCharacteristicReadRequest(
const device::BluetoothDevice* device,
const device::BluetoothLocalGattCharacteristic* characteristic,
@@ -365,6 +392,8 @@ class ArcBluetoothBridge
template <class LocalGattObjectT>
int32_t CreateGattAttributeHandle(LocalGattObjectT* gatt_obj);
+ int32_t CreateGattReadTransaction(const GattServerReadCallbacks& callbacks);
+ int32_t CreateGattWriteTransaction(const GattServerWriteCallbacks& callbacks);
mojo::Binding<mojom::BluetoothHost> binding_;
@@ -375,10 +404,13 @@ class ArcBluetoothBridge
notification_session_;
// Map from android int handle to Chrome (BlueZ) string identifier.
std::map<int32_t, std::string> gatt_identifier_;
+ std::map<std::string, int32_t> gatt_handle_;
// 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.
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_;
« no previous file with comments | « no previous file | components/arc/bluetooth/arc_bluetooth_bridge.cc » ('j') | components/arc/bluetooth/arc_bluetooth_bridge.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698