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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 TaskHandle& TaskHandle::operator=(TaskHandle&& other) { | 104 TaskHandle& TaskHandle::operator=(TaskHandle&& other) { |
105 TaskHandle tmp(std::move(other)); | 105 TaskHandle tmp(std::move(other)); |
106 runner_.Swap(tmp.runner_); | 106 runner_.Swap(tmp.runner_); |
107 return *this; | 107 return *this; |
108 } | 108 } |
109 | 109 |
110 TaskHandle::TaskHandle(RefPtr<Runner> runner) : runner_(std::move(runner)) { | 110 TaskHandle::TaskHandle(RefPtr<Runner> runner) : runner_(std::move(runner)) { |
111 DCHECK(runner_); | 111 DCHECK(runner_); |
112 } | 112 } |
113 | 113 |
| 114 bool WebTaskRunner::RunsTasksOnCurrentThread() { |
| 115 return RunsTasksInCurrentSequence(); |
| 116 } |
| 117 |
114 // Use a custom function for base::Bind instead of convertToBaseCallback to | 118 // Use a custom function for base::Bind instead of convertToBaseCallback to |
115 // avoid copying the closure later in the call chain. Copying the bound state | 119 // avoid copying the closure later in the call chain. Copying the bound state |
116 // can lead to data races with ref counted objects like StringImpl. See | 120 // can lead to data races with ref counted objects like StringImpl. See |
117 // crbug.com/679915 for more details. | 121 // crbug.com/679915 for more details. |
118 void WebTaskRunner::PostTask(const WebTraceLocation& location, | 122 void WebTaskRunner::PostTask(const WebTraceLocation& location, |
119 std::unique_ptr<CrossThreadClosure> task) { | 123 std::unique_ptr<CrossThreadClosure> task) { |
120 ToSingleThreadTaskRunner()->PostTask( | 124 ToSingleThreadTaskRunner()->PostTask( |
121 location, base::Bind(&RunCrossThreadClosure, base::Passed(&task))); | 125 location, base::Bind(&RunCrossThreadClosure, base::Passed(&task))); |
122 } | 126 } |
123 | 127 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 PostDelayedTask(location, | 168 PostDelayedTask(location, |
165 WTF::Bind(&TaskHandle::Runner::Run, runner->AsWeakPtr(), | 169 WTF::Bind(&TaskHandle::Runner::Run, runner->AsWeakPtr(), |
166 TaskHandle(runner)), | 170 TaskHandle(runner)), |
167 delay_ms); | 171 delay_ms); |
168 return TaskHandle(runner); | 172 return TaskHandle(runner); |
169 } | 173 } |
170 | 174 |
171 WebTaskRunner::~WebTaskRunner() = default; | 175 WebTaskRunner::~WebTaskRunner() = default; |
172 | 176 |
173 } // namespace blink | 177 } // namespace blink |
OLD | NEW |