| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 #else | 63 #else |
| 64 AllowCrossThreadAccess(m_weakFactory.createWeakPtr()), | 64 AllowCrossThreadAccess(m_weakFactory.createWeakPtr()), |
| 65 #endif | 65 #endif |
| 66 task, | 66 task, |
| 67 isInspectorTask)); | 67 isInspectorTask)); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void MainThreadTaskRunner::postTask(const WebTraceLocation& location, PassOwnPtr
<ExecutionContextTask> task) | 70 void MainThreadTaskRunner::postTask(const WebTraceLocation& location, PassOwnPtr
<ExecutionContextTask> task) |
| 71 { | 71 { |
| 72 if (!task->taskNameForInstrumentation().isEmpty()) | 72 if (!task->taskNameForInstrumentation().isEmpty()) |
| 73 InspectorInstrumentation::didPostExecutionContextTask(m_context, task.ge
t()); | 73 InspectorInstrumentation::scheduleAsyncTask(m_context, "postTask", task.
get()); |
| 74 postTaskInternal(location, task, false); | 74 postTaskInternal(location, task, false); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void MainThreadTaskRunner::postInspectorTask(const WebTraceLocation& location, P
assOwnPtr<ExecutionContextTask> task) | 77 void MainThreadTaskRunner::postInspectorTask(const WebTraceLocation& location, P
assOwnPtr<ExecutionContextTask> task) |
| 78 { | 78 { |
| 79 postTaskInternal(location, task, true); | 79 postTaskInternal(location, task, true); |
| 80 } | 80 } |
| 81 | 81 |
| 82 void MainThreadTaskRunner::perform(PassOwnPtr<ExecutionContextTask> task, bool i
sInspectorTask) | 82 void MainThreadTaskRunner::perform(PassOwnPtr<ExecutionContextTask> task, bool i
sInspectorTask) |
| 83 { | 83 { |
| 84 if (!isInspectorTask && (m_context->tasksNeedSuspension() || !m_pendingTasks
.isEmpty())) { | 84 if (!isInspectorTask && (m_context->tasksNeedSuspension() || !m_pendingTasks
.isEmpty())) { |
| 85 m_pendingTasks.append(task); | 85 m_pendingTasks.append(task); |
| 86 return; | 86 return; |
| 87 } | 87 } |
| 88 | 88 |
| 89 const bool instrumenting = !isInspectorTask && !task->taskNameForInstrumenta
tion().isEmpty(); | 89 if (!isInspectorTask) |
| 90 if (instrumenting) | 90 InspectorInstrumentation::asyncTaskStarted(m_context, task.get()); |
| 91 InspectorInstrumentation::willPerformExecutionContextTask(m_context, tas
k.get()); | |
| 92 task->performTask(m_context); | 91 task->performTask(m_context); |
| 93 if (instrumenting) | 92 if (!isInspectorTask) |
| 94 InspectorInstrumentation::didPerformExecutionContextTask(m_context); | 93 InspectorInstrumentation::asyncTaskFinished(m_context, task.get()); |
| 95 } | 94 } |
| 96 | 95 |
| 97 void MainThreadTaskRunner::suspend() | 96 void MainThreadTaskRunner::suspend() |
| 98 { | 97 { |
| 99 ASSERT(!m_suspended); | 98 ASSERT(!m_suspended); |
| 100 m_pendingTasksTimer.stop(); | 99 m_pendingTasksTimer.stop(); |
| 101 m_suspended = true; | 100 m_suspended = true; |
| 102 } | 101 } |
| 103 | 102 |
| 104 void MainThreadTaskRunner::resume() | 103 void MainThreadTaskRunner::resume() |
| 105 { | 104 { |
| 106 ASSERT(m_suspended); | 105 ASSERT(m_suspended); |
| 107 if (!m_pendingTasks.isEmpty()) | 106 if (!m_pendingTasks.isEmpty()) |
| 108 m_pendingTasksTimer.startOneShot(0, BLINK_FROM_HERE); | 107 m_pendingTasksTimer.startOneShot(0, BLINK_FROM_HERE); |
| 109 | 108 |
| 110 m_suspended = false; | 109 m_suspended = false; |
| 111 } | 110 } |
| 112 | 111 |
| 113 void MainThreadTaskRunner::pendingTasksTimerFired(Timer<MainThreadTaskRunner>*) | 112 void MainThreadTaskRunner::pendingTasksTimerFired(Timer<MainThreadTaskRunner>*) |
| 114 { | 113 { |
| 115 while (!m_pendingTasks.isEmpty()) { | 114 while (!m_pendingTasks.isEmpty()) { |
| 116 OwnPtr<ExecutionContextTask> task = m_pendingTasks[0].release(); | 115 OwnPtr<ExecutionContextTask> task = m_pendingTasks[0].release(); |
| 117 m_pendingTasks.remove(0); | 116 m_pendingTasks.remove(0); |
| 118 const bool instrumenting = !task->taskNameForInstrumentation().isEmpty()
; | 117 const bool instrumenting = !task->taskNameForInstrumentation().isEmpty()
; |
| 119 if (instrumenting) | 118 if (instrumenting) |
| 120 InspectorInstrumentation::willPerformExecutionContextTask(m_context,
task.get()); | 119 InspectorInstrumentation::asyncTaskStarted(m_context, task.get()); |
| 121 task->performTask(m_context); | 120 task->performTask(m_context); |
| 122 if (instrumenting) | 121 if (instrumenting) |
| 123 InspectorInstrumentation::didPerformExecutionContextTask(m_context); | 122 InspectorInstrumentation::asyncTaskFinished(m_context, task.get()); |
| 124 } | 123 } |
| 125 } | 124 } |
| 126 | 125 |
| 127 } // namespace blink | 126 } // namespace blink |
| OLD | NEW |