1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229
|
// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_METRICS_H_
#define CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_METRICS_H_
#include <optional>
#include "third_party/blink/public/mojom/bluetooth/web_bluetooth.mojom.h"
namespace device {
class BluetoothUUID;
}
namespace content {
// General Metrics
// Enumeration for outcomes of querying the bluetooth cache.
enum class CacheQueryOutcome {
kSuccess = 0,
kBadRenderer = 1,
kNoDevice = 2,
kNoService = 3,
kNoCharacteristic = 4,
kNoDescriptor = 5,
};
// requestDevice() Metrics
// Records stats about the arguments used when calling requestDevice.
// - The union of filtered and optional service UUIDs.
void RecordRequestDeviceOptions(
const blink::mojom::WebBluetoothRequestDeviceOptionsPtr& options);
// GattServer.connect() Metrics
enum class UMAConnectGATTOutcome {
kSuccess = 0,
kNoDevice = 1,
kUnknown = 2,
kInProgress = 3,
kFailed = 4,
kAuthFailed = 5,
kAuthCanceled = 6,
kAuthRejected = 7,
kAuthTimeout = 8,
kUnsupportedDevice = 9,
kNotReady = 10,
kAlreadyConnected = 11,
kAlreadyExists = 12,
kNotConnected = 13,
kDoesNotExist = 14,
kInvalidArgs = 15,
kNonAuthTimeout = 16,
kNoMemory = 17,
kJniEnvironment = 18,
kJniThreadAttach = 19,
kWakelock = 20,
kUnexpectedState = 21,
kSocketError = 22,
// Note: Add new ConnectGATT outcomes immediately above this line. Make sure
// to update the enum list in
// tools/metrics/histograms/metadata/bluetooth/enums.xml accordingly.
kMaxValue = kSocketError,
};
// There should be a call to this function before every
// Send(BluetoothMsg_ConnectGATTSuccess) and
// Send(BluetoothMsg_ConnectGATTError).
void RecordConnectGATTOutcome(UMAConnectGATTOutcome outcome);
// Records the outcome of the cache query for connectGATT. Should only be called
// if QueryCacheForDevice fails.
void RecordConnectGATTOutcome(CacheQueryOutcome outcome);
// getPrimaryService() and getPrimaryServices() Metrics
// Records the UUID of the service used when calling getPrimaryService.
void RecordGetPrimaryServicesServices(
blink::mojom::WebBluetoothGATTQueryQuantity quantity,
const std::optional<device::BluetoothUUID>& service);
// getCharacteristic() and getCharacteristics() Metrics
enum class UMAGetCharacteristicOutcome {
kSuccess = 0,
kNoDevice = 1,
kNoService = 2,
kNotFound = 3,
kBlocklisted = 4,
kNoCharacteristics = 5,
// Note: Add new outcomes immediately above this line.
// Make sure to update the enum list in
// tools/metrics/histogram/histograms.xml accordingly.
kMaxValue = kNoCharacteristics,
};
enum class UMAGetDescriptorOutcome {
kSuccess = 0,
kNoDevice = 1,
kNoService = 2,
kNoCharacteristic = 3,
kNotFound = 4,
kBlocklisted = 5,
kNoDescriptors = 6,
// Note: Add new outcomes immediately above this line.
// Make sure to update the enum list in
// tools/metrics/histogram/histograms.xml accordingly.
kMaxValue = kNoDescriptors,
};
// There should be a call to this function whenever
// RemoteServiceGetCharacteristicsCallback is run.
// Pass blink::mojom::WebBluetoothGATTQueryQuantity::SINGLE for
// getCharacteristic.
// Pass blink::mojom::WebBluetoothGATTQueryQuantity::MULTIPLE for
// getCharacteristics.
void RecordGetCharacteristicsOutcome(
blink::mojom::WebBluetoothGATTQueryQuantity quantity,
UMAGetCharacteristicOutcome outcome);
// Records the outcome of the cache query for getCharacteristics. Should only be
// called if QueryCacheForService fails.
void RecordGetCharacteristicsOutcome(
blink::mojom::WebBluetoothGATTQueryQuantity quantity,
CacheQueryOutcome outcome);
// Records the UUID of the characteristic used when calling getCharacteristic.
void RecordGetCharacteristicsCharacteristic(
blink::mojom::WebBluetoothGATTQueryQuantity quantity,
const std::optional<device::BluetoothUUID>& characteristic);
// Records the outcome of the cache query for getDescriptors. Should only be
// called if QueryCacheForService fails.
void RecordGetDescriptorsOutcome(
blink::mojom::WebBluetoothGATTQueryQuantity quantity,
CacheQueryOutcome outcome);
// GATT Operations Metrics
// These are the possible outcomes when performing GATT operations i.e.
// characteristic.readValue/writeValue descriptor.readValue/writeValue.
enum class UMAGATTOperationOutcome {
kSuccess = 0,
kNoDevice = 1,
kNoService = 2,
kNoCharacteristic = 3,
kNoDescriptor = 4,
kUnknown = 5,
kFailed = 6,
kInProgress = 7,
kInvalidLength = 8,
kNotPermitted = 9,
kNotAuthorized = 10,
kNotPaired = 11,
kNotSupported = 12,
kBlocklisted = 13,
// Note: Add new GATT Outcomes immediately above this line.
// Make sure to update the enum list in
// tools/metrics/histograms/histograms.xml accordingly.
kMaxValue = kBlocklisted
};
// Values below do NOT map to UMA metric values.
enum class UMAGATTOperation {
kCharacteristicRead,
kCharacteristicWrite,
kStartNotifications,
kDescriptorReadObsolete,
kDescriptorWriteObsolete,
};
// Records the outcome of a GATT operation.
// There should be a call to this function whenever the corresponding operation
// doesn't have a call to Record[Operation]Outcome.
void RecordGATTOperationOutcome(UMAGATTOperation operation,
UMAGATTOperationOutcome outcome);
// Characteristic.readValue() Metrics:
// There should be a call to this function for every Mojo
// bluetooth.mojom.Device.ReadValueForCharacteristic response.
void RecordCharacteristicReadValueOutcome(UMAGATTOperationOutcome error);
// Records the outcome of a cache query for readValue. Should only be called if
// QueryCacheForCharacteristic fails.
void RecordCharacteristicReadValueOutcome(CacheQueryOutcome outcome);
// Characteristic.writeValue() Metrics
// There should be a call to this function for every Mojo
// bluetooth.mojom.Device.WriteValueForCharacteristic response.
void RecordCharacteristicWriteValueOutcome(UMAGATTOperationOutcome error);
// Records the outcome of a cache query for writeValue. Should only be called if
// QueryCacheForCharacteristic fails.
void RecordCharacteristicWriteValueOutcome(CacheQueryOutcome outcome);
// Characteristic.startNotifications() Metrics
// There should be a call to this function for every call to the
// blink.mojom.WebBluetoothService.RemoteCharacteristicStartNotifications Mojo
// call.
void RecordStartNotificationsOutcome(UMAGATTOperationOutcome outcome);
// Records the outcome of a cache query for startNotifications. Should only be
// called if QueryCacheForCharacteristic fails.
void RecordStartNotificationsOutcome(CacheQueryOutcome outcome);
enum class UMARSSISignalStrengthLevel {
kLessThanOrEqualToMinRssi = 0,
kLevel0 = 1,
kLevel1 = 2,
kLevel2 = 3,
kLevel3 = 4,
kLevel4 = 5,
kGreaterThanOrEqualToMaxRssi = 6,
// Note: Add new RSSI signal strength level immediately above this line.
kMaxValue = kGreaterThanOrEqualToMaxRssi,
};
// Records the raw RSSI, and processed result displayed to users, when
// content::BluetoothDeviceChooserController::CalculateSignalStrengthLevel() is
// called.
void RecordRSSISignalStrength(int rssi);
void RecordRSSISignalStrengthLevel(UMARSSISignalStrengthLevel level);
} // namespace content
#endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_METRICS_H_
|