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::TileSource tile_source) { | 101 ntp_tiles::TileSource tile_source, |
| 102 ntp_tiles::TileVisualType tile_type) { |
102 if ((position >= kNumMostVisited) || impression_was_logged_[position]) { | 103 if ((position >= kNumMostVisited) || impression_was_logged_[position]) { |
103 return; | 104 return; |
104 } | 105 } |
105 impression_was_logged_[position] = true; | 106 impression_was_logged_[position] = true; |
106 impression_tile_source_[position] = tile_source; | 107 impression_tile_source_[position] = tile_source; |
| 108 impression_tile_type_[position] = tile_type; |
107 } | 109 } |
108 | 110 |
109 void NTPUserDataLogger::LogMostVisitedNavigation( | 111 void NTPUserDataLogger::LogMostVisitedNavigation( |
110 int position, | 112 int position, |
111 ntp_tiles::TileSource tile_source) { | 113 ntp_tiles::TileSource tile_source, |
112 ntp_tiles::metrics::RecordTileClick(position, tile_source, | 114 ntp_tiles::TileVisualType tile_type) { |
113 ntp_tiles::TileVisualType::THUMBNAIL); | 115 ntp_tiles::metrics::RecordTileClick(position, tile_source, tile_type); |
114 | 116 |
115 // Records the action. This will be available as a time-stamped stream | 117 // 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. | 118 // server-side and can be used to compute time-to-long-dwell. |
117 base::RecordAction(base::UserMetricsAction("MostVisited_Clicked")); | 119 base::RecordAction(base::UserMetricsAction("MostVisited_Clicked")); |
118 } | 120 } |
119 | 121 |
120 NTPUserDataLogger::NTPUserDataLogger(content::WebContents* contents) | 122 NTPUserDataLogger::NTPUserDataLogger(content::WebContents* contents) |
121 : content::WebContentsObserver(contents), | 123 : content::WebContentsObserver(contents), |
122 impression_tile_source_(kNumMostVisited), | 124 impression_tile_source_(kNumMostVisited), |
| 125 impression_tile_type_(kNumMostVisited), |
123 has_emitted_(false), | 126 has_emitted_(false), |
124 during_startup_(!AfterStartupTaskUtils::IsBrowserStartupComplete()) { | 127 during_startup_(!AfterStartupTaskUtils::IsBrowserStartupComplete()) { |
125 // We record metrics about session data here because when this class typically | 128 // We record metrics about session data here because when this class typically |
126 // emits metrics it is too late. This session data would theoretically have | 129 // emits metrics it is too late. This session data would theoretically have |
127 // been used to populate the page, and we want to learn about its state when | 130 // been used to populate the page, and we want to learn about its state when |
128 // the NTP is being generated. | 131 // the NTP is being generated. |
129 RecordSyncSessionMetrics(contents); | 132 RecordSyncSessionMetrics(contents); |
130 } | 133 } |
131 | 134 |
132 // content::WebContentsObserver override | 135 // content::WebContentsObserver override |
(...skipping 28 matching lines...) Expand all Loading... |
161 for (int i = 0; i < kNumMostVisited; i++) { | 164 for (int i = 0; i < kNumMostVisited; i++) { |
162 if (!impression_was_logged_[i]) { | 165 if (!impression_was_logged_[i]) { |
163 break; | 166 break; |
164 } | 167 } |
165 if (impression_tile_source_[i] == | 168 if (impression_tile_source_[i] == |
166 ntp_tiles::TileSource::SUGGESTIONS_SERVICE) { | 169 ntp_tiles::TileSource::SUGGESTIONS_SERVICE) { |
167 has_server_side_suggestions = true; | 170 has_server_side_suggestions = true; |
168 } | 171 } |
169 // No URL passed since we're not interested in favicon-related Rappor | 172 // No URL passed since we're not interested in favicon-related Rappor |
170 // metrics. | 173 // metrics. |
171 tiles.emplace_back(impression_tile_source_[i], | 174 tiles.emplace_back(impression_tile_source_[i], impression_tile_type_[i], |
172 ntp_tiles::TileVisualType::THUMBNAIL, GURL()); | 175 GURL()); |
173 } | 176 } |
174 | 177 |
175 // Not interested in Rappor metrics. | 178 // Not interested in Rappor metrics. |
176 ntp_tiles::metrics::RecordPageImpression(tiles, /*rappor_service=*/nullptr); | 179 ntp_tiles::metrics::RecordPageImpression(tiles, /*rappor_service=*/nullptr); |
177 | 180 |
178 UMA_HISTOGRAM_LOAD_TIME("NewTabPage.TilesReceivedTime", tiles_received_time_); | 181 UMA_HISTOGRAM_LOAD_TIME("NewTabPage.TilesReceivedTime", tiles_received_time_); |
179 UMA_HISTOGRAM_LOAD_TIME("NewTabPage.LoadTime", load_time); | 182 UMA_HISTOGRAM_LOAD_TIME("NewTabPage.LoadTime", load_time); |
180 | 183 |
181 // Split between ML (aka SuggestionsService) and MV (aka TopSites). | 184 // Split between ML (aka SuggestionsService) and MV (aka TopSites). |
182 if (has_server_side_suggestions) { | 185 if (has_server_side_suggestions) { |
(...skipping 24 matching lines...) Expand all Loading... |
207 UMA_HISTOGRAM_LOAD_TIME("NewTabPage.LoadTime.Startup", load_time); | 210 UMA_HISTOGRAM_LOAD_TIME("NewTabPage.LoadTime.Startup", load_time); |
208 } else { | 211 } else { |
209 UMA_HISTOGRAM_LOAD_TIME("NewTabPage.TilesReceivedTime.NewTab", | 212 UMA_HISTOGRAM_LOAD_TIME("NewTabPage.TilesReceivedTime.NewTab", |
210 tiles_received_time_); | 213 tiles_received_time_); |
211 UMA_HISTOGRAM_LOAD_TIME("NewTabPage.LoadTime.NewTab", load_time); | 214 UMA_HISTOGRAM_LOAD_TIME("NewTabPage.LoadTime.NewTab", load_time); |
212 } | 215 } |
213 | 216 |
214 has_emitted_ = true; | 217 has_emitted_ = true; |
215 during_startup_ = false; | 218 during_startup_ = false; |
216 } | 219 } |
OLD | NEW |