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

Unified Diff: device/bluetooth/bluetooth_low_energy_peripheral_delegate.mm

Issue 1948763003: Adding support for service scan on OS X (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cleanup
Patch Set: Fixing comments Created 4 years, 7 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_low_energy_peripheral_delegate.mm
diff --git a/device/bluetooth/bluetooth_low_energy_peripheral_delegate.mm b/device/bluetooth/bluetooth_low_energy_peripheral_delegate.mm
new file mode 100644
index 0000000000000000000000000000000000000000..761442910df3d3a06ea962651309c7000157c47b
--- /dev/null
+++ b/device/bluetooth/bluetooth_low_energy_peripheral_delegate.mm
@@ -0,0 +1,63 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "device/bluetooth/bluetooth_low_energy_peripheral_delegate.h"
+
+#include "device/bluetooth/bluetooth_adapter_mac.h"
+#include "device/bluetooth/bluetooth_low_energy_discovery_manager_mac.h"
+
+namespace device {
+
+// This class exists to bridge between the Objective-C CBPeripheralDelegate
+// class and our BluetoothLowEnergyDiscoveryManagerMac and BluetoothAdapterMac
+// classes.
+class BluetoothLowEnergyPeripheralBridge {
+ public:
+ BluetoothLowEnergyPeripheralBridge(BluetoothLowEnergyDeviceMac* device_mac)
+ : device_mac_(device_mac) {}
+
+ ~BluetoothLowEnergyPeripheralBridge() {}
+
+ void DidModifyServices(NSArray* invalidatedServices) {
+ device_mac_->DidModifyServices(invalidatedServices);
+ }
+
+ void DidDiscoverPrimaryServices(NSError* error) {
+ device_mac_->DidDiscoverPrimaryServices(error);
+ };
+
+ CBPeripheral* GetPeripheral() { return device_mac_->GetPeripheral(); }
+
+ private:
+ BluetoothLowEnergyDeviceMac* device_mac_;
+};
+
+} // namespace device
+
+@implementation BluetoothLowEnergyPeripheralDelegate
+
+- (id)initWithBluetoothLowEnergyDeviceMac:
+ (device::BluetoothLowEnergyDeviceMac*)device_mac {
+ if ((self = [super init])) {
+ bridge_.reset(new device::BluetoothLowEnergyPeripheralBridge(device_mac));
+ }
+ return self;
+}
+
+- (void)dealloc {
+ [bridge_->GetPeripheral() setDelegate:nil];
+ [super dealloc];
+}
+
+- (void)peripheral:(CBPeripheral*)peripheral
+ didModifyServices:(NSArray*)invalidatedServices {
+ bridge_->DidModifyServices(invalidatedServices);
+}
+
+- (void)peripheral:(CBPeripheral*)peripheral
+ didDiscoverServices:(NSError*)error {
+ bridge_->DidDiscoverPrimaryServices(error);
+}
+
+@end
« no previous file with comments | « device/bluetooth/bluetooth_low_energy_peripheral_delegate.h ('k') | device/bluetooth/bluetooth_remote_gatt_service_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698