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 DISCOVERY_START_FAILED
= 3,
47 DISCOVERY_STOP_FAILED
= 4,
48 NO_MATCHING_DEVICES_FOUND
= 5,
49 BLUETOOTH_ADAPTER_NOT_PRESENT
= 6,
50 BLUETOOTH_ADAPTER_OFF
= 7,
51 // NOTE: Add new requestDevice() outcomes immediately above this line. Make
52 // sure to update the enum list in
53 // tools/metrics/histograms/histograms.xml accordingly.
56 // There should be a call to this function before every
57 // Send(BluetoothMsg_RequestDeviceSuccess...) or
58 // Send(BluetoothMsg_RequestDeviceError...).
59 void RecordRequestDeviceOutcome(UMARequestDeviceOutcome outcome
);
61 // Records stats about the arguments used when calling requestDevice.
62 // - The number of filters used.
63 // - The size of each filter.
64 // - UUID of the services used in filters.
65 // - Number of optional services used.
66 // - UUID of the optional services.
67 // - Size of the union of all services.
68 void RecordRequestDeviceArguments(
69 const std::vector
<content::BluetoothScanFilter
>& filters
,
70 const std::vector
<device::BluetoothUUID
>& optional_services
);
72 // connectGATT() Metrics
73 enum class UMAConnectGATTOutcome
{
83 UNSUPPORTED_DEVICE
= 9,
84 // Note: Add new ConnectGATT outcomes immediately above this line. Make sure
85 // to update the enum list in tools/metrics/histograms/histograms.xml
89 // There should be a call to this function before every
90 // Send(BluetoothMsg_ConnectGATTSuccess) and
91 // Send(BluetoothMsg_ConnectGATTError).
92 void RecordConnectGATTOutcome(UMAConnectGATTOutcome outcome
);
93 // Records how long it took for the connection to succeed.
94 void RecordConnectGATTTimeSuccess(const base::TimeDelta
& duration
);
95 // Records how long it took for the connection to fail.
96 void RecordConnectGATTTimeFailed(const base::TimeDelta
& duration
);
98 // getPrimaryService() Metrics
99 enum class UMAGetPrimaryServiceOutcome
{
103 // Note: Add new GetPrimaryService outcomes immediately above this line.
104 // Make sure to update the enum list in
105 // tools/metrics/histograms/histograms.xml accordingly.
108 // Record the service uuid used when calling getPrimaryService.
109 void RecordGetPrimaryServiceService(const device::BluetoothUUID
& service
);
110 // There should be a call to this function for every call to
111 // Send(BluetoothMsg_GetPrimaryServiceSuccess) and
112 // Send(BluetoothMsg_GetPrimaryServiceError).
113 void RecordGetPrimaryServiceOutcome(UMAGetPrimaryServiceOutcome outcome
);
115 // getCharacteristic() Metrics
116 enum class UMAGetCharacteristicOutcome
{
121 // Note: Add new outcomes immediately above this line.
122 // Make sure to update the enum list in
123 // tools/metrisc/histogram/histograms.xml accordingly.
126 // There should be a call to this function for every call to
127 // Send(BluetoothMsg_GetCharacteristicSuccess) and
128 // Send(BluetoothMsg_GetCharacteristicError).
129 void RecordGetCharacteristicOutcome(UMAGetCharacteristicOutcome outcome
);
130 // Records the UUID of the characteristic used when calling getCharacteristic.
131 void RecordGetCharacteristicCharacteristic(const std::string
& characteristic
);
133 // GATT Operations Metrics
135 // These are the possible outcomes when performing GATT operations i.e.
136 // characteristic.readValue/writeValue descriptor.readValue/writeValue.
137 enum UMAGATTOperationOutcome
{
141 NO_CHARACTERISTIC
= 3,
151 // Note: Add new GATT Outcomes immediately above this line.
152 // Make sure to update the enum list in
153 // tools/metrics/histograms/histograms.xml accordingly.
157 enum class UMAGATTOperation
{
159 CHARACTERISTIC_WRITE
,
160 // Note: Add new GATT Operations immediately above this line.
164 // Records the outcome of a GATT operation.
165 // There should be a call to this function whenever the corresponding operation
166 // doesn't have a call to Record[Operation]Outcome.
167 void RecordGATTOperationOutcome(UMAGATTOperation operation
,
168 UMAGATTOperationOutcome outcome
);
170 // Characteristic.readValue() Metrics
171 // There should be a call to this function for every call to
172 // Send(BluetoothMsg_ReadCharacteristicValueSuccess) and
173 // Send(BluetoothMsg_ReadCharacteristicValueError).
174 void RecordCharacteristicReadValueOutcome(UMAGATTOperationOutcome error
);
176 // Characteristic.writeValue() Metrics
177 // There should be a call to this function for every call to
178 // Send(BluetoothMsg_WriteCharacteristicValueSuccess) and
179 // Send(BluetoothMsg_WriteCharacteristicValueError).
180 void RecordCharacteristicWriteValueOutcome(UMAGATTOperationOutcome error
);
182 } // namespace content
184 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_METRICS_H_