| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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: A service, characteristic, or descriptor ID not in the | 5 // ID Not In Map Note: A service, characteristic, or descriptor ID not in the |
| 6 // corresponding WebBluetoothServiceImpl map [service_id_to_device_address_, | 6 // corresponding WebBluetoothServiceImpl map [service_id_to_device_address_, |
| 7 // characteristic_id_to_service_id_, descriptor_id_to_characteristic_id_] | 7 // characteristic_id_to_service_id_, descriptor_id_to_characteristic_id_] |
| 8 // implies a hostile renderer because a renderer obtains the corresponding ID | 8 // implies a hostile renderer because a renderer obtains the corresponding ID |
| 9 // from this class and it will be added to the map at that time. | 9 // from this class and it will be added to the map at that time. |
| 10 | 10 |
| (...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 } | 737 } |
| 738 notify_session_iter->second->Stop(base::Bind( | 738 notify_session_iter->second->Stop(base::Bind( |
| 739 &WebBluetoothServiceImpl::OnStopNotifySessionComplete, | 739 &WebBluetoothServiceImpl::OnStopNotifySessionComplete, |
| 740 weak_ptr_factory_.GetWeakPtr(), characteristic_instance_id, callback)); | 740 weak_ptr_factory_.GetWeakPtr(), characteristic_instance_id, callback)); |
| 741 } | 741 } |
| 742 | 742 |
| 743 void WebBluetoothServiceImpl::RemoteDescriptorReadValue( | 743 void WebBluetoothServiceImpl::RemoteDescriptorReadValue( |
| 744 const std::string& descriptor_instance_id, | 744 const std::string& descriptor_instance_id, |
| 745 const RemoteDescriptorReadValueCallback& callback) { | 745 const RemoteDescriptorReadValueCallback& callback) { |
| 746 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 746 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 747 RecordWebBluetoothFunctionCall( |
| 748 UMAWebBluetoothFunction::DESCRIPTOR_READ_VALUE); |
| 747 | 749 |
| 748 const CacheQueryResult query_result = | 750 const CacheQueryResult query_result = |
| 749 QueryCacheForDescriptor(descriptor_instance_id); | 751 QueryCacheForDescriptor(descriptor_instance_id); |
| 750 | 752 |
| 751 if (query_result.outcome == CacheQueryOutcome::BAD_RENDERER) { | 753 if (query_result.outcome == CacheQueryOutcome::BAD_RENDERER) { |
| 752 return; | 754 return; |
| 753 } | 755 } |
| 754 | 756 |
| 755 if (query_result.outcome != CacheQueryOutcome::SUCCESS) { | 757 if (query_result.outcome != CacheQueryOutcome::SUCCESS) { |
| 758 RecordDescriptorReadValueOutcome(query_result.outcome); |
| 756 callback.Run(query_result.GetWebResult(), base::nullopt /* value */); | 759 callback.Run(query_result.GetWebResult(), base::nullopt /* value */); |
| 757 return; | 760 return; |
| 758 } | 761 } |
| 759 | 762 |
| 760 if (BluetoothBlocklist::Get().IsExcludedFromReads( | 763 if (BluetoothBlocklist::Get().IsExcludedFromReads( |
| 761 query_result.descriptor->GetUUID())) { | 764 query_result.descriptor->GetUUID())) { |
| 765 RecordDescriptorReadValueOutcome(UMAGATTOperationOutcome::BLOCKLISTED); |
| 762 callback.Run(blink::mojom::WebBluetoothResult::BLOCKLISTED_READ, | 766 callback.Run(blink::mojom::WebBluetoothResult::BLOCKLISTED_READ, |
| 763 base::nullopt /* value */); | 767 base::nullopt /* value */); |
| 764 return; | 768 return; |
| 765 } | 769 } |
| 766 | 770 |
| 767 query_result.descriptor->ReadRemoteDescriptor( | 771 query_result.descriptor->ReadRemoteDescriptor( |
| 768 base::Bind(&WebBluetoothServiceImpl::OnDescriptorReadValueSuccess, | 772 base::Bind(&WebBluetoothServiceImpl::OnDescriptorReadValueSuccess, |
| 769 weak_ptr_factory_.GetWeakPtr(), callback), | 773 weak_ptr_factory_.GetWeakPtr(), callback), |
| 770 base::Bind(&WebBluetoothServiceImpl::OnDescriptorReadValueFailed, | 774 base::Bind(&WebBluetoothServiceImpl::OnDescriptorReadValueFailed, |
| 771 weak_ptr_factory_.GetWeakPtr(), callback)); | 775 weak_ptr_factory_.GetWeakPtr(), callback)); |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 969 const std::string& characteristic_instance_id, | 973 const std::string& characteristic_instance_id, |
| 970 const RemoteCharacteristicStopNotificationsCallback& callback) { | 974 const RemoteCharacteristicStopNotificationsCallback& callback) { |
| 971 characteristic_id_to_notify_session_.erase(characteristic_instance_id); | 975 characteristic_id_to_notify_session_.erase(characteristic_instance_id); |
| 972 callback.Run(); | 976 callback.Run(); |
| 973 } | 977 } |
| 974 | 978 |
| 975 void WebBluetoothServiceImpl::OnDescriptorReadValueSuccess( | 979 void WebBluetoothServiceImpl::OnDescriptorReadValueSuccess( |
| 976 const RemoteDescriptorReadValueCallback& callback, | 980 const RemoteDescriptorReadValueCallback& callback, |
| 977 const std::vector<uint8_t>& value) { | 981 const std::vector<uint8_t>& value) { |
| 978 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 982 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 983 RecordDescriptorReadValueOutcome(UMAGATTOperationOutcome::SUCCESS); |
| 979 callback.Run(blink::mojom::WebBluetoothResult::SUCCESS, value); | 984 callback.Run(blink::mojom::WebBluetoothResult::SUCCESS, value); |
| 980 } | 985 } |
| 981 | 986 |
| 982 void WebBluetoothServiceImpl::OnDescriptorReadValueFailed( | 987 void WebBluetoothServiceImpl::OnDescriptorReadValueFailed( |
| 983 const RemoteDescriptorReadValueCallback& callback, | 988 const RemoteDescriptorReadValueCallback& callback, |
| 984 device::BluetoothRemoteGattService::GattErrorCode error_code) { | 989 device::BluetoothRemoteGattService::GattErrorCode error_code) { |
| 985 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 990 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 986 // TODO(667319) We are reporting failures to UMA but not reporting successes. | |
| 987 callback.Run(TranslateGATTErrorAndRecord(error_code, | 991 callback.Run(TranslateGATTErrorAndRecord(error_code, |
| 988 UMAGATTOperation::DESCRIPTOR_READ), | 992 UMAGATTOperation::DESCRIPTOR_READ), |
| 989 base::nullopt /* value */); | 993 base::nullopt /* value */); |
| 990 } | 994 } |
| 991 | 995 |
| 992 CacheQueryResult WebBluetoothServiceImpl::QueryCacheForDevice( | 996 CacheQueryResult WebBluetoothServiceImpl::QueryCacheForDevice( |
| 993 const WebBluetoothDeviceId& device_id) { | 997 const WebBluetoothDeviceId& device_id) { |
| 994 const std::string& device_address = | 998 const std::string& device_address = |
| 995 allowed_devices_map_.GetDeviceAddress(GetOrigin(), device_id); | 999 allowed_devices_map_.GetDeviceAddress(GetOrigin(), device_id); |
| 996 if (device_address.empty()) { | 1000 if (device_address.empty()) { |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1124 characteristic_id_to_service_id_.clear(); | 1128 characteristic_id_to_service_id_.clear(); |
| 1125 service_id_to_device_address_.clear(); | 1129 service_id_to_device_address_.clear(); |
| 1126 connected_devices_.reset( | 1130 connected_devices_.reset( |
| 1127 new FrameConnectedBluetoothDevices(render_frame_host_)); | 1131 new FrameConnectedBluetoothDevices(render_frame_host_)); |
| 1128 allowed_devices_map_ = BluetoothAllowedDevicesMap(); | 1132 allowed_devices_map_ = BluetoothAllowedDevicesMap(); |
| 1129 device_chooser_controller_.reset(); | 1133 device_chooser_controller_.reset(); |
| 1130 BluetoothAdapterFactoryWrapper::Get().ReleaseAdapter(this); | 1134 BluetoothAdapterFactoryWrapper::Get().ReleaseAdapter(this); |
| 1131 } | 1135 } |
| 1132 | 1136 |
| 1133 } // namespace content | 1137 } // namespace content |
| OLD | NEW |