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_NTP_SNIPPETS_SCHEDULER_H_ | 5 #ifndef COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_SCHEDULER_H_ |
6 #define COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_SCHEDULER_H_ | 6 #define COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_SCHEDULER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 | 10 |
11 namespace ntp_snippets { | 11 namespace ntp_snippets { |
12 | 12 |
13 // Interface to schedule the periodic fetching of snippets. | 13 // Interface to schedule the periodic fetching of snippets. |
14 class NTPSnippetsScheduler { | 14 class NTPSnippetsScheduler { |
15 public: | 15 public: |
16 // Schedule periodic fetching of snippets, with different period depending on | 16 // Schedule periodic fetching of snippets, with different period depending on |
17 // network and charging state. The concrete implementation should call | 17 // network and charging state, and also set up a delay after which the periods |
18 // NTPSnippetsService::FetchSnippets once per period. | 18 // may change. The concrete implementation should call |
| 19 // NTPSnippetsService::FetchSnippets once per period, and |
| 20 // NTPSnippetsService::RescheduleFetching at |reschedule_time|. |
| 21 // Any of the values can be zero to indicate that the corresponding task |
| 22 // should not be scheduled. |
19 virtual bool Schedule(base::TimeDelta period_wifi_charging, | 23 virtual bool Schedule(base::TimeDelta period_wifi_charging, |
20 base::TimeDelta period_wifi, | 24 base::TimeDelta period_wifi, |
21 base::TimeDelta period_fallback) = 0; | 25 base::TimeDelta period_fallback, |
| 26 base::Time reschedule_time) = 0; |
22 | 27 |
23 // Cancel the scheduled fetching task, if any. | 28 // Cancel any scheduled tasks. |
24 virtual bool Unschedule() = 0; | 29 virtual bool Unschedule() = 0; |
25 | 30 |
26 protected: | 31 protected: |
27 NTPSnippetsScheduler() = default; | 32 NTPSnippetsScheduler() = default; |
28 | 33 |
29 private: | 34 private: |
30 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsScheduler); | 35 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsScheduler); |
31 }; | 36 }; |
32 | 37 |
33 } // namespace ntp_snippets | 38 } // namespace ntp_snippets |
34 | 39 |
35 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_SCHEDULER_H_ | 40 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_SCHEDULER_H_ |
OLD | NEW |