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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 tiles_received_time_ = time; | 91 tiles_received_time_ = time; |
92 break; | 92 break; |
93 case NTP_ALL_TILES_LOADED: | 93 case NTP_ALL_TILES_LOADED: |
94 EmitNtpStatistics(time); | 94 EmitNtpStatistics(time); |
95 break; | 95 break; |
96 } | 96 } |
97 } | 97 } |
98 | 98 |
99 void NTPUserDataLogger::LogMostVisitedImpression( | 99 void NTPUserDataLogger::LogMostVisitedImpression( |
100 int position, | 100 int position, |
101 ntp_tiles::NTPTileSource tile_source) { | 101 ntp_tiles::TileSource tile_source) { |
102 if ((position >= kNumMostVisited) || impression_was_logged_[position]) { | 102 if ((position >= kNumMostVisited) || impression_was_logged_[position]) { |
103 return; | 103 return; |
104 } | 104 } |
105 impression_was_logged_[position] = true; | 105 impression_was_logged_[position] = true; |
106 impression_tile_source_[position] = tile_source; | 106 impression_tile_source_[position] = tile_source; |
107 } | 107 } |
108 | 108 |
109 void NTPUserDataLogger::LogMostVisitedNavigation( | 109 void NTPUserDataLogger::LogMostVisitedNavigation( |
110 int position, | 110 int position, |
111 ntp_tiles::NTPTileSource tile_source) { | 111 ntp_tiles::TileSource tile_source) { |
112 ntp_tiles::metrics::RecordTileClick(position, tile_source, | 112 ntp_tiles::metrics::RecordTileClick(position, tile_source, |
113 ntp_tiles::metrics::THUMBNAIL); | 113 ntp_tiles::TileVisualType::THUMBNAIL); |
114 | 114 |
115 // Records the action. This will be available as a time-stamped stream | 115 // Records the action. This will be available as a time-stamped stream |
116 // server-side and can be used to compute time-to-long-dwell. | 116 // server-side and can be used to compute time-to-long-dwell. |
117 base::RecordAction(base::UserMetricsAction("MostVisited_Clicked")); | 117 base::RecordAction(base::UserMetricsAction("MostVisited_Clicked")); |
118 } | 118 } |
119 | 119 |
120 NTPUserDataLogger::NTPUserDataLogger(content::WebContents* contents) | 120 NTPUserDataLogger::NTPUserDataLogger(content::WebContents* contents) |
121 : content::WebContentsObserver(contents), | 121 : content::WebContentsObserver(contents), |
122 impression_tile_source_(kNumMostVisited), | 122 impression_tile_source_(kNumMostVisited), |
123 has_emitted_(false), | 123 has_emitted_(false), |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 DVLOG(1) << "Emitting NTP load time: " << load_time << ", " | 156 DVLOG(1) << "Emitting NTP load time: " << load_time << ", " |
157 << "number of tiles: " << impression_was_logged_.count(); | 157 << "number of tiles: " << impression_was_logged_.count(); |
158 | 158 |
159 std::vector<ntp_tiles::metrics::TileImpression> tiles; | 159 std::vector<ntp_tiles::metrics::TileImpression> tiles; |
160 bool has_server_side_suggestions = false; | 160 bool has_server_side_suggestions = false; |
161 for (int i = 0; i < kNumMostVisited; i++) { | 161 for (int i = 0; i < kNumMostVisited; i++) { |
162 if (!impression_was_logged_[i]) { | 162 if (!impression_was_logged_[i]) { |
163 break; | 163 break; |
164 } | 164 } |
165 if (impression_tile_source_[i] == | 165 if (impression_tile_source_[i] == |
166 ntp_tiles::NTPTileSource::SUGGESTIONS_SERVICE) { | 166 ntp_tiles::TileSource::SUGGESTIONS_SERVICE) { |
167 has_server_side_suggestions = true; | 167 has_server_side_suggestions = true; |
168 } | 168 } |
169 // No URL passed since we're not interested in favicon-related Rappor | 169 // No URL passed since we're not interested in favicon-related Rappor |
170 // metrics. | 170 // metrics. |
171 tiles.emplace_back(impression_tile_source_[i], | 171 tiles.emplace_back(impression_tile_source_[i], |
172 ntp_tiles::metrics::THUMBNAIL, GURL()); | 172 ntp_tiles::TileVisualType::THUMBNAIL, GURL()); |
173 } | 173 } |
174 | 174 |
175 // Not interested in Rappor metrics. | 175 // Not interested in Rappor metrics. |
176 ntp_tiles::metrics::RecordPageImpression(tiles, /*rappor_service=*/nullptr); | 176 ntp_tiles::metrics::RecordPageImpression(tiles, /*rappor_service=*/nullptr); |
177 | 177 |
178 UMA_HISTOGRAM_LOAD_TIME("NewTabPage.TilesReceivedTime", tiles_received_time_); | 178 UMA_HISTOGRAM_LOAD_TIME("NewTabPage.TilesReceivedTime", tiles_received_time_); |
179 UMA_HISTOGRAM_LOAD_TIME("NewTabPage.LoadTime", load_time); | 179 UMA_HISTOGRAM_LOAD_TIME("NewTabPage.LoadTime", load_time); |
180 | 180 |
181 // Split between ML (aka SuggestionsService) and MV (aka TopSites). | 181 // Split between ML (aka SuggestionsService) and MV (aka TopSites). |
182 if (has_server_side_suggestions) { | 182 if (has_server_side_suggestions) { |
(...skipping 24 matching lines...) Expand all Loading... |
207 UMA_HISTOGRAM_LOAD_TIME("NewTabPage.LoadTime.Startup", load_time); | 207 UMA_HISTOGRAM_LOAD_TIME("NewTabPage.LoadTime.Startup", load_time); |
208 } else { | 208 } else { |
209 UMA_HISTOGRAM_LOAD_TIME("NewTabPage.TilesReceivedTime.NewTab", | 209 UMA_HISTOGRAM_LOAD_TIME("NewTabPage.TilesReceivedTime.NewTab", |
210 tiles_received_time_); | 210 tiles_received_time_); |
211 UMA_HISTOGRAM_LOAD_TIME("NewTabPage.LoadTime.NewTab", load_time); | 211 UMA_HISTOGRAM_LOAD_TIME("NewTabPage.LoadTime.NewTab", load_time); |
212 } | 212 } |
213 | 213 |
214 has_emitted_ = true; | 214 has_emitted_ = true; |
215 during_startup_ = false; | 215 during_startup_ = false; |
216 } | 216 } |
OLD | NEW |