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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 384 it != gatt_services_.end(); ++it) { | 384 it != gatt_services_.end(); ++it) { |
| 385 device::BluetoothRemoteGattService* gatt_service = it->second; | 385 device::BluetoothRemoteGattService* gatt_service = it->second; |
| 386 device::BluetoothRemoteGattServiceMac* gatt_service_mac = | 386 device::BluetoothRemoteGattServiceMac* gatt_service_mac = |
| 387 static_cast<BluetoothRemoteGattServiceMac*>(gatt_service); | 387 static_cast<BluetoothRemoteGattServiceMac*>(gatt_service); |
| 388 if (gatt_service_mac->GetService() == cb_service) | 388 if (gatt_service_mac->GetService() == cb_service) |
| 389 return gatt_service_mac; | 389 return gatt_service_mac; |
| 390 } | 390 } |
| 391 return nullptr; | 391 return nullptr; |
| 392 } | 392 } |
| 393 | 393 |
| 394 void BluetoothLowEnergyDeviceMac::DidDisconnectPeripheral() { | |
| 395 RemoveAllServices(); | |
| 396 DCHECK(create_gatt_connection_error_callbacks_.empty()); | |
| 397 DidDisconnectGatt(); | |
| 398 } | |
| 399 | |
| 394 void BluetoothLowEnergyDeviceMac::DidDisconnectPeripheral( | 400 void BluetoothLowEnergyDeviceMac::DidDisconnectPeripheral( |
|
ortuno
2016/08/09 19:14:56
I wonder if we really need this function now. Once
jlebel
2016/08/10 08:42:19
There is no point to call BluetoothDevice::DidDisc
ortuno
2016/08/10 16:49:09
I'm saying that you don't really need this error v
| |
| 395 BluetoothDevice::ConnectErrorCode error_code) { | 401 BluetoothDevice::ConnectErrorCode error_code) { |
| 402 RemoveAllServices(); | |
| 403 DCHECK(create_gatt_connection_error_callbacks_.empty()); | |
| 404 // TODO(http://crbug.com/585897): Need to pass the error. | |
| 405 DidDisconnectGatt(); | |
| 406 } | |
| 407 | |
| 408 void BluetoothLowEnergyDeviceMac::RemoveAllServices() { | |
| 396 SetGattServicesDiscoveryComplete(false); | 409 SetGattServicesDiscoveryComplete(false); |
| 397 // Removing all services at once to ensure that calling GetGattService on | 410 // Removing all services at once to ensure that calling GetGattService on |
| 398 // removed service in GattServiceRemoved returns null. | 411 // removed service in GattServiceRemoved returns null. |
| 399 GattServiceMap gatt_services_swapped; | 412 GattServiceMap gatt_services_swapped; |
| 400 gatt_services_swapped.swap(gatt_services_); | 413 gatt_services_swapped.swap(gatt_services_); |
| 401 gatt_services_swapped.clear(); | 414 gatt_services_swapped.clear(); |
| 402 if (create_gatt_connection_error_callbacks_.empty()) { | |
| 403 // TODO(http://crbug.com/585897): Need to pass the error. | |
| 404 DidDisconnectGatt(); | |
| 405 } else { | |
| 406 DidFailToConnectGatt(error_code); | |
| 407 } | |
| 408 } | 415 } |
| OLD | NEW |