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 <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
115 DVLOG(1) << "NTP URL changed from \"" << logger->ntp_url_ << "\" to \"" | 115 DVLOG(1) << "NTP URL changed from \"" << logger->ntp_url_ << "\" to \"" |
116 << entry->GetURL() << "\""; | 116 << entry->GetURL() << "\""; |
117 logger->ntp_url_ = entry->GetURL(); | 117 logger->ntp_url_ = entry->GetURL(); |
118 } | 118 } |
119 | 119 |
120 return logger; | 120 return logger; |
121 } | 121 } |
122 | 122 |
123 void NTPUserDataLogger::LogEvent(NTPLoggingEventType event, | 123 void NTPUserDataLogger::LogEvent(NTPLoggingEventType event, |
124 base::TimeDelta time) { | 124 base::TimeDelta time) { |
125 switch (event) { | 125 DCHECK_EQ(NTP_ALL_TILES_LOADED, event); |
126 case NTP_SERVER_SIDE_SUGGESTION: | 126 EmitNtpStatistics(time); |
127 has_server_side_suggestions_ = true; | |
128 number_of_tiles_++; | |
129 return; | |
130 case NTP_CLIENT_SIDE_SUGGESTION: | |
131 has_client_side_suggestions_ = true; | |
132 number_of_tiles_++; | |
133 return; | |
134 case NTP_ALL_TILES_LOADED: | |
135 EmitNtpStatistics(time); | |
136 return; | |
137 } | |
138 NOTREACHED(); | |
139 } | 127 } |
140 | 128 |
141 void NTPUserDataLogger::LogMostVisitedImpression( | 129 void NTPUserDataLogger::LogMostVisitedImpression( |
142 int position, NTPLoggingTileSource tile_source) { | 130 int position, NTPLoggingTileSource tile_source) { |
131 switch (tile_source) { | |
132 case NTPLoggingTileSource::CLIENT: | |
133 has_client_side_suggestions_ = true; | |
134 break; | |
135 case NTPLoggingTileSource::SERVER: | |
136 has_server_side_suggestions_ = true; | |
137 break; | |
138 } | |
139 number_of_tiles_++; | |
Marc Treib
2016/10/24 11:51:43
This preserves the previous behavior: set has_clie
sfiera
2016/10/24 13:01:16
Does it matter? number_of_tiles_ is only relevant
Marc Treib
2016/10/24 14:29:11
Exactly, it *shouldn't* matter. If for whatever re
sfiera
2016/10/24 14:41:11
Even better!
| |
140 | |
143 if ((position >= kNumMostVisited) || impression_was_logged_[position]) { | 141 if ((position >= kNumMostVisited) || impression_was_logged_[position]) { |
144 return; | 142 return; |
145 } | 143 } |
146 impression_was_logged_[position] = true; | 144 impression_was_logged_[position] = true; |
147 | 145 |
148 UMA_HISTOGRAM_ENUMERATION(kMostVisitedImpressionHistogramName, position, | 146 UMA_HISTOGRAM_ENUMERATION(kMostVisitedImpressionHistogramName, position, |
149 kNumMostVisited); | 147 kNumMostVisited); |
150 | 148 |
151 // Cannot rely on UMA histograms macro because the name of the histogram is | 149 // Cannot rely on UMA histograms macro because the name of the histogram is |
152 // generated dynamically. | 150 // generated dynamically. |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
238 | 236 |
239 has_server_side_suggestions_ = false; | 237 has_server_side_suggestions_ = false; |
240 has_client_side_suggestions_ = false; | 238 has_client_side_suggestions_ = false; |
241 UMA_HISTOGRAM_CUSTOM_COUNTS( | 239 UMA_HISTOGRAM_CUSTOM_COUNTS( |
242 "NewTabPage.NumberOfTiles", number_of_tiles_, 1, kNumMostVisited, | 240 "NewTabPage.NumberOfTiles", number_of_tiles_, 1, kNumMostVisited, |
243 kNumMostVisited + 1); | 241 kNumMostVisited + 1); |
244 number_of_tiles_ = 0; | 242 number_of_tiles_ = 0; |
245 has_emitted_ = true; | 243 has_emitted_ = true; |
246 during_startup_ = false; | 244 during_startup_ = false; |
247 } | 245 } |
OLD | NEW |