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