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

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

Issue 1007383003: Adds a new UMA histogram to measure the NTP load time since navigation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 35f90b67ef4dccbfc9c5e942c4f0e85dad7b7476..03a145c395620bf3a75b53ed0a1c7aef2241727e 100644
--- a/chrome/browser/ui/webui/ntp/ntp_user_data_logger.cc
+++ b/chrome/browser/ui/webui/ntp/ntp_user_data_logger.cc
@@ -93,38 +93,42 @@ void NTPUserDataLogger::EmitNtpStatistics() {
UMA_HISTOGRAM_COUNTS("NewTabPage.NumberOfMouseOvers", number_of_mouseovers_);
number_of_mouseovers_ = 0;
- // Only log the following statistics if at least one tile is recorded. This
- // check is required because the statistics are emitted whenever the user
- // changes tab away from the NTP. However, if the user comes back to that NTP
- // later the statistics are not regenerated (i.e. they are all 0). If we log
- // them again we get a strong bias.
- if (number_of_tiles_ > 0) {
- UMA_HISTOGRAM_ENUMERATION(
- "NewTabPage.SuggestionsType",
- has_server_side_suggestions_ ? SERVER_SIDE : CLIENT_SIDE,
- SUGGESTIONS_TYPE_COUNT);
- has_server_side_suggestions_ = false;
- UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfTiles", number_of_tiles_);
- number_of_tiles_ = 0;
- UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfThumbnailTiles",
- number_of_thumbnail_tiles_);
- number_of_thumbnail_tiles_ = 0;
- UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfGrayTiles",
- number_of_gray_tiles_);
- number_of_gray_tiles_ = 0;
- UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfExternalTiles",
- number_of_external_tiles_);
- number_of_external_tiles_ = 0;
- UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfThumbnailErrors",
- number_of_thumbnail_errors_);
- number_of_thumbnail_errors_ = 0;
- UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfGrayTileFallbacks",
- number_of_gray_tile_fallbacks_);
- number_of_gray_tile_fallbacks_ = 0;
- UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfExternalTileFallbacks",
- number_of_external_tile_fallbacks_);
- number_of_external_tile_fallbacks_ = 0;
- }
+ // We only send statistics once per page.
+ // And we don't send if there are no tiles recorded.
+ if (has_emitted_ || !number_of_tiles_)
+ return;
+
+ UMA_HISTOGRAM_ENUMERATION(
+ "NewTabPage.SuggestionsType",
+ has_server_side_suggestions_ ? SERVER_SIDE : CLIENT_SIDE,
+ SUGGESTIONS_TYPE_COUNT);
+ has_server_side_suggestions_ = false;
+ UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfTiles", number_of_tiles_);
+ number_of_tiles_ = 0;
+ UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfThumbnailTiles",
+ number_of_thumbnail_tiles_);
+ number_of_thumbnail_tiles_ = 0;
+ UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfGrayTiles",
+ number_of_gray_tiles_);
+ number_of_gray_tiles_ = 0;
+ UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfExternalTiles",
+ number_of_external_tiles_);
+ number_of_external_tiles_ = 0;
+ UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfThumbnailErrors",
+ number_of_thumbnail_errors_);
+ number_of_thumbnail_errors_ = 0;
+ UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfGrayTileFallbacks",
+ number_of_gray_tile_fallbacks_);
+ number_of_gray_tile_fallbacks_ = 0;
+ UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfExternalTileFallbacks",
+ number_of_external_tile_fallbacks_);
+ number_of_external_tile_fallbacks_ = 0;
+ UMA_HISTOGRAM_CUSTOM_TIMES("NewTabPage.LoadTime",
+ base::TimeDelta::FromMilliseconds(load_time_),
+ base::TimeDelta::FromMilliseconds(1),
+ base::TimeDelta::FromSeconds(60), 100);
+ load_time_ = 0;
+ has_emitted_ = true;
}
void NTPUserDataLogger::LogEvent(NTPLoggingEventType event, uint64 time) {
@@ -162,6 +166,12 @@ void NTPUserDataLogger::LogEvent(NTPLoggingEventType event, uint64 time) {
case NTP_MOUSEOVER:
number_of_mouseovers_++;
break;
+ case NTP_TILE_LOADED:
+ // The time at which the last tile has loaded (title, thumbnail or single)
+ // is a good proxy for the total load time of the NTP, therefore we keep
+ // the max as the load time.
+ load_time_ = std::max(load_time_, time);
+ break;
default:
NOTREACHED();
}
@@ -236,5 +246,7 @@ NTPUserDataLogger::NTPUserDataLogger(content::WebContents* contents)
number_of_thumbnail_errors_(0),
number_of_gray_tile_fallbacks_(0),
number_of_external_tile_fallbacks_(0),
- number_of_mouseovers_(0) {
+ number_of_mouseovers_(0),
+ load_time_(0),
+ has_emitted_(false) {
}

Powered by Google App Engine
This is Rietveld 408576698