Chromium Code Reviews| 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_ | |
|
skvlad-chromium
2016/10/28 21:51:42
Please add includes for system types:
#include <me
| |
| 7 | |
| 8 namespace net { | |
| 9 | |
| 10 // Used by platform specific QuicAlarms. For example, WebRTC will use it to set | |
| 11 // and cancel an alarm. When setting an alarm, the task runner will schedule a | |
| 12 // task on rtc::Thread. When canceling an alarm, the canceler for that task will | |
| 13 // be called. | |
| 14 class QuartcTaskRunnerInterface { | |
| 15 public: | |
| 16 virtual ~QuartcTaskRunnerInterface() {} | |
| 17 | |
| 18 class Task { | |
| 19 public: | |
| 20 virtual ~Task() {} | |
| 21 | |
| 22 // Called when it's time to start the task. | |
| 23 virtual void Run() = 0; | |
| 24 }; | |
| 25 | |
| 26 // A handler used to cancel a scheduled task. In some cases, a task cannot | |
| 27 // be directly canceled with its pointer. For example, in WebRTC, the task | |
| 28 // will be scheduled on rtc::Thread. When canceling a task, its pointer cannot | |
| 29 // locate the scheduled task in the thread message queue. So when scheduling a | |
| 30 // task, an additional handler (ScheduledTask) will be returned. | |
| 31 class ScheduledTask { | |
| 32 public: | |
| 33 virtual ~ScheduledTask() {} | |
| 34 | |
| 35 // Cancels a scheduled task, meaning the task will not be run. | |
| 36 virtual void Cancel() = 0; | |
| 37 }; | |
| 38 | |
| 39 // Schedules a task, which will be run after the given delay. A ScheduledTask | |
| 40 // may be used to cancel the task. | |
| 41 virtual std::unique_ptr<ScheduledTask> Schedule(Task* task, | |
| 42 uint64_t delay_ms) = 0; | |
| 43 }; | |
| 44 | |
| 45 } // namespace net | |
| 46 | |
| 47 #endif // NET_QUIC_QUARTC_QUARTC_TASKRUNNER_INTERFACE_H_ | |
| OLD | NEW |