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

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: Add GattServerCallbacks type to store the callbacks 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
« no previous file with comments | « no previous file | components/arc/bluetooth/arc_bluetooth_bridge.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_;
« no previous file with comments | « no previous file | components/arc/bluetooth/arc_bluetooth_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698