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