| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_SCHEDULER_CHILD_WEB_TASK_RUNNER_H_ | 5 #ifndef COMPONENTS_SCHEDULER_CHILD_WEB_TASK_RUNNER_H_ |
| 6 #define COMPONENTS_SCHEDULER_CHILD_WEB_TASK_RUNNER_H_ | 6 #define COMPONENTS_SCHEDULER_CHILD_WEB_TASK_RUNNER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "components/scheduler/scheduler_export.h" | 11 #include "components/scheduler/scheduler_export.h" |
| 12 #include "third_party/WebKit/public/platform/WebTaskRunner.h" | 12 #include "third_party/WebKit/public/platform/WebTaskRunner.h" |
| 13 | 13 |
| 14 namespace base { | |
| 15 class SingleThreadTaskRunner; | |
| 16 } // namespace base | |
| 17 | |
| 18 namespace scheduler { | 14 namespace scheduler { |
| 15 class TaskQueue; |
| 19 | 16 |
| 20 class SCHEDULER_EXPORT WebTaskRunnerImpl : public blink::WebTaskRunner { | 17 class SCHEDULER_EXPORT WebTaskRunnerImpl : public blink::WebTaskRunner { |
| 21 public: | 18 public: |
| 22 explicit WebTaskRunnerImpl( | 19 explicit WebTaskRunnerImpl(scoped_refptr<TaskQueue> task_queue); |
| 23 scoped_refptr<base::SingleThreadTaskRunner> task_runner); | |
| 24 | 20 |
| 25 ~WebTaskRunnerImpl() override; | 21 ~WebTaskRunnerImpl() override; |
| 26 | 22 |
| 27 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner() const { | |
| 28 return task_runner_; | |
| 29 } | |
| 30 | |
| 31 // blink::WebTaskRunner implementation: | 23 // blink::WebTaskRunner implementation: |
| 32 void postTask(const blink::WebTraceLocation& web_location, | 24 void postTask(const blink::WebTraceLocation& web_location, |
| 33 blink::WebTaskRunner::Task* task) override; | 25 blink::WebTaskRunner::Task* task) override; |
| 34 void postDelayedTask(const blink::WebTraceLocation& web_location, | 26 void postDelayedTask(const blink::WebTraceLocation& web_location, |
| 35 blink::WebTaskRunner::Task* task, | 27 blink::WebTaskRunner::Task* task, |
| 36 double delayMs) override; | 28 double delayMs) override; |
| 37 blink::WebTaskRunner* clone() override; | 29 blink::WebTaskRunner* clone() override; |
| 38 | 30 |
| 39 // blink::WebTaskRunner::Task should be wrapped by base::Passed() when | 31 // blink::WebTaskRunner::Task should be wrapped by base::Passed() when |
| 40 // used with base::Bind(). See https://crbug.com/551356. | 32 // used with base::Bind(). See https://crbug.com/551356. |
| 41 // runTask() is a helper to call blink::WebTaskRunner::Task::run from | 33 // runTask() is a helper to call blink::WebTaskRunner::Task::run from |
| 42 // scoped_ptr<blink::WebTaskRunner::Task>. | 34 // scoped_ptr<blink::WebTaskRunner::Task>. |
| 43 // runTask() is placed here because scoped_ptr<> cannot be used from Blink. | 35 // runTask() is placed here because scoped_ptr<> cannot be used from Blink. |
| 44 static void runTask(scoped_ptr<blink::WebTaskRunner::Task>); | 36 static void runTask(scoped_ptr<blink::WebTaskRunner::Task>); |
| 45 | 37 |
| 46 private: | 38 private: |
| 47 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 39 scoped_refptr<TaskQueue> task_queue_; |
| 48 | 40 |
| 49 DISALLOW_COPY_AND_ASSIGN(WebTaskRunnerImpl); | 41 DISALLOW_COPY_AND_ASSIGN(WebTaskRunnerImpl); |
| 50 }; | 42 }; |
| 51 | 43 |
| 52 } // namespace scheduler | 44 } // namespace scheduler |
| 53 | 45 |
| 54 #endif // COMPONENTS_SCHEDULER_CHILD_WEB_TASK_RUNNER_H_ | 46 #endif // COMPONENTS_SCHEDULER_CHILD_WEB_TASK_RUNNER_H_ |
| OLD | NEW |