OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <IOBluetooth/Bluetooth.h> | 7 #include <IOBluetooth/Bluetooth.h> |
8 #import <IOBluetooth/objc/IOBluetoothDevice.h> | 8 #import <IOBluetooth/objc/IOBluetoothDevice.h> |
9 #import <IOBluetooth/objc/IOBluetoothSDPServiceRecord.h> | 9 #import <IOBluetooth/objc/IOBluetoothSDPServiceRecord.h> |
10 #import <IOBluetooth/objc/IOBluetoothSDPUUID.h> | 10 #import <IOBluetooth/objc/IOBluetoothSDPUUID.h> |
(...skipping 18 matching lines...) Expand all Loading... |
29 - (NSString*)addressString; | 29 - (NSString*)addressString; |
30 - (NSString*)name; | 30 - (NSString*)name; |
31 - (unsigned int)classOfDevice; | 31 - (unsigned int)classOfDevice; |
32 - (NSArray*)services; | 32 - (NSArray*)services; |
33 @end | 33 @end |
34 | 34 |
35 #endif // MAC_OS_X_VERSION_10_7 | 35 #endif // MAC_OS_X_VERSION_10_7 |
36 | 36 |
37 namespace { | 37 namespace { |
38 | 38 |
| 39 const char kFailedToConnect[] = "Connection failed"; |
| 40 |
39 // Converts |uuid| to a IOBluetoothSDPUUID instance. | 41 // Converts |uuid| to a IOBluetoothSDPUUID instance. |
40 // | 42 // |
41 // |uuid| must be in the format of XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX. | 43 // |uuid| must be in the format of XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX. |
42 IOBluetoothSDPUUID* GetIOBluetoothSDPUUID(const std::string& uuid) { | 44 IOBluetoothSDPUUID* GetIOBluetoothSDPUUID(const std::string& uuid) { |
43 DCHECK(uuid.size() == 36); | 45 DCHECK(uuid.size() == 36); |
44 DCHECK(uuid[8] == '-'); | 46 DCHECK(uuid[8] == '-'); |
45 DCHECK(uuid[13] == '-'); | 47 DCHECK(uuid[13] == '-'); |
46 DCHECK(uuid[18] == '-'); | 48 DCHECK(uuid[18] == '-'); |
47 DCHECK(uuid[23] == '-'); | 49 DCHECK(uuid[23] == '-'); |
48 std::string numbers_only = uuid; | 50 std::string numbers_only = uuid; |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 if (record != nil) { | 189 if (record != nil) { |
188 BluetoothServiceRecordMac service_record(record); | 190 BluetoothServiceRecordMac service_record(record); |
189 scoped_refptr<BluetoothSocket> socket( | 191 scoped_refptr<BluetoothSocket> socket( |
190 BluetoothSocketMac::CreateBluetoothSocket(service_record)); | 192 BluetoothSocketMac::CreateBluetoothSocket(service_record)); |
191 if (socket.get() != NULL) | 193 if (socket.get() != NULL) |
192 callback.Run(socket); | 194 callback.Run(socket); |
193 } | 195 } |
194 } | 196 } |
195 | 197 |
196 void BluetoothDeviceMac::ConnectToProfile( | 198 void BluetoothDeviceMac::ConnectToProfile( |
197 device::BluetoothProfile* profile, | 199 BluetoothProfile* profile, |
198 const base::Closure& callback, | 200 const base::Closure& callback, |
199 const ErrorCallback& error_callback) { | 201 const ConnectToProfileErrorCallback& error_callback) { |
200 if (static_cast<BluetoothProfileMac*>(profile)->Connect(device_)) | 202 if (static_cast<BluetoothProfileMac*>(profile)->Connect(device_)) |
201 callback.Run(); | 203 callback.Run(); |
202 else | 204 else |
203 error_callback.Run(); | 205 error_callback.Run(kFailedToConnect); |
204 } | 206 } |
205 | 207 |
206 void BluetoothDeviceMac::SetOutOfBandPairingData( | 208 void BluetoothDeviceMac::SetOutOfBandPairingData( |
207 const BluetoothOutOfBandPairingData& data, | 209 const BluetoothOutOfBandPairingData& data, |
208 const base::Closure& callback, | 210 const base::Closure& callback, |
209 const ErrorCallback& error_callback) { | 211 const ErrorCallback& error_callback) { |
210 NOTIMPLEMENTED(); | 212 NOTIMPLEMENTED(); |
211 } | 213 } |
212 | 214 |
213 void BluetoothDeviceMac::ClearOutOfBandPairingData( | 215 void BluetoothDeviceMac::ClearOutOfBandPairingData( |
214 const base::Closure& callback, | 216 const base::Closure& callback, |
215 const ErrorCallback& error_callback) { | 217 const ErrorCallback& error_callback) { |
216 NOTIMPLEMENTED(); | 218 NOTIMPLEMENTED(); |
217 } | 219 } |
218 | 220 |
219 } // namespace device | 221 } // namespace device |
OLD | NEW |