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

Unified Diff: components/ntp_snippets/category.h

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
Index: components/ntp_snippets/category.h
diff --git a/components/ntp_snippets/category.h b/components/ntp_snippets/category.h
index 0ae86c8b16f9e7d2fc5f00d62166dd9c883e34ec..c13c115314f90f3bb011767259ed9daaf598ad6b 100644
--- a/components/ntp_snippets/category.h
+++ b/components/ntp_snippets/category.h
@@ -9,8 +9,6 @@
namespace ntp_snippets {
-class CategoryFactory;
-
// These are the categories that the client knows about.
// The values before LOCAL_CATEGORIES_COUNT are the categories that are provided
// locally on the device. Categories provided by the server (IDs strictly larger
@@ -59,6 +57,19 @@ class Category {
// a std::map, but should not be used to order categories for other purposes.
struct CompareByID;
+ // Creates a category from a KnownCategory value. The passed |known_category|
+ // must not be one of the special values (LOCAL_CATEGORIES_COUNT or
+ // REMOTE_CATEGORIES_OFFSET).
+ static Category FromKnownCategory(KnownCategories known_category);
+
+ // Creates a category from a category identifier delivered by the server.
+ // |remote_category| must be positive.
+ static Category FromRemoteCategory(int remote_category);
+
+ // Creates a category from an ID as returned by |id()|. |id| must be a
+ // non-negative value.
+ static Category FromIDValue(int id);
+
// Returns a non-negative identifier that is unique for the category and can
// be converted back to a Category instance using
// |CategoryFactory::FromIDValue(id)|.
@@ -68,8 +79,6 @@ class Category {
bool IsKnownCategory(KnownCategories known_category) const;
private:
- friend class CategoryFactory;
-
explicit Category(int id);
int id_;
« no previous file with comments | « components/ntp_snippets/bookmarks/bookmark_suggestions_provider.cc ('k') | components/ntp_snippets/category.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698