Index: components/ntp_snippets/content_suggestion.cc |
diff --git a/components/ntp_snippets/content_suggestion.cc b/components/ntp_snippets/content_suggestion.cc |
index 0617f6e09a26e08cb62e1fa315b242b8584fb3c0..8086881f0082dab700ce43ccde78c9163f4d2e82 100644 |
--- a/components/ntp_snippets/content_suggestion.cc |
+++ b/components/ntp_snippets/content_suggestion.cc |
@@ -6,13 +6,32 @@ |
namespace ntp_snippets { |
-ContentSuggestion::ContentSuggestion(const std::string& id, const GURL& url) |
+bool ContentSuggestion::ID::operator==(const ID& rhs) const { |
+ return category_ == rhs.category_ && |
+ within_category_id_ == rhs.within_category_id_; |
+} |
+ |
+bool ContentSuggestion::ID::operator!=(const ID& rhs) const { |
+ return !(*this == rhs); |
+} |
+ |
+ContentSuggestion::ContentSuggestion(ID id, const GURL& url) |
: id_(id), url_(url), score_(0) {} |
+ContentSuggestion::ContentSuggestion(Category category, |
+ const std::string& within_category_id, |
+ const GURL& url) |
+ : id_(category, within_category_id), url_(url), score_(0) {} |
+ |
ContentSuggestion::ContentSuggestion(ContentSuggestion&&) = default; |
ContentSuggestion& ContentSuggestion::operator=(ContentSuggestion&&) = default; |
ContentSuggestion::~ContentSuggestion() = default; |
+std::ostream& operator<<(std::ostream& os, ContentSuggestion::ID id) { |
+ os << id.category() << "|" << id.within_category_id(); |
+ return os; |
+} |
+ |
} // namespace ntp_snippets |