Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(681)

Unified Diff: device/bluetooth/bluetooth_adapter_mac.mm

Issue 2253223002: bluetooth: Implement hardware filtering on macOS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: device/bluetooth/bluetooth_adapter_mac.mm
diff --git a/device/bluetooth/bluetooth_adapter_mac.mm b/device/bluetooth/bluetooth_adapter_mac.mm
index dca907ffdeac4f616fb7be80f9b5869985590224..27c96698e3182a400cbf3c0031c32edb0c7f971f 100644
--- a/device/bluetooth/bluetooth_adapter_mac.mm
+++ b/device/bluetooth/bluetooth_adapter_mac.mm
@@ -302,10 +302,23 @@ void BluetoothAdapterMac::RemoveDiscoverySession(
const DiscoverySessionErrorCallback& error_callback) {
DVLOG(1) << __func__;
+ DCHECK(discovery_filter);
+
+ BluetoothTransport transport = discovery_filter->GetTransport();
+
if (num_discovery_sessions_ > 1) {
// There are active sessions other than the one currently being removed.
DCHECK(IsDiscovering());
num_discovery_sessions_--;
+
+ std::set<BluetoothUUID> filter_uuids;
+ discovery_filter->GetUUIDs(filter_uuids);
+
+ if (IsLowEnergyAvailable() && (transport & BLUETOOTH_TRANSPORT_LE)) {
+ low_energy_discovery_manager_->RemoveDiscoveryUUIDs(
+ std::move(filter_uuids));
+ }
+
callback.Run();
return;
}
@@ -316,11 +329,6 @@ void BluetoothAdapterMac::RemoveDiscoverySession(
return;
}
- // Default to dual discovery if |discovery_filter| is NULL.
- BluetoothTransport transport = BLUETOOTH_TRANSPORT_DUAL;
- if (discovery_filter)
- transport = discovery_filter->GetTransport();
-
if (transport & BLUETOOTH_TRANSPORT_CLASSIC) {
if (!classic_discovery_manager_->StopDiscovery()) {
DVLOG(1) << "Failed to stop classic discovery";
@@ -329,6 +337,7 @@ void BluetoothAdapterMac::RemoveDiscoverySession(
return;
}
}
+
if (transport & BLUETOOTH_TRANSPORT_LE) {
if (IsLowEnergyAvailable())
low_energy_discovery_manager_->StopDiscovery();
@@ -349,11 +358,8 @@ void BluetoothAdapterMac::SetDiscoveryFilter(
bool BluetoothAdapterMac::StartDiscovery(
BluetoothDiscoveryFilter* discovery_filter) {
Jeffrey Yasskin 2016/08/23 21:37:04 Similarly here, change the interface's signature i
- // Default to dual discovery if |discovery_filter| is NULL. IOBluetooth seems
- // allow starting low energy and classic discovery at once.
- BluetoothTransport transport = BLUETOOTH_TRANSPORT_DUAL;
- if (discovery_filter)
- transport = discovery_filter->GetTransport();
+ DCHECK(discovery_filter);
+ BluetoothTransport transport = discovery_filter->GetTransport();
if ((transport & BLUETOOTH_TRANSPORT_CLASSIC) &&
!classic_discovery_manager_->IsDiscovering()) {
@@ -367,9 +373,11 @@ bool BluetoothAdapterMac::StartDiscovery(
if (transport & BLUETOOTH_TRANSPORT_LE) {
// Begin a low energy discovery session or update it if one is already
// running.
- if (IsLowEnergyAvailable())
- low_energy_discovery_manager_->StartDiscovery(
- BluetoothDevice::UUIDList());
+ if (IsLowEnergyAvailable()) {
+ std::set<BluetoothUUID> filter_uuids;
+ discovery_filter->GetUUIDs(filter_uuids);
+ low_energy_discovery_manager_->StartDiscovery(std::move(filter_uuids));
+ }
}
return true;
}
« no previous file with comments | « no previous file | device/bluetooth/bluetooth_adapter_mac_unittest.mm » ('j') | device/bluetooth/bluetooth_adapter_mac_unittest.mm » ('J')

Powered by Google App Engine
This is Rietveld 408576698