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::kUnknownPower), |
15 rssi(device::BluetoothDevice::kUnknownPower), | 15 rssi(device::BluetoothDevice::kUnknownPower), |
16 device_class(0), | 16 device_class(0), |
17 vendor_id_source( | 17 vendor_id_source( |
18 device::BluetoothDevice::VendorIDSource::VENDOR_ID_UNKNOWN), | 18 device::BluetoothDevice::VendorIDSource::VENDOR_ID_UNKNOWN), |
19 vendor_id(0), | 19 vendor_id(0), |
20 product_id(0), | 20 product_id(0), |
21 product_version(0), | 21 product_version(0), |
22 paired(false), | |
23 uuids() {} | 22 uuids() {} |
24 | 23 |
25 BluetoothDevice::BluetoothDevice( | 24 BluetoothDevice::BluetoothDevice( |
26 const std::string& id, | 25 const std::string& id, |
27 const base::string16& name, | 26 const base::string16& name, |
28 int8_t tx_power, | 27 int8_t tx_power, |
29 int8_t rssi, | 28 int8_t rssi, |
30 uint32_t device_class, | 29 uint32_t device_class, |
31 device::BluetoothDevice::VendorIDSource vendor_id_source, | 30 device::BluetoothDevice::VendorIDSource vendor_id_source, |
32 uint16_t vendor_id, | 31 uint16_t vendor_id, |
33 uint16_t product_id, | 32 uint16_t product_id, |
34 uint16_t product_version, | 33 uint16_t product_version, |
35 bool paired, | |
36 const std::vector<std::string>& uuids) | 34 const std::vector<std::string>& uuids) |
37 : id(id), | 35 : id(id), |
38 name(name), | 36 name(name), |
39 tx_power(tx_power), | 37 tx_power(tx_power), |
40 rssi(rssi), | 38 rssi(rssi), |
41 device_class(device_class), | 39 device_class(device_class), |
42 vendor_id_source(vendor_id_source), | 40 vendor_id_source(vendor_id_source), |
43 vendor_id(vendor_id), | 41 vendor_id(vendor_id), |
44 product_id(product_id), | 42 product_id(product_id), |
45 product_version(product_version), | 43 product_version(product_version), |
46 paired(paired), | |
47 uuids(uuids) {} | 44 uuids(uuids) {} |
48 | 45 |
49 BluetoothDevice::~BluetoothDevice() { | 46 BluetoothDevice::~BluetoothDevice() { |
50 } | 47 } |
51 | 48 |
52 // static | 49 // static |
53 std::vector<std::string> BluetoothDevice::UUIDsFromBluetoothUUIDs( | 50 std::vector<std::string> BluetoothDevice::UUIDsFromBluetoothUUIDs( |
54 const device::BluetoothDevice::UUIDList& uuid_list) { | 51 const device::BluetoothDevice::UUIDList& uuid_list) { |
55 std::vector<std::string> uuids; | 52 std::vector<std::string> uuids; |
56 uuids.reserve(uuid_list.size()); | 53 uuids.reserve(uuid_list.size()); |
57 for (const auto& it : uuid_list) | 54 for (const auto& it : uuid_list) |
58 uuids.push_back(it.canonical_value()); | 55 uuids.push_back(it.canonical_value()); |
59 return uuids; | 56 return uuids; |
60 } | 57 } |
61 | 58 |
62 // static | 59 // static |
63 int8_t BluetoothDevice::ValidatePower(int16_t power) { | 60 int8_t BluetoothDevice::ValidatePower(int16_t power) { |
64 return ((power < -127) || (power > 127)) ? BluetoothDevice::kUnknownPower | 61 return ((power < -127) || (power > 127)) ? BluetoothDevice::kUnknownPower |
65 : power; | 62 : power; |
66 } | 63 } |
67 | 64 |
68 } // namespace content | 65 } // namespace content |
OLD | NEW |