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

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

Issue 2774663002: [Remote suggestions] Refactor the scheduler (Closed)
Patch Set: Marc's nits #2 Created 3 years, 8 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_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 10 matching lines...) Expand all
21 #include "components/prefs/pref_service.h" 21 #include "components/prefs/pref_service.h"
22 #include "ui/gfx/image/image.h" 22 #include "ui/gfx/image/image.h"
23 23
24 namespace ntp_snippets { 24 namespace ntp_snippets {
25 25
26 ContentSuggestionsService::ContentSuggestionsService( 26 ContentSuggestionsService::ContentSuggestionsService(
27 State state, 27 State state,
28 SigninManagerBase* signin_manager, 28 SigninManagerBase* signin_manager,
29 history::HistoryService* history_service, 29 history::HistoryService* history_service,
30 PrefService* pref_service, 30 PrefService* pref_service,
31 std::unique_ptr<CategoryRanker> category_ranker) 31 std::unique_ptr<CategoryRanker> category_ranker,
32 std::unique_ptr<UserClassifier> user_classifier,
33 std::unique_ptr<RemoteSuggestionsScheduler> remote_suggestions_scheduler)
32 : state_(state), 34 : state_(state),
33 signin_observer_(this), 35 signin_observer_(this),
34 history_service_observer_(this), 36 history_service_observer_(this),
35 remote_suggestions_provider_(nullptr), 37 remote_suggestions_provider_(nullptr),
36 remote_suggestions_scheduler_(nullptr),
37 pref_service_(pref_service), 38 pref_service_(pref_service),
38 user_classifier_(pref_service, base::MakeUnique<base::DefaultClock>()), 39 remote_suggestions_scheduler_(std::move(remote_suggestions_scheduler)),
40 user_classifier_(std::move(user_classifier)),
39 category_ranker_(std::move(category_ranker)) { 41 category_ranker_(std::move(category_ranker)) {
40 // Can be null in tests. 42 // Can be null in tests.
41 if (signin_manager) { 43 if (signin_manager) {
42 signin_observer_.Add(signin_manager); 44 signin_observer_.Add(signin_manager);
43 } 45 }
44 46
45 if (history_service) { 47 if (history_service) {
46 history_service_observer_.Add(history_service); 48 history_service_observer_.Add(history_service);
47 } 49 }
48 50
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 void ContentSuggestionsService::StoreDismissedCategoriesToPrefs() { 512 void ContentSuggestionsService::StoreDismissedCategoriesToPrefs() {
511 base::ListValue list; 513 base::ListValue list;
512 for (const auto& category_provider_pair : dismissed_providers_by_category_) { 514 for (const auto& category_provider_pair : dismissed_providers_by_category_) {
513 list.AppendInteger(category_provider_pair.first.id()); 515 list.AppendInteger(category_provider_pair.first.id());
514 } 516 }
515 517
516 pref_service_->Set(prefs::kDismissedCategories, list); 518 pref_service_->Set(prefs::kDismissedCategories, list);
517 } 519 }
518 520
519 } // namespace ntp_snippets 521 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « components/ntp_snippets/content_suggestions_service.h ('k') | components/ntp_snippets/content_suggestions_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698