| 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_REMOTE_SUGGESTIONS_SCHEDULER_IMPL_H_ | 5 #ifndef COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_SCHEDULER_IMPL_H_ |
| 6 #define COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_SCHEDULER_IMPL_H_ | 6 #define COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_SCHEDULER_IMPL_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 // Idempotent, can be run any time later without impacting the current | 86 // Idempotent, can be run any time later without impacting the current |
| 87 // schedule. | 87 // schedule. |
| 88 void StopScheduling(); | 88 void StopScheduling(); |
| 89 | 89 |
| 90 // Trigger a background refetch for the given |trigger| if enabled and if the | 90 // Trigger a background refetch for the given |trigger| if enabled and if the |
| 91 // timing is appropriate for another fetch. | 91 // timing is appropriate for another fetch. |
| 92 void RefetchInTheBackgroundIfAppropriate(TriggerType trigger); | 92 void RefetchInTheBackgroundIfAppropriate(TriggerType trigger); |
| 93 | 93 |
| 94 // Checks whether it is time to perform a soft background fetch, according to | 94 // Checks whether it is time to perform a soft background fetch, according to |
| 95 // |schedule|. | 95 // |schedule|. |
| 96 bool ShouldRefetchInTheBackgroundNow(); | 96 bool ShouldRefetchInTheBackgroundNow(base::Time last_fetch_attempt_time); |
| 97 | 97 |
| 98 // Returns whether background fetching (for the given |trigger|) is disabled. | 98 // Returns whether background fetching (for the given |trigger|) is disabled. |
| 99 bool BackgroundFetchesDisabled(TriggerType trigger) const; | 99 bool BackgroundFetchesDisabled(TriggerType trigger) const; |
| 100 | 100 |
| 101 // Returns true if quota is available for another request. | 101 // Returns true if quota is available for another request. |
| 102 bool AcquireQuota(bool interactive_request); | 102 bool AcquireQuota(bool interactive_request); |
| 103 | 103 |
| 104 // Callback after RefetchInTheBackground is completed. | 104 // Callback after RefetchInTheBackground is completed. |
| 105 void RefetchInTheBackgroundFinished(Status fetch_status); | 105 void RefetchInTheBackgroundFinished(Status fetch_status); |
| 106 | 106 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 137 bool background_fetch_in_progress_; | 137 bool background_fetch_in_progress_; |
| 138 | 138 |
| 139 // Used to adapt the schedule based on usage activity of the user. Not owned. | 139 // Used to adapt the schedule based on usage activity of the user. Not owned. |
| 140 const UserClassifier* user_classifier_; | 140 const UserClassifier* user_classifier_; |
| 141 | 141 |
| 142 // Request throttlers for limiting requests for different classes of users. | 142 // Request throttlers for limiting requests for different classes of users. |
| 143 RequestThrottler request_throttler_rare_ntp_user_; | 143 RequestThrottler request_throttler_rare_ntp_user_; |
| 144 RequestThrottler request_throttler_active_ntp_user_; | 144 RequestThrottler request_throttler_active_ntp_user_; |
| 145 RequestThrottler request_throttler_active_suggestions_consumer_; | 145 RequestThrottler request_throttler_active_suggestions_consumer_; |
| 146 | 146 |
| 147 // To make sure we only report the first trigger to UMA. |
| 148 bool time_until_first_trigger_reported_; |
| 149 |
| 147 // We should not fetch in background before EULA gets accepted. | 150 // We should not fetch in background before EULA gets accepted. |
| 148 std::unique_ptr<EulaState> eula_state_; | 151 std::unique_ptr<EulaState> eula_state_; |
| 149 | 152 |
| 150 PrefService* profile_prefs_; | 153 PrefService* profile_prefs_; |
| 151 std::unique_ptr<base::Clock> clock_; | 154 std::unique_ptr<base::Clock> clock_; |
| 152 std::set<TriggerType> enabled_triggers_; | 155 std::set<TriggerType> enabled_triggers_; |
| 153 | 156 |
| 154 base::Time background_fetches_allowed_after_; | 157 base::Time background_fetches_allowed_after_; |
| 155 | 158 |
| 156 DISALLOW_COPY_AND_ASSIGN(RemoteSuggestionsSchedulerImpl); | 159 DISALLOW_COPY_AND_ASSIGN(RemoteSuggestionsSchedulerImpl); |
| 157 }; | 160 }; |
| 158 | 161 |
| 159 } // namespace ntp_snippets | 162 } // namespace ntp_snippets |
| 160 | 163 |
| 161 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_SCHEDULER_IMPL_H_ | 164 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_SCHEDULER_IMPL_H_ |
| OLD | NEW |