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

Unified Diff: components/ntp_snippets/content_suggestions_metrics.cc

Issue 2337103003: [NTP Snippets] Metrics: switch over known categories (Closed)
Patch Set: no static set Created 4 years, 3 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: components/ntp_snippets/content_suggestions_metrics.cc
diff --git a/components/ntp_snippets/content_suggestions_metrics.cc b/components/ntp_snippets/content_suggestions_metrics.cc
index 5d4fbe169ad5a462da482bcc432b02bbbaa3b785..031a54ee0285a8901adfe35c796751b430f5653a 100644
--- a/components/ntp_snippets/content_suggestions_metrics.cc
+++ b/components/ntp_snippets/content_suggestions_metrics.cc
@@ -44,17 +44,27 @@ const char kHistogramMoreButtonClicked[] =
const char kPerCategoryHistogramFormat[] = "%s.%s";
std::string GetCategorySuffix(Category category) {
- // TODO(treib): Find a way to produce a compile error if a known category
- // isn't listed here.
- if (category.IsKnownCategory(KnownCategories::RECENT_TABS))
- return "RecentTabs";
- if (category.IsKnownCategory(KnownCategories::DOWNLOADS))
- return "Downloads";
- if (category.IsKnownCategory(KnownCategories::BOOKMARKS))
- return "Bookmarks";
- if (category.IsKnownCategory(KnownCategories::ARTICLES))
- return "Articles";
- // All other categories go into a single "Experimental" bucket.
+ if (category.IsAnyKnownCategory()) {
+ KnownCategories known_category =
+ static_cast<KnownCategories>(category.id());
+ switch (known_category) {
jkrcal 2016/09/13 16:08:05 Way better, thanks!
+ case KnownCategories::RECENT_TABS:
+ return "RecentTabs";
+ case KnownCategories::DOWNLOADS:
+ return "Downloads";
+ case KnownCategories::BOOKMARKS:
+ return "Bookmarks";
+ case KnownCategories::PHYSICAL_WEB_PAGES:
+ return "PhysicalWeb";
+ case KnownCategories::ARTICLES:
+ return "Articles";
+ case KnownCategories::LOCAL_CATEGORIES_COUNT:
+ case KnownCategories::REMOTE_CATEGORIES_OFFSET:
+ NOTREACHED();
+ break;
+ }
+ }
+ // All other (unknown) categories go into a single "Experimental" bucket.
return "Experimental";
}

Powered by Google App Engine
This is Rietveld 408576698