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

Unified Diff: content/browser/bluetooth/bluetooth_dispatcher_host.cc

Issue 1270603010: bluetooth: Add histograms and logging for connectGATT (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-uma-requestDevice
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/bluetooth/bluetooth_dispatcher_host.cc
diff --git a/content/browser/bluetooth/bluetooth_dispatcher_host.cc b/content/browser/bluetooth/bluetooth_dispatcher_host.cc
index 031f17177443abb4c8507430aa4eba6ccaf195dc..310094a5c285bc0bb58fab1a14f54aeb7feae9f6 100644
--- a/content/browser/bluetooth/bluetooth_dispatcher_host.cc
+++ b/content/browser/bluetooth/bluetooth_dispatcher_host.cc
@@ -111,6 +111,37 @@ void RecordUnionOfServices(
union_of_services.size());
}
+enum class UMAConnectGATTOutcome {
+ SUCCESS,
+ NO_DEVICE,
+ UNKNOWN,
+ IN_PROGRESS,
+ FAILED,
+ AUTH_FAILED,
+ AUTH_CANCELED,
+ AUTH_REJECTED,
+ AUTH_TIMEOUT,
+ UNSUPPORTED_DEVICE,
+ // Note: Add new ConnectGATT outcomes immediately above this line. Make sure
+ // to update the enum list in tools/metrisc/histogram/histograms.xml
+ // accordingly.
+ COUNT
+};
+
+void RecordConnectGATTOutcome(UMAConnectGATTOutcome outcome) {
+ UMA_HISTOGRAM_ENUMERATION("Bluetooth.Web.ConnectGATT.Outcome",
+ static_cast<int>(outcome),
+ static_cast<int>(UMAConnectGATTOutcome::COUNT));
+}
+
+void RecordConnectGATTTimeSuccess(const base::TimeDelta& duration) {
+ UMA_HISTOGRAM_TIMES("Bluetooth.Web.ConnectGATT.TimeSuccess", duration);
Jeffrey Yasskin 2015/08/12 00:35:45 I'm a little worried that 10 seconds won't be enou
ortuno 2015/08/12 16:34:04 Done.
+}
+
+void RecordConnectGATTTimeFailed(const base::TimeDelta& duration) {
+ UMA_HISTOGRAM_TIMES("Bluetooth.Web.ConnectGATT.TimeFailed", duration);
+}
+
enum class UMAWebBluetoothFunction {
REQUEST_DEVICE,
CONNECT_GATT,
@@ -171,20 +202,28 @@ WebBluetoothError TranslateConnectError(
device::BluetoothDevice::ConnectErrorCode error_code) {
switch (error_code) {
case device::BluetoothDevice::ERROR_UNKNOWN:
+ RecordConnectGATTOutcome(UMAConnectGATTOutcome::UNKNOWN);
return WebBluetoothError::ConnectUnknownError;
case device::BluetoothDevice::ERROR_INPROGRESS:
+ RecordConnectGATTOutcome(UMAConnectGATTOutcome::IN_PROGRESS);
return WebBluetoothError::ConnectAlreadyInProgress;
case device::BluetoothDevice::ERROR_FAILED:
+ RecordConnectGATTOutcome(UMAConnectGATTOutcome::FAILED);
return WebBluetoothError::ConnectUnknownFailure;
case device::BluetoothDevice::ERROR_AUTH_FAILED:
+ RecordConnectGATTOutcome(UMAConnectGATTOutcome::AUTH_FAILED);
return WebBluetoothError::ConnectAuthFailed;
case device::BluetoothDevice::ERROR_AUTH_CANCELED:
+ RecordConnectGATTOutcome(UMAConnectGATTOutcome::AUTH_CANCELED);
return WebBluetoothError::ConnectAuthCanceled;
case device::BluetoothDevice::ERROR_AUTH_REJECTED:
+ RecordConnectGATTOutcome(UMAConnectGATTOutcome::AUTH_REJECTED);
return WebBluetoothError::ConnectAuthRejected;
case device::BluetoothDevice::ERROR_AUTH_TIMEOUT:
+ RecordConnectGATTOutcome(UMAConnectGATTOutcome::AUTH_TIMEOUT);
return WebBluetoothError::ConnectAuthTimeout;
case device::BluetoothDevice::ERROR_UNSUPPORTED_DEVICE:
+ RecordConnectGATTOutcome(UMAConnectGATTOutcome::UNSUPPORTED_DEVICE);
return WebBluetoothError::ConnectUnsupportedDevice;
}
NOTREACHED();
@@ -413,6 +452,8 @@ void BluetoothDispatcherHost::OnConnectGATT(
// the device. https://crbug.com/484745
device::BluetoothDevice* device = adapter_->GetDevice(device_instance_id);
if (device == nullptr) { // See "NETWORK_ERROR Note" above.
+ RecordConnectGATTOutcome(UMAConnectGATTOutcome::NO_DEVICE);
+ VLOG(1) << "Bluetooth Device no longer in range.";
Send(new BluetoothMsg_ConnectGATTError(
thread_id, request_id, WebBluetoothError::DeviceNoLongerInRange));
return;
@@ -420,10 +461,10 @@ void BluetoothDispatcherHost::OnConnectGATT(
device->CreateGattConnection(
base::Bind(&BluetoothDispatcherHost::OnGATTConnectionCreated,
weak_ptr_factory_.GetWeakPtr(), thread_id, request_id,
- device_instance_id),
+ device_instance_id, base::TimeTicks::Now()),
Jeffrey Yasskin 2015/08/12 00:35:45 Measure the starting time once at the beginning of
ortuno 2015/08/12 16:34:04 Done.
base::Bind(&BluetoothDispatcherHost::OnCreateGATTConnectionError,
weak_ptr_factory_.GetWeakPtr(), thread_id, request_id,
- device_instance_id));
+ device_instance_id, base::TimeTicks::Now()));
}
void BluetoothDispatcherHost::OnGetPrimaryService(
@@ -722,9 +763,12 @@ void BluetoothDispatcherHost::OnGATTConnectionCreated(
int thread_id,
int request_id,
const std::string& device_instance_id,
+ base::TimeTicks start_time,
scoped_ptr<device::BluetoothGattConnection> connection) {
// TODO(ortuno): Save the BluetoothGattConnection so we can disconnect
// from it.
+ RecordConnectGATTTimeSuccess(base::TimeTicks::Now() - start_time);
+ RecordConnectGATTOutcome(UMAConnectGATTOutcome::SUCCESS);
Send(new BluetoothMsg_ConnectGATTSuccess(thread_id, request_id,
device_instance_id));
}
@@ -733,10 +777,12 @@ void BluetoothDispatcherHost::OnCreateGATTConnectionError(
int thread_id,
int request_id,
const std::string& device_instance_id,
+ base::TimeTicks start_time,
device::BluetoothDevice::ConnectErrorCode error_code) {
// There was an error creating the ATT Bearer so we reject with
// NetworkError.
// https://webbluetoothchrome.github.io/web-bluetooth/#dom-bluetoothdevice-connectgatt
+ RecordConnectGATTTimeFailed(base::TimeTicks::Now() - start_time);
Send(new BluetoothMsg_ConnectGATTError(thread_id, request_id,
Jeffrey Yasskin 2015/08/12 00:35:45 Comment that RecordConnectGATTOutcome is called by
ortuno 2015/08/12 16:34:04 Done.
TranslateConnectError(error_code)));
}

Powered by Google App Engine
This is Rietveld 408576698