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

Unified Diff: components/ntp_snippets/content_suggestion.cc

Issue 2102023002: Add ContentSuggestionsService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor corrections Created 4 years, 6 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 0fa4f0cd9dde852a8d368ad0476df7c59c1faadf..0090688da13e2db33847e2a7ab72f532a65166d4 100644
--- a/components/ntp_snippets/content_suggestion.cc
+++ b/components/ntp_snippets/content_suggestion.cc
@@ -6,12 +6,30 @@
namespace ntp_snippets {
+namespace {
+
+// Helper function to combine ID and provider_type into a common ID to make it
+// unique.
+std::string CombineID(ContentSuggestionsProviderType provider_type,
+ std::string original_id) {
Marc Treib 2016/06/30 10:36:53 const std::string&
Philipp Keck 2016/06/30 17:14:07 Done.
+ return std::to_string(int(provider_type)) + ":" + original_id;
Marc Treib 2016/06/30 10:36:53 Hm, base::StringPrintf would be the common way to
Philipp Keck 2016/06/30 17:14:07 Done.
+}
+
+}
tschumann 2016/06/30 10:55:18 shouldn't the closing namespace be commented like
Philipp Keck 2016/06/30 17:14:07 Done.
+
ContentSuggestion::ContentSuggestion(
const std::string& id,
- const ContentSuggestionsProviderType provider,
+ const ContentSuggestionsProviderType provider_type,
const ContentSuggestionCategory category,
const GURL& url)
- : id_(id), provider_(provider), category_(category), url_(url), score_(0) {}
+ : id_(CombineID(provider_type, id)),
+ category_(category),
+ url_(url),
+ score_(0) {}
+
+ContentSuggestion::ContentSuggestion(ContentSuggestion&&) = default;
+
+ContentSuggestion& ContentSuggestion::operator=(ContentSuggestion&&) = default;
ContentSuggestion::~ContentSuggestion() {}

Powered by Google App Engine
This is Rietveld 408576698