Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Side by Side Diff: Source/platform/scheduler/TracedTask.cpp

Issue 595023002: Implement idle task scheduling. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rename estimatedNextBeginFrameSeconds Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698