| 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 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 GattServiceMap gatt_services_swapped; | 483 GattServiceMap gatt_services_swapped; |
| 484 gatt_services_swapped.swap(gatt_services_); | 484 gatt_services_swapped.swap(gatt_services_); |
| 485 gatt_services_swapped.clear(); | 485 gatt_services_swapped.clear(); |
| 486 device_uuids_.ClearServiceUUIDs(); | 486 device_uuids_.ClearServiceUUIDs(); |
| 487 // There are two cases in which this function will be called: | 487 // There are two cases in which this function will be called: |
| 488 // 1. When the connection to the device breaks (either because | 488 // 1. When the connection to the device breaks (either because |
| 489 // we closed it or the device closed it). | 489 // we closed it or the device closed it). |
| 490 // 2. When we cancel a pending connection request. | 490 // 2. When we cancel a pending connection request. |
| 491 if (create_gatt_connection_error_callbacks_.empty()) { | 491 if (create_gatt_connection_error_callbacks_.empty()) { |
| 492 // If there are no pending callbacks then the connection broke (#1). | 492 // If there are no pending callbacks then the connection broke (#1). |
| 493 DidDisconnectGatt(true /* notifyDeviceChanged */); | 493 DidDisconnectGatt(); |
| 494 return; | 494 return; |
| 495 } | 495 } |
| 496 // Else we canceled the connection request (#2). | 496 // Else we canceled the connection request (#2). |
| 497 // TODO(http://crbug.com/585897): Need to pass the error. | 497 // TODO(http://crbug.com/585897): Need to pass the error. |
| 498 DidFailToConnectGatt(BluetoothDevice::ConnectErrorCode::ERROR_FAILED); | 498 DidFailToConnectGatt(BluetoothDevice::ConnectErrorCode::ERROR_FAILED); |
| 499 } | 499 } |
| 500 | 500 |
| 501 namespace device { | 501 namespace device { |
| 502 | 502 |
| 503 std::ostream& operator<<(std::ostream& out, | 503 std::ostream& operator<<(std::ostream& out, |
| 504 const BluetoothLowEnergyDeviceMac& device) { | 504 const BluetoothLowEnergyDeviceMac& device) { |
| 505 // TODO(crbug.com/703878): Should use | 505 // TODO(crbug.com/703878): Should use |
| 506 // BluetoothLowEnergyDeviceMac::GetNameForDisplay() instead. | 506 // BluetoothLowEnergyDeviceMac::GetNameForDisplay() instead. |
| 507 base::Optional<std::string> name = device.GetName(); | 507 base::Optional<std::string> name = device.GetName(); |
| 508 const char* is_gatt_connected = | 508 const char* is_gatt_connected = |
| 509 device.IsGattConnected() ? "GATT connected" : "GATT disconnected"; | 509 device.IsGattConnected() ? "GATT connected" : "GATT disconnected"; |
| 510 return out << "<BluetoothLowEnergyDeviceMac " << device.GetAddress() << "/" | 510 return out << "<BluetoothLowEnergyDeviceMac " << device.GetAddress() << "/" |
| 511 << &device << ", " << is_gatt_connected << ", \"" | 511 << &device << ", " << is_gatt_connected << ", \"" |
| 512 << name.value_or("Unnamed device") << "\">"; | 512 << name.value_or("Unnamed device") << "\">"; |
| 513 } | 513 } |
| 514 } // namespace device | 514 } // namespace device |
| OLD | NEW |