| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 private: | 63 private: |
| 64 // Abstract description of the fetching schedule. | 64 // Abstract description of the fetching schedule. |
| 65 struct FetchingSchedule { | 65 struct FetchingSchedule { |
| 66 static FetchingSchedule Empty(); | 66 static FetchingSchedule Empty(); |
| 67 bool operator==(const FetchingSchedule& other) const; | 67 bool operator==(const FetchingSchedule& other) const; |
| 68 bool operator!=(const FetchingSchedule& other) const; | 68 bool operator!=(const FetchingSchedule& other) const; |
| 69 bool is_empty() const; | 69 bool is_empty() const; |
| 70 | 70 |
| 71 base::TimeDelta interval_persistent_wifi; | 71 base::TimeDelta interval_persistent_wifi; |
| 72 base::TimeDelta interval_persistent_fallback; | 72 base::TimeDelta interval_persistent_fallback; |
| 73 base::TimeDelta interval_soft_on_usage_event; | 73 base::TimeDelta interval_soft_wifi; |
| 74 base::TimeDelta interval_soft_on_ntp_opened; | 74 base::TimeDelta interval_soft_fallback; |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 enum class TriggerType; | 77 enum class TriggerType; |
| 78 | 78 |
| 79 // After the call, updates will be scheduled in the future. Idempotent, can be | 79 // After the call, updates will be scheduled in the future. Idempotent, can be |
| 80 // run any time later without impacting the current schedule. | 80 // run any time later without impacting the current schedule. |
| 81 // If you want to enforce rescheduling, call Unschedule() and then Schedule(). | 81 // If you want to enforce rescheduling, call Unschedule() and then Schedule(). |
| 82 void StartScheduling(); | 82 void StartScheduling(); |
| 83 | 83 |
| 84 // After the call, no updates will happen before another call to Schedule(). | 84 // After the call, no updates will happen before another call to Schedule(). |
| 85 // Idempotent, can be run any time later without impacting the current | 85 // Idempotent, can be run any time later without impacting the current |
| 86 // schedule. | 86 // schedule. |
| 87 void StopScheduling(); | 87 void StopScheduling(); |
| 88 | 88 |
| 89 // Trigger a background refetch for the given |trigger| if enabled. | 89 // Trigger a background refetch for the given |trigger| if enabled. |
| 90 void RefetchInTheBackgroundIfEnabled(TriggerType trigger); | 90 void RefetchInTheBackgroundIfEnabled(TriggerType trigger); |
| 91 | 91 |
| 92 // Trigger the background refetch. | 92 // Trigger the background refetch. |
| 93 void RefetchInTheBackground(); | 93 void RefetchInTheBackground(); |
| 94 | 94 |
| 95 // Checks whether it is time to perform a soft background fetch, according to | 95 // Checks whether it is time to perform a soft background fetch, according to |
| 96 // |schedule|. | 96 // |schedule|. |
| 97 bool ShouldRefetchInTheBackgroundNow(TriggerType trigger); | 97 bool ShouldRefetchInTheBackgroundNow(); |
| 98 | 98 |
| 99 // Returns whether background fetching (for the given |trigger|) is disabled. | 99 // Returns whether background fetching (for the given |trigger|) is disabled. |
| 100 bool BackgroundFetchesDisabled(TriggerType trigger) const; | 100 bool BackgroundFetchesDisabled(TriggerType trigger) const; |
| 101 | 101 |
| 102 // Returns true if quota is available for another request. | 102 // Returns true if quota is available for another request. |
| 103 bool AcquireQuota(bool interactive_request); | 103 bool AcquireQuota(bool interactive_request); |
| 104 | 104 |
| 105 // Callback after RefetchInTheBackground is completed. | 105 // Callback after RefetchInTheBackground is completed. |
| 106 void RefetchInTheBackgroundFinished(Status fetch_status); | 106 void RefetchInTheBackgroundFinished(Status fetch_status); |
| 107 | 107 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 std::set<TriggerType> enabled_triggers_; | 153 std::set<TriggerType> enabled_triggers_; |
| 154 | 154 |
| 155 base::Time background_fetches_allowed_after_; | 155 base::Time background_fetches_allowed_after_; |
| 156 | 156 |
| 157 DISALLOW_COPY_AND_ASSIGN(RemoteSuggestionsSchedulerImpl); | 157 DISALLOW_COPY_AND_ASSIGN(RemoteSuggestionsSchedulerImpl); |
| 158 }; | 158 }; |
| 159 | 159 |
| 160 } // namespace ntp_snippets | 160 } // namespace ntp_snippets |
| 161 | 161 |
| 162 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_SCHEDULER_IMPL_H_ | 162 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_SCHEDULER_IMPL_H_ |
| OLD | NEW |