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

Side by Side Diff: components/ntp_snippets/content_suggestion.cc

Issue 2377663002: [NTP Snippets] Introduce ContentSuggestion::ID (Closed)
Patch Set: rebase Created 4 years, 2 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 unified diff | Download patch
OLDNEW
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
OLDNEW
« 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