Chromium Code Reviews| Index: content/browser/bluetooth/bluetooth_metrics.cc |
| diff --git a/content/browser/bluetooth/bluetooth_metrics.cc b/content/browser/bluetooth/bluetooth_metrics.cc |
| index e9a34c82ad9e2912e0e44609ed87a224e4116337..96a9b94c115f3224f1198cf17589268c74627f10 100644 |
| --- a/content/browser/bluetooth/bluetooth_metrics.cc |
| +++ b/content/browser/bluetooth/bluetooth_metrics.cc |
| @@ -36,6 +36,63 @@ void RecordWebBluetoothFunctionCall(UMAWebBluetoothFunction function) { |
| static_cast<int>(UMAWebBluetoothFunction::COUNT)); |
| } |
| +static UMAGATTOperationOutcome TranslateCacheQueryOutcomeToGATT( |
| + CacheQueryOutcome outcome) { |
| + switch (outcome) { |
| + case CacheQueryOutcome::NO_DEVICE: |
| + return UMAGATTOperationOutcome::NO_DEVICE; |
| + case CacheQueryOutcome::NO_SERVICE: |
| + return UMAGATTOperationOutcome::NO_SERVICE; |
| + case CacheQueryOutcome::NO_CHARACTERISTIC: |
| + return UMAGATTOperationOutcome::NO_CHARACTERISTIC; |
| + default: |
| + NOTIMPLEMENTED(); |
| + return UMAGATTOperationOutcome::NOT_SUPPORTED; |
| + } |
| +} |
| + |
| +void RecordOutcomeWithCacheQueryResult(UMAWebBluetoothFunction function, |
| + CacheQueryOutcome outcome) { |
| + switch (function) { |
| + case UMAWebBluetoothFunction::CONNECT_GATT: |
| + DCHECK(outcome == CacheQueryOutcome::NO_DEVICE); |
| + RecordConnectGATTOutcome(UMAConnectGATTOutcome::NO_DEVICE); |
| + return; |
| + case UMAWebBluetoothFunction::GET_PRIMARY_SERVICE: |
| + DCHECK(outcome == CacheQueryOutcome::NO_DEVICE); |
| + RecordGetPrimaryServiceOutcome(UMAGetPrimaryServiceOutcome::NO_DEVICE); |
| + return; |
| + case UMAWebBluetoothFunction::GET_CHARACTERISTIC: |
| + switch (outcome) { |
| + case CacheQueryOutcome::NO_DEVICE: |
| + RecordGetCharacteristicOutcome( |
| + UMAGetCharacteristicOutcome::NO_DEVICE); |
| + return; |
| + case CacheQueryOutcome::NO_SERVICE: |
| + RecordGetCharacteristicOutcome( |
| + UMAGetCharacteristicOutcome::NO_SERVICE); |
| + return; |
| + default: |
| + NOTIMPLEMENTED(); |
|
scheib
2015/10/19 23:15:54
I suggest not using 'default' in switch statements
ortuno
2015/10/20 17:44:03
Done.
|
| + return; |
| + } |
| + case UMAWebBluetoothFunction::CHARACTERISTIC_READ_VALUE: |
| + RecordCharacteristicReadValueOutcome( |
| + TranslateCacheQueryOutcomeToGATT(outcome)); |
| + return; |
| + case UMAWebBluetoothFunction::CHARACTERISTIC_WRITE_VALUE: |
| + RecordCharacteristicWriteValueOutcome( |
| + TranslateCacheQueryOutcomeToGATT(outcome)); |
| + return; |
| + case UMAWebBluetoothFunction::CHARACTERISTIC_START_NOTIFICATIONS: |
| + RecordStartNotificationsOutcome( |
| + TranslateCacheQueryOutcomeToGATT(outcome)); |
| + return; |
| + default: |
| + NOTIMPLEMENTED(); |
| + } |
| +} |
| + |
| // requestDevice() |
| void RecordRequestDeviceOutcome(UMARequestDeviceOutcome outcome) { |