| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/common/bluetooth/bluetooth_device.h" | 5 #include "content/common/bluetooth/bluetooth_device.h" |
| 6 | 6 |
| 7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 | 8 |
| 9 namespace content { | 9 namespace content { |
| 10 | 10 |
| 11 BluetoothDevice::BluetoothDevice() | 11 BluetoothDevice::BluetoothDevice() |
| 12 : id(""), | 12 : id(""), |
| 13 name(base::string16()), | 13 name(base::string16()), |
| 14 tx_power(device::BluetoothDevice::kUnknownPower), | |
| 15 rssi(device::BluetoothDevice::kUnknownPower), | |
| 16 uuids() {} | 14 uuids() {} |
| 17 | 15 |
| 18 BluetoothDevice::BluetoothDevice( | 16 BluetoothDevice::BluetoothDevice( |
| 19 const std::string& id, | 17 const std::string& id, |
| 20 const base::string16& name, | 18 const base::string16& name, |
| 21 int8_t tx_power, | |
| 22 int8_t rssi, | |
| 23 const std::vector<std::string>& uuids) | 19 const std::vector<std::string>& uuids) |
| 24 : id(id), | 20 : id(id), |
| 25 name(name), | 21 name(name), |
| 26 tx_power(tx_power), | |
| 27 rssi(rssi), | |
| 28 uuids(uuids) {} | 22 uuids(uuids) {} |
| 29 | 23 |
| 30 BluetoothDevice::~BluetoothDevice() { | 24 BluetoothDevice::~BluetoothDevice() { |
| 31 } | 25 } |
| 32 | 26 |
| 33 // static | 27 // static |
| 34 std::vector<std::string> BluetoothDevice::UUIDsFromBluetoothUUIDs( | 28 std::vector<std::string> BluetoothDevice::UUIDsFromBluetoothUUIDs( |
| 35 const device::BluetoothDevice::UUIDList& uuid_list) { | 29 const device::BluetoothDevice::UUIDList& uuid_list) { |
| 36 std::vector<std::string> uuids; | 30 std::vector<std::string> uuids; |
| 37 uuids.reserve(uuid_list.size()); | 31 uuids.reserve(uuid_list.size()); |
| 38 for (const auto& it : uuid_list) | 32 for (const auto& it : uuid_list) |
| 39 uuids.push_back(it.canonical_value()); | 33 uuids.push_back(it.canonical_value()); |
| 40 return uuids; | 34 return uuids; |
| 41 } | 35 } |
| 42 | 36 |
| 43 // static | |
| 44 int8_t BluetoothDevice::ValidatePower(int16_t power) { | |
| 45 return ((power < -127) || (power > 127)) ? BluetoothDevice::kUnknownPower | |
| 46 : power; | |
| 47 } | |
| 48 | |
| 49 } // namespace content | 37 } // namespace content |
| OLD | NEW |