1 // Copyright 2020 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_BACKGROUND_TASK_SCHEDULER_BACKGROUND_TASK_SCHEDULER_H_
6 #define COMPONENTS_BACKGROUND_TASK_SCHEDULER_BACKGROUND_TASK_SCHEDULER_H_
8 #include "base/functional/callback.h"
9 #include "components/background_task_scheduler/task_info.h"
10 #include "components/keyed_service/core/keyed_service.h"
12 namespace background_task {
14 // A BackgroundTaskScheduler is used to schedule jobs that run in the
15 // background. It is backed by system APIs which have different implementations
16 // on different android versions. For more information, please refer
17 // BackgroundTaskScheduler.java.
18 class BackgroundTaskScheduler : public KeyedService {
20 BackgroundTaskScheduler(const BackgroundTaskScheduler&) = delete;
21 BackgroundTaskScheduler& operator=(const BackgroundTaskScheduler&) = delete;
23 // Schedules a background task with various scheduling related params
24 // contained in |task_info|.
25 virtual bool Schedule(const TaskInfo& task_info) = 0;
27 // Cancels the task specified by the |task_id}.
28 virtual void Cancel(int task_id) = 0;
31 BackgroundTaskScheduler() = default;
32 ~BackgroundTaskScheduler() override = default;
35 } // namespace background_task
37 #endif // COMPONENTS_BACKGROUND_TASK_SCHEDULER_BACKGROUND_TASK_SCHEDULER_H_