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 TracedTask::~TracedTask() { } | |
31 | |
32 void TracedTask::traceRun() const | |
33 { | |
34 TRACE_EVENT_FLOW_END0("blink", m_traceName, MANGLE(m_flowTraceID)); | |
35 | |
36 TRACE_EVENT2("blink", m_traceName, | |
37 "src_file", m_location.fileName(), | |
38 "src_func", m_location.functionName()); | |
picksi1
2014/09/25 08:53:31
This function is confusingly named, how about upda
rmcilroy
2014/09/29 17:42:58
Changed to endFlowTraceEvent() (and only deals wit
| |
39 } | |
40 | |
41 TracedStandardTask::TracedStandardTask(const Task& task, const TraceLocation& lo cation, const char* traceName) | |
42 : TracedTask(location, traceName) | |
43 , m_task(task) { } | |
44 | |
45 TracedStandardTask::~TracedStandardTask() { } | |
46 | |
47 void TracedStandardTask::run() const | |
48 { | |
49 traceRun(); | |
50 m_task(); | |
51 } | |
52 | |
53 TracedIdleTask::TracedIdleTask(const IdleTask& idleTask, const TraceLocation& lo cation, const char* traceName) | |
54 : TracedTask(location, traceName) | |
55 , m_idleTask(idleTask) | |
56 { | |
57 ASSERT(Scheduler::shared()); | |
58 } | |
picksi1
2014/09/25 08:53:31
Do we need this ASSERT here? Might there be a situ
rmcilroy
2014/09/29 17:42:57
I think these should only be created by the Schedu
| |
59 | |
60 TracedIdleTask::~TracedIdleTask() { } | |
61 | |
62 void TracedIdleTask::run() const | |
63 { | |
64 Scheduler* scheduler = Scheduler::shared(); | |
Sami
2014/09/24 14:00:40
Another note to self: we should keep |scheduler| a
rmcilroy
2014/09/29 17:42:58
Acknowledged.
| |
65 double availableIdleTime = scheduler->getSecondsUntilFrameDeadline(); | |
rmcilroy
2014/09/24 08:49:18
Simon: I'm not entirely convinced that it is worth
picksi1
2014/09/25 08:53:31
I see what you mean. I wonder if there's the begin
rmcilroy
2014/09/29 17:42:57
The fact that the new patch set passes a deadline
| |
66 if (availableIdleTime > 0) { | |
Sami
2014/09/24 14:00:40
I think there's a race here where the scheduler ca
rmcilroy
2014/09/29 17:42:58
Your right - in the maybeExecuteIdleTask function
| |
67 traceRun(); | |
68 m_idleTask(availableIdleTime * 1000); | |
picksi1
2014/09/25 08:53:31
Are we able to choose a time unit, seconds or mill
rmcilroy
2014/09/29 17:42:57
Change all APIs to seconds.
| |
69 } | |
70 } | |
71 | |
41 } // namespace blink | 72 } // namespace blink |
OLD | NEW |