Chromium Code Reviews| Index: content/browser/bluetooth/bluetooth_dispatcher_host.cc |
| diff --git a/content/browser/bluetooth/bluetooth_dispatcher_host.cc b/content/browser/bluetooth/bluetooth_dispatcher_host.cc |
| index c4fe0562a92f8f147fdd61ae4439257845369cd6..4f61d2a6c00e5a4907e9fb221c911a244cc948e7 100644 |
| --- a/content/browser/bluetooth/bluetooth_dispatcher_host.cc |
| +++ b/content/browser/bluetooth/bluetooth_dispatcher_host.cc |
| @@ -307,6 +307,7 @@ bool BluetoothDispatcherHost::OnMessageReceived(const IPC::Message& message) { |
| OnGATTServerDisconnect) |
| IPC_MESSAGE_HANDLER(BluetoothHostMsg_GetPrimaryService, OnGetPrimaryService) |
| IPC_MESSAGE_HANDLER(BluetoothHostMsg_GetCharacteristic, OnGetCharacteristic) |
| + IPC_MESSAGE_HANDLER(BluetoothHostMsg_GetCharacteristics, OnGetCharacteristics) |
| IPC_MESSAGE_HANDLER(BluetoothHostMsg_ReadValue, OnReadValue) |
| IPC_MESSAGE_HANDLER(BluetoothHostMsg_WriteValue, OnWriteValue) |
| IPC_MESSAGE_HANDLER(BluetoothHostMsg_StartNotifications, OnStartNotifications) |
| @@ -833,6 +834,61 @@ void BluetoothDispatcherHost::OnGetCharacteristic( |
| thread_id, request_id, WebBluetoothError::CharacteristicNotFound)); |
| } |
| +void BluetoothDispatcherHost::OnGetCharacteristics( |
| + int thread_id, |
| + int request_id, |
| + int frame_routing_id, |
| + const std::string& service_instance_id, |
| + const std::string& characteristic_uuid) { |
| + DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| + RecordWebBluetoothFunctionCall( |
| + UMAWebBluetoothFunction::SERVICE_GET_CHARACTERISTICS); |
| + RecordGetCharacteristicsCharacteristic(characteristic_uuid); |
| + |
| + const CacheQueryResult query_result = |
| + QueryCacheForService(GetOrigin(frame_routing_id), service_instance_id); |
| + |
| + if (query_result.outcome == CacheQueryOutcome::BAD_RENDERER) { |
| + return; |
| + } |
| + |
| + if (query_result.outcome != CacheQueryOutcome::SUCCESS) { |
| + RecordGetCharacteristicsOutcome(query_result.outcome); |
| + Send(new BluetoothMsg_GetCharacteristicsError(thread_id, request_id, |
| + query_result.GetWebError())); |
| + return; |
| + } |
| + |
| + std::vector<std::string> characteristics_instance_ids; |
|
Jeffrey Yasskin
2016/02/24 23:20:29
Can we transpose these three vectors? That is, mak
ortuno
2016/02/25 23:08:27
Ah. I asked a while ago if three arrays were bette
Jeffrey Yasskin
2016/02/25 23:46:57
Ah, sorry if I've given two contradictory answers
|
| + std::vector<std::string> characteristics_uuids; |
| + std::vector<uint32_t> characteristics_properties; |
| + |
| + for (BluetoothGattCharacteristic* characteristic : |
| + query_result.service->GetCharacteristics()) { |
| + if (characteristic_uuid.empty() || |
| + characteristic_uuid == characteristic->GetUUID().canonical_value()) { |
|
Jeffrey Yasskin
2016/02/24 23:20:29
Could you add a TODO to incorporate the blacklist
ortuno
2016/02/25 23:08:27
Added blacklist check since Vince's patch landed a
|
| + characteristics_instance_ids.push_back(characteristic->GetIdentifier()); |
| + characteristics_uuids.push_back( |
| + characteristic->GetUUID().canonical_value()); |
| + characteristics_properties.push_back( |
| + static_cast<uint32_t>(characteristic->GetProperties())); |
| + } |
| + } |
| + |
| + if (!characteristics_instance_ids.empty()) { |
| + RecordGetCharacteristicsOutcome(UMAGetCharacteristicOutcome::SUCCESS); |
| + Send(new BluetoothMsg_GetCharacteristicsSuccess( |
| + thread_id, request_id, characteristics_instance_ids, |
| + characteristics_uuids, characteristics_properties)); |
| + return; |
| + } |
| + RecordGetCharacteristicsOutcome(UMAGetCharacteristicOutcome::NOT_FOUND); |
|
Jeffrey Yasskin
2016/02/24 23:20:29
Probably split this by characteristic_uuid.empty()
ortuno
2016/02/25 23:08:27
Done.
|
| + Send(new BluetoothMsg_GetCharacteristicsError( |
| + thread_id, request_id, characteristic_uuid.empty() |
| + ? WebBluetoothError::NoCharacteristicsFound |
| + : WebBluetoothError::CharacteristicNotFound)); |
| +} |
| + |
| void BluetoothDispatcherHost::OnReadValue( |
| int thread_id, |
| int request_id, |