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

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: Fix compile errors on bots 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
« no previous file with comments | « content/browser/bluetooth/bluetooth_metrics.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..32dde3b0fd68768a3df88f522063a0da4a3a36e3 100644
--- a/content/browser/bluetooth/bluetooth_metrics.cc
+++ b/content/browser/bluetooth/bluetooth_metrics.cc
@@ -103,6 +103,11 @@ void RecordConnectGATTOutcome(UMAConnectGATTOutcome outcome) {
static_cast<int>(UMAConnectGATTOutcome::COUNT));
}
+void RecordConnectGATTOutcome(CacheQueryOutcome outcome) {
+ DCHECK(outcome == CacheQueryOutcome::NO_DEVICE);
+ RecordConnectGATTOutcome(UMAConnectGATTOutcome::NO_DEVICE);
+}
+
void RecordConnectGATTTimeSuccess(const base::TimeDelta& duration) {
UMA_HISTOGRAM_MEDIUM_TIMES("Bluetooth.Web.ConnectGATT.TimeSuccess", duration);
}
@@ -126,6 +131,11 @@ void RecordGetPrimaryServiceOutcome(UMAGetPrimaryServiceOutcome outcome) {
static_cast<int>(UMAGetPrimaryServiceOutcome::COUNT));
}
+void RecordGetPrimaryServiceOutcome(CacheQueryOutcome outcome) {
+ DCHECK(outcome == CacheQueryOutcome::NO_DEVICE);
+ RecordGetPrimaryServiceOutcome(UMAGetPrimaryServiceOutcome::NO_DEVICE);
+}
+
// getCharacteristic
void RecordGetCharacteristicOutcome(UMAGetCharacteristicOutcome outcome) {
@@ -134,6 +144,24 @@ void RecordGetCharacteristicOutcome(UMAGetCharacteristicOutcome outcome) {
static_cast<int>(UMAGetCharacteristicOutcome::COUNT));
}
+void RecordGetCharacteristicOutcome(CacheQueryOutcome outcome) {
+ switch (outcome) {
+ case CacheQueryOutcome::SUCCESS:
+ case CacheQueryOutcome::BAD_RENDERER:
+ NOTREACHED() << "No need to record a success or renderer crash";
+ return;
+ case CacheQueryOutcome::NO_DEVICE:
+ RecordGetCharacteristicOutcome(UMAGetCharacteristicOutcome::NO_DEVICE);
+ return;
+ case CacheQueryOutcome::NO_SERVICE:
+ RecordGetCharacteristicOutcome(UMAGetCharacteristicOutcome::NO_SERVICE);
+ return;
+ case CacheQueryOutcome::NO_CHARACTERISTIC:
+ NOTREACHED();
+ return;
+ }
+}
+
void RecordGetCharacteristicCharacteristic(const std::string& characteristic) {
UMA_HISTOGRAM_SPARSE_SLOWLY("Bluetooth.Web.GetCharacteristic.Characteristic",
HashUUID(characteristic));
@@ -160,6 +188,24 @@ void RecordGATTOperationOutcome(UMAGATTOperation operation,
NOTREACHED();
}
+static UMAGATTOperationOutcome TranslateCacheQueryOutcomeToGATTOperationOutcome(
+ CacheQueryOutcome outcome) {
+ switch (outcome) {
+ case CacheQueryOutcome::SUCCESS:
+ case CacheQueryOutcome::BAD_RENDERER:
+ NOTREACHED() << "No need to record success or renderer crash";
+ return UMAGATTOperationOutcome::NOT_SUPPORTED;
+ case CacheQueryOutcome::NO_DEVICE:
+ return UMAGATTOperationOutcome::NO_DEVICE;
+ case CacheQueryOutcome::NO_SERVICE:
+ return UMAGATTOperationOutcome::NO_SERVICE;
+ case CacheQueryOutcome::NO_CHARACTERISTIC:
+ return UMAGATTOperationOutcome::NO_CHARACTERISTIC;
+ }
+ NOTREACHED() << "No need to record success or renderer crash";
+ return UMAGATTOperationOutcome::NOT_SUPPORTED;
+}
+
// Characteristic.readValue
// static
@@ -169,6 +215,11 @@ void RecordCharacteristicReadValueOutcome(UMAGATTOperationOutcome outcome) {
static_cast<int>(UMAGATTOperationOutcome::COUNT));
}
+void RecordCharacteristicReadValueOutcome(CacheQueryOutcome outcome) {
+ RecordCharacteristicReadValueOutcome(
+ TranslateCacheQueryOutcomeToGATTOperationOutcome(outcome));
+}
+
// Characteristic.writeValue
void RecordCharacteristicWriteValueOutcome(UMAGATTOperationOutcome outcome) {
@@ -177,6 +228,11 @@ void RecordCharacteristicWriteValueOutcome(UMAGATTOperationOutcome outcome) {
static_cast<int>(UMAGATTOperationOutcome::COUNT));
}
+void RecordCharacteristicWriteValueOutcome(CacheQueryOutcome outcome) {
+ RecordCharacteristicWriteValueOutcome(
+ TranslateCacheQueryOutcomeToGATTOperationOutcome(outcome));
+}
+
// Characteristic.startNotifications
void RecordStartNotificationsOutcome(UMAGATTOperationOutcome outcome) {
UMA_HISTOGRAM_ENUMERATION(
@@ -185,4 +241,9 @@ void RecordStartNotificationsOutcome(UMAGATTOperationOutcome outcome) {
static_cast<int>(UMAGATTOperationOutcome::COUNT));
}
+void RecordStartNotificationsOutcome(CacheQueryOutcome outcome) {
+ RecordStartNotificationsOutcome(
+ TranslateCacheQueryOutcomeToGATTOperationOutcome(outcome));
+}
+
} // namespace content
« no previous file with comments | « content/browser/bluetooth/bluetooth_metrics.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698