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

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

Issue 2446163005: [NTP Snippets] FetchMore backend (Closed)
Patch Set: Address comments from https://codereview.chromium.org/2421463002/ Created 4 years, 1 month 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_service.h" 5 #include "components/ntp_snippets/content_suggestions_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 void ContentSuggestionsService::RemoveObserver(Observer* observer) { 189 void ContentSuggestionsService::RemoveObserver(Observer* observer) {
190 observers_.RemoveObserver(observer); 190 observers_.RemoveObserver(observer);
191 } 191 }
192 192
193 void ContentSuggestionsService::RegisterProvider( 193 void ContentSuggestionsService::RegisterProvider(
194 std::unique_ptr<ContentSuggestionsProvider> provider) { 194 std::unique_ptr<ContentSuggestionsProvider> provider) {
195 DCHECK(state_ == State::ENABLED); 195 DCHECK(state_ == State::ENABLED);
196 providers_.push_back(std::move(provider)); 196 providers_.push_back(std::move(provider));
197 } 197 }
198 198
199 void ContentSuggestionsService::FetchMore(const Category& category,
200 const FetchedMoreCallback& callback) {
201 auto providers_it = providers_by_category_.find(category);
202 if (providers_it == providers_by_category_.end())
203 return;
204
205 providers_it->second->FetchMore(category, callback);
206 }
207
199 //////////////////////////////////////////////////////////////////////////////// 208 ////////////////////////////////////////////////////////////////////////////////
200 // Private methods 209 // Private methods
201 210
202 void ContentSuggestionsService::OnNewSuggestions( 211 void ContentSuggestionsService::OnNewSuggestions(
203 ContentSuggestionsProvider* provider, 212 ContentSuggestionsProvider* provider,
204 Category category, 213 Category category,
205 std::vector<ContentSuggestion> suggestions) { 214 std::vector<ContentSuggestion> suggestions) {
206 // Providers shouldn't call this when they're in a non-available state. 215 // Providers shouldn't call this when they're in a non-available state.
207 DCHECK( 216 DCHECK(
208 IsCategoryStatusInitOrAvailable(provider->GetCategoryStatus(category))); 217 IsCategoryStatusInitOrAvailable(provider->GetCategoryStatus(category)));
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 void ContentSuggestionsService::StoreDismissedCategoriesToPrefs() { 438 void ContentSuggestionsService::StoreDismissedCategoriesToPrefs() {
430 base::ListValue list; 439 base::ListValue list;
431 for (const auto& category_provider_pair : dismissed_providers_by_category_) { 440 for (const auto& category_provider_pair : dismissed_providers_by_category_) {
432 list.AppendInteger(category_provider_pair.first.id()); 441 list.AppendInteger(category_provider_pair.first.id());
433 } 442 }
434 443
435 pref_service_->Set(prefs::kDismissedCategories, list); 444 pref_service_->Set(prefs::kDismissedCategories, list);
436 } 445 }
437 446
438 } // namespace ntp_snippets 447 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698