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), | 14 tx_power(device::BluetoothDevice::kUnknownTxPower), |
15 rssi(device::BluetoothDevice::kUnknownPower), | 15 rssi(device::BluetoothDevice::kUnknownRSSI), |
16 uuids() {} | 16 uuids() {} |
17 | 17 |
18 BluetoothDevice::BluetoothDevice( | 18 BluetoothDevice::BluetoothDevice( |
19 const std::string& id, | 19 const std::string& id, |
20 const base::string16& name, | 20 const base::string16& name, |
21 int8_t tx_power, | 21 int8_t tx_power, |
22 int8_t rssi, | 22 int8_t rssi, |
23 const std::vector<std::string>& uuids) | 23 const std::vector<std::string>& uuids) |
24 : id(id), | 24 : id(id), |
25 name(name), | 25 name(name), |
26 tx_power(tx_power), | 26 tx_power(tx_power), |
27 rssi(rssi), | 27 rssi(rssi), |
28 uuids(uuids) {} | 28 uuids(uuids) {} |
29 | 29 |
30 BluetoothDevice::~BluetoothDevice() { | 30 BluetoothDevice::~BluetoothDevice() { |
31 } | 31 } |
32 | 32 |
33 // static | 33 // static |
34 std::vector<std::string> BluetoothDevice::UUIDsFromBluetoothUUIDs( | 34 std::vector<std::string> BluetoothDevice::UUIDsFromBluetoothUUIDs( |
35 const device::BluetoothDevice::UUIDList& uuid_list) { | 35 const device::BluetoothDevice::UUIDList& uuid_list) { |
36 std::vector<std::string> uuids; | 36 std::vector<std::string> uuids; |
37 uuids.reserve(uuid_list.size()); | 37 uuids.reserve(uuid_list.size()); |
38 for (const auto& it : uuid_list) | 38 for (const auto& it : uuid_list) |
39 uuids.push_back(it.canonical_value()); | 39 uuids.push_back(it.canonical_value()); |
40 return uuids; | 40 return uuids; |
41 } | 41 } |
42 | 42 |
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 | 43 } // namespace content |
OLD | NEW |