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

Unified Diff: components/ntp_snippets/remote/remote_suggestions_provider.h

Issue 2557363002: [NTP Snippets] Refactor background scheduling for remote suggestions (Closed)
Patch Set: Created 4 years 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/remote/remote_suggestions_provider.h
diff --git a/components/ntp_snippets/remote/remote_suggestions_provider.h b/components/ntp_snippets/remote/remote_suggestions_provider.h
index a8081b7ee9ffdadb3b853164edd1d175b786d2c6..4277caba8a8afc7c6811c17fc60f7548f2c24203 100644
--- a/components/ntp_snippets/remote/remote_suggestions_provider.h
+++ b/components/ntp_snippets/remote/remote_suggestions_provider.h
@@ -25,7 +25,7 @@
#include "components/ntp_snippets/content_suggestions_provider.h"
#include "components/ntp_snippets/remote/ntp_snippet.h"
#include "components/ntp_snippets/remote/ntp_snippets_fetcher.h"
-#include "components/ntp_snippets/remote/ntp_snippets_scheduler.h"
+#include "components/ntp_snippets/remote/remote_suggestions_scheduler.h"
#include "components/ntp_snippets/remote/remote_suggestions_status_service.h"
#include "components/ntp_snippets/remote/request_throttler.h"
@@ -44,6 +44,7 @@ class ImageFetcher;
namespace ntp_snippets {
class RemoteSuggestionsDatabase;
+class RemoteSuggestionsHardScheduler;
class UserClassifier;
// Retrieves fresh content data (articles) from the server, stores them and
@@ -59,7 +60,8 @@ class UserClassifier;
// image fetcher to the NTPSnippetService.
class RemoteSuggestionsProvider final
: public ContentSuggestionsProvider,
- public image_fetcher::ImageFetcherDelegate {
+ public image_fetcher::ImageFetcherDelegate,
+ public RemoteSuggestionsScheduler::Updater {
public:
// |application_language_code| should be a ISO 639-1 compliant string, e.g.
// 'en' or 'en-US'. Note that this code should only specify the language, not
@@ -71,7 +73,7 @@ class RemoteSuggestionsProvider final
PrefService* pref_service,
const std::string& application_language_code,
const UserClassifier* user_classifier,
- NTPSnippetsScheduler* scheduler,
+ RemoteSuggestionsHardScheduler* hard_scheduler,
std::unique_ptr<NTPSnippetsFetcher> snippets_fetcher,
std::unique_ptr<image_fetcher::ImageFetcher> image_fetcher,
std::unique_ptr<image_fetcher::ImageDecoder> image_decoder,
@@ -91,11 +93,10 @@ class RemoteSuggestionsProvider final
// calls may trigger DCHECKs.
bool initialized() const { return ready() || state_ == State::DISABLED; }
- // Fetchs content suggestions from the Content Suggestions server for all
- // remote categories in the background.
- void FetchSnippetsInTheBackground();
+ // ContentSuggestionsScheduler::Updater implementation
Marc Treib 2016/12/08 16:14:58 RemoteSuggestionsScheduler. Also, private?
jkrcal 2016/12/09 09:20:38 Done both. (thanks, was not aware that implementat
+ void UpdateRemoteSuggestionsBySchedule() override;
- // Fetchs content suggestions from the Content Suggestions server for all
+ // Fetches content suggestions from the Content Suggestions server for all
// remote categories. The request to the server is performed as an interactive
// request. Interactive requests are used for actions triggered by the user
// and request lower latency processing.
@@ -111,10 +112,9 @@ class RemoteSuggestionsProvider final
return snippets_fetcher_.get();
}
- // (Re)schedules the periodic fetching of snippets. If |force| is true, the
- // tasks will be re-scheduled even if they already exist and have the correct
- // periods.
- void RescheduleFetching(bool force);
+ RemoteSuggestionsScheduler* scheduler() {
+ return &scheduler_;
+ }
// ContentSuggestionsProvider implementation
CategoryStatus GetCategoryStatus(Category category) override;
@@ -379,8 +379,8 @@ class RemoteSuggestionsProvider final
// Classifier that tells us how active the user is. Not owned.
const UserClassifier* user_classifier_;
- // Scheduler for fetching snippets. Not owned.
- NTPSnippetsScheduler* scheduler_;
+ // Scheduler for fetching snippets.
+ RemoteSuggestionsScheduler scheduler_;
// The snippets fetcher.
std::unique_ptr<NTPSnippetsFetcher> snippets_fetcher_;

Powered by Google App Engine
This is Rietveld 408576698