forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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}
- Loading branch information
1 parent
72359fe
commit 42faa2d
Showing
9 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
chrome/browser/ui/ash/metrics/chrome_user_metrics_recorder.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// 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); | ||
} |
40 changes: 40 additions & 0 deletions
40
chrome/browser/ui/ash/metrics/chrome_user_metrics_recorder.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// 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_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters