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

Unified Diff: components/ntp_snippets/category.cc

Issue 2568033005: [NTP::SectionOrder] Replace CategoryFactory with a category ranker. (Closed)
Patch Set: rebase. Created 4 years 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
« no previous file with comments | « components/ntp_snippets/category.h ('k') | components/ntp_snippets/category_factory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ntp_snippets/category.cc
diff --git a/components/ntp_snippets/category.cc b/components/ntp_snippets/category.cc
index abc86ab9f2c71827710d8f2d477ec9206c170991..4409ac1b376b7491129f46ece2c591e1ae30edd5 100644
--- a/components/ntp_snippets/category.cc
+++ b/components/ntp_snippets/category.cc
@@ -8,6 +8,26 @@
namespace ntp_snippets {
+// static
+Category Category::FromKnownCategory(KnownCategories known_category) {
+ return FromIDValue(static_cast<int>(known_category));
+}
+
+// static
+Category Category::FromRemoteCategory(int remote_category) {
+ DCHECK_GT(remote_category, 0);
+ return Category(static_cast<int>(KnownCategories::REMOTE_CATEGORIES_OFFSET) +
+ remote_category);
+}
+
+// static
+Category Category::FromIDValue(int id) {
+ DCHECK_GE(id, 0);
+ DCHECK(id < static_cast<int>(KnownCategories::LOCAL_CATEGORIES_COUNT) ||
+ id > static_cast<int>(KnownCategories::REMOTE_CATEGORIES_OFFSET));
+ return Category(id);
+}
+
Category::Category(int id) : id_(id) {}
bool Category::IsKnownCategory(KnownCategories known_category) const {
« no previous file with comments | « components/ntp_snippets/category.h ('k') | components/ntp_snippets/category_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698