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

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);
64 65
66 // To clarify at the call site whether we are calling EmitNtpStatistics() for
67 // a good reason (CLOSED, NAVIGATED_AWAY) or a questionable one (MV_CHANGED,
68 // INTNERNAL_FLUSH).
Marc Treib 2016/07/06 12:04:27 nit: typo
sfiera 2016/07/06 12:08:41 Done.
69 // TODO(sfiera): remove MV_CHANGED, INTERNAL_FLUSH.
70 enum class EmitReason { CLOSED, NAVIGATED_AWAY, MV_CHANGED, INTERNAL_FLUSH };
71
72 // Logs a number of statistics regarding the NTP. Called when an NTP tab is
73 // about to be deactivated (be it by switching tabs, losing focus or closing
74 // the tab/shutting down Chrome), or when the user navigates to a URL.
75 void EmitNtpStatistics(EmitReason reason);
76
65 // True if at least one iframe came from a server-side suggestion. 77 // True if at least one iframe came from a server-side suggestion.
66 bool has_server_side_suggestions_; 78 bool has_server_side_suggestions_;
67 79
68 // True if at least one iframe came from a client-side suggestion. 80 // True if at least one iframe came from a client-side suggestion.
69 bool has_client_side_suggestions_; 81 bool has_client_side_suggestions_;
70 82
71 // Total number of tiles rendered, no matter if it's a thumbnail, a gray tile 83 // Total number of tiles rendered, no matter if it's a thumbnail, a gray tile
72 // or an external tile. 84 // or an external tile.
73 size_t number_of_tiles_; 85 size_t number_of_tiles_;
74 86
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // Are stats being logged during Chrome startup? 120 // Are stats being logged during Chrome startup?
109 bool during_startup_; 121 bool during_startup_;
110 122
111 // The URL of this New Tab Page - varies based on NTP version. 123 // The URL of this New Tab Page - varies based on NTP version.
112 GURL ntp_url_; 124 GURL ntp_url_;
113 125
114 DISALLOW_COPY_AND_ASSIGN(NTPUserDataLogger); 126 DISALLOW_COPY_AND_ASSIGN(NTPUserDataLogger);
115 }; 127 };
116 128
117 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NTP_USER_DATA_LOGGER_H_ 129 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NTP_USER_DATA_LOGGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698