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