1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_METRICS_H_
6 #define CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_METRICS_H_
20 struct BluetoothScanFilter
;
24 // Enumaration of each Web Bluetooth API entry point.
25 enum class UMAWebBluetoothFunction
{
28 GET_PRIMARY_SERVICE
= 2,
29 GET_CHARACTERISTIC
= 3,
30 CHARACTERISTIC_READ_VALUE
= 4,
31 CHARACTERISTIC_WRITE_VALUE
= 5,
32 // NOTE: Add new actions immediately above this line. Make sure to update
33 // the enum list in tools/metrics/histograms/histograms.xml accordingly.
37 // There should be a call to this function for every call to the Web Bluetooth
39 void RecordWebBluetoothFunctionCall(UMAWebBluetoothFunction function
);
41 // requestDevice() Metrics
42 enum class UMARequestDeviceOutcome
{
44 NO_BLUETOOTH_ADAPTER
= 1,
46 OBSOLETE_DISCOVERY_START_FAILED
= 3,
47 OBSOLETE_DISCOVERY_STOP_FAILED
= 4,
48 OBSOLETE_NO_MATCHING_DEVICES_FOUND
= 5,
49 BLUETOOTH_ADAPTER_NOT_PRESENT
= 6,
50 OBSOLETE_BLUETOOTH_ADAPTER_OFF
= 7,
51 CHOSEN_DEVICE_VANISHED
= 8,
52 BLUETOOTH_CHOOSER_CANCELLED
= 9,
53 // NOTE: Add new requestDevice() outcomes immediately above this line. Make
54 // sure to update the enum list in
55 // tools/metrics/histograms/histograms.xml accordingly.
58 // There should be a call to this function before every
59 // Send(BluetoothMsg_RequestDeviceSuccess...) or
60 // Send(BluetoothMsg_RequestDeviceError...).
61 void RecordRequestDeviceOutcome(UMARequestDeviceOutcome outcome
);
63 // Records stats about the arguments used when calling requestDevice.
64 // - The number of filters used.
65 // - The size of each filter.
66 // - UUID of the services used in filters.
67 // - Number of optional services used.
68 // - UUID of the optional services.
69 // - Size of the union of all services.
70 void RecordRequestDeviceArguments(
71 const std::vector
<content::BluetoothScanFilter
>& filters
,
72 const std::vector
<device::BluetoothUUID
>& optional_services
);
74 // connectGATT() Metrics
75 enum class UMAConnectGATTOutcome
{
85 UNSUPPORTED_DEVICE
= 9,
86 // Note: Add new ConnectGATT outcomes immediately above this line. Make sure
87 // to update the enum list in tools/metrics/histograms/histograms.xml
91 // There should be a call to this function before every
92 // Send(BluetoothMsg_ConnectGATTSuccess) and
93 // Send(BluetoothMsg_ConnectGATTError).
94 void RecordConnectGATTOutcome(UMAConnectGATTOutcome outcome
);
95 // Records how long it took for the connection to succeed.
96 void RecordConnectGATTTimeSuccess(const base::TimeDelta
& duration
);
97 // Records how long it took for the connection to fail.
98 void RecordConnectGATTTimeFailed(const base::TimeDelta
& duration
);
100 // getPrimaryService() Metrics
101 enum class UMAGetPrimaryServiceOutcome
{
105 // Note: Add new GetPrimaryService outcomes immediately above this line.
106 // Make sure to update the enum list in
107 // tools/metrics/histograms/histograms.xml accordingly.
110 // Record the service uuid used when calling getPrimaryService.
111 void RecordGetPrimaryServiceService(const device::BluetoothUUID
& service
);
112 // There should be a call to this function for every call to
113 // Send(BluetoothMsg_GetPrimaryServiceSuccess) and
114 // Send(BluetoothMsg_GetPrimaryServiceError).
115 void RecordGetPrimaryServiceOutcome(UMAGetPrimaryServiceOutcome outcome
);
117 // getCharacteristic() Metrics
118 enum class UMAGetCharacteristicOutcome
{
123 // Note: Add new outcomes immediately above this line.
124 // Make sure to update the enum list in
125 // tools/metrisc/histogram/histograms.xml accordingly.
128 // There should be a call to this function for every call to
129 // Send(BluetoothMsg_GetCharacteristicSuccess) and
130 // Send(BluetoothMsg_GetCharacteristicError).
131 void RecordGetCharacteristicOutcome(UMAGetCharacteristicOutcome outcome
);
132 // Records the UUID of the characteristic used when calling getCharacteristic.
133 void RecordGetCharacteristicCharacteristic(const std::string
& characteristic
);
135 // GATT Operations Metrics
137 // These are the possible outcomes when performing GATT operations i.e.
138 // characteristic.readValue/writeValue descriptor.readValue/writeValue.
139 enum UMAGATTOperationOutcome
{
143 NO_CHARACTERISTIC
= 3,
153 // Note: Add new GATT Outcomes immediately above this line.
154 // Make sure to update the enum list in
155 // tools/metrics/histograms/histograms.xml accordingly.
159 enum class UMAGATTOperation
{
161 CHARACTERISTIC_WRITE
,
162 // Note: Add new GATT Operations immediately above this line.
166 // Records the outcome of a GATT operation.
167 // There should be a call to this function whenever the corresponding operation
168 // doesn't have a call to Record[Operation]Outcome.
169 void RecordGATTOperationOutcome(UMAGATTOperation operation
,
170 UMAGATTOperationOutcome outcome
);
172 // Characteristic.readValue() Metrics
173 // There should be a call to this function for every call to
174 // Send(BluetoothMsg_ReadCharacteristicValueSuccess) and
175 // Send(BluetoothMsg_ReadCharacteristicValueError).
176 void RecordCharacteristicReadValueOutcome(UMAGATTOperationOutcome error
);
178 // Characteristic.writeValue() Metrics
179 // There should be a call to this function for every call to
180 // Send(BluetoothMsg_WriteCharacteristicValueSuccess) and
181 // Send(BluetoothMsg_WriteCharacteristicValueError).
182 void RecordCharacteristicWriteValueOutcome(UMAGATTOperationOutcome error
);
184 } // namespace content
186 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_METRICS_H_