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 #include "platform/WebTaskRunner.h" | 5 #include "platform/WebTaskRunner.h" |
6 | 6 |
7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
9 | 9 |
10 namespace base { | 10 namespace base { |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 location, convertToBaseCallback(std::move(task)), | 142 location, convertToBaseCallback(std::move(task)), |
143 base::TimeDelta::FromMilliseconds(delayMs)); | 143 base::TimeDelta::FromMilliseconds(delayMs)); |
144 } | 144 } |
145 | 145 |
146 TaskHandle WebTaskRunner::postCancellableTask( | 146 TaskHandle WebTaskRunner::postCancellableTask( |
147 const WebTraceLocation& location, | 147 const WebTraceLocation& location, |
148 std::unique_ptr<WTF::Closure> task) { | 148 std::unique_ptr<WTF::Closure> task) { |
149 DCHECK(runsTasksOnCurrentThread()); | 149 DCHECK(runsTasksOnCurrentThread()); |
150 RefPtr<TaskHandle::Runner> runner = | 150 RefPtr<TaskHandle::Runner> runner = |
151 adoptRef(new TaskHandle::Runner(std::move(task))); | 151 adoptRef(new TaskHandle::Runner(std::move(task))); |
152 postTask(location, WTF::bind(&TaskHandle::Runner::run, runner->asWeakPtr(), | 152 postTask(location, |
153 TaskHandle(runner))); | 153 WTF::bind(&TaskHandle::Runner::run, runner->asWeakPtr(), |
| 154 TaskHandle(runner))); |
154 return TaskHandle(runner); | 155 return TaskHandle(runner); |
155 } | 156 } |
156 | 157 |
157 TaskHandle WebTaskRunner::postDelayedCancellableTask( | 158 TaskHandle WebTaskRunner::postDelayedCancellableTask( |
158 const WebTraceLocation& location, | 159 const WebTraceLocation& location, |
159 std::unique_ptr<WTF::Closure> task, | 160 std::unique_ptr<WTF::Closure> task, |
160 long long delayMs) { | 161 long long delayMs) { |
161 DCHECK(runsTasksOnCurrentThread()); | 162 DCHECK(runsTasksOnCurrentThread()); |
162 RefPtr<TaskHandle::Runner> runner = | 163 RefPtr<TaskHandle::Runner> runner = |
163 adoptRef(new TaskHandle::Runner(std::move(task))); | 164 adoptRef(new TaskHandle::Runner(std::move(task))); |
164 postDelayedTask(location, WTF::bind(&TaskHandle::Runner::run, | 165 postDelayedTask(location, |
165 runner->asWeakPtr(), TaskHandle(runner)), | 166 WTF::bind(&TaskHandle::Runner::run, runner->asWeakPtr(), |
| 167 TaskHandle(runner)), |
166 delayMs); | 168 delayMs); |
167 return TaskHandle(runner); | 169 return TaskHandle(runner); |
168 } | 170 } |
169 | 171 |
170 WebTaskRunner::~WebTaskRunner() = default; | 172 WebTaskRunner::~WebTaskRunner() = default; |
171 | 173 |
172 } // namespace blink | 174 } // namespace blink |
OLD | NEW |