| 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_profile_mac.h" | 5 #include "device/bluetooth/bluetooth_profile_mac.h" |
| 6 | 6 |
| 7 #import <IOBluetooth/objc/IOBluetoothDevice.h> | 7 #import <IOBluetooth/objc/IOBluetoothDevice.h> |
| 8 #import <IOBluetooth/objc/IOBluetoothSDPServiceRecord.h> | 8 #import <IOBluetooth/objc/IOBluetoothSDPServiceRecord.h> |
| 9 #import <IOBluetooth/objc/IOBluetoothSDPUUID.h> | 9 #import <IOBluetooth/objc/IOBluetoothSDPUUID.h> |
| 10 | 10 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 DCHECK(uuid_bytes_vector.size() == 16); | 39 DCHECK(uuid_bytes_vector.size() == 16); |
| 40 | 40 |
| 41 return [IOBluetoothSDPUUID uuidWithBytes:&uuid_bytes_vector[0] | 41 return [IOBluetoothSDPUUID uuidWithBytes:&uuid_bytes_vector[0] |
| 42 length:uuid_bytes_vector.size()]; | 42 length:uuid_bytes_vector.size()]; |
| 43 } | 43 } |
| 44 | 44 |
| 45 } // namespace | 45 } // namespace |
| 46 | 46 |
| 47 namespace device { | 47 namespace device { |
| 48 | 48 |
| 49 BluetoothProfileMac::BluetoothProfileMac(const BluetoothUUID& uuid, | 49 BluetoothProfileMac::BluetoothProfileMac(const std::string& uuid, |
| 50 const std::string& name) | 50 const std::string& name) |
| 51 : BluetoothProfile(), uuid_(uuid), name_(name) { | 51 : BluetoothProfile(), uuid_(uuid), name_(name) { |
| 52 } | 52 } |
| 53 | 53 |
| 54 BluetoothProfileMac::~BluetoothProfileMac() { | 54 BluetoothProfileMac::~BluetoothProfileMac() { |
| 55 } | 55 } |
| 56 | 56 |
| 57 void BluetoothProfileMac::Unregister() { | 57 void BluetoothProfileMac::Unregister() { |
| 58 delete this; | 58 delete this; |
| 59 } | 59 } |
| 60 | 60 |
| 61 void BluetoothProfileMac::SetConnectionCallback( | 61 void BluetoothProfileMac::SetConnectionCallback( |
| 62 const ConnectionCallback& callback) { | 62 const ConnectionCallback& callback) { |
| 63 connection_callback_ = callback; | 63 connection_callback_ = callback; |
| 64 } | 64 } |
| 65 | 65 |
| 66 bool BluetoothProfileMac::Connect(IOBluetoothDevice* device) { | 66 bool BluetoothProfileMac::Connect(IOBluetoothDevice* device) { |
| 67 if (connection_callback_.is_null()) | 67 if (connection_callback_.is_null()) |
| 68 return false; | 68 return false; |
| 69 | 69 |
| 70 IOBluetoothSDPServiceRecord* record = | 70 IOBluetoothSDPServiceRecord* record = |
| 71 [device getServiceRecordForUUID:GetIOBluetoothSDPUUID( | 71 [device getServiceRecordForUUID:GetIOBluetoothSDPUUID(uuid_)]; |
| 72 uuid_.canonical_value())]; | |
| 73 if (record != nil) { | 72 if (record != nil) { |
| 74 scoped_refptr<BluetoothSocket> socket( | 73 scoped_refptr<BluetoothSocket> socket( |
| 75 BluetoothSocketMac::CreateBluetoothSocket(record)); | 74 BluetoothSocketMac::CreateBluetoothSocket(record)); |
| 76 if (socket.get() != NULL) { | 75 if (socket.get() != NULL) { |
| 77 BluetoothDeviceMac device_mac(device); | 76 BluetoothDeviceMac device_mac(device); |
| 78 connection_callback_.Run(&device_mac, socket); | 77 connection_callback_.Run(&device_mac, socket); |
| 79 return true; | 78 return true; |
| 80 } | 79 } |
| 81 } | 80 } |
| 82 return false; | 81 return false; |
| 83 } | 82 } |
| 84 | 83 |
| 85 } // namespace device | 84 } // namespace device |
| OLD | NEW |