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

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

Issue 2205233002: Combine all suggestions factories into ContentSuggestionsServiceFactory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Bernhard's comments Created 4 years, 4 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_suggestions_provider.h" 5 #include "components/ntp_snippets/content_suggestions_provider.h"
6 6
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "components/ntp_snippets/category_factory.h" 9 #include "components/ntp_snippets/category_factory.h"
10 10
11 namespace ntp_snippets { 11 namespace ntp_snippets {
12 12
13 namespace { 13 namespace {
14 14
15 const char kCombinedIDFormat[] = "%d|%s"; 15 const char kCombinedIDFormat[] = "%d|%s";
16 const char kSeparator = '|'; 16 const char kSeparator = '|';
17 17
18 } // namespace 18 } // namespace
19 19
20 ContentSuggestionsProvider::ContentSuggestionsProvider( 20 ContentSuggestionsProvider::ContentSuggestionsProvider(
21 Observer* observer,
21 CategoryFactory* category_factory) 22 CategoryFactory* category_factory)
22 : category_factory_(category_factory) {} 23 : observer_(observer), category_factory_(category_factory) {}
23 24
24 ContentSuggestionsProvider::~ContentSuggestionsProvider() {} 25 ContentSuggestionsProvider::~ContentSuggestionsProvider() {}
25 26
26 std::string ContentSuggestionsProvider::MakeUniqueID( 27 std::string ContentSuggestionsProvider::MakeUniqueID(
27 Category category, 28 Category category,
28 const std::string& within_category_id) { 29 const std::string& within_category_id) {
29 return base::StringPrintf(kCombinedIDFormat, category.id(), 30 return base::StringPrintf(kCombinedIDFormat, category.id(),
30 within_category_id.c_str()); 31 within_category_id.c_str());
31 } 32 }
32 33
(...skipping 10 matching lines...) Expand all
43 44
44 std::string ContentSuggestionsProvider::GetWithinCategoryIDFromUniqueID( 45 std::string ContentSuggestionsProvider::GetWithinCategoryIDFromUniqueID(
45 const std::string& unique_id) { 46 const std::string& unique_id) {
46 size_t colon_index = unique_id.find(kSeparator); 47 size_t colon_index = unique_id.find(kSeparator);
47 DCHECK_NE(std::string::npos, colon_index) << "Not a valid unique_id: " 48 DCHECK_NE(std::string::npos, colon_index) << "Not a valid unique_id: "
48 << unique_id; 49 << unique_id;
49 return unique_id.substr(colon_index + 1); 50 return unique_id.substr(colon_index + 1);
50 } 51 }
51 52
52 } // namespace ntp_snippets 53 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « components/ntp_snippets/content_suggestions_provider.h ('k') | components/ntp_snippets/content_suggestions_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698