Chromium Code Reviews| Index: Source/platform/scheduler/Scheduler.cpp |
| diff --git a/Source/platform/scheduler/Scheduler.cpp b/Source/platform/scheduler/Scheduler.cpp |
| index fb331ac6e3766aad23db042059ad0c43b549bb18..c196d8f20c186616dfdfcd51218e305da7d01c99 100644 |
| --- a/Source/platform/scheduler/Scheduler.cpp |
| +++ b/Source/platform/scheduler/Scheduler.cpp |
| @@ -73,8 +73,8 @@ public: |
| class Scheduler::MainThreadPendingTaskRunner : public WebThread::Task { |
| public: |
| MainThreadPendingTaskRunner( |
| - const Scheduler::Task& task, const TraceLocation& location) |
| - : m_task(task, location) |
| + const Scheduler::Task& task, const TraceLocation& location, const char* traceName, int flowTraceID) |
| + : m_task(task, location, traceName, flowTraceID) |
| { |
| ASSERT(Scheduler::shared()); |
| } |
| @@ -90,7 +90,7 @@ public: |
| m_task.run(); |
| } |
| - Scheduler::TracedTask m_task; |
| + TracedTask m_task; |
| }; |
| Scheduler* Scheduler::s_sharedScheduler = nullptr; |
| @@ -115,6 +115,9 @@ Scheduler::Scheduler() |
| : m_sharedTimerFunction(nullptr) |
| , m_mainThread(blink::Platform::current()->currentThread()) |
| , m_highPriorityTaskCount(0) |
| + // flow trace ID begins as the 'this' pointer to help ensure different scheduler |
| + // instances don't generate identical IDs |
| + , m_nextFlowTraceID(static_cast<int>(reinterpret_cast<intptr_t>(this))) |
| , m_highPriorityTaskRunnerPosted(false) |
| { |
| } |
| @@ -126,31 +129,40 @@ Scheduler::~Scheduler() |
| } |
| } |
| +int Scheduler::generateFlowTraceID() |
| +{ |
| + return atomicIncrement(&m_nextFlowTraceID); |
| +} |
| + |
| void Scheduler::scheduleIdleTask(const TraceLocation& location, const IdleTask& idleTask) |
| { |
| // TODO: send a real allottedTime here. |
| m_mainThread->postTask(new MainThreadIdleTaskAdapter(idleTask, 0, location)); |
| } |
| +void Scheduler::postHighPriorityTaskInternal(const TraceLocation& location, const Task& task, const char * traceName) |
| +{ |
| + Locker<Mutex> lock(m_pendingTasksMutex); |
| + |
| + TracedTask tracedTask = TracedTask(task, location, traceName, generateFlowTraceID()); |
|
alexclarke
2014/09/01 11:24:20
How about:
m_pendingHighPriorityTasks.append(Trac
picksi1
2014/09/01 13:33:48
In general I like to break complex lines down to a
|
| + m_pendingHighPriorityTasks.append(tracedTask); |
| + atomicIncrement(&m_highPriorityTaskCount); |
| + maybePostMainThreadPendingHighPriorityTaskRunner(); |
| +} |
| + |
| void Scheduler::postTask(const TraceLocation& location, const Task& task) |
| { |
| - m_mainThread->postTask(new MainThreadPendingTaskRunner(task, location)); |
| + m_mainThread->postTask(new MainThreadPendingTaskRunner(task, location, "Scheduler::MainThreadTask", generateFlowTraceID())); |
| } |
| void Scheduler::postInputTask(const TraceLocation& location, const Task& task) |
| { |
| - Locker<Mutex> lock(m_pendingTasksMutex); |
| - m_pendingHighPriorityTasks.append(TracedTask(task, location)); |
| - atomicIncrement(&m_highPriorityTaskCount); |
| - maybePostMainThreadPendingHighPriorityTaskRunner(); |
| + postHighPriorityTaskInternal(location, task, "Scheduler::InputTask"); |
| } |
| void Scheduler::postCompositorTask(const TraceLocation& location, const Task& task) |
| { |
| - Locker<Mutex> lock(m_pendingTasksMutex); |
| - m_pendingHighPriorityTasks.append(TracedTask(task, location)); |
| - atomicIncrement(&m_highPriorityTaskCount); |
| - maybePostMainThreadPendingHighPriorityTaskRunner(); |
| + postHighPriorityTaskInternal(location, task, "Scheduler::CompositorTask"); |
| } |
| void Scheduler::maybePostMainThreadPendingHighPriorityTaskRunner() |
| @@ -256,12 +268,4 @@ bool Scheduler::hasPendingHighPriorityWork() const |
| return acquireLoad(&m_highPriorityTaskCount) != 0; |
| } |
| -void Scheduler::TracedTask::run() |
| -{ |
| - TRACE_EVENT2("blink", "TracedTask::run", |
| - "src_file", m_location.fileName(), |
| - "src_func", m_location.functionName()); |
| - m_task(); |
| -} |
| - |
| } // namespace blink |