Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // ID Not In Map Note: | 5 // ID Not In Map Note: |
| 6 // A service, characteristic, or descriptor ID not in the corresponding | 6 // A service, characteristic, or descriptor ID not in the corresponding |
| 7 // BluetoothDispatcherHost map [service_to_device_, characteristic_to_service_, | 7 // BluetoothDispatcherHost map [service_to_device_, characteristic_to_service_, |
| 8 // descriptor_to_characteristic_] implies a hostile renderer because a renderer | 8 // descriptor_to_characteristic_] implies a hostile renderer because a renderer |
| 9 // obtains the corresponding ID from this class and it will be added to the map | 9 // obtains the corresponding ID from this class and it will be added to the map |
| 10 // at that time. | 10 // at that time. |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 300 bool BluetoothDispatcherHost::OnMessageReceived(const IPC::Message& message) { | 300 bool BluetoothDispatcherHost::OnMessageReceived(const IPC::Message& message) { |
| 301 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 301 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 302 bool handled = true; | 302 bool handled = true; |
| 303 IPC_BEGIN_MESSAGE_MAP(BluetoothDispatcherHost, message) | 303 IPC_BEGIN_MESSAGE_MAP(BluetoothDispatcherHost, message) |
| 304 IPC_MESSAGE_HANDLER(BluetoothHostMsg_RequestDevice, OnRequestDevice) | 304 IPC_MESSAGE_HANDLER(BluetoothHostMsg_RequestDevice, OnRequestDevice) |
| 305 IPC_MESSAGE_HANDLER(BluetoothHostMsg_GATTServerConnect, OnGATTServerConnect) | 305 IPC_MESSAGE_HANDLER(BluetoothHostMsg_GATTServerConnect, OnGATTServerConnect) |
| 306 IPC_MESSAGE_HANDLER(BluetoothHostMsg_GATTServerDisconnect, | 306 IPC_MESSAGE_HANDLER(BluetoothHostMsg_GATTServerDisconnect, |
| 307 OnGATTServerDisconnect) | 307 OnGATTServerDisconnect) |
| 308 IPC_MESSAGE_HANDLER(BluetoothHostMsg_GetPrimaryService, OnGetPrimaryService) | 308 IPC_MESSAGE_HANDLER(BluetoothHostMsg_GetPrimaryService, OnGetPrimaryService) |
| 309 IPC_MESSAGE_HANDLER(BluetoothHostMsg_GetCharacteristic, OnGetCharacteristic) | 309 IPC_MESSAGE_HANDLER(BluetoothHostMsg_GetCharacteristic, OnGetCharacteristic) |
| 310 IPC_MESSAGE_HANDLER(BluetoothHostMsg_GetCharacteristics, OnGetCharacteristics) | |
| 310 IPC_MESSAGE_HANDLER(BluetoothHostMsg_ReadValue, OnReadValue) | 311 IPC_MESSAGE_HANDLER(BluetoothHostMsg_ReadValue, OnReadValue) |
| 311 IPC_MESSAGE_HANDLER(BluetoothHostMsg_WriteValue, OnWriteValue) | 312 IPC_MESSAGE_HANDLER(BluetoothHostMsg_WriteValue, OnWriteValue) |
| 312 IPC_MESSAGE_HANDLER(BluetoothHostMsg_StartNotifications, OnStartNotifications) | 313 IPC_MESSAGE_HANDLER(BluetoothHostMsg_StartNotifications, OnStartNotifications) |
| 313 IPC_MESSAGE_HANDLER(BluetoothHostMsg_StopNotifications, OnStopNotifications) | 314 IPC_MESSAGE_HANDLER(BluetoothHostMsg_StopNotifications, OnStopNotifications) |
| 314 IPC_MESSAGE_HANDLER(BluetoothHostMsg_RegisterCharacteristic, | 315 IPC_MESSAGE_HANDLER(BluetoothHostMsg_RegisterCharacteristic, |
| 315 OnRegisterCharacteristicObject); | 316 OnRegisterCharacteristicObject); |
| 316 IPC_MESSAGE_HANDLER(BluetoothHostMsg_UnregisterCharacteristic, | 317 IPC_MESSAGE_HANDLER(BluetoothHostMsg_UnregisterCharacteristic, |
| 317 OnUnregisterCharacteristicObject); | 318 OnUnregisterCharacteristicObject); |
| 318 IPC_MESSAGE_UNHANDLED(handled = false) | 319 IPC_MESSAGE_UNHANDLED(handled = false) |
| 319 IPC_END_MESSAGE_MAP() | 320 IPC_END_MESSAGE_MAP() |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 826 thread_id, request_id, characteristic_instance_id, | 827 thread_id, request_id, characteristic_instance_id, |
| 827 static_cast<uint32_t>(characteristic->GetProperties()))); | 828 static_cast<uint32_t>(characteristic->GetProperties()))); |
| 828 return; | 829 return; |
| 829 } | 830 } |
| 830 } | 831 } |
| 831 RecordGetCharacteristicOutcome(UMAGetCharacteristicOutcome::NOT_FOUND); | 832 RecordGetCharacteristicOutcome(UMAGetCharacteristicOutcome::NOT_FOUND); |
| 832 Send(new BluetoothMsg_GetCharacteristicError( | 833 Send(new BluetoothMsg_GetCharacteristicError( |
| 833 thread_id, request_id, WebBluetoothError::CharacteristicNotFound)); | 834 thread_id, request_id, WebBluetoothError::CharacteristicNotFound)); |
| 834 } | 835 } |
| 835 | 836 |
| 837 void BluetoothDispatcherHost::OnGetCharacteristics( | |
| 838 int thread_id, | |
| 839 int request_id, | |
| 840 int frame_routing_id, | |
| 841 const std::string& service_instance_id, | |
| 842 const std::string& characteristic_uuid) { | |
| 843 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 844 RecordWebBluetoothFunctionCall( | |
| 845 UMAWebBluetoothFunction::SERVICE_GET_CHARACTERISTICS); | |
| 846 RecordGetCharacteristicsCharacteristic(characteristic_uuid); | |
| 847 | |
| 848 const CacheQueryResult query_result = | |
| 849 QueryCacheForService(GetOrigin(frame_routing_id), service_instance_id); | |
| 850 | |
| 851 if (query_result.outcome == CacheQueryOutcome::BAD_RENDERER) { | |
| 852 return; | |
| 853 } | |
| 854 | |
| 855 if (query_result.outcome != CacheQueryOutcome::SUCCESS) { | |
| 856 RecordGetCharacteristicsOutcome(query_result.outcome); | |
| 857 Send(new BluetoothMsg_GetCharacteristicsError(thread_id, request_id, | |
| 858 query_result.GetWebError())); | |
| 859 return; | |
| 860 } | |
| 861 | |
| 862 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
| |
| 863 std::vector<std::string> characteristics_uuids; | |
| 864 std::vector<uint32_t> characteristics_properties; | |
| 865 | |
| 866 for (BluetoothGattCharacteristic* characteristic : | |
| 867 query_result.service->GetCharacteristics()) { | |
| 868 if (characteristic_uuid.empty() || | |
| 869 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
| |
| 870 characteristics_instance_ids.push_back(characteristic->GetIdentifier()); | |
| 871 characteristics_uuids.push_back( | |
| 872 characteristic->GetUUID().canonical_value()); | |
| 873 characteristics_properties.push_back( | |
| 874 static_cast<uint32_t>(characteristic->GetProperties())); | |
| 875 } | |
| 876 } | |
| 877 | |
| 878 if (!characteristics_instance_ids.empty()) { | |
| 879 RecordGetCharacteristicsOutcome(UMAGetCharacteristicOutcome::SUCCESS); | |
| 880 Send(new BluetoothMsg_GetCharacteristicsSuccess( | |
| 881 thread_id, request_id, characteristics_instance_ids, | |
| 882 characteristics_uuids, characteristics_properties)); | |
| 883 return; | |
| 884 } | |
| 885 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.
| |
| 886 Send(new BluetoothMsg_GetCharacteristicsError( | |
| 887 thread_id, request_id, characteristic_uuid.empty() | |
| 888 ? WebBluetoothError::NoCharacteristicsFound | |
| 889 : WebBluetoothError::CharacteristicNotFound)); | |
| 890 } | |
| 891 | |
| 836 void BluetoothDispatcherHost::OnReadValue( | 892 void BluetoothDispatcherHost::OnReadValue( |
| 837 int thread_id, | 893 int thread_id, |
| 838 int request_id, | 894 int request_id, |
| 839 int frame_routing_id, | 895 int frame_routing_id, |
| 840 const std::string& characteristic_instance_id) { | 896 const std::string& characteristic_instance_id) { |
| 841 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 897 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 842 RecordWebBluetoothFunctionCall( | 898 RecordWebBluetoothFunctionCall( |
| 843 UMAWebBluetoothFunction::CHARACTERISTIC_READ_VALUE); | 899 UMAWebBluetoothFunction::CHARACTERISTIC_READ_VALUE); |
| 844 | 900 |
| 845 const CacheQueryResult query_result = QueryCacheForCharacteristic( | 901 const CacheQueryResult query_result = QueryCacheForCharacteristic( |
| (...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1522 | 1578 |
| 1523 bool BluetoothDispatcherHost::CanFrameAccessCharacteristicInstance( | 1579 bool BluetoothDispatcherHost::CanFrameAccessCharacteristicInstance( |
| 1524 int frame_routing_id, | 1580 int frame_routing_id, |
| 1525 const std::string& characteristic_instance_id) { | 1581 const std::string& characteristic_instance_id) { |
| 1526 return QueryCacheForCharacteristic(GetOrigin(frame_routing_id), | 1582 return QueryCacheForCharacteristic(GetOrigin(frame_routing_id), |
| 1527 characteristic_instance_id) | 1583 characteristic_instance_id) |
| 1528 .outcome != CacheQueryOutcome::BAD_RENDERER; | 1584 .outcome != CacheQueryOutcome::BAD_RENDERER; |
| 1529 } | 1585 } |
| 1530 | 1586 |
| 1531 } // namespace content | 1587 } // namespace content |
| OLD | NEW |