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 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 GattServiceMap gatt_services_swapped; | 446 GattServiceMap gatt_services_swapped; |
447 gatt_services_swapped.swap(gatt_services_); | 447 gatt_services_swapped.swap(gatt_services_); |
448 gatt_services_swapped.clear(); | 448 gatt_services_swapped.clear(); |
449 device_uuids_.ClearServiceUUIDs(); | 449 device_uuids_.ClearServiceUUIDs(); |
450 // There are two cases in which this function will be called: | 450 // There are two cases in which this function will be called: |
451 // 1. When the connection to the device breaks (either because | 451 // 1. When the connection to the device breaks (either because |
452 // we closed it or the device closed it). | 452 // we closed it or the device closed it). |
453 // 2. When we cancel a pending connection request. | 453 // 2. When we cancel a pending connection request. |
454 if (create_gatt_connection_error_callbacks_.empty()) { | 454 if (create_gatt_connection_error_callbacks_.empty()) { |
455 // If there are no pending callbacks then the connection broke (#1). | 455 // If there are no pending callbacks then the connection broke (#1). |
456 DidDisconnectGatt(true /* notifyDeviceChanged */); | 456 DidDisconnectGatt(); |
457 return; | 457 return; |
458 } | 458 } |
459 // Else we canceled the connection request (#2). | 459 // Else we canceled the connection request (#2). |
460 // TODO(http://crbug.com/585897): Need to pass the error. | 460 // TODO(http://crbug.com/585897): Need to pass the error. |
461 DidFailToConnectGatt(BluetoothDevice::ConnectErrorCode::ERROR_FAILED); | 461 DidFailToConnectGatt(BluetoothDevice::ConnectErrorCode::ERROR_FAILED); |
462 } | 462 } |
463 | 463 |
464 namespace device { | 464 namespace device { |
465 | 465 |
466 std::ostream& operator<<(std::ostream& out, | 466 std::ostream& operator<<(std::ostream& out, |
467 const BluetoothLowEnergyDeviceMac& device) { | 467 const BluetoothLowEnergyDeviceMac& device) { |
468 // TODO(crbug.com/703878): Should use | 468 // TODO(crbug.com/703878): Should use |
469 // BluetoothLowEnergyDeviceMac::GetNameForDisplay() instead. | 469 // BluetoothLowEnergyDeviceMac::GetNameForDisplay() instead. |
470 base::Optional<std::string> name = device.GetName(); | 470 base::Optional<std::string> name = device.GetName(); |
471 const char* name_cstr = name ? name->c_str() : ""; | 471 const char* name_cstr = name ? name->c_str() : ""; |
472 return out << "<BluetoothLowEnergyDeviceMac " << device.GetAddress() << "/" | 472 return out << "<BluetoothLowEnergyDeviceMac " << device.GetAddress() << "/" |
473 << &device << ", \"" << name_cstr << "\">"; | 473 << &device << ", \"" << name_cstr << "\">"; |
474 } | 474 } |
475 } // namespace device | 475 } // namespace device |
OLD | NEW |