Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(648)

Side by Side Diff: device/bluetooth/bluetooth_adapter_mac.mm

Issue 2276213002: bluetooth: Fix mac crash when logging is enabled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_adapter_mac.h" 5 #include "device/bluetooth/bluetooth_adapter_mac.h"
6 6
7 #import <IOBluetooth/objc/IOBluetoothDevice.h> 7 #import <IOBluetooth/objc/IOBluetoothDevice.h>
8 #import <IOBluetooth/objc/IOBluetoothHostController.h> 8 #import <IOBluetooth/objc/IOBluetoothHostController.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 10
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 } 588 }
589 589
590 void BluetoothAdapterMac::DidFailToConnectPeripheral(CBPeripheral* peripheral, 590 void BluetoothAdapterMac::DidFailToConnectPeripheral(CBPeripheral* peripheral,
591 NSError* error) { 591 NSError* error) {
592 BluetoothLowEnergyDeviceMac* device_mac = 592 BluetoothLowEnergyDeviceMac* device_mac =
593 GetBluetoothLowEnergyDeviceMac(peripheral); 593 GetBluetoothLowEnergyDeviceMac(peripheral);
594 if (!device_mac) { 594 if (!device_mac) {
595 [low_energy_central_manager_ cancelPeripheralConnection:peripheral]; 595 [low_energy_central_manager_ cancelPeripheralConnection:peripheral];
596 return; 596 return;
597 } 597 }
598 VLOG(1) << "Bluetooth error, domain: " << error.domain.UTF8String 598 VLOG(1) << "Failed to connect to peripheral";
599 << ", error code: " << error.code;
600 BluetoothDevice::ConnectErrorCode error_code = 599 BluetoothDevice::ConnectErrorCode error_code =
601 BluetoothDeviceMac::GetConnectErrorCodeFromNSError(error); 600 BluetoothDevice::ConnectErrorCode::ERROR_UNKNOWN;
Jeffrey Yasskin 2016/08/24 23:28:13 If this happens when we explicitly disconnected wh
ortuno 2016/08/25 16:39:56 We should but I would like to do that in a separat
602 VLOG(1) << "Bluetooth error, domain: " << error.domain.UTF8String 601 if (error) {
603 << ", error code: " << error.code 602 error_code = BluetoothDeviceMac::GetConnectErrorCodeFromNSError(error);
604 << ", converted into: " << error_code; 603 VLOG(1) << "Bluetooth error, domain: " << error.domain.UTF8String
604 << ", error code: " << error.code
605 << ", converted into: " << error_code;
606 }
605 device_mac->DidFailToConnectGatt(error_code); 607 device_mac->DidFailToConnectGatt(error_code);
606 } 608 }
607 609
608 void BluetoothAdapterMac::DidDisconnectPeripheral(CBPeripheral* peripheral, 610 void BluetoothAdapterMac::DidDisconnectPeripheral(CBPeripheral* peripheral,
609 NSError* error) { 611 NSError* error) {
610 BluetoothLowEnergyDeviceMac* device_mac = 612 BluetoothLowEnergyDeviceMac* device_mac =
611 GetBluetoothLowEnergyDeviceMac(peripheral); 613 GetBluetoothLowEnergyDeviceMac(peripheral);
612 if (!device_mac) { 614 if (!device_mac) {
613 [low_energy_central_manager_ cancelPeripheralConnection:peripheral]; 615 [low_energy_central_manager_ cancelPeripheralConnection:peripheral];
614 return; 616 return;
615 } 617 }
616 VLOG(1) << "Bluetooth error, domain: " << error.domain.UTF8String 618 VLOG(1) << "Disconnected from peripheral.";
617 << ", error code: " << error.code; 619 if (error) {
618 BluetoothDevice::ConnectErrorCode error_code = 620 VLOG(1) << "Bluetooth error, domain: " << error.domain.UTF8String
619 BluetoothDeviceMac::GetConnectErrorCodeFromNSError(error); 621 << ", error code: " << error.code;
620 device_mac->DidDisconnectPeripheral(error_code); 622 }
623 device_mac->DidDisconnectPeripheral(error);
621 } 624 }
622 625
623 BluetoothLowEnergyDeviceMac* 626 BluetoothLowEnergyDeviceMac*
624 BluetoothAdapterMac::GetBluetoothLowEnergyDeviceMac(CBPeripheral* peripheral) { 627 BluetoothAdapterMac::GetBluetoothLowEnergyDeviceMac(CBPeripheral* peripheral) {
625 std::string device_address = 628 std::string device_address =
626 BluetoothLowEnergyDeviceMac::GetPeripheralHashAddress(peripheral); 629 BluetoothLowEnergyDeviceMac::GetPeripheralHashAddress(peripheral);
627 DevicesMap::const_iterator iter = devices_.find(device_address); 630 DevicesMap::const_iterator iter = devices_.find(device_address);
628 if (iter == devices_.end()) { 631 if (iter == devices_.end()) {
629 return nil; 632 return nil;
630 } 633 }
631 return static_cast<BluetoothLowEnergyDeviceMac*>(iter->second); 634 return static_cast<BluetoothLowEnergyDeviceMac*>(iter->second);
632 } 635 }
633 636
634 } // namespace device 637 } // namespace device
OLDNEW
« no previous file with comments | « no previous file | device/bluetooth/bluetooth_low_energy_device_mac.h » ('j') | device/bluetooth/bluetooth_low_energy_device_mac.mm » ('J')

Powered by Google App Engine
This is Rietveld 408576698