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

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

Issue 13416005: Bluetooth: clean up BluetoothDevice (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More win visible fixes Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « device/bluetooth/bluetooth_device_mac.h ('k') | device/bluetooth/bluetooth_device_win.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 10
(...skipping 22 matching lines...) Expand all
33 33
34 namespace device { 34 namespace device {
35 35
36 BluetoothDeviceMac::BluetoothDeviceMac(const IOBluetoothDevice* device) 36 BluetoothDeviceMac::BluetoothDeviceMac(const IOBluetoothDevice* device)
37 : BluetoothDevice(), 37 : BluetoothDevice(),
38 device_fingerprint_(ComputeDeviceFingerprint(device)) { 38 device_fingerprint_(ComputeDeviceFingerprint(device)) {
39 name_ = base::SysNSStringToUTF8([device name]); 39 name_ = base::SysNSStringToUTF8([device name]);
40 address_ = base::SysNSStringToUTF8([device addressString]); 40 address_ = base::SysNSStringToUTF8([device addressString]);
41 bluetooth_class_ = [device classOfDevice]; 41 bluetooth_class_ = [device classOfDevice];
42 connected_ = [device isConnected]; 42 connected_ = [device isConnected];
43 bonded_ = [device isPaired]; 43 paired_ = [device isPaired];
44 visible_ = true;
45 44
46 for (IOBluetoothSDPServiceRecord* service in [device services]) { 45 for (IOBluetoothSDPServiceRecord* service in [device services]) {
47 BluetoothServiceRecord* service_record = 46 BluetoothServiceRecord* service_record =
48 new BluetoothServiceRecordMac(service); 47 new BluetoothServiceRecordMac(service);
49 service_record_list_.push_back(service_record); 48 service_record_list_.push_back(service_record);
50 service_uuids_.push_back(service_record->uuid()); 49 service_uuids_.push_back(service_record->uuid());
51 } 50 }
52 } 51 }
53 52
54 BluetoothDeviceMac::~BluetoothDeviceMac() { 53 BluetoothDeviceMac::~BluetoothDeviceMac() {
55 } 54 }
56 55
57 bool BluetoothDeviceMac::IsPaired() const { 56 uint32 BluetoothDeviceMac::GetBluetoothClass() const {
58 return bonded_; 57 return bluetooth_class_;
59 } 58 }
60 59
61 const BluetoothDevice::ServiceList& BluetoothDeviceMac::GetServices() const { 60 std::string BluetoothDeviceMac::GetDeviceName() const {
61 return name_;
62 }
63
64 std::string BluetoothDeviceMac::GetAddress() const {
65 return address_;
66 }
67
68 bool BluetoothDeviceMac::IsPaired() const {
69 return paired_;
70 }
71
72 bool BluetoothDeviceMac::IsConnected() const {
73 return connected_;
74 }
75
76 bool BluetoothDeviceMac::IsConnectable() const {
77 return false;
78 }
79
80 bool BluetoothDeviceMac::IsConnecting() const {
81 return false;
82 }
83
84 BluetoothDevice::ServiceList BluetoothDeviceMac::GetServices() const {
62 return service_uuids_; 85 return service_uuids_;
63 } 86 }
64 87
65 void BluetoothDeviceMac::GetServiceRecords( 88 void BluetoothDeviceMac::GetServiceRecords(
66 const ServiceRecordsCallback& callback, 89 const ServiceRecordsCallback& callback,
67 const ErrorCallback& error_callback) { 90 const ErrorCallback& error_callback) {
68 callback.Run(service_record_list_); 91 callback.Run(service_record_list_);
69 } 92 }
70 93
71 void BluetoothDeviceMac::ProvidesServiceWithName( 94 void BluetoothDeviceMac::ProvidesServiceWithName(
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 &device_string, 203 &device_string,
181 "|%s|%lu", 204 "|%s|%lu",
182 base::SysNSStringToUTF8([record getServiceName]).c_str(), 205 base::SysNSStringToUTF8([record getServiceName]).c_str(),
183 static_cast<unsigned long>([[record attributes] count])); 206 static_cast<unsigned long>([[record attributes] count]));
184 } 207 }
185 208
186 return base::Hash(device_string); 209 return base::Hash(device_string);
187 } 210 }
188 211
189 } // namespace device 212 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_device_mac.h ('k') | device/bluetooth/bluetooth_device_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698