#include "config.h"
#include "core/dom/MainThreadTaskRunner.h"
-#include "core/dom/Document.h"
+#include "core/dom/ExecutionContext.h"
#include "core/dom/ExecutionContextTask.h"
+#include "core/inspector/InspectorInstrumentation.h"
#include "wtf/Assertions.h"
+#include "wtf/MainThread.h"
-namespace WebCore {
+namespace blink {
struct PerformTaskContext {
WTF_MAKE_NONCOPYABLE(PerformTaskContext); WTF_MAKE_FAST_ALLOCATED;
public:
- PerformTaskContext(WeakPtr<MainThreadTaskRunner> runner, PassOwnPtr<ExecutionContextTask> task)
+ PerformTaskContext(WeakPtr<MainThreadTaskRunner> runner, PassOwnPtr<ExecutionContextTask> task, bool isInspectorTask)
: m_runner(runner)
, m_task(task)
+ , m_isInspectorTask(isInspectorTask)
{
}
WeakPtr<MainThreadTaskRunner> m_runner;
OwnPtr<ExecutionContextTask> m_task;
+ bool m_isInspectorTask;
static void didReceiveTask(void* untypedContext);
};
MainThreadTaskRunner* runner = self->m_runner.get();
if (!runner)
return;
- runner->perform(self->m_task.release());
+ runner->perform(self->m_task.release(), self->m_isInspectorTask);
}
MainThreadTaskRunner::MainThreadTaskRunner(ExecutionContext* context)
void MainThreadTaskRunner::postTask(PassOwnPtr<ExecutionContextTask> task)
{
- callOnMainThread(PerformTaskContext::didReceiveTask, new PerformTaskContext(m_weakFactory.createWeakPtr(), task));
+ if (!task->taskNameForInstrumentation().isEmpty())
+ InspectorInstrumentation::didPostExecutionContextTask(m_context, task.get());
+ callOnMainThread(PerformTaskContext::didReceiveTask, new PerformTaskContext(m_weakFactory.createWeakPtr(), task, false));
}
-void MainThreadTaskRunner::perform(PassOwnPtr<ExecutionContextTask> task)
+void MainThreadTaskRunner::postInspectorTask(PassOwnPtr<ExecutionContextTask> task)
{
- if (m_context->tasksNeedSuspension() || !m_pendingTasks.isEmpty()) {
+ callOnMainThread(PerformTaskContext::didReceiveTask, new PerformTaskContext(m_weakFactory.createWeakPtr(), task, true));
+}
+
+void MainThreadTaskRunner::perform(PassOwnPtr<ExecutionContextTask> task, bool isInspectorTask)
+{
+ if (!isInspectorTask && (m_context->tasksNeedSuspension() || !m_pendingTasks.isEmpty())) {
m_pendingTasks.append(task);
return;
}
+ const bool instrumenting = !isInspectorTask && !task->taskNameForInstrumentation().isEmpty();
+ if (instrumenting)
+ InspectorInstrumentation::willPerformExecutionContextTask(m_context, task.get());
task->performTask(m_context);
+ if (instrumenting)
+ InspectorInstrumentation::didPerformExecutionContextTask(m_context);
}
void MainThreadTaskRunner::suspend()
while (!m_pendingTasks.isEmpty()) {
OwnPtr<ExecutionContextTask> task = m_pendingTasks[0].release();
m_pendingTasks.remove(0);
+ const bool instrumenting = !task->taskNameForInstrumentation().isEmpty();
+ if (instrumenting)
+ InspectorInstrumentation::willPerformExecutionContextTask(m_context, task.get());
task->performTask(m_context);
+ if (instrumenting)
+ InspectorInstrumentation::didPerformExecutionContextTask(m_context);
}
}