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

Unified Diff: chrome/browser/ui/cocoa/confirm_quit_panel_controller.mm

Issue 6794030: [Mac] Confirm-to-quit: Add histogram metrics. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 9 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 | « chrome/browser/ui/cocoa/confirm_quit_panel_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/confirm_quit_panel_controller.mm
diff --git a/chrome/browser/ui/cocoa/confirm_quit_panel_controller.mm b/chrome/browser/ui/cocoa/confirm_quit_panel_controller.mm
index 1fe843cbec04df98e373d2ac6128aa1ff4cc9e1a..4b44d4d6ecd7ce0e1a95b9e887bd146bd189b559 100644
--- a/chrome/browser/ui/cocoa/confirm_quit_panel_controller.mm
+++ b/chrome/browser/ui/cocoa/confirm_quit_panel_controller.mm
@@ -7,6 +7,7 @@
#include "base/logging.h"
#include "base/memory/scoped_nsobject.h"
+#include "base/metrics/histogram.h"
#include "base/sys_string_conversions.h"
#import "chrome/browser/ui/cocoa/confirm_quit_panel_controller.h"
#include "grit/generated_resources.h"
@@ -24,6 +25,20 @@ const NSTimeInterval kTimeDeltaFuzzFactor = 1.0;
// Duration of the window fade out animation.
const NSTimeInterval kWindowFadeAnimationDuration = 0.2;
+// For metrics recording only: How long the user must hold the keys to
+// differentitate kDoubleTap from kTapHold.
+const NSTimeInterval kDoubleTapTimeDelta = 0.32;
+
+// Functions ///////////////////////////////////////////////////////////////////
+
+namespace confirm_quit {
+
+void RecordHistogram(ConfirmQuitMetric sample) {
+ HISTOGRAM_ENUMERATION("ConfirmToQuit", sample, kSampleCount);
+}
+
+} // namespace confirm_quit
+
// Custom Content View /////////////////////////////////////////////////////////
// The content view of the window that draws a custom frame.
@@ -217,6 +232,12 @@ ConfirmQuitPanelController* g_confirmQuitPanelController = nil;
NSEvent* nextEvent = [self pumpEventQueueForKeyUp:app
untilDate:[NSDate distantFuture]];
[app discardEventsMatchingMask:NSAnyEventMask beforeEvent:nextEvent];
+
+ // Based on how long the user held the keys, record the metric.
+ if ([[NSDate date] timeIntervalSinceDate:timeNow] < kDoubleTapTimeDelta)
+ confirm_quit::RecordHistogram(confirm_quit::kDoubleTap);
+ else
+ confirm_quit::RecordHistogram(confirm_quit::kTapHold);
return NSTerminateNow;
} else {
[lastQuitAttempt release]; // Harmless if already nil.
@@ -263,6 +284,7 @@ ConfirmQuitPanelController* g_confirmQuitPanelController = nil;
if (willQuit) {
// The user held down the combination long enough that quitting should
// happen.
+ confirm_quit::RecordHistogram(confirm_quit::kHoldDuration);
return NSTerminateNow;
} else {
// Slowly fade the confirm window out in case the user doesn't
« no previous file with comments | « chrome/browser/ui/cocoa/confirm_quit_panel_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698