Chromium Code Reviews| 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 1c76a5862a7b95d1aab0cfb49257e2b5d742cd94..0b7e43a95fddf18c1795556a0317215478405f73 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,7 @@ 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(); |
| - |
| - // 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 +109,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() { |
|
Marc Treib
2016/12/09 12:25:26
Comment on why this needs to be exposed?
jkrcal
2016/12/14 09:42:09
Done.
|
| + return &scheduler_; |
| + } |
| // ContentSuggestionsProvider implementation |
| CategoryStatus GetCategoryStatus(Category category) override; |
| @@ -259,6 +256,9 @@ class RemoteSuggestionsProvider final |
| void OnImageDataFetched(const std::string& id_within_category, |
| const std::string& image_data) override; |
| + // RemoteSuggestionsScheduler::Updater implementation |
| + void UpdateRemoteSuggestionsBySchedule() override; |
| + |
| // Callbacks for the RemoteSuggestionsDatabase. |
| void OnDatabaseLoaded(NTPSnippet::PtrVector snippets); |
| void OnDatabaseError(); |
| @@ -387,8 +387,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_; |