OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef DEVICE_BLUETOOTH_CONNECT_RESULT_TYPE_CONVERTER_H_ |
| 6 #define DEVICE_BLUETOOTH_CONNECT_RESULT_TYPE_CONVERTER_H_ |
| 7 |
| 8 #include "device/bluetooth/bluetooth_device.h" |
| 9 #include "device/bluetooth/public/interfaces/adapter.mojom.h" |
| 10 #include "mojo/public/cpp/bindings/type_converter.h" |
| 11 |
| 12 namespace mojo { |
| 13 |
| 14 // TypeConverter to translate from |
| 15 // device::BluetoothDevice::ConnectErrorCode to bluetooth.mojom.ConnectResult. |
| 16 // TODO(crbug.com/666561): Replace because TypeConverter is deprecated. |
| 17 template <> |
| 18 struct TypeConverter<bluetooth::mojom::ConnectResult, |
| 19 device::BluetoothDevice::ConnectErrorCode> { |
| 20 static bluetooth::mojom::ConnectResult Convert( |
| 21 const device::BluetoothDevice::ConnectErrorCode& input) { |
| 22 switch (input) { |
| 23 case device::BluetoothDevice::ConnectErrorCode:: |
| 24 ERROR_ATTRIBUTE_LENGTH_INVALID: |
| 25 return bluetooth::mojom::ConnectResult::ATTRIBUTE_LENGTH_INVALID; |
| 26 case device::BluetoothDevice::ConnectErrorCode::ERROR_AUTH_CANCELED: |
| 27 return bluetooth::mojom::ConnectResult::AUTH_CANCELED; |
| 28 case device::BluetoothDevice::ConnectErrorCode::ERROR_AUTH_FAILED: |
| 29 return bluetooth::mojom::ConnectResult::AUTH_FAILED; |
| 30 case device::BluetoothDevice::ConnectErrorCode::ERROR_AUTH_REJECTED: |
| 31 return bluetooth::mojom::ConnectResult::AUTH_REJECTED; |
| 32 case device::BluetoothDevice::ConnectErrorCode::ERROR_AUTH_TIMEOUT: |
| 33 return bluetooth::mojom::ConnectResult::AUTH_TIMEOUT; |
| 34 case device::BluetoothDevice::ConnectErrorCode:: |
| 35 ERROR_CONNECTION_CONGESTED: |
| 36 return bluetooth::mojom::ConnectResult::CONNECTION_CONGESTED; |
| 37 case device::BluetoothDevice::ConnectErrorCode::ERROR_FAILED: |
| 38 return bluetooth::mojom::ConnectResult::FAILED; |
| 39 case device::BluetoothDevice::ConnectErrorCode::ERROR_INPROGRESS: |
| 40 return bluetooth::mojom::ConnectResult::INPROGRESS; |
| 41 case device::BluetoothDevice::ConnectErrorCode:: |
| 42 ERROR_INSUFFICIENT_ENCRYPTION: |
| 43 return bluetooth::mojom::ConnectResult::INSUFFICIENT_ENCRYPTION; |
| 44 case device::BluetoothDevice::ConnectErrorCode::ERROR_OFFSET_INVALID: |
| 45 return bluetooth::mojom::ConnectResult::OFFSET_INVALID; |
| 46 case device::BluetoothDevice::ConnectErrorCode::ERROR_READ_NOT_PERMITTED: |
| 47 return bluetooth::mojom::ConnectResult::READ_NOT_PERMITTED; |
| 48 case device::BluetoothDevice::ConnectErrorCode:: |
| 49 ERROR_REQUEST_NOT_SUPPORTED: |
| 50 return bluetooth::mojom::ConnectResult::REQUEST_NOT_SUPPORTED; |
| 51 case device::BluetoothDevice::ConnectErrorCode::ERROR_UNKNOWN: |
| 52 return bluetooth::mojom::ConnectResult::UNKNOWN; |
| 53 case device::BluetoothDevice::ConnectErrorCode::ERROR_UNSUPPORTED_DEVICE: |
| 54 return bluetooth::mojom::ConnectResult::UNSUPPORTED_DEVICE; |
| 55 case device::BluetoothDevice::ConnectErrorCode::ERROR_WRITE_NOT_PERMITTED: |
| 56 return bluetooth::mojom::ConnectResult::WRITE_NOT_PERMITTED; |
| 57 case device::BluetoothDevice::ConnectErrorCode::NUM_CONNECT_ERROR_CODES: |
| 58 NOTREACHED(); |
| 59 return bluetooth::mojom::ConnectResult::UNTRANSLATED_CONNECT_ERROR_CODE; |
| 60 } |
| 61 NOTREACHED(); |
| 62 return bluetooth::mojom::ConnectResult::UNTRANSLATED_CONNECT_ERROR_CODE; |
| 63 } |
| 64 }; |
| 65 } |
| 66 |
| 67 #endif // DEVICE_BLUETOOTH_CONNECT_RESULT_TYPE_CONVERTER_H_ |
OLD | NEW |