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/content_suggestion.h" | 5 #include "components/ntp_snippets/content_suggestion.h" |
6 | 6 |
7 namespace ntp_snippets { | 7 namespace ntp_snippets { |
8 | 8 |
9 ContentSuggestion::ContentSuggestion(const std::string& id, const GURL& url) | 9 bool ContentSuggestion::ID::operator==(const ID& rhs) const { |
| 10 return category_ == rhs.category_ && |
| 11 id_within_category_ == rhs.id_within_category_; |
| 12 } |
| 13 |
| 14 bool ContentSuggestion::ID::operator!=(const ID& rhs) const { |
| 15 return !(*this == rhs); |
| 16 } |
| 17 |
| 18 ContentSuggestion::ContentSuggestion(ID id, const GURL& url) |
10 : id_(id), url_(url), score_(0) {} | 19 : id_(id), url_(url), score_(0) {} |
11 | 20 |
| 21 ContentSuggestion::ContentSuggestion(Category category, |
| 22 const std::string& id_within_category, |
| 23 const GURL& url) |
| 24 : id_(category, id_within_category), url_(url), score_(0) {} |
| 25 |
12 ContentSuggestion::ContentSuggestion(ContentSuggestion&&) = default; | 26 ContentSuggestion::ContentSuggestion(ContentSuggestion&&) = default; |
13 | 27 |
14 ContentSuggestion& ContentSuggestion::operator=(ContentSuggestion&&) = default; | 28 ContentSuggestion& ContentSuggestion::operator=(ContentSuggestion&&) = default; |
15 | 29 |
16 ContentSuggestion::~ContentSuggestion() = default; | 30 ContentSuggestion::~ContentSuggestion() = default; |
17 | 31 |
| 32 std::ostream& operator<<(std::ostream& os, ContentSuggestion::ID id) { |
| 33 os << id.category() << "|" << id.id_within_category(); |
| 34 return os; |
| 35 } |
| 36 |
18 } // namespace ntp_snippets | 37 } // namespace ntp_snippets |
OLD | NEW |