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

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

Issue 180163009: chrome.bluetooth API improvements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address code review feedback. Created 6 years, 9 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 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
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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 [device_ getServiceRecordForUUID:GetIOBluetoothSDPUUID(service_uuid)]; 209 [device_ getServiceRecordForUUID:GetIOBluetoothSDPUUID(service_uuid)];
208 if (record != nil) { 210 if (record != nil) {
209 BluetoothServiceRecordMac service_record(record); 211 BluetoothServiceRecordMac service_record(record);
210 scoped_refptr<BluetoothSocket> socket( 212 scoped_refptr<BluetoothSocket> socket(
211 BluetoothSocketMac::CreateBluetoothSocket(service_record)); 213 BluetoothSocketMac::CreateBluetoothSocket(service_record));
212 if (socket.get() != NULL) 214 if (socket.get() != NULL)
213 callback.Run(socket); 215 callback.Run(socket);
214 } 216 }
215 } 217 }
216 218
217 void BluetoothDeviceMac::ConnectToProfile( 219 void BluetoothDeviceMac::ConnectToProfile(BluetoothProfile* profile,
218 device::BluetoothProfile* profile, 220 const base::Closure& callback,
219 const base::Closure& callback, 221 const ErrorCallback& error_callback) {
220 const ErrorCallback& error_callback) {
221 if (static_cast<BluetoothProfileMac*>(profile)->Connect(device_)) 222 if (static_cast<BluetoothProfileMac*>(profile)->Connect(device_))
222 callback.Run(); 223 callback.Run();
223 else 224 else
224 error_callback.Run(); 225 error_callback.Run(kFailedToConnect);
225 } 226 }
226 227
227 void BluetoothDeviceMac::SetOutOfBandPairingData( 228 void BluetoothDeviceMac::SetOutOfBandPairingData(
228 const BluetoothOutOfBandPairingData& data, 229 const BluetoothOutOfBandPairingData& data,
229 const base::Closure& callback, 230 const base::Closure& callback,
230 const ErrorCallback& error_callback) { 231 const ErrorCallback& error_callback) {
231 NOTIMPLEMENTED(); 232 NOTIMPLEMENTED();
232 } 233 }
233 234
234 void BluetoothDeviceMac::ClearOutOfBandPairingData( 235 void BluetoothDeviceMac::ClearOutOfBandPairingData(
235 const base::Closure& callback, 236 const base::Closure& callback,
236 const ErrorCallback& error_callback) { 237 const ErrorCallback& error_callback) {
237 NOTIMPLEMENTED(); 238 NOTIMPLEMENTED();
238 } 239 }
239 240
240 } // namespace device 241 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698