OLD | NEW |
| (Empty) |
1 // Copyright 2015 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 COMPONENTS_SCHEDULER_CHILD_WEB_TASK_RUNNER_H_ | |
6 #define COMPONENTS_SCHEDULER_CHILD_WEB_TASK_RUNNER_H_ | |
7 | |
8 #include <memory> | |
9 | |
10 #include "base/macros.h" | |
11 #include "base/memory/ref_counted.h" | |
12 #include "base/time/time.h" | |
13 #include "components/scheduler/scheduler_export.h" | |
14 #include "third_party/WebKit/public/platform/WebTaskRunner.h" | |
15 | |
16 namespace scheduler { | |
17 class TaskQueue; | |
18 | |
19 class SCHEDULER_EXPORT WebTaskRunnerImpl : public blink::WebTaskRunner { | |
20 public: | |
21 explicit WebTaskRunnerImpl(scoped_refptr<TaskQueue> task_queue); | |
22 | |
23 ~WebTaskRunnerImpl() override; | |
24 | |
25 // blink::WebTaskRunner implementation: | |
26 void postTask(const blink::WebTraceLocation& web_location, | |
27 blink::WebTaskRunner::Task* task) override; | |
28 void postDelayedTask(const blink::WebTraceLocation& web_location, | |
29 blink::WebTaskRunner::Task* task, | |
30 double delayMs) override; | |
31 bool runsTasksOnCurrentThread() override; | |
32 double virtualTimeSeconds() const override; | |
33 double monotonicallyIncreasingVirtualTimeSeconds() const override; | |
34 std::unique_ptr<blink::WebTaskRunner> clone() override; | |
35 | |
36 // blink::WebTaskRunner::Task should be wrapped by base::Passed() when | |
37 // used with base::Bind(). See https://crbug.com/551356. | |
38 // runTask() is a helper to call blink::WebTaskRunner::Task::run from | |
39 // std::unique_ptr<blink::WebTaskRunner::Task>. | |
40 // runTask() is placed here because std::unique_ptr<> cannot be used from | |
41 // Blink. | |
42 static void runTask(std::unique_ptr<blink::WebTaskRunner::Task>); | |
43 | |
44 private: | |
45 base::TimeTicks Now() const; | |
46 | |
47 scoped_refptr<TaskQueue> task_queue_; | |
48 | |
49 DISALLOW_COPY_AND_ASSIGN(WebTaskRunnerImpl); | |
50 }; | |
51 | |
52 } // namespace scheduler | |
53 | |
54 #endif // COMPONENTS_SCHEDULER_CHILD_WEB_TASK_RUNNER_H_ | |
OLD | NEW |