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

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

Issue 2912633002: bluetooth: macOS: Adding histograms for NSError values (Closed)
Patch Set: Resolving comments Created 3 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
11 #include <memory> 11 #include <memory>
12 #include <string> 12 #include <string>
13 13
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
16 #include "base/containers/hash_tables.h" 16 #include "base/containers/hash_tables.h"
17 #include "base/location.h" 17 #include "base/location.h"
18 #include "base/mac/mac_util.h" 18 #include "base/mac/mac_util.h"
19 #include "base/mac/sdk_forward_declarations.h" 19 #include "base/mac/sdk_forward_declarations.h"
20 #include "base/memory/ptr_util.h" 20 #include "base/memory/ptr_util.h"
21 #include "base/profiler/scoped_tracker.h" 21 #include "base/profiler/scoped_tracker.h"
22 #include "base/sequenced_task_runner.h" 22 #include "base/sequenced_task_runner.h"
23 #include "base/single_thread_task_runner.h" 23 #include "base/single_thread_task_runner.h"
24 #include "base/strings/sys_string_conversions.h" 24 #include "base/strings/sys_string_conversions.h"
25 #include "base/threading/thread_task_runner_handle.h" 25 #include "base/threading/thread_task_runner_handle.h"
26 #include "base/time/time.h" 26 #include "base/time/time.h"
27 #include "device/bluetooth/bluetooth_adapter_mac_metrics.h"
27 #include "device/bluetooth/bluetooth_classic_device_mac.h" 28 #include "device/bluetooth/bluetooth_classic_device_mac.h"
28 #include "device/bluetooth/bluetooth_common.h" 29 #include "device/bluetooth/bluetooth_common.h"
29 #include "device/bluetooth/bluetooth_discovery_session.h" 30 #include "device/bluetooth/bluetooth_discovery_session.h"
30 #include "device/bluetooth/bluetooth_discovery_session_outcome.h" 31 #include "device/bluetooth/bluetooth_discovery_session_outcome.h"
31 #include "device/bluetooth/bluetooth_low_energy_central_manager_delegate.h" 32 #include "device/bluetooth/bluetooth_low_energy_central_manager_delegate.h"
32 #include "device/bluetooth/bluetooth_socket_mac.h" 33 #include "device/bluetooth/bluetooth_socket_mac.h"
33 34
34 namespace { 35 namespace {
35 36
36 // The frequency with which to poll the adapter for updates. 37 // The frequency with which to poll the adapter for updates.
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 } 708 }
708 709
709 void BluetoothAdapterMac::DidFailToConnectPeripheral(CBPeripheral* peripheral, 710 void BluetoothAdapterMac::DidFailToConnectPeripheral(CBPeripheral* peripheral,
710 NSError* error) { 711 NSError* error) {
711 BluetoothLowEnergyDeviceMac* device_mac = 712 BluetoothLowEnergyDeviceMac* device_mac =
712 GetBluetoothLowEnergyDeviceMac(peripheral); 713 GetBluetoothLowEnergyDeviceMac(peripheral);
713 if (!device_mac) { 714 if (!device_mac) {
714 [low_energy_central_manager_ cancelPeripheralConnection:peripheral]; 715 [low_energy_central_manager_ cancelPeripheralConnection:peripheral];
715 return; 716 return;
716 } 717 }
718 RecordDidFailToConnectPeripheralResult(error);
717 BluetoothDevice::ConnectErrorCode error_code = 719 BluetoothDevice::ConnectErrorCode error_code =
718 BluetoothDevice::ConnectErrorCode::ERROR_UNKNOWN; 720 BluetoothDevice::ConnectErrorCode::ERROR_UNKNOWN;
719 if (error) { 721 if (error) {
720 error_code = BluetoothDeviceMac::GetConnectErrorCodeFromNSError(error); 722 error_code = BluetoothDeviceMac::GetConnectErrorCodeFromNSError(error);
721 } 723 }
722 VLOG(1) << *device_mac << ": Failed to connect to peripheral with error " 724 VLOG(1) << *device_mac << ": Failed to connect to peripheral with error "
723 << BluetoothAdapterMac::String(error) 725 << BluetoothAdapterMac::String(error)
724 << ", error code: " << error_code; 726 << ", error code: " << error_code;
725 device_mac->DidFailToConnectGatt(error_code); 727 device_mac->DidFailToConnectGatt(error_code);
726 } 728 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 // hash the probability of this occuring with 10,000 devices 765 // hash the probability of this occuring with 10,000 devices
764 // simultaneously present is 1e-6 (see 766 // simultaneously present is 1e-6 (see
765 // https://en.wikipedia.org/wiki/Birthday_problem#Probability_table). We 767 // https://en.wikipedia.org/wiki/Birthday_problem#Probability_table). We
766 // ignore the second device by returning. 768 // ignore the second device by returning.
767 return true; 769 return true;
768 } 770 }
769 return false; 771 return false;
770 } 772 }
771 773
772 } // namespace device 774 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698