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..44524cb8bf923471f76aa6813caa2368c67686e5 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_ && |
+ id_within_category_ == rhs.id_within_category_; |
+} |
+ |
+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& id_within_category, |
+ const GURL& url) |
+ : id_(category, id_within_category), 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.id_within_category(); |
+ return os; |
+} |
+ |
} // namespace ntp_snippets |