OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_METRICS_H_ |
| 6 #define CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_METRICS_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 namespace base { |
| 11 class TimeDelta; |
| 12 } |
| 13 |
| 14 namespace device { |
| 15 class BluetoothUUID; |
| 16 } |
| 17 |
| 18 namespace content { |
| 19 struct BluetoothScanFilter; |
| 20 |
| 21 // General Metrics |
| 22 |
| 23 // Enumaration of each Web Bluetooth API entry point. |
| 24 enum class UMAWebBluetoothFunction { |
| 25 REQUEST_DEVICE = 0, |
| 26 CONNECT_GATT = 1, |
| 27 GET_PRIMARY_SERVICE = 2, |
| 28 GET_CHARACTERISTIC = 3, |
| 29 CHARACTERISTIC_READ_VALUE = 4, |
| 30 CHARACTERISTIC_WRITE_VALUE = 5, |
| 31 // NOTE: Add new actions immediately above this line. Make sure to update |
| 32 // the enum list in tools/metrics/histograms/histograms.xml accordingly. |
| 33 COUNT |
| 34 }; |
| 35 |
| 36 // There should be a call to this function for every call to the Web Bluetooth |
| 37 // API. |
| 38 void RecordWebBluetoothFunctionCall(UMAWebBluetoothFunction function); |
| 39 |
| 40 // requestDevice() Metrics |
| 41 enum class UMARequestDeviceOutcome { |
| 42 SUCCESS = 0, |
| 43 NO_BLUETOOTH_ADAPTER = 1, |
| 44 NO_RENDER_FRAME = 2, |
| 45 DISCOVERY_START_FAILED = 3, |
| 46 DISCOVERY_STOP_FAILED = 4, |
| 47 NO_MATCHING_DEVICES_FOUND = 5, |
| 48 BLUETOOTH_ADAPTER_NOT_PRESENT = 6, |
| 49 BLUETOOTH_ADAPTER_OFF = 7, |
| 50 // NOTE: Add new requestDevice() outcomes immediately above this line. Make |
| 51 // sure to update the enum list in |
| 52 // tools/metrics/histograms/histograms.xml accordingly. |
| 53 COUNT |
| 54 }; |
| 55 // There should be a call to this function before every |
| 56 // Send(BluetoothMsg_RequestDeviceSuccess...) or |
| 57 // Send(BluetoothMsg_RequestDeviceError...). |
| 58 void RecordRequestDeviceOutcome(UMARequestDeviceOutcome outcome); |
| 59 |
| 60 // Records stats about the arguments used when calling requestDevice. |
| 61 // - The number of filters used. |
| 62 // - The size of each filter. |
| 63 // - UUID of the services used in filters. |
| 64 // - Number of optional services used. |
| 65 // - UUID of the optional services. |
| 66 // - Size of the union of all services. |
| 67 void RecordRequestDeviceArguments( |
| 68 const std::vector<content::BluetoothScanFilter>& filters, |
| 69 const std::vector<device::BluetoothUUID>& optional_services); |
| 70 |
| 71 // connectGATT() Metrics |
| 72 enum class UMAConnectGATTOutcome { |
| 73 SUCCESS = 0, |
| 74 NO_DEVICE = 1, |
| 75 UNKNOWN = 2, |
| 76 IN_PROGRESS = 3, |
| 77 FAILED = 4, |
| 78 AUTH_FAILED = 5, |
| 79 AUTH_CANCELED = 6, |
| 80 AUTH_REJECTED = 7, |
| 81 AUTH_TIMEOUT = 8, |
| 82 UNSUPPORTED_DEVICE = 9, |
| 83 // Note: Add new ConnectGATT outcomes immediately above this line. Make sure |
| 84 // to update the enum list in tools/metrics/histograms/histograms.xml |
| 85 // accordingly. |
| 86 COUNT |
| 87 }; |
| 88 // There should be a call to this function before every |
| 89 // Send(BluetoothMsg_ConnectGATTSuccess) and |
| 90 // Send(BluetoothMsg_ConnectGATTError). |
| 91 void RecordConnectGATTOutcome(UMAConnectGATTOutcome outcome); |
| 92 // Records how long it took for the connection to succeed. |
| 93 void RecordConnectGATTTimeSuccess(const base::TimeDelta& duration); |
| 94 // Records how long it took for the connection to fail. |
| 95 void RecordConnectGATTTimeFailed(const base::TimeDelta& duration); |
| 96 |
| 97 // getPrimaryService() Metrics |
| 98 enum class UMAGetPrimaryServiceOutcome { |
| 99 SUCCESS = 0, |
| 100 NO_DEVICE = 1, |
| 101 NOT_FOUND = 2, |
| 102 // Note: Add new GetPrimaryService outcomes immediately above this line. |
| 103 // Make sure to update the enum list in |
| 104 // tools/metrics/histograms/histograms.xml accordingly. |
| 105 COUNT |
| 106 }; |
| 107 // Record the service uuid used when calling getPrimaryService. |
| 108 void RecordGetPrimaryServiceService(const device::BluetoothUUID& service); |
| 109 // There should be a call to this function for every call to |
| 110 // Send(BluetoothMsg_GetPrimaryServiceSuccess) and |
| 111 // Send(BluetoothMsg_GetPrimaryServiceError). |
| 112 void RecordGetPrimaryServiceOutcome(UMAGetPrimaryServiceOutcome outcome); |
| 113 |
| 114 // read/write characteristics Metrics |
| 115 // TODO(ortuno): For now we are just copying over the code to record these |
| 116 // errors but a follow up CL will add a function for each operation. |
| 117 |
| 118 // These types of errors aren't as common. We log them to understand |
| 119 // how common they are and if we need to investigate more. |
| 120 enum class UMAGATTError { |
| 121 UNKNOWN = 0, |
| 122 FAILED = 1, |
| 123 IN_PROGRESS = 2, |
| 124 NOT_PAIRED = 3, |
| 125 // Note: Add new GATT Errors immediately above this line. |
| 126 // Make sure to update the enum list in |
| 127 // tools/metrics/histograms/histograms.xml accordingly. |
| 128 MAX_ERROR, |
| 129 }; |
| 130 // Records the GATT Error the function returned. |
| 131 void RecordGATTError(UMAGATTError error); |
| 132 |
| 133 } // namespace content |
| 134 |
| 135 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_METRICS_H_ |
OLD | NEW |