| 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 #ifndef CONTENT_BROWSER_BLUETOOTH_WEB_BLUETOOTH_SERVICE_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_BLUETOOTH_WEB_BLUETOOTH_SERVICE_IMPL_H_ |
| 6 #define CONTENT_BROWSER_BLUETOOTH_WEB_BLUETOOTH_SERVICE_IMPL_H_ | 6 #define CONTENT_BROWSER_BLUETOOTH_WEB_BLUETOOTH_SERVICE_IMPL_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 void RemoteCharacteristicWriteValue( | 121 void RemoteCharacteristicWriteValue( |
| 122 const std::string& characteristic_instance_id, | 122 const std::string& characteristic_instance_id, |
| 123 const std::vector<uint8_t>& value, | 123 const std::vector<uint8_t>& value, |
| 124 const RemoteCharacteristicWriteValueCallback& callback) override; | 124 const RemoteCharacteristicWriteValueCallback& callback) override; |
| 125 void RemoteCharacteristicStartNotifications( | 125 void RemoteCharacteristicStartNotifications( |
| 126 const std::string& characteristic_instance_id, | 126 const std::string& characteristic_instance_id, |
| 127 const RemoteCharacteristicStartNotificationsCallback& callback) override; | 127 const RemoteCharacteristicStartNotificationsCallback& callback) override; |
| 128 void RemoteCharacteristicStopNotifications( | 128 void RemoteCharacteristicStopNotifications( |
| 129 const std::string& characteristic_instance_id, | 129 const std::string& characteristic_instance_id, |
| 130 const RemoteCharacteristicStopNotificationsCallback& callback) override; | 130 const RemoteCharacteristicStopNotificationsCallback& callback) override; |
| 131 void RemoteCharacteristicGetDescriptors( |
| 132 const std::string& service_instance_id, |
| 133 blink::mojom::WebBluetoothGATTQueryQuantity quantity, |
| 134 const base::Optional<device::BluetoothUUID>& characteristics_uuid, |
| 135 const RemoteCharacteristicGetDescriptorsCallback& callback) override; |
| 131 | 136 |
| 132 void RequestDeviceImpl( | 137 void RequestDeviceImpl( |
| 133 blink::mojom::WebBluetoothRequestDeviceOptionsPtr options, | 138 blink::mojom::WebBluetoothRequestDeviceOptionsPtr options, |
| 134 const RequestDeviceCallback& callback, | 139 const RequestDeviceCallback& callback, |
| 135 device::BluetoothAdapter* adapter); | 140 device::BluetoothAdapter* adapter); |
| 136 | 141 |
| 137 // Should only be run after the services have been discovered for | 142 // Should only be run after the services have been discovered for |
| 138 // |device_address|. | 143 // |device_address|. |
| 139 void RemoteServerGetPrimaryServicesImpl( | 144 void RemoteServerGetPrimaryServicesImpl( |
| 140 const WebBluetoothDeviceId& device_id, | 145 const WebBluetoothDeviceId& device_id, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 156 const WebBluetoothDeviceId& device_id, | 161 const WebBluetoothDeviceId& device_id, |
| 157 base::TimeTicks start_time, | 162 base::TimeTicks start_time, |
| 158 const RemoteServerConnectCallback& callback, | 163 const RemoteServerConnectCallback& callback, |
| 159 std::unique_ptr<device::BluetoothGattConnection> connection); | 164 std::unique_ptr<device::BluetoothGattConnection> connection); |
| 160 void OnCreateGATTConnectionFailed( | 165 void OnCreateGATTConnectionFailed( |
| 161 base::TimeTicks start_time, | 166 base::TimeTicks start_time, |
| 162 const RemoteServerConnectCallback& callback, | 167 const RemoteServerConnectCallback& callback, |
| 163 device::BluetoothDevice::ConnectErrorCode error_code); | 168 device::BluetoothDevice::ConnectErrorCode error_code); |
| 164 | 169 |
| 165 // Callbacks for BluetoothRemoteGattCharacteristic::ReadRemoteCharacteristic. | 170 // Callbacks for BluetoothRemoteGattCharacteristic::ReadRemoteCharacteristic. |
| 166 void OnReadValueSuccess(const RemoteCharacteristicReadValueCallback& callback, | 171 void OnCharacteristicReadValueSuccess( |
| 167 const std::vector<uint8_t>& value); | 172 const RemoteCharacteristicReadValueCallback& callback, |
| 168 void OnReadValueFailed( | 173 const std::vector<uint8_t>& value); |
| 174 void OnCharacteristicReadValueFailed( |
| 169 const RemoteCharacteristicReadValueCallback& callback, | 175 const RemoteCharacteristicReadValueCallback& callback, |
| 170 device::BluetoothRemoteGattService::GattErrorCode error_code); | 176 device::BluetoothRemoteGattService::GattErrorCode error_code); |
| 171 | 177 |
| 172 // Callbacks for BluetoothRemoteGattCharacteristic::WriteRemoteCharacteristic. | 178 // Callbacks for BluetoothRemoteGattCharacteristic::WriteRemoteCharacteristic. |
| 173 void OnWriteValueSuccess( | 179 void OnCharacteristicWriteValueSuccess( |
| 174 const RemoteCharacteristicWriteValueCallback& callback); | 180 const RemoteCharacteristicWriteValueCallback& callback); |
| 175 void OnWriteValueFailed( | 181 void OnCharacteristicWriteValueFailed( |
| 176 const RemoteCharacteristicWriteValueCallback& callback, | 182 const RemoteCharacteristicWriteValueCallback& callback, |
| 177 device::BluetoothRemoteGattService::GattErrorCode error_code); | 183 device::BluetoothRemoteGattService::GattErrorCode error_code); |
| 178 | 184 |
| 179 // Callbacks for BluetoothRemoteGattCharacteristic::StartNotifySession. | 185 // Callbacks for BluetoothRemoteGattCharacteristic::StartNotifySession. |
| 180 void OnStartNotifySessionSuccess( | 186 void OnStartNotifySessionSuccess( |
| 181 const RemoteCharacteristicStartNotificationsCallback& callback, | 187 const RemoteCharacteristicStartNotificationsCallback& callback, |
| 182 std::unique_ptr<device::BluetoothGattNotifySession> notify_session); | 188 std::unique_ptr<device::BluetoothGattNotifySession> notify_session); |
| 183 void OnStartNotifySessionFailed( | 189 void OnStartNotifySessionFailed( |
| 184 const RemoteCharacteristicStartNotificationsCallback& callback, | 190 const RemoteCharacteristicStartNotificationsCallback& callback, |
| 185 device::BluetoothRemoteGattService::GattErrorCode error_code); | 191 device::BluetoothRemoteGattService::GattErrorCode error_code); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 | 226 |
| 221 // Used to open a BluetoothChooser and start a device discovery session. | 227 // Used to open a BluetoothChooser and start a device discovery session. |
| 222 std::unique_ptr<BluetoothDeviceChooserController> device_chooser_controller_; | 228 std::unique_ptr<BluetoothDeviceChooserController> device_chooser_controller_; |
| 223 | 229 |
| 224 // Keeps track of which devices the frame's origin is allowed to access. | 230 // Keeps track of which devices the frame's origin is allowed to access. |
| 225 BluetoothAllowedDevicesMap allowed_devices_map_; | 231 BluetoothAllowedDevicesMap allowed_devices_map_; |
| 226 | 232 |
| 227 // Maps to get the object's parent based on its instanceID. | 233 // Maps to get the object's parent based on its instanceID. |
| 228 std::unordered_map<std::string, std::string> service_id_to_device_address_; | 234 std::unordered_map<std::string, std::string> service_id_to_device_address_; |
| 229 std::unordered_map<std::string, std::string> characteristic_id_to_service_id_; | 235 std::unordered_map<std::string, std::string> characteristic_id_to_service_id_; |
| 236 std::unordered_map<std::string, std::string> |
| 237 descriptor_id_to_characteristic_id_; |
| 230 | 238 |
| 231 // Map to keep track of the connected Bluetooth devices. | 239 // Map to keep track of the connected Bluetooth devices. |
| 232 std::unique_ptr<FrameConnectedBluetoothDevices> connected_devices_; | 240 std::unique_ptr<FrameConnectedBluetoothDevices> connected_devices_; |
| 233 | 241 |
| 234 // Maps a device address to callbacks that are waiting for services to | 242 // Maps a device address to callbacks that are waiting for services to |
| 235 // be discovered for that device. | 243 // be discovered for that device. |
| 236 std::unordered_map<std::string, std::vector<PrimaryServicesRequestCallback>> | 244 std::unordered_map<std::string, std::vector<PrimaryServicesRequestCallback>> |
| 237 pending_primary_services_requests_; | 245 pending_primary_services_requests_; |
| 238 | 246 |
| 239 // Map to keep track of the characteristics' notify sessions. | 247 // Map to keep track of the characteristics' notify sessions. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 253 mojo::Binding<blink::mojom::WebBluetoothService> binding_; | 261 mojo::Binding<blink::mojom::WebBluetoothService> binding_; |
| 254 | 262 |
| 255 base::WeakPtrFactory<WebBluetoothServiceImpl> weak_ptr_factory_; | 263 base::WeakPtrFactory<WebBluetoothServiceImpl> weak_ptr_factory_; |
| 256 | 264 |
| 257 DISALLOW_COPY_AND_ASSIGN(WebBluetoothServiceImpl); | 265 DISALLOW_COPY_AND_ASSIGN(WebBluetoothServiceImpl); |
| 258 }; | 266 }; |
| 259 | 267 |
| 260 } // namespace content | 268 } // namespace content |
| 261 | 269 |
| 262 #endif // CONTENT_BROWSER_BLUETOOTH_WEB_BLUETOOTH_SERVICE_IMPL_H_ | 270 #endif // CONTENT_BROWSER_BLUETOOTH_WEB_BLUETOOTH_SERVICE_IMPL_H_ |
| OLD | NEW |