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

Side by Side Diff: components/ntp_snippets/category.h

Issue 2337103003: [NTP Snippets] Metrics: switch over known categories (Closed)
Patch Set: base::underlying_type :-/ 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 unified diff | Download patch
« no previous file with comments | « no previous file | components/ntp_snippets/category.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_NTP_SNIPPETS_CATEGORY_H_ 5 #ifndef COMPONENTS_NTP_SNIPPETS_CATEGORY_H_
6 #define COMPONENTS_NTP_SNIPPETS_CATEGORY_H_ 6 #define COMPONENTS_NTP_SNIPPETS_CATEGORY_H_
7 7
8 #include <ostream> 8 #include <ostream>
9 9
10 namespace ntp_snippets { 10 namespace ntp_snippets {
(...skipping 16 matching lines...) Expand all
27 27
28 // Recently used bookmarks. 28 // Recently used bookmarks.
29 BOOKMARKS, 29 BOOKMARKS,
30 30
31 // Physical Web page available in the vicinity. 31 // Physical Web page available in the vicinity.
32 PHYSICAL_WEB_PAGES, 32 PHYSICAL_WEB_PAGES,
33 33
34 // Follows the last local category. 34 // Follows the last local category.
35 LOCAL_CATEGORIES_COUNT, 35 LOCAL_CATEGORIES_COUNT,
36 36
37 // Remote categories come after this.
37 REMOTE_CATEGORIES_OFFSET = 10000, 38 REMOTE_CATEGORIES_OFFSET = 10000,
38 39
39 // Articles for you. 40 // Articles for you.
40 ARTICLES, 41 ARTICLES,
41 }; 42 };
42 43
43 // A category groups ContentSuggestions which belong together. Use the 44 // A category groups ContentSuggestions which belong together. Use the
44 // CategoryFactory to obtain instances. 45 // CategoryFactory to obtain instances.
45 class Category { 46 class Category {
46 public: 47 public:
47 // An arbitrary but consistent ordering. Can be used to look up categories in 48 // An arbitrary but consistent ordering. Can be used to look up categories in
48 // a std::map, but should not be used to order categories for other purposes. 49 // a std::map, but should not be used to order categories for other purposes.
49 struct CompareByID; 50 struct CompareByID;
50 51
51 // Returns a non-negative identifier that is unique for the category and can 52 // Returns a non-negative identifier that is unique for the category and can
52 // be converted back to a Category instance using 53 // be converted back to a Category instance using
53 // |CategoryFactory::FromIDValue(id)|. 54 // |CategoryFactory::FromIDValue(id)|.
54 // Note that these IDs are not necessarily stable across multiple runs of 55 // Note that these IDs are not necessarily stable across multiple runs of
55 // the application, so they should not be persisted. 56 // the application, so they should not be persisted.
56 int id() const { return id_; } 57 int id() const { return id_; }
57 58
59 // Returns whether this category matches the given |known_category|.
58 bool IsKnownCategory(KnownCategories known_category) const; 60 bool IsKnownCategory(KnownCategories known_category) const;
59 61
60 private: 62 private:
61 friend class CategoryFactory; 63 friend class CategoryFactory;
62 64
63 explicit Category(int id); 65 explicit Category(int id);
64 66
65 int id_; 67 int id_;
66 68
67 // Allow copy and assignment. 69 // Allow copy and assignment.
68 }; 70 };
69 71
70 bool operator==(const Category& left, const Category& right); 72 bool operator==(const Category& left, const Category& right);
71 73
72 bool operator!=(const Category& left, const Category& right); 74 bool operator!=(const Category& left, const Category& right);
73 75
74 struct Category::CompareByID { 76 struct Category::CompareByID {
75 bool operator()(const Category& left, const Category& right) const; 77 bool operator()(const Category& left, const Category& right) const;
76 }; 78 };
77 79
78 std::ostream& operator<<(std::ostream& os, const Category& obj); 80 std::ostream& operator<<(std::ostream& os, const Category& obj);
79 81
80 } // namespace ntp_snippets 82 } // namespace ntp_snippets
81 83
82 #endif // COMPONENTS_NTP_SNIPPETS_CATEGORY_H_ 84 #endif // COMPONENTS_NTP_SNIPPETS_CATEGORY_H_
OLDNEW
« no previous file with comments | « no previous file | components/ntp_snippets/category.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698