OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "core/workers/WorkerOrWorkletGlobalScope.h" | 5 #include "core/workers/WorkerOrWorkletGlobalScope.h" |
6 | 6 |
7 #include "core/dom/ExecutionContextTask.h" | 7 #include "core/dom/ExecutionContextTask.h" |
| 8 #include "core/dom/TaskRunnerHelper.h" |
8 #include "core/frame/Deprecation.h" | 9 #include "core/frame/Deprecation.h" |
9 #include "core/inspector/ConsoleMessage.h" | 10 #include "core/inspector/ConsoleMessage.h" |
10 #include "core/probe/CoreProbes.h" | 11 #include "core/probe/CoreProbes.h" |
11 #include "core/workers/WorkerReportingProxy.h" | 12 #include "core/workers/WorkerReportingProxy.h" |
12 #include "core/workers/WorkerThread.h" | 13 #include "core/workers/WorkerThread.h" |
13 #include "platform/CrossThreadFunctional.h" | 14 #include "platform/CrossThreadFunctional.h" |
14 #include "wtf/Functional.h" | 15 #include "wtf/Functional.h" |
15 | 16 |
16 namespace blink { | 17 namespace blink { |
17 | 18 |
(...skipping 12 matching lines...) Expand all Loading... |
30 if (m_deprecationWarningBits.quickGet(feature)) | 31 if (m_deprecationWarningBits.quickGet(feature)) |
31 return; | 32 return; |
32 m_deprecationWarningBits.quickSet(feature); | 33 m_deprecationWarningBits.quickSet(feature); |
33 DCHECK(!Deprecation::deprecationMessage(feature).isEmpty()); | 34 DCHECK(!Deprecation::deprecationMessage(feature).isEmpty()); |
34 addConsoleMessage( | 35 addConsoleMessage( |
35 ConsoleMessage::create(DeprecationMessageSource, WarningMessageLevel, | 36 ConsoleMessage::create(DeprecationMessageSource, WarningMessageLevel, |
36 Deprecation::deprecationMessage(feature))); | 37 Deprecation::deprecationMessage(feature))); |
37 } | 38 } |
38 | 39 |
39 void WorkerOrWorkletGlobalScope::postTask( | 40 void WorkerOrWorkletGlobalScope::postTask( |
40 TaskType, | 41 TaskType type, |
41 const WebTraceLocation& location, | 42 const WebTraceLocation& location, |
42 std::unique_ptr<ExecutionContextTask> task, | 43 std::unique_ptr<ExecutionContextTask> task, |
43 const String& taskNameForInstrumentation) { | 44 const String& taskNameForInstrumentation) { |
44 if (!thread()) | 45 if (!thread()) |
45 return; | 46 return; |
46 | 47 |
47 bool isInstrumented = !taskNameForInstrumentation.isEmpty(); | 48 bool isInstrumented = !taskNameForInstrumentation.isEmpty(); |
48 if (isInstrumented) { | 49 if (isInstrumented) { |
49 probe::asyncTaskScheduled(this, "Worker task", task.get()); | 50 probe::asyncTaskScheduled(this, "Worker task", task.get()); |
50 } | 51 } |
51 | 52 |
52 thread()->postTask( | 53 TaskRunnerHelper::get(type, this) |
53 location, crossThreadBind(&WorkerOrWorkletGlobalScope::runTask, | 54 ->postTask(location, |
54 wrapCrossThreadWeakPersistent(this), | 55 crossThreadBind(&WorkerOrWorkletGlobalScope::runTask, |
55 WTF::passed(std::move(task)), isInstrumented)); | 56 wrapCrossThreadWeakPersistent(this), |
| 57 WTF::passed(std::move(task)), isInstrumented)); |
56 } | 58 } |
57 | 59 |
58 void WorkerOrWorkletGlobalScope::runTask( | 60 void WorkerOrWorkletGlobalScope::runTask( |
59 std::unique_ptr<ExecutionContextTask> task, | 61 std::unique_ptr<ExecutionContextTask> task, |
60 bool isInstrumented) { | 62 bool isInstrumented) { |
61 DCHECK(thread()->isCurrentThread()); | 63 DCHECK(thread()->isCurrentThread()); |
62 probe::AsyncTask asyncTask(this, task.get(), nullptr, isInstrumented); | 64 probe::AsyncTask asyncTask(this, task.get(), nullptr, isInstrumented); |
63 task->performTask(this); | 65 task->performTask(this); |
64 } | 66 } |
65 | 67 |
66 } // namespace blink | 68 } // namespace blink |
OLD | NEW |