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

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: Fix Expect_EQ 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
« no previous file with comments | « Source/platform/scheduler/TracedTask.h ('k') | Source/web/WebViewImpl.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
8 #include "wtf/PassOwnPtr.h"
7 9
8 namespace blink { 10 namespace blink {
11 namespace internal {
9 12
10 volatile int TracedTask::s_nextFlowTraceID = 0; 13 volatile int TracedTask::s_nextFlowTraceID = 0;
11 14
12 void TracedTask::run() const 15 TracedTask::TracedTask(const TraceLocation& location, const char* traceName)
13 { 16 : 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) 17 , m_traceName(traceName)
27 { 18 {
28 bool tracingEnabled; 19 bool tracingEnabled;
29 TRACE_EVENT_CATEGORY_GROUP_ENABLED("blink", &tracingEnabled); 20 TRACE_EVENT_CATEGORY_GROUP_ENABLED("blink", &tracingEnabled);
30 21
31 if (tracingEnabled) { 22 if (tracingEnabled) {
32 // atomicIncrement is slow so we only do it if tracing is enabled 23 // atomicIncrement is slow so we only do it if tracing is enabled
33 m_flowTraceID = static_cast<uint64_t>(atomicIncrement(&s_nextFlowTraceID )); 24 m_flowTraceID = static_cast<uint64_t>(atomicIncrement(&s_nextFlowTraceID ));
34 25
35 TRACE_EVENT_FLOW_BEGIN2("blink", m_traceName, MANGLE(m_flowTraceID), 26 TRACE_EVENT_FLOW_BEGIN2("blink", m_traceName, MANGLE(m_flowTraceID),
36 "src_file", m_location.fileName(), 27 "src_file", m_location.fileName(),
37 "src_func", m_location.functionName()); 28 "src_func", m_location.functionName());
38 } 29 }
39 } 30 }
40 31
32 TraceLocation TracedTask::getLocation() const
33 {
34 return m_location;
35 }
36
37 const char* TracedTask::getTraceName() const
38 {
39 return m_traceName;
40 }
41
42 void TracedTask::endFlowTraceEvent() const
43 {
44 TRACE_EVENT_FLOW_END0("blink", m_traceName, MANGLE(m_flowTraceID));
45 }
46
47 TracedTask::~TracedTask() { }
48
49 TracedStandardTask::TracedStandardTask(const Task& task, const TraceLocation& lo cation, const char* traceName)
50 : TracedTask(location, traceName)
51 , m_task(task) { }
52
53 TracedStandardTask::~TracedStandardTask() { }
54
55 // static
56 PassOwnPtr<TracedStandardTask> TracedStandardTask::Create(const Task& task, cons t TraceLocation& location, const char* traceName)
57 {
58 return adoptPtr(new TracedStandardTask(task, location, traceName));
59 }
60
61 void TracedStandardTask::run() const
62 {
63 endFlowTraceEvent();
64 TRACE_EVENT2("blink", getTraceName(),
65 "src_file", getLocation().fileName(),
66 "src_func", getLocation().functionName());
67
68 m_task();
69 }
70
71 TracedIdleTask::TracedIdleTask(const IdleTask& idleTask, const TraceLocation& lo cation, const char* traceName)
72 : TracedTask(location, traceName)
73 , m_idleTask(idleTask)
74 {
75 ASSERT(Scheduler::shared());
76 }
77
78 TracedIdleTask::~TracedIdleTask() { }
79
80 // static
81 PassOwnPtr<TracedIdleTask> TracedIdleTask::Create(const IdleTask& idleTask, cons t TraceLocation& location, const char* traceName)
82 {
83 return adoptPtr(new TracedIdleTask(idleTask, location, traceName));
84 }
85
86 void TracedIdleTask::run() const
87 {
88 endFlowTraceEvent();
89 TRACE_EVENT2("blink", getTraceName(),
90 "src_file", getLocation().fileName(),
91 "src_func", getLocation().functionName());
92
93 m_idleTask(Scheduler::shared()->currentFrameDeadlineForIdleTasks());
94 }
95
96 } // namespace internal
41 } // namespace blink 97 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/scheduler/TracedTask.h ('k') | Source/web/WebViewImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698