OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "device/bluetooth/bluetooth_device_mac.h" | 5 #include "device/bluetooth/bluetooth_device_mac.h" |
6 | 6 |
7 #include "device/bluetooth/bluetooth_adapter_mac.h" | 7 #include "device/bluetooth/bluetooth_adapter_mac.h" |
8 | 8 |
| 9 static NSString* const kErrorDomain = @"ConnectErrorCode"; |
| 10 |
9 namespace device { | 11 namespace device { |
10 | 12 |
11 BluetoothDeviceMac::BluetoothDeviceMac(BluetoothAdapterMac* adapter) | 13 BluetoothDeviceMac::BluetoothDeviceMac(BluetoothAdapterMac* adapter) |
12 : BluetoothDevice(adapter) {} | 14 : BluetoothDevice(adapter) {} |
13 | 15 |
14 BluetoothDeviceMac::~BluetoothDeviceMac() { | 16 BluetoothDeviceMac::~BluetoothDeviceMac() { |
15 } | 17 } |
16 | 18 |
| 19 NSError* BluetoothDeviceMac::GetNSErrorFromConnectErrorCode( |
| 20 BluetoothDevice::ConnectErrorCode error_code) { |
| 21 // TODO(http://crbug.com/585894): Need to convert the error. |
| 22 return [NSError errorWithDomain:kErrorDomain code:error_code userInfo:nil]; |
| 23 } |
| 24 |
| 25 BluetoothDevice::ConnectErrorCode |
| 26 BluetoothDeviceMac::GetConnectErrorCodeFromNSError(NSError* error) { |
| 27 if ([error.domain isEqualToString:kErrorDomain]) { |
| 28 BluetoothDevice::ConnectErrorCode connect_error_code = |
| 29 (BluetoothDevice::ConnectErrorCode)error.code; |
| 30 if (connect_error_code >= 0 || |
| 31 connect_error_code < BluetoothDevice::NUM_CONNECT_ERROR_CODES) { |
| 32 return connect_error_code; |
| 33 } |
| 34 DCHECK(false); |
| 35 return BluetoothDevice::ERROR_FAILED; |
| 36 } |
| 37 // TODO(http://crbug.com/585894): Need to convert the error. |
| 38 return BluetoothDevice::ERROR_FAILED; |
| 39 } |
| 40 |
17 } // namespace device | 41 } // namespace device |
OLD | NEW |