[refactor] More post-NSS WebCrypto cleanups (utility functions).
[chromium-blink-merge.git] / content / browser / bluetooth / bluetooth_metrics.h
blobfb1a282d351e949844fdf7ac1da75179c0bbd489
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_
8 #include <string>
9 #include <vector>
11 namespace base {
12 class TimeDelta;
15 namespace device {
16 class BluetoothUUID;
19 namespace content {
20 struct BluetoothScanFilter;
22 // General Metrics
24 // Enumaration of each Web Bluetooth API entry point.
25 enum class UMAWebBluetoothFunction {
26 REQUEST_DEVICE = 0,
27 CONNECT_GATT = 1,
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.
34 COUNT
37 // There should be a call to this function for every call to the Web Bluetooth
38 // API.
39 void RecordWebBluetoothFunctionCall(UMAWebBluetoothFunction function);
41 // requestDevice() Metrics
42 enum class UMARequestDeviceOutcome {
43 SUCCESS = 0,
44 NO_BLUETOOTH_ADAPTER = 1,
45 NO_RENDER_FRAME = 2,
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.
56 COUNT
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 {
76 SUCCESS = 0,
77 NO_DEVICE = 1,
78 UNKNOWN = 2,
79 IN_PROGRESS = 3,
80 FAILED = 4,
81 AUTH_FAILED = 5,
82 AUTH_CANCELED = 6,
83 AUTH_REJECTED = 7,
84 AUTH_TIMEOUT = 8,
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
88 // accordingly.
89 COUNT
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 {
102 SUCCESS = 0,
103 NO_DEVICE = 1,
104 NOT_FOUND = 2,
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.
108 COUNT
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 {
119 SUCCESS = 0,
120 NO_DEVICE = 1,
121 NO_SERVICE = 2,
122 NOT_FOUND = 3,
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.
126 COUNT
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 {
140 SUCCESS = 0,
141 NO_DEVICE = 1,
142 NO_SERVICE = 2,
143 NO_CHARACTERISTIC = 3,
144 NO_DESCRIPTOR = 4,
145 UNKNOWN = 5,
146 FAILED = 6,
147 IN_PROGRESS = 7,
148 INVALID_LENGTH = 8,
149 NOT_PERMITTED = 9,
150 NOT_AUTHORIZED = 10,
151 NOT_PAIRED = 11,
152 NOT_SUPPORTED = 12,
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.
156 COUNT
159 enum class UMAGATTOperation {
160 CHARACTERISTIC_READ,
161 CHARACTERISTIC_WRITE,
162 // Note: Add new GATT Operations immediately above this line.
163 COUNT
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_