| 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 } | 148 } |
| 149 | 149 |
| 150 void NTPUserDataLogger::EmitNtpStatistics(base::TimeDelta load_time) { | 150 void NTPUserDataLogger::EmitNtpStatistics(base::TimeDelta load_time) { |
| 151 // We only send statistics once per page. | 151 // We only send statistics once per page. |
| 152 if (has_emitted_) | 152 if (has_emitted_) |
| 153 return; | 153 return; |
| 154 | 154 |
| 155 DVLOG(1) << "Emitting NTP load time: " << load_time << ", " | 155 DVLOG(1) << "Emitting NTP load time: " << load_time << ", " |
| 156 << "number of tiles: " << impression_was_logged_.count(); | 156 << "number of tiles: " << impression_was_logged_.count(); |
| 157 | 157 |
| 158 std::vector<std::pair<ntp_tiles::NTPTileSource, | 158 std::vector<ntp_tiles::metrics::TileImpression> tiles; |
| 159 ntp_tiles::metrics::MostVisitedTileType>> | |
| 160 tiles; | |
| 161 bool has_server_side_suggestions = false; | 159 bool has_server_side_suggestions = false; |
| 162 for (int i = 0; i < kNumMostVisited; i++) { | 160 for (int i = 0; i < kNumMostVisited; i++) { |
| 163 if (!impression_was_logged_[i]) { | 161 if (!impression_was_logged_[i]) { |
| 164 break; | 162 break; |
| 165 } | 163 } |
| 166 if (impression_tile_source_[i] == | 164 if (impression_tile_source_[i] == |
| 167 ntp_tiles::NTPTileSource::SUGGESTIONS_SERVICE) { | 165 ntp_tiles::NTPTileSource::SUGGESTIONS_SERVICE) { |
| 168 has_server_side_suggestions = true; | 166 has_server_side_suggestions = true; |
| 169 } | 167 } |
| 168 // No URL passed since we're not interested in favicon-related Rappor |
| 169 // metrics. |
| 170 tiles.emplace_back(impression_tile_source_[i], | 170 tiles.emplace_back(impression_tile_source_[i], |
| 171 ntp_tiles::metrics::THUMBNAIL); | 171 ntp_tiles::metrics::THUMBNAIL, GURL()); |
| 172 } | 172 } |
| 173 ntp_tiles::metrics::RecordPageImpression(tiles); | 173 |
| 174 // Not interested in Rappor metrics. |
| 175 ntp_tiles::metrics::RecordPageImpression(tiles, /*rappor_service=*/nullptr); |
| 174 | 176 |
| 175 LogLoadTimeHistogram("NewTabPage.LoadTime", load_time); | 177 LogLoadTimeHistogram("NewTabPage.LoadTime", load_time); |
| 176 | 178 |
| 177 // Split between ML and MV. | 179 // Split between ML and MV. |
| 178 std::string type = has_server_side_suggestions ? "MostLikely" : "MostVisited"; | 180 std::string type = has_server_side_suggestions ? "MostLikely" : "MostVisited"; |
| 179 LogLoadTimeHistogram("NewTabPage.LoadTime." + type, load_time); | 181 LogLoadTimeHistogram("NewTabPage.LoadTime." + type, load_time); |
| 180 | 182 |
| 181 // Split between Web and Local. | 183 // Split between Web and Local. |
| 182 std::string variant = ntp_url_.SchemeIsHTTPOrHTTPS() ? "Web" : "LocalNTP"; | 184 std::string variant = ntp_url_.SchemeIsHTTPOrHTTPS() ? "Web" : "LocalNTP"; |
| 183 LogLoadTimeHistogram("NewTabPage.LoadTime." + variant, load_time); | 185 LogLoadTimeHistogram("NewTabPage.LoadTime." + variant, load_time); |
| 184 | 186 |
| 185 // Split between Startup and non-startup. | 187 // Split between Startup and non-startup. |
| 186 std::string status = during_startup_ ? "Startup" : "NewTab"; | 188 std::string status = during_startup_ ? "Startup" : "NewTab"; |
| 187 LogLoadTimeHistogram("NewTabPage.LoadTime." + status, load_time); | 189 LogLoadTimeHistogram("NewTabPage.LoadTime." + status, load_time); |
| 188 | 190 |
| 189 has_emitted_ = true; | 191 has_emitted_ = true; |
| 190 during_startup_ = false; | 192 during_startup_ = false; |
| 191 } | 193 } |
| OLD | NEW |