Index: chrome/browser/ui/webui/ntp/ntp_user_data_logger.h |
diff --git a/chrome/browser/ui/webui/ntp/ntp_user_data_logger.h b/chrome/browser/ui/webui/ntp/ntp_user_data_logger.h |
index c3efcc52bd411a8ed005c4b0d6220e4aabba5ebf..7150ce86d9c08b68d1bc4a20adbb49d097220629 100644 |
--- a/chrome/browser/ui/webui/ntp/ntp_user_data_logger.h |
+++ b/chrome/browser/ui/webui/ntp/ntp_user_data_logger.h |
@@ -31,11 +31,6 @@ class NTPUserDataLogger |
static NTPUserDataLogger* GetOrCreateFromWebContents( |
content::WebContents* content); |
- // Logs a number of statistics regarding the NTP. Called when an NTP tab is |
- // about to be deactivated (be it by switching tabs, losing focus or closing |
- // the tab/shutting down Chrome), or when the user navigates to a URL. |
- void EmitNtpStatistics(); |
- |
// Called when an event occurs on the NTP that requires a counter to be |
// incremented. |time| is the delta time in ms from navigation start until |
// this event happened. |
@@ -51,6 +46,12 @@ class NTPUserDataLogger |
void NavigationEntryCommitted( |
const content::LoadCommittedDetails& load_details) override; |
+ // Called when the tab is closed. Logs statistics. |
+ void TabDeactivated(); |
+ |
+ // Called when the set of most visited sites changes. Flushes statistics. |
+ void MostVisitedItemsChanged(); |
+ |
protected: |
explicit NTPUserDataLogger(content::WebContents* contents); |
@@ -61,6 +62,19 @@ class NTPUserDataLogger |
OnMostVisitedItemsChangedFromServer); |
FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest, |
OnMostVisitedItemsChangedFromClient); |
+ FRIEND_TEST_ALL_PREFIXES(NTPUserDataLoggerTest, |
+ TestLogging); |
+ |
+ // To clarify at the call site whether we are calling EmitNtpStatistics() for |
+ // a good reason (CLOSED, NAVIGATED_AWAY) or a questionable one (MV_CHANGED, |
+ // INTERNAL_FLUSH). |
+ // TODO(sfiera): remove MV_CHANGED, INTERNAL_FLUSH. |
+ enum class EmitReason { CLOSED, NAVIGATED_AWAY, MV_CHANGED, INTERNAL_FLUSH }; |
+ |
+ // Logs a number of statistics regarding the NTP. Called when an NTP tab is |
+ // about to be deactivated (be it by switching tabs, losing focus or closing |
+ // the tab/shutting down Chrome), or when the user navigates to a URL. |
+ void EmitNtpStatistics(EmitReason reason); |
// True if at least one iframe came from a server-side suggestion. |
bool has_server_side_suggestions_; |