Index: content/renderer/bluetooth/bluetooth_dispatcher.cc |
diff --git a/content/renderer/bluetooth/bluetooth_dispatcher.cc b/content/renderer/bluetooth/bluetooth_dispatcher.cc |
index 5f10eede5a56d60fac2e0693abca441ea7fbea5a..75ff89ef2497f9cb51032d798c197d7e6273f7b3 100644 |
--- a/content/renderer/bluetooth/bluetooth_dispatcher.cc |
+++ b/content/renderer/bluetooth/bluetooth_dispatcher.cc |
@@ -68,16 +68,19 @@ struct BluetoothCharacteristicRequest { |
// Struct that holds a pending Start/StopNotifications request. |
struct BluetoothNotificationsRequest { |
BluetoothNotificationsRequest( |
+ int frame_routing_id, |
const std::string characteristic_instance_id, |
blink::WebBluetoothGATTCharacteristic* characteristic, |
blink::WebBluetoothNotificationsCallbacks* callbacks, |
NotificationsRequestType type) |
- : characteristic_instance_id(characteristic_instance_id), |
+ : frame_routing_id(frame_routing_id), |
+ characteristic_instance_id(characteristic_instance_id), |
characteristic(characteristic), |
callbacks(callbacks), |
type(type) {} |
~BluetoothNotificationsRequest() {} |
+ const int frame_routing_id; |
const std::string characteristic_instance_id; |
// The characteristic object is owned by the execution context on |
// the blink side which can destroy the object at any point. Since the |
@@ -214,61 +217,70 @@ void BluetoothDispatcher::requestDevice( |
} |
void BluetoothDispatcher::connectGATT( |
+ int frame_routing_id, |
const blink::WebString& device_id, |
blink::WebBluetoothConnectGATTCallbacks* callbacks) { |
int request_id = pending_connect_requests_.Add(callbacks); |
Send(new BluetoothHostMsg_ConnectGATT(CurrentWorkerId(), request_id, |
- device_id.utf8())); |
+ frame_routing_id, device_id.utf8())); |
} |
void BluetoothDispatcher::getPrimaryService( |
+ int frame_routing_id, |
const blink::WebString& device_id, |
const blink::WebString& service_uuid, |
blink::WebBluetoothGetPrimaryServiceCallbacks* callbacks) { |
int request_id = pending_primary_service_requests_.Add( |
new BluetoothPrimaryServiceRequest(device_id, service_uuid, callbacks)); |
Send(new BluetoothHostMsg_GetPrimaryService( |
- CurrentWorkerId(), request_id, device_id.utf8(), service_uuid.utf8())); |
+ CurrentWorkerId(), request_id, frame_routing_id, device_id.utf8(), |
+ service_uuid.utf8())); |
} |
void BluetoothDispatcher::getCharacteristic( |
+ int frame_routing_id, |
const blink::WebString& service_instance_id, |
const blink::WebString& characteristic_uuid, |
blink::WebBluetoothGetCharacteristicCallbacks* callbacks) { |
int request_id = |
pending_characteristic_requests_.Add(new BluetoothCharacteristicRequest( |
service_instance_id, characteristic_uuid, callbacks)); |
- Send(new BluetoothHostMsg_GetCharacteristic(CurrentWorkerId(), request_id, |
- service_instance_id.utf8(), |
- characteristic_uuid.utf8())); |
+ Send(new BluetoothHostMsg_GetCharacteristic( |
+ CurrentWorkerId(), request_id, frame_routing_id, |
+ service_instance_id.utf8(), characteristic_uuid.utf8())); |
} |
void BluetoothDispatcher::readValue( |
+ int frame_routing_id, |
const blink::WebString& characteristic_instance_id, |
blink::WebBluetoothReadValueCallbacks* callbacks) { |
int request_id = pending_read_value_requests_.Add(callbacks); |
Send(new BluetoothHostMsg_ReadValue(CurrentWorkerId(), request_id, |
+ frame_routing_id, |
characteristic_instance_id.utf8())); |
} |
void BluetoothDispatcher::writeValue( |
+ int frame_routing_id, |
const blink::WebString& characteristic_instance_id, |
const blink::WebVector<uint8_t>& value, |
blink::WebBluetoothWriteValueCallbacks* callbacks) { |
int request_id = pending_write_value_requests_.Add(callbacks); |
Send(new BluetoothHostMsg_WriteValue( |
- CurrentWorkerId(), request_id, characteristic_instance_id.utf8(), |
+ CurrentWorkerId(), request_id, frame_routing_id, |
+ characteristic_instance_id.utf8(), |
std::vector<uint8_t>(value.begin(), value.end()))); |
} |
void BluetoothDispatcher::startNotifications( |
+ int frame_routing_id, |
const blink::WebString& characteristic_instance_id, |
blink::WebBluetoothGATTCharacteristic* characteristic, |
blink::WebBluetoothNotificationsCallbacks* callbacks) { |
- int request_id = QueueNotificationRequest(characteristic_instance_id.utf8(), |
- characteristic, callbacks, |
- NotificationsRequestType::START); |
+ int request_id = QueueNotificationRequest( |
+ frame_routing_id, characteristic_instance_id.utf8(), characteristic, |
+ callbacks, NotificationsRequestType::START); |
// The Notification subscription's state can change after a request |
// finishes. To avoid resolving with a soon-to-be-invalid state we queue |
// requests. |
@@ -281,12 +293,13 @@ void BluetoothDispatcher::startNotifications( |
} |
void BluetoothDispatcher::stopNotifications( |
+ int frame_routing_id, |
const blink::WebString& characteristic_instance_id, |
blink::WebBluetoothGATTCharacteristic* characteristic, |
blink::WebBluetoothNotificationsCallbacks* callbacks) { |
- int request_id = QueueNotificationRequest(characteristic_instance_id.utf8(), |
- characteristic, callbacks, |
- NotificationsRequestType::STOP); |
+ int request_id = QueueNotificationRequest( |
+ frame_routing_id, characteristic_instance_id.utf8(), characteristic, |
+ callbacks, NotificationsRequestType::STOP); |
if (HasNotificationRequestResponsePending( |
characteristic_instance_id.utf8())) { |
return; |
@@ -296,6 +309,7 @@ void BluetoothDispatcher::stopNotifications( |
} |
void BluetoothDispatcher::characteristicObjectRemoved( |
+ int frame_routing_id, |
const blink::WebString& characteristic_instance_id, |
blink::WebBluetoothGATTCharacteristic* characteristic) { |
// We need to remove references to the object from the following: |
@@ -307,7 +321,7 @@ void BluetoothDispatcher::characteristicObjectRemoved( |
// TODO(ortuno): We should only unregister a characteristic once |
// there are no characteristic objects that have listeners attached. |
// https://crbug.com/541388 |
- UnregisterCharacteristicObject(characteristic_instance_id); |
+ UnregisterCharacteristicObject(frame_routing_id, characteristic_instance_id); |
// 2 |
// If the object is in the queue we null the characteristic. If this is the |
@@ -354,11 +368,12 @@ void BluetoothDispatcher::characteristicObjectRemoved( |
// We pass in the characteristic so that ResolveOrSendStopNotificationsRequest |
// can remove the characteristic from ActiveNotificationSubscriptions. |
ResolveOrSendStopNotificationsRequest(QueueNotificationRequest( |
- characteristic_instance_id.utf8(), characteristic, |
+ frame_routing_id, characteristic_instance_id.utf8(), characteristic, |
nullptr /* callbacks */, NotificationsRequestType::STOP)); |
} |
void BluetoothDispatcher::registerCharacteristicObject( |
+ int frame_routing_id, |
const blink::WebString& characteristic_instance_id, |
blink::WebBluetoothGATTCharacteristic* characteristic) { |
// TODO(ortuno): After the Object manager is implemented, there will |
@@ -371,7 +386,7 @@ void BluetoothDispatcher::registerCharacteristicObject( |
std::make_pair(characteristic_instance_id.utf8(), characteristic)); |
Send(new BluetoothHostMsg_RegisterCharacteristic( |
- CurrentWorkerId(), characteristic_instance_id.utf8())); |
+ CurrentWorkerId(), frame_routing_id, characteristic_instance_id.utf8())); |
} |
void BluetoothDispatcher::WillStopCurrentWorkerThread() { |
@@ -379,13 +394,15 @@ void BluetoothDispatcher::WillStopCurrentWorkerThread() { |
} |
int BluetoothDispatcher::QueueNotificationRequest( |
+ int frame_routing_id, |
const std::string& characteristic_instance_id, |
blink::WebBluetoothGATTCharacteristic* characteristic, |
blink::WebBluetoothNotificationsCallbacks* callbacks, |
NotificationsRequestType type) { |
int request_id = |
pending_notifications_requests_.Add(new BluetoothNotificationsRequest( |
- characteristic_instance_id, characteristic, callbacks, type)); |
+ frame_routing_id, characteristic_instance_id, characteristic, |
+ callbacks, type)); |
notification_requests_queues_[characteristic_instance_id].push(request_id); |
return request_id; |
@@ -471,6 +488,7 @@ void BluetoothDispatcher::ResolveOrSendStartNotificationRequest( |
int request_id) { |
BluetoothNotificationsRequest* request = |
pending_notifications_requests_.Lookup(request_id); |
+ const int frame_routing_id = request->frame_routing_id; |
const std::string& characteristic_instance_id = |
request->characteristic_instance_id; |
blink::WebBluetoothGATTCharacteristic* characteristic = |
@@ -493,6 +511,7 @@ void BluetoothDispatcher::ResolveOrSendStartNotificationRequest( |
} |
Send(new BluetoothHostMsg_StartNotifications(CurrentWorkerId(), request_id, |
+ frame_routing_id, |
characteristic_instance_id)); |
} |
@@ -503,6 +522,7 @@ void BluetoothDispatcher::ResolveOrSendStopNotificationsRequest( |
// requests. |
BluetoothNotificationsRequest* request = |
pending_notifications_requests_.Lookup(request_id); |
+ const int frame_routing_id = request->frame_routing_id; |
const std::string& characteristic_instance_id = |
request->characteristic_instance_id; |
blink::WebBluetoothGATTCharacteristic* characteristic = |
@@ -514,6 +534,7 @@ void BluetoothDispatcher::ResolveOrSendStopNotificationsRequest( |
if (RemoveFromActiveNotificationSubscriptions(characteristic_instance_id, |
characteristic)) { |
Send(new BluetoothHostMsg_StopNotifications(CurrentWorkerId(), request_id, |
+ frame_routing_id, |
characteristic_instance_id)); |
return; |
} |
@@ -530,12 +551,14 @@ void BluetoothDispatcher::ResolveOrSendStopNotificationsRequest( |
} |
void BluetoothDispatcher::UnregisterCharacteristicObject( |
+ int frame_routing_id, |
const blink::WebString& characteristic_instance_id) { |
int removed = |
active_characteristics_.erase(characteristic_instance_id.utf8()); |
if (removed != 0) { |
Send(new BluetoothHostMsg_UnregisterCharacteristic( |
- CurrentWorkerId(), characteristic_instance_id.utf8())); |
+ CurrentWorkerId(), frame_routing_id, |
+ characteristic_instance_id.utf8())); |
} |
} |
@@ -706,8 +729,9 @@ void BluetoothDispatcher::OnStartNotificationsSuccess(int thread_id, |
// which would result in the subscription continuing. |
if (request->characteristic == nullptr) { |
QueueNotificationRequest( |
- request->characteristic_instance_id, nullptr /* characteristic */, |
- nullptr /* callbacks */, NotificationsRequestType::STOP); |
+ request->frame_routing_id, request->characteristic_instance_id, |
+ nullptr /* characteristic */, nullptr /* callbacks */, |
+ NotificationsRequestType::STOP); |
} |
request->callbacks->onSuccess(); |