| 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> |
| 11 #include <utility> | 11 #include <utility> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "components/ntp_snippets/content_suggestions_provider.h" | 16 #include "components/ntp_snippets/content_suggestions_provider.h" |
| 17 #include "components/ntp_snippets/remote/persistent_scheduler.h" | 17 #include "components/ntp_snippets/remote/persistent_scheduler.h" |
| 18 #include "components/ntp_snippets/remote/remote_suggestions_provider.h" | 18 #include "components/ntp_snippets/remote/remote_suggestions_provider.h" |
| 19 #include "components/ntp_snippets/remote/remote_suggestions_scheduler.h" | 19 #include "components/ntp_snippets/remote/remote_suggestions_scheduler.h" |
| 20 #include "components/ntp_snippets/remote/request_throttler.h" |
| 20 | 21 |
| 21 class PrefRegistrySimple; | 22 class PrefRegistrySimple; |
| 22 class PrefService; | 23 class PrefService; |
| 23 | 24 |
| 24 namespace base { | 25 namespace base { |
| 25 class Clock; | 26 class Clock; |
| 26 } | 27 } |
| 27 | 28 |
| 28 namespace ntp_snippets { | 29 namespace ntp_snippets { |
| 29 | 30 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 // Trigger a background refetch for the given |trigger| if enabled. | 138 // Trigger a background refetch for the given |trigger| if enabled. |
| 138 void RefetchInTheBackgroundIfEnabled(TriggerType trigger); | 139 void RefetchInTheBackgroundIfEnabled(TriggerType trigger); |
| 139 | 140 |
| 140 // Checks whether it is time to perform a soft background fetch, according to | 141 // Checks whether it is time to perform a soft background fetch, according to |
| 141 // |schedule|. | 142 // |schedule|. |
| 142 bool ShouldRefetchInTheBackgroundNow(TriggerType trigger); | 143 bool ShouldRefetchInTheBackgroundNow(TriggerType trigger); |
| 143 | 144 |
| 144 // Returns whether background fetching (for the given |trigger|) is disabled. | 145 // Returns whether background fetching (for the given |trigger|) is disabled. |
| 145 bool BackgroundFetchesDisabled(TriggerType trigger) const; | 146 bool BackgroundFetchesDisabled(TriggerType trigger) const; |
| 146 | 147 |
| 148 // Returns true if quota is available for another request. |
| 149 bool AcquireQuota(bool interactive_request); |
| 150 |
| 147 // Callback after Fetch is completed. | 151 // Callback after Fetch is completed. |
| 148 void FetchFinished(const FetchDoneCallback& callback, | 152 void FetchFinished(const FetchDoneCallback& callback, |
| 149 Status fetch_status, | 153 Status fetch_status, |
| 150 std::vector<ContentSuggestion> suggestions); | 154 std::vector<ContentSuggestion> suggestions); |
| 151 | 155 |
| 152 // Callback after RefetchInTheBackground is completed. | 156 // Callback after RefetchInTheBackground is completed. |
| 153 void RefetchInTheBackgroundFinished( | 157 void RefetchInTheBackgroundFinished( |
| 154 std::unique_ptr<FetchStatusCallback> callback, | 158 std::unique_ptr<FetchStatusCallback> callback, |
| 155 Status fetch_status); | 159 Status fetch_status); |
| 156 | 160 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 182 // Interface for scheduling hard fetches, OS dependent. Not owned, may be | 186 // Interface for scheduling hard fetches, OS dependent. Not owned, may be |
| 183 // null. | 187 // null. |
| 184 PersistentScheduler* persistent_scheduler_; | 188 PersistentScheduler* persistent_scheduler_; |
| 185 | 189 |
| 186 FetchingSchedule schedule_; | 190 FetchingSchedule schedule_; |
| 187 bool background_fetch_in_progress_; | 191 bool background_fetch_in_progress_; |
| 188 | 192 |
| 189 // Used to adapt the schedule based on usage activity of the user. Not owned. | 193 // Used to adapt the schedule based on usage activity of the user. Not owned. |
| 190 const UserClassifier* user_classifier_; | 194 const UserClassifier* user_classifier_; |
| 191 | 195 |
| 196 // Request throttlers for limiting requests for different classes of users. |
| 197 RequestThrottler request_throttler_rare_ntp_user_; |
| 198 RequestThrottler request_throttler_active_ntp_user_; |
| 199 RequestThrottler request_throttler_active_suggestions_consumer_; |
| 200 |
| 192 PrefService* pref_service_; | 201 PrefService* pref_service_; |
| 193 std::unique_ptr<base::Clock> clock_; | 202 std::unique_ptr<base::Clock> clock_; |
| 194 std::set<SchedulingRemoteSuggestionsProvider::TriggerType> enabled_triggers_; | 203 std::set<SchedulingRemoteSuggestionsProvider::TriggerType> enabled_triggers_; |
| 195 | 204 |
| 196 base::Time background_fetches_allowed_after_; | 205 base::Time background_fetches_allowed_after_; |
| 197 | 206 |
| 198 DISALLOW_COPY_AND_ASSIGN(SchedulingRemoteSuggestionsProvider); | 207 DISALLOW_COPY_AND_ASSIGN(SchedulingRemoteSuggestionsProvider); |
| 199 }; | 208 }; |
| 200 | 209 |
| 201 } // namespace ntp_snippets | 210 } // namespace ntp_snippets |
| 202 | 211 |
| 203 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_SCHEDULING_REMOTE_SUGGESTIONS_PROVIDER
_H_ | 212 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_SCHEDULING_REMOTE_SUGGESTIONS_PROVIDER
_H_ |
| OLD | NEW |