| 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 double virtualTimeSeconds() const override; | |
| 32 double monotonicallyIncreasingVirtualTimeSeconds() const override; | |
| 33 blink::WebTaskRunner* clone() override; | |
| 34 | |
| 35 // blink::WebTaskRunner::Task should be wrapped by base::Passed() when | |
| 36 // used with base::Bind(). See https://crbug.com/551356. | |
| 37 // runTask() is a helper to call blink::WebTaskRunner::Task::run from | |
| 38 // std::unique_ptr<blink::WebTaskRunner::Task>. | |
| 39 // runTask() is placed here because std::unique_ptr<> cannot be used from | |
| 40 // Blink. | |
| 41 static void runTask(std::unique_ptr<blink::WebTaskRunner::Task>); | |
| 42 | |
| 43 private: | |
| 44 base::TimeTicks Now() const; | |
| 45 | |
| 46 scoped_refptr<TaskQueue> task_queue_; | |
| 47 | |
| 48 DISALLOW_COPY_AND_ASSIGN(WebTaskRunnerImpl); | |
| 49 }; | |
| 50 | |
| 51 } // namespace scheduler | |
| 52 | |
| 53 #endif // COMPONENTS_SCHEDULER_CHILD_WEB_TASK_RUNNER_H_ | |
| OLD | NEW |