Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: device/bluetooth/bluetooth_device_mac.mm

Issue 2052513002: Read characteristic implementation on macOS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@characteristicscan_servicescan_cleanup
Patch Set: Test not meant to be commited Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"; 9 static NSString* const kConnectErrorDomain = @"ConnectErrorCode";
10 static NSString* const kGattErrorDomain = @"GattErrorCode";
10 11
11 namespace device { 12 namespace device {
12 13
13 BluetoothDeviceMac::BluetoothDeviceMac(BluetoothAdapterMac* adapter) 14 BluetoothDeviceMac::BluetoothDeviceMac(BluetoothAdapterMac* adapter)
14 : BluetoothDevice(adapter) {} 15 : BluetoothDevice(adapter) {}
15 16
16 BluetoothDeviceMac::~BluetoothDeviceMac() { 17 BluetoothDeviceMac::~BluetoothDeviceMac() {
17 } 18 }
18 19
19 NSError* BluetoothDeviceMac::GetNSErrorFromConnectErrorCode( 20 NSError* BluetoothDeviceMac::GetNSErrorFromConnectErrorCode(
20 BluetoothDevice::ConnectErrorCode error_code) { 21 BluetoothDevice::ConnectErrorCode error_code) {
21 // TODO(http://crbug.com/585894): Need to convert the error. 22 // TODO(http://crbug.com/585894): Need to convert the error.
msarda 2016/06/27 11:52:47 It looks like the error is converted here. Does th
jlebel 2016/06/27 12:09:20 It would be nicer to use a CBError code.
22 return [NSError errorWithDomain:kErrorDomain code:error_code userInfo:nil]; 23 return [NSError errorWithDomain:kConnectErrorDomain
24 code:error_code
25 userInfo:nil];
23 } 26 }
24 27
25 BluetoothDevice::ConnectErrorCode 28 BluetoothDevice::ConnectErrorCode
26 BluetoothDeviceMac::GetConnectErrorCodeFromNSError(NSError* error) { 29 BluetoothDeviceMac::GetConnectErrorCodeFromNSError(NSError* error) {
27 if ([error.domain isEqualToString:kErrorDomain]) { 30 if ([error.domain isEqualToString:kConnectErrorDomain]) {
28 BluetoothDevice::ConnectErrorCode connect_error_code = 31 BluetoothDevice::ConnectErrorCode connect_error_code =
29 (BluetoothDevice::ConnectErrorCode)error.code; 32 (BluetoothDevice::ConnectErrorCode)error.code;
30 if (connect_error_code >= 0 || 33 if (connect_error_code >= 0 ||
31 connect_error_code < BluetoothDevice::NUM_CONNECT_ERROR_CODES) { 34 connect_error_code < BluetoothDevice::NUM_CONNECT_ERROR_CODES) {
32 return connect_error_code; 35 return connect_error_code;
33 } 36 }
34 DCHECK(false); 37 DCHECK(false);
35 return BluetoothDevice::ERROR_FAILED; 38 return BluetoothDevice::ERROR_FAILED;
36 } 39 }
37 // TODO(http://crbug.com/585894): Need to convert the error. 40 // TODO(http://crbug.com/585894): Need to convert the error.
38 return BluetoothDevice::ERROR_FAILED; 41 return BluetoothDevice::ERROR_FAILED;
39 } 42 }
40 43
44 NSError* BluetoothDeviceMac::GetNSErrorFromGattErrorCode(
45 BluetoothGattService::GattErrorCode error_code) {
46 // TODO(http://crbug.com/619595): Need to convert the error.
47 return
48 [NSError errorWithDomain:kGattErrorDomain code:error_code userInfo:nil];
49 }
50
51 BluetoothGattService::GattErrorCode
52 BluetoothDeviceMac::GetGattErrorCodeFromNSError(NSError* error) {
53 if ([error.domain isEqualToString:kGattErrorDomain]) {
54 BluetoothGattService::GattErrorCode gatt_error_code =
55 (BluetoothGattService::GattErrorCode)error.code;
56 if (gatt_error_code >= 0 ||
57 gatt_error_code <= BluetoothGattService::GATT_ERROR_NOT_SUPPORTED) {
58 return gatt_error_code;
59 }
60 DCHECK(false);
msarda 2016/06/27 11:52:47 Use NOTREACHED() (equivalent with DCHECK(false) bu
jlebel 2016/06/27 12:09:20 Done.
61 return BluetoothGattService::GATT_ERROR_FAILED;
62 }
63 // TODO(http://crbug.com/619595): Need to convert the error.
msarda 2016/06/27 11:52:47 I do not understand this TODO. It looks like the e
jlebel 2016/06/27 12:09:20 Updating the comment to: Need to convert the error
64 return BluetoothGattService::GATT_ERROR_FAILED;
65 }
66
41 } // namespace device 67 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698