OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_adapter.h" | 5 #include "device/bluetooth/bluetooth_adapter.h" |
6 | 6 |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "device/bluetooth/bluetooth_device.h" | 8 #include "device/bluetooth/bluetooth_device.h" |
9 | 9 |
10 namespace device { | 10 namespace device { |
11 | 11 |
12 BluetoothAdapter::BluetoothAdapter() { | 12 BluetoothAdapter::BluetoothAdapter() { |
13 } | 13 } |
14 | 14 |
15 BluetoothAdapter::~BluetoothAdapter() { | 15 BluetoothAdapter::~BluetoothAdapter() { |
16 STLDeleteValues(&devices_); | 16 STLDeleteValues(&devices_); |
17 } | 17 } |
18 | 18 |
19 const std::string& BluetoothAdapter::address() const { | |
20 return address_; | |
21 } | |
22 | |
23 const std::string& BluetoothAdapter::name() const { | |
24 return name_; | |
25 } | |
26 | |
27 BluetoothAdapter::DeviceList BluetoothAdapter::GetDevices() { | 19 BluetoothAdapter::DeviceList BluetoothAdapter::GetDevices() { |
28 ConstDeviceList const_devices = | 20 ConstDeviceList const_devices = |
29 const_cast<const BluetoothAdapter *>(this)->GetDevices(); | 21 const_cast<const BluetoothAdapter *>(this)->GetDevices(); |
30 | 22 |
31 DeviceList devices; | 23 DeviceList devices; |
32 for (ConstDeviceList::const_iterator i = const_devices.begin(); | 24 for (ConstDeviceList::const_iterator i = const_devices.begin(); |
33 i != const_devices.end(); ++i) | 25 i != const_devices.end(); ++i) |
34 devices.push_back(const_cast<BluetoothDevice *>(*i)); | 26 devices.push_back(const_cast<BluetoothDevice *>(*i)); |
35 | 27 |
36 return devices; | 28 return devices; |
(...skipping 17 matching lines...) Expand all Loading... |
54 const BluetoothDevice* BluetoothAdapter::GetDevice( | 46 const BluetoothDevice* BluetoothAdapter::GetDevice( |
55 const std::string& address) const { | 47 const std::string& address) const { |
56 DevicesMap::const_iterator iter = devices_.find(address); | 48 DevicesMap::const_iterator iter = devices_.find(address); |
57 if (iter != devices_.end()) | 49 if (iter != devices_.end()) |
58 return iter->second; | 50 return iter->second; |
59 | 51 |
60 return NULL; | 52 return NULL; |
61 } | 53 } |
62 | 54 |
63 } // namespace device | 55 } // namespace device |
OLD | NEW |