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

Unified Diff: chrome/browser/ui/webui/ntp/ntp_user_data_logger.cc

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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/ntp/ntp_user_data_logger.cc
diff --git a/chrome/browser/ui/webui/ntp/ntp_user_data_logger.cc b/chrome/browser/ui/webui/ntp/ntp_user_data_logger.cc
index 4fca77a3986d5207c47ae3ed9cf06110e70cc944..126390ca036c428bf9a20aee28d5e1e821dbfa28 100644
--- a/chrome/browser/ui/webui/ntp/ntp_user_data_logger.cc
+++ b/chrome/browser/ui/webui/ntp/ntp_user_data_logger.cc
@@ -15,6 +15,10 @@
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/web_contents.h"
+// Macro to log UMA statistics related to the 8 tiles shown on the NTP.
+#define UMA_HISTOGRAM_NTP_TILES(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \
Alexei Svitkine (slow) 2014/01/16 19:50:30 Nit: I'd wrap it like this: #define UMA_HISTOGRAM
beaudoin 2014/01/17 03:51:46 I wrapped it exactly like in histogram.h, but I ha
+ name, sample, 0, 8, 9)
+
namespace {
// Used to track if suggestions were issued by the client or the server.
@@ -54,58 +58,46 @@ NTPUserDataLogger* NTPUserDataLogger::GetOrCreateFromWebContents(
return logger;
}
-void NTPUserDataLogger::EmitThumbnailErrorRate() {
- DCHECK_LE(number_of_thumbnail_errors_, number_of_thumbnail_attempts_);
- if (number_of_thumbnail_attempts_ != 0) {
- UMA_HISTOGRAM_PERCENTAGE(
- "NewTabPage.ThumbnailErrorRate",
- GetPercentError(number_of_thumbnail_errors_,
- number_of_thumbnail_attempts_));
- }
- DCHECK_LE(number_of_fallback_thumbnails_used_,
- number_of_fallback_thumbnails_requested_);
- if (number_of_fallback_thumbnails_requested_ != 0) {
- UMA_HISTOGRAM_PERCENTAGE(
- "NewTabPage.ThumbnailFallbackRate",
- GetPercentError(number_of_fallback_thumbnails_used_,
- number_of_fallback_thumbnails_requested_));
- }
- number_of_thumbnail_attempts_ = 0;
- number_of_thumbnail_errors_ = 0;
- number_of_fallback_thumbnails_requested_ = 0;
- number_of_fallback_thumbnails_used_ = 0;
-}
-
void NTPUserDataLogger::EmitNtpStatistics() {
UMA_HISTOGRAM_COUNTS("NewTabPage.NumberOfMouseOvers", number_of_mouseovers_);
number_of_mouseovers_ = 0;
- UMA_HISTOGRAM_COUNTS("NewTabPage.NumberOfExternalTiles",
- number_of_external_tiles_);
- number_of_external_tiles_ = 0;
- UMA_HISTOGRAM_ENUMERATION(
- "NewTabPage.SuggestionsType",
- server_side_suggestions_ ? SERVER_SIDE : CLIENT_SIDE,
- SUGGESTIONS_TYPE_COUNT);
- server_side_suggestions_ = false;
+
+ // Only log the following statistics if at least one tile is recorded. This
+ // check is required because the statistics are emitted whenever the user
+ // changes tab away from the NTP. However, if the user comes back to that NTP
+ // later the statistics are not regenerated (i.e. they are all 0). If we log
+ // them again we get a strong bias.
+ if (number_of_tiles_ > 0) {
+ UMA_HISTOGRAM_ENUMERATION(
+ "NewTabPage.SuggestionsType",
+ server_side_suggestions_ ? SERVER_SIDE : CLIENT_SIDE,
+ SUGGESTIONS_TYPE_COUNT);
+ server_side_suggestions_ = false;
+ UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfTiles", number_of_tiles_);
+ number_of_tiles_ = 0;
+ UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfThumbnailTiles",
+ number_of_thumbnail_tiles_);
+ number_of_thumbnail_tiles_ = 0;
+ UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfGrayTiles",
+ number_of_gray_tiles_);
+ number_of_gray_tiles_ = 0;
+ UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfExternalTiles",
+ number_of_external_tiles_);
+ number_of_external_tiles_ = 0;
+ UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfThumbnailErrors",
+ number_of_thumbnail_errors_);
+ number_of_thumbnail_errors_ = 0;
+ UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfGrayTileFallbacks",
+ number_of_gray_tile_fallbacks_);
+ number_of_gray_tile_fallbacks_ = 0;
+ UMA_HISTOGRAM_NTP_TILES("NewTabPage.NumberOfExternalTileFallbacks",
+ number_of_external_tile_fallbacks_);
+ number_of_external_tile_fallbacks_ = 0;
+ }
}
void NTPUserDataLogger::LogEvent(NTPLoggingEventType event) {
switch (event) {
- case NTP_MOUSEOVER:
- number_of_mouseovers_++;
- break;
- case NTP_THUMBNAIL_ATTEMPT:
- number_of_thumbnail_attempts_++;
- break;
- case NTP_THUMBNAIL_ERROR:
- number_of_thumbnail_errors_++;
- break;
- case NTP_FALLBACK_THUMBNAIL_REQUESTED:
- number_of_fallback_thumbnails_requested_++;
- break;
- case NTP_FALLBACK_THUMBNAIL_USED:
- number_of_fallback_thumbnails_used_++;
- break;
case NTP_SERVER_SIDE_SUGGESTION:
server_side_suggestions_ = true;
break;
@@ -114,10 +106,31 @@ void NTPUserDataLogger::LogEvent(NTPLoggingEventType event) {
// otherwise there could be a race condition depending on the order in
// which the iframes call this method.
DCHECK(!server_side_suggestions_);
- break;
+ break;
+ case NTP_TILE:
+ number_of_tiles_++;
+ break;
+ case NTP_THUMBNAIL_TILE:
+ number_of_thumbnail_tiles_++;
+ break;
+ case NTP_GRAY_TILE:
+ number_of_gray_tiles_++;
+ break;
case NTP_EXTERNAL_TILE:
number_of_external_tiles_++;
break;
+ case NTP_THUMBNAIL_ERROR:
+ number_of_thumbnail_errors_++;
+ break;
+ case NTP_GRAY_TILE_FALLBACK:
+ number_of_gray_tile_fallbacks_++;
+ break;
+ case NTP_EXTERNAL_TILE_FALLBACK:
+ number_of_external_tile_fallbacks_++;
+ break;
+ case NTP_MOUSEOVER:
+ number_of_mouseovers_++;
+ break;
default:
NOTREACHED();
}
@@ -144,24 +157,18 @@ void NTPUserDataLogger::NavigationEntryCommitted(
if (search::MatchesOriginAndPath(ntp_url_, load_details.previous_url)) {
EmitNtpStatistics();
- // Only log thumbnail error rates for Instant NTP pages, as we do not have
- // this data for non-Instant NTPs.
- if (ntp_url_ != GURL(chrome::kChromeUINewTabURL))
- EmitThumbnailErrorRate();
}
}
NTPUserDataLogger::NTPUserDataLogger(content::WebContents* contents)
: content::WebContentsObserver(contents),
- number_of_mouseovers_(0),
- number_of_thumbnail_attempts_(0),
- number_of_thumbnail_errors_(0),
- number_of_fallback_thumbnails_requested_(0),
- number_of_fallback_thumbnails_used_(0),
+ server_side_suggestions_(false),
+ number_of_tiles_(0),
+ number_of_thumbnail_tiles_(0),
+ number_of_gray_tiles_(0),
number_of_external_tiles_(0),
- server_side_suggestions_(false) {
-}
-
-size_t NTPUserDataLogger::GetPercentError(size_t errors, size_t events) const {
- return (100 * errors) / events;
+ number_of_thumbnail_errors_(0),
+ number_of_gray_tile_fallbacks_(0),
+ number_of_external_tile_fallbacks_(0),
+ number_of_mouseovers_(0) {
}

Powered by Google App Engine
This is Rietveld 408576698