Chromium Code Reviews| Index: Source/platform/scheduler/TracedTask.cpp |
| diff --git a/Source/platform/scheduler/TracedTask.cpp b/Source/platform/scheduler/TracedTask.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..676e565352327e7ca0f5fa4facc265ca104d64b6 |
| --- /dev/null |
| +++ b/Source/platform/scheduler/TracedTask.cpp |
| @@ -0,0 +1,41 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "config.h" |
| +#include "platform/scheduler/TracedTask.h" |
| + |
| +namespace blink { |
| + |
| +int TracedTask::s_nextFlowTraceID = 0; |
| + |
| +void TracedTask::run() const |
| +{ |
| + TRACE_EVENT_FLOW_END0("blink", m_traceName, TRACE_ID_MANGLE(m_flowTraceID)); |
| + |
| + TRACE_EVENT2("blink", m_traceName, |
| + "src_file", m_location.fileName(), |
| + "src_func", m_location.functionName()); |
| + |
| + m_task(); |
| +} |
| + |
| +TracedTask::TracedTask(const Task& task, const TraceLocation& location, const char* traceName) |
| + : m_task(task) |
| + , m_location(location) |
| + , m_traceName(traceName) |
| +{ |
| + bool tracingEnabled; |
| + TRACE_EVENT_CATEGORY_GROUP_ENABLED("blink", &tracingEnabled); |
|
eseidel
2014/09/04 06:49:13
Is there also a check for flow events? My underst
Sami
2014/09/04 09:51:07
Only whole categories can be enabled or disabled.
|
| + |
| + if (tracingEnabled) { |
| + // atomicIncrement is slow so we only do it if tracing is enabled |
| + m_flowTraceID = atomicIncrement(&s_nextFlowTraceID); |
| + |
| + TRACE_EVENT_FLOW_BEGIN2("blink", m_traceName, TRACE_ID_MANGLE(m_flowTraceID), |
| + "src_file", m_location.fileName(), |
| + "src_func", m_location.functionName()); |
| + } |
| +} |
| + |
| +} // namespace blink |