| 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 TriggerConditions { |
| 17 // TODO(dougarnett): define network, battery, power conditions. | 17 TriggerConditions(bool power, int battery, bool unmetered) |
| 18 : require_power_connected(power), |
| 19 minimum_battery_percentage(battery), |
| 20 require_unmetered_network(unmetered) {} |
| 21 bool require_power_connected; |
| 22 int minimum_battery_percentage; |
| 23 bool require_unmetered_network; |
| 18 }; | 24 }; |
| 19 | 25 |
| 20 Scheduler() {} | 26 Scheduler() {} |
| 21 virtual ~Scheduler() {} | 27 virtual ~Scheduler() {} |
| 22 | 28 |
| 23 // Schedules the triggering of a task subject to |trigger_conditions|. | 29 // Schedules the triggering of a task subject to |trigger_conditions|. |
| 24 // This may overwrite any previous scheduled task with a new one for | 30 // This may overwrite any previous scheduled task with a new one for |
| 25 // these conditions. That is, only one set of triggering conditions | 31 // these conditions. That is, only one set of triggering conditions |
| 26 // is scheduled at a time. | 32 // is scheduled at a time. |
| 27 virtual void Schedule(const TriggerCondition& trigger_condition) = 0; | 33 virtual void Schedule(const TriggerConditions& trigger_condition) = 0; |
| 28 | 34 |
| 29 // Unschedules the currently scheduled task, if any. | 35 // Unschedules the currently scheduled task, if any. |
| 30 virtual void Unschedule() = 0; | 36 virtual void Unschedule() = 0; |
| 31 }; | 37 }; |
| 32 | 38 |
| 33 } // namespace offline_pages | 39 } // namespace offline_pages |
| 34 | 40 |
| 35 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_SCHEDULER_H_ | 41 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_SCHEDULER_H_ |
| OLD | NEW |