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

Unified Diff: components/ntp_snippets/category.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/category.cc
diff --git a/components/ntp_snippets/category.cc b/components/ntp_snippets/category.cc
index c9dff3125dfc9c1ecdd92ce433f1c055f43efbe5..90bcf58d5608c3a8a996b555dd199bf26e565713 100644
--- a/components/ntp_snippets/category.cc
+++ b/components/ntp_snippets/category.cc
@@ -12,6 +12,20 @@ bool Category::IsKnownCategory(KnownCategories known_category) const {
return id_ == static_cast<int>(known_category);
}
+bool Category::IsAnyKnownCategory() const {
+ static const int kKnownCategoryIds[] = {
+ static_cast<int>(KnownCategories::RECENT_TABS),
+ static_cast<int>(KnownCategories::DOWNLOADS),
+ static_cast<int>(KnownCategories::BOOKMARKS),
+ static_cast<int>(KnownCategories::PHYSICAL_WEB_PAGES),
+ static_cast<int>(KnownCategories::ARTICLES)};
jkrcal 2016/09/13 16:08:05 I am just wondering: Cannot you add to the enum c
Marc Treib 2016/09/13 16:28:50 SERVER_CATEGORIES_MAX would actually have to be KN
jkrcal 2016/09/13 17:22:27 How come? Is it because we can introduce some cate
tschumann 2016/09/14 08:41:35 Joining this discussion as a by-stander. Given tha
Marc Treib 2016/09/14 08:42:20 Say the server adds categories 2 and 3. Later, we
+ for (int known_category_id : kKnownCategoryIds) {
+ if (id_ == known_category_id)
+ return true;
+ }
+ return false;
+}
+
bool operator==(const Category& left, const Category& right) {
return left.id() == right.id();
}

Powered by Google App Engine
This is Rietveld 408576698