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

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 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 base::TimeDelta::FromMilliseconds(load_time_),
128 base::TimeDelta::FromMilliseconds(1),
129 base::TimeDelta::FromSeconds(60), 100);
130 load_time_ = 0;
131 has_emitted_ = true;
128 } 132 }
129 133
130 void NTPUserDataLogger::LogEvent(NTPLoggingEventType event, uint64 time) { 134 void NTPUserDataLogger::LogEvent(NTPLoggingEventType event, uint64 time) {
131 switch (event) { 135 switch (event) {
132 case NTP_SERVER_SIDE_SUGGESTION: 136 case NTP_SERVER_SIDE_SUGGESTION:
133 has_server_side_suggestions_ = true; 137 has_server_side_suggestions_ = true;
134 break; 138 break;
135 case NTP_CLIENT_SIDE_SUGGESTION: 139 case NTP_CLIENT_SIDE_SUGGESTION:
136 // We should never get a mix of server and client side suggestions, 140 // 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 141 // otherwise there could be a race condition depending on the order in
(...skipping 17 matching lines...) Expand all
155 break; 159 break;
156 case NTP_GRAY_TILE_FALLBACK: 160 case NTP_GRAY_TILE_FALLBACK:
157 number_of_gray_tile_fallbacks_++; 161 number_of_gray_tile_fallbacks_++;
158 break; 162 break;
159 case NTP_EXTERNAL_TILE_FALLBACK: 163 case NTP_EXTERNAL_TILE_FALLBACK:
160 number_of_external_tile_fallbacks_++; 164 number_of_external_tile_fallbacks_++;
161 break; 165 break;
162 case NTP_MOUSEOVER: 166 case NTP_MOUSEOVER:
163 number_of_mouseovers_++; 167 number_of_mouseovers_++;
164 break; 168 break;
169 case NTP_TILE_LOADED:
170 // The time at which the last tile has loaded (title, thumbnail or single)
171 // is a good proxy for the total load time of the NTP, therefore we keep
172 // the max as the load time.
173 load_time_ = std::max(load_time_, time);
174 break;
165 default: 175 default:
166 NOTREACHED(); 176 NOTREACHED();
167 } 177 }
168 } 178 }
169 179
170 void NTPUserDataLogger::LogMostVisitedImpression( 180 void NTPUserDataLogger::LogMostVisitedImpression(
171 int position, const base::string16& provider) { 181 int position, const base::string16& provider) {
172 // Log the Most Visited navigation for navigations that have providers and 182 // Log the Most Visited navigation for navigations that have providers and
173 // those that dont. 183 // those that dont.
174 UMA_HISTOGRAM_ENUMERATION(kMostVisitedImpressionHistogramName, position, 184 UMA_HISTOGRAM_ENUMERATION(kMostVisitedImpressionHistogramName, position,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 NTPUserDataLogger::NTPUserDataLogger(content::WebContents* contents) 239 NTPUserDataLogger::NTPUserDataLogger(content::WebContents* contents)
230 : content::WebContentsObserver(contents), 240 : content::WebContentsObserver(contents),
231 has_server_side_suggestions_(false), 241 has_server_side_suggestions_(false),
232 number_of_tiles_(0), 242 number_of_tiles_(0),
233 number_of_thumbnail_tiles_(0), 243 number_of_thumbnail_tiles_(0),
234 number_of_gray_tiles_(0), 244 number_of_gray_tiles_(0),
235 number_of_external_tiles_(0), 245 number_of_external_tiles_(0),
236 number_of_thumbnail_errors_(0), 246 number_of_thumbnail_errors_(0),
237 number_of_gray_tile_fallbacks_(0), 247 number_of_gray_tile_fallbacks_(0),
238 number_of_external_tile_fallbacks_(0), 248 number_of_external_tile_fallbacks_(0),
239 number_of_mouseovers_(0) { 249 number_of_mouseovers_(0),
250 load_time_(0),
251 has_emitted_(false) {
240 } 252 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698