Commit 23b7ba50 authored by Thomas Lukaszewicz's avatar Thomas Lukaszewicz Committed by Commit Bot

Tab Search: Add metrics to track closed tab position

This CL adds metrics to track the position of a closed tab from
both filtered and unfiltered lists.

Bug: 1099917
Change-Id: I32ee18442cf965a05d7d92152ffc730c34674538
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2530260
Commit-Queue: Thomas Lukaszewicz <tluk@chromium.org>
Reviewed-by: default avatarYuheng Huang <yuhengh@chromium.org>
Reviewed-by: default avatarJesse Doherty <jwd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826986}
parent cc1c8db4
...@@ -292,8 +292,9 @@ export class TabSearchAppElement extends PolymerElement { ...@@ -292,8 +292,9 @@ export class TabSearchAppElement extends PolymerElement {
*/ */
onItemClose_(e) { onItemClose_(e) {
performance.mark('close_tab:benchmark_begin'); performance.mark('close_tab:benchmark_begin');
const tabIndex = e.currentTarget.parentNode.indexOf(e.currentTarget);
const tabId = Number.parseInt(e.currentTarget.id, 10); const tabId = Number.parseInt(e.currentTarget.id, 10);
this.apiProxy_.closeTab(tabId); this.apiProxy_.closeTab(tabId, !!this.searchText_, tabIndex);
this.announceA11y_(loadTimeData.getString('a11yTabClosed')); this.announceA11y_(loadTimeData.getString('a11yTabClosed'));
listenOnce(this.$.tabsList, 'rendered-item-count-changed', () => { listenOnce(this.$.tabsList, 'rendered-item-count-changed', () => {
performance.mark('close_tab:benchmark_end'); performance.mark('close_tab:benchmark_end');
......
...@@ -18,8 +18,12 @@ export const TabSwitchAction = { ...@@ -18,8 +18,12 @@ export const TabSwitchAction = {
/** @interface */ /** @interface */
export class TabSearchApiProxy { export class TabSearchApiProxy {
/** @param {number} tabId */ /**
closeTab(tabId) {} * @param {number} tabId
* @param {boolean} withSearch
* @param {number} closedTabIndex
*/
closeTab(tabId, withSearch, closedTabIndex) {}
/** @return {Promise<{profileTabs: ProfileTabs}>} */ /** @return {Promise<{profileTabs: ProfileTabs}>} */
getProfileTabs() {} getProfileTabs() {}
...@@ -57,7 +61,11 @@ export class TabSearchApiProxyImpl { ...@@ -57,7 +61,11 @@ export class TabSearchApiProxyImpl {
} }
/** @override */ /** @override */
closeTab(tabId) { closeTab(tabId, withSearch, closedTabIndex) {
chrome.metricsPrivate.recordSmallCount(
withSearch ? 'Tabs.TabSearch.WebUI.IndexOfCloseTabInFilteredList' :
'Tabs.TabSearch.WebUI.IndexOfCloseTabInUnfilteredList',
closedTabIndex);
this.handler.closeTab(tabId); this.handler.closeTab(tabId);
} }
......
...@@ -110,8 +110,11 @@ suite('TabSearchAppTest', () => { ...@@ -110,8 +110,11 @@ suite('TabSearchAppTest', () => {
const tabSearchItemCloseButton = /** @type {!HTMLElement} */ ( const tabSearchItemCloseButton = /** @type {!HTMLElement} */ (
tabSearchItem.shadowRoot.querySelector('cr-icon-button')); tabSearchItem.shadowRoot.querySelector('cr-icon-button'));
tabSearchItemCloseButton.click(); tabSearchItemCloseButton.click();
const tabId = await testProxy.whenCalled('closeTab'); const [tabId, withSearch, closedTabIndex] =
await testProxy.whenCalled('closeTab');
assertEquals(tabData.tabId, tabId); assertEquals(tabData.tabId, tabId);
assertFalse(withSearch);
assertEquals(0, closedTabIndex);
}); });
test('Keyboard navigation on an empty list', async () => { test('Keyboard navigation on an empty list', async () => {
......
...@@ -30,8 +30,8 @@ export class TestTabSearchApiProxy extends TestBrowserProxy { ...@@ -30,8 +30,8 @@ export class TestTabSearchApiProxy extends TestBrowserProxy {
} }
/** @override */ /** @override */
closeTab(tabId) { closeTab(tabId, withSearch, closedTabIndex) {
this.methodCalled('closeTab', tabId); this.methodCalled('closeTab', [tabId, withSearch, closedTabIndex]);
} }
/** @override */ /** @override */
......
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