| 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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 it != gatt_services_.end(); ++it) { | 383 it != gatt_services_.end(); ++it) { |
| 384 device::BluetoothRemoteGattService* gatt_service = it->second; | 384 device::BluetoothRemoteGattService* gatt_service = it->second; |
| 385 device::BluetoothRemoteGattServiceMac* gatt_service_mac = | 385 device::BluetoothRemoteGattServiceMac* gatt_service_mac = |
| 386 static_cast<BluetoothRemoteGattServiceMac*>(gatt_service); | 386 static_cast<BluetoothRemoteGattServiceMac*>(gatt_service); |
| 387 if (gatt_service_mac->GetService() == cb_service) | 387 if (gatt_service_mac->GetService() == cb_service) |
| 388 return gatt_service_mac; | 388 return gatt_service_mac; |
| 389 } | 389 } |
| 390 return nullptr; | 390 return nullptr; |
| 391 } | 391 } |
| 392 | 392 |
| 393 void BluetoothLowEnergyDeviceMac::DidDisconnectPeripheral() { | 393 void BluetoothLowEnergyDeviceMac::DidDisconnectPeripheral( |
| 394 BluetoothDevice::ConnectErrorCode error_code) { |
| 394 SetGattServicesDiscoveryComplete(false); | 395 SetGattServicesDiscoveryComplete(false); |
| 395 // Removing all services at once to ensure that calling GetGattService on | 396 // Removing all services at once to ensure that calling GetGattService on |
| 396 // removed service in GattServiceRemoved returns null. | 397 // removed service in GattServiceRemoved returns null. |
| 397 GattServiceMap gatt_services_swapped; | 398 GattServiceMap gatt_services_swapped; |
| 398 gatt_services_swapped.swap(gatt_services_); | 399 gatt_services_swapped.swap(gatt_services_); |
| 399 gatt_services_swapped.clear(); | 400 gatt_services_swapped.clear(); |
| 400 DCHECK(create_gatt_connection_error_callbacks_.empty()); | 401 if (create_gatt_connection_error_callbacks_.empty()) { |
| 401 DidDisconnectGatt(); | 402 // TODO(http://crbug.com/585897): Need to pass the error. |
| 403 DidDisconnectGatt(); |
| 404 } else { |
| 405 DidFailToConnectGatt(error_code); |
| 406 } |
| 402 } | 407 } |
| OLD | NEW |