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

Unified Diff: device/bluetooth/bluetooth_adapter_mac.mm

Issue 12929003: Implemented BluetoothAdapterMac::AddDevices(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DeviceRemoved obsolete in OSX. Created 7 years, 9 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 5d964ccbf9f31fa7d3a9fe2329d61d9b048aef20..ed37a4a4ba40e4c45ea3e92591933e3c2455caca 100644
--- a/device/bluetooth/bluetooth_adapter_mac.mm
+++ b/device/bluetooth/bluetooth_adapter_mac.mm
@@ -4,7 +4,8 @@
#include "device/bluetooth/bluetooth_adapter_mac.h"
-#include <IOBluetooth/objc/IOBluetoothHostController.h>
+#import <IOBluetooth/objc/IOBluetoothDevice.h>
+#import <IOBluetooth/objc/IOBluetoothHostController.h>
#include <string>
@@ -16,6 +17,7 @@
#include "base/thread_task_runner_handle.h"
#include "base/time.h"
#include "base/strings/sys_string_conversions.h"
+#include "device/bluetooth/bluetooth_device_mac.h"
// Replicate specific 10.7 SDK declarations for building with prior SDKs.
#if !defined(MAC_OS_X_VERSION_10_7) || \
@@ -133,6 +135,8 @@ void BluetoothAdapterMac::PollAdapter() {
AdapterPoweredChanged(this, powered_));
}
+ UpdateDevices([IOBluetoothDevice recentDevices:0]);
+
ui_task_runner_->PostDelayedTask(
FROM_HERE,
base::Bind(&BluetoothAdapterMac::PollAdapter,
@@ -140,4 +144,28 @@ void BluetoothAdapterMac::PollAdapter() {
base::TimeDelta::FromMilliseconds(kPollIntervalMs));
}
+void BluetoothAdapterMac::UpdateDevices(NSArray* devices) {
+ for (IOBluetoothDevice* device in devices) {
+ std::string device_address =
+ base::SysNSStringToUTF8([device addressString]);
+ DevicesMap::iterator found_device_iter = devices_.find(device_address);
+
+ if (found_device_iter == devices_.end()) {
+ devices_[device_address] = new BluetoothDeviceMac(device);
+ FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_,
+ DeviceAdded(this, devices_[device_address]));
+ continue;
+ }
+ BluetoothDeviceMac* device_mac =
+ static_cast<BluetoothDeviceMac*>(found_device_iter->second);
+ if (device_mac->device_fingerprint() !=
+ BluetoothDeviceMac::ComputeDeviceFingerprint(device)) {
+ devices_[device_address] = new BluetoothDeviceMac(device);
+ FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_,
+ DeviceChanged(this, devices_[device_address]));
+ delete device_mac;
+ }
+ }
+}
+
} // namespace device

Powered by Google App Engine
This is Rietveld 408576698