| 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 | 8 |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 // differ from the WebContents URL which is usually chrome://newtab/. | 103 // differ from the WebContents URL which is usually chrome://newtab/. |
| 104 const content::NavigationEntry* entry = | 104 const content::NavigationEntry* entry = |
| 105 content->GetController().GetVisibleEntry(); | 105 content->GetController().GetVisibleEntry(); |
| 106 if (entry) | 106 if (entry) |
| 107 logger->ntp_url_ = entry->GetURL(); | 107 logger->ntp_url_ = entry->GetURL(); |
| 108 | 108 |
| 109 return logger; | 109 return logger; |
| 110 } | 110 } |
| 111 | 111 |
| 112 void NTPUserDataLogger::EmitNtpStatistics() { | 112 void NTPUserDataLogger::EmitNtpStatistics() { |
| 113 UMA_HISTOGRAM_COUNTS("NewTabPage.NumberOfMouseOvers", number_of_mouseovers_); | |
| 114 number_of_mouseovers_ = 0; | |
| 115 | |
| 116 // We only send statistics once per page. | 113 // We only send statistics once per page. |
| 117 // And we don't send if there are no tiles recorded. | 114 // And we don't send if there are no tiles recorded. |
| 118 if (has_emitted_ || !number_of_tiles_) | 115 if (has_emitted_ || !number_of_tiles_) |
| 119 return; | 116 return; |
| 120 | 117 |
| 121 // LoadTime only gets update once per page, so we don't have it on reloads. | 118 // LoadTime only gets update once per page, so we don't have it on reloads. |
| 122 if (load_time_ > base::TimeDelta::FromMilliseconds(0)) { | 119 if (load_time_ > base::TimeDelta::FromMilliseconds(0)) { |
| 123 logLoadTimeHistogram("NewTabPage.LoadTime", load_time_); | 120 logLoadTimeHistogram("NewTabPage.LoadTime", load_time_); |
| 124 | 121 |
| 125 // Split between ML and MV. | 122 // Split between ML and MV. |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 break; | 193 break; |
| 197 case NTP_THUMBNAIL_ERROR: | 194 case NTP_THUMBNAIL_ERROR: |
| 198 number_of_thumbnail_errors_++; | 195 number_of_thumbnail_errors_++; |
| 199 break; | 196 break; |
| 200 case NTP_GRAY_TILE_FALLBACK: | 197 case NTP_GRAY_TILE_FALLBACK: |
| 201 number_of_gray_tile_fallbacks_++; | 198 number_of_gray_tile_fallbacks_++; |
| 202 break; | 199 break; |
| 203 case NTP_EXTERNAL_TILE_FALLBACK: | 200 case NTP_EXTERNAL_TILE_FALLBACK: |
| 204 number_of_external_tile_fallbacks_++; | 201 number_of_external_tile_fallbacks_++; |
| 205 break; | 202 break; |
| 206 case NTP_MOUSEOVER: | |
| 207 number_of_mouseovers_++; | |
| 208 break; | |
| 209 case NTP_TILE_LOADED: | 203 case NTP_TILE_LOADED: |
| 210 // The time at which the last tile has loaded (title, thumbnail or single) | 204 // The time at which the last tile has loaded (title, thumbnail or single) |
| 211 // is a good proxy for the total load time of the NTP, therefore we keep | 205 // is a good proxy for the total load time of the NTP, therefore we keep |
| 212 // the max as the load time. | 206 // the max as the load time. |
| 213 load_time_ = std::max(load_time_, time); | 207 load_time_ = std::max(load_time_, time); |
| 214 break; | 208 break; |
| 215 default: | 209 default: |
| 216 NOTREACHED(); | 210 NOTREACHED(); |
| 217 } | 211 } |
| 218 } | 212 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 : content::WebContentsObserver(contents), | 264 : content::WebContentsObserver(contents), |
| 271 has_server_side_suggestions_(false), | 265 has_server_side_suggestions_(false), |
| 272 has_client_side_suggestions_(false), | 266 has_client_side_suggestions_(false), |
| 273 number_of_tiles_(0), | 267 number_of_tiles_(0), |
| 274 number_of_thumbnail_tiles_(0), | 268 number_of_thumbnail_tiles_(0), |
| 275 number_of_gray_tiles_(0), | 269 number_of_gray_tiles_(0), |
| 276 number_of_external_tiles_(0), | 270 number_of_external_tiles_(0), |
| 277 number_of_thumbnail_errors_(0), | 271 number_of_thumbnail_errors_(0), |
| 278 number_of_gray_tile_fallbacks_(0), | 272 number_of_gray_tile_fallbacks_(0), |
| 279 number_of_external_tile_fallbacks_(0), | 273 number_of_external_tile_fallbacks_(0), |
| 280 number_of_mouseovers_(0), | |
| 281 has_emitted_(false), | 274 has_emitted_(false), |
| 282 during_startup_(false) { | 275 during_startup_(false) { |
| 283 during_startup_ = !AfterStartupTaskUtils::IsBrowserStartupComplete(); | 276 during_startup_ = !AfterStartupTaskUtils::IsBrowserStartupComplete(); |
| 284 | 277 |
| 285 // We record metrics about session data here because when this class typically | 278 // We record metrics about session data here because when this class typically |
| 286 // emits metrics it is too late. This session data would theoretically have | 279 // emits metrics it is too late. This session data would theoretically have |
| 287 // been used to populate the page, and we want to learn about its state when | 280 // been used to populate the page, and we want to learn about its state when |
| 288 // the NTP is being generated. | 281 // the NTP is being generated. |
| 289 if (contents) { | 282 if (contents) { |
| 290 ProfileSyncService* sync = ProfileSyncServiceFactory::GetForProfile( | 283 ProfileSyncService* sync = ProfileSyncServiceFactory::GetForProfile( |
| 291 Profile::FromBrowserContext(contents->GetBrowserContext())); | 284 Profile::FromBrowserContext(contents->GetBrowserContext())); |
| 292 if (sync) { | 285 if (sync) { |
| 293 browser_sync::SessionsSyncManager* sessions = | 286 browser_sync::SessionsSyncManager* sessions = |
| 294 static_cast<browser_sync::SessionsSyncManager*>( | 287 static_cast<browser_sync::SessionsSyncManager*>( |
| 295 sync->GetSessionsSyncableService()); | 288 sync->GetSessionsSyncableService()); |
| 296 if (sessions) { | 289 if (sessions) { |
| 297 sync_sessions::SyncSessionsMetrics::RecordYoungestForeignTabAgeOnNTP( | 290 sync_sessions::SyncSessionsMetrics::RecordYoungestForeignTabAgeOnNTP( |
| 298 sessions); | 291 sessions); |
| 299 } | 292 } |
| 300 } | 293 } |
| 301 } | 294 } |
| 302 } | 295 } |
| OLD | NEW |