| 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 "base/metrics/user_metrics.h" | 
| 11 #include "chrome/browser/after_startup_task_utils.h" | 12 #include "chrome/browser/after_startup_task_utils.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" | 
| 22 #include "content/public/browser/navigation_entry.h" | 23 #include "content/public/browser/navigation_entry.h" | 
| 23 #include "content/public/browser/user_metrics.h" |  | 
| 24 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" | 
| 25 | 25 | 
| 26 namespace { | 26 namespace { | 
| 27 | 27 | 
| 28 void RecordSyncSessionMetrics(content::WebContents* contents) { | 28 void RecordSyncSessionMetrics(content::WebContents* contents) { | 
| 29   if (!contents) | 29   if (!contents) | 
| 30     return; | 30     return; | 
| 31   browser_sync::ProfileSyncService* sync = | 31   browser_sync::ProfileSyncService* sync = | 
| 32       ProfileSyncServiceFactory::GetForProfile( | 32       ProfileSyncServiceFactory::GetForProfile( | 
| 33           Profile::FromBrowserContext(contents->GetBrowserContext())); | 33           Profile::FromBrowserContext(contents->GetBrowserContext())); | 
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 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::NTPTileSource 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::metrics::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   content::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), | 
| 124       during_startup_(!AfterStartupTaskUtils::IsBrowserStartupComplete()) { | 124       during_startup_(!AfterStartupTaskUtils::IsBrowserStartupComplete()) { | 
| 125   // We record metrics about session data here because when this class typically | 125   // 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 | 126   // 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 | 127   // been used to populate the page, and we want to learn about its state when | 
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after  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 | 
|---|