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

Unified Diff: chrome/browser/ui/webui/ntp/ntp_user_data_logger.cc

Issue 2435683003: Cleanup desktop NTP metrics recording, part 2 (Closed)
Patch Set: review Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/ntp/ntp_user_data_logger.cc
diff --git a/chrome/browser/ui/webui/ntp/ntp_user_data_logger.cc b/chrome/browser/ui/webui/ntp/ntp_user_data_logger.cc
index d249c9df5633eddf0a5135c3b1e74dfa8263d85c..da644f5eb7dbd82671bbe493f153994754ac78fe 100644
--- a/chrome/browser/ui/webui/ntp/ntp_user_data_logger.cc
+++ b/chrome/browser/ui/webui/ntp/ntp_user_data_logger.cc
@@ -122,20 +122,8 @@ NTPUserDataLogger* NTPUserDataLogger::GetOrCreateFromWebContents(
void NTPUserDataLogger::LogEvent(NTPLoggingEventType event,
base::TimeDelta time) {
- switch (event) {
- case NTP_SERVER_SIDE_SUGGESTION:
- has_server_side_suggestions_ = true;
- number_of_tiles_++;
- return;
- case NTP_CLIENT_SIDE_SUGGESTION:
- has_client_side_suggestions_ = true;
- number_of_tiles_++;
- return;
- case NTP_ALL_TILES_LOADED:
- EmitNtpStatistics(time);
- return;
- }
- NOTREACHED();
+ DCHECK_EQ(NTP_ALL_TILES_LOADED, event);
+ EmitNtpStatistics(time);
}
void NTPUserDataLogger::LogMostVisitedImpression(
@@ -145,6 +133,15 @@ void NTPUserDataLogger::LogMostVisitedImpression(
}
impression_was_logged_[position] = true;
+ switch (tile_source) {
+ case NTPLoggingTileSource::CLIENT:
+ has_client_side_suggestions_ = true;
+ break;
+ case NTPLoggingTileSource::SERVER:
+ has_server_side_suggestions_ = true;
+ break;
+ }
+
UMA_HISTOGRAM_ENUMERATION(kMostVisitedImpressionHistogramName, position,
kNumMostVisited);
@@ -185,7 +182,6 @@ NTPUserDataLogger::NTPUserDataLogger(content::WebContents* contents)
: content::WebContentsObserver(contents),
has_server_side_suggestions_(false),
has_client_side_suggestions_(false),
- number_of_tiles_(0),
has_emitted_(false),
during_startup_(!AfterStartupTaskUtils::IsBrowserStartupComplete()) {
// We record metrics about session data here because when this class typically
@@ -209,7 +205,6 @@ void NTPUserDataLogger::NavigatedFromURLToURL(const GURL& from,
DVLOG(1) << "Returning to New Tab Page";
impression_was_logged_.reset();
has_emitted_ = false;
- number_of_tiles_ = 0;
has_server_side_suggestions_ = false;
has_client_side_suggestions_ = false;
}
@@ -219,8 +214,10 @@ void NTPUserDataLogger::EmitNtpStatistics(base::TimeDelta load_time) {
// We only send statistics once per page.
if (has_emitted_)
return;
+
+ size_t number_of_tiles = impression_was_logged_.count();
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);
@@ -236,12 +233,9 @@ void NTPUserDataLogger::EmitNtpStatistics(base::TimeDelta load_time) {
std::string status = during_startup_ ? "Startup" : "NewTab";
LogLoadTimeHistogram("NewTabPage.LoadTime." + status, load_time);
- has_server_side_suggestions_ = false;
- has_client_side_suggestions_ = false;
UMA_HISTOGRAM_CUSTOM_COUNTS(
- "NewTabPage.NumberOfTiles", number_of_tiles_, 1, kNumMostVisited,
+ "NewTabPage.NumberOfTiles", number_of_tiles, 1, kNumMostVisited,
kNumMostVisited + 1);
- number_of_tiles_ = 0;
has_emitted_ = true;
during_startup_ = false;
}
« no previous file with comments | « chrome/browser/ui/webui/ntp/ntp_user_data_logger.h ('k') | chrome/browser/ui/webui/ntp/ntp_user_data_logger_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698