| 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 periods depending on |
| 17 // network state, and also set up a delay after which the periods may change. | 17 // network state. The concrete implementation should call |
| 18 // The concrete implementation should call | 18 // NTPSnippetsService::FetchSnippets once per period. |
| 19 // NTPSnippetsService::FetchSnippets once per period, and | 19 // Any of the periods can be zero to indicate that the corresponding task |
| 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. | 20 // should not be scheduled. |
| 23 virtual bool Schedule(base::TimeDelta period_wifi, | 21 virtual bool Schedule(base::TimeDelta period_wifi, |
| 24 base::TimeDelta period_fallback, | 22 base::TimeDelta period_fallback) = 0; |
| 25 base::Time reschedule_time) = 0; | |
| 26 | 23 |
| 27 // Cancel any scheduled tasks. | 24 // Cancel any scheduled tasks. |
| 28 virtual bool Unschedule() = 0; | 25 virtual bool Unschedule() = 0; |
| 29 | 26 |
| 30 protected: | 27 protected: |
| 31 NTPSnippetsScheduler() = default; | 28 NTPSnippetsScheduler() = default; |
| 32 | 29 |
| 33 private: | 30 private: |
| 34 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsScheduler); | 31 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsScheduler); |
| 35 }; | 32 }; |
| 36 | 33 |
| 37 } // namespace ntp_snippets | 34 } // namespace ntp_snippets |
| 38 | 35 |
| 39 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_SCHEDULER_H_ | 36 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_SCHEDULER_H_ |
| OLD | NEW |