OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef NET_QUIC_QUARTC_QUARTC_TASKRUNNER_INTERFACE_H_ |
| 6 #define NET_QUIC_QUARTC_QUARTC_TASKRUNNER_INTERFACE_H_ |
| 7 |
| 8 #include <stdint.h> |
| 9 |
| 10 #include <memory> |
| 11 |
| 12 namespace net { |
| 13 |
| 14 // Used by platform specific QuicAlarms. For example, WebRTC will use it to set |
| 15 // and cancel an alarm. When setting an alarm, the task runner will schedule a |
| 16 // task on rtc::Thread. When canceling an alarm, the canceler for that task will |
| 17 // be called. |
| 18 class QuartcTaskRunnerInterface { |
| 19 public: |
| 20 virtual ~QuartcTaskRunnerInterface() {} |
| 21 |
| 22 class Task { |
| 23 public: |
| 24 virtual ~Task() {} |
| 25 |
| 26 // Called when it's time to start the task. |
| 27 virtual void Run() = 0; |
| 28 }; |
| 29 |
| 30 // A handler used to cancel a scheduled task. In some cases, a task cannot |
| 31 // be directly canceled with its pointer. For example, in WebRTC, the task |
| 32 // will be scheduled on rtc::Thread. When canceling a task, its pointer cannot |
| 33 // locate the scheduled task in the thread message queue. So when scheduling a |
| 34 // task, an additional handler (ScheduledTask) will be returned. |
| 35 class ScheduledTask { |
| 36 public: |
| 37 virtual ~ScheduledTask() {} |
| 38 |
| 39 // Cancels a scheduled task, meaning the task will not be run. |
| 40 virtual void Cancel() = 0; |
| 41 }; |
| 42 |
| 43 // Schedules a task, which will be run after the given delay. A ScheduledTask |
| 44 // may be used to cancel the task. |
| 45 virtual std::unique_ptr<ScheduledTask> Schedule(Task* task, |
| 46 uint64_t delay_ms) = 0; |
| 47 }; |
| 48 |
| 49 } // namespace net |
| 50 |
| 51 #endif // NET_QUIC_QUARTC_QUARTC_TASKRUNNER_INTERFACE_H_ |
OLD | NEW |