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