Chromium Code Reviews| Index: device/bluetooth/bluetooth_device_android.cc |
| diff --git a/device/bluetooth/bluetooth_device_android.cc b/device/bluetooth/bluetooth_device_android.cc |
| index cb142563d043a928919ff9b5dc0fc46fca2019ea..0d8664b6b5f67d50f86a926962dbdc6ad71eaa3e 100644 |
| --- a/device/bluetooth/bluetooth_device_android.cc |
| +++ b/device/bluetooth/bluetooth_device_android.cc |
| @@ -8,6 +8,8 @@ |
| #include "base/android/jni_android.h" |
| #include "base/android/jni_array.h" |
| #include "base/android/jni_string.h" |
| +#include "base/metrics/histogram_macros.h" |
|
scheib
2016/01/15 01:39:45
Why is histogram_macros required? Seems to be a bu
ortuno
2016/01/15 21:34:41
Done.
|
| +#include "base/metrics/sparse_histogram.h" |
| #include "base/strings/stringprintf.h" |
| #include "device/bluetooth/bluetooth_adapter_android.h" |
| #include "device/bluetooth/bluetooth_remote_gatt_service_android.h" |
| @@ -17,6 +19,20 @@ using base::android::AttachCurrentThread; |
| using base::android::AppendJavaStringArrayToStringVector; |
| namespace device { |
| +namespace { |
| +void RecordConnectionSuccessResult(int32_t status) { |
| + UMA_HISTOGRAM_SPARSE_SLOWLY("Bluetooth.Android.GATTConnection.Success.Result", |
| + status); |
| +} |
| +void RecordConnectionFailureResult(int32_t status) { |
| + UMA_HISTOGRAM_SPARSE_SLOWLY("Bluetooth.Android.GATTConnection.Failure.Result", |
| + status); |
| +} |
| +void RecordConnectionTerminatedResult(int32_t status) { |
| + UMA_HISTOGRAM_SPARSE_SLOWLY( |
| + "Bluetooth.Android.GATTConnection.Terminated.Result", status); |
| +} |
| +} // namespace |
| BluetoothDeviceAndroid* BluetoothDeviceAndroid::Create( |
| BluetoothAdapterAndroid* adapter, |
| @@ -206,6 +222,20 @@ void BluetoothDeviceAndroid::OnConnectionStateChange( |
| const JavaParamRef<jobject>& jcaller, |
| int32_t status, |
| bool connected) { |
| + // There are many errors not present in the Android documentation that |
| + // can be returned. We histogram these errors to better understand the |
| + // cases in which they arise. |
| + if (connected) { |
| + RecordConnectionSuccessResult(status); |
| + } else if (create_gatt_connection_error_callbacks_.size() > 0) { |
| + // We assume that if there are any pending connection callbacks there |
| + // was a failed connection attempt. |
| + RecordConnectionFailureResult(status); |
| + } else { |
| + // Otherwise an existing connection was terminated. |
| + RecordConnectionTerminatedResult(status); |
| + } |
| + |
| gatt_connected_ = connected; |
| if (gatt_connected_) { |
| DidConnectGatt(); |