| Index: components/ntp_snippets/content_suggestions_service.h
|
| diff --git a/components/ntp_snippets/content_suggestions_service.h b/components/ntp_snippets/content_suggestions_service.h
|
| index b207e065b472820fe6117cb086385d66c4ad46d2..75adedba875e388a5aea9bd418ce995e57ced4b0 100644
|
| --- a/components/ntp_snippets/content_suggestions_service.h
|
| +++ b/components/ntp_snippets/content_suggestions_service.h
|
| @@ -24,6 +24,7 @@
|
| #include "components/ntp_snippets/category_rankers/category_ranker.h"
|
| #include "components/ntp_snippets/category_status.h"
|
| #include "components/ntp_snippets/content_suggestions_provider.h"
|
| +#include "components/ntp_snippets/remote/remote_suggestions_scheduler.h"
|
| #include "components/ntp_snippets/user_classifier.h"
|
| #include "components/signin/core/browser/signin_manager.h"
|
|
|
| @@ -33,7 +34,6 @@ class PrefRegistrySimple;
|
| namespace ntp_snippets {
|
|
|
| class RemoteSuggestionsProvider;
|
| -class RemoteSuggestionsScheduler;
|
|
|
| // Retrieves suggestions from a number of ContentSuggestionsProviders and serves
|
| // them grouped into categories. There can be at most one provider per category.
|
| @@ -86,11 +86,16 @@ class ContentSuggestionsService : public KeyedService,
|
| DISABLED,
|
| };
|
|
|
| - ContentSuggestionsService(State state,
|
| - SigninManagerBase* signin_manager,
|
| - history::HistoryService* history_service,
|
| - PrefService* pref_service,
|
| - std::unique_ptr<CategoryRanker> category_ranker);
|
| + ContentSuggestionsService(
|
| + State state,
|
| + SigninManagerBase* signin_manager, // Can be nullptr in unittests.
|
| + history::HistoryService* history_service, // Can be nullptr in unittests.
|
| + PrefService* pref_service,
|
| + std::unique_ptr<CategoryRanker> category_ranker,
|
| + std::unique_ptr<UserClassifier> user_classifier,
|
| + std::unique_ptr<RemoteSuggestionsScheduler>
|
| + remote_suggestions_scheduler // Can be nullptr in unittests.
|
| + );
|
| ~ContentSuggestionsService() override;
|
|
|
| // Inherited from KeyedService.
|
| @@ -221,18 +226,17 @@ class ContentSuggestionsService : public KeyedService,
|
| return remote_suggestions_provider_;
|
| }
|
|
|
| - // The reference to RemoteSuggestionsScheduler should only be set by the
|
| - // factory. The interface is suited for informing about external events that
|
| - // have influence on scheduling remote fetches.
|
| - void set_remote_suggestions_scheduler(
|
| - ntp_snippets::RemoteSuggestionsScheduler* remote_suggestions_scheduler) {
|
| - remote_suggestions_scheduler_ = remote_suggestions_scheduler;
|
| - }
|
| + // The interface is suited for informing about external events that have
|
| + // influence on scheduling remote fetches. Can be nullptr in tests.
|
| RemoteSuggestionsScheduler* remote_suggestions_scheduler() {
|
| - return remote_suggestions_scheduler_;
|
| + return remote_suggestions_scheduler_.get();
|
| }
|
|
|
| - UserClassifier* user_classifier() { return &user_classifier_; }
|
| + // Can be nullptr in tests.
|
| + // TODO(jkrcal): The getter is only used from the bridge and from
|
| + // snippets-internals. Can we get rid of it with the metrics refactoring?
|
| + UserClassifier* user_classifier() { return user_classifier_.get(); }
|
| +
|
| CategoryRanker* category_ranker() { return category_ranker_.get(); }
|
|
|
| private:
|
| @@ -340,13 +344,14 @@ class ContentSuggestionsService : public KeyedService,
|
| // in |providers_|, otherwise this is a nullptr.
|
| RemoteSuggestionsProvider* remote_suggestions_provider_;
|
|
|
| - // Interface for informing about external events that have influence on
|
| - // scheduling remote fetches. Not owned.
|
| - RemoteSuggestionsScheduler* remote_suggestions_scheduler_;
|
| -
|
| PrefService* pref_service_;
|
|
|
| - UserClassifier user_classifier_;
|
| + // Interface for informing about external events that have influence on
|
| + // scheduling remote fetches.
|
| + std::unique_ptr<RemoteSuggestionsScheduler> remote_suggestions_scheduler_;
|
| +
|
| + // Classifies the user on the basis of long-term user interactions.
|
| + std::unique_ptr<UserClassifier> user_classifier_;
|
|
|
| // Provides order for categories.
|
| std::unique_ptr<CategoryRanker> category_ranker_;
|
|
|