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

Side by Side 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, 8 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/webui/ntp/ntp_user_data_logger.h ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/ntp/ntp_user_data_logger.h" 5 #include "chrome/browser/ui/webui/ntp/ntp_user_data_logger.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/search/most_visited_iframe_source.h" 10 #include "chrome/browser/search/most_visited_iframe_source.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 std::string NTPUserDataLogger::GetMostVisitedNavigationHistogramNameForProvider( 86 std::string NTPUserDataLogger::GetMostVisitedNavigationHistogramNameForProvider(
87 const std::string& provider) { 87 const std::string& provider) {
88 return base::StringPrintf(kMostVisitedNavigationHistogramWithProvider, 88 return base::StringPrintf(kMostVisitedNavigationHistogramWithProvider,
89 provider.c_str()); 89 provider.c_str());
90 } 90 }
91 91
92 void NTPUserDataLogger::EmitNtpStatistics() { 92 void NTPUserDataLogger::EmitNtpStatistics() {
93 UMA_HISTOGRAM_COUNTS("NewTabPage.NumberOfMouseOvers", number_of_mouseovers_); 93 UMA_HISTOGRAM_COUNTS("NewTabPage.NumberOfMouseOvers", number_of_mouseovers_);
94 number_of_mouseovers_ = 0; 94 number_of_mouseovers_ = 0;
95 95
96 // Only log the following statistics if at least one tile is recorded. This 96 // We only send statistics once per page.
97 // check is required because the statistics are emitted whenever the user 97 // And we don't send if there are no tiles recorded.
98 // changes tab away from the NTP. However, if the user comes back to that NTP 98 if (has_emitted_ || !number_of_tiles_)
99 // later the statistics are not regenerated (i.e. they are all 0). If we log 99 return;
100 // them again we get a strong bias. 100
101 if (number_of_tiles_ > 0) { 101 UMA_HISTOGRAM_ENUMERATION(
102 UMA_HISTOGRAM_ENUMERATION( 102 "NewTabPage.SuggestionsType",
103 "NewTabPage.SuggestionsType", 103 has_server_side_suggestions_ ? SERVER_SIDE : CLIENT_SIDE,
104 has_server_side_suggestions_ ? SERVER_SIDE : CLIENT_SIDE, 104 SUGGESTIONS_TYPE_COUNT);
105 SUGGESTIONS_TYPE_COUNT); 105 has_server_side_suggestions_ = false;
106 has_server_side_suggestions_ = false; 106 UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfTiles", number_of_tiles_);
107 UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfTiles", number_of_tiles_); 107 number_of_tiles_ = 0;
108 number_of_tiles_ = 0; 108 UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfThumbnailTiles",
109 UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfThumbnailTiles", 109 number_of_thumbnail_tiles_);
110 number_of_thumbnail_tiles_); 110 number_of_thumbnail_tiles_ = 0;
111 number_of_thumbnail_tiles_ = 0; 111 UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfGrayTiles",
112 UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfGrayTiles", 112 number_of_gray_tiles_);
113 number_of_gray_tiles_); 113 number_of_gray_tiles_ = 0;
114 number_of_gray_tiles_ = 0; 114 UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfExternalTiles",
115 UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfExternalTiles", 115 number_of_external_tiles_);
116 number_of_external_tiles_); 116 number_of_external_tiles_ = 0;
117 number_of_external_tiles_ = 0; 117 UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfThumbnailErrors",
118 UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfThumbnailErrors", 118 number_of_thumbnail_errors_);
119 number_of_thumbnail_errors_); 119 number_of_thumbnail_errors_ = 0;
120 number_of_thumbnail_errors_ = 0; 120 UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfGrayTileFallbacks",
121 UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfGrayTileFallbacks", 121 number_of_gray_tile_fallbacks_);
122 number_of_gray_tile_fallbacks_); 122 number_of_gray_tile_fallbacks_ = 0;
123 number_of_gray_tile_fallbacks_ = 0; 123 UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfExternalTileFallbacks",
124 UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfExternalTileFallbacks", 124 number_of_external_tile_fallbacks_);
125 number_of_external_tile_fallbacks_); 125 number_of_external_tile_fallbacks_ = 0;
126 number_of_external_tile_fallbacks_ = 0; 126 UMA_HISTOGRAM_CUSTOM_TIMES("NewTabPage.LoadTime",
127 } 127 load_time_,
128 base::TimeDelta::FromMilliseconds(1),
129 base::TimeDelta::FromSeconds(60), 100);
130 load_time_ = base::TimeDelta::FromMilliseconds(0);
131 has_emitted_ = true;
128 } 132 }
129 133
130 void NTPUserDataLogger::LogEvent(NTPLoggingEventType event, 134 void NTPUserDataLogger::LogEvent(NTPLoggingEventType event,
131 base::TimeDelta time) { 135 base::TimeDelta time) {
132 switch (event) { 136 switch (event) {
133 case NTP_SERVER_SIDE_SUGGESTION: 137 case NTP_SERVER_SIDE_SUGGESTION:
134 has_server_side_suggestions_ = true; 138 has_server_side_suggestions_ = true;
135 break; 139 break;
136 case NTP_CLIENT_SIDE_SUGGESTION: 140 case NTP_CLIENT_SIDE_SUGGESTION:
137 // We should never get a mix of server and client side suggestions, 141 // We should never get a mix of server and client side suggestions,
(...skipping 18 matching lines...) Expand all
156 break; 160 break;
157 case NTP_GRAY_TILE_FALLBACK: 161 case NTP_GRAY_TILE_FALLBACK:
158 number_of_gray_tile_fallbacks_++; 162 number_of_gray_tile_fallbacks_++;
159 break; 163 break;
160 case NTP_EXTERNAL_TILE_FALLBACK: 164 case NTP_EXTERNAL_TILE_FALLBACK:
161 number_of_external_tile_fallbacks_++; 165 number_of_external_tile_fallbacks_++;
162 break; 166 break;
163 case NTP_MOUSEOVER: 167 case NTP_MOUSEOVER:
164 number_of_mouseovers_++; 168 number_of_mouseovers_++;
165 break; 169 break;
170 case NTP_TILE_LOADED:
171 // The time at which the last tile has loaded (title, thumbnail or single)
172 // is a good proxy for the total load time of the NTP, therefore we keep
173 // the max as the load time.
174 load_time_ = std::max(load_time_, time);
175 break;
166 default: 176 default:
167 NOTREACHED(); 177 NOTREACHED();
168 } 178 }
169 } 179 }
170 180
171 void NTPUserDataLogger::LogMostVisitedImpression( 181 void NTPUserDataLogger::LogMostVisitedImpression(
172 int position, const base::string16& provider) { 182 int position, const base::string16& provider) {
173 // Log the Most Visited navigation for navigations that have providers and 183 // Log the Most Visited navigation for navigations that have providers and
174 // those that dont. 184 // those that dont.
175 UMA_HISTOGRAM_ENUMERATION(kMostVisitedImpressionHistogramName, position, 185 UMA_HISTOGRAM_ENUMERATION(kMostVisitedImpressionHistogramName, position,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 NTPUserDataLogger::NTPUserDataLogger(content::WebContents* contents) 240 NTPUserDataLogger::NTPUserDataLogger(content::WebContents* contents)
231 : content::WebContentsObserver(contents), 241 : content::WebContentsObserver(contents),
232 has_server_side_suggestions_(false), 242 has_server_side_suggestions_(false),
233 number_of_tiles_(0), 243 number_of_tiles_(0),
234 number_of_thumbnail_tiles_(0), 244 number_of_thumbnail_tiles_(0),
235 number_of_gray_tiles_(0), 245 number_of_gray_tiles_(0),
236 number_of_external_tiles_(0), 246 number_of_external_tiles_(0),
237 number_of_thumbnail_errors_(0), 247 number_of_thumbnail_errors_(0),
238 number_of_gray_tile_fallbacks_(0), 248 number_of_gray_tile_fallbacks_(0),
239 number_of_external_tile_fallbacks_(0), 249 number_of_external_tile_fallbacks_(0),
240 number_of_mouseovers_(0) { 250 number_of_mouseovers_(0),
251 has_emitted_(false) {
241 } 252 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/ntp/ntp_user_data_logger.h ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698