| OLD | NEW |
| 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 #ifndef COMPONENTS_NTP_SNIPPETS_REMOTE_SCHEDULING_REMOTE_SUGGESTIONS_PROVIDER_H_ | 5 #ifndef COMPONENTS_NTP_SNIPPETS_REMOTE_SCHEDULING_REMOTE_SUGGESTIONS_PROVIDER_H_ |
| 6 #define COMPONENTS_NTP_SNIPPETS_REMOTE_SCHEDULING_REMOTE_SUGGESTIONS_PROVIDER_H_ | 6 #define COMPONENTS_NTP_SNIPPETS_REMOTE_SCHEDULING_REMOTE_SUGGESTIONS_PROVIDER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 // After the call, updates will be scheduled in the future. Idempotent, can be | 107 // After the call, updates will be scheduled in the future. Idempotent, can be |
| 108 // run any time later without impacting the current schedule. | 108 // run any time later without impacting the current schedule. |
| 109 // If you want to enforce rescheduling, call Unschedule() and then Schedule(). | 109 // If you want to enforce rescheduling, call Unschedule() and then Schedule(). |
| 110 void StartScheduling(); | 110 void StartScheduling(); |
| 111 | 111 |
| 112 // After the call, no updates will happen before another call to Schedule(). | 112 // After the call, no updates will happen before another call to Schedule(). |
| 113 // Idempotent, can be run any time later without impacting the current | 113 // Idempotent, can be run any time later without impacting the current |
| 114 // schedule. | 114 // schedule. |
| 115 void StopScheduling(); | 115 void StopScheduling(); |
| 116 | 116 |
| 117 // Checks whether it is time to perform a soft background fetch, according to |
| 118 // |schedule|. |
| 119 bool ShouldRefetchInTheBackgroundNow(); |
| 120 |
| 117 // Callback after Fetch is completed. | 121 // Callback after Fetch is completed. |
| 118 void FetchFinished(const FetchDoneCallback& callback, | 122 void FetchFinished(const FetchDoneCallback& callback, |
| 119 Status status_code, | 123 Status fetch_status, |
| 120 std::vector<ContentSuggestion> suggestions); | 124 std::vector<ContentSuggestion> suggestions); |
| 121 | 125 |
| 126 // Callback after RefetchInTheBackground is completed. |
| 127 void RefetchInTheBackgroundFinished( |
| 128 std::unique_ptr<FetchStatusCallback> callback, |
| 129 Status fetch_status); |
| 130 |
| 122 FetchingSchedule GetDesiredFetchingSchedule() const; | 131 FetchingSchedule GetDesiredFetchingSchedule() const; |
| 123 FetchingSchedule GetLastFetchingSchedule() const; | 132 FetchingSchedule GetLastFetchingSchedule() const; |
| 124 void StoreLastFetchingSchedule(const FetchingSchedule& schedule); | 133 void StoreLastFetchingSchedule(const FetchingSchedule& schedule); |
| 125 | 134 |
| 126 // Common function to call after each fetch. | |
| 127 void OnFetchCompleted(Status status); | |
| 128 | |
| 129 // Applies the provided |schedule|. | 135 // Applies the provided |schedule|. |
| 130 void ApplyFetchingSchedule(const FetchingSchedule& schedule); | 136 void ApplyFetchingSchedule(const FetchingSchedule& schedule, |
| 137 bool also_apply_persistent_schedule); |
| 131 | 138 |
| 132 // Interface for doing all the actual work (apart from scheduling). | 139 // Interface for doing all the actual work (apart from scheduling). |
| 133 std::unique_ptr<RemoteSuggestionsProvider> provider_; | 140 std::unique_ptr<RemoteSuggestionsProvider> provider_; |
| 134 | 141 |
| 135 // Interface for scheduling hard fetches, OS dependent. Not owned, may be | 142 // Interface for scheduling hard fetches, OS dependent. Not owned, may be |
| 136 // null. | 143 // null. |
| 137 PersistentScheduler* persistent_scheduler_; | 144 PersistentScheduler* persistent_scheduler_; |
| 138 | 145 |
| 146 bool background_fetch_in_progress_; |
| 147 |
| 139 // Used to adapt the schedule based on usage activity of the user. Not owned. | 148 // Used to adapt the schedule based on usage activity of the user. Not owned. |
| 140 const UserClassifier* user_classifier_; | 149 const UserClassifier* user_classifier_; |
| 141 | 150 |
| 142 PrefService* pref_service_; | 151 PrefService* pref_service_; |
| 143 | 152 |
| 144 DISALLOW_COPY_AND_ASSIGN(SchedulingRemoteSuggestionsProvider); | 153 DISALLOW_COPY_AND_ASSIGN(SchedulingRemoteSuggestionsProvider); |
| 145 }; | 154 }; |
| 146 | 155 |
| 147 } // namespace ntp_snippets | 156 } // namespace ntp_snippets |
| 148 | 157 |
| 149 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_SCHEDULING_REMOTE_SUGGESTIONS_PROVIDER
_H_ | 158 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_SCHEDULING_REMOTE_SUGGESTIONS_PROVIDER
_H_ |
| OLD | NEW |