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) |
13 { | 14 : m_location(location) |
14 TRACE_EVENT_FLOW_END0("blink", m_traceName, MANGLE(m_flowTraceID)); | |
15 | |
16 TRACE_EVENT2("blink", m_traceName, | |
17 "src_file", m_location.fileName(), | |
18 "src_func", m_location.functionName()); | |
19 | |
20 m_task(); | |
21 } | |
22 | |
23 TracedTask::TracedTask(const Task& task, const TraceLocation& location, const ch
ar* traceName) | |
24 : m_task(task) | |
25 , m_location(location) | |
26 , m_traceName(traceName) | 15 , m_traceName(traceName) |
27 { | 16 { |
28 bool tracingEnabled; | 17 bool tracingEnabled; |
29 TRACE_EVENT_CATEGORY_GROUP_ENABLED("blink", &tracingEnabled); | 18 TRACE_EVENT_CATEGORY_GROUP_ENABLED("blink", &tracingEnabled); |
30 | 19 |
31 if (tracingEnabled) { | 20 if (tracingEnabled) { |
32 // atomicIncrement is slow so we only do it if tracing is enabled | 21 // atomicIncrement is slow so we only do it if tracing is enabled |
33 m_flowTraceID = static_cast<uint64_t>(atomicIncrement(&s_nextFlowTraceID
)); | 22 m_flowTraceID = static_cast<uint64_t>(atomicIncrement(&s_nextFlowTraceID
)); |
34 | 23 |
35 TRACE_EVENT_FLOW_BEGIN2("blink", m_traceName, MANGLE(m_flowTraceID), | 24 TRACE_EVENT_FLOW_BEGIN2("blink", m_traceName, MANGLE(m_flowTraceID), |
36 "src_file", m_location.fileName(), | 25 "src_file", m_location.fileName(), |
37 "src_func", m_location.functionName()); | 26 "src_func", m_location.functionName()); |
38 } | 27 } |
39 } | 28 } |
40 | 29 |
| 30 TraceLocation TracedTask::getLocation() const |
| 31 { |
| 32 return m_location; |
| 33 } |
| 34 |
| 35 const char* TracedTask::getTraceName() const |
| 36 { |
| 37 return m_traceName; |
| 38 } |
| 39 |
| 40 void TracedTask::endFlowTraceEvent() const |
| 41 { |
| 42 TRACE_EVENT_FLOW_END0("blink", m_traceName, MANGLE(m_flowTraceID)); |
| 43 } |
| 44 |
| 45 TracedTask::~TracedTask() { } |
| 46 |
| 47 TracedStandardTask::TracedStandardTask(const Task& task, const TraceLocation& lo
cation, const char* traceName) |
| 48 : TracedTask(location, traceName) |
| 49 , m_task(task) { } |
| 50 |
| 51 TracedStandardTask::~TracedStandardTask() { } |
| 52 |
| 53 void TracedStandardTask::run() const |
| 54 { |
| 55 endFlowTraceEvent(); |
| 56 TRACE_EVENT2("blink", getTraceName(), |
| 57 "src_file", getLocation().fileName(), |
| 58 "src_func", getLocation().functionName()); |
| 59 |
| 60 m_task(); |
| 61 } |
| 62 |
| 63 TracedIdleTask::TracedIdleTask(const IdleTask& idleTask, const TraceLocation& lo
cation, const char* traceName) |
| 64 : TracedTask(location, traceName) |
| 65 , m_idleTask(idleTask) |
| 66 { |
| 67 ASSERT(Scheduler::shared()); |
| 68 } |
| 69 |
| 70 TracedIdleTask::~TracedIdleTask() { } |
| 71 |
| 72 void TracedIdleTask::run() const |
| 73 { |
| 74 endFlowTraceEvent(); |
| 75 TRACE_EVENT2("blink", getTraceName(), |
| 76 "src_file", getLocation().fileName(), |
| 77 "src_func", getLocation().functionName()); |
| 78 |
| 79 m_idleTask(Scheduler::shared()->currentFrameDeadlineForIdleTasks()); |
| 80 } |
| 81 |
41 } // namespace blink | 82 } // namespace blink |
OLD | NEW |