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

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

Issue 2406573002: 📰 Persist category dismissals (Closed)
Patch Set: fix test Created 4 years, 2 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
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" 7 #include "base/logging.h"
8 8
9 namespace ntp_snippets { 9 namespace ntp_snippets {
10 10
11 Category::Category(int id) : id_(id) {} 11 Category::Category(int id) : id_(id) {}
12 12
13 bool Category::IsKnownCategory(KnownCategories known_category) const { 13 bool Category::IsKnownCategory(KnownCategories known_category) const {
14 DCHECK_NE(known_category, KnownCategories::LOCAL_CATEGORIES_COUNT); 14 DCHECK_NE(known_category, KnownCategories::LOCAL_CATEGORIES_COUNT);
15 DCHECK_NE(known_category, KnownCategories::REMOTE_CATEGORIES_OFFSET); 15 DCHECK_NE(known_category, KnownCategories::REMOTE_CATEGORIES_OFFSET);
16 return id_ == static_cast<int>(known_category); 16 return id_ == static_cast<int>(known_category);
17 } 17 }
18 18
19 bool Category::IsRemote() const {
20 return id_ > static_cast<int>(KnownCategories::REMOTE_CATEGORIES_OFFSET);
21 }
22
19 bool operator==(const Category& left, const Category& right) { 23 bool operator==(const Category& left, const Category& right) {
20 return left.id() == right.id(); 24 return left.id() == right.id();
21 } 25 }
22 26
23 bool operator!=(const Category& left, const Category& right) { 27 bool operator!=(const Category& left, const Category& right) {
24 return !(left == right); 28 return !(left == right);
25 } 29 }
26 30
27 bool Category::CompareByID::operator()(const Category& left, 31 bool Category::CompareByID::operator()(const Category& left,
28 const Category& right) const { 32 const Category& right) const {
29 return left.id() < right.id(); 33 return left.id() < right.id();
30 } 34 }
31 35
32 std::ostream& operator<<(std::ostream& os, const Category& obj) { 36 std::ostream& operator<<(std::ostream& os, const Category& obj) {
33 os << obj.id(); 37 os << obj.id();
34 return os; 38 return os;
35 } 39 }
36 40
37 } // namespace ntp_snippets 41 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698