Commit 42faa2d8 authored by bruthig's avatar bruthig Committed by Commit bot

Added the Ash.Tab.TimeBetweenSwitchToExistingTabUserActions histogram to track...

Added the Ash.Tab.TimeBetweenSwitchToExistingTabUserActions histogram to track time between tab switches.

TEST=Manually verified histogram data added on ChromeOS.

BUG=478930

Review URL: https://codereview.chromium.org/1124153007

Cr-Commit-Position: refs/heads/master@{#330217}
parent 72359fec
......@@ -13,6 +13,9 @@ namespace {
const char kShelfHistogramName[] =
"Ash.Shelf.TimeBetweenNavigateToTaskSwitches";
const char kTabStripHistogramName[] =
"Ash.Tab.TimeBetweenSwitchToExistingTabUserActions";
const char kAcceleratorWindowCycleHistogramName[] =
"Ash.WindowCycleController.TimeBetweenTaskSwitches";
......@@ -22,6 +25,8 @@ const char* GetHistogramName(
switch (task_switch_source) {
case TaskSwitchMetricsRecorder::kShelf:
return kShelfHistogramName;
case TaskSwitchMetricsRecorder::kTabStrip:
return kTabStripHistogramName;
case TaskSwitchMetricsRecorder::kWindowCycleController:
return kAcceleratorWindowCycleHistogramName;
}
......
......@@ -24,6 +24,8 @@ class ASH_EXPORT TaskSwitchMetricsRecorder {
enum TaskSwitchSource {
// All task switches caused by shelf buttons, not including sub-menus.
kShelf,
// All task switches caused by the tab strip.
kTabStrip,
// Task switches caused by the WindowCycleController (ie Alt+Tab).
kWindowCycleController
};
......
......@@ -92,4 +92,19 @@ TEST_F(TaskSwitchMetricsRecorderTest,
histogram_tester_->ExpectTotalCount(kHistogramName, 2);
}
// Verifies that the TaskSwitchMetricsRecorder::kTabStrip source adds data to
// the Ash.Tab.TimeBetweenSwitchToExistingTabUserActions histogram.
TEST_F(TaskSwitchMetricsRecorderTest,
VerifyTaskSwitchesFromTheTabStripAreRecorded) {
const std::string kHistogramName =
"Ash.Tab.TimeBetweenSwitchToExistingTabUserActions";
OnTaskSwitch(TaskSwitchMetricsRecorder::kTabStrip);
OnTaskSwitch(TaskSwitchMetricsRecorder::kTabStrip);
histogram_tester_->ExpectTotalCount(kHistogramName, 1);
OnTaskSwitch(TaskSwitchMetricsRecorder::kTabStrip);
histogram_tester_->ExpectTotalCount(kHistogramName, 2);
}
} // namespace ash
......@@ -13,6 +13,7 @@
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
#include "chrome/browser/ui/ash/metrics/chrome_user_metrics_recorder.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
......@@ -93,6 +94,9 @@ class ChromeShellDelegate : public ash::ShellDelegate,
ObserverList<ash::VirtualKeyboardStateObserver> keyboard_state_observer_list_;
// Proxies events from chrome/browser to ash::UserMetricsRecorder.
scoped_ptr<ChromeUserMetricsRecorder> chrome_user_metrics_recorder_;
#if defined(OS_CHROMEOS)
scoped_ptr<chromeos::DisplayConfigurationObserver>
display_configuration_observer_;
......
......@@ -217,10 +217,13 @@ void ChromeShellDelegate::PreInit() {
// in Shell::Init.
display_configuration_observer_.reset(
new chromeos::DisplayConfigurationObserver());
chrome_user_metrics_recorder_.reset(new ChromeUserMetricsRecorder);
}
void ChromeShellDelegate::PreShutdown() {
display_configuration_observer_.reset();
chrome_user_metrics_recorder_.reset();
}
ash::SessionStateDelegate* ChromeShellDelegate::CreateSessionStateDelegate() {
......
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/ash/metrics/chrome_user_metrics_recorder.h"
#include "ash/metrics/task_switch_metrics_recorder.h"
#include "ash/metrics/user_metrics_recorder.h"
#include "ash/shell.h"
#include "base/logging.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/host_desktop.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
ChromeUserMetricsRecorder::ChromeUserMetricsRecorder() {
BrowserList::AddObserver(this);
}
ChromeUserMetricsRecorder::~ChromeUserMetricsRecorder() {
DCHECK(BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH)->empty());
BrowserList::RemoveObserver(this);
}
void ChromeUserMetricsRecorder::OnBrowserAdded(Browser* browser) {
browser->tab_strip_model()->AddObserver(this);
}
void ChromeUserMetricsRecorder::OnBrowserRemoved(Browser* browser) {
browser->tab_strip_model()->RemoveObserver(this);
}
void ChromeUserMetricsRecorder::ActiveTabChanged(
content::WebContents* old_contents,
content::WebContents* new_contents,
int index,
int reason) {
if (reason & CHANGE_REASON_USER_GESTURE)
OnTabSwitchedByUserGesture();
}
void ChromeUserMetricsRecorder::OnTabSwitchedByUserGesture() {
ash::Shell::GetInstance()
->metrics()
->task_switch_metrics_recorder()
.OnTaskSwitch(ash::TaskSwitchMetricsRecorder::kTabStrip);
}
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_ASH_METRICS_CHROME_USER_METRICS_RECORDER_H_
#define CHROME_BROWSER_UI_ASH_METRICS_CHROME_USER_METRICS_RECORDER_H_
#include "base/macros.h"
#include "chrome/browser/ui/browser_list_observer.h"
#include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
namespace content {
class WebContents;
} // namespace content
// A bridge proxy between chrome/browser events and ash::UserMetricsRecorder.
class ChromeUserMetricsRecorder : public chrome::BrowserListObserver,
public TabStripModelObserver {
public:
ChromeUserMetricsRecorder();
~ChromeUserMetricsRecorder() override;
// chrome::BroswerListObserver:
void OnBrowserAdded(Browser* browser) override;
void OnBrowserRemoved(Browser* browser) override;
// TabStripModelObserver:
void ActiveTabChanged(content::WebContents* old_contents,
content::WebContents* new_contents,
int index,
int reason) override;
private:
// Called when a different tab becomes active due to a user gesture.
void OnTabSwitchedByUserGesture();
DISALLOW_COPY_AND_ASSIGN(ChromeUserMetricsRecorder);
};
#endif // CHROME_BROWSER_UI_ASH_METRICS_CHROME_USER_METRICS_RECORDER_H_
......@@ -599,6 +599,8 @@
'browser/ui/ash/launcher/multi_profile_browser_status_monitor.h',
'browser/ui/ash/media_delegate_chromeos.cc',
'browser/ui/ash/media_delegate_chromeos.h',
'browser/ui/ash/metrics/chrome_user_metrics_recorder.cc',
'browser/ui/ash/metrics/chrome_user_metrics_recorder.h',
'browser/ui/ash/multi_user/multi_user_context_menu_chromeos.cc',
'browser/ui/ash/multi_user/multi_user_notification_blocker_chromeos.cc',
'browser/ui/ash/multi_user/multi_user_notification_blocker_chromeos.h',
......
......@@ -785,6 +785,16 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<summary>The duration of mostly stationary long-duration touches.</summary>
</histogram>
<histogram name="Ash.Tab.TimeBetweenSwitchToExistingTabUserActions"
units="seconds">
<owner>bruthig@chromium.org</owner>
<owner>tdanderson@chromium.org</owner>
<summary>
The number of seconds between tab switches triggered by a user gesture (e.g.
Ctrl+T, Ctrl+1, tapping or clicking the tab strip, etc).
</summary>
</histogram>
<histogram name="Ash.TouchDuration" units="milliseconds">
<obsolete>
Deprecated 12/2013 in r239809, and replaced by Ash.TouchDuration2.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment