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

Unified Diff: components/ntp_snippets/content_suggestion.cc

Issue 2377663002: [NTP Snippets] Introduce ContentSuggestion::ID (Closed)
Patch Set: rebase Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
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
« no previous file with comments | « components/ntp_snippets/content_suggestion.h ('k') | components/ntp_snippets/content_suggestions_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698