| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All Rights Reserved. | 2 * Copyright (C) 2013 Google Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 * | 24 * |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "core/dom/MainThreadTaskRunner.h" | 27 #include "core/dom/MainThreadTaskRunner.h" |
| 28 | 28 |
| 29 #include "core/dom/ExecutionContext.h" | 29 #include "core/dom/ExecutionContext.h" |
| 30 #include "core/dom/ExecutionContextTask.h" | 30 #include "core/dom/ExecutionContextTask.h" |
| 31 #include "core/inspector/InspectorInstrumentation.h" | 31 #include "core/inspector/InspectorInstrumentation.h" |
| 32 #include "platform/ThreadSafeFunctional.h" | 32 #include "platform/CrossThreadFunctional.h" |
| 33 #include "public/platform/Platform.h" | 33 #include "public/platform/Platform.h" |
| 34 #include "wtf/Assertions.h" | 34 #include "wtf/Assertions.h" |
| 35 | 35 |
| 36 namespace blink { | 36 namespace blink { |
| 37 | 37 |
| 38 MainThreadTaskRunner::MainThreadTaskRunner(ExecutionContext* context) | 38 MainThreadTaskRunner::MainThreadTaskRunner(ExecutionContext* context) |
| 39 : m_context(context) | 39 : m_context(context) |
| 40 , m_pendingTasksTimer(this, &MainThreadTaskRunner::pendingTasksTimerFired) | 40 , m_pendingTasksTimer(this, &MainThreadTaskRunner::pendingTasksTimerFired) |
| 41 , m_suspended(false) | 41 , m_suspended(false) |
| 42 , m_weakFactory(this) | 42 , m_weakFactory(this) |
| 43 { | 43 { |
| 44 } | 44 } |
| 45 | 45 |
| 46 MainThreadTaskRunner::~MainThreadTaskRunner() | 46 MainThreadTaskRunner::~MainThreadTaskRunner() |
| 47 { | 47 { |
| 48 } | 48 } |
| 49 | 49 |
| 50 void MainThreadTaskRunner::postTaskInternal(const WebTraceLocation& location, st
d::unique_ptr<ExecutionContextTask> task, bool isInspectorTask, bool instrumenti
ng) | 50 void MainThreadTaskRunner::postTaskInternal(const WebTraceLocation& location, st
d::unique_ptr<ExecutionContextTask> task, bool isInspectorTask, bool instrumenti
ng) |
| 51 { | 51 { |
| 52 Platform::current()->mainThread()->getWebTaskRunner()->postTask(location, th
readSafeBind( | 52 Platform::current()->mainThread()->getWebTaskRunner()->postTask(location, cr
ossThreadBind( |
| 53 &MainThreadTaskRunner::perform, | 53 &MainThreadTaskRunner::perform, |
| 54 m_weakFactory.createWeakPtr(), | 54 m_weakFactory.createWeakPtr(), |
| 55 passed(std::move(task)), | 55 passed(std::move(task)), |
| 56 isInspectorTask, | 56 isInspectorTask, |
| 57 instrumenting)); | 57 instrumenting)); |
| 58 } | 58 } |
| 59 | 59 |
| 60 void MainThreadTaskRunner::postTask(const WebTraceLocation& location, std::uniqu
e_ptr<ExecutionContextTask> task, const String& taskNameForInstrumentation) | 60 void MainThreadTaskRunner::postTask(const WebTraceLocation& location, std::uniqu
e_ptr<ExecutionContextTask> task, const String& taskNameForInstrumentation) |
| 61 { | 61 { |
| 62 if (!taskNameForInstrumentation.isEmpty()) | 62 if (!taskNameForInstrumentation.isEmpty()) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 while (!m_pendingTasks.isEmpty()) { | 112 while (!m_pendingTasks.isEmpty()) { |
| 113 std::unique_ptr<ExecutionContextTask> task = std::move(m_pendingTasks[0]
.first); | 113 std::unique_ptr<ExecutionContextTask> task = std::move(m_pendingTasks[0]
.first); |
| 114 const bool instrumenting = m_pendingTasks[0].second; | 114 const bool instrumenting = m_pendingTasks[0].second; |
| 115 m_pendingTasks.remove(0); | 115 m_pendingTasks.remove(0); |
| 116 InspectorInstrumentation::AsyncTask asyncTask(m_context, task.get(), ins
trumenting); | 116 InspectorInstrumentation::AsyncTask asyncTask(m_context, task.get(), ins
trumenting); |
| 117 task->performTask(m_context); | 117 task->performTask(m_context); |
| 118 } | 118 } |
| 119 } | 119 } |
| 120 | 120 |
| 121 } // namespace blink | 121 } // namespace blink |
| OLD | NEW |