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

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

Issue 2745323002: Adding std::ostream& operator<<(std::ostream& out, NSError* error) (Closed)
Patch Set: Moving operator<< to bluetooth_adapter_mac.mm Created 3 years, 8 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 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 BluetoothLowEnergyDeviceMac* device_mac = 667 BluetoothLowEnergyDeviceMac* device_mac =
668 GetBluetoothLowEnergyDeviceMac(peripheral); 668 GetBluetoothLowEnergyDeviceMac(peripheral);
669 if (!device_mac) { 669 if (!device_mac) {
670 [low_energy_central_manager_ cancelPeripheralConnection:peripheral]; 670 [low_energy_central_manager_ cancelPeripheralConnection:peripheral];
671 return; 671 return;
672 } 672 }
673 BluetoothDevice::ConnectErrorCode error_code = 673 BluetoothDevice::ConnectErrorCode error_code =
674 BluetoothDevice::ConnectErrorCode::ERROR_UNKNOWN; 674 BluetoothDevice::ConnectErrorCode::ERROR_UNKNOWN;
675 if (error) { 675 if (error) {
676 error_code = BluetoothDeviceMac::GetConnectErrorCodeFromNSError(error); 676 error_code = BluetoothDeviceMac::GetConnectErrorCodeFromNSError(error);
677 VLOG(1) << "Converting Bluetooth error, domain: " << error.domain.UTF8String
678 << ", error code: " << error.code << ", to: " << error_code;
679 } 677 }
680 VLOG(1) << *device_mac << ": Failed to connect to peripheral with error " 678 VLOG(1) << *device_mac << ": Failed to connect to peripheral with error "
681 << error; 679 << error << ", error code: " << error_code;
682 device_mac->DidFailToConnectGatt(error_code); 680 device_mac->DidFailToConnectGatt(error_code);
683 } 681 }
684 682
685 void BluetoothAdapterMac::DidDisconnectPeripheral(CBPeripheral* peripheral, 683 void BluetoothAdapterMac::DidDisconnectPeripheral(CBPeripheral* peripheral,
686 NSError* error) { 684 NSError* error) {
687 BluetoothLowEnergyDeviceMac* device_mac = 685 BluetoothLowEnergyDeviceMac* device_mac =
688 GetBluetoothLowEnergyDeviceMac(peripheral); 686 GetBluetoothLowEnergyDeviceMac(peripheral);
689 if (!device_mac) { 687 if (!device_mac) {
690 [low_energy_central_manager_ cancelPeripheralConnection:peripheral]; 688 [low_energy_central_manager_ cancelPeripheralConnection:peripheral];
691 return; 689 return;
(...skipping 27 matching lines...) Expand all
719 // Collision, two identifiers map to the same hash address. With a 48 bit 717 // Collision, two identifiers map to the same hash address. With a 48 bit
720 // hash the probability of this occuring with 10,000 devices 718 // hash the probability of this occuring with 10,000 devices
721 // simultaneously present is 1e-6 (see 719 // simultaneously present is 1e-6 (see
722 // https://en.wikipedia.org/wiki/Birthday_problem#Probability_table). We 720 // https://en.wikipedia.org/wiki/Birthday_problem#Probability_table). We
723 // ignore the second device by returning. 721 // ignore the second device by returning.
724 return true; 722 return true;
725 } 723 }
726 return false; 724 return false;
727 } 725 }
728 726
727 DEVICE_BLUETOOTH_EXPORT std::ostream& operator<<(std::ostream& out,
728 NSError* error) {
729 if (!error) {
730 return out << "no error";
731 }
732 return out << "error domain: " << base::SysNSStringToUTF8(error.domain)
733 << ", code: " << std::to_string(error.code) << ", description: "
734 << base::SysNSStringToUTF8(error.localizedDescription);
735 }
736
729 } // namespace device 737 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_adapter_mac.h ('k') | device/bluetooth/bluetooth_low_energy_device_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698