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

Unified Diff: components/ntp_snippets/content_suggestions_service.h

Issue 2774663002: [Remote suggestions] Refactor the scheduler (Closed)
Patch Set: Fix iOS compile Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
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..2de6129650a6357a93f446c9f88914a8c8bb105c 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,14 @@ 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(
Marc Treib 2017/03/27 11:31:00 Add a comment saying which of the passed-in ptrs m
jkrcal 2017/03/27 14:09:31 Done.
+ State state,
+ SigninManagerBase* signin_manager,
+ history::HistoryService* history_service,
+ PrefService* pref_service,
+ std::unique_ptr<CategoryRanker> category_ranker,
+ std::unique_ptr<UserClassifier> user_classifier,
+ std::unique_ptr<RemoteSuggestionsScheduler> remote_suggestions_scheduler);
~ContentSuggestionsService() override;
// Inherited from KeyedService.
@@ -221,18 +224,16 @@ 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.
Marc Treib 2017/03/27 11:31:00 Mention that it can be null?
jkrcal 2017/03/27 14:09:31 Done.
RemoteSuggestionsScheduler* remote_suggestions_scheduler() {
- return remote_suggestions_scheduler_;
+ return remote_suggestions_scheduler_.get();
}
- UserClassifier* user_classifier() { return &user_classifier_; }
+ // 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 +341,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_;

Powered by Google App Engine
This is Rietveld 408576698