OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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_GATT_RESULT_TYPE_CONVERTER_H_ |
| 6 #define DEVICE_BLUETOOTH_GATT_RESULT_TYPE_CONVERTER_H_ |
| 7 |
| 8 #include "device/bluetooth/bluetooth_gatt_service.h" |
| 9 #include "device/bluetooth/public/interfaces/device.mojom.h" |
| 10 #include "mojo/public/cpp/bindings/type_converter.h" |
| 11 |
| 12 namespace mojo { |
| 13 |
| 14 // TypeConverter to translate from |
| 15 // device::BluetoothGattService::GattErrorCode to bluetooth.mojom.GattResult. |
| 16 // TODO(crbug.com/666561): Replace because TypeConverter is deprecated. |
| 17 // This TypeConverter is needed to work around the fact that the Mojo enum, |
| 18 // GattResult, has more values than the C++ enum, GattErrorCode. |
| 19 template <> |
| 20 struct TypeConverter<bluetooth::mojom::GattResult, |
| 21 device::BluetoothGattService::GattErrorCode> { |
| 22 static bluetooth::mojom::GattResult Convert( |
| 23 const device::BluetoothGattService::GattErrorCode& input) { |
| 24 switch (input) { |
| 25 case device::BluetoothGattService::GattErrorCode::GATT_ERROR_UNKNOWN: |
| 26 return bluetooth::mojom::GattResult::UNKNOWN; |
| 27 case device::BluetoothGattService::GattErrorCode::GATT_ERROR_FAILED: |
| 28 return bluetooth::mojom::GattResult::FAILED; |
| 29 case device::BluetoothGattService::GattErrorCode::GATT_ERROR_IN_PROGRESS: |
| 30 return bluetooth::mojom::GattResult::IN_PROGRESS; |
| 31 case device::BluetoothGattService::GattErrorCode:: |
| 32 GATT_ERROR_INVALID_LENGTH: |
| 33 return bluetooth::mojom::GattResult::INVALID_LENGTH; |
| 34 case device::BluetoothGattService::GattErrorCode:: |
| 35 GATT_ERROR_NOT_PERMITTED: |
| 36 return bluetooth::mojom::GattResult::NOT_PERMITTED; |
| 37 case device::BluetoothGattService::GattErrorCode:: |
| 38 GATT_ERROR_NOT_AUTHORIZED: |
| 39 return bluetooth::mojom::GattResult::NOT_AUTHORIZED; |
| 40 case device::BluetoothGattService::GattErrorCode::GATT_ERROR_NOT_PAIRED: |
| 41 return bluetooth::mojom::GattResult::NOT_PAIRED; |
| 42 case device::BluetoothGattService::GattErrorCode:: |
| 43 GATT_ERROR_NOT_SUPPORTED: |
| 44 return bluetooth::mojom::GattResult::NOT_SUPPORTED; |
| 45 } |
| 46 NOTREACHED(); |
| 47 return bluetooth::mojom::GattResult::NOT_SUPPORTED; |
| 48 } |
| 49 }; |
| 50 } |
| 51 |
| 52 #endif // DEVICE_BLUETOOTH_GATT_RESULT_TYPE_CONVERTER_H_ |
OLD | NEW |