OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_discovery_filter.h" | 5 #include "device/bluetooth/bluetooth_discovery_filter.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "device/bluetooth/bluetooth_common.h" | 10 #include "device/bluetooth/bluetooth_common.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 | 57 |
58 void BluetoothDiscoveryFilter::SetTransport(BluetoothTransport transport) { | 58 void BluetoothDiscoveryFilter::SetTransport(BluetoothTransport transport) { |
59 DCHECK(transport != BLUETOOTH_TRANSPORT_INVALID); | 59 DCHECK(transport != BLUETOOTH_TRANSPORT_INVALID); |
60 transport_ = transport; | 60 transport_ = transport; |
61 } | 61 } |
62 | 62 |
63 void BluetoothDiscoveryFilter::GetUUIDs( | 63 void BluetoothDiscoveryFilter::GetUUIDs( |
64 std::set<device::BluetoothUUID>& out_uuids) const { | 64 std::set<device::BluetoothUUID>& out_uuids) const { |
65 out_uuids.clear(); | 65 out_uuids.clear(); |
66 | 66 |
67 for (auto* uuid : uuids_) | 67 for (const auto& uuid : uuids_) |
68 out_uuids.insert(*uuid); | 68 out_uuids.insert(uuid); |
69 } | 69 } |
70 | 70 |
71 void BluetoothDiscoveryFilter::AddUUID(const device::BluetoothUUID& uuid) { | 71 void BluetoothDiscoveryFilter::AddUUID(const device::BluetoothUUID& uuid) { |
72 DCHECK(uuid.IsValid()); | 72 DCHECK(uuid.IsValid()); |
73 for (auto* uuid_it : uuids_) { | 73 for (const auto& uuid_it : uuids_) { |
74 if (*uuid_it == uuid) | 74 if (uuid_it == uuid) |
75 return; | 75 return; |
76 } | 76 } |
77 | 77 |
78 uuids_.push_back(new device::BluetoothUUID(uuid)); | 78 uuids_.push_back(uuid); |
79 } | 79 } |
80 | 80 |
81 void BluetoothDiscoveryFilter::CopyFrom( | 81 void BluetoothDiscoveryFilter::CopyFrom( |
82 const BluetoothDiscoveryFilter& filter) { | 82 const BluetoothDiscoveryFilter& filter) { |
83 transport_ = filter.transport_; | 83 transport_ = filter.transport_; |
84 | 84 |
85 if (filter.uuids_.size()) { | 85 if (filter.uuids_.size()) { |
86 for (auto* uuid : filter.uuids_) | 86 for (const auto& uuid : filter.uuids_) |
87 AddUUID(*uuid); | 87 AddUUID(uuid); |
88 } else | 88 } else |
89 uuids_.clear(); | 89 uuids_.clear(); |
90 | 90 |
91 if (filter.rssi_.get()) { | 91 if (filter.rssi_.get()) { |
92 SetRSSI(*filter.rssi_); | 92 SetRSSI(*filter.rssi_); |
93 } else | 93 } else |
94 rssi_.reset(); | 94 rssi_.reset(); |
95 | 95 |
96 if (filter.pathloss_.get()) { | 96 if (filter.pathloss_.get()) { |
97 SetPathloss(*filter.pathloss_); | 97 SetPathloss(*filter.pathloss_); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 | 174 |
175 return true; | 175 return true; |
176 } | 176 } |
177 | 177 |
178 bool BluetoothDiscoveryFilter::IsDefault() const { | 178 bool BluetoothDiscoveryFilter::IsDefault() const { |
179 return !(rssi_.get() || pathloss_.get() || uuids_.size() || | 179 return !(rssi_.get() || pathloss_.get() || uuids_.size() || |
180 transport_ != BLUETOOTH_TRANSPORT_DUAL); | 180 transport_ != BLUETOOTH_TRANSPORT_DUAL); |
181 } | 181 } |
182 | 182 |
183 } // namespace device | 183 } // namespace device |
OLD | NEW |