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

Unified Diff: device/bluetooth/bluetooth_adapter_mac.mm

Issue 1276353005: Planned implementation of CreateGattConnection Base URL: https://chromium.googlesource.com/chromium/src.git@adapimpl-simple
Patch Set: Created 5 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
« 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 bf108eee4c0b52fbb48eab66c3e4a2f1716233a8..d20163e2d0a849f56fce3cb61dfe5aac660e69ad 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_gatt_connection_mac.h"
#include "device/bluetooth/bluetooth_low_energy_central_manager_delegate.h"
#include "device/bluetooth/bluetooth_socket_mac.h"
#include "device/bluetooth/bluetooth_uuid.h"
@@ -460,7 +461,8 @@ void BluetoothAdapterMac::LowEnergyDeviceUpdated(
if (!device_reference) {
// A new device has been found.
device_reference =
- new BluetoothLowEnergyDeviceMac(peripheral, advertisement_data, rssi);
+ new BluetoothLowEnergyDeviceMac(peripheral, advertisement_data, rssi,
+ this, low_energy_central_manager_);
FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_,
DeviceAdded(this, device_reference));
return;
@@ -522,4 +524,63 @@ void BluetoothAdapterMac::AddPairedDevices() {
}
}
+void BluetoothAdapterMac::DidConnectPeripheral(CBPeripheral* peripheral) {
+ std::string address =
+ BluetoothLowEnergyDeviceMac::GetPeripheralHashAddress(peripheral);
+ BluetoothLowEnergyDeviceMac* device =
+ static_cast<BluetoothLowEnergyDeviceMac*>(devices_[address]);
+
+ for (BluetoothDevice::GattConnectionCallback connect_success_callback :
+ device->create_gatt_connection_success_callbacks_) {
+ scoped_ptr<device::BluetoothGattConnection> connection(
+ new BluetoothGattConnectionMac(this, GetAddress()));
+ connect_success_callback.Run(connection.Pass());
+ }
+ for (ErrorCallback disconnect_error_callback :
+ device->disconnect_error_callbacks_) {
+ disconnect_error_callback.Run();
+ }
+ device->ClearConnectionCallbacks();
+}
+
+void BluetoothAdapterMac::DidConnectPeripheralError(CBPeripheral* peripheral,
+ NSError* error) {
+ std::string address =
+ BluetoothLowEnergyDeviceMac::GetPeripheralHashAddress(peripheral);
+ BluetoothLowEnergyDeviceMac* device =
+ static_cast<BluetoothLowEnergyDeviceMac*>(devices_[address]);
+
+ for (BluetoothDevice::ConnectErrorCallback connect_error_callback :
+ device->create_gatt_connection_error_callbacks_) {
+ BluetoothDevice::ConnectErrorCode error_code =
+ BluetoothDevice::ConnectErrorCode::ERROR_UNKNOWN;
+ connect_error_callback.Run(error_code);
+ }
+ for (base::Closure disconnect_success_callback :
+ device->disconnect_success_callbacks_) {
+ disconnect_success_callback.Run();
+ }
+ device->ClearConnectionCallbacks();
+}
+
+void BluetoothAdapterMac::DidDisconnectPeripheral(CBPeripheral* peripheral,
+ NSError* error) {
+ std::string address =
+ BluetoothLowEnergyDeviceMac::GetPeripheralHashAddress(peripheral);
+ BluetoothLowEnergyDeviceMac* device =
+ static_cast<BluetoothLowEnergyDeviceMac*>(devices_[address]);
+
+ for (BluetoothDevice::ConnectErrorCallback connect_error_callback :
+ device->create_gatt_connection_error_callbacks_) {
+ BluetoothDevice::ConnectErrorCode error_code =
+ BluetoothDevice::ConnectErrorCode::ERROR_UNKNOWN;
+ connect_error_callback.Run(error_code);
+ }
+ for (base::Closure disconnect_success_callback :
+ device->disconnect_success_callbacks_) {
+ disconnect_success_callback.Run();
+ }
+ device->ClearConnectionCallbacks();
+}
+
} // 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