| 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 #include "content/renderer/bluetooth/web_bluetooth_impl.h" | 5 #include "content/renderer/bluetooth/web_bluetooth_impl.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 | 182 |
| 183 void WebBluetoothImpl::OnRequestDeviceComplete( | 183 void WebBluetoothImpl::OnRequestDeviceComplete( |
| 184 std::unique_ptr<blink::WebBluetoothRequestDeviceCallbacks> callbacks, | 184 std::unique_ptr<blink::WebBluetoothRequestDeviceCallbacks> callbacks, |
| 185 const blink::mojom::WebBluetoothError error, | 185 const blink::mojom::WebBluetoothError error, |
| 186 blink::mojom::WebBluetoothDevicePtr device) { | 186 blink::mojom::WebBluetoothDevicePtr device) { |
| 187 if (error == blink::mojom::WebBluetoothError::SUCCESS) { | 187 if (error == blink::mojom::WebBluetoothError::SUCCESS) { |
| 188 blink::WebVector<blink::WebString> uuids(device->uuids.size()); | 188 blink::WebVector<blink::WebString> uuids(device->uuids.size()); |
| 189 for (size_t i = 0; i < device->uuids.size(); ++i) | 189 for (size_t i = 0; i < device->uuids.size(); ++i) |
| 190 uuids[i] = blink::WebString::fromUTF8(device->uuids[i]); | 190 uuids[i] = blink::WebString::fromUTF8(device->uuids[i]); |
| 191 | 191 |
| 192 callbacks->onSuccess(base::WrapUnique(new blink::WebBluetoothDeviceInit( | 192 callbacks->onSuccess(base::MakeUnique<blink::WebBluetoothDeviceInit>( |
| 193 blink::WebString::fromUTF8(device->id.str()), | 193 blink::WebString::fromUTF8(device->id.str()), |
| 194 device->name.is_null() ? blink::WebString() | 194 device->name.is_null() ? blink::WebString() |
| 195 : blink::WebString::fromUTF8(device->name), | 195 : blink::WebString::fromUTF8(device->name), |
| 196 uuids))); | 196 uuids)); |
| 197 } else { | 197 } else { |
| 198 callbacks->onError(ToInt32(error)); | 198 callbacks->onError(ToInt32(error)); |
| 199 } | 199 } |
| 200 } | 200 } |
| 201 | 201 |
| 202 void WebBluetoothImpl::GattServerDisconnected( | 202 void WebBluetoothImpl::GattServerDisconnected( |
| 203 const WebBluetoothDeviceId& device_id) { | 203 const WebBluetoothDeviceId& device_id) { |
| 204 auto device_iter = connected_devices_.find(device_id); | 204 auto device_iter = connected_devices_.find(device_id); |
| 205 if (device_iter != connected_devices_.end()) { | 205 if (device_iter != connected_devices_.end()) { |
| 206 // Remove device from the map before calling dispatchGattServerDisconnected | 206 // Remove device from the map before calling dispatchGattServerDisconnected |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 // Create an associated interface ptr and pass it to the WebBluetoothService | 322 // Create an associated interface ptr and pass it to the WebBluetoothService |
| 323 // so that it can send us events without us prompting. | 323 // so that it can send us events without us prompting. |
| 324 blink::mojom::WebBluetoothServiceClientAssociatedPtrInfo ptr_info; | 324 blink::mojom::WebBluetoothServiceClientAssociatedPtrInfo ptr_info; |
| 325 binding_.Bind(&ptr_info, web_bluetooth_service_.associated_group()); | 325 binding_.Bind(&ptr_info, web_bluetooth_service_.associated_group()); |
| 326 web_bluetooth_service_->SetClient(std::move(ptr_info)); | 326 web_bluetooth_service_->SetClient(std::move(ptr_info)); |
| 327 } | 327 } |
| 328 return *web_bluetooth_service_; | 328 return *web_bluetooth_service_; |
| 329 } | 329 } |
| 330 | 330 |
| 331 } // namespace content | 331 } // namespace content |
| OLD | NEW |