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

Unified Diff: chrome/browser/chrome_webusb_browser_client.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/chrome_webusb_browser_client.cc
diff --git a/chrome/browser/chrome_webusb_browser_client.cc b/chrome/browser/chrome_webusb_browser_client.cc
index 24a63f29f81320b87f1cac3260878c09647449f0..29428149f1eb0c6898b9aefc55eb4db594bfcd3c 100644
--- a/chrome/browser/chrome_webusb_browser_client.cc
+++ b/chrome/browser/chrome_webusb_browser_client.cc
@@ -7,6 +7,7 @@
#include <utility>
#include "base/macros.h"
+#include "base/metrics/histogram_macros.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/net/referrer.h"
#include "chrome/browser/profiles/profile_manager.h"
@@ -30,6 +31,23 @@ namespace {
const char kWebUsbDetectorNotificationID[] = "webusb.detector";
+enum WebUsbNotificationClosed {
asargent_no_longer_on_chrome 2016/01/21 18:54:15 nit: We typically include a comment above enums us
+ // The notification was dismissed but not by the user (either automatically
+ // or because the device was unplugged).
+ WEBUSB_NOTIFICATION_CLOSED,
+ // The user closed the notification.
+ WEBUSB_NOTIFICATION_CLOSED_BY_USER,
+ // The user clicked on the notification.
+ WEBUSB_NOTIFICATION_CLOSED_CLICKED,
+ // Maximum value for the enum.
+ WEBUSB_NOTIFICATION_CLOSED_MAX
+};
+
+void RecordNotificationClosure(WebUsbNotificationClosed disposition) {
+ UMA_HISTOGRAM_ENUMERATION("WebUsb.NotificationClosed", disposition,
+ WEBUSB_NOTIFICATION_CLOSED_MAX);
+}
+
Browser* GetBrowser() {
chrome::ScopedTabbedBrowserDisplayer browser_displayer(
ProfileManager::GetActiveUserProfile(), chrome::GetActiveDesktop());
@@ -51,16 +69,27 @@ class WebUsbNotificationDelegate : public message_center::NotificationDelegate {
: landing_page_(landing_page), notification_id_(notification_id) {}
void Click() override {
+ clicked_ = true;
OpenURL(landing_page_);
message_center::MessageCenter::Get()->RemoveNotification(
notification_id_, false /* by_user */);
}
+ void Close(bool by_user) override {
+ if (clicked_)
+ RecordNotificationClosure(WEBUSB_NOTIFICATION_CLOSED_CLICKED);
+ else if (by_user)
+ RecordNotificationClosure(WEBUSB_NOTIFICATION_CLOSED_BY_USER);
+ else
+ RecordNotificationClosure(WEBUSB_NOTIFICATION_CLOSED);
+ }
+
private:
~WebUsbNotificationDelegate() override = default;
GURL landing_page_;
std::string notification_id_;
+ bool clicked_ = false;
DISALLOW_COPY_AND_ASSIGN(WebUsbNotificationDelegate);
};
« no previous file with comments | « no previous file | chrome/browser/usb/usb_chooser_bubble_delegate.cc » ('j') | tools/metrics/histograms/histograms.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698