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

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, 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 unified diff | Download patch
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 already sent statistics for this page once.
97 // check is required because the statistics are emitted whenever the user 97 if (has_emitted_) {
Dan Beam 2015/03/17 01:18:46 no curlies
fserb 2015/03/17 16:02:17 Done.
98 // changes tab away from the NTP. However, if the user comes back to that NTP 98 return;
99 // later the statistics are not regenerated (i.e. they are all 0). If we log
100 // them again we get a strong bias.
101 if (number_of_tiles_ > 0) {
102 UMA_HISTOGRAM_ENUMERATION(
103 "NewTabPage.SuggestionsType",
104 has_server_side_suggestions_ ? SERVER_SIDE : CLIENT_SIDE,
105 SUGGESTIONS_TYPE_COUNT);
106 has_server_side_suggestions_ = false;
107 UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfTiles", number_of_tiles_);
108 number_of_tiles_ = 0;
109 UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfThumbnailTiles",
110 number_of_thumbnail_tiles_);
111 number_of_thumbnail_tiles_ = 0;
112 UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfGrayTiles",
113 number_of_gray_tiles_);
114 number_of_gray_tiles_ = 0;
115 UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfExternalTiles",
116 number_of_external_tiles_);
117 number_of_external_tiles_ = 0;
118 UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfThumbnailErrors",
119 number_of_thumbnail_errors_);
120 number_of_thumbnail_errors_ = 0;
121 UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfGrayTileFallbacks",
122 number_of_gray_tile_fallbacks_);
123 number_of_gray_tile_fallbacks_ = 0;
124 UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfExternalTileFallbacks",
125 number_of_external_tile_fallbacks_);
126 number_of_external_tile_fallbacks_ = 0;
127 } 99 }
100
101 // Only log the following statistics if at least one tile is recorded.
102 if (!number_of_tiles_) {
Dan Beam 2015/03/17 01:18:46 nit: can you combine with if above?
fserb 2015/03/17 16:02:17 Done.
103 return;
104 }
105
106 UMA_HISTOGRAM_ENUMERATION(
107 "NewTabPage.SuggestionsType",
108 has_server_side_suggestions_ ? SERVER_SIDE : CLIENT_SIDE,
109 SUGGESTIONS_TYPE_COUNT);
110 has_server_side_suggestions_ = false;
111 UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfTiles", number_of_tiles_);
112 number_of_tiles_ = 0;
113 UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfThumbnailTiles",
114 number_of_thumbnail_tiles_);
115 number_of_thumbnail_tiles_ = 0;
116 UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfGrayTiles",
117 number_of_gray_tiles_);
118 number_of_gray_tiles_ = 0;
119 UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfExternalTiles",
120 number_of_external_tiles_);
121 number_of_external_tiles_ = 0;
122 UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfThumbnailErrors",
123 number_of_thumbnail_errors_);
124 number_of_thumbnail_errors_ = 0;
125 UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfGrayTileFallbacks",
126 number_of_gray_tile_fallbacks_);
127 number_of_gray_tile_fallbacks_ = 0;
128 UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfExternalTileFallbacks",
129 number_of_external_tile_fallbacks_);
130 number_of_external_tile_fallbacks_ = 0;
131 UMA_HISTOGRAM_CUSTOM_TIMES("NewTabPage.LoadTime",
132 base::TimeDelta::FromMilliseconds(load_time_),
133 base::TimeDelta::FromMilliseconds(1),
134 base::TimeDelta::FromSeconds(60), 100);
135 load_time_ = 0;
136 has_emitted_ = true;
128 } 137 }
129 138
130 void NTPUserDataLogger::LogEvent(NTPLoggingEventType event, uint64 time) { 139 void NTPUserDataLogger::LogEvent(NTPLoggingEventType event, uint64 time) {
131 switch (event) { 140 switch (event) {
132 case NTP_SERVER_SIDE_SUGGESTION: 141 case NTP_SERVER_SIDE_SUGGESTION:
133 has_server_side_suggestions_ = true; 142 has_server_side_suggestions_ = true;
134 break; 143 break;
135 case NTP_CLIENT_SIDE_SUGGESTION: 144 case NTP_CLIENT_SIDE_SUGGESTION:
136 // We should never get a mix of server and client side suggestions, 145 // We should never get a mix of server and client side suggestions,
137 // otherwise there could be a race condition depending on the order in 146 // otherwise there could be a race condition depending on the order in
(...skipping 17 matching lines...) Expand all
155 break; 164 break;
156 case NTP_GRAY_TILE_FALLBACK: 165 case NTP_GRAY_TILE_FALLBACK:
157 number_of_gray_tile_fallbacks_++; 166 number_of_gray_tile_fallbacks_++;
158 break; 167 break;
159 case NTP_EXTERNAL_TILE_FALLBACK: 168 case NTP_EXTERNAL_TILE_FALLBACK:
160 number_of_external_tile_fallbacks_++; 169 number_of_external_tile_fallbacks_++;
161 break; 170 break;
162 case NTP_MOUSEOVER: 171 case NTP_MOUSEOVER:
163 number_of_mouseovers_++; 172 number_of_mouseovers_++;
164 break; 173 break;
174 case NTP_TILE_LOADED:
175 // The time at which the last tile has loaded (title, thumbnail or single)
176 // is a good proxy for the total load time of the NTP, therefore we keep
177 // the max as the load time.
178 load_time_ = std::max(load_time_, time);
179 break;
165 default: 180 default:
166 NOTREACHED(); 181 NOTREACHED();
167 } 182 }
168 } 183 }
169 184
170 void NTPUserDataLogger::LogMostVisitedImpression( 185 void NTPUserDataLogger::LogMostVisitedImpression(
171 int position, const base::string16& provider) { 186 int position, const base::string16& provider) {
172 // Log the Most Visited navigation for navigations that have providers and 187 // Log the Most Visited navigation for navigations that have providers and
173 // those that dont. 188 // those that dont.
174 UMA_HISTOGRAM_ENUMERATION(kMostVisitedImpressionHistogramName, position, 189 UMA_HISTOGRAM_ENUMERATION(kMostVisitedImpressionHistogramName, position,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 NTPUserDataLogger::NTPUserDataLogger(content::WebContents* contents) 244 NTPUserDataLogger::NTPUserDataLogger(content::WebContents* contents)
230 : content::WebContentsObserver(contents), 245 : content::WebContentsObserver(contents),
231 has_server_side_suggestions_(false), 246 has_server_side_suggestions_(false),
232 number_of_tiles_(0), 247 number_of_tiles_(0),
233 number_of_thumbnail_tiles_(0), 248 number_of_thumbnail_tiles_(0),
234 number_of_gray_tiles_(0), 249 number_of_gray_tiles_(0),
235 number_of_external_tiles_(0), 250 number_of_external_tiles_(0),
236 number_of_thumbnail_errors_(0), 251 number_of_thumbnail_errors_(0),
237 number_of_gray_tile_fallbacks_(0), 252 number_of_gray_tile_fallbacks_(0),
238 number_of_external_tile_fallbacks_(0), 253 number_of_external_tile_fallbacks_(0),
239 number_of_mouseovers_(0) { 254 number_of_mouseovers_(0),
255 load_time_(0),
256 has_emitted_(false) {
240 } 257 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698