| 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 <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "device/bluetooth/bluetooth_types.h" |
| 10 |
| 9 namespace device { | 11 namespace device { |
| 10 | 12 |
| 11 BluetoothDiscoveryFilter::BluetoothDiscoveryFilter(TransportMask transport) { | 13 BluetoothDiscoveryFilter::BluetoothDiscoveryFilter(TransportMask transport) { |
| 12 SetTransport(transport); | 14 SetTransport(transport); |
| 13 } | 15 } |
| 14 | 16 |
| 15 BluetoothDiscoveryFilter::~BluetoothDiscoveryFilter() { | 17 BluetoothDiscoveryFilter::~BluetoothDiscoveryFilter() { |
| 16 } | 18 } |
| 17 | 19 |
| 18 bool BluetoothDiscoveryFilter::GetRSSI(int16_t* out_rssi) const { | 20 bool BluetoothDiscoveryFilter::GetRSSI(int16_t* out_rssi) const { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 std::unique_ptr<device::BluetoothDiscoveryFilter> | 101 std::unique_ptr<device::BluetoothDiscoveryFilter> |
| 100 BluetoothDiscoveryFilter::Merge( | 102 BluetoothDiscoveryFilter::Merge( |
| 101 const device::BluetoothDiscoveryFilter* filter_a, | 103 const device::BluetoothDiscoveryFilter* filter_a, |
| 102 const device::BluetoothDiscoveryFilter* filter_b) { | 104 const device::BluetoothDiscoveryFilter* filter_b) { |
| 103 std::unique_ptr<BluetoothDiscoveryFilter> result; | 105 std::unique_ptr<BluetoothDiscoveryFilter> result; |
| 104 | 106 |
| 105 if (!filter_a && !filter_b) { | 107 if (!filter_a && !filter_b) { |
| 106 return result; | 108 return result; |
| 107 } | 109 } |
| 108 | 110 |
| 109 result.reset(new BluetoothDiscoveryFilter(Transport::TRANSPORT_DUAL)); | 111 result.reset( |
| 112 new BluetoothDiscoveryFilter(BluetoothTransport::TRANSPORT_DUAL)); |
| 110 | 113 |
| 111 if (!filter_a || !filter_b || filter_a->IsDefault() || | 114 if (!filter_a || !filter_b || filter_a->IsDefault() || |
| 112 filter_b->IsDefault()) { | 115 filter_b->IsDefault()) { |
| 113 return result; | 116 return result; |
| 114 } | 117 } |
| 115 | 118 |
| 116 // both filters are not empty, so they must have transport set. | 119 // both filters are not empty, so they must have transport set. |
| 117 result->SetTransport(filter_a->transport_ | filter_b->transport_); | 120 result->SetTransport(filter_a->transport_ | filter_b->transport_); |
| 118 | 121 |
| 119 // if both filters have uuids, them merge them. Otherwise uuids filter should | 122 // if both filters have uuids, them merge them. Otherwise uuids filter should |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 GetUUIDs(uuids_a); | 169 GetUUIDs(uuids_a); |
| 167 other.GetUUIDs(uuids_b); | 170 other.GetUUIDs(uuids_b); |
| 168 if (uuids_a != uuids_b) | 171 if (uuids_a != uuids_b) |
| 169 return false; | 172 return false; |
| 170 | 173 |
| 171 return true; | 174 return true; |
| 172 } | 175 } |
| 173 | 176 |
| 174 bool BluetoothDiscoveryFilter::IsDefault() const { | 177 bool BluetoothDiscoveryFilter::IsDefault() const { |
| 175 return !(rssi_.get() || pathloss_.get() || uuids_.size() || | 178 return !(rssi_.get() || pathloss_.get() || uuids_.size() || |
| 176 transport_ != Transport::TRANSPORT_DUAL); | 179 transport_ != BluetoothTransport::TRANSPORT_DUAL); |
| 177 } | 180 } |
| 178 | 181 |
| 179 } // namespace device | 182 } // namespace device |
| OLD | NEW |