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

Unified Diff: chrome/browser/usb/usb_chooser_context.cc

Issue 1584283003: Add UMA histograms for WebUSB. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move UMA macro usage into helper functions. Created 4 years, 11 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: chrome/browser/usb/usb_chooser_context.cc
diff --git a/chrome/browser/usb/usb_chooser_context.cc b/chrome/browser/usb/usb_chooser_context.cc
index 702c98adc162caa1287464026dd3efd3a40b3f37..4fcd5a5d9af2e18874cc557f27871da334ecbc7f 100644
--- a/chrome/browser/usb/usb_chooser_context.cc
+++ b/chrome/browser/usb/usb_chooser_context.cc
@@ -7,6 +7,7 @@
#include <utility>
#include <vector>
+#include "base/metrics/histogram_macros.h"
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
@@ -24,6 +25,20 @@ const char kProductIdKey[] = "product-id";
const char kSerialNumberKey[] = "serial-number";
const char kVendorIdKey[] = "vendor-id";
+enum WebUsbPermissionRevoked {
+ // Permission to access a USB device was revoked by the user.
+ WEBUSB_PERMISSION_REVOKED = 0,
+ // Permission to access an ephemeral USB device was revoked by the user.
+ WEBUSB_PERMISSION_REVOKED_EPHEMERAL,
+ // Maximum value for the enum.
+ WEBUSB_PERMISSION_REVOKED_MAX
+};
+
+void RecordPermissionRevocation(WebUsbPermissionRevoked kind) {
+ UMA_HISTOGRAM_ENUMERATION("WebUsb.PermissionRevoked", kind,
+ WEBUSB_PERMISSION_REVOKED_MAX);
+}
+
bool CanStorePersistentEntry(const scoped_refptr<const UsbDevice>& device) {
return !device->serial_number().empty();
}
@@ -116,9 +131,11 @@ void UsbChooserContext::RevokeObjectPermission(
std::string guid;
if (object.GetString(kGuidKey, &guid)) {
RevokeDevicePermission(requesting_origin, embedding_origin, guid);
+ RecordPermissionRevocation(WEBUSB_PERMISSION_REVOKED_EPHEMERAL);
} else {
ChooserContextBase::RevokeObjectPermission(requesting_origin,
embedding_origin, object);
+ RecordPermissionRevocation(WEBUSB_PERMISSION_REVOKED);
}
}

Powered by Google App Engine
This is Rietveld 408576698