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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 if (record != nil) { | 188 if (record != nil) { |
187 BluetoothServiceRecordMac service_record(record); | 189 BluetoothServiceRecordMac service_record(record); |
188 scoped_refptr<BluetoothSocket> socket( | 190 scoped_refptr<BluetoothSocket> socket( |
189 BluetoothSocketMac::CreateBluetoothSocket(service_record)); | 191 BluetoothSocketMac::CreateBluetoothSocket(service_record)); |
190 if (socket.get() != NULL) | 192 if (socket.get() != NULL) |
191 callback.Run(socket); | 193 callback.Run(socket); |
192 } | 194 } |
193 } | 195 } |
194 | 196 |
195 void BluetoothDeviceMac::ConnectToProfile( | 197 void BluetoothDeviceMac::ConnectToProfile( |
196 device::BluetoothProfile* profile, | 198 BluetoothProfile* profile, |
197 const base::Closure& callback, | 199 const base::Closure& callback, |
198 const ErrorCallback& error_callback) { | 200 const ConnectToProfileErrorCallback& error_callback) { |
199 if (static_cast<BluetoothProfileMac*>(profile)->Connect(device_)) | 201 if (static_cast<BluetoothProfileMac*>(profile)->Connect(device_)) |
200 callback.Run(); | 202 callback.Run(); |
201 else | 203 else |
202 error_callback.Run(); | 204 error_callback.Run(kFailedToConnect); |
203 } | 205 } |
204 | 206 |
205 void BluetoothDeviceMac::SetOutOfBandPairingData( | 207 void BluetoothDeviceMac::SetOutOfBandPairingData( |
206 const BluetoothOutOfBandPairingData& data, | 208 const BluetoothOutOfBandPairingData& data, |
207 const base::Closure& callback, | 209 const base::Closure& callback, |
208 const ErrorCallback& error_callback) { | 210 const ErrorCallback& error_callback) { |
209 NOTIMPLEMENTED(); | 211 NOTIMPLEMENTED(); |
210 } | 212 } |
211 | 213 |
212 void BluetoothDeviceMac::ClearOutOfBandPairingData( | 214 void BluetoothDeviceMac::ClearOutOfBandPairingData( |
213 const base::Closure& callback, | 215 const base::Closure& callback, |
214 const ErrorCallback& error_callback) { | 216 const ErrorCallback& error_callback) { |
215 NOTIMPLEMENTED(); | 217 NOTIMPLEMENTED(); |
216 } | 218 } |
217 | 219 |
218 } // namespace device | 220 } // namespace device |
OLD | NEW |