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

Unified Diff: content/renderer/bluetooth/bluetooth_dispatcher.cc

Issue 1611443002: bluetooth: Update BluetoothGATTCharacteristic.value on writeValue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@useDataview
Patch Set: Created 4 years, 11 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: content/renderer/bluetooth/bluetooth_dispatcher.cc
diff --git a/content/renderer/bluetooth/bluetooth_dispatcher.cc b/content/renderer/bluetooth/bluetooth_dispatcher.cc
index ebc7cb2b80679bc9cefc1912270fc8511d1e8a3d..c9b6d5fce6b3626d897a5715d8f7cca918180280 100644
--- a/content/renderer/bluetooth/bluetooth_dispatcher.cc
+++ b/content/renderer/bluetooth/bluetooth_dispatcher.cc
@@ -67,6 +67,17 @@ struct BluetoothCharacteristicRequest {
scoped_ptr<blink::WebBluetoothGetCharacteristicCallbacks> callbacks;
};
+// Struct that holds a pending WriteValue request.
+struct BluetoothWriteValueRequest {
+ BluetoothWriteValueRequest(const blink::WebVector<uint8_t>& value,
+ blink::WebBluetoothWriteValueCallbacks* callbacks)
+ : value(value), callbacks(callbacks) {}
+ ~BluetoothWriteValueRequest() {}
+
+ const blink::WebVector<uint8_t> value;
+ scoped_ptr<blink::WebBluetoothWriteValueCallbacks> callbacks;
+};
+
// Struct that holds a pending Start/StopNotifications request.
struct BluetoothNotificationsRequest {
BluetoothNotificationsRequest(
@@ -273,8 +284,8 @@ void BluetoothDispatcher::writeValue(
const blink::WebString& characteristic_instance_id,
const blink::WebVector<uint8_t>& value,
blink::WebBluetoothWriteValueCallbacks* callbacks) {
- int request_id = pending_write_value_requests_.Add(callbacks);
-
+ int request_id = pending_write_value_requests_.Add(
+ new BluetoothWriteValueRequest(value, callbacks));
Send(new BluetoothHostMsg_WriteValue(
CurrentWorkerId(), request_id, frame_routing_id,
characteristic_instance_id.utf8(),
@@ -695,7 +706,9 @@ void BluetoothDispatcher::OnReadValueError(int thread_id,
void BluetoothDispatcher::OnWriteValueSuccess(int thread_id, int request_id) {
DCHECK(pending_write_value_requests_.Lookup(request_id)) << request_id;
- pending_write_value_requests_.Lookup(request_id)->onSuccess();
+ BluetoothWriteValueRequest* request =
+ pending_write_value_requests_.Lookup(request_id);
+ request->callbacks->onSuccess(request->value);
pending_write_value_requests_.Remove(request_id);
}
@@ -705,8 +718,9 @@ void BluetoothDispatcher::OnWriteValueError(int thread_id,
WebBluetoothError error) {
DCHECK(pending_write_value_requests_.Lookup(request_id)) << request_id;
- pending_write_value_requests_.Lookup(request_id)
- ->onError(WebBluetoothError(error));
+ BluetoothWriteValueRequest* request =
+ pending_write_value_requests_.Lookup(request_id);
+ request->callbacks->onError(WebBluetoothError(error));
pending_write_value_requests_.Remove(request_id);
}
« no previous file with comments | « content/renderer/bluetooth/bluetooth_dispatcher.h ('k') | third_party/WebKit/LayoutTests/bluetooth/writeValue.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698