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

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

Issue 102433009: Most visited iframe now postMessage to signal the iframing page that the link has been displayed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adding server0 to histogram.xml. Created 6 years, 11 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 | Annotate | Revision Log
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 "chrome/common/ntp_logging_events.h" 8 #include "chrome/common/ntp_logging_events.h"
9 #include "content/public/browser/web_contents_observer.h" 9 #include "content/public/browser/web_contents_observer.h"
10 #include "content/public/browser/web_contents_user_data.h" 10 #include "content/public/browser/web_contents_user_data.h"
11 11
12 namespace content { 12 namespace content {
13 class WebContents; 13 class WebContents;
14 } 14 }
15 15
16 // Helper class for logging data from the NTP. Attached to each NTP instance. 16 // Helper class for logging data from the NTP. Attached to each NTP instance.
17 class NTPUserDataLogger 17 class NTPUserDataLogger
18 : public content::WebContentsObserver, 18 : public content::WebContentsObserver,
19 public content::WebContentsUserData<NTPUserDataLogger> { 19 public content::WebContentsUserData<NTPUserDataLogger> {
20 public: 20 public:
21 virtual ~NTPUserDataLogger(); 21 virtual ~NTPUserDataLogger();
22 22
23 static NTPUserDataLogger* GetOrCreateFromWebContents( 23 static NTPUserDataLogger* GetOrCreateFromWebContents(
24 content::WebContents* content); 24 content::WebContents* content);
25 25
26 // Logs the error percentage rate when loading thumbnail images for this NTP
27 // session to UMA histogram. Called when the user navigates to a URL. Only
28 // called for the instant NTP.
29 void EmitThumbnailErrorRate();
30
31 // Logs a number of statistics regarding the NTP. Called when an NTP tab is 26 // Logs a number of statistics regarding the NTP. Called when an NTP tab is
32 // about to be deactivated (be it by switching tabs, losing focus or closing 27 // about to be deactivated (be it by switching tabs, losing focus or closing
33 // the tab/shutting down Chrome), or when the user navigates to a URL. 28 // the tab/shutting down Chrome), or when the user navigates to a URL.
34 void EmitNtpStatistics(); 29 void EmitNtpStatistics();
35 30
36 // Called each time an event occurs on the NTP that requires a counter to be 31 // Called each time an event occurs on the NTP that requires a counter to be
37 // incremented. 32 // incremented.
38 void LogEvent(NTPLoggingEventType event); 33 void LogEvent(NTPLoggingEventType event);
39 34
40 // Logs an impression on one of the Most Visited tiles by a given provider. 35 // Logs an impression on one of the Most Visited tiles by a given provider.
41 void LogImpression(int position, const base::string16& provider); 36 void LogImpression(int position, const base::string16& provider);
42 37
43 // content::WebContentsObserver override 38 // content::WebContentsObserver override
44 virtual void NavigationEntryCommitted( 39 virtual void NavigationEntryCommitted(
45 const content::LoadCommittedDetails& load_details) OVERRIDE; 40 const content::LoadCommittedDetails& load_details) OVERRIDE;
46 41
47 protected: 42 protected:
48 explicit NTPUserDataLogger(content::WebContents* contents); 43 explicit NTPUserDataLogger(content::WebContents* contents);
49 44
50 // Returns the percent error given |events| occurrences and |errors| errors.
51 virtual size_t GetPercentError(size_t errors, size_t events) const;
52
53 private: 45 private:
54 friend class content::WebContentsUserData<NTPUserDataLogger>; 46 friend class content::WebContentsUserData<NTPUserDataLogger>;
55 47
56 // Total number of mouseovers for this NTP session. 48 // True if at least one iframe came from a server-side suggestion. In
57 size_t number_of_mouseovers_; 49 // practice, either all the iframes are server-side suggestions or none are.
50 bool server_side_suggestions_;
Alexei Svitkine (slow) 2014/01/16 19:50:30 Optional nit: I think has_server_side_suggestions_
beaudoin 2014/01/17 03:51:46 Done.
58 51
59 // Total number of attempts made to load thumbnail images for this NTP 52 // Total number of tiles rendered, no matter if it's a thumbnail, a gray tile
60 // session. 53 // or an external tile.
61 size_t number_of_thumbnail_attempts_; 54 size_t number_of_tiles_;
55
56 // Total number of tiles using a local thumbnail image for this NTP session.
57 size_t number_of_thumbnail_tiles_;
58
59 // Total number of tiles for which no thumbnail is specified and a gray tile
60 // with the domain is used as the main tile.
61 size_t number_of_gray_tiles_;
62
63 // Total number of tiles for which the visual appearance is handled externally
64 // by the page itself.
65 size_t number_of_external_tiles_;
62 66
63 // Total number of errors that occurred when trying to load thumbnail images 67 // Total number of errors that occurred when trying to load thumbnail images
64 // for this NTP session. When these errors occur a grey tile is shown instead 68 // for this NTP session. When these errors occur a grey tile is shown instead
65 // of a thumbnail image. 69 // of a thumbnail image.
66 size_t number_of_thumbnail_errors_; 70 size_t number_of_thumbnail_errors_;
67 71
68 // Total number of attempts made to load thumbnail images while providing a 72 // The number of times a gray tile with the domain was used as the fallback
69 // fallback thumbnail for this NTP session. 73 // for a failed thumbnail.
70 size_t number_of_fallback_thumbnails_requested_; 74 size_t number_of_gray_tile_fallbacks_;
71 75
72 // Total number of errors that occurred while trying to load the primary 76 // The number of times an external tile, for which the visual appearance is
73 // thumbnail image and that caused a fallback to the secondary thumbnail. 77 // handled by the page itself, was the fallback for a failed thumbnail.
74 size_t number_of_fallback_thumbnails_used_; 78 size_t number_of_external_tile_fallbacks_;
75 79
76 // Total number of tiles for which the visual appearance is handled externally 80 // Total number of mouseovers for this NTP session.
77 // by the page itself. 81 size_t number_of_mouseovers_;
78 size_t number_of_external_tiles_;
79
80 // True if at least one iframe came from a server-side suggestion. In
81 // practice, either all the iframes are server-side suggestions or none are.
82 bool server_side_suggestions_;
83 82
84 // The URL of this New Tab Page - varies based on NTP version. 83 // The URL of this New Tab Page - varies based on NTP version.
85 GURL ntp_url_; 84 GURL ntp_url_;
86 85
87 DISALLOW_COPY_AND_ASSIGN(NTPUserDataLogger); 86 DISALLOW_COPY_AND_ASSIGN(NTPUserDataLogger);
88 }; 87 };
89 88
90 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NTP_USER_DATA_LOGGER_H_ 89 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NTP_USER_DATA_LOGGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698