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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 void NotifyCharacteristicValueChanged( | 90 void NotifyCharacteristicValueChanged( |
91 const std::string& characteristic_instance_id, | 91 const std::string& characteristic_instance_id, |
92 std::vector<uint8_t> value); | 92 std::vector<uint8_t> value); |
93 | 93 |
94 // WebBluetoothService methods: | 94 // WebBluetoothService methods: |
95 void SetClient( | 95 void SetClient( |
96 blink::mojom::WebBluetoothServiceClientAssociatedPtrInfo client) override; | 96 blink::mojom::WebBluetoothServiceClientAssociatedPtrInfo client) override; |
97 void RequestDevice(blink::mojom::WebBluetoothRequestDeviceOptionsPtr options, | 97 void RequestDevice(blink::mojom::WebBluetoothRequestDeviceOptionsPtr options, |
98 const RequestDeviceCallback& callback) override; | 98 const RequestDeviceCallback& callback) override; |
99 void RemoteServerConnect( | 99 void RemoteServerConnect( |
100 const mojo::String& device_id, | 100 const web_bluetooth::WebBluetoothDeviceId& device_id, |
101 const RemoteServerConnectCallback& callback) override; | 101 const RemoteServerConnectCallback& callback) override; |
102 void RemoteServerDisconnect(const mojo::String& device_id) override; | 102 void RemoteServerDisconnect( |
| 103 const web_bluetooth::WebBluetoothDeviceId& device_id) override; |
103 void RemoteServerGetPrimaryServices( | 104 void RemoteServerGetPrimaryServices( |
104 const mojo::String& device_id, | 105 const web_bluetooth::WebBluetoothDeviceId& device_id, |
105 blink::mojom::WebBluetoothGATTQueryQuantity quantity, | 106 blink::mojom::WebBluetoothGATTQueryQuantity quantity, |
106 const base::Optional<device::BluetoothUUID>& services_uuid, | 107 const base::Optional<device::BluetoothUUID>& service_uuid, |
107 const RemoteServerGetPrimaryServicesCallback& callback) override; | 108 const RemoteServerGetPrimaryServicesCallback& callback) override; |
108 void RemoteServiceGetCharacteristics( | 109 void RemoteServiceGetCharacteristics( |
109 const mojo::String& service_instance_id, | 110 const mojo::String& service_instance_id, |
110 blink::mojom::WebBluetoothGATTQueryQuantity quantity, | 111 blink::mojom::WebBluetoothGATTQueryQuantity quantity, |
111 const base::Optional<device::BluetoothUUID>& characteristics_uuid, | 112 const base::Optional<device::BluetoothUUID>& characteristics_uuid, |
112 const RemoteServiceGetCharacteristicsCallback& callback) override; | 113 const RemoteServiceGetCharacteristicsCallback& callback) override; |
113 void RemoteCharacteristicReadValue( | 114 void RemoteCharacteristicReadValue( |
114 const mojo::String& characteristic_instance_id, | 115 const mojo::String& characteristic_instance_id, |
115 const RemoteCharacteristicReadValueCallback& callback) override; | 116 const RemoteCharacteristicReadValueCallback& callback) override; |
116 void RemoteCharacteristicWriteValue( | 117 void RemoteCharacteristicWriteValue( |
117 const mojo::String& characteristic_instance_id, | 118 const mojo::String& characteristic_instance_id, |
118 mojo::Array<uint8_t> value, | 119 mojo::Array<uint8_t> value, |
119 const RemoteCharacteristicWriteValueCallback& callback) override; | 120 const RemoteCharacteristicWriteValueCallback& callback) override; |
120 void RemoteCharacteristicStartNotifications( | 121 void RemoteCharacteristicStartNotifications( |
121 const mojo::String& characteristic_instance_id, | 122 const mojo::String& characteristic_instance_id, |
122 const RemoteCharacteristicStartNotificationsCallback& callback) override; | 123 const RemoteCharacteristicStartNotificationsCallback& callback) override; |
123 void RemoteCharacteristicStopNotifications( | 124 void RemoteCharacteristicStopNotifications( |
124 const mojo::String& characteristic_instance_id, | 125 const mojo::String& characteristic_instance_id, |
125 const RemoteCharacteristicStopNotificationsCallback& callback) override; | 126 const RemoteCharacteristicStopNotificationsCallback& callback) override; |
126 | 127 |
127 void RequestDeviceImpl( | 128 void RequestDeviceImpl( |
128 blink::mojom::WebBluetoothRequestDeviceOptionsPtr options, | 129 blink::mojom::WebBluetoothRequestDeviceOptionsPtr options, |
129 const RequestDeviceCallback& callback, | 130 const RequestDeviceCallback& callback, |
130 device::BluetoothAdapter* adapter); | 131 device::BluetoothAdapter* adapter); |
131 | 132 |
132 // Should only be run after the services have been discovered for | 133 // Should only be run after the services have been discovered for |
133 // |device_address|. | 134 // |device_address|. |
134 void RemoteServerGetPrimaryServicesImpl( | 135 void RemoteServerGetPrimaryServicesImpl( |
135 const mojo::String& device_id, | 136 const web_bluetooth::WebBluetoothDeviceId& device_id, |
136 blink::mojom::WebBluetoothGATTQueryQuantity quantity, | 137 blink::mojom::WebBluetoothGATTQueryQuantity quantity, |
137 const base::Optional<device::BluetoothUUID>& services_uuid, | 138 const base::Optional<device::BluetoothUUID>& services_uuid, |
138 const RemoteServerGetPrimaryServicesCallback& callback, | 139 const RemoteServerGetPrimaryServicesCallback& callback, |
139 device::BluetoothDevice* device); | 140 device::BluetoothDevice* device); |
140 | 141 |
141 // Callbacks for BluetoothDeviceChooserController::GetDevice. | 142 // Callbacks for BluetoothDeviceChooserController::GetDevice. |
142 void OnGetDeviceSuccess( | 143 void OnGetDeviceSuccess( |
143 const RequestDeviceCallback& callback, | 144 const RequestDeviceCallback& callback, |
144 blink::mojom::WebBluetoothRequestDeviceOptionsPtr options, | 145 blink::mojom::WebBluetoothRequestDeviceOptionsPtr options, |
145 const std::string& device_id); | 146 const std::string& device_id); |
146 void OnGetDeviceFailed(const RequestDeviceCallback& callback, | 147 void OnGetDeviceFailed(const RequestDeviceCallback& callback, |
147 blink::mojom::WebBluetoothError error); | 148 blink::mojom::WebBluetoothError error); |
148 | 149 |
149 // Callbacks for BluetoothDevice::CreateGattConnection. | 150 // Callbacks for BluetoothDevice::CreateGattConnection. |
150 void OnCreateGATTConnectionSuccess( | 151 void OnCreateGATTConnectionSuccess( |
151 const std::string& device_id, | 152 const web_bluetooth::WebBluetoothDeviceId& device_id, |
152 base::TimeTicks start_time, | 153 base::TimeTicks start_time, |
153 const RemoteServerConnectCallback& callback, | 154 const RemoteServerConnectCallback& callback, |
154 std::unique_ptr<device::BluetoothGattConnection> connection); | 155 std::unique_ptr<device::BluetoothGattConnection> connection); |
155 void OnCreateGATTConnectionFailed( | 156 void OnCreateGATTConnectionFailed( |
156 const std::string& device_id, | |
157 base::TimeTicks start_time, | 157 base::TimeTicks start_time, |
158 const RemoteServerConnectCallback& callback, | 158 const RemoteServerConnectCallback& callback, |
159 device::BluetoothDevice::ConnectErrorCode error_code); | 159 device::BluetoothDevice::ConnectErrorCode error_code); |
160 | 160 |
161 // Callbacks for BluetoothRemoteGattCharacteristic::ReadRemoteCharacteristic. | 161 // Callbacks for BluetoothRemoteGattCharacteristic::ReadRemoteCharacteristic. |
162 void OnReadValueSuccess(const RemoteCharacteristicReadValueCallback& callback, | 162 void OnReadValueSuccess(const RemoteCharacteristicReadValueCallback& callback, |
163 const std::vector<uint8_t>& value); | 163 const std::vector<uint8_t>& value); |
164 void OnReadValueFailed( | 164 void OnReadValueFailed( |
165 const RemoteCharacteristicReadValueCallback& callback, | 165 const RemoteCharacteristicReadValueCallback& callback, |
166 device::BluetoothRemoteGattService::GattErrorCode error_code); | 166 device::BluetoothRemoteGattService::GattErrorCode error_code); |
(...skipping 21 matching lines...) Expand all Loading... |
188 // Functions to query the platform cache for the bluetooth object. | 188 // Functions to query the platform cache for the bluetooth object. |
189 // result.outcome == CacheQueryOutcome::SUCCESS if the object was found in the | 189 // result.outcome == CacheQueryOutcome::SUCCESS if the object was found in the |
190 // cache. Otherwise result.outcome that can used to record the outcome and | 190 // cache. Otherwise result.outcome that can used to record the outcome and |
191 // result.error will contain the error that should be sent to the renderer. | 191 // result.error will contain the error that should be sent to the renderer. |
192 // One of the possible outcomes is BAD_RENDERER. In this case we crash the | 192 // One of the possible outcomes is BAD_RENDERER. In this case we crash the |
193 // renderer, record the reason and close the pipe, so it's safe to drop | 193 // renderer, record the reason and close the pipe, so it's safe to drop |
194 // any callbacks. | 194 // any callbacks. |
195 | 195 |
196 // Queries the platform cache for a Device with |device_id| for |origin|. | 196 // Queries the platform cache for a Device with |device_id| for |origin|. |
197 // Fills in the |outcome| field and the |device| field if successful. | 197 // Fills in the |outcome| field and the |device| field if successful. |
198 CacheQueryResult QueryCacheForDevice(const std::string& device_id); | 198 CacheQueryResult QueryCacheForDevice( |
| 199 const web_bluetooth::WebBluetoothDeviceId& device_id); |
199 | 200 |
200 // Queries the platform cache for a Service with |service_instance_id|. Fills | 201 // Queries the platform cache for a Service with |service_instance_id|. Fills |
201 // in the |outcome| field, and |device| and |service| fields if successful. | 202 // in the |outcome| field, and |device| and |service| fields if successful. |
202 CacheQueryResult QueryCacheForService(const std::string& service_instance_id); | 203 CacheQueryResult QueryCacheForService(const std::string& service_instance_id); |
203 | 204 |
204 // Queries the platform cache for a characteristic with | 205 // Queries the platform cache for a characteristic with |
205 // |characteristic_instance_id|. Fills in the |outcome| field, and |device|, | 206 // |characteristic_instance_id|. Fills in the |outcome| field, and |device|, |
206 // |service| and |characteristic| fields if successful. | 207 // |service| and |characteristic| fields if successful. |
207 CacheQueryResult QueryCacheForCharacteristic( | 208 CacheQueryResult QueryCacheForCharacteristic( |
208 const std::string& characteristic_instance_id); | 209 const std::string& characteristic_instance_id); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 mojo::Binding<blink::mojom::WebBluetoothService> binding_; | 251 mojo::Binding<blink::mojom::WebBluetoothService> binding_; |
251 | 252 |
252 base::WeakPtrFactory<WebBluetoothServiceImpl> weak_ptr_factory_; | 253 base::WeakPtrFactory<WebBluetoothServiceImpl> weak_ptr_factory_; |
253 | 254 |
254 DISALLOW_COPY_AND_ASSIGN(WebBluetoothServiceImpl); | 255 DISALLOW_COPY_AND_ASSIGN(WebBluetoothServiceImpl); |
255 }; | 256 }; |
256 | 257 |
257 } // namespace content | 258 } // namespace content |
258 | 259 |
259 #endif // CONTENT_BROWSER_BLUETOOTH_WEB_BLUETOOTH_SERVICE_IMPL_H_ | 260 #endif // CONTENT_BROWSER_BLUETOOTH_WEB_BLUETOOTH_SERVICE_IMPL_H_ |
OLD | NEW |