Index: chrome/browser/android/most_visited_sites.cc |
diff --git a/chrome/browser/android/most_visited_sites.cc b/chrome/browser/android/most_visited_sites.cc |
index ae6f1a9b8037d517749edbc9b26b4e9c76b3b577..8ceaf3b6e4e9355d922fbb7563f94153c8225b42 100644 |
--- a/chrome/browser/android/most_visited_sites.cc |
+++ b/chrome/browser/android/most_visited_sites.cc |
@@ -58,16 +58,14 @@ namespace { |
// Total number of tiles displayed. |
const char kNumTilesHistogramName[] = "NewTabPage.NumberOfTiles"; |
-// Tracking thumbnails. |
-const char kNumLocalThumbnailTilesHistogramName[] = |
- "NewTabPage.NumberOfThumbnailTiles"; |
-const char kNumEmptyTilesHistogramName[] = "NewTabPage.NumberOfGrayTiles"; |
-const char kNumServerTilesHistogramName[] = "NewTabPage.NumberOfExternalTiles"; |
- |
-// Format for tile clicks histogram. |
-const char kOpenedItemHistogramFormat[] = "NewTabPage.MostVisited.%s"; |
-// Format for tile impressions histogram. |
-const char kImpressionHistogramFormat[] = "NewTabPage.SuggestionsImpression.%s"; |
+ |
+// Format for tile clicks histograms. |
+const char kOpenedItemPositionHistogramFormat[] = "NewTabPage.MostVisited.%s"; |
+const char kOpenedItemTypeHistogramFormat[] = "NewTabPage.TileTypeClicked.%s"; |
+// Format for tile impressions histograms. |
+const char kImpressionPositionHistogramFormat[] = |
+ "NewTabPage.SuggestionsImpression.%s"; |
+const char kImpressionTypeHistogramFormat[] = "NewTabPage.TileType.%s"; |
// Identifiers for the various tile sources. |
const char kHistogramClientName[] = "client"; |
const char kHistogramServerName[] = "server"; |
@@ -76,6 +74,31 @@ const char kHistogramPopularName[] = "popular"; |
const char kPopularSitesFieldTrialName[] = "NTPPopularSites"; |
+// The visual type of a most visited tile. |
+// |
+// These values must stay in sync with the MostVisitedTileType enum |
+// in histograms.xml. |
+// |
+// A Java counterpart will be generated for this enum. |
+// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.ntp |
+enum MostVisitedTileType { |
+ // The icon or thumbnail hasn't loaded yet. |
+ NONE, |
+ // The item displays a site's actual favicon or touch icon. |
+ ICON_REAL, |
+ // The item displays a color derived from the site's favicon or touch icon. |
+ ICON_COLOR, |
+ // The item displays a default gray box in place of an icon. |
+ ICON_DEFAULT, |
+ // The item displays a locally-captured thumbnail of the site content. |
+ THUMBNAIL_LOCAL, |
+ // The item displays a server-provided thumbnail of the site content. |
+ THUMBNAIL_SERVER, |
+ // The item displays a default graphic in place of a thumbnail. |
+ THUMBNAIL_DEFAULT, |
+ NUM_TILE_TYPES, |
+}; |
+ |
scoped_ptr<SkBitmap> MaybeFetchLocalThumbnail( |
const GURL& url, |
const scoped_refptr<TopSites>& top_sites) { |
@@ -206,7 +229,6 @@ std::string MostVisitedSites::Suggestion::GetSourceHistogramName() const { |
MostVisitedSites::MostVisitedSites(Profile* profile) |
: profile_(profile), num_sites_(0), received_most_visited_sites_(false), |
received_popular_sites_(false), recorded_uma_(false), |
- num_local_thumbs_(0), num_server_thumbs_(0), num_empty_thumbs_(0), |
scoped_observer_(this), weak_ptr_factory_(this) { |
// Register the debugging page for the Suggestions Service and the thumbnails |
// debugging page. |
@@ -234,10 +256,6 @@ void MostVisitedSites::Destroy(JNIEnv* env, jobject obj) { |
delete this; |
} |
-void MostVisitedSites::OnLoadingComplete(JNIEnv* env, jobject obj) { |
- RecordThumbnailUMAMetrics(); |
-} |
- |
void MostVisitedSites::SetMostVisitedURLsObserver(JNIEnv* env, |
jobject obj, |
jobject j_observer, |
@@ -343,18 +361,10 @@ void MostVisitedSites::OnObtainedThumbnail( |
DCHECK_CURRENTLY_ON(BrowserThread::UI); |
JNIEnv* env = AttachCurrentThread(); |
ScopedJavaLocalRef<jobject> j_bitmap; |
- if (bitmap) { |
+ if (bitmap) |
j_bitmap = gfx::ConvertToJavaBitmap(bitmap); |
- if (is_local_thumbnail) { |
- ++num_local_thumbs_; |
- } else { |
- ++num_server_thumbs_; |
- } |
- } else { |
- ++num_empty_thumbs_; |
- } |
Java_ThumbnailCallback_onMostVisitedURLsThumbnailAvailable( |
- env, j_callback->obj(), j_bitmap.obj()); |
+ env, j_callback->obj(), j_bitmap.obj(), is_local_thumbnail); |
} |
void MostVisitedSites::BlacklistUrl(JNIEnv* env, |
@@ -379,15 +389,56 @@ void MostVisitedSites::BlacklistUrl(JNIEnv* env, |
} |
} |
+void MostVisitedSites::RecordTileTypeMetrics(JNIEnv* env, |
+ jobject obj, |
+ jintArray jtile_types, |
+ jboolean is_icon_mode) { |
+ std::vector<int> tile_types; |
+ base::android::JavaIntArrayToIntVector(env, jtile_types, &tile_types); |
+ DCHECK_EQ(current_suggestions_.size(), tile_types.size()); |
+ |
+ int counts_per_type[NUM_TILE_TYPES] = {0}; |
+ for (size_t i = 0; i < tile_types.size(); i++) { |
+ int tile_type = tile_types[i]; |
+ counts_per_type[tile_type]++; |
+ std::string histogram = base::StringPrintf( |
+ kImpressionTypeHistogramFormat, |
+ current_suggestions_[i]->GetSourceHistogramName().c_str()); |
+ LogHistogramEvent(histogram, tile_type, NUM_TILE_TYPES); |
+ } |
+ |
+ if (is_icon_mode) { |
+ UMA_HISTOGRAM_COUNTS_100("NewTabPage.IconsReal", |
+ counts_per_type[ICON_REAL]); |
+ UMA_HISTOGRAM_COUNTS_100("NewTabPage.IconsColor", |
+ counts_per_type[ICON_COLOR]); |
+ UMA_HISTOGRAM_COUNTS_100("NewTabPage.IconsGray", |
+ counts_per_type[ICON_DEFAULT]); |
+ } else { |
+ UMA_HISTOGRAM_COUNTS_100("NewTabPage.NumberOfThumbnailTiles", |
+ counts_per_type[THUMBNAIL_LOCAL]); |
+ UMA_HISTOGRAM_COUNTS_100("NewTabPage.NumberOfExternalTiles", |
+ counts_per_type[THUMBNAIL_SERVER]); |
+ UMA_HISTOGRAM_COUNTS_100("NewTabPage.NumberOfGrayTiles", |
+ counts_per_type[THUMBNAIL_DEFAULT]); |
+ } |
+} |
+ |
void MostVisitedSites::RecordOpenedMostVisitedItem(JNIEnv* env, |
jobject obj, |
- jint index) { |
+ jint index, |
+ jint tile_type) { |
DCHECK_GE(index, 0); |
DCHECK_LT(index, static_cast<int>(current_suggestions_.size())); |
std::string histogram = base::StringPrintf( |
- kOpenedItemHistogramFormat, |
+ kOpenedItemPositionHistogramFormat, |
current_suggestions_[index]->GetSourceHistogramName().c_str()); |
LogHistogramEvent(histogram, index, num_sites_); |
+ |
+ histogram = base::StringPrintf( |
+ kOpenedItemTypeHistogramFormat, |
+ current_suggestions_[index]->GetSourceHistogramName().c_str()); |
+ LogHistogramEvent(histogram, tile_type, NUM_TILE_TYPES); |
} |
void MostVisitedSites::OnStateChanged() { |
@@ -710,20 +761,10 @@ void MostVisitedSites::OnPopularSitesAvailable(bool success) { |
QueryMostVisitedURLs(); |
} |
-void MostVisitedSites::RecordThumbnailUMAMetrics() { |
- UMA_HISTOGRAM_SPARSE_SLOWLY(kNumLocalThumbnailTilesHistogramName, |
- num_local_thumbs_); |
- num_local_thumbs_ = 0; |
- UMA_HISTOGRAM_SPARSE_SLOWLY(kNumEmptyTilesHistogramName, num_empty_thumbs_); |
- num_empty_thumbs_ = 0; |
- UMA_HISTOGRAM_SPARSE_SLOWLY(kNumServerTilesHistogramName, num_server_thumbs_); |
- num_server_thumbs_ = 0; |
-} |
- |
void MostVisitedSites::RecordImpressionUMAMetrics() { |
for (size_t i = 0; i < current_suggestions_.size(); i++) { |
std::string histogram = base::StringPrintf( |
- kImpressionHistogramFormat, |
+ kImpressionPositionHistogramFormat, |
current_suggestions_[i]->GetSourceHistogramName().c_str()); |
LogHistogramEvent(histogram, static_cast<int>(i), num_sites_); |
} |
@@ -736,7 +777,7 @@ void MostVisitedSites::TopSitesChanged(history::TopSites* top_sites, |
ChangeReason change_reason) { |
if (mv_source_ == TOP_SITES) { |
// The displayed suggestions are invalidated. |
- QueryMostVisitedURLs(); |
+ InitiateTopSitesQuery(); |
newt (away)
2015/09/28 22:34:21
There's no need to requery the server suggestions
|
} |
} |