OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "config.h" | 5 #include "config.h" |
6 #include "platform/scheduler/TracedTask.h" | 6 #include "platform/scheduler/TracedTask.h" |
| 7 #include "platform/scheduler/Scheduler.h" |
7 | 8 |
8 namespace blink { | 9 namespace blink { |
9 | 10 |
10 volatile int TracedTask::s_nextFlowTraceID = 0; | 11 volatile int TracedTask::s_nextFlowTraceID = 0; |
11 | 12 |
12 void TracedTask::run() const | 13 TracedTask::TracedTask(const TraceLocation& location, const char* traceName) |
| 14 : m_location(location) |
| 15 , m_traceName(traceName) |
| 16 { |
| 17 bool tracingEnabled; |
| 18 TRACE_EVENT_CATEGORY_GROUP_ENABLED("blink", &tracingEnabled); |
| 19 |
| 20 if (tracingEnabled) { |
| 21 // atomicIncrement is slow so we only do it if tracing is enabled |
| 22 m_flowTraceID = static_cast<uint64_t>(atomicIncrement(&s_nextFlowTraceID
)); |
| 23 |
| 24 TRACE_EVENT_FLOW_BEGIN2("blink", m_traceName, MANGLE(m_flowTraceID), |
| 25 "src_file", m_location.fileName(), |
| 26 "src_func", m_location.functionName()); |
| 27 } |
| 28 } |
| 29 |
| 30 void TracedTask::endFlowTraceEvent() const |
13 { | 31 { |
14 TRACE_EVENT_FLOW_END0("blink", m_traceName, MANGLE(m_flowTraceID)); | 32 TRACE_EVENT_FLOW_END0("blink", m_traceName, MANGLE(m_flowTraceID)); |
| 33 } |
15 | 34 |
| 35 TracedTask::~TracedTask() { } |
| 36 |
| 37 TracedStandardTask::TracedStandardTask(const Task& task, const TraceLocation& lo
cation, const char* traceName) |
| 38 : TracedTask(location, traceName) |
| 39 , m_task(task) { } |
| 40 |
| 41 TracedStandardTask::~TracedStandardTask() { } |
| 42 |
| 43 void TracedStandardTask::run() const |
| 44 { |
| 45 endFlowTraceEvent(); |
16 TRACE_EVENT2("blink", m_traceName, | 46 TRACE_EVENT2("blink", m_traceName, |
17 "src_file", m_location.fileName(), | 47 "src_file", m_location.fileName(), |
18 "src_func", m_location.functionName()); | 48 "src_func", m_location.functionName()); |
19 | 49 |
20 m_task(); | 50 m_task(); |
21 } | 51 } |
22 | 52 |
23 TracedTask::TracedTask(const Task& task, const TraceLocation& location, const ch
ar* traceName) | 53 TracedIdleTask::TracedIdleTask(const IdleTask& idleTask, const TraceLocation& lo
cation, const char* traceName) |
24 : m_task(task) | 54 : TracedTask(location, traceName) |
25 , m_location(location) | 55 , m_idleTask(idleTask) |
26 , m_traceName(traceName) | |
27 { | 56 { |
28 bool tracingEnabled; | 57 ASSERT(Scheduler::shared()); |
29 TRACE_EVENT_CATEGORY_GROUP_ENABLED("blink", &tracingEnabled); | 58 } |
30 | 59 |
31 if (tracingEnabled) { | 60 TracedIdleTask::~TracedIdleTask() { } |
32 // atomicIncrement is slow so we only do it if tracing is enabled | |
33 m_flowTraceID = static_cast<uint64_t>(atomicIncrement(&s_nextFlowTraceID
)); | |
34 | 61 |
35 TRACE_EVENT_FLOW_BEGIN2("blink", m_traceName, MANGLE(m_flowTraceID), | 62 void TracedIdleTask::run() const |
| 63 { |
| 64 endFlowTraceEvent(); |
| 65 TRACE_EVENT2("blink", m_traceName, |
36 "src_file", m_location.fileName(), | 66 "src_file", m_location.fileName(), |
37 "src_func", m_location.functionName()); | 67 "src_func", m_location.functionName()); |
38 } | 68 |
| 69 m_idleTask(Scheduler::shared()->currentFrameDeadlineForIdleTasks()); |
39 } | 70 } |
40 | 71 |
41 } // namespace blink | 72 } // namespace blink |
OLD | NEW |