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

Issue 6794030: [Mac] Confirm-to-quit: Add histogram metrics. (Closed)

Created:
9 years, 8 months ago by Robert Sesek
Modified:
9 years, 7 months ago
Reviewers:
Nico
CC:
chromium-reviews, pam+watch_chromium.org
Visibility:
Public.

Description

[Mac] Confirm-to-quit: Add histogram metrics. BUG=none TEST=none Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=80456

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+45 lines, -1 line) Patch
M chrome/browser/app_controller_mac.mm View 1 chunk +3 lines, -1 line 0 comments Download
M chrome/browser/ui/cocoa/confirm_quit_panel_controller.h View 1 chunk +20 lines, -0 lines 0 comments Download
M chrome/browser/ui/cocoa/confirm_quit_panel_controller.mm View 4 chunks +22 lines, -0 lines 0 comments Download

Messages

Total messages: 2 (0 generated)
Robert Sesek
9 years, 8 months ago (2011-04-04 20:21:10 UTC) #1
Nico
9 years, 8 months ago (2011-04-04 20:45:35 UTC) #2
LGTM

On Mon, Apr 4, 2011 at 1:21 PM,  <rsesek@chromium.org> wrote:
> Reviewers: Nico,
>
> Description:
> [Mac] Confirm-to-quit: Add histogram metrics.
>
> BUG=none
> TEST=none
>
>
> Please review this at http://codereview.chromium.org/6794030/
>
> SVN Base: svn://svn.chromium.org/chrome/trunk/src
>
> Affected files:
>  M chrome/browser/app_controller_mac.mm
>  M chrome/browser/ui/cocoa/confirm_quit_panel_controller.h
>  M chrome/browser/ui/cocoa/confirm_quit_panel_controller.mm
>
>
> Index: chrome/browser/app_controller_mac.mm
> diff --git a/chrome/browser/app_controller_mac.mm
> b/chrome/browser/app_controller_mac.mm
> index
>
e9d4d076616cd415bf6198f951ab6850ffe791ab..6934219cb24e7c5d21f20741803f2b728902e7e7
> 100644
> --- a/chrome/browser/app_controller_mac.mm
> +++ b/chrome/browser/app_controller_mac.mm
> @@ -277,8 +277,10 @@ void RecordLastRunAppBundlePath() {
>  -
> (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)app
> {
>   // Check if the preference is turned on.
>   const PrefService* prefs = [self defaultProfile]->GetPrefs();
> -  if (!prefs->GetBoolean(prefs::kConfirmToQuitEnabled))
> +  if (!prefs->GetBoolean(prefs::kConfirmToQuitEnabled)) {
> +    confirm_quit::RecordHistogram(confirm_quit::kNoConfirm);
>     return NSTerminateNow;
> +  }
>
>   // If the application is going to terminate as the result of a Cmd+Q
>   // invocation, use the special sauce to prevent accidental quitting.
> Index: chrome/browser/ui/cocoa/confirm_quit_panel_controller.h
> diff --git a/chrome/browser/ui/cocoa/confirm_quit_panel_controller.h
> b/chrome/browser/ui/cocoa/confirm_quit_panel_controller.h
> index
>
88b66f3044155160ab10b7f69117c323c29efbaa..8a1816d45a779112fedb58890c9bf5674a560dcc
> 100644
> --- a/chrome/browser/ui/cocoa/confirm_quit_panel_controller.h
> +++ b/chrome/browser/ui/cocoa/confirm_quit_panel_controller.h
> @@ -12,6 +12,26 @@
>
>  @class ConfirmQuitFrameView;
>
> +namespace confirm_quit {
> +
> +enum ConfirmQuitMetric {
> +  // The user quit without having the feature enabled.
> +  kNoConfirm = 0,
> +  // The user held Cmd+Q for the entire duration.
> +  kHoldDuration,
> +  // The user hit Cmd+Q twice for the accelerated path.
> +  kDoubleTap,
> +  // The user tapped Cmd+Q once and then held it.
> +  kTapHold,
> +
> +  kSampleCount
> +};
> +
> +// Records the histogram value for the above metric.
> +void RecordHistogram(ConfirmQuitMetric sample);
> +
> +}  // namespace confirm_quit
> +
>  // The ConfirmQuitPanelController manages the black HUD window that tells
> users
>  // to "Hold Cmd+Q to Quit".
>  @interface ConfirmQuitPanelController :
> NSWindowController<NSWindowDelegate> {
> 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
>
>
>

Powered by Google App Engine
This is Rietveld 408576698