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

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: 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..fd1862c2fead199f85633bce1da9b01268c3c40c 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,15 @@ 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
+};
+
bool CanStorePersistentEntry(const scoped_refptr<const UsbDevice>& device) {
return !device->serial_number().empty();
}
@@ -116,9 +126,15 @@ void UsbChooserContext::RevokeObjectPermission(
std::string guid;
if (object.GetString(kGuidKey, &guid)) {
RevokeDevicePermission(requesting_origin, embedding_origin, guid);
+ UMA_HISTOGRAM_ENUMERATION("WebUsb.PermissionRevoked",
+ WEBUSB_PERMISSION_REVOKED_EPHEMERAL,
Alexei Svitkine (slow) 2016/01/18 20:05:13 Ditto.
Reilly Grant (use Gerrit) 2016/01/20 00:59:37 Done.
+ WEBUSB_PERMISSION_REVOKED_MAX);
} else {
ChooserContextBase::RevokeObjectPermission(requesting_origin,
embedding_origin, object);
+ UMA_HISTOGRAM_ENUMERATION("WebUsb.PermissionRevoked",
+ WEBUSB_PERMISSION_REVOKED,
+ WEBUSB_PERMISSION_REVOKED_MAX);
}
}

Powered by Google App Engine
This is Rietveld 408576698