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

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

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 | « components/ntp_snippets/category.h ('k') | components/ntp_snippets/category_factory.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 #include "components/ntp_snippets/category.h" 5 #include "components/ntp_snippets/category.h"
6 6
7 #include "base/logging.h"
8
7 namespace ntp_snippets { 9 namespace ntp_snippets {
8 10
9 Category::Category(int id) : id_(id) {} 11 Category::Category(int id) : id_(id) {}
10 12
11 bool Category::IsKnownCategory(KnownCategories known_category) const { 13 bool Category::IsKnownCategory(KnownCategories known_category) const {
14 DCHECK_NE(known_category, KnownCategories::LOCAL_CATEGORIES_COUNT);
15 DCHECK_NE(known_category, KnownCategories::REMOTE_CATEGORIES_OFFSET);
12 return id_ == static_cast<int>(known_category); 16 return id_ == static_cast<int>(known_category);
13 } 17 }
14 18
15 bool operator==(const Category& left, const Category& right) { 19 bool operator==(const Category& left, const Category& right) {
16 return left.id() == right.id(); 20 return left.id() == right.id();
17 } 21 }
18 22
19 bool operator!=(const Category& left, const Category& right) { 23 bool operator!=(const Category& left, const Category& right) {
20 return !(left == right); 24 return !(left == right);
21 } 25 }
22 26
23 bool Category::CompareByID::operator()(const Category& left, 27 bool Category::CompareByID::operator()(const Category& left,
24 const Category& right) const { 28 const Category& right) const {
25 return left.id() < right.id(); 29 return left.id() < right.id();
26 } 30 }
27 31
28 std::ostream& operator<<(std::ostream& os, const Category& obj) { 32 std::ostream& operator<<(std::ostream& os, const Category& obj) {
29 os << obj.id(); 33 os << obj.id();
30 return os; 34 return os;
31 } 35 }
32 36
33 } // namespace ntp_snippets 37 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « components/ntp_snippets/category.h ('k') | components/ntp_snippets/category_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698