Index: device/bluetooth/bluetooth_device_experimental_chromeos.cc |
diff --git a/device/bluetooth/bluetooth_device_experimental_chromeos.cc b/device/bluetooth/bluetooth_device_experimental_chromeos.cc |
index 85e84d33e8e133626ab545cbff4c482785d0133c..f1e953321abd51c4b0e210d0a58c55d8d9e622bb 100644 |
--- a/device/bluetooth/bluetooth_device_experimental_chromeos.cc |
+++ b/device/bluetooth/bluetooth_device_experimental_chromeos.cc |
@@ -5,6 +5,7 @@ |
#include "device/bluetooth/bluetooth_device_experimental_chromeos.h" |
#include "base/bind.h" |
+#include "base/metrics/histogram.h" |
#include "chromeos/dbus/dbus_thread_manager.h" |
#include "chromeos/dbus/experimental_bluetooth_adapter_client.h" |
#include "chromeos/dbus/experimental_bluetooth_agent_manager_client.h" |
@@ -24,6 +25,35 @@ namespace { |
// (which we fail in OnRegisterAgentError with ERROR_INPROGRESS). |
const char kAgentPath[] = "/org/chromium/bluetooth_agent"; |
+// Histogram enumerations for pairing methods. |
+enum UMAPairingMethod { |
+ UMA_PAIRING_METHOD_NONE, |
+ UMA_PAIRING_METHOD_REQUEST_PINCODE, |
+ UMA_PAIRING_METHOD_REQUEST_PASSKEY, |
+ UMA_PAIRING_METHOD_DISPLAY_PINCODE, |
+ UMA_PAIRING_METHOD_DISPLAY_PASSKEY, |
+ UMA_PAIRING_METHOD_CONFIRM_PASSKEY, |
+ // NOTE: Add new pairing methods immediately above this line. Make sure to |
+ // update the enum list in tools/histogram/histograms.xml accordinly. |
+ UMA_PAIRING_METHOD_COUNT |
+}; |
+ |
+// Histogram enumerations for pairing results. |
+enum UMAPairingResult { |
+ UMA_PAIRING_RESULT_SUCCESS, |
+ UMA_PAIRING_RESULT_INPROGRESS, |
+ UMA_PAIRING_RESULT_FAILED, |
+ UMA_PAIRING_RESULT_AUTH_FAILED, |
+ UMA_PAIRING_RESULT_AUTH_CANCELED, |
+ UMA_PAIRING_RESULT_AUTH_REJECTED, |
+ UMA_PAIRING_RESULT_AUTH_TIMEOUT, |
+ UMA_PAIRING_RESULT_UNSUPPORTED_DEVICE, |
+ UMA_PAIRING_RESULT_UNKNOWN_ERROR, |
+ // NOTE: Add new pairing results immediately above this line. Make sure to |
+ // update the enum list in tools/histogram/histograms.xml accordinly. |
+ UMA_PAIRING_RESULT_COUNT |
+}; |
+ |
} // namespace |
namespace chromeos { |
@@ -35,6 +65,7 @@ BluetoothDeviceExperimentalChromeOS::BluetoothDeviceExperimentalChromeOS( |
object_path_(object_path), |
num_connecting_calls_(0), |
pairing_delegate_(NULL), |
+ pairing_delegate_used_(false), |
weak_ptr_factory_(this) { |
} |
@@ -68,6 +99,15 @@ std::string BluetoothDeviceExperimentalChromeOS::GetAddress() const { |
return properties->address.value(); |
} |
+std::string BluetoothDeviceExperimentalChromeOS::GetModalias() const { |
+ ExperimentalBluetoothDeviceClient::Properties* properties = |
+ DBusThreadManager::Get()->GetExperimentalBluetoothDeviceClient()-> |
+ GetProperties(object_path_); |
+ DCHECK(properties); |
+ |
+ return properties->modalias.value(); |
+} |
+ |
bool BluetoothDeviceExperimentalChromeOS::IsPaired() const { |
ExperimentalBluetoothDeviceClient::Properties* properties = |
DBusThreadManager::Get()->GetExperimentalBluetoothDeviceClient()-> |
@@ -151,6 +191,7 @@ void BluetoothDeviceExperimentalChromeOS::Connect( |
DCHECK(agent_.get() == NULL); |
pairing_delegate_ = pairing_delegate; |
+ pairing_delegate_used_ = false; |
// The agent path is relatively meaningless since BlueZ only supports |
// one per application at a time. |
@@ -299,6 +340,10 @@ void BluetoothDeviceExperimentalChromeOS::RequestPinCode( |
DCHECK(device_path == object_path_); |
VLOG(1) << object_path_.value() << ": RequestPinCode"; |
+ UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod", |
+ UMA_PAIRING_METHOD_REQUEST_PINCODE, |
+ UMA_PAIRING_METHOD_COUNT); |
+ |
DCHECK(pairing_delegate_); |
DCHECK(pincode_callback_.is_null()); |
pincode_callback_ = callback; |
@@ -312,6 +357,10 @@ void BluetoothDeviceExperimentalChromeOS::DisplayPinCode( |
DCHECK(device_path == object_path_); |
VLOG(1) << object_path_.value() << ": DisplayPinCode: " << pincode; |
+ UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod", |
+ UMA_PAIRING_METHOD_DISPLAY_PINCODE, |
+ UMA_PAIRING_METHOD_COUNT); |
+ |
DCHECK(pairing_delegate_); |
pairing_delegate_->DisplayPinCode(this, pincode); |
} |
@@ -323,6 +372,10 @@ void BluetoothDeviceExperimentalChromeOS::RequestPasskey( |
DCHECK(device_path == object_path_); |
VLOG(1) << object_path_.value() << ": RequestPasskey"; |
+ UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod", |
+ UMA_PAIRING_METHOD_REQUEST_PASSKEY, |
+ UMA_PAIRING_METHOD_COUNT); |
+ |
DCHECK(pairing_delegate_); |
DCHECK(passkey_callback_.is_null()); |
passkey_callback_ = callback; |
@@ -337,6 +390,11 @@ void BluetoothDeviceExperimentalChromeOS::DisplayPasskey( |
VLOG(1) << object_path_.value() << ": DisplayPasskey: " << passkey |
<< " (" << entered << " entered)"; |
+ if (entered == 0) |
+ UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod", |
+ UMA_PAIRING_METHOD_DISPLAY_PASSKEY, |
+ UMA_PAIRING_METHOD_COUNT); |
+ |
DCHECK(pairing_delegate_); |
if (entered == 0) |
pairing_delegate_->DisplayPasskey(this, passkey); |
@@ -351,6 +409,10 @@ void BluetoothDeviceExperimentalChromeOS::RequestConfirmation( |
DCHECK(device_path == object_path_); |
VLOG(1) << object_path_.value() << ": RequestConfirmation: " << passkey; |
+ UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod", |
+ UMA_PAIRING_METHOD_CONFIRM_PASSKEY, |
+ UMA_PAIRING_METHOD_COUNT); |
+ |
DCHECK(pairing_delegate_); |
DCHECK(confirmation_callback_.is_null()); |
confirmation_callback_ = callback; |
@@ -430,6 +492,7 @@ void BluetoothDeviceExperimentalChromeOS::OnConnectError( |
error_code = ERROR_UNSUPPORTED_DEVICE; |
} |
+ RecordPairingResult(false, error_code); |
error_callback.Run(error_code); |
} |
@@ -468,6 +531,7 @@ void BluetoothDeviceExperimentalChromeOS::OnRegisterAgentError( |
if (error_name == bluetooth_adapter::kErrorAlreadyExists) |
error_code = ERROR_INPROGRESS; |
+ RecordPairingResult(false, error_code); |
error_callback.Run(error_code); |
} |
@@ -475,6 +539,11 @@ void BluetoothDeviceExperimentalChromeOS::OnPair( |
const base::Closure& callback, |
const ConnectErrorCallback& error_callback) { |
VLOG(1) << object_path_.value() << ": Paired"; |
+ |
+ if (!pairing_delegate_used_) |
+ UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod", |
+ UMA_PAIRING_METHOD_NONE, |
+ UMA_PAIRING_METHOD_COUNT); |
UnregisterAgent(); |
SetTrusted(); |
ConnectInternal(callback, error_callback); |
@@ -507,6 +576,7 @@ void BluetoothDeviceExperimentalChromeOS::OnPairError( |
error_code = ERROR_AUTH_TIMEOUT; |
} |
+ RecordPairingResult(false, error_code); |
error_callback.Run(error_code); |
} |
@@ -616,4 +686,43 @@ bool BluetoothDeviceExperimentalChromeOS::RunPairingCallbacks(Status status) { |
return callback_run; |
} |
+void BluetoothDeviceExperimentalChromeOS::RecordPairingResult( |
+ bool success, |
+ ConnectErrorCode error_code) { |
+ UMAPairingResult pairing_result; |
+ if (success) { |
+ pairing_result = UMA_PAIRING_RESULT_SUCCESS; |
+ } else { |
+ switch (error_code) { |
+ case ERROR_INPROGRESS: |
+ pairing_result = UMA_PAIRING_RESULT_INPROGRESS; |
+ break; |
+ case ERROR_FAILED: |
+ pairing_result = UMA_PAIRING_RESULT_FAILED; |
+ break; |
+ case ERROR_AUTH_FAILED: |
+ pairing_result = UMA_PAIRING_RESULT_AUTH_FAILED; |
+ break; |
+ case ERROR_AUTH_CANCELED: |
+ pairing_result = UMA_PAIRING_RESULT_AUTH_CANCELED; |
+ break; |
+ case ERROR_AUTH_REJECTED: |
+ pairing_result = UMA_PAIRING_RESULT_AUTH_REJECTED; |
+ break; |
+ case ERROR_AUTH_TIMEOUT: |
+ pairing_result = UMA_PAIRING_RESULT_AUTH_TIMEOUT; |
+ break; |
+ case ERROR_UNSUPPORTED_DEVICE: |
+ pairing_result = UMA_PAIRING_RESULT_UNSUPPORTED_DEVICE; |
+ break; |
+ default: |
+ pairing_result = UMA_PAIRING_RESULT_UNKNOWN_ERROR; |
+ } |
+ } |
+ |
+ UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingResult", |
+ pairing_result, |
+ UMA_PAIRING_RESULT_COUNT); |
+} |
+ |
} // namespace chromeos |