Make USB permissions work in the new permission message system
[chromium-blink-merge.git] / content / browser / bluetooth / bluetooth_metrics.h
blobd0947650db532530c3083a61766056e39e150fc6
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 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.
54 COUNT
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 {
74 SUCCESS = 0,
75 NO_DEVICE = 1,
76 UNKNOWN = 2,
77 IN_PROGRESS = 3,
78 FAILED = 4,
79 AUTH_FAILED = 5,
80 AUTH_CANCELED = 6,
81 AUTH_REJECTED = 7,
82 AUTH_TIMEOUT = 8,
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
86 // accordingly.
87 COUNT
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 {
100 SUCCESS = 0,
101 NO_DEVICE = 1,
102 NOT_FOUND = 2,
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.
106 COUNT
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 {
117 SUCCESS = 0,
118 NO_DEVICE = 1,
119 NO_SERVICE = 2,
120 NOT_FOUND = 3,
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.
124 COUNT
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 {
138 SUCCESS = 0,
139 NO_DEVICE = 1,
140 NO_SERVICE = 2,
141 NO_CHARACTERISTIC = 3,
142 NO_DESCRIPTOR = 4,
143 UNKNOWN = 5,
144 FAILED = 6,
145 IN_PROGRESS = 7,
146 INVALID_LENGTH = 8,
147 NOT_PERMITTED = 9,
148 NOT_AUTHORIZED = 10,
149 NOT_PAIRED = 11,
150 NOT_SUPPORTED = 12,
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.
154 COUNT
157 enum class UMAGATTOperation {
158 CHARACTERISTIC_READ,
159 CHARACTERISTIC_WRITE,
160 // Note: Add new GATT Operations immediately above this line.
161 COUNT
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_