Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(697)

Side by Side Diff: chrome/browser/ui/webui/ntp/ntp_user_data_logger.h

Issue 2127783002: Make EmitNtpStatistics() private. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef CHROME_BROWSER_UI_WEBUI_NTP_NTP_USER_DATA_LOGGER_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_NTP_NTP_USER_DATA_LOGGER_H_
6 #define CHROME_BROWSER_UI_WEBUI_NTP_NTP_USER_DATA_LOGGER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_NTP_NTP_USER_DATA_LOGGER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 13 matching lines...) Expand all
24 // Helper class for logging data from the NTP. Attached to each NTP instance. 24 // Helper class for logging data from the NTP. Attached to each NTP instance.
25 class NTPUserDataLogger 25 class NTPUserDataLogger
26 : public content::WebContentsObserver, 26 : public content::WebContentsObserver,
27 public content::WebContentsUserData<NTPUserDataLogger> { 27 public content::WebContentsUserData<NTPUserDataLogger> {
28 public: 28 public:
29 ~NTPUserDataLogger() override; 29 ~NTPUserDataLogger() override;
30 30
31 static NTPUserDataLogger* GetOrCreateFromWebContents( 31 static NTPUserDataLogger* GetOrCreateFromWebContents(
32 content::WebContents* content); 32 content::WebContents* content);
33 33
34 // Logs a number of statistics regarding the NTP. Called when an NTP tab is
35 // about to be deactivated (be it by switching tabs, losing focus or closing
36 // the tab/shutting down Chrome), or when the user navigates to a URL.
37 void EmitNtpStatistics();
38
39 // Called when an event occurs on the NTP that requires a counter to be 34 // Called when an event occurs on the NTP that requires a counter to be
40 // incremented. |time| is the delta time in ms from navigation start until 35 // incremented. |time| is the delta time in ms from navigation start until
41 // this event happened. 36 // this event happened.
42 void LogEvent(NTPLoggingEventType event, base::TimeDelta time); 37 void LogEvent(NTPLoggingEventType event, base::TimeDelta time);
43 38
44 // Logs an impression on one of the NTP tiles by a given source. 39 // Logs an impression on one of the NTP tiles by a given source.
45 void LogMostVisitedImpression(int position, NTPLoggingTileSource tile_source); 40 void LogMostVisitedImpression(int position, NTPLoggingTileSource tile_source);
46 41
47 // Logs a navigation on one of the NTP tiles by a given source. 42 // Logs a navigation on one of the NTP tiles by a given source.
48 void LogMostVisitedNavigation(int position, NTPLoggingTileSource tile_source); 43 void LogMostVisitedNavigation(int position, NTPLoggingTileSource tile_source);
49 44
50 // content::WebContentsObserver override 45 // content::WebContentsObserver override
51 void NavigationEntryCommitted( 46 void NavigationEntryCommitted(
52 const content::LoadCommittedDetails& load_details) override; 47 const content::LoadCommittedDetails& load_details) override;
53 48
49 // Called when the tab is closed. Logs statistics.
50 void TabDeactivated();
51
52 // Called when the set of most visited sites changes. Flushes statistics.
53 void MostVisitedItemsChanged();
54
54 protected: 55 protected:
55 explicit NTPUserDataLogger(content::WebContents* contents); 56 explicit NTPUserDataLogger(content::WebContents* contents);
56 57
57 private: 58 private:
58 friend class content::WebContentsUserData<NTPUserDataLogger>; 59 friend class content::WebContentsUserData<NTPUserDataLogger>;
59 60
60 FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest, 61 FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest,
61 OnMostVisitedItemsChangedFromServer); 62 OnMostVisitedItemsChangedFromServer);
62 FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest, 63 FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest,
63 OnMostVisitedItemsChangedFromClient); 64 OnMostVisitedItemsChangedFromClient);
65 FRIEND_TEST_ALL_PREFIXES(NTPUserDataLoggerTest,
66 TestLogging);
67
68 // To clarify at the call site whether we are calling EmitNtpStatistics() for
69 // a good reason (CLOSED, NAVIGATED_AWAY) or a questionable one (MV_CHANGED,
70 // INTERNAL_FLUSH).
71 // TODO(sfiera): remove MV_CHANGED, INTERNAL_FLUSH.
72 enum class EmitReason { CLOSED, NAVIGATED_AWAY, MV_CHANGED, INTERNAL_FLUSH };
73
74 // Logs a number of statistics regarding the NTP. Called when an NTP tab is
75 // about to be deactivated (be it by switching tabs, losing focus or closing
76 // the tab/shutting down Chrome), or when the user navigates to a URL.
77 void EmitNtpStatistics(EmitReason reason);
64 78
65 // True if at least one iframe came from a server-side suggestion. 79 // True if at least one iframe came from a server-side suggestion.
66 bool has_server_side_suggestions_; 80 bool has_server_side_suggestions_;
67 81
68 // True if at least one iframe came from a client-side suggestion. 82 // True if at least one iframe came from a client-side suggestion.
69 bool has_client_side_suggestions_; 83 bool has_client_side_suggestions_;
70 84
71 // Total number of tiles rendered, no matter if it's a thumbnail, a gray tile 85 // Total number of tiles rendered, no matter if it's a thumbnail, a gray tile
72 // or an external tile. 86 // or an external tile.
73 size_t number_of_tiles_; 87 size_t number_of_tiles_;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // Are stats being logged during Chrome startup? 119 // Are stats being logged during Chrome startup?
106 bool during_startup_; 120 bool during_startup_;
107 121
108 // The URL of this New Tab Page - varies based on NTP version. 122 // The URL of this New Tab Page - varies based on NTP version.
109 GURL ntp_url_; 123 GURL ntp_url_;
110 124
111 DISALLOW_COPY_AND_ASSIGN(NTPUserDataLogger); 125 DISALLOW_COPY_AND_ASSIGN(NTPUserDataLogger);
112 }; 126 };
113 127
114 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NTP_USER_DATA_LOGGER_H_ 128 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NTP_USER_DATA_LOGGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/search_tab_helper.cc ('k') | chrome/browser/ui/webui/ntp/ntp_user_data_logger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698