Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "device/bluetooth/bluetooth_low_energy_device_mac.h" | 5 #include "device/bluetooth/bluetooth_low_energy_device_mac.h" |
| 6 | 6 |
| 7 #import <CoreFoundation/CoreFoundation.h> | 7 #import <CoreFoundation/CoreFoundation.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 346 it != gatt_services_.end(); ++it) { | 346 it != gatt_services_.end(); ++it) { |
| 347 device::BluetoothRemoteGattService* gatt_service = it->second; | 347 device::BluetoothRemoteGattService* gatt_service = it->second; |
| 348 device::BluetoothRemoteGattServiceMac* gatt_service_mac = | 348 device::BluetoothRemoteGattServiceMac* gatt_service_mac = |
| 349 static_cast<BluetoothRemoteGattServiceMac*>(gatt_service); | 349 static_cast<BluetoothRemoteGattServiceMac*>(gatt_service); |
| 350 if (gatt_service_mac->GetService() == cb_service) | 350 if (gatt_service_mac->GetService() == cb_service) |
| 351 return gatt_service_mac; | 351 return gatt_service_mac; |
| 352 } | 352 } |
| 353 return nullptr; | 353 return nullptr; |
| 354 } | 354 } |
| 355 | 355 |
| 356 void BluetoothLowEnergyDeviceMac::DidDisconnectPeripheral( | 356 void BluetoothLowEnergyDeviceMac::DidDisconnectPeripheral(NSError* error) { |
| 357 BluetoothDevice::ConnectErrorCode error_code) { | |
| 358 SetGattServicesDiscoveryComplete(false); | 357 SetGattServicesDiscoveryComplete(false); |
| 359 // Removing all services at once to ensure that calling GetGattService on | 358 // Removing all services at once to ensure that calling GetGattService on |
| 360 // removed service in GattServiceRemoved returns null. | 359 // removed service in GattServiceRemoved returns null. |
| 361 GattServiceMap gatt_services_swapped; | 360 GattServiceMap gatt_services_swapped; |
| 362 gatt_services_swapped.swap(gatt_services_); | 361 gatt_services_swapped.swap(gatt_services_); |
| 363 gatt_services_swapped.clear(); | 362 gatt_services_swapped.clear(); |
| 364 device_uuids_.ClearServiceUUIDs(); | 363 device_uuids_.ClearServiceUUIDs(); |
| 364 // There are two cases in which this function will be called: | |
| 365 // 1. When the connection to the device breaks (either because | |
| 366 // we closed it or the device closed it). | |
| 367 // 2. When we cancel a pending connection request. | |
| 365 if (create_gatt_connection_error_callbacks_.empty()) { | 368 if (create_gatt_connection_error_callbacks_.empty()) { |
| 366 // TODO(http://crbug.com/585897): Need to pass the error. | 369 // If there are no pending callbacks then the connection broke (#1). |
| 367 DidDisconnectGatt(); | 370 DidDisconnectGatt(); |
| 368 } else { | 371 return; |
| 369 DidFailToConnectGatt(error_code); | |
| 370 } | 372 } |
| 373 // Else we canceled the connection request (#2). | |
| 374 // TODO(http://crbug.com/585897): Need to pass the error. | |
| 375 DidFailToConnectGatt(BluetoothDevice::ConnectErrorCode::ERROR_FAILED); | |
|
Jeffrey Yasskin
2016/08/24 23:28:13
I think I've failed to specify this (https://githu
ortuno
2016/08/25 16:39:56
That makes sense. We currently have no error for t
| |
| 371 } | 376 } |
| OLD | NEW |