Commit 839adb26 authored by treib's avatar treib Committed by Commit bot

Cleanup desktop NTP metrics recording

- Remove all logging code from the multi-iframe NTP
- Remove NTPLoggingEventType.NTP_TILE, use NTP_*_SIDE_SUGGESTIONS instead
- Other small cleanups

BUG=656646
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation

Review-Url: https://codereview.chromium.org/2429523002
Cr-Commit-Position: refs/heads/master@{#427056}
parent 233364e6
...@@ -16,13 +16,10 @@ ...@@ -16,13 +16,10 @@
* @const * @const
*/ */
var LOG_TYPE = { var LOG_TYPE = {
// The suggestion is coming from the server. // A suggestion coming from the server was rendered.
NTP_SERVER_SIDE_SUGGESTION: 0, NTP_SERVER_SIDE_SUGGESTION: 0,
// The suggestion is coming from the client. // A suggestion coming from the client was rendered.
NTP_CLIENT_SIDE_SUGGESTION: 1, NTP_CLIENT_SIDE_SUGGESTION: 1,
// Indicates a tile was rendered, no matter if it's a thumbnail, a gray tile
// or an external tile.
NTP_TILE: 2,
// All NTP Tiles have finished loading (successfully or failing). // All NTP Tiles have finished loading (successfully or failing).
NTP_ALL_TILES_LOADED: 11, NTP_ALL_TILES_LOADED: 11,
}; };
...@@ -371,7 +368,6 @@ var renderTile = function(data) { ...@@ -371,7 +368,6 @@ var renderTile = function(data) {
return tile; return tile;
} }
logEvent(LOG_TYPE.NTP_TILE);
// The tile will be appended to tiles. // The tile will be appended to tiles.
var position = tiles.children.length; var position = tiles.children.length;
logMostVisitedImpression(position, data.tileSource); logMostVisitedImpression(position, data.tileSource);
......
...@@ -11,21 +11,13 @@ window.addEventListener('DOMContentLoaded', function() { ...@@ -11,21 +11,13 @@ window.addEventListener('DOMContentLoaded', function() {
'use strict'; 'use strict';
fillMostVisited(document.location, function(params, data) { fillMostVisited(document.location, function(params, data) {
function logEvent(eventName) {
chrome.embeddedSearch.newTabPage.logEvent(eventName);
}
function logMostVisitedImpression(tileIndex, tileSource) {
chrome.embeddedSearch.newTabPage.logMostVisitedImpression(tileIndex,
tileSource);
}
function displayLink(link) { function displayLink(link) {
document.body.appendChild(link); document.body.appendChild(link);
window.parent.postMessage('linkDisplayed', '{{ORIGIN}}'); window.parent.postMessage('linkDisplayed', '{{ORIGIN}}');
} }
function showDomainElement() { function showDomainElement() {
var link = createMostVisitedLink( var link = createMostVisitedLink(
params, data.url, data.title, undefined, data.direction, params, data.url, data.title, undefined, data.direction);
data.tileSource);
var domain = document.createElement('div'); var domain = document.createElement('div');
domain.textContent = data.domain; domain.textContent = data.domain;
link.appendChild(domain); link.appendChild(domain);
...@@ -35,8 +27,7 @@ window.addEventListener('DOMContentLoaded', function() { ...@@ -35,8 +27,7 @@ window.addEventListener('DOMContentLoaded', function() {
// externally by the page itself. // externally by the page itself.
function showEmptyTile() { function showEmptyTile() {
displayLink(createMostVisitedLink( displayLink(createMostVisitedLink(
params, data.url, data.title, undefined, data.direction, params, data.url, data.title, undefined, data.direction));
data.tileSource));
} }
// Creates and adds an image. // Creates and adds an image.
function createThumbnail(src, imageClass) { function createThumbnail(src, imageClass) {
...@@ -46,15 +37,13 @@ window.addEventListener('DOMContentLoaded', function() { ...@@ -46,15 +37,13 @@ window.addEventListener('DOMContentLoaded', function() {
} }
image.onload = function() { image.onload = function() {
var link = createMostVisitedLink( var link = createMostVisitedLink(
params, data.url, data.title, undefined, data.direction, params, data.url, data.title, undefined, data.direction);
data.tileSource);
// Use blocker to prevent context menu from showing image-related items. // Use blocker to prevent context menu from showing image-related items.
var blocker = document.createElement('span'); var blocker = document.createElement('span');
blocker.className = 'blocker'; blocker.className = 'blocker';
link.appendChild(blocker); link.appendChild(blocker);
link.appendChild(image); link.appendChild(image);
displayLink(link); displayLink(link);
logEvent(NTP_LOGGING_EVENT_TYPE.NTP_TILE_LOADED);
}; };
image.onerror = function() { image.onerror = function() {
// If no external thumbnail fallback (etfb), and have domain. // If no external thumbnail fallback (etfb), and have domain.
...@@ -63,7 +52,6 @@ window.addEventListener('DOMContentLoaded', function() { ...@@ -63,7 +52,6 @@ window.addEventListener('DOMContentLoaded', function() {
} else { } else {
showEmptyTile(); showEmptyTile();
} }
logEvent(NTP_LOGGING_EVENT_TYPE.NTP_TILE_LOADED);
}; };
image.src = src; image.src = src;
} }
...@@ -73,7 +61,6 @@ window.addEventListener('DOMContentLoaded', function() { ...@@ -73,7 +61,6 @@ window.addEventListener('DOMContentLoaded', function() {
showEmptyTile(); showEmptyTile();
} else if (useIcons && data.largeIconUrl) { } else if (useIcons && data.largeIconUrl) {
createThumbnail(data.largeIconUrl, 'large-icon'); createThumbnail(data.largeIconUrl, 'large-icon');
// TODO(huangs): Log event for large icons.
} else if (!useIcons && data.thumbnailUrls && data.thumbnailUrls.length) { } else if (!useIcons && data.thumbnailUrls && data.thumbnailUrls.length) {
createThumbnail(data.thumbnailUrls[0], 'thumbnail'); createThumbnail(data.thumbnailUrls[0], 'thumbnail');
} else if (data.domain) { } else if (data.domain) {
...@@ -81,11 +68,5 @@ window.addEventListener('DOMContentLoaded', function() { ...@@ -81,11 +68,5 @@ window.addEventListener('DOMContentLoaded', function() {
} else { } else {
showEmptyTile(); showEmptyTile();
} }
logEvent(NTP_LOGGING_EVENT_TYPE.NTP_TILE);
// Log an impression if we know the position of the tile.
if (isFinite(params.pos)) {
logMostVisitedImpression(parseInt(params.pos, 10), data.tileSource);
}
}); });
}); });
...@@ -13,12 +13,6 @@ window.addEventListener('DOMContentLoaded', function() { ...@@ -13,12 +13,6 @@ window.addEventListener('DOMContentLoaded', function() {
fillMostVisited(window.location, function(params, data) { fillMostVisited(window.location, function(params, data) {
document.body.appendChild( document.body.appendChild(
createMostVisitedLink( createMostVisitedLink(
params, data.url, data.title, data.title, data.direction, params, data.url, data.title, data.title, data.direction));
data.tileSource));
}); });
}); });
window.addEventListener('load', function() {
chrome.embeddedSearch.newTabPage.logEvent(
NTP_LOGGING_EVENT_TYPE.NTP_TILE_LOADED);
});
...@@ -10,41 +10,6 @@ ...@@ -10,41 +10,6 @@
<include src="instant_iframe_validation.js"> <include src="instant_iframe_validation.js">
// TODO(treib): A number of things from this file (e.g. the "enums" below) are
// duplicated in most_visited_single.js. Pull those out into a shared file.
/**
* The different types of events that are logged from the NTP. This enum is
* used to transfer information from the NTP javascript to the renderer and is
* not used as a UMA enum histogram's logged value.
* Note: Keep in sync with common/ntp_logging_events.h
* @enum {number}
* @const
*/
var NTP_LOGGING_EVENT_TYPE = {
// The suggestion is coming from the server.
NTP_SERVER_SIDE_SUGGESTION: 0,
// The suggestion is coming from the client.
NTP_CLIENT_SIDE_SUGGESTION: 1,
// Indicates a tile was rendered, no matter if it's a thumbnail, a gray tile
// or an external tile.
NTP_TILE: 2,
// A NTP Tile has finished loading (successfully or failing).
NTP_TILE_LOADED: 10,
};
/**
* The different sources that an NTP tile can have.
* Note: Keep in sync with common/ntp_logging_events.h
* @enum {number}
* @const
*/
var NTPLoggingTileSource = {
CLIENT: 0,
SERVER: 1,
};
/** /**
* The origin of this request. * The origin of this request.
* @const {string} * @const {string}
...@@ -83,11 +48,9 @@ function parseQueryParams(location) { ...@@ -83,11 +48,9 @@ function parseQueryParams(location) {
* @param {string} title The title for the link. * @param {string} title The title for the link.
* @param {string|undefined} text The text for the link or none. * @param {string|undefined} text The text for the link or none.
* @param {string|undefined} direction The text direction. * @param {string|undefined} direction The text direction.
* @param {number} tileSource The source from NTPLoggingTileSource.
* @return {HTMLAnchorElement} A new link element. * @return {HTMLAnchorElement} A new link element.
*/ */
function createMostVisitedLink( function createMostVisitedLink(params, href, title, text, direction) {
params, href, title, text, direction, tileSource) {
var styles = getMostVisitedStyles(params, !!text); var styles = getMostVisitedStyles(params, !!text);
var link = document.createElement('a'); var link = document.createElement('a');
link.style.color = styles.color; link.style.color = styles.color;
...@@ -135,12 +98,6 @@ function createMostVisitedLink( ...@@ -135,12 +98,6 @@ function createMostVisitedLink(
generatePing(DOMAIN_ORIGIN + params.ping); generatePing(DOMAIN_ORIGIN + params.ping);
} }
var ntpApiHandle = chrome.embeddedSearch.newTabPage;
if ('pos' in params && isFinite(params.pos)) {
ntpApiHandle.logMostVisitedNavigation(parseInt(params.pos, 10),
tileSource);
}
// Follow <a> normally, so transition type will be LINK. // Follow <a> normally, so transition type will be LINK.
}; };
...@@ -243,10 +200,6 @@ function fillMostVisited(location, fill) { ...@@ -243,10 +200,6 @@ function fillMostVisited(location, fill) {
params.rid = parseInt(params.rid, 10); params.rid = parseInt(params.rid, 10);
if (!isFinite(params.rid) && !params.url) if (!isFinite(params.rid) && !params.url)
return; return;
// Log whether the suggestion was obtained from the server or the client.
chrome.embeddedSearch.newTabPage.logEvent(params.url ?
NTP_LOGGING_EVENT_TYPE.NTP_SERVER_SIDE_SUGGESTION :
NTP_LOGGING_EVENT_TYPE.NTP_CLIENT_SIDE_SUGGESTION);
var data; var data;
if (params.url) { if (params.url) {
// Means that the suggestion data comes from the server. Create data object. // Means that the suggestion data comes from the server. Create data object.
...@@ -256,15 +209,13 @@ function fillMostVisited(location, fill) { ...@@ -256,15 +209,13 @@ function fillMostVisited(location, fill) {
thumbnailUrl: params.tu || '', thumbnailUrl: params.tu || '',
title: params.ti || '', title: params.ti || '',
direction: params.di || '', direction: params.di || '',
domain: params.dom || '', domain: params.dom || ''
tileSource: NTPLoggingTileSource.SERVER
}; };
} else { } else {
var apiHandle = chrome.embeddedSearch.searchBox; var apiHandle = chrome.embeddedSearch.searchBox;
data = apiHandle.getMostVisitedItemData(params.rid); data = apiHandle.getMostVisitedItemData(params.rid);
if (!data) if (!data)
return; return;
data.tileSource = NTPLoggingTileSource.CLIENT;
} }
if (isFinite(params.dummy) && parseInt(params.dummy, 10)) { if (isFinite(params.dummy) && parseInt(params.dummy, 10)) {
......
...@@ -259,14 +259,15 @@ TEST_F(SearchIPCRouterTest, ProcessLogEventMsg) { ...@@ -259,14 +259,15 @@ TEST_F(SearchIPCRouterTest, ProcessLogEventMsg) {
NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl));
SetupMockDelegateAndPolicy(); SetupMockDelegateAndPolicy();
MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
EXPECT_CALL(*mock_delegate(), OnLogEvent(NTP_TILE, delta)).Times(1); EXPECT_CALL(*mock_delegate(), OnLogEvent(NTP_CLIENT_SIDE_SUGGESTION, delta))
.Times(1);
EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1) EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1)
.WillOnce(testing::Return(true)); .WillOnce(testing::Return(true));
content::WebContents* contents = web_contents(); content::WebContents* contents = web_contents();
OnMessageReceived(ChromeViewHostMsg_LogEvent( OnMessageReceived(ChromeViewHostMsg_LogEvent(
contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), contents->GetRoutingID(), GetSearchIPCRouterSeqNo(),
NTP_TILE, delta)); NTP_CLIENT_SIDE_SUGGESTION, delta));
} }
TEST_F(SearchIPCRouterTest, IgnoreLogEventMsg) { TEST_F(SearchIPCRouterTest, IgnoreLogEventMsg) {
...@@ -274,14 +275,15 @@ TEST_F(SearchIPCRouterTest, IgnoreLogEventMsg) { ...@@ -274,14 +275,15 @@ TEST_F(SearchIPCRouterTest, IgnoreLogEventMsg) {
NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar"));
SetupMockDelegateAndPolicy(); SetupMockDelegateAndPolicy();
MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
EXPECT_CALL(*mock_delegate(), OnLogEvent(NTP_TILE, delta)).Times(0); EXPECT_CALL(*mock_delegate(), OnLogEvent(NTP_CLIENT_SIDE_SUGGESTION, delta))
.Times(0);
EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1) EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1)
.WillOnce(testing::Return(false)); .WillOnce(testing::Return(false));
content::WebContents* contents = web_contents(); content::WebContents* contents = web_contents();
OnMessageReceived(ChromeViewHostMsg_LogEvent( OnMessageReceived(ChromeViewHostMsg_LogEvent(
contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), contents->GetRoutingID(), GetSearchIPCRouterSeqNo(),
NTP_TILE, delta)); NTP_CLIENT_SIDE_SUGGESTION, delta));
} }
TEST_F(SearchIPCRouterTest, ProcessLogMostVisitedImpressionMsg) { TEST_F(SearchIPCRouterTest, ProcessLogMostVisitedImpressionMsg) {
...@@ -486,11 +488,12 @@ TEST_F(SearchIPCRouterTest, IgnoreMessageIfThePageIsNotActive) { ...@@ -486,11 +488,12 @@ TEST_F(SearchIPCRouterTest, IgnoreMessageIfThePageIsNotActive) {
contents->GetRoutingID(), page_seq_no, OMNIBOX_FOCUS_VISIBLE)); contents->GetRoutingID(), page_seq_no, OMNIBOX_FOCUS_VISIBLE));
base::TimeDelta delta = base::TimeDelta::FromMilliseconds(123); base::TimeDelta delta = base::TimeDelta::FromMilliseconds(123);
EXPECT_CALL(*mock_delegate(), OnLogEvent(NTP_TILE, delta)).Times(0); EXPECT_CALL(*mock_delegate(), OnLogEvent(NTP_CLIENT_SIDE_SUGGESTION, delta))
.Times(0);
EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(0); EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(0);
OnMessageReceived(ChromeViewHostMsg_LogEvent(contents->GetRoutingID(), OnMessageReceived(
page_seq_no, ChromeViewHostMsg_LogEvent(contents->GetRoutingID(), page_seq_no,
NTP_TILE, delta)); NTP_CLIENT_SIDE_SUGGESTION, delta));
base::string16 text; base::string16 text;
EXPECT_CALL(*mock_delegate(), PasteIntoOmnibox(text)).Times(0); EXPECT_CALL(*mock_delegate(), PasteIntoOmnibox(text)).Times(0);
......
...@@ -54,6 +54,21 @@ std::string GetSourceName(NTPLoggingTileSource tile_source) { ...@@ -54,6 +54,21 @@ std::string GetSourceName(NTPLoggingTileSource tile_source) {
return std::string(); return std::string();
} }
void RecordSyncSessionMetrics(content::WebContents* contents) {
if (!contents)
return;
browser_sync::ProfileSyncService* sync =
ProfileSyncServiceFactory::GetForProfile(
Profile::FromBrowserContext(contents->GetBrowserContext()));
if (!sync)
return;
sync_sessions::SessionsSyncManager* sessions =
static_cast<sync_sessions::SessionsSyncManager*>(
sync->GetSessionsSyncableService());
sync_sessions::SyncSessionsMetrics::RecordYoungestForeignTabAgeOnNTP(
sessions);
}
} // namespace } // namespace
DEFINE_WEB_CONTENTS_USER_DATA_KEY(NTPUserDataLogger); DEFINE_WEB_CONTENTS_USER_DATA_KEY(NTPUserDataLogger);
...@@ -62,7 +77,7 @@ DEFINE_WEB_CONTENTS_USER_DATA_KEY(NTPUserDataLogger); ...@@ -62,7 +77,7 @@ DEFINE_WEB_CONTENTS_USER_DATA_KEY(NTPUserDataLogger);
// Log a time event for a given |histogram| at a given |value|. This // Log a time event for a given |histogram| at a given |value|. This
// routine exists because regular histogram macros are cached thus can't be used // routine exists because regular histogram macros are cached thus can't be used
// if the name of the histogram will change at a given call site. // if the name of the histogram will change at a given call site.
void logLoadTimeHistogram(const std::string& histogram, base::TimeDelta value) { void LogLoadTimeHistogram(const std::string& histogram, base::TimeDelta value) {
base::HistogramBase* counter = base::Histogram::FactoryTimeGet( base::HistogramBase* counter = base::Histogram::FactoryTimeGet(
histogram, histogram,
base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMilliseconds(1),
...@@ -110,23 +125,17 @@ void NTPUserDataLogger::LogEvent(NTPLoggingEventType event, ...@@ -110,23 +125,17 @@ void NTPUserDataLogger::LogEvent(NTPLoggingEventType event,
switch (event) { switch (event) {
case NTP_SERVER_SIDE_SUGGESTION: case NTP_SERVER_SIDE_SUGGESTION:
has_server_side_suggestions_ = true; has_server_side_suggestions_ = true;
break; number_of_tiles_++;
return;
case NTP_CLIENT_SIDE_SUGGESTION: case NTP_CLIENT_SIDE_SUGGESTION:
has_client_side_suggestions_ = true; has_client_side_suggestions_ = true;
break;
case NTP_TILE:
// TODO(sfiera): remove NTP_TILE and use NTP_*_SIDE_SUGGESTION.
number_of_tiles_++; number_of_tiles_++;
break; return;
case NTP_TILE_LOADED:
// We no longer emit statistics for the multi-iframe NTP.
break;
case NTP_ALL_TILES_LOADED: case NTP_ALL_TILES_LOADED:
EmitNtpStatistics(time); EmitNtpStatistics(time);
break; return;
default:
NOTREACHED();
} }
NOTREACHED();
} }
void NTPUserDataLogger::LogMostVisitedImpression( void NTPUserDataLogger::LogMostVisitedImpression(
...@@ -178,27 +187,12 @@ NTPUserDataLogger::NTPUserDataLogger(content::WebContents* contents) ...@@ -178,27 +187,12 @@ NTPUserDataLogger::NTPUserDataLogger(content::WebContents* contents)
has_client_side_suggestions_(false), has_client_side_suggestions_(false),
number_of_tiles_(0), number_of_tiles_(0),
has_emitted_(false), has_emitted_(false),
during_startup_(false) { during_startup_(!AfterStartupTaskUtils::IsBrowserStartupComplete()) {
during_startup_ = !AfterStartupTaskUtils::IsBrowserStartupComplete();
// We record metrics about session data here because when this class typically // We record metrics about session data here because when this class typically
// emits metrics it is too late. This session data would theoretically have // emits metrics it is too late. This session data would theoretically have
// been used to populate the page, and we want to learn about its state when // been used to populate the page, and we want to learn about its state when
// the NTP is being generated. // the NTP is being generated.
if (contents) { RecordSyncSessionMetrics(contents);
browser_sync::ProfileSyncService* sync =
ProfileSyncServiceFactory::GetForProfile(
Profile::FromBrowserContext(contents->GetBrowserContext()));
if (sync) {
sync_sessions::SessionsSyncManager* sessions =
static_cast<sync_sessions::SessionsSyncManager*>(
sync->GetSessionsSyncableService());
if (sessions) {
sync_sessions::SyncSessionsMetrics::RecordYoungestForeignTabAgeOnNTP(
sessions);
}
}
}
} }
// content::WebContentsObserver override // content::WebContentsObserver override
...@@ -228,19 +222,19 @@ void NTPUserDataLogger::EmitNtpStatistics(base::TimeDelta load_time) { ...@@ -228,19 +222,19 @@ void NTPUserDataLogger::EmitNtpStatistics(base::TimeDelta load_time) {
DVLOG(1) << "Emitting NTP load time: " << load_time << ", " DVLOG(1) << "Emitting NTP load time: " << load_time << ", "
<< "number of tiles: " << number_of_tiles_; << "number of tiles: " << number_of_tiles_;
logLoadTimeHistogram("NewTabPage.LoadTime", load_time); LogLoadTimeHistogram("NewTabPage.LoadTime", load_time);
// Split between ML and MV. // Split between ML and MV.
std::string type = has_server_side_suggestions_ ? std::string type = has_server_side_suggestions_ ?
"MostLikely" : "MostVisited"; "MostLikely" : "MostVisited";
logLoadTimeHistogram("NewTabPage.LoadTime." + type, load_time); LogLoadTimeHistogram("NewTabPage.LoadTime." + type, load_time);
// Split between Web and Local. // Split between Web and Local.
std::string source = ntp_url_.SchemeIsHTTPOrHTTPS() ? "Web" : "LocalNTP"; std::string source = ntp_url_.SchemeIsHTTPOrHTTPS() ? "Web" : "LocalNTP";
logLoadTimeHistogram("NewTabPage.LoadTime." + source, load_time); LogLoadTimeHistogram("NewTabPage.LoadTime." + source, load_time);
// Split between Startup and non-startup. // Split between Startup and non-startup.
std::string status = during_startup_ ? "Startup" : "NewTab"; std::string status = during_startup_ ? "Startup" : "NewTab";
logLoadTimeHistogram("NewTabPage.LoadTime." + status, load_time); LogLoadTimeHistogram("NewTabPage.LoadTime." + status, load_time);
has_server_side_suggestions_ = false; has_server_side_suggestions_ = false;
has_client_side_suggestions_ = false; has_client_side_suggestions_ = false;
......
...@@ -34,8 +34,8 @@ class NTPUserDataLogger ...@@ -34,8 +34,8 @@ class NTPUserDataLogger
content::WebContents* content); content::WebContents* content);
// Called when an event occurs on the NTP that requires a counter to be // Called when an event occurs on the NTP that requires a counter to be
// incremented. |time| is the delta time in ms from navigation start until // incremented. |time| is the delta time from navigation start until this
// this event happened. // event happened.
void LogEvent(NTPLoggingEventType event, base::TimeDelta time); void LogEvent(NTPLoggingEventType event, base::TimeDelta time);
// Logs an impression on one of the NTP tiles by a given source. // Logs an impression on one of the NTP tiles by a given source.
...@@ -50,12 +50,6 @@ class NTPUserDataLogger ...@@ -50,12 +50,6 @@ class NTPUserDataLogger
private: private:
friend class content::WebContentsUserData<NTPUserDataLogger>; friend class content::WebContentsUserData<NTPUserDataLogger>;
FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest,
OnMostVisitedItemsChangedFromServer);
FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest,
OnMostVisitedItemsChangedFromClient);
FRIEND_TEST_ALL_PREFIXES(NTPUserDataLoggerTest,
TestLogging);
FRIEND_TEST_ALL_PREFIXES(NTPUserDataLoggerTest, TestLogMostVisitedImpression); FRIEND_TEST_ALL_PREFIXES(NTPUserDataLoggerTest, TestLogMostVisitedImpression);
FRIEND_TEST_ALL_PREFIXES(NTPUserDataLoggerTest, TestNumberOfTiles); FRIEND_TEST_ALL_PREFIXES(NTPUserDataLoggerTest, TestNumberOfTiles);
......
...@@ -81,15 +81,14 @@ class NTPUserDataLoggerTest : public testing::Test { ...@@ -81,15 +81,14 @@ class NTPUserDataLoggerTest : public testing::Test {
TEST_F(NTPUserDataLoggerTest, TestNumberOfTiles) { TEST_F(NTPUserDataLoggerTest, TestNumberOfTiles) {
base::StatisticsRecorder::Initialize(); base::StatisticsRecorder::Initialize();
// Enusure non-zero statistics. // Ensure non-zero statistics.
TestNTPUserDataLogger logger; TestNTPUserDataLogger logger;
logger.ntp_url_ = GURL("chrome://newtab/"); logger.ntp_url_ = GURL("chrome://newtab/");
base::TimeDelta delta = base::TimeDelta::FromMilliseconds(0); base::TimeDelta delta = base::TimeDelta::FromMilliseconds(0);
for (int i = 0; i < 8; ++i) for (int i = 0; i < 8; ++i)
logger.LogEvent(NTP_TILE, delta); logger.LogEvent(NTP_SERVER_SIDE_SUGGESTION, delta);
logger.LogEvent(NTP_SERVER_SIDE_SUGGESTION, delta);
logger.LogEvent(NTP_ALL_TILES_LOADED, delta); logger.LogEvent(NTP_ALL_TILES_LOADED, delta);
......
...@@ -8,18 +8,17 @@ ...@@ -8,18 +8,17 @@
// The different types of events that are logged from the NTP. This enum is used // The different types of events that are logged from the NTP. This enum is used
// to transfer information from the NTP javascript to the renderer and is not // to transfer information from the NTP javascript to the renderer and is not
// used as a UMA enum histogram's logged value. // used as a UMA enum histogram's logged value.
// Note: Keep in sync with browser/resources/local_ntp/most_visited_util.js // Note: Keep in sync with browser/resources/local_ntp/most_visited_single.js
// and browser/resources/local_ntp/most_visited_single.js
enum NTPLoggingEventType { enum NTPLoggingEventType {
// The suggestion is coming from the server. // A suggestion coming from the server was rendered.
NTP_SERVER_SIDE_SUGGESTION = 0, NTP_SERVER_SIDE_SUGGESTION = 0,
// The suggestion is coming from the client. // A suggestion coming from the client was rendered.
NTP_CLIENT_SIDE_SUGGESTION = 1, NTP_CLIENT_SIDE_SUGGESTION = 1,
// Indicates a tile was rendered, no matter if it's a thumbnail, a gray tile // Indicates a tile was rendered, no matter if it's a thumbnail, a gray tile
// or an external tile. // or an external tile.
NTP_TILE = 2, // Deleted: NTP_TILE = 2,
// The tile uses a local thumbnail image. // The tile uses a local thumbnail image.
// Deleted: NTP_THUMBNAIL_TILE = 3, // Deleted: NTP_THUMBNAIL_TILE = 3,
...@@ -45,7 +44,7 @@ enum NTPLoggingEventType { ...@@ -45,7 +44,7 @@ enum NTPLoggingEventType {
// A NTP Tile has finished loading (successfully or failing). Logged only by // A NTP Tile has finished loading (successfully or failing). Logged only by
// the multi-iframe version of the NTP. // the multi-iframe version of the NTP.
NTP_TILE_LOADED = 10, // Deleted: NTP_TILE_LOADED = 10,
// All NTP tiles have finished loading (successfully or failing). Logged only // All NTP tiles have finished loading (successfully or failing). Logged only
// by the single-iframe version of the NTP. // by the single-iframe version of the NTP.
...@@ -55,8 +54,7 @@ enum NTPLoggingEventType { ...@@ -55,8 +54,7 @@ enum NTPLoggingEventType {
}; };
// The source of an NTP tile. // The source of an NTP tile.
// Note: Keep in sync with browser/resources/local_ntp/most_visited_util.js and // Note: Keep in sync with browser/resources/local_ntp/most_visited_single.js.
// browser/resources/local_ntp/most_visited_single.js.
// TODO(treib): Merge this into MostVisitedSource from components/ntp_tiles. // TODO(treib): Merge this into MostVisitedSource from components/ntp_tiles.
enum class NTPLoggingTileSource { enum class NTPLoggingTileSource {
CLIENT = 0, CLIENT = 0,
......
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