Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(868)

Unified Diff: content/browser/bluetooth/bluetooth_metrics.cc

Issue 1397983004: bluetooth: Refactor repeated code used to find a Bluetooth object from its ID. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-characteristic-changed-1
Patch Set: Clean up Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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) {

Powered by Google App Engine
This is Rietveld 408576698