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

Unified Diff: device/bluetooth/bluetooth_adapter_mac.mm

Issue 1226133006: Move CBCentralManager from the Discovery Manager to Adapter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@adddevs
Patch Set: comment edit Created 5 years, 5 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
« no previous file with comments | « device/bluetooth/bluetooth_adapter_mac.h ('k') | device/bluetooth/bluetooth_adapter_mac_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/bluetooth_adapter_mac.mm
diff --git a/device/bluetooth/bluetooth_adapter_mac.mm b/device/bluetooth/bluetooth_adapter_mac.mm
index b4b2720a616b0f1dab4c23435d5157a8763b6655..0bff39aaa31ee343ca82ef3a1804d6c60391bbe6 100644
--- a/device/bluetooth/bluetooth_adapter_mac.mm
+++ b/device/bluetooth/bluetooth_adapter_mac.mm
@@ -24,6 +24,7 @@
#include "base/time/time.h"
#include "device/bluetooth/bluetooth_classic_device_mac.h"
#include "device/bluetooth/bluetooth_discovery_session.h"
+#include "device/bluetooth/bluetooth_low_energy_central_manager_delegate.h"
#include "device/bluetooth/bluetooth_socket_mac.h"
#include "device/bluetooth/bluetooth_uuid.h"
@@ -60,9 +61,20 @@ BluetoothAdapterMac::BluetoothAdapterMac()
classic_discovery_manager_(
BluetoothDiscoveryManagerMac::CreateClassic(this)),
weak_ptr_factory_(this) {
- if (IsLowEnergyAvailable())
+ if (IsLowEnergyAvailable()) {
low_energy_discovery_manager_.reset(
BluetoothLowEnergyDiscoveryManagerMac::Create(this));
+ low_energy_central_manager_delegate_.reset(
+ [[BluetoothLowEnergyCentralManagerDelegate alloc]
+ initWithDiscoveryManager:low_energy_discovery_manager_.get()
+ andAdapter:this]);
+ Class aClass = NSClassFromString(@"CBCentralManager");
+ low_energy_central_manager_.reset([[aClass alloc]
+ initWithDelegate:low_energy_central_manager_delegate_.get()
+ queue:dispatch_get_main_queue()]);
+ low_energy_discovery_manager_->SetCentralManager(
+ low_energy_central_manager_.get());
+ }
DCHECK(classic_discovery_manager_.get());
}
@@ -439,6 +451,9 @@ void BluetoothAdapterMac::LowEnergyDeviceUpdated(
DeviceChanged(this, device_reference));
}
+// TODO(krstnmnlsn): Implement. crbug.com/511025
+void BluetoothAdapterMac::LowEnergyCentralManagerUpdatedState() {}
+
void BluetoothAdapterMac::RemoveTimedOutDevices() {
// Notify observers if any previously seen devices are no longer available,
// i.e. if they are no longer paired, connected, nor recently discovered via
@@ -474,4 +489,14 @@ void BluetoothAdapterMac::AddPairedDevices() {
}
}
+void BluetoothAdapterMac::SetCentralManagerForTesting(
+ CBCentralManager* central_manager) {
+ CHECK(BluetoothAdapterMac::IsLowEnergyAvailable());
+ [central_manager performSelector:@selector(setDelegate:)
+ withObject:low_energy_central_manager_delegate_];
+ low_energy_central_manager_.reset(central_manager);
+ low_energy_discovery_manager_->SetCentralManager(
+ low_energy_central_manager_.get());
+}
+
} // namespace device
« no previous file with comments | « device/bluetooth/bluetooth_adapter_mac.h ('k') | device/bluetooth/bluetooth_adapter_mac_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698