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

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

Issue 656463004: Use the scheduling mechanism provided by the platform (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Mike's comments. Created 6 years, 1 month 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/WebKit.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "platform/scheduler/TracedTask.h"
7 #include "platform/scheduler/Scheduler.h"
8 #include "wtf/PassOwnPtr.h"
9
10 namespace blink {
11 namespace internal {
12
13 volatile int TracedTask::s_nextFlowTraceID = 0;
14
15 TracedTask::TracedTask(const TraceLocation& location, const char* traceName)
16 : m_location(location)
17 , m_traceName(traceName)
18 {
19 bool tracingEnabled;
20 TRACE_EVENT_CATEGORY_GROUP_ENABLED("blink", &tracingEnabled);
21
22 if (tracingEnabled) {
23 // atomicIncrement is slow so we only do it if tracing is enabled
24 m_flowTraceID = static_cast<uint64_t>(atomicIncrement(&s_nextFlowTraceID ));
25
26 TRACE_EVENT_FLOW_BEGIN2("blink", m_traceName, MANGLE(m_flowTraceID),
27 "src_file", m_location.fileName(),
28 "src_func", m_location.functionName());
29 }
30 }
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
97 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/scheduler/TracedTask.h ('k') | Source/web/WebKit.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698