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

Unified Diff: components/ntp_snippets/category.h

Issue 2568033005: [NTP::SectionOrder] Replace CategoryFactory with a category ranker. (Closed)
Patch Set: download provider tests. 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..8f8237ffc4831b7c1f4e049d2801b870d078a0d5 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
@@ -55,6 +53,19 @@ enum class KnownCategories {
// CategoryFactory to obtain instances.
class Category {
public:
+ // 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);
+
// An arbitrary but consistent ordering. Can be used to look up categories in
// a std::map, but should not be used to order categories for other purposes.
struct CompareByID;
@@ -68,8 +79,6 @@ class Category {
bool IsKnownCategory(KnownCategories known_category) const;
private:
- friend class CategoryFactory;
-
explicit Category(int id);
int id_;

Powered by Google App Engine
This is Rietveld 408576698