Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(497)

Unified Diff: net/quic/quartc/quartc_task_runner_interface.h

Issue 2324833004: Define Stable API for WebRTC/Quartc (Closed)
Patch Set: Fix the IOS simulator and merge. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/quartc/quartc_stream_test.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quartc/quartc_task_runner_interface.h
diff --git a/net/quic/quartc/quartc_task_runner_interface.h b/net/quic/quartc/quartc_task_runner_interface.h
new file mode 100644
index 0000000000000000000000000000000000000000..00917b74b41c87a69e9c4b3a7d76b443684229f3
--- /dev/null
+++ b/net/quic/quartc/quartc_task_runner_interface.h
@@ -0,0 +1,51 @@
+// Copyright (c) 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_QUIC_QUARTC_QUARTC_TASKRUNNER_INTERFACE_H_
+#define NET_QUIC_QUARTC_QUARTC_TASKRUNNER_INTERFACE_H_
+
+#include <stdint.h>
+
+#include <memory>
+
+namespace net {
+
+// Used by platform specific QuicAlarms. For example, WebRTC will use it to set
+// and cancel an alarm. When setting an alarm, the task runner will schedule a
+// task on rtc::Thread. When canceling an alarm, the canceler for that task will
+// be called.
+class QuartcTaskRunnerInterface {
+ public:
+ virtual ~QuartcTaskRunnerInterface() {}
+
+ class Task {
+ public:
+ virtual ~Task() {}
+
+ // Called when it's time to start the task.
+ virtual void Run() = 0;
+ };
+
+ // A handler used to cancel a scheduled task. In some cases, a task cannot
+ // be directly canceled with its pointer. For example, in WebRTC, the task
+ // will be scheduled on rtc::Thread. When canceling a task, its pointer cannot
+ // locate the scheduled task in the thread message queue. So when scheduling a
+ // task, an additional handler (ScheduledTask) will be returned.
+ class ScheduledTask {
+ public:
+ virtual ~ScheduledTask() {}
+
+ // Cancels a scheduled task, meaning the task will not be run.
+ virtual void Cancel() = 0;
+ };
+
+ // Schedules a task, which will be run after the given delay. A ScheduledTask
+ // may be used to cancel the task.
+ virtual std::unique_ptr<ScheduledTask> Schedule(Task* task,
+ uint64_t delay_ms) = 0;
+};
+
+} // namespace net
+
+#endif // NET_QUIC_QUARTC_QUARTC_TASKRUNNER_INTERFACE_H_
« no previous file with comments | « net/quic/quartc/quartc_stream_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698