| 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_OFFLINE_PAGES_BACKGROUND_SCHEDULER_H_ | 5 #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_SCHEDULER_H_ |
| 6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_SCHEDULER_H_ | 6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_SCHEDULER_H_ |
| 7 | 7 |
| 8 namespace offline_pages { | 8 namespace offline_pages { |
| 9 | 9 |
| 10 // Interface of a class responsible for scheduling a task to initiate | 10 // Interface of a class responsible for scheduling a task to initiate |
| 11 // processing of background offlining requests upon select system conditions | 11 // processing of background offlining requests upon select system conditions |
| 12 // (such as having a network connection). | 12 // (such as having a network connection). |
| 13 class Scheduler { | 13 class Scheduler { |
| 14 public: | 14 public: |
| 15 // Defines a set of system conditions to trigger background processing. | 15 // Defines a set of system conditions to trigger background processing. |
| 16 struct TriggerCondition { | 16 struct TriggerCondition { |
| 17 // TODO(dougarnett): define network, battery, power conditions. | 17 // TODO(dougarnett): define network, battery, power conditions. |
| 18 }; | 18 }; |
| 19 | 19 |
| 20 Scheduler() {} | 20 Scheduler() {} |
| 21 virtual ~Scheduler() {} | 21 virtual ~Scheduler() {} |
| 22 | 22 |
| 23 // Ensures that the system has a task scheduled for |trigger_conditions|. | 23 // Schedules the triggering of a task subject to |trigger_conditions|. |
| 24 // This may overwrite any previous scheduled task with a new one for | 24 // This may overwrite any previous scheduled task with a new one for |
| 25 // these conditions. | 25 // these conditions. That is, only one set of triggering conditions |
| 26 virtual void EnsureScheduled(const TriggerCondition& trigger_condition) = 0; | 26 // is scheduled at a time. |
| 27 virtual void Schedule(const TriggerCondition& trigger_condition) = 0; |
| 27 | 28 |
| 28 // Clears the currently scheduled task, if any. | 29 // Unschedules the currently scheduled task, if any. |
| 29 virtual void ClearScheduled() = 0; | 30 virtual void Unschedule() = 0; |
| 30 }; | 31 }; |
| 31 | 32 |
| 32 } // namespace offline_pages | 33 } // namespace offline_pages |
| 33 | 34 |
| 34 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_SCHEDULER_H_ | 35 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_SCHEDULER_H_ |
| OLD | NEW |