| OLD | NEW |
| 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 |
| OLD | NEW |